blob_id
stringlengths
40
40
directory_id
stringlengths
40
40
path
stringlengths
3
264
content_id
stringlengths
40
40
detected_licenses
listlengths
0
85
license_type
stringclasses
2 values
repo_name
stringlengths
5
140
snapshot_id
stringlengths
40
40
revision_id
stringlengths
40
40
branch_name
stringclasses
986 values
visit_date
timestamp[us]
revision_date
timestamp[us]
committer_date
timestamp[us]
github_id
int64
3.89k
681M
star_events_count
int64
0
209k
fork_events_count
int64
0
110k
gha_license_id
stringclasses
23 values
gha_event_created_at
timestamp[us]
gha_created_at
timestamp[us]
gha_language
stringclasses
145 values
src_encoding
stringclasses
34 values
language
stringclasses
1 value
is_vendor
bool
1 class
is_generated
bool
2 classes
length_bytes
int64
3
10.4M
extension
stringclasses
122 values
content
stringlengths
3
10.4M
authors
listlengths
1
1
author_id
stringlengths
0
158
94a2b17e4bba50dfe045637151cfa7817290276e
d4e96aa48ddff651558a3fe2212ebb3a3afe5ac3
/Modules/Filtering/BiasCorrection/include/itkMRASlabIdentifier.hxx
bed513de391080321896176bce89ee1ab83e3b4f
[ "SMLNJ", "BSD-3-Clause", "LicenseRef-scancode-free-unknown", "LicenseRef-scancode-mit-old-style", "LicenseRef-scancode-other-permissive", "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-warranty-disclaimer", "NTP", "IJG", "GPL-1.0-or-later", "libtiff", "BSD-4.3TAHOE", "...
permissive
nalinimsingh/ITK_4D
18e8929672df64df58a6446f047e6ec04d3c2616
95a2eacaeaffe572889832ef0894239f89e3f303
refs/heads/master
2020-03-17T18:58:50.953317
2018-10-01T20:46:43
2018-10-01T21:21:01
133,841,430
0
0
Apache-2.0
2018-05-17T16:34:54
2018-05-17T16:34:53
null
UTF-8
C++
false
false
5,556
hxx
/*========================================================================= * * Copyright Insight Software Consortium * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0.txt * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * *=========================================================================*/ #ifndef itkMRASlabIdentifier_hxx #define itkMRASlabIdentifier_hxx #include <algorithm> #include <vector> #include <queue> #include "itkMRASlabIdentifier.h" #include "itkImageRegionIterator.h" #include "itkMath.h" namespace itk { template< typename TInputImage > MRASlabIdentifier< TInputImage > ::MRASlabIdentifier() { m_Image = ITK_NULLPTR; m_NumberOfSamples = 10; m_BackgroundMinimumThreshold = NumericTraits< ImagePixelType >::min(); m_Tolerance = 0.0; // default slicing axis is z m_SlicingDirection = 2; } template< typename TInputImage > void MRASlabIdentifier< TInputImage > ::GenerateSlabRegions(void) { // this method only works with 3D MRI image if ( ImageType::ImageDimension != 3 ) { itkExceptionMacro("ERROR: This algorithm only works with 3D images."); } ImageSizeType size; ImageRegionType region; ImageIndexType index; region = m_Image->GetLargestPossibleRegion(); size = region.GetSize(); index = region.GetIndex(); IndexValueType firstSlice = index[m_SlicingDirection]; IndexValueType lastSlice = firstSlice + size[m_SlicingDirection]; SizeValueType totalSlices = size[m_SlicingDirection]; double sum; std::vector< double > avgMin(totalSlices); // calculate minimum intensities for each slice ImagePixelType pixel; for ( int i = 0; i < 3; i++ ) { if ( i != m_SlicingDirection ) { index[i] = 0; } } size[m_SlicingDirection] = 1; region.SetSize(size); SizeValueType count = 0; IndexValueType currentSlice = firstSlice; while ( currentSlice < lastSlice ) { index[m_SlicingDirection] = currentSlice; region.SetIndex(index); ImageRegionConstIterator< TInputImage > iter(m_Image, region); iter.GoToBegin(); std::priority_queue< ImagePixelType > mins; for ( unsigned int i = 0; i < m_NumberOfSamples; ++i ) { mins.push( NumericTraits< ImagePixelType >::max() ); } while ( !iter.IsAtEnd() ) { pixel = iter.Get(); if ( pixel > m_BackgroundMinimumThreshold ) { if ( mins.top() > pixel ) { mins.pop(); mins.push(pixel); } } ++iter; } sum = 0.0; while ( !mins.empty() ) { sum += mins.top(); mins.pop(); } avgMin[count] = sum / (double)m_NumberOfSamples; ++count; ++currentSlice; } // calculate overall average sum = 0.0; std::vector< double >::iterator am_iter = avgMin.begin(); while ( am_iter != avgMin.end() ) { sum += *am_iter; ++am_iter; } double average = sum / (double)totalSlices; // determine slabs am_iter = avgMin.begin(); double prevSign = *am_iter - average; double avgMinValue; ImageIndexType slabIndex; ImageRegionType slabRegion; ImageSizeType slabSize; SizeValueType slabLength = 0; IndexValueType slabBegin = firstSlice; slabSize = size; slabIndex = index; while ( am_iter != avgMin.end() ) { avgMinValue = *am_iter; double sign = avgMinValue - average; if ( ( sign * prevSign < 0 ) && ( itk::Math::abs(sign) > m_Tolerance ) ) { slabIndex[m_SlicingDirection] = slabBegin; slabSize[m_SlicingDirection] = slabLength; slabRegion.SetSize(slabSize); slabRegion.SetIndex(slabIndex); m_Slabs.push_back(slabRegion); prevSign = sign; slabBegin += slabLength; slabLength = 0; } am_iter++; slabLength++; } slabIndex[m_SlicingDirection] = slabBegin; slabSize[m_SlicingDirection] = slabLength; slabRegion.SetIndex(slabIndex); slabRegion.SetSize(slabSize); m_Slabs.push_back(slabRegion); } template< typename TInputImage > typename MRASlabIdentifier< TInputImage >::SlabRegionVectorType MRASlabIdentifier< TInputImage > ::GetSlabRegionVector(void) { return m_Slabs; } template< typename TInputImage > void MRASlabIdentifier< TInputImage > ::PrintSelf(std::ostream & os, Indent indent) const { Superclass::PrintSelf(os, indent); if ( m_Image ) { os << indent << "Image: " << m_Image << std::endl; } else { os << indent << "Image: " << "(None)" << std::endl; } os << indent << "NumberOfSamples: " << m_NumberOfSamples << std::endl; os << indent << "SlicingDirection: " << m_SlicingDirection << std::endl; os << indent << "Background Pixel Minimum Intensity Threshold: " << m_BackgroundMinimumThreshold << std::endl; os << indent << "Tolerance: " << m_Tolerance << std::endl; } } // end namespace itk #endif /* itkMRASlabIdentifier_hxx */
[ "ruizhi@csail.mit.edu" ]
ruizhi@csail.mit.edu
4044d70d1203a0c918ed9628b793b6c3ec5db78b
4bea57e631734f8cb1c230f521fd523a63c1ff23
/projects/openfoam/rarefied-flows/impingment/sims/test/nozzle1/5.28/uniform/time
d9cf1386a521bbe82bce01c30bc277698868fd52
[]
no_license
andytorrestb/cfal
76217f77dd43474f6b0a7eb430887e8775b78d7f
730fb66a3070ccb3e0c52c03417e3b09140f3605
refs/heads/master
2023-07-04T01:22:01.990628
2021-08-01T15:36:17
2021-08-01T15:36:17
294,183,829
1
0
null
null
null
null
UTF-8
C++
false
false
997
/*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | | \\ / O peration | Version: v1912 | | \\ / A nd | Website: www.openfoam.com | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ FoamFile { version 2.0; format ascii; class dictionary; location "5.28/uniform"; object time; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // value 5.2800000000010332; name "5.28"; index 52800; deltaT 0.0001; deltaT0 0.0001; // ************************************************************************* //
[ "andytorrestb@gmail.com" ]
andytorrestb@gmail.com
2cb322bc8a90873b2ceb33986989428105b29638
befaf0dfc5880d18f42e1fa7e39e27f8d2f8dde9
/SDK/SCUM_Event_1H_N9_Black_classes.hpp
13aa8cb779d7f6fbda9437758eb6250763fcb567
[]
no_license
cpkt9762/SCUM-SDK
0b59c99748a9e131eb37e5e3d3b95ebc893d7024
c0dbd67e10a288086120cde4f44d60eb12e12273
refs/heads/master
2020-03-28T00:04:48.016948
2018-09-04T13:32:38
2018-09-04T13:32:38
null
0
0
null
null
null
null
UTF-8
C++
false
false
936
hpp
#pragma once // SCUM (0.1.17.8320) SDK #ifdef _MSC_VER #pragma pack(push, 0x8) #endif #include "SCUM_Event_1H_N9_Black_structs.hpp" namespace SDK { //--------------------------------------------------------------------------- //Classes //--------------------------------------------------------------------------- // BlueprintGeneratedClass Event_1H_N9_Black.Event_1H_N9_Black_C // 0x0008 (0x07D8 - 0x07D0) class AEvent_1H_N9_Black_C : public AWeaponItem { public: class UMeleeAttackCollisionCapsule* MeleeAttackCollisionCapsule; // 0x07D0(0x0008) (CPF_BlueprintVisible, CPF_ZeroConstructor, CPF_InstancedReference, CPF_IsPlainOldData) static UClass* StaticClass() { static auto ptr = UObject::FindObject<UClass>("BlueprintGeneratedClass Event_1H_N9_Black.Event_1H_N9_Black_C"); return ptr; } void UserConstructionScript(); }; } #ifdef _MSC_VER #pragma pack(pop) #endif
[ "igromanru@yahoo.de" ]
igromanru@yahoo.de
5641674050dc7e13bc0bb8f371f545a6d4a5253e
515a28f08f58aaab7e277c90c7902c21bc8f4125
/src/lipservice/PLOTR/Card5/Xstep.hpp
b6140e4907664e0f8df6a964df71224a59b30030
[ "BSD-2-Clause" ]
permissive
njoy/lipservice
e3bf4c8c07d79a46c13a88976f22ee07e416f4a6
1efa5e9452384a7bfc278fde57979c4d91e312c0
refs/heads/master
2023-08-04T11:01:04.411539
2021-01-20T22:24:17
2021-01-20T22:24:17
146,359,436
0
2
NOASSERTION
2023-07-25T19:41:10
2018-08-27T22:05:50
C++
UTF-8
C++
false
false
840
hpp
struct Xstep { using Value_t = std::optional< double >; static std::string name(){ return "xstep"; } static std::string description(){ return "The xstep argument specifies the spacing for tics on the energy (x)\n" "axis.\n\n" "The default behavior is automatic scaling. If the default is used,\n" "the default should be used for el and eh as well.\n\n" "The value is ignored if log scaling is used."; } static Value_t defaultValue(){ // const Value_t el ){ // if( el != std::nullopt ){ // Log::info( "When using a default value in PLOTR::Card5, all values\n" // "should use their default value.\n" ); // std::exception e; // throw e; // } return std::nullopt; } static bool verify( const Value_t v ){ //, const Value_t ){ return *v > 0.0; } };
[ "jlconlin@lanl.gov" ]
jlconlin@lanl.gov
22c7104a287830a94bda85d8159ab52bd06210dc
279238a61d78e867f971902ca1e60e4f559dc266
/ex00/Parser.hpp
dfe584b61ab36493625f5194cb869c4f415ce475
[]
no_license
jferrier34/cpp_d16_2018
3fd914ef540438be81f0ad7cd400a1f67ad24dc5
f0632bab50a69a6ae02f87654868bdda550afd32
refs/heads/master
2023-08-11T22:11:03.563707
2019-01-18T08:06:24
2019-01-18T08:06:24
407,254,421
0
0
null
null
null
null
UTF-8
C++
false
false
344
hpp
/* ** EPITECH PROJECT, 2019 ** Parser.hpp ** File description: ** ex00 */ #ifndef PARSER_H #define PARSER_H #include <stack> #include <string> class Parser { std::stack<char> _operators; std::stack<int> _operands; public: Parser(); ~Parser(); void feed(std::string const&); int result() const; void reset(); }; #endif
[ "jferrier@localhost.localdomain" ]
jferrier@localhost.localdomain
c3fc7ad56d655dd15cecf126d2ab982269fa55a2
bac1c0c112e93e0838e622246d2a5be6c2c00219
/server/Server.hpp
404ba084d8a64b36a04d3834720a872bca7f8a10
[]
no_license
ThoSe1990/cppDatabase
bc1135dd83ff93b216a5135f0d2fc9295e8e81aa
6a65aaaa4a49623892a9fa965b322bbd10ea0f57
refs/heads/master
2023-05-06T13:07:39.408098
2021-05-27T10:49:16
2021-05-27T10:49:16
370,110,951
0
0
null
null
null
null
UTF-8
C++
false
false
2,111
hpp
#ifndef _SERVER_SERVER_HPP_ #define _SERVER_SERVER_HPP_ #include <iostream> #include <boost/asio.hpp> #include "DatabaseServerApi.hpp" using boost::asio::ip::tcp; class Session : public std::enable_shared_from_this<Session> { public: Session(tcp::socket Socket) : socket(std::move(Socket)){ } void Run() { std::cout << "session created" << std::endl; waitForRequest(); } private: tcp::socket socket; boost::asio::streambuf buffer; const std::string end_of_stream{"<EOF>"}; void waitForRequest() { auto self(shared_from_this()); boost::asio::async_read_until(socket, buffer, end_of_stream, [this, self](boost::system::error_code ec, std::size_t /*length*/) { if (!ec) { std::string serializedData { buffers_begin(buffer.data()), buffers_end(buffer.data()) - end_of_stream.length() }; buffer.consume(buffer.size()); DatabaseServerApi::HandleRequest(std::move(serializedData), socket); DatabaseServerApi::Update(); waitForRequest(); } else std::cout << "error: " << ec << std::endl;; }); } }; class Server { public: Server(boost::asio::io_context& io_context, short port) : acceptor(io_context, tcp::endpoint(tcp::v4(), port)) { do_accept(); } private: tcp::acceptor acceptor; void do_accept() { acceptor.async_accept( [this](boost::system::error_code ec, tcp::socket socket) { if (!ec) { std::cout << "creating session on: " << socket.remote_endpoint().address().to_string() << ":" << socket.remote_endpoint().port() << std::endl; std::make_shared<Session>(std::move(socket))->Run(); } else std::cout << "error: " << ec.message() << std::endl; do_accept(); }); } }; #endif
[ "thomas.sedlmair@googlemail.com" ]
thomas.sedlmair@googlemail.com
dd6d645e31a92c36f75c359761b9bc42bc0b8405
2bbca1dd862b65b9a1aa5bd4fc5402a557e4036f
/qspotifyutil.h
c56aedc11ae6982cac76be970b9314987d8c4512
[]
no_license
juiceme/libQtSpotify
5bb5397d37a7e3a9110dfc8385dbd7fbe639660b
9cf1ef4752522552370c426e2861cdedde6c20da
refs/heads/master
2020-03-21T10:44:51.612525
2018-03-22T14:35:29
2018-03-22T14:35:29
null
0
0
null
null
null
null
UTF-8
C++
false
false
274
h
#ifndef QSPOTIFYUTIL_H #define QSPOTIFYUTIL_H #include <functional> class QString; struct sp_link; class QSpotifyUtil { public: QSpotifyUtil(); static void spLinkToQString(sp_link *link, std::function<void(const QString&)> consumer); }; #endif // QSPOTIFYUTIL_H
[ "lukedirtwalker@gmail.com" ]
lukedirtwalker@gmail.com
1a053157bbfa0c84e5df398342732dd2b173bb81
c42aa20328948971e0f28fc29d3547b6f3bab693
/player/common.cpp
136bc6b4f1c1a16619ece901be4fb70cd9acf219
[]
no_license
JarrettBillingsley/DecompilingSonic1
9d3cca3b68c0af48675a41b2a95d6d18301980f9
3238a55ac642cf8f8b0e26b61727c295290173af
refs/heads/master
2020-03-29T09:57:05.815554
2015-11-11T22:49:14
2015-11-11T22:49:14
42,833,717
6
3
null
2020-02-14T17:26:34
2015-09-20T23:29:45
C++
UTF-8
C++
false
false
3,607
cpp
bool Player_IsFlipped () { return Obj_IsFlipped(v_player); } bool Player_IsInAir () { return Obj_IsInAir(v_player); } bool Player_IsRolling () { return Obj_IsRolling(v_player); } bool Player_IsStanding () { return Obj_IsStanding(v_player); } bool Player_IsJumping () { return Obj_IsJumping(v_player); } bool Player_IsPushing () { return Obj_IsPushing(v_player); } bool Player_IsUnderwater() { return Obj_IsUnderwater(v_player); } void Player_SetFlipped (bool val = true) { Obj_SetFlipped (v_player, val); } void Player_SetInAir (bool val = true) { Obj_SetInAir (v_player, val); } void Player_SetRolling (bool val = true) { Obj_SetRolling (v_player, val); } void Player_SetStanding (bool val = true) { Obj_SetStanding (v_player, val); } void Player_SetJumping (bool val = true) { Obj_SetJumping (v_player, val); } void Player_SetPushing (bool val = true) { Obj_SetPushing (v_player, val); } void Player_SetUnderwater(bool val = true) { Obj_SetUnderwater(v_player, val); } void Player_SetNotFlipped() { Obj_SetNotFlipped(v_player); } void Player_SetNotInAir() { Obj_SetNotInAir(v_player); } void Player_SetNotRolling() { Obj_SetNotRolling(v_player); } void Player_SetNotStanding() { Obj_SetNotStanding(v_player); } void Player_SetNotJumping() { Obj_SetNotJumping(v_player); } void Player_SetNotPushing() { Obj_SetNotPushing(v_player); } void Player_SetNotUnderwater() { Obj_SetNotUnderwater(v_player); } bool Player_IsDead() { return v_player->routine >= PlayerRoutine_Dead; } bool Player_IsControllable() { return v_player->routine < PlayerRoutine_Hurt; } void Player_SetHurt() { v_player->routine = PlayerRoutine_Hurt; } void Player_SetDead() { v_player->routine = PlayerRoutine_Dead; } void Player_SetAnimFloat() { v_player->anim = 0xF; } void Player_SetAnimDrowning() { v_player->anim = 0x17; } void Player_SetAnimSlide() { v_player->anim = 0x1F; } // a0 a2 void Player_Hurt(Object* player, Object* obj) { // If he has no shield.. if(!v_shield) { // if he has rings, make the rings spill out if(v_rings) { if(auto ringLoss = FindFreeObj()) { ringLoss->id = ID_RingLoss; ringLoss->x = player->x; ringLoss->y = player->y; } } else if(!f_debugmode) // otherwise, kill him (if debug mode isn't on) { Player_Kill(player, obj); return; } } // Hurt sonic v_shield = 0; Player_SetHurt(); Player_ResetOnFloor(player); Player_SetInAir(); // Bounce him away if(Player_IsUnderwater()) { player->velY = -0x200; player->velX = -0x100; } else { player->velY = -0x400; player->velX = -0x200; } // Make him bounce right if he's to the right of the object if(player->x > obj->x) player->velX = -player->velX; player->inertia = 0; player->anim = Anim::Hurt; VAR_W(player, Player_InvincibilityW) = 120; // 2 seconds of invincibility; // Bwah if(obj->id == ID_Spikes || obj->id == ID_Harpoon) PlaySound_Special(SFX_HitSpikes); else PlaySound_Special(SFX_Death); } // a0 a2 void Player_Kill(Object* player, Object* killer) { if(v_debuguse) return; // Set him up to do the death bounce v_invinc = 0; Player_SetDead(); Player_ResetOnFloor(player); Player_SetInAir(); player->velY = -0x700; player->velX = 0; player->inertia = 0; VAR_W(player, Player_DeathOrigYW) = player->y; player->anim = Anim::Death; BSET(player->gfx, 0x80); // Bwah if(killer->id == ID_Spikes) PlaySound_Special(SFX_HitSpikes); else PlaySound_Special(SFX_Death); }
[ "jarrett.billingsley@gmail.com" ]
jarrett.billingsley@gmail.com
51dd7a27279752184dd0959baf25ba191aa51454
1b904895aa5ba33e0137a962c33cc86a94308c73
/src/game/Game.h
4ed2a7a81f927be65b1bc0ad1b45ed241d26c52b
[ "MIT" ]
permissive
len-m/zombievival
b7105c4fd1eeeab01598eb0df80bb88666e6f561
8894c79bd57e98348e77c2208d593293da2225cd
refs/heads/master
2023-02-12T21:20:12.449988
2021-01-07T19:40:39
2021-01-07T19:40:39
323,917,435
0
0
null
null
null
null
UTF-8
C++
false
false
4,604
h
#ifndef GAME_H #define GAME_H #include <SFML/Graphics.hpp> #include <math.h> #include "Player.h" #include "Enemy.h" #include "Bullet.h" #include <vector> #include <stdlib.h> //srand, rand #include "Collision.h" #include "Chunk.h" #include "UpgradeMenu.h" #include "ItemDrop.h" #include "Trap.h" #include "Inventory.h" #include "../ResourceManager.h" #include <algorithm> class Game { public: Game(sf::RenderWindow *window); void update(const float &deltaTime); void render(); bool getIsActive(); void setIsActive(const bool &newIsActive); bool getIsDead(); bool getIsPaused(); void setIsPaused(const bool &isPaused); private: //general stuff Collision m_collision; int generateRandomNumber(const int &range); float getVectorLength(const sf::Vector2f &vector, const sf::Vector2f &offset); sf::RenderWindow *m_window; sf::View m_view; bool m_isActive; sf::Clock m_gametime; sf::RectangleShape m_field; sf::RectangleShape m_borderLeft; sf::RectangleShape m_borderTop; sf::RectangleShape m_borderRight; sf::RectangleShape m_borderBottom; ResourceManager resourceManager; float m_score; sf::Text m_scoreText; sf::Text m_gameOverText; bool m_isPaused; sf::Text m_isPausedText; //cursor sf::Vector2f m_cursorWorldPosition; sf::Sprite m_cursor; //bullet std::vector<std::shared_ptr<Bullet>> m_bulletVector; sf::Clock m_bulletCooldownClock; float m_bulletSpeed; float m_bulletLifetime; float m_bulletCooldown; bool m_onBulletCooldown; float m_bulletDamage; bool m_playerFiredLastFrame; float m_bulletSpawnAmountRest; //player void move(const sf::Vector2f &movement, const float &deltaTime); void moveOutOfBorder(const float &deltaTime); void shoot(); void takeTrap(); void placeTrap(); std::shared_ptr<Player> m_player; float m_playerMaxLife; float m_movementSpeed; float m_knockbackMovementSpeed; sf::Vector2f m_knockbackStartingPosition; float m_knockbackLength; bool m_dead; //enemy std::vector<std::shared_ptr<Enemy>> m_enemyVector; sf::Clock m_enemySpawnClock; float m_enemySpawnRate; float m_enemySpawnCountDifference; float m_enemySpawnRadius; int m_maxAllowedAliveEnemies; float m_enemyMoveFactor; float m_enemyMaxDistanceFromPlayer; int m_wave; int m_enemiesTotalToBeSpawnedInWave; int m_enemiesSpawnedCount; sf::Text m_waveText; sf::Clock m_waveCooldownClock; bool m_onWaveCooldown; bool m_drawWaveText; float m_waveCooldownLength; std::vector<float> m_enemyTrappedClock; float m_trappedTime; //enemyType float m_enemyNormalDamage; float m_enemyNormalMovementSpeed; float m_enemyNormalMaxLife; float m_enemyTankDamage; float m_enemyTankMovementSpeed; float m_enemyTankMaxLife; //item drops std::vector<std::shared_ptr<ItemDrop>> m_itemDropHeartVector; std::vector<std::shared_ptr<ItemDrop>> m_itemDropCoinVector; std::vector<std::shared_ptr<ItemDrop>> m_itemDropTrapVector; float m_heartLifeRefill; int m_itemDropSpawnRate; int m_coinAmount; //trap bool m_hasTrap; std::vector<std::shared_ptr<Trap>> m_trapVector; float m_trapUseDamage; //damage the trap gets if an enemy steps inside //chunk void canSpawnChunk(bool *canSpawn, sf::Vector2f chunkToBeCheckedForOccupation, sf::Vector2f postion); void spawnChunk(bool canSpawn, sf::Vector2f position); void chunkSpawning(const int &i, const sf::Vector2f &chunkPosition1, const sf::Vector2f &chunkPosition2, const sf::Vector2f &chunkPosition3); std::vector<std::shared_ptr<Chunk>> m_chunkVector; float m_chunkLength; int m_numberOfTilesPerChunk; std::vector<sf::Texture> m_backgroundTextures; //upgrade Menu void upgrade(float *upgradeType, const bool &multiply, const float &amount, const int &i); std::shared_ptr<UpgradeMenu> m_upgradeMenu; //inventory std::shared_ptr<Inventory> m_inventory; //sounds sf::Sound shootSound; sf::Sound enemyHit; sf::Sound playerHit; }; #endif
[ "l.michalke@tu-bs.de" ]
l.michalke@tu-bs.de
a81eb9d95e5feff9131ac3be819af0341a82e598
00fd4e809a6ae49c8ef41783f919b86df8c8b614
/Funções.cpp
d8a14f9fadaa03a467db47c5a94573793181ebf9
[]
no_license
Williamfigueira96/C-
21fc7cb04c98645227a47a1406a8eba025bc3d0b
060210f7ffbe190f99becb7a030de37440078e65
refs/heads/master
2020-12-05T20:56:50.389967
2016-09-14T12:16:10
2016-09-14T12:16:10
66,416,107
0
0
null
2016-08-24T16:53:42
2016-08-24T01:04:15
C++
ISO-8859-1
C++
false
false
1,012
cpp
#include"Meu.h" // Função que lista um vetor numeros decimais // Parâmetros: // Entrada:int vetInt[] - endereço do primeiro byte da primeira decimais do vetor // int nTamanho - quantidade de inteiras do vetor void ListarDecimais(double vetDouble[], int nTamanho, int nQtdePorLinha) { int i, // índice e contador nQtLinha; // para a contagem por linha char cWork[200]; for(i = 0; i < nTamanho; ) // for para a listagem de todas { for(nQtLinha = 0; nQtLinha < nQtdePorLinha; nQtLinha++,i++) // loop para listar uma a uma { if(i == nTamanho) // todas as inteiras foram listadas? { break; // cai fora do for } //cout << vetDouble[i] << "\t"; // lista uma inteira do vetor sprintf_s(cWork,sizeof(cWork),"%.02f", vetDouble[i]); cout << " " << cWork << "\t"; } // for nQtLinha cout << endl; // pula de linha } // for i cout << "-------->>>fim da listagem!!!!<<--------" << endl; PAUSA; } // Listar as decimais
[ "noreply@github.com" ]
Williamfigueira96.noreply@github.com
ead4b7016944910f54b573bc743b730c7a91aacd
313269781178b4aa9d585a6c7f7a8f63b07df439
/etu-impala-cdh1.0.1/src/debug/impala-1.0.1-SNAPSHOT/be/generated-sources/gen-cpp/Frontend_types.cpp
d32232f586685b4574ecb52918161e38ba46a46a
[]
no_license
stephenchinqlz/pkgs
06f8823cd8a646527a3eae787c5dd7f6c8da81f4
796bf57f1034ac54c3b3788c9c3fa907b4fc1ab7
refs/heads/master
2021-01-24T05:15:16.299619
2013-07-06T17:23:01
2013-07-06T17:23:01
null
0
0
null
null
null
null
UTF-8
C++
false
true
134,047
cpp
/** * Autogenerated by Thrift Compiler (0.9.0) * * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING * @generated */ #include "Frontend_types.h" #include <algorithm> namespace impala { int _kTFileFormatValues[] = { TFileFormat::PARQUETFILE, TFileFormat::RCFILE, TFileFormat::SEQUENCEFILE, TFileFormat::TEXTFILE }; const char* _kTFileFormatNames[] = { "PARQUETFILE", "RCFILE", "SEQUENCEFILE", "TEXTFILE" }; const std::map<int, const char*> _TFileFormat_VALUES_TO_NAMES(::apache::thrift::TEnumIterator(4, _kTFileFormatValues, _kTFileFormatNames), ::apache::thrift::TEnumIterator(-1, NULL, NULL)); int _kTAlterTableTypeValues[] = { TAlterTableType::ADD_REPLACE_COLUMNS, TAlterTableType::ADD_PARTITION, TAlterTableType::CHANGE_COLUMN, TAlterTableType::DROP_COLUMN, TAlterTableType::DROP_PARTITION, TAlterTableType::RENAME_TABLE, TAlterTableType::SET_FILE_FORMAT, TAlterTableType::SET_LOCATION }; const char* _kTAlterTableTypeNames[] = { "ADD_REPLACE_COLUMNS", "ADD_PARTITION", "CHANGE_COLUMN", "DROP_COLUMN", "DROP_PARTITION", "RENAME_TABLE", "SET_FILE_FORMAT", "SET_LOCATION" }; const std::map<int, const char*> _TAlterTableType_VALUES_TO_NAMES(::apache::thrift::TEnumIterator(8, _kTAlterTableTypeValues, _kTAlterTableTypeNames), ::apache::thrift::TEnumIterator(-1, NULL, NULL)); int _kTDdlTypeValues[] = { TDdlType::SHOW_TABLES, TDdlType::SHOW_DBS, TDdlType::USE, TDdlType::DESCRIBE, TDdlType::ALTER_TABLE, TDdlType::CREATE_DATABASE, TDdlType::CREATE_TABLE, TDdlType::CREATE_TABLE_LIKE, TDdlType::DROP_DATABASE, TDdlType::DROP_TABLE }; const char* _kTDdlTypeNames[] = { "SHOW_TABLES", "SHOW_DBS", "USE", "DESCRIBE", "ALTER_TABLE", "CREATE_DATABASE", "CREATE_TABLE", "CREATE_TABLE_LIKE", "DROP_DATABASE", "DROP_TABLE" }; const std::map<int, const char*> _TDdlType_VALUES_TO_NAMES(::apache::thrift::TEnumIterator(10, _kTDdlTypeValues, _kTDdlTypeNames), ::apache::thrift::TEnumIterator(-1, NULL, NULL)); int _kTMetadataOpcodeValues[] = { TMetadataOpcode::GET_TYPE_INFO, TMetadataOpcode::GET_CATALOGS, TMetadataOpcode::GET_SCHEMAS, TMetadataOpcode::GET_TABLES, TMetadataOpcode::GET_TABLE_TYPES, TMetadataOpcode::GET_COLUMNS, TMetadataOpcode::GET_FUNCTIONS }; const char* _kTMetadataOpcodeNames[] = { "GET_TYPE_INFO", "GET_CATALOGS", "GET_SCHEMAS", "GET_TABLES", "GET_TABLE_TYPES", "GET_COLUMNS", "GET_FUNCTIONS" }; const std::map<int, const char*> _TMetadataOpcode_VALUES_TO_NAMES(::apache::thrift::TEnumIterator(7, _kTMetadataOpcodeValues, _kTMetadataOpcodeNames), ::apache::thrift::TEnumIterator(-1, NULL, NULL)); const char* TGetTablesParams::ascii_fingerprint = "D0297FC5011701BD87898CC36146A565"; const uint8_t TGetTablesParams::binary_fingerprint[16] = {0xD0,0x29,0x7F,0xC5,0x01,0x17,0x01,0xBD,0x87,0x89,0x8C,0xC3,0x61,0x46,0xA5,0x65}; uint32_t TGetTablesParams::read(::apache::thrift::protocol::TProtocol* iprot) { uint32_t xfer = 0; std::string fname; ::apache::thrift::protocol::TType ftype; int16_t fid; xfer += iprot->readStructBegin(fname); using ::apache::thrift::protocol::TProtocolException; while (true) { xfer += iprot->readFieldBegin(fname, ftype, fid); if (ftype == ::apache::thrift::protocol::T_STOP) { break; } switch (fid) { case 1: if (ftype == ::apache::thrift::protocol::T_STRING) { xfer += iprot->readString(this->db); this->__isset.db = true; } else { xfer += iprot->skip(ftype); } break; case 2: if (ftype == ::apache::thrift::protocol::T_STRING) { xfer += iprot->readString(this->pattern); this->__isset.pattern = true; } else { xfer += iprot->skip(ftype); } break; default: xfer += iprot->skip(ftype); break; } xfer += iprot->readFieldEnd(); } xfer += iprot->readStructEnd(); return xfer; } uint32_t TGetTablesParams::write(::apache::thrift::protocol::TProtocol* oprot) const { uint32_t xfer = 0; uint32_t fcnt = 0; xfer += oprot->writeStructBegin("TGetTablesParams"); if (this->__isset.db) { ++fcnt; xfer += oprot->writeFieldBegin("db", ::apache::thrift::protocol::T_STRING, 1); xfer += oprot->writeString(this->db); xfer += oprot->writeFieldEnd(); } if (this->__isset.pattern) { ++fcnt; xfer += oprot->writeFieldBegin("pattern", ::apache::thrift::protocol::T_STRING, 2); xfer += oprot->writeString(this->pattern); xfer += oprot->writeFieldEnd(); } xfer += oprot->writeFieldStop(); xfer += oprot->writeStructEnd(); return xfer; } void swap(TGetTablesParams &a, TGetTablesParams &b) { using ::std::swap; swap(a.db, b.db); swap(a.pattern, b.pattern); swap(a.__isset, b.__isset); } const char* TGetTablesResult::ascii_fingerprint = "ACE4F644F0FDD289DDC4EE5B83BC13C0"; const uint8_t TGetTablesResult::binary_fingerprint[16] = {0xAC,0xE4,0xF6,0x44,0xF0,0xFD,0xD2,0x89,0xDD,0xC4,0xEE,0x5B,0x83,0xBC,0x13,0xC0}; uint32_t TGetTablesResult::read(::apache::thrift::protocol::TProtocol* iprot) { uint32_t xfer = 0; std::string fname; ::apache::thrift::protocol::TType ftype; int16_t fid; xfer += iprot->readStructBegin(fname); using ::apache::thrift::protocol::TProtocolException; while (true) { xfer += iprot->readFieldBegin(fname, ftype, fid); if (ftype == ::apache::thrift::protocol::T_STOP) { break; } switch (fid) { case 1: if (ftype == ::apache::thrift::protocol::T_LIST) { { this->tables.clear(); uint32_t _size0; ::apache::thrift::protocol::TType _etype3; xfer += iprot->readListBegin(_etype3, _size0); this->tables.resize(_size0); uint32_t _i4; for (_i4 = 0; _i4 < _size0; ++_i4) { xfer += iprot->readString(this->tables[_i4]); } xfer += iprot->readListEnd(); } this->__isset.tables = true; } else { xfer += iprot->skip(ftype); } break; default: xfer += iprot->skip(ftype); break; } xfer += iprot->readFieldEnd(); } xfer += iprot->readStructEnd(); return xfer; } uint32_t TGetTablesResult::write(::apache::thrift::protocol::TProtocol* oprot) const { uint32_t xfer = 0; uint32_t fcnt = 0; xfer += oprot->writeStructBegin("TGetTablesResult"); ++fcnt; xfer += oprot->writeFieldBegin("tables", ::apache::thrift::protocol::T_LIST, 1); { xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRING, static_cast<uint32_t>(this->tables.size())); std::vector<std::string> ::const_iterator _iter5; for (_iter5 = this->tables.begin(); _iter5 != this->tables.end(); ++_iter5) { xfer += oprot->writeString((*_iter5)); } xfer += oprot->writeListEnd(); } xfer += oprot->writeFieldEnd(); xfer += oprot->writeFieldStop(); xfer += oprot->writeStructEnd(); return xfer; } void swap(TGetTablesResult &a, TGetTablesResult &b) { using ::std::swap; swap(a.tables, b.tables); swap(a.__isset, b.__isset); } const char* TGetDbsParams::ascii_fingerprint = "66E694018C17E5B65A59AE8F55CCA3CD"; const uint8_t TGetDbsParams::binary_fingerprint[16] = {0x66,0xE6,0x94,0x01,0x8C,0x17,0xE5,0xB6,0x5A,0x59,0xAE,0x8F,0x55,0xCC,0xA3,0xCD}; uint32_t TGetDbsParams::read(::apache::thrift::protocol::TProtocol* iprot) { uint32_t xfer = 0; std::string fname; ::apache::thrift::protocol::TType ftype; int16_t fid; xfer += iprot->readStructBegin(fname); using ::apache::thrift::protocol::TProtocolException; while (true) { xfer += iprot->readFieldBegin(fname, ftype, fid); if (ftype == ::apache::thrift::protocol::T_STOP) { break; } switch (fid) { case 1: if (ftype == ::apache::thrift::protocol::T_STRING) { xfer += iprot->readString(this->pattern); this->__isset.pattern = true; } else { xfer += iprot->skip(ftype); } break; default: xfer += iprot->skip(ftype); break; } xfer += iprot->readFieldEnd(); } xfer += iprot->readStructEnd(); return xfer; } uint32_t TGetDbsParams::write(::apache::thrift::protocol::TProtocol* oprot) const { uint32_t xfer = 0; uint32_t fcnt = 0; xfer += oprot->writeStructBegin("TGetDbsParams"); if (this->__isset.pattern) { ++fcnt; xfer += oprot->writeFieldBegin("pattern", ::apache::thrift::protocol::T_STRING, 1); xfer += oprot->writeString(this->pattern); xfer += oprot->writeFieldEnd(); } xfer += oprot->writeFieldStop(); xfer += oprot->writeStructEnd(); return xfer; } void swap(TGetDbsParams &a, TGetDbsParams &b) { using ::std::swap; swap(a.pattern, b.pattern); swap(a.__isset, b.__isset); } const char* TGetDbsResult::ascii_fingerprint = "ACE4F644F0FDD289DDC4EE5B83BC13C0"; const uint8_t TGetDbsResult::binary_fingerprint[16] = {0xAC,0xE4,0xF6,0x44,0xF0,0xFD,0xD2,0x89,0xDD,0xC4,0xEE,0x5B,0x83,0xBC,0x13,0xC0}; uint32_t TGetDbsResult::read(::apache::thrift::protocol::TProtocol* iprot) { uint32_t xfer = 0; std::string fname; ::apache::thrift::protocol::TType ftype; int16_t fid; xfer += iprot->readStructBegin(fname); using ::apache::thrift::protocol::TProtocolException; while (true) { xfer += iprot->readFieldBegin(fname, ftype, fid); if (ftype == ::apache::thrift::protocol::T_STOP) { break; } switch (fid) { case 1: if (ftype == ::apache::thrift::protocol::T_LIST) { { this->dbs.clear(); uint32_t _size6; ::apache::thrift::protocol::TType _etype9; xfer += iprot->readListBegin(_etype9, _size6); this->dbs.resize(_size6); uint32_t _i10; for (_i10 = 0; _i10 < _size6; ++_i10) { xfer += iprot->readString(this->dbs[_i10]); } xfer += iprot->readListEnd(); } this->__isset.dbs = true; } else { xfer += iprot->skip(ftype); } break; default: xfer += iprot->skip(ftype); break; } xfer += iprot->readFieldEnd(); } xfer += iprot->readStructEnd(); return xfer; } uint32_t TGetDbsResult::write(::apache::thrift::protocol::TProtocol* oprot) const { uint32_t xfer = 0; uint32_t fcnt = 0; xfer += oprot->writeStructBegin("TGetDbsResult"); ++fcnt; xfer += oprot->writeFieldBegin("dbs", ::apache::thrift::protocol::T_LIST, 1); { xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRING, static_cast<uint32_t>(this->dbs.size())); std::vector<std::string> ::const_iterator _iter11; for (_iter11 = this->dbs.begin(); _iter11 != this->dbs.end(); ++_iter11) { xfer += oprot->writeString((*_iter11)); } xfer += oprot->writeListEnd(); } xfer += oprot->writeFieldEnd(); xfer += oprot->writeFieldStop(); xfer += oprot->writeStructEnd(); return xfer; } void swap(TGetDbsResult &a, TGetDbsResult &b) { using ::std::swap; swap(a.dbs, b.dbs); swap(a.__isset, b.__isset); } const char* TColumnDesc::ascii_fingerprint = "D6FD826D949221396F4FFC3ECCD3D192"; const uint8_t TColumnDesc::binary_fingerprint[16] = {0xD6,0xFD,0x82,0x6D,0x94,0x92,0x21,0x39,0x6F,0x4F,0xFC,0x3E,0xCC,0xD3,0xD1,0x92}; uint32_t TColumnDesc::read(::apache::thrift::protocol::TProtocol* iprot) { uint32_t xfer = 0; std::string fname; ::apache::thrift::protocol::TType ftype; int16_t fid; xfer += iprot->readStructBegin(fname); using ::apache::thrift::protocol::TProtocolException; bool isset_columnName = false; bool isset_columnType = false; while (true) { xfer += iprot->readFieldBegin(fname, ftype, fid); if (ftype == ::apache::thrift::protocol::T_STOP) { break; } switch (fid) { case 1: if (ftype == ::apache::thrift::protocol::T_STRING) { xfer += iprot->readString(this->columnName); isset_columnName = true; } else { xfer += iprot->skip(ftype); } break; case 2: if (ftype == ::apache::thrift::protocol::T_I32) { int32_t ecast12; xfer += iprot->readI32(ecast12); this->columnType = ( ::impala::TPrimitiveType::type)ecast12; isset_columnType = true; } else { xfer += iprot->skip(ftype); } break; default: xfer += iprot->skip(ftype); break; } xfer += iprot->readFieldEnd(); } xfer += iprot->readStructEnd(); if (!isset_columnName) throw TProtocolException(TProtocolException::INVALID_DATA); if (!isset_columnType) throw TProtocolException(TProtocolException::INVALID_DATA); return xfer; } uint32_t TColumnDesc::write(::apache::thrift::protocol::TProtocol* oprot) const { uint32_t xfer = 0; uint32_t fcnt = 0; xfer += oprot->writeStructBegin("TColumnDesc"); ++fcnt; xfer += oprot->writeFieldBegin("columnName", ::apache::thrift::protocol::T_STRING, 1); xfer += oprot->writeString(this->columnName); xfer += oprot->writeFieldEnd(); ++fcnt; xfer += oprot->writeFieldBegin("columnType", ::apache::thrift::protocol::T_I32, 2); xfer += oprot->writeI32((int32_t)this->columnType); xfer += oprot->writeFieldEnd(); xfer += oprot->writeFieldStop(); xfer += oprot->writeStructEnd(); return xfer; } void swap(TColumnDesc &a, TColumnDesc &b) { using ::std::swap; swap(a.columnName, b.columnName); swap(a.columnType, b.columnType); } const char* TColumnDef::ascii_fingerprint = "1A466928A838FDE756589DF00F1277D0"; const uint8_t TColumnDef::binary_fingerprint[16] = {0x1A,0x46,0x69,0x28,0xA8,0x38,0xFD,0xE7,0x56,0x58,0x9D,0xF0,0x0F,0x12,0x77,0xD0}; uint32_t TColumnDef::read(::apache::thrift::protocol::TProtocol* iprot) { uint32_t xfer = 0; std::string fname; ::apache::thrift::protocol::TType ftype; int16_t fid; xfer += iprot->readStructBegin(fname); using ::apache::thrift::protocol::TProtocolException; bool isset_columnDesc = false; while (true) { xfer += iprot->readFieldBegin(fname, ftype, fid); if (ftype == ::apache::thrift::protocol::T_STOP) { break; } switch (fid) { case 1: if (ftype == ::apache::thrift::protocol::T_STRUCT) { xfer += this->columnDesc.read(iprot); isset_columnDesc = true; } else { xfer += iprot->skip(ftype); } break; case 2: if (ftype == ::apache::thrift::protocol::T_STRING) { xfer += iprot->readString(this->comment); this->__isset.comment = true; } else { xfer += iprot->skip(ftype); } break; default: xfer += iprot->skip(ftype); break; } xfer += iprot->readFieldEnd(); } xfer += iprot->readStructEnd(); if (!isset_columnDesc) throw TProtocolException(TProtocolException::INVALID_DATA); return xfer; } uint32_t TColumnDef::write(::apache::thrift::protocol::TProtocol* oprot) const { uint32_t xfer = 0; uint32_t fcnt = 0; xfer += oprot->writeStructBegin("TColumnDef"); ++fcnt; xfer += oprot->writeFieldBegin("columnDesc", ::apache::thrift::protocol::T_STRUCT, 1); xfer += this->columnDesc.write(oprot); xfer += oprot->writeFieldEnd(); if (this->__isset.comment) { ++fcnt; xfer += oprot->writeFieldBegin("comment", ::apache::thrift::protocol::T_STRING, 2); xfer += oprot->writeString(this->comment); xfer += oprot->writeFieldEnd(); } xfer += oprot->writeFieldStop(); xfer += oprot->writeStructEnd(); return xfer; } void swap(TColumnDef &a, TColumnDef &b) { using ::std::swap; swap(a.columnDesc, b.columnDesc); swap(a.comment, b.comment); swap(a.__isset, b.__isset); } const char* TDescribeTableParams::ascii_fingerprint = "383E55F0D02199A3E52B9227E13A83A2"; const uint8_t TDescribeTableParams::binary_fingerprint[16] = {0x38,0x3E,0x55,0xF0,0xD0,0x21,0x99,0xA3,0xE5,0x2B,0x92,0x27,0xE1,0x3A,0x83,0xA2}; uint32_t TDescribeTableParams::read(::apache::thrift::protocol::TProtocol* iprot) { uint32_t xfer = 0; std::string fname; ::apache::thrift::protocol::TType ftype; int16_t fid; xfer += iprot->readStructBegin(fname); using ::apache::thrift::protocol::TProtocolException; bool isset_table_name = false; while (true) { xfer += iprot->readFieldBegin(fname, ftype, fid); if (ftype == ::apache::thrift::protocol::T_STOP) { break; } switch (fid) { case 1: if (ftype == ::apache::thrift::protocol::T_STRING) { xfer += iprot->readString(this->db); this->__isset.db = true; } else { xfer += iprot->skip(ftype); } break; case 2: if (ftype == ::apache::thrift::protocol::T_STRING) { xfer += iprot->readString(this->table_name); isset_table_name = true; } else { xfer += iprot->skip(ftype); } break; default: xfer += iprot->skip(ftype); break; } xfer += iprot->readFieldEnd(); } xfer += iprot->readStructEnd(); if (!isset_table_name) throw TProtocolException(TProtocolException::INVALID_DATA); return xfer; } uint32_t TDescribeTableParams::write(::apache::thrift::protocol::TProtocol* oprot) const { uint32_t xfer = 0; uint32_t fcnt = 0; xfer += oprot->writeStructBegin("TDescribeTableParams"); if (this->__isset.db) { ++fcnt; xfer += oprot->writeFieldBegin("db", ::apache::thrift::protocol::T_STRING, 1); xfer += oprot->writeString(this->db); xfer += oprot->writeFieldEnd(); } ++fcnt; xfer += oprot->writeFieldBegin("table_name", ::apache::thrift::protocol::T_STRING, 2); xfer += oprot->writeString(this->table_name); xfer += oprot->writeFieldEnd(); xfer += oprot->writeFieldStop(); xfer += oprot->writeStructEnd(); return xfer; } void swap(TDescribeTableParams &a, TDescribeTableParams &b) { using ::std::swap; swap(a.db, b.db); swap(a.table_name, b.table_name); swap(a.__isset, b.__isset); } const char* TDescribeTableResult::ascii_fingerprint = "310594E5EEC07991F491FF2D8123E958"; const uint8_t TDescribeTableResult::binary_fingerprint[16] = {0x31,0x05,0x94,0xE5,0xEE,0xC0,0x79,0x91,0xF4,0x91,0xFF,0x2D,0x81,0x23,0xE9,0x58}; uint32_t TDescribeTableResult::read(::apache::thrift::protocol::TProtocol* iprot) { uint32_t xfer = 0; std::string fname; ::apache::thrift::protocol::TType ftype; int16_t fid; xfer += iprot->readStructBegin(fname); using ::apache::thrift::protocol::TProtocolException; bool isset_columns = false; while (true) { xfer += iprot->readFieldBegin(fname, ftype, fid); if (ftype == ::apache::thrift::protocol::T_STOP) { break; } switch (fid) { case 1: if (ftype == ::apache::thrift::protocol::T_LIST) { { this->columns.clear(); uint32_t _size13; ::apache::thrift::protocol::TType _etype16; xfer += iprot->readListBegin(_etype16, _size13); this->columns.resize(_size13); uint32_t _i17; for (_i17 = 0; _i17 < _size13; ++_i17) { xfer += this->columns[_i17].read(iprot); } xfer += iprot->readListEnd(); } isset_columns = true; } else { xfer += iprot->skip(ftype); } break; default: xfer += iprot->skip(ftype); break; } xfer += iprot->readFieldEnd(); } xfer += iprot->readStructEnd(); if (!isset_columns) throw TProtocolException(TProtocolException::INVALID_DATA); return xfer; } uint32_t TDescribeTableResult::write(::apache::thrift::protocol::TProtocol* oprot) const { uint32_t xfer = 0; uint32_t fcnt = 0; xfer += oprot->writeStructBegin("TDescribeTableResult"); ++fcnt; xfer += oprot->writeFieldBegin("columns", ::apache::thrift::protocol::T_LIST, 1); { xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRUCT, static_cast<uint32_t>(this->columns.size())); std::vector<TColumnDef> ::const_iterator _iter18; for (_iter18 = this->columns.begin(); _iter18 != this->columns.end(); ++_iter18) { xfer += (*_iter18).write(oprot); } xfer += oprot->writeListEnd(); } xfer += oprot->writeFieldEnd(); xfer += oprot->writeFieldStop(); xfer += oprot->writeStructEnd(); return xfer; } void swap(TDescribeTableResult &a, TDescribeTableResult &b) { using ::std::swap; swap(a.columns, b.columns); } const char* TCreateDbParams::ascii_fingerprint = "CAD4F97378DF2EFF77F23A193511C552"; const uint8_t TCreateDbParams::binary_fingerprint[16] = {0xCA,0xD4,0xF9,0x73,0x78,0xDF,0x2E,0xFF,0x77,0xF2,0x3A,0x19,0x35,0x11,0xC5,0x52}; uint32_t TCreateDbParams::read(::apache::thrift::protocol::TProtocol* iprot) { uint32_t xfer = 0; std::string fname; ::apache::thrift::protocol::TType ftype; int16_t fid; xfer += iprot->readStructBegin(fname); using ::apache::thrift::protocol::TProtocolException; bool isset_db = false; while (true) { xfer += iprot->readFieldBegin(fname, ftype, fid); if (ftype == ::apache::thrift::protocol::T_STOP) { break; } switch (fid) { case 1: if (ftype == ::apache::thrift::protocol::T_STRING) { xfer += iprot->readString(this->db); isset_db = true; } else { xfer += iprot->skip(ftype); } break; case 2: if (ftype == ::apache::thrift::protocol::T_STRING) { xfer += iprot->readString(this->comment); this->__isset.comment = true; } else { xfer += iprot->skip(ftype); } break; case 3: if (ftype == ::apache::thrift::protocol::T_STRING) { xfer += iprot->readString(this->location); this->__isset.location = true; } else { xfer += iprot->skip(ftype); } break; case 4: if (ftype == ::apache::thrift::protocol::T_BOOL) { xfer += iprot->readBool(this->if_not_exists); this->__isset.if_not_exists = true; } else { xfer += iprot->skip(ftype); } break; default: xfer += iprot->skip(ftype); break; } xfer += iprot->readFieldEnd(); } xfer += iprot->readStructEnd(); if (!isset_db) throw TProtocolException(TProtocolException::INVALID_DATA); return xfer; } uint32_t TCreateDbParams::write(::apache::thrift::protocol::TProtocol* oprot) const { uint32_t xfer = 0; uint32_t fcnt = 0; xfer += oprot->writeStructBegin("TCreateDbParams"); ++fcnt; xfer += oprot->writeFieldBegin("db", ::apache::thrift::protocol::T_STRING, 1); xfer += oprot->writeString(this->db); xfer += oprot->writeFieldEnd(); if (this->__isset.comment) { ++fcnt; xfer += oprot->writeFieldBegin("comment", ::apache::thrift::protocol::T_STRING, 2); xfer += oprot->writeString(this->comment); xfer += oprot->writeFieldEnd(); } if (this->__isset.location) { ++fcnt; xfer += oprot->writeFieldBegin("location", ::apache::thrift::protocol::T_STRING, 3); xfer += oprot->writeString(this->location); xfer += oprot->writeFieldEnd(); } if (this->__isset.if_not_exists) { ++fcnt; xfer += oprot->writeFieldBegin("if_not_exists", ::apache::thrift::protocol::T_BOOL, 4); xfer += oprot->writeBool(this->if_not_exists); xfer += oprot->writeFieldEnd(); } xfer += oprot->writeFieldStop(); xfer += oprot->writeStructEnd(); return xfer; } void swap(TCreateDbParams &a, TCreateDbParams &b) { using ::std::swap; swap(a.db, b.db); swap(a.comment, b.comment); swap(a.location, b.location); swap(a.if_not_exists, b.if_not_exists); swap(a.__isset, b.__isset); } const char* TTableName::ascii_fingerprint = "07A9615F837F7D0A952B595DD3020972"; const uint8_t TTableName::binary_fingerprint[16] = {0x07,0xA9,0x61,0x5F,0x83,0x7F,0x7D,0x0A,0x95,0x2B,0x59,0x5D,0xD3,0x02,0x09,0x72}; uint32_t TTableName::read(::apache::thrift::protocol::TProtocol* iprot) { uint32_t xfer = 0; std::string fname; ::apache::thrift::protocol::TType ftype; int16_t fid; xfer += iprot->readStructBegin(fname); using ::apache::thrift::protocol::TProtocolException; bool isset_db_name = false; bool isset_table_name = false; while (true) { xfer += iprot->readFieldBegin(fname, ftype, fid); if (ftype == ::apache::thrift::protocol::T_STOP) { break; } switch (fid) { case 1: if (ftype == ::apache::thrift::protocol::T_STRING) { xfer += iprot->readString(this->db_name); isset_db_name = true; } else { xfer += iprot->skip(ftype); } break; case 2: if (ftype == ::apache::thrift::protocol::T_STRING) { xfer += iprot->readString(this->table_name); isset_table_name = true; } else { xfer += iprot->skip(ftype); } break; default: xfer += iprot->skip(ftype); break; } xfer += iprot->readFieldEnd(); } xfer += iprot->readStructEnd(); if (!isset_db_name) throw TProtocolException(TProtocolException::INVALID_DATA); if (!isset_table_name) throw TProtocolException(TProtocolException::INVALID_DATA); return xfer; } uint32_t TTableName::write(::apache::thrift::protocol::TProtocol* oprot) const { uint32_t xfer = 0; uint32_t fcnt = 0; xfer += oprot->writeStructBegin("TTableName"); ++fcnt; xfer += oprot->writeFieldBegin("db_name", ::apache::thrift::protocol::T_STRING, 1); xfer += oprot->writeString(this->db_name); xfer += oprot->writeFieldEnd(); ++fcnt; xfer += oprot->writeFieldBegin("table_name", ::apache::thrift::protocol::T_STRING, 2); xfer += oprot->writeString(this->table_name); xfer += oprot->writeFieldEnd(); xfer += oprot->writeFieldStop(); xfer += oprot->writeStructEnd(); return xfer; } void swap(TTableName &a, TTableName &b) { using ::std::swap; swap(a.db_name, b.db_name); swap(a.table_name, b.table_name); } const char* TTableRowFormat::ascii_fingerprint = "B2C950B9C25B62CA02C2A8C700FEE26F"; const uint8_t TTableRowFormat::binary_fingerprint[16] = {0xB2,0xC9,0x50,0xB9,0xC2,0x5B,0x62,0xCA,0x02,0xC2,0xA8,0xC7,0x00,0xFE,0xE2,0x6F}; uint32_t TTableRowFormat::read(::apache::thrift::protocol::TProtocol* iprot) { uint32_t xfer = 0; std::string fname; ::apache::thrift::protocol::TType ftype; int16_t fid; xfer += iprot->readStructBegin(fname); using ::apache::thrift::protocol::TProtocolException; while (true) { xfer += iprot->readFieldBegin(fname, ftype, fid); if (ftype == ::apache::thrift::protocol::T_STOP) { break; } switch (fid) { case 1: if (ftype == ::apache::thrift::protocol::T_STRING) { xfer += iprot->readString(this->field_terminator); this->__isset.field_terminator = true; } else { xfer += iprot->skip(ftype); } break; case 2: if (ftype == ::apache::thrift::protocol::T_STRING) { xfer += iprot->readString(this->line_terminator); this->__isset.line_terminator = true; } else { xfer += iprot->skip(ftype); } break; case 3: if (ftype == ::apache::thrift::protocol::T_STRING) { xfer += iprot->readString(this->escaped_by); this->__isset.escaped_by = true; } else { xfer += iprot->skip(ftype); } break; default: xfer += iprot->skip(ftype); break; } xfer += iprot->readFieldEnd(); } xfer += iprot->readStructEnd(); return xfer; } uint32_t TTableRowFormat::write(::apache::thrift::protocol::TProtocol* oprot) const { uint32_t xfer = 0; uint32_t fcnt = 0; xfer += oprot->writeStructBegin("TTableRowFormat"); if (this->__isset.field_terminator) { ++fcnt; xfer += oprot->writeFieldBegin("field_terminator", ::apache::thrift::protocol::T_STRING, 1); xfer += oprot->writeString(this->field_terminator); xfer += oprot->writeFieldEnd(); } if (this->__isset.line_terminator) { ++fcnt; xfer += oprot->writeFieldBegin("line_terminator", ::apache::thrift::protocol::T_STRING, 2); xfer += oprot->writeString(this->line_terminator); xfer += oprot->writeFieldEnd(); } if (this->__isset.escaped_by) { ++fcnt; xfer += oprot->writeFieldBegin("escaped_by", ::apache::thrift::protocol::T_STRING, 3); xfer += oprot->writeString(this->escaped_by); xfer += oprot->writeFieldEnd(); } xfer += oprot->writeFieldStop(); xfer += oprot->writeStructEnd(); return xfer; } void swap(TTableRowFormat &a, TTableRowFormat &b) { using ::std::swap; swap(a.field_terminator, b.field_terminator); swap(a.line_terminator, b.line_terminator); swap(a.escaped_by, b.escaped_by); swap(a.__isset, b.__isset); } const char* TPartitionKeyValue::ascii_fingerprint = "07A9615F837F7D0A952B595DD3020972"; const uint8_t TPartitionKeyValue::binary_fingerprint[16] = {0x07,0xA9,0x61,0x5F,0x83,0x7F,0x7D,0x0A,0x95,0x2B,0x59,0x5D,0xD3,0x02,0x09,0x72}; uint32_t TPartitionKeyValue::read(::apache::thrift::protocol::TProtocol* iprot) { uint32_t xfer = 0; std::string fname; ::apache::thrift::protocol::TType ftype; int16_t fid; xfer += iprot->readStructBegin(fname); using ::apache::thrift::protocol::TProtocolException; bool isset_name = false; bool isset_value = false; while (true) { xfer += iprot->readFieldBegin(fname, ftype, fid); if (ftype == ::apache::thrift::protocol::T_STOP) { break; } switch (fid) { case 1: if (ftype == ::apache::thrift::protocol::T_STRING) { xfer += iprot->readString(this->name); isset_name = true; } else { xfer += iprot->skip(ftype); } break; case 2: if (ftype == ::apache::thrift::protocol::T_STRING) { xfer += iprot->readString(this->value); isset_value = true; } else { xfer += iprot->skip(ftype); } break; default: xfer += iprot->skip(ftype); break; } xfer += iprot->readFieldEnd(); } xfer += iprot->readStructEnd(); if (!isset_name) throw TProtocolException(TProtocolException::INVALID_DATA); if (!isset_value) throw TProtocolException(TProtocolException::INVALID_DATA); return xfer; } uint32_t TPartitionKeyValue::write(::apache::thrift::protocol::TProtocol* oprot) const { uint32_t xfer = 0; uint32_t fcnt = 0; xfer += oprot->writeStructBegin("TPartitionKeyValue"); ++fcnt; xfer += oprot->writeFieldBegin("name", ::apache::thrift::protocol::T_STRING, 1); xfer += oprot->writeString(this->name); xfer += oprot->writeFieldEnd(); ++fcnt; xfer += oprot->writeFieldBegin("value", ::apache::thrift::protocol::T_STRING, 2); xfer += oprot->writeString(this->value); xfer += oprot->writeFieldEnd(); xfer += oprot->writeFieldStop(); xfer += oprot->writeStructEnd(); return xfer; } void swap(TPartitionKeyValue &a, TPartitionKeyValue &b) { using ::std::swap; swap(a.name, b.name); swap(a.value, b.value); } const char* TAlterTableRenameParams::ascii_fingerprint = "A756D3DBE614FB13F70BF7F7B6EB3D73"; const uint8_t TAlterTableRenameParams::binary_fingerprint[16] = {0xA7,0x56,0xD3,0xDB,0xE6,0x14,0xFB,0x13,0xF7,0x0B,0xF7,0xF7,0xB6,0xEB,0x3D,0x73}; uint32_t TAlterTableRenameParams::read(::apache::thrift::protocol::TProtocol* iprot) { uint32_t xfer = 0; std::string fname; ::apache::thrift::protocol::TType ftype; int16_t fid; xfer += iprot->readStructBegin(fname); using ::apache::thrift::protocol::TProtocolException; bool isset_new_table_name = false; while (true) { xfer += iprot->readFieldBegin(fname, ftype, fid); if (ftype == ::apache::thrift::protocol::T_STOP) { break; } switch (fid) { case 1: if (ftype == ::apache::thrift::protocol::T_STRUCT) { xfer += this->new_table_name.read(iprot); isset_new_table_name = true; } else { xfer += iprot->skip(ftype); } break; default: xfer += iprot->skip(ftype); break; } xfer += iprot->readFieldEnd(); } xfer += iprot->readStructEnd(); if (!isset_new_table_name) throw TProtocolException(TProtocolException::INVALID_DATA); return xfer; } uint32_t TAlterTableRenameParams::write(::apache::thrift::protocol::TProtocol* oprot) const { uint32_t xfer = 0; uint32_t fcnt = 0; xfer += oprot->writeStructBegin("TAlterTableRenameParams"); ++fcnt; xfer += oprot->writeFieldBegin("new_table_name", ::apache::thrift::protocol::T_STRUCT, 1); xfer += this->new_table_name.write(oprot); xfer += oprot->writeFieldEnd(); xfer += oprot->writeFieldStop(); xfer += oprot->writeStructEnd(); return xfer; } void swap(TAlterTableRenameParams &a, TAlterTableRenameParams &b) { using ::std::swap; swap(a.new_table_name, b.new_table_name); } const char* TAlterTableAddReplaceColsParams::ascii_fingerprint = "8A062F846D2647E1DF73D40439FB8C26"; const uint8_t TAlterTableAddReplaceColsParams::binary_fingerprint[16] = {0x8A,0x06,0x2F,0x84,0x6D,0x26,0x47,0xE1,0xDF,0x73,0xD4,0x04,0x39,0xFB,0x8C,0x26}; uint32_t TAlterTableAddReplaceColsParams::read(::apache::thrift::protocol::TProtocol* iprot) { uint32_t xfer = 0; std::string fname; ::apache::thrift::protocol::TType ftype; int16_t fid; xfer += iprot->readStructBegin(fname); using ::apache::thrift::protocol::TProtocolException; bool isset_columns = false; bool isset_replace_existing_cols = false; while (true) { xfer += iprot->readFieldBegin(fname, ftype, fid); if (ftype == ::apache::thrift::protocol::T_STOP) { break; } switch (fid) { case 1: if (ftype == ::apache::thrift::protocol::T_LIST) { { this->columns.clear(); uint32_t _size19; ::apache::thrift::protocol::TType _etype22; xfer += iprot->readListBegin(_etype22, _size19); this->columns.resize(_size19); uint32_t _i23; for (_i23 = 0; _i23 < _size19; ++_i23) { xfer += this->columns[_i23].read(iprot); } xfer += iprot->readListEnd(); } isset_columns = true; } else { xfer += iprot->skip(ftype); } break; case 2: if (ftype == ::apache::thrift::protocol::T_BOOL) { xfer += iprot->readBool(this->replace_existing_cols); isset_replace_existing_cols = true; } else { xfer += iprot->skip(ftype); } break; default: xfer += iprot->skip(ftype); break; } xfer += iprot->readFieldEnd(); } xfer += iprot->readStructEnd(); if (!isset_columns) throw TProtocolException(TProtocolException::INVALID_DATA); if (!isset_replace_existing_cols) throw TProtocolException(TProtocolException::INVALID_DATA); return xfer; } uint32_t TAlterTableAddReplaceColsParams::write(::apache::thrift::protocol::TProtocol* oprot) const { uint32_t xfer = 0; uint32_t fcnt = 0; xfer += oprot->writeStructBegin("TAlterTableAddReplaceColsParams"); ++fcnt; xfer += oprot->writeFieldBegin("columns", ::apache::thrift::protocol::T_LIST, 1); { xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRUCT, static_cast<uint32_t>(this->columns.size())); std::vector<TColumnDef> ::const_iterator _iter24; for (_iter24 = this->columns.begin(); _iter24 != this->columns.end(); ++_iter24) { xfer += (*_iter24).write(oprot); } xfer += oprot->writeListEnd(); } xfer += oprot->writeFieldEnd(); ++fcnt; xfer += oprot->writeFieldBegin("replace_existing_cols", ::apache::thrift::protocol::T_BOOL, 2); xfer += oprot->writeBool(this->replace_existing_cols); xfer += oprot->writeFieldEnd(); xfer += oprot->writeFieldStop(); xfer += oprot->writeStructEnd(); return xfer; } void swap(TAlterTableAddReplaceColsParams &a, TAlterTableAddReplaceColsParams &b) { using ::std::swap; swap(a.columns, b.columns); swap(a.replace_existing_cols, b.replace_existing_cols); } const char* TAlterTableAddPartitionParams::ascii_fingerprint = "DDBF94C5C0804BF720FBDF685968F8B2"; const uint8_t TAlterTableAddPartitionParams::binary_fingerprint[16] = {0xDD,0xBF,0x94,0xC5,0xC0,0x80,0x4B,0xF7,0x20,0xFB,0xDF,0x68,0x59,0x68,0xF8,0xB2}; uint32_t TAlterTableAddPartitionParams::read(::apache::thrift::protocol::TProtocol* iprot) { uint32_t xfer = 0; std::string fname; ::apache::thrift::protocol::TType ftype; int16_t fid; xfer += iprot->readStructBegin(fname); using ::apache::thrift::protocol::TProtocolException; bool isset_partition_spec = false; bool isset_if_not_exists = false; while (true) { xfer += iprot->readFieldBegin(fname, ftype, fid); if (ftype == ::apache::thrift::protocol::T_STOP) { break; } switch (fid) { case 1: if (ftype == ::apache::thrift::protocol::T_LIST) { { this->partition_spec.clear(); uint32_t _size25; ::apache::thrift::protocol::TType _etype28; xfer += iprot->readListBegin(_etype28, _size25); this->partition_spec.resize(_size25); uint32_t _i29; for (_i29 = 0; _i29 < _size25; ++_i29) { xfer += this->partition_spec[_i29].read(iprot); } xfer += iprot->readListEnd(); } isset_partition_spec = true; } else { xfer += iprot->skip(ftype); } break; case 3: if (ftype == ::apache::thrift::protocol::T_BOOL) { xfer += iprot->readBool(this->if_not_exists); isset_if_not_exists = true; } else { xfer += iprot->skip(ftype); } break; case 2: if (ftype == ::apache::thrift::protocol::T_STRING) { xfer += iprot->readString(this->location); this->__isset.location = true; } else { xfer += iprot->skip(ftype); } break; default: xfer += iprot->skip(ftype); break; } xfer += iprot->readFieldEnd(); } xfer += iprot->readStructEnd(); if (!isset_partition_spec) throw TProtocolException(TProtocolException::INVALID_DATA); if (!isset_if_not_exists) throw TProtocolException(TProtocolException::INVALID_DATA); return xfer; } uint32_t TAlterTableAddPartitionParams::write(::apache::thrift::protocol::TProtocol* oprot) const { uint32_t xfer = 0; uint32_t fcnt = 0; xfer += oprot->writeStructBegin("TAlterTableAddPartitionParams"); ++fcnt; xfer += oprot->writeFieldBegin("partition_spec", ::apache::thrift::protocol::T_LIST, 1); { xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRUCT, static_cast<uint32_t>(this->partition_spec.size())); std::vector<TPartitionKeyValue> ::const_iterator _iter30; for (_iter30 = this->partition_spec.begin(); _iter30 != this->partition_spec.end(); ++_iter30) { xfer += (*_iter30).write(oprot); } xfer += oprot->writeListEnd(); } xfer += oprot->writeFieldEnd(); if (this->__isset.location) { ++fcnt; xfer += oprot->writeFieldBegin("location", ::apache::thrift::protocol::T_STRING, 2); xfer += oprot->writeString(this->location); xfer += oprot->writeFieldEnd(); } ++fcnt; xfer += oprot->writeFieldBegin("if_not_exists", ::apache::thrift::protocol::T_BOOL, 3); xfer += oprot->writeBool(this->if_not_exists); xfer += oprot->writeFieldEnd(); xfer += oprot->writeFieldStop(); xfer += oprot->writeStructEnd(); return xfer; } void swap(TAlterTableAddPartitionParams &a, TAlterTableAddPartitionParams &b) { using ::std::swap; swap(a.partition_spec, b.partition_spec); swap(a.if_not_exists, b.if_not_exists); swap(a.location, b.location); swap(a.__isset, b.__isset); } const char* TAlterTableDropColParams::ascii_fingerprint = "EFB929595D312AC8F305D5A794CFEDA1"; const uint8_t TAlterTableDropColParams::binary_fingerprint[16] = {0xEF,0xB9,0x29,0x59,0x5D,0x31,0x2A,0xC8,0xF3,0x05,0xD5,0xA7,0x94,0xCF,0xED,0xA1}; uint32_t TAlterTableDropColParams::read(::apache::thrift::protocol::TProtocol* iprot) { uint32_t xfer = 0; std::string fname; ::apache::thrift::protocol::TType ftype; int16_t fid; xfer += iprot->readStructBegin(fname); using ::apache::thrift::protocol::TProtocolException; bool isset_col_name = false; while (true) { xfer += iprot->readFieldBegin(fname, ftype, fid); if (ftype == ::apache::thrift::protocol::T_STOP) { break; } switch (fid) { case 1: if (ftype == ::apache::thrift::protocol::T_STRING) { xfer += iprot->readString(this->col_name); isset_col_name = true; } else { xfer += iprot->skip(ftype); } break; default: xfer += iprot->skip(ftype); break; } xfer += iprot->readFieldEnd(); } xfer += iprot->readStructEnd(); if (!isset_col_name) throw TProtocolException(TProtocolException::INVALID_DATA); return xfer; } uint32_t TAlterTableDropColParams::write(::apache::thrift::protocol::TProtocol* oprot) const { uint32_t xfer = 0; uint32_t fcnt = 0; xfer += oprot->writeStructBegin("TAlterTableDropColParams"); ++fcnt; xfer += oprot->writeFieldBegin("col_name", ::apache::thrift::protocol::T_STRING, 1); xfer += oprot->writeString(this->col_name); xfer += oprot->writeFieldEnd(); xfer += oprot->writeFieldStop(); xfer += oprot->writeStructEnd(); return xfer; } void swap(TAlterTableDropColParams &a, TAlterTableDropColParams &b) { using ::std::swap; swap(a.col_name, b.col_name); } const char* TAlterTableDropPartitionParams::ascii_fingerprint = "6F92A0A7B206615BE32209BF2E6A7ED1"; const uint8_t TAlterTableDropPartitionParams::binary_fingerprint[16] = {0x6F,0x92,0xA0,0xA7,0xB2,0x06,0x61,0x5B,0xE3,0x22,0x09,0xBF,0x2E,0x6A,0x7E,0xD1}; uint32_t TAlterTableDropPartitionParams::read(::apache::thrift::protocol::TProtocol* iprot) { uint32_t xfer = 0; std::string fname; ::apache::thrift::protocol::TType ftype; int16_t fid; xfer += iprot->readStructBegin(fname); using ::apache::thrift::protocol::TProtocolException; bool isset_partition_spec = false; bool isset_if_exists = false; while (true) { xfer += iprot->readFieldBegin(fname, ftype, fid); if (ftype == ::apache::thrift::protocol::T_STOP) { break; } switch (fid) { case 1: if (ftype == ::apache::thrift::protocol::T_LIST) { { this->partition_spec.clear(); uint32_t _size31; ::apache::thrift::protocol::TType _etype34; xfer += iprot->readListBegin(_etype34, _size31); this->partition_spec.resize(_size31); uint32_t _i35; for (_i35 = 0; _i35 < _size31; ++_i35) { xfer += this->partition_spec[_i35].read(iprot); } xfer += iprot->readListEnd(); } isset_partition_spec = true; } else { xfer += iprot->skip(ftype); } break; case 2: if (ftype == ::apache::thrift::protocol::T_BOOL) { xfer += iprot->readBool(this->if_exists); isset_if_exists = true; } else { xfer += iprot->skip(ftype); } break; default: xfer += iprot->skip(ftype); break; } xfer += iprot->readFieldEnd(); } xfer += iprot->readStructEnd(); if (!isset_partition_spec) throw TProtocolException(TProtocolException::INVALID_DATA); if (!isset_if_exists) throw TProtocolException(TProtocolException::INVALID_DATA); return xfer; } uint32_t TAlterTableDropPartitionParams::write(::apache::thrift::protocol::TProtocol* oprot) const { uint32_t xfer = 0; uint32_t fcnt = 0; xfer += oprot->writeStructBegin("TAlterTableDropPartitionParams"); ++fcnt; xfer += oprot->writeFieldBegin("partition_spec", ::apache::thrift::protocol::T_LIST, 1); { xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRUCT, static_cast<uint32_t>(this->partition_spec.size())); std::vector<TPartitionKeyValue> ::const_iterator _iter36; for (_iter36 = this->partition_spec.begin(); _iter36 != this->partition_spec.end(); ++_iter36) { xfer += (*_iter36).write(oprot); } xfer += oprot->writeListEnd(); } xfer += oprot->writeFieldEnd(); ++fcnt; xfer += oprot->writeFieldBegin("if_exists", ::apache::thrift::protocol::T_BOOL, 2); xfer += oprot->writeBool(this->if_exists); xfer += oprot->writeFieldEnd(); xfer += oprot->writeFieldStop(); xfer += oprot->writeStructEnd(); return xfer; } void swap(TAlterTableDropPartitionParams &a, TAlterTableDropPartitionParams &b) { using ::std::swap; swap(a.partition_spec, b.partition_spec); swap(a.if_exists, b.if_exists); } const char* TAlterTableChangeColParams::ascii_fingerprint = "50D38FCE9C274638E6D49F7975E2CE6C"; const uint8_t TAlterTableChangeColParams::binary_fingerprint[16] = {0x50,0xD3,0x8F,0xCE,0x9C,0x27,0x46,0x38,0xE6,0xD4,0x9F,0x79,0x75,0xE2,0xCE,0x6C}; uint32_t TAlterTableChangeColParams::read(::apache::thrift::protocol::TProtocol* iprot) { uint32_t xfer = 0; std::string fname; ::apache::thrift::protocol::TType ftype; int16_t fid; xfer += iprot->readStructBegin(fname); using ::apache::thrift::protocol::TProtocolException; bool isset_col_name = false; bool isset_new_col_def = false; while (true) { xfer += iprot->readFieldBegin(fname, ftype, fid); if (ftype == ::apache::thrift::protocol::T_STOP) { break; } switch (fid) { case 1: if (ftype == ::apache::thrift::protocol::T_STRING) { xfer += iprot->readString(this->col_name); isset_col_name = true; } else { xfer += iprot->skip(ftype); } break; case 2: if (ftype == ::apache::thrift::protocol::T_STRUCT) { xfer += this->new_col_def.read(iprot); isset_new_col_def = true; } else { xfer += iprot->skip(ftype); } break; default: xfer += iprot->skip(ftype); break; } xfer += iprot->readFieldEnd(); } xfer += iprot->readStructEnd(); if (!isset_col_name) throw TProtocolException(TProtocolException::INVALID_DATA); if (!isset_new_col_def) throw TProtocolException(TProtocolException::INVALID_DATA); return xfer; } uint32_t TAlterTableChangeColParams::write(::apache::thrift::protocol::TProtocol* oprot) const { uint32_t xfer = 0; uint32_t fcnt = 0; xfer += oprot->writeStructBegin("TAlterTableChangeColParams"); ++fcnt; xfer += oprot->writeFieldBegin("col_name", ::apache::thrift::protocol::T_STRING, 1); xfer += oprot->writeString(this->col_name); xfer += oprot->writeFieldEnd(); ++fcnt; xfer += oprot->writeFieldBegin("new_col_def", ::apache::thrift::protocol::T_STRUCT, 2); xfer += this->new_col_def.write(oprot); xfer += oprot->writeFieldEnd(); xfer += oprot->writeFieldStop(); xfer += oprot->writeStructEnd(); return xfer; } void swap(TAlterTableChangeColParams &a, TAlterTableChangeColParams &b) { using ::std::swap; swap(a.col_name, b.col_name); swap(a.new_col_def, b.new_col_def); } const char* TAlterTableSetFileFormatParams::ascii_fingerprint = "101E22EEE714785E462FCF6056B14937"; const uint8_t TAlterTableSetFileFormatParams::binary_fingerprint[16] = {0x10,0x1E,0x22,0xEE,0xE7,0x14,0x78,0x5E,0x46,0x2F,0xCF,0x60,0x56,0xB1,0x49,0x37}; uint32_t TAlterTableSetFileFormatParams::read(::apache::thrift::protocol::TProtocol* iprot) { uint32_t xfer = 0; std::string fname; ::apache::thrift::protocol::TType ftype; int16_t fid; xfer += iprot->readStructBegin(fname); using ::apache::thrift::protocol::TProtocolException; bool isset_file_format = false; while (true) { xfer += iprot->readFieldBegin(fname, ftype, fid); if (ftype == ::apache::thrift::protocol::T_STOP) { break; } switch (fid) { case 1: if (ftype == ::apache::thrift::protocol::T_I32) { int32_t ecast37; xfer += iprot->readI32(ecast37); this->file_format = (TFileFormat::type)ecast37; isset_file_format = true; } else { xfer += iprot->skip(ftype); } break; case 2: if (ftype == ::apache::thrift::protocol::T_LIST) { { this->partition_spec.clear(); uint32_t _size38; ::apache::thrift::protocol::TType _etype41; xfer += iprot->readListBegin(_etype41, _size38); this->partition_spec.resize(_size38); uint32_t _i42; for (_i42 = 0; _i42 < _size38; ++_i42) { xfer += this->partition_spec[_i42].read(iprot); } xfer += iprot->readListEnd(); } this->__isset.partition_spec = true; } else { xfer += iprot->skip(ftype); } break; default: xfer += iprot->skip(ftype); break; } xfer += iprot->readFieldEnd(); } xfer += iprot->readStructEnd(); if (!isset_file_format) throw TProtocolException(TProtocolException::INVALID_DATA); return xfer; } uint32_t TAlterTableSetFileFormatParams::write(::apache::thrift::protocol::TProtocol* oprot) const { uint32_t xfer = 0; uint32_t fcnt = 0; xfer += oprot->writeStructBegin("TAlterTableSetFileFormatParams"); ++fcnt; xfer += oprot->writeFieldBegin("file_format", ::apache::thrift::protocol::T_I32, 1); xfer += oprot->writeI32((int32_t)this->file_format); xfer += oprot->writeFieldEnd(); if (this->__isset.partition_spec) { ++fcnt; xfer += oprot->writeFieldBegin("partition_spec", ::apache::thrift::protocol::T_LIST, 2); { xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRUCT, static_cast<uint32_t>(this->partition_spec.size())); std::vector<TPartitionKeyValue> ::const_iterator _iter43; for (_iter43 = this->partition_spec.begin(); _iter43 != this->partition_spec.end(); ++_iter43) { xfer += (*_iter43).write(oprot); } xfer += oprot->writeListEnd(); } xfer += oprot->writeFieldEnd(); } xfer += oprot->writeFieldStop(); xfer += oprot->writeStructEnd(); return xfer; } void swap(TAlterTableSetFileFormatParams &a, TAlterTableSetFileFormatParams &b) { using ::std::swap; swap(a.file_format, b.file_format); swap(a.partition_spec, b.partition_spec); swap(a.__isset, b.__isset); } const char* TAlterTableSetLocationParams::ascii_fingerprint = "620BD7B2710FAEABD876BE1FA48F69F0"; const uint8_t TAlterTableSetLocationParams::binary_fingerprint[16] = {0x62,0x0B,0xD7,0xB2,0x71,0x0F,0xAE,0xAB,0xD8,0x76,0xBE,0x1F,0xA4,0x8F,0x69,0xF0}; uint32_t TAlterTableSetLocationParams::read(::apache::thrift::protocol::TProtocol* iprot) { uint32_t xfer = 0; std::string fname; ::apache::thrift::protocol::TType ftype; int16_t fid; xfer += iprot->readStructBegin(fname); using ::apache::thrift::protocol::TProtocolException; bool isset_location = false; while (true) { xfer += iprot->readFieldBegin(fname, ftype, fid); if (ftype == ::apache::thrift::protocol::T_STOP) { break; } switch (fid) { case 1: if (ftype == ::apache::thrift::protocol::T_STRING) { xfer += iprot->readString(this->location); isset_location = true; } else { xfer += iprot->skip(ftype); } break; case 2: if (ftype == ::apache::thrift::protocol::T_LIST) { { this->partition_spec.clear(); uint32_t _size44; ::apache::thrift::protocol::TType _etype47; xfer += iprot->readListBegin(_etype47, _size44); this->partition_spec.resize(_size44); uint32_t _i48; for (_i48 = 0; _i48 < _size44; ++_i48) { xfer += this->partition_spec[_i48].read(iprot); } xfer += iprot->readListEnd(); } this->__isset.partition_spec = true; } else { xfer += iprot->skip(ftype); } break; default: xfer += iprot->skip(ftype); break; } xfer += iprot->readFieldEnd(); } xfer += iprot->readStructEnd(); if (!isset_location) throw TProtocolException(TProtocolException::INVALID_DATA); return xfer; } uint32_t TAlterTableSetLocationParams::write(::apache::thrift::protocol::TProtocol* oprot) const { uint32_t xfer = 0; uint32_t fcnt = 0; xfer += oprot->writeStructBegin("TAlterTableSetLocationParams"); ++fcnt; xfer += oprot->writeFieldBegin("location", ::apache::thrift::protocol::T_STRING, 1); xfer += oprot->writeString(this->location); xfer += oprot->writeFieldEnd(); if (this->__isset.partition_spec) { ++fcnt; xfer += oprot->writeFieldBegin("partition_spec", ::apache::thrift::protocol::T_LIST, 2); { xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRUCT, static_cast<uint32_t>(this->partition_spec.size())); std::vector<TPartitionKeyValue> ::const_iterator _iter49; for (_iter49 = this->partition_spec.begin(); _iter49 != this->partition_spec.end(); ++_iter49) { xfer += (*_iter49).write(oprot); } xfer += oprot->writeListEnd(); } xfer += oprot->writeFieldEnd(); } xfer += oprot->writeFieldStop(); xfer += oprot->writeStructEnd(); return xfer; } void swap(TAlterTableSetLocationParams &a, TAlterTableSetLocationParams &b) { using ::std::swap; swap(a.location, b.location); swap(a.partition_spec, b.partition_spec); swap(a.__isset, b.__isset); } const char* TAlterTableParams::ascii_fingerprint = "8F534EA99B58367B90C40A9C386F9A64"; const uint8_t TAlterTableParams::binary_fingerprint[16] = {0x8F,0x53,0x4E,0xA9,0x9B,0x58,0x36,0x7B,0x90,0xC4,0x0A,0x9C,0x38,0x6F,0x9A,0x64}; uint32_t TAlterTableParams::read(::apache::thrift::protocol::TProtocol* iprot) { uint32_t xfer = 0; std::string fname; ::apache::thrift::protocol::TType ftype; int16_t fid; xfer += iprot->readStructBegin(fname); using ::apache::thrift::protocol::TProtocolException; bool isset_alter_type = false; bool isset_table_name = false; while (true) { xfer += iprot->readFieldBegin(fname, ftype, fid); if (ftype == ::apache::thrift::protocol::T_STOP) { break; } switch (fid) { case 1: if (ftype == ::apache::thrift::protocol::T_I32) { int32_t ecast50; xfer += iprot->readI32(ecast50); this->alter_type = (TAlterTableType::type)ecast50; isset_alter_type = true; } else { xfer += iprot->skip(ftype); } break; case 2: if (ftype == ::apache::thrift::protocol::T_STRUCT) { xfer += this->table_name.read(iprot); isset_table_name = true; } else { xfer += iprot->skip(ftype); } break; case 3: if (ftype == ::apache::thrift::protocol::T_STRUCT) { xfer += this->rename_params.read(iprot); this->__isset.rename_params = true; } else { xfer += iprot->skip(ftype); } break; case 4: if (ftype == ::apache::thrift::protocol::T_STRUCT) { xfer += this->add_replace_cols_params.read(iprot); this->__isset.add_replace_cols_params = true; } else { xfer += iprot->skip(ftype); } break; case 5: if (ftype == ::apache::thrift::protocol::T_STRUCT) { xfer += this->add_partition_params.read(iprot); this->__isset.add_partition_params = true; } else { xfer += iprot->skip(ftype); } break; case 6: if (ftype == ::apache::thrift::protocol::T_STRUCT) { xfer += this->change_col_params.read(iprot); this->__isset.change_col_params = true; } else { xfer += iprot->skip(ftype); } break; case 7: if (ftype == ::apache::thrift::protocol::T_STRUCT) { xfer += this->drop_col_params.read(iprot); this->__isset.drop_col_params = true; } else { xfer += iprot->skip(ftype); } break; case 8: if (ftype == ::apache::thrift::protocol::T_STRUCT) { xfer += this->drop_partition_params.read(iprot); this->__isset.drop_partition_params = true; } else { xfer += iprot->skip(ftype); } break; case 9: if (ftype == ::apache::thrift::protocol::T_STRUCT) { xfer += this->set_file_format_params.read(iprot); this->__isset.set_file_format_params = true; } else { xfer += iprot->skip(ftype); } break; case 10: if (ftype == ::apache::thrift::protocol::T_STRUCT) { xfer += this->set_location_params.read(iprot); this->__isset.set_location_params = true; } else { xfer += iprot->skip(ftype); } break; default: xfer += iprot->skip(ftype); break; } xfer += iprot->readFieldEnd(); } xfer += iprot->readStructEnd(); if (!isset_alter_type) throw TProtocolException(TProtocolException::INVALID_DATA); if (!isset_table_name) throw TProtocolException(TProtocolException::INVALID_DATA); return xfer; } uint32_t TAlterTableParams::write(::apache::thrift::protocol::TProtocol* oprot) const { uint32_t xfer = 0; uint32_t fcnt = 0; xfer += oprot->writeStructBegin("TAlterTableParams"); ++fcnt; xfer += oprot->writeFieldBegin("alter_type", ::apache::thrift::protocol::T_I32, 1); xfer += oprot->writeI32((int32_t)this->alter_type); xfer += oprot->writeFieldEnd(); ++fcnt; xfer += oprot->writeFieldBegin("table_name", ::apache::thrift::protocol::T_STRUCT, 2); xfer += this->table_name.write(oprot); xfer += oprot->writeFieldEnd(); if (this->__isset.rename_params) { ++fcnt; xfer += oprot->writeFieldBegin("rename_params", ::apache::thrift::protocol::T_STRUCT, 3); xfer += this->rename_params.write(oprot); xfer += oprot->writeFieldEnd(); } if (this->__isset.add_replace_cols_params) { ++fcnt; xfer += oprot->writeFieldBegin("add_replace_cols_params", ::apache::thrift::protocol::T_STRUCT, 4); xfer += this->add_replace_cols_params.write(oprot); xfer += oprot->writeFieldEnd(); } if (this->__isset.add_partition_params) { ++fcnt; xfer += oprot->writeFieldBegin("add_partition_params", ::apache::thrift::protocol::T_STRUCT, 5); xfer += this->add_partition_params.write(oprot); xfer += oprot->writeFieldEnd(); } if (this->__isset.change_col_params) { ++fcnt; xfer += oprot->writeFieldBegin("change_col_params", ::apache::thrift::protocol::T_STRUCT, 6); xfer += this->change_col_params.write(oprot); xfer += oprot->writeFieldEnd(); } if (this->__isset.drop_col_params) { ++fcnt; xfer += oprot->writeFieldBegin("drop_col_params", ::apache::thrift::protocol::T_STRUCT, 7); xfer += this->drop_col_params.write(oprot); xfer += oprot->writeFieldEnd(); } if (this->__isset.drop_partition_params) { ++fcnt; xfer += oprot->writeFieldBegin("drop_partition_params", ::apache::thrift::protocol::T_STRUCT, 8); xfer += this->drop_partition_params.write(oprot); xfer += oprot->writeFieldEnd(); } if (this->__isset.set_file_format_params) { ++fcnt; xfer += oprot->writeFieldBegin("set_file_format_params", ::apache::thrift::protocol::T_STRUCT, 9); xfer += this->set_file_format_params.write(oprot); xfer += oprot->writeFieldEnd(); } if (this->__isset.set_location_params) { ++fcnt; xfer += oprot->writeFieldBegin("set_location_params", ::apache::thrift::protocol::T_STRUCT, 10); xfer += this->set_location_params.write(oprot); xfer += oprot->writeFieldEnd(); } xfer += oprot->writeFieldStop(); xfer += oprot->writeStructEnd(); return xfer; } void swap(TAlterTableParams &a, TAlterTableParams &b) { using ::std::swap; swap(a.alter_type, b.alter_type); swap(a.table_name, b.table_name); swap(a.rename_params, b.rename_params); swap(a.add_replace_cols_params, b.add_replace_cols_params); swap(a.add_partition_params, b.add_partition_params); swap(a.change_col_params, b.change_col_params); swap(a.drop_col_params, b.drop_col_params); swap(a.drop_partition_params, b.drop_partition_params); swap(a.set_file_format_params, b.set_file_format_params); swap(a.set_location_params, b.set_location_params); swap(a.__isset, b.__isset); } const char* TCreateTableLikeParams::ascii_fingerprint = "7BEC16F01713BB030792212D7EDE7C30"; const uint8_t TCreateTableLikeParams::binary_fingerprint[16] = {0x7B,0xEC,0x16,0xF0,0x17,0x13,0xBB,0x03,0x07,0x92,0x21,0x2D,0x7E,0xDE,0x7C,0x30}; uint32_t TCreateTableLikeParams::read(::apache::thrift::protocol::TProtocol* iprot) { uint32_t xfer = 0; std::string fname; ::apache::thrift::protocol::TType ftype; int16_t fid; xfer += iprot->readStructBegin(fname); using ::apache::thrift::protocol::TProtocolException; bool isset_table_name = false; bool isset_src_table_name = false; bool isset_is_external = false; bool isset_if_not_exists = false; bool isset_owner = false; while (true) { xfer += iprot->readFieldBegin(fname, ftype, fid); if (ftype == ::apache::thrift::protocol::T_STOP) { break; } switch (fid) { case 1: if (ftype == ::apache::thrift::protocol::T_STRUCT) { xfer += this->table_name.read(iprot); isset_table_name = true; } else { xfer += iprot->skip(ftype); } break; case 2: if (ftype == ::apache::thrift::protocol::T_STRUCT) { xfer += this->src_table_name.read(iprot); isset_src_table_name = true; } else { xfer += iprot->skip(ftype); } break; case 3: if (ftype == ::apache::thrift::protocol::T_BOOL) { xfer += iprot->readBool(this->is_external); isset_is_external = true; } else { xfer += iprot->skip(ftype); } break; case 4: if (ftype == ::apache::thrift::protocol::T_BOOL) { xfer += iprot->readBool(this->if_not_exists); isset_if_not_exists = true; } else { xfer += iprot->skip(ftype); } break; case 5: if (ftype == ::apache::thrift::protocol::T_STRING) { xfer += iprot->readString(this->owner); isset_owner = true; } else { xfer += iprot->skip(ftype); } break; case 6: if (ftype == ::apache::thrift::protocol::T_I32) { int32_t ecast51; xfer += iprot->readI32(ecast51); this->file_format = (TFileFormat::type)ecast51; this->__isset.file_format = true; } else { xfer += iprot->skip(ftype); } break; case 7: if (ftype == ::apache::thrift::protocol::T_STRING) { xfer += iprot->readString(this->comment); this->__isset.comment = true; } else { xfer += iprot->skip(ftype); } break; case 8: if (ftype == ::apache::thrift::protocol::T_STRING) { xfer += iprot->readString(this->location); this->__isset.location = true; } else { xfer += iprot->skip(ftype); } break; default: xfer += iprot->skip(ftype); break; } xfer += iprot->readFieldEnd(); } xfer += iprot->readStructEnd(); if (!isset_table_name) throw TProtocolException(TProtocolException::INVALID_DATA); if (!isset_src_table_name) throw TProtocolException(TProtocolException::INVALID_DATA); if (!isset_is_external) throw TProtocolException(TProtocolException::INVALID_DATA); if (!isset_if_not_exists) throw TProtocolException(TProtocolException::INVALID_DATA); if (!isset_owner) throw TProtocolException(TProtocolException::INVALID_DATA); return xfer; } uint32_t TCreateTableLikeParams::write(::apache::thrift::protocol::TProtocol* oprot) const { uint32_t xfer = 0; uint32_t fcnt = 0; xfer += oprot->writeStructBegin("TCreateTableLikeParams"); ++fcnt; xfer += oprot->writeFieldBegin("table_name", ::apache::thrift::protocol::T_STRUCT, 1); xfer += this->table_name.write(oprot); xfer += oprot->writeFieldEnd(); ++fcnt; xfer += oprot->writeFieldBegin("src_table_name", ::apache::thrift::protocol::T_STRUCT, 2); xfer += this->src_table_name.write(oprot); xfer += oprot->writeFieldEnd(); ++fcnt; xfer += oprot->writeFieldBegin("is_external", ::apache::thrift::protocol::T_BOOL, 3); xfer += oprot->writeBool(this->is_external); xfer += oprot->writeFieldEnd(); ++fcnt; xfer += oprot->writeFieldBegin("if_not_exists", ::apache::thrift::protocol::T_BOOL, 4); xfer += oprot->writeBool(this->if_not_exists); xfer += oprot->writeFieldEnd(); ++fcnt; xfer += oprot->writeFieldBegin("owner", ::apache::thrift::protocol::T_STRING, 5); xfer += oprot->writeString(this->owner); xfer += oprot->writeFieldEnd(); if (this->__isset.file_format) { ++fcnt; xfer += oprot->writeFieldBegin("file_format", ::apache::thrift::protocol::T_I32, 6); xfer += oprot->writeI32((int32_t)this->file_format); xfer += oprot->writeFieldEnd(); } if (this->__isset.comment) { ++fcnt; xfer += oprot->writeFieldBegin("comment", ::apache::thrift::protocol::T_STRING, 7); xfer += oprot->writeString(this->comment); xfer += oprot->writeFieldEnd(); } if (this->__isset.location) { ++fcnt; xfer += oprot->writeFieldBegin("location", ::apache::thrift::protocol::T_STRING, 8); xfer += oprot->writeString(this->location); xfer += oprot->writeFieldEnd(); } xfer += oprot->writeFieldStop(); xfer += oprot->writeStructEnd(); return xfer; } void swap(TCreateTableLikeParams &a, TCreateTableLikeParams &b) { using ::std::swap; swap(a.table_name, b.table_name); swap(a.src_table_name, b.src_table_name); swap(a.is_external, b.is_external); swap(a.if_not_exists, b.if_not_exists); swap(a.owner, b.owner); swap(a.file_format, b.file_format); swap(a.comment, b.comment); swap(a.location, b.location); swap(a.__isset, b.__isset); } const char* TCreateTableParams::ascii_fingerprint = "A806D16923885311424912DE4D07024D"; const uint8_t TCreateTableParams::binary_fingerprint[16] = {0xA8,0x06,0xD1,0x69,0x23,0x88,0x53,0x11,0x42,0x49,0x12,0xDE,0x4D,0x07,0x02,0x4D}; uint32_t TCreateTableParams::read(::apache::thrift::protocol::TProtocol* iprot) { uint32_t xfer = 0; std::string fname; ::apache::thrift::protocol::TType ftype; int16_t fid; xfer += iprot->readStructBegin(fname); using ::apache::thrift::protocol::TProtocolException; bool isset_table_name = false; bool isset_columns = false; bool isset_file_format = false; bool isset_is_external = false; bool isset_if_not_exists = false; bool isset_owner = false; while (true) { xfer += iprot->readFieldBegin(fname, ftype, fid); if (ftype == ::apache::thrift::protocol::T_STOP) { break; } switch (fid) { case 1: if (ftype == ::apache::thrift::protocol::T_STRUCT) { xfer += this->table_name.read(iprot); isset_table_name = true; } else { xfer += iprot->skip(ftype); } break; case 2: if (ftype == ::apache::thrift::protocol::T_LIST) { { this->columns.clear(); uint32_t _size52; ::apache::thrift::protocol::TType _etype55; xfer += iprot->readListBegin(_etype55, _size52); this->columns.resize(_size52); uint32_t _i56; for (_i56 = 0; _i56 < _size52; ++_i56) { xfer += this->columns[_i56].read(iprot); } xfer += iprot->readListEnd(); } isset_columns = true; } else { xfer += iprot->skip(ftype); } break; case 3: if (ftype == ::apache::thrift::protocol::T_LIST) { { this->partition_columns.clear(); uint32_t _size57; ::apache::thrift::protocol::TType _etype60; xfer += iprot->readListBegin(_etype60, _size57); this->partition_columns.resize(_size57); uint32_t _i61; for (_i61 = 0; _i61 < _size57; ++_i61) { xfer += this->partition_columns[_i61].read(iprot); } xfer += iprot->readListEnd(); } this->__isset.partition_columns = true; } else { xfer += iprot->skip(ftype); } break; case 4: if (ftype == ::apache::thrift::protocol::T_I32) { int32_t ecast62; xfer += iprot->readI32(ecast62); this->file_format = (TFileFormat::type)ecast62; isset_file_format = true; } else { xfer += iprot->skip(ftype); } break; case 5: if (ftype == ::apache::thrift::protocol::T_BOOL) { xfer += iprot->readBool(this->is_external); isset_is_external = true; } else { xfer += iprot->skip(ftype); } break; case 6: if (ftype == ::apache::thrift::protocol::T_BOOL) { xfer += iprot->readBool(this->if_not_exists); isset_if_not_exists = true; } else { xfer += iprot->skip(ftype); } break; case 7: if (ftype == ::apache::thrift::protocol::T_STRING) { xfer += iprot->readString(this->owner); isset_owner = true; } else { xfer += iprot->skip(ftype); } break; case 8: if (ftype == ::apache::thrift::protocol::T_STRUCT) { xfer += this->row_format.read(iprot); this->__isset.row_format = true; } else { xfer += iprot->skip(ftype); } break; case 9: if (ftype == ::apache::thrift::protocol::T_STRING) { xfer += iprot->readString(this->comment); this->__isset.comment = true; } else { xfer += iprot->skip(ftype); } break; case 10: if (ftype == ::apache::thrift::protocol::T_STRING) { xfer += iprot->readString(this->location); this->__isset.location = true; } else { xfer += iprot->skip(ftype); } break; default: xfer += iprot->skip(ftype); break; } xfer += iprot->readFieldEnd(); } xfer += iprot->readStructEnd(); if (!isset_table_name) throw TProtocolException(TProtocolException::INVALID_DATA); if (!isset_columns) throw TProtocolException(TProtocolException::INVALID_DATA); if (!isset_file_format) throw TProtocolException(TProtocolException::INVALID_DATA); if (!isset_is_external) throw TProtocolException(TProtocolException::INVALID_DATA); if (!isset_if_not_exists) throw TProtocolException(TProtocolException::INVALID_DATA); if (!isset_owner) throw TProtocolException(TProtocolException::INVALID_DATA); return xfer; } uint32_t TCreateTableParams::write(::apache::thrift::protocol::TProtocol* oprot) const { uint32_t xfer = 0; uint32_t fcnt = 0; xfer += oprot->writeStructBegin("TCreateTableParams"); ++fcnt; xfer += oprot->writeFieldBegin("table_name", ::apache::thrift::protocol::T_STRUCT, 1); xfer += this->table_name.write(oprot); xfer += oprot->writeFieldEnd(); ++fcnt; xfer += oprot->writeFieldBegin("columns", ::apache::thrift::protocol::T_LIST, 2); { xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRUCT, static_cast<uint32_t>(this->columns.size())); std::vector<TColumnDef> ::const_iterator _iter63; for (_iter63 = this->columns.begin(); _iter63 != this->columns.end(); ++_iter63) { xfer += (*_iter63).write(oprot); } xfer += oprot->writeListEnd(); } xfer += oprot->writeFieldEnd(); if (this->__isset.partition_columns) { ++fcnt; xfer += oprot->writeFieldBegin("partition_columns", ::apache::thrift::protocol::T_LIST, 3); { xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRUCT, static_cast<uint32_t>(this->partition_columns.size())); std::vector<TColumnDef> ::const_iterator _iter64; for (_iter64 = this->partition_columns.begin(); _iter64 != this->partition_columns.end(); ++_iter64) { xfer += (*_iter64).write(oprot); } xfer += oprot->writeListEnd(); } xfer += oprot->writeFieldEnd(); } ++fcnt; xfer += oprot->writeFieldBegin("file_format", ::apache::thrift::protocol::T_I32, 4); xfer += oprot->writeI32((int32_t)this->file_format); xfer += oprot->writeFieldEnd(); ++fcnt; xfer += oprot->writeFieldBegin("is_external", ::apache::thrift::protocol::T_BOOL, 5); xfer += oprot->writeBool(this->is_external); xfer += oprot->writeFieldEnd(); ++fcnt; xfer += oprot->writeFieldBegin("if_not_exists", ::apache::thrift::protocol::T_BOOL, 6); xfer += oprot->writeBool(this->if_not_exists); xfer += oprot->writeFieldEnd(); ++fcnt; xfer += oprot->writeFieldBegin("owner", ::apache::thrift::protocol::T_STRING, 7); xfer += oprot->writeString(this->owner); xfer += oprot->writeFieldEnd(); if (this->__isset.row_format) { ++fcnt; xfer += oprot->writeFieldBegin("row_format", ::apache::thrift::protocol::T_STRUCT, 8); xfer += this->row_format.write(oprot); xfer += oprot->writeFieldEnd(); } if (this->__isset.comment) { ++fcnt; xfer += oprot->writeFieldBegin("comment", ::apache::thrift::protocol::T_STRING, 9); xfer += oprot->writeString(this->comment); xfer += oprot->writeFieldEnd(); } if (this->__isset.location) { ++fcnt; xfer += oprot->writeFieldBegin("location", ::apache::thrift::protocol::T_STRING, 10); xfer += oprot->writeString(this->location); xfer += oprot->writeFieldEnd(); } xfer += oprot->writeFieldStop(); xfer += oprot->writeStructEnd(); return xfer; } void swap(TCreateTableParams &a, TCreateTableParams &b) { using ::std::swap; swap(a.table_name, b.table_name); swap(a.columns, b.columns); swap(a.partition_columns, b.partition_columns); swap(a.file_format, b.file_format); swap(a.is_external, b.is_external); swap(a.if_not_exists, b.if_not_exists); swap(a.owner, b.owner); swap(a.row_format, b.row_format); swap(a.comment, b.comment); swap(a.location, b.location); swap(a.__isset, b.__isset); } const char* TDropDbParams::ascii_fingerprint = "7D61C9AA00102AB4D8F72A1DA58297DC"; const uint8_t TDropDbParams::binary_fingerprint[16] = {0x7D,0x61,0xC9,0xAA,0x00,0x10,0x2A,0xB4,0xD8,0xF7,0x2A,0x1D,0xA5,0x82,0x97,0xDC}; uint32_t TDropDbParams::read(::apache::thrift::protocol::TProtocol* iprot) { uint32_t xfer = 0; std::string fname; ::apache::thrift::protocol::TType ftype; int16_t fid; xfer += iprot->readStructBegin(fname); using ::apache::thrift::protocol::TProtocolException; bool isset_db = false; bool isset_if_exists = false; while (true) { xfer += iprot->readFieldBegin(fname, ftype, fid); if (ftype == ::apache::thrift::protocol::T_STOP) { break; } switch (fid) { case 1: if (ftype == ::apache::thrift::protocol::T_STRING) { xfer += iprot->readString(this->db); isset_db = true; } else { xfer += iprot->skip(ftype); } break; case 2: if (ftype == ::apache::thrift::protocol::T_BOOL) { xfer += iprot->readBool(this->if_exists); isset_if_exists = true; } else { xfer += iprot->skip(ftype); } break; default: xfer += iprot->skip(ftype); break; } xfer += iprot->readFieldEnd(); } xfer += iprot->readStructEnd(); if (!isset_db) throw TProtocolException(TProtocolException::INVALID_DATA); if (!isset_if_exists) throw TProtocolException(TProtocolException::INVALID_DATA); return xfer; } uint32_t TDropDbParams::write(::apache::thrift::protocol::TProtocol* oprot) const { uint32_t xfer = 0; uint32_t fcnt = 0; xfer += oprot->writeStructBegin("TDropDbParams"); ++fcnt; xfer += oprot->writeFieldBegin("db", ::apache::thrift::protocol::T_STRING, 1); xfer += oprot->writeString(this->db); xfer += oprot->writeFieldEnd(); ++fcnt; xfer += oprot->writeFieldBegin("if_exists", ::apache::thrift::protocol::T_BOOL, 2); xfer += oprot->writeBool(this->if_exists); xfer += oprot->writeFieldEnd(); xfer += oprot->writeFieldStop(); xfer += oprot->writeStructEnd(); return xfer; } void swap(TDropDbParams &a, TDropDbParams &b) { using ::std::swap; swap(a.db, b.db); swap(a.if_exists, b.if_exists); } const char* TDropTableParams::ascii_fingerprint = "790158CF902C527D004C99E60A2E4B2E"; const uint8_t TDropTableParams::binary_fingerprint[16] = {0x79,0x01,0x58,0xCF,0x90,0x2C,0x52,0x7D,0x00,0x4C,0x99,0xE6,0x0A,0x2E,0x4B,0x2E}; uint32_t TDropTableParams::read(::apache::thrift::protocol::TProtocol* iprot) { uint32_t xfer = 0; std::string fname; ::apache::thrift::protocol::TType ftype; int16_t fid; xfer += iprot->readStructBegin(fname); using ::apache::thrift::protocol::TProtocolException; bool isset_table_name = false; bool isset_if_exists = false; while (true) { xfer += iprot->readFieldBegin(fname, ftype, fid); if (ftype == ::apache::thrift::protocol::T_STOP) { break; } switch (fid) { case 1: if (ftype == ::apache::thrift::protocol::T_STRUCT) { xfer += this->table_name.read(iprot); isset_table_name = true; } else { xfer += iprot->skip(ftype); } break; case 2: if (ftype == ::apache::thrift::protocol::T_BOOL) { xfer += iprot->readBool(this->if_exists); isset_if_exists = true; } else { xfer += iprot->skip(ftype); } break; default: xfer += iprot->skip(ftype); break; } xfer += iprot->readFieldEnd(); } xfer += iprot->readStructEnd(); if (!isset_table_name) throw TProtocolException(TProtocolException::INVALID_DATA); if (!isset_if_exists) throw TProtocolException(TProtocolException::INVALID_DATA); return xfer; } uint32_t TDropTableParams::write(::apache::thrift::protocol::TProtocol* oprot) const { uint32_t xfer = 0; uint32_t fcnt = 0; xfer += oprot->writeStructBegin("TDropTableParams"); ++fcnt; xfer += oprot->writeFieldBegin("table_name", ::apache::thrift::protocol::T_STRUCT, 1); xfer += this->table_name.write(oprot); xfer += oprot->writeFieldEnd(); ++fcnt; xfer += oprot->writeFieldBegin("if_exists", ::apache::thrift::protocol::T_BOOL, 2); xfer += oprot->writeBool(this->if_exists); xfer += oprot->writeFieldEnd(); xfer += oprot->writeFieldStop(); xfer += oprot->writeStructEnd(); return xfer; } void swap(TDropTableParams &a, TDropTableParams &b) { using ::std::swap; swap(a.table_name, b.table_name); swap(a.if_exists, b.if_exists); } const char* TSessionState::ascii_fingerprint = "07A9615F837F7D0A952B595DD3020972"; const uint8_t TSessionState::binary_fingerprint[16] = {0x07,0xA9,0x61,0x5F,0x83,0x7F,0x7D,0x0A,0x95,0x2B,0x59,0x5D,0xD3,0x02,0x09,0x72}; uint32_t TSessionState::read(::apache::thrift::protocol::TProtocol* iprot) { uint32_t xfer = 0; std::string fname; ::apache::thrift::protocol::TType ftype; int16_t fid; xfer += iprot->readStructBegin(fname); using ::apache::thrift::protocol::TProtocolException; bool isset_database = false; bool isset_user = false; while (true) { xfer += iprot->readFieldBegin(fname, ftype, fid); if (ftype == ::apache::thrift::protocol::T_STOP) { break; } switch (fid) { case 1: if (ftype == ::apache::thrift::protocol::T_STRING) { xfer += iprot->readString(this->database); isset_database = true; } else { xfer += iprot->skip(ftype); } break; case 2: if (ftype == ::apache::thrift::protocol::T_STRING) { xfer += iprot->readString(this->user); isset_user = true; } else { xfer += iprot->skip(ftype); } break; default: xfer += iprot->skip(ftype); break; } xfer += iprot->readFieldEnd(); } xfer += iprot->readStructEnd(); if (!isset_database) throw TProtocolException(TProtocolException::INVALID_DATA); if (!isset_user) throw TProtocolException(TProtocolException::INVALID_DATA); return xfer; } uint32_t TSessionState::write(::apache::thrift::protocol::TProtocol* oprot) const { uint32_t xfer = 0; uint32_t fcnt = 0; xfer += oprot->writeStructBegin("TSessionState"); ++fcnt; xfer += oprot->writeFieldBegin("database", ::apache::thrift::protocol::T_STRING, 1); xfer += oprot->writeString(this->database); xfer += oprot->writeFieldEnd(); ++fcnt; xfer += oprot->writeFieldBegin("user", ::apache::thrift::protocol::T_STRING, 2); xfer += oprot->writeString(this->user); xfer += oprot->writeFieldEnd(); xfer += oprot->writeFieldStop(); xfer += oprot->writeStructEnd(); return xfer; } void swap(TSessionState &a, TSessionState &b) { using ::std::swap; swap(a.database, b.database); swap(a.user, b.user); } const char* TClientRequest::ascii_fingerprint = "AEEBB37EB85D30D8B07D47726C1C3058"; const uint8_t TClientRequest::binary_fingerprint[16] = {0xAE,0xEB,0xB3,0x7E,0xB8,0x5D,0x30,0xD8,0xB0,0x7D,0x47,0x72,0x6C,0x1C,0x30,0x58}; uint32_t TClientRequest::read(::apache::thrift::protocol::TProtocol* iprot) { uint32_t xfer = 0; std::string fname; ::apache::thrift::protocol::TType ftype; int16_t fid; xfer += iprot->readStructBegin(fname); using ::apache::thrift::protocol::TProtocolException; bool isset_stmt = false; bool isset_queryOptions = false; bool isset_sessionState = false; while (true) { xfer += iprot->readFieldBegin(fname, ftype, fid); if (ftype == ::apache::thrift::protocol::T_STOP) { break; } switch (fid) { case 1: if (ftype == ::apache::thrift::protocol::T_STRING) { xfer += iprot->readString(this->stmt); isset_stmt = true; } else { xfer += iprot->skip(ftype); } break; case 2: if (ftype == ::apache::thrift::protocol::T_STRUCT) { xfer += this->queryOptions.read(iprot); isset_queryOptions = true; } else { xfer += iprot->skip(ftype); } break; case 3: if (ftype == ::apache::thrift::protocol::T_STRUCT) { xfer += this->sessionState.read(iprot); isset_sessionState = true; } else { xfer += iprot->skip(ftype); } break; default: xfer += iprot->skip(ftype); break; } xfer += iprot->readFieldEnd(); } xfer += iprot->readStructEnd(); if (!isset_stmt) throw TProtocolException(TProtocolException::INVALID_DATA); if (!isset_queryOptions) throw TProtocolException(TProtocolException::INVALID_DATA); if (!isset_sessionState) throw TProtocolException(TProtocolException::INVALID_DATA); return xfer; } uint32_t TClientRequest::write(::apache::thrift::protocol::TProtocol* oprot) const { uint32_t xfer = 0; uint32_t fcnt = 0; xfer += oprot->writeStructBegin("TClientRequest"); ++fcnt; xfer += oprot->writeFieldBegin("stmt", ::apache::thrift::protocol::T_STRING, 1); xfer += oprot->writeString(this->stmt); xfer += oprot->writeFieldEnd(); ++fcnt; xfer += oprot->writeFieldBegin("queryOptions", ::apache::thrift::protocol::T_STRUCT, 2); xfer += this->queryOptions.write(oprot); xfer += oprot->writeFieldEnd(); ++fcnt; xfer += oprot->writeFieldBegin("sessionState", ::apache::thrift::protocol::T_STRUCT, 3); xfer += this->sessionState.write(oprot); xfer += oprot->writeFieldEnd(); xfer += oprot->writeFieldStop(); xfer += oprot->writeStructEnd(); return xfer; } void swap(TClientRequest &a, TClientRequest &b) { using ::std::swap; swap(a.stmt, b.stmt); swap(a.queryOptions, b.queryOptions); swap(a.sessionState, b.sessionState); } const char* TShowDbsParams::ascii_fingerprint = "66E694018C17E5B65A59AE8F55CCA3CD"; const uint8_t TShowDbsParams::binary_fingerprint[16] = {0x66,0xE6,0x94,0x01,0x8C,0x17,0xE5,0xB6,0x5A,0x59,0xAE,0x8F,0x55,0xCC,0xA3,0xCD}; uint32_t TShowDbsParams::read(::apache::thrift::protocol::TProtocol* iprot) { uint32_t xfer = 0; std::string fname; ::apache::thrift::protocol::TType ftype; int16_t fid; xfer += iprot->readStructBegin(fname); using ::apache::thrift::protocol::TProtocolException; while (true) { xfer += iprot->readFieldBegin(fname, ftype, fid); if (ftype == ::apache::thrift::protocol::T_STOP) { break; } switch (fid) { case 1: if (ftype == ::apache::thrift::protocol::T_STRING) { xfer += iprot->readString(this->show_pattern); this->__isset.show_pattern = true; } else { xfer += iprot->skip(ftype); } break; default: xfer += iprot->skip(ftype); break; } xfer += iprot->readFieldEnd(); } xfer += iprot->readStructEnd(); return xfer; } uint32_t TShowDbsParams::write(::apache::thrift::protocol::TProtocol* oprot) const { uint32_t xfer = 0; uint32_t fcnt = 0; xfer += oprot->writeStructBegin("TShowDbsParams"); if (this->__isset.show_pattern) { ++fcnt; xfer += oprot->writeFieldBegin("show_pattern", ::apache::thrift::protocol::T_STRING, 1); xfer += oprot->writeString(this->show_pattern); xfer += oprot->writeFieldEnd(); } xfer += oprot->writeFieldStop(); xfer += oprot->writeStructEnd(); return xfer; } void swap(TShowDbsParams &a, TShowDbsParams &b) { using ::std::swap; swap(a.show_pattern, b.show_pattern); swap(a.__isset, b.__isset); } const char* TShowTablesParams::ascii_fingerprint = "D0297FC5011701BD87898CC36146A565"; const uint8_t TShowTablesParams::binary_fingerprint[16] = {0xD0,0x29,0x7F,0xC5,0x01,0x17,0x01,0xBD,0x87,0x89,0x8C,0xC3,0x61,0x46,0xA5,0x65}; uint32_t TShowTablesParams::read(::apache::thrift::protocol::TProtocol* iprot) { uint32_t xfer = 0; std::string fname; ::apache::thrift::protocol::TType ftype; int16_t fid; xfer += iprot->readStructBegin(fname); using ::apache::thrift::protocol::TProtocolException; while (true) { xfer += iprot->readFieldBegin(fname, ftype, fid); if (ftype == ::apache::thrift::protocol::T_STOP) { break; } switch (fid) { case 1: if (ftype == ::apache::thrift::protocol::T_STRING) { xfer += iprot->readString(this->db); this->__isset.db = true; } else { xfer += iprot->skip(ftype); } break; case 2: if (ftype == ::apache::thrift::protocol::T_STRING) { xfer += iprot->readString(this->show_pattern); this->__isset.show_pattern = true; } else { xfer += iprot->skip(ftype); } break; default: xfer += iprot->skip(ftype); break; } xfer += iprot->readFieldEnd(); } xfer += iprot->readStructEnd(); return xfer; } uint32_t TShowTablesParams::write(::apache::thrift::protocol::TProtocol* oprot) const { uint32_t xfer = 0; uint32_t fcnt = 0; xfer += oprot->writeStructBegin("TShowTablesParams"); if (this->__isset.db) { ++fcnt; xfer += oprot->writeFieldBegin("db", ::apache::thrift::protocol::T_STRING, 1); xfer += oprot->writeString(this->db); xfer += oprot->writeFieldEnd(); } if (this->__isset.show_pattern) { ++fcnt; xfer += oprot->writeFieldBegin("show_pattern", ::apache::thrift::protocol::T_STRING, 2); xfer += oprot->writeString(this->show_pattern); xfer += oprot->writeFieldEnd(); } xfer += oprot->writeFieldStop(); xfer += oprot->writeStructEnd(); return xfer; } void swap(TShowTablesParams &a, TShowTablesParams &b) { using ::std::swap; swap(a.db, b.db); swap(a.show_pattern, b.show_pattern); swap(a.__isset, b.__isset); } const char* TUseDbParams::ascii_fingerprint = "EFB929595D312AC8F305D5A794CFEDA1"; const uint8_t TUseDbParams::binary_fingerprint[16] = {0xEF,0xB9,0x29,0x59,0x5D,0x31,0x2A,0xC8,0xF3,0x05,0xD5,0xA7,0x94,0xCF,0xED,0xA1}; uint32_t TUseDbParams::read(::apache::thrift::protocol::TProtocol* iprot) { uint32_t xfer = 0; std::string fname; ::apache::thrift::protocol::TType ftype; int16_t fid; xfer += iprot->readStructBegin(fname); using ::apache::thrift::protocol::TProtocolException; bool isset_db = false; while (true) { xfer += iprot->readFieldBegin(fname, ftype, fid); if (ftype == ::apache::thrift::protocol::T_STOP) { break; } switch (fid) { case 1: if (ftype == ::apache::thrift::protocol::T_STRING) { xfer += iprot->readString(this->db); isset_db = true; } else { xfer += iprot->skip(ftype); } break; default: xfer += iprot->skip(ftype); break; } xfer += iprot->readFieldEnd(); } xfer += iprot->readStructEnd(); if (!isset_db) throw TProtocolException(TProtocolException::INVALID_DATA); return xfer; } uint32_t TUseDbParams::write(::apache::thrift::protocol::TProtocol* oprot) const { uint32_t xfer = 0; uint32_t fcnt = 0; xfer += oprot->writeStructBegin("TUseDbParams"); ++fcnt; xfer += oprot->writeFieldBegin("db", ::apache::thrift::protocol::T_STRING, 1); xfer += oprot->writeString(this->db); xfer += oprot->writeFieldEnd(); xfer += oprot->writeFieldStop(); xfer += oprot->writeStructEnd(); return xfer; } void swap(TUseDbParams &a, TUseDbParams &b) { using ::std::swap; swap(a.db, b.db); } const char* TExplainResult::ascii_fingerprint = "33B1AC796556B5D176326D0D2FCA5450"; const uint8_t TExplainResult::binary_fingerprint[16] = {0x33,0xB1,0xAC,0x79,0x65,0x56,0xB5,0xD1,0x76,0x32,0x6D,0x0D,0x2F,0xCA,0x54,0x50}; uint32_t TExplainResult::read(::apache::thrift::protocol::TProtocol* iprot) { uint32_t xfer = 0; std::string fname; ::apache::thrift::protocol::TType ftype; int16_t fid; xfer += iprot->readStructBegin(fname); using ::apache::thrift::protocol::TProtocolException; bool isset_results = false; while (true) { xfer += iprot->readFieldBegin(fname, ftype, fid); if (ftype == ::apache::thrift::protocol::T_STOP) { break; } switch (fid) { case 1: if (ftype == ::apache::thrift::protocol::T_LIST) { { this->results.clear(); uint32_t _size65; ::apache::thrift::protocol::TType _etype68; xfer += iprot->readListBegin(_etype68, _size65); this->results.resize(_size65); uint32_t _i69; for (_i69 = 0; _i69 < _size65; ++_i69) { xfer += this->results[_i69].read(iprot); } xfer += iprot->readListEnd(); } isset_results = true; } else { xfer += iprot->skip(ftype); } break; default: xfer += iprot->skip(ftype); break; } xfer += iprot->readFieldEnd(); } xfer += iprot->readStructEnd(); if (!isset_results) throw TProtocolException(TProtocolException::INVALID_DATA); return xfer; } uint32_t TExplainResult::write(::apache::thrift::protocol::TProtocol* oprot) const { uint32_t xfer = 0; uint32_t fcnt = 0; xfer += oprot->writeStructBegin("TExplainResult"); ++fcnt; xfer += oprot->writeFieldBegin("results", ::apache::thrift::protocol::T_LIST, 1); { xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRUCT, static_cast<uint32_t>(this->results.size())); std::vector< ::impala::TResultRow> ::const_iterator _iter70; for (_iter70 = this->results.begin(); _iter70 != this->results.end(); ++_iter70) { xfer += (*_iter70).write(oprot); } xfer += oprot->writeListEnd(); } xfer += oprot->writeFieldEnd(); xfer += oprot->writeFieldStop(); xfer += oprot->writeStructEnd(); return xfer; } void swap(TExplainResult &a, TExplainResult &b) { using ::std::swap; swap(a.results, b.results); } const char* TResultSetMetadata::ascii_fingerprint = "D50C2F9EC7D3B85649634752C0F64DC3"; const uint8_t TResultSetMetadata::binary_fingerprint[16] = {0xD5,0x0C,0x2F,0x9E,0xC7,0xD3,0xB8,0x56,0x49,0x63,0x47,0x52,0xC0,0xF6,0x4D,0xC3}; uint32_t TResultSetMetadata::read(::apache::thrift::protocol::TProtocol* iprot) { uint32_t xfer = 0; std::string fname; ::apache::thrift::protocol::TType ftype; int16_t fid; xfer += iprot->readStructBegin(fname); using ::apache::thrift::protocol::TProtocolException; bool isset_columnDescs = false; while (true) { xfer += iprot->readFieldBegin(fname, ftype, fid); if (ftype == ::apache::thrift::protocol::T_STOP) { break; } switch (fid) { case 1: if (ftype == ::apache::thrift::protocol::T_LIST) { { this->columnDescs.clear(); uint32_t _size71; ::apache::thrift::protocol::TType _etype74; xfer += iprot->readListBegin(_etype74, _size71); this->columnDescs.resize(_size71); uint32_t _i75; for (_i75 = 0; _i75 < _size71; ++_i75) { xfer += this->columnDescs[_i75].read(iprot); } xfer += iprot->readListEnd(); } isset_columnDescs = true; } else { xfer += iprot->skip(ftype); } break; default: xfer += iprot->skip(ftype); break; } xfer += iprot->readFieldEnd(); } xfer += iprot->readStructEnd(); if (!isset_columnDescs) throw TProtocolException(TProtocolException::INVALID_DATA); return xfer; } uint32_t TResultSetMetadata::write(::apache::thrift::protocol::TProtocol* oprot) const { uint32_t xfer = 0; uint32_t fcnt = 0; xfer += oprot->writeStructBegin("TResultSetMetadata"); ++fcnt; xfer += oprot->writeFieldBegin("columnDescs", ::apache::thrift::protocol::T_LIST, 1); { xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRUCT, static_cast<uint32_t>(this->columnDescs.size())); std::vector<TColumnDesc> ::const_iterator _iter76; for (_iter76 = this->columnDescs.begin(); _iter76 != this->columnDescs.end(); ++_iter76) { xfer += (*_iter76).write(oprot); } xfer += oprot->writeListEnd(); } xfer += oprot->writeFieldEnd(); xfer += oprot->writeFieldStop(); xfer += oprot->writeStructEnd(); return xfer; } void swap(TResultSetMetadata &a, TResultSetMetadata &b) { using ::std::swap; swap(a.columnDescs, b.columnDescs); } const char* TCatalogUpdate::ascii_fingerprint = "845BD8C082A6EDFE58B66C91C7C24C6E"; const uint8_t TCatalogUpdate::binary_fingerprint[16] = {0x84,0x5B,0xD8,0xC0,0x82,0xA6,0xED,0xFE,0x58,0xB6,0x6C,0x91,0xC7,0xC2,0x4C,0x6E}; uint32_t TCatalogUpdate::read(::apache::thrift::protocol::TProtocol* iprot) { uint32_t xfer = 0; std::string fname; ::apache::thrift::protocol::TType ftype; int16_t fid; xfer += iprot->readStructBegin(fname); using ::apache::thrift::protocol::TProtocolException; bool isset_target_table = false; bool isset_db_name = false; bool isset_created_partitions = false; while (true) { xfer += iprot->readFieldBegin(fname, ftype, fid); if (ftype == ::apache::thrift::protocol::T_STOP) { break; } switch (fid) { case 1: if (ftype == ::apache::thrift::protocol::T_STRING) { xfer += iprot->readString(this->target_table); isset_target_table = true; } else { xfer += iprot->skip(ftype); } break; case 2: if (ftype == ::apache::thrift::protocol::T_STRING) { xfer += iprot->readString(this->db_name); isset_db_name = true; } else { xfer += iprot->skip(ftype); } break; case 3: if (ftype == ::apache::thrift::protocol::T_SET) { { this->created_partitions.clear(); uint32_t _size77; ::apache::thrift::protocol::TType _etype80; xfer += iprot->readSetBegin(_etype80, _size77); uint32_t _i81; for (_i81 = 0; _i81 < _size77; ++_i81) { std::string _elem82; xfer += iprot->readString(_elem82); this->created_partitions.insert(_elem82); } xfer += iprot->readSetEnd(); } isset_created_partitions = true; } else { xfer += iprot->skip(ftype); } break; default: xfer += iprot->skip(ftype); break; } xfer += iprot->readFieldEnd(); } xfer += iprot->readStructEnd(); if (!isset_target_table) throw TProtocolException(TProtocolException::INVALID_DATA); if (!isset_db_name) throw TProtocolException(TProtocolException::INVALID_DATA); if (!isset_created_partitions) throw TProtocolException(TProtocolException::INVALID_DATA); return xfer; } uint32_t TCatalogUpdate::write(::apache::thrift::protocol::TProtocol* oprot) const { uint32_t xfer = 0; uint32_t fcnt = 0; xfer += oprot->writeStructBegin("TCatalogUpdate"); ++fcnt; xfer += oprot->writeFieldBegin("target_table", ::apache::thrift::protocol::T_STRING, 1); xfer += oprot->writeString(this->target_table); xfer += oprot->writeFieldEnd(); ++fcnt; xfer += oprot->writeFieldBegin("db_name", ::apache::thrift::protocol::T_STRING, 2); xfer += oprot->writeString(this->db_name); xfer += oprot->writeFieldEnd(); ++fcnt; xfer += oprot->writeFieldBegin("created_partitions", ::apache::thrift::protocol::T_SET, 3); { xfer += oprot->writeSetBegin(::apache::thrift::protocol::T_STRING, static_cast<uint32_t>(this->created_partitions.size())); std::set<std::string> ::const_iterator _iter83; for (_iter83 = this->created_partitions.begin(); _iter83 != this->created_partitions.end(); ++_iter83) { xfer += oprot->writeString((*_iter83)); } xfer += oprot->writeSetEnd(); } xfer += oprot->writeFieldEnd(); xfer += oprot->writeFieldStop(); xfer += oprot->writeStructEnd(); return xfer; } void swap(TCatalogUpdate &a, TCatalogUpdate &b) { using ::std::swap; swap(a.target_table, b.target_table); swap(a.db_name, b.db_name); swap(a.created_partitions, b.created_partitions); } const char* TFinalizeParams::ascii_fingerprint = "B7080D97FBE64A05254F705FB1FADA7F"; const uint8_t TFinalizeParams::binary_fingerprint[16] = {0xB7,0x08,0x0D,0x97,0xFB,0xE6,0x4A,0x05,0x25,0x4F,0x70,0x5F,0xB1,0xFA,0xDA,0x7F}; uint32_t TFinalizeParams::read(::apache::thrift::protocol::TProtocol* iprot) { uint32_t xfer = 0; std::string fname; ::apache::thrift::protocol::TType ftype; int16_t fid; xfer += iprot->readStructBegin(fname); using ::apache::thrift::protocol::TProtocolException; bool isset_is_overwrite = false; bool isset_hdfs_base_dir = false; bool isset_table_name = false; bool isset_table_db = false; while (true) { xfer += iprot->readFieldBegin(fname, ftype, fid); if (ftype == ::apache::thrift::protocol::T_STOP) { break; } switch (fid) { case 1: if (ftype == ::apache::thrift::protocol::T_BOOL) { xfer += iprot->readBool(this->is_overwrite); isset_is_overwrite = true; } else { xfer += iprot->skip(ftype); } break; case 2: if (ftype == ::apache::thrift::protocol::T_STRING) { xfer += iprot->readString(this->hdfs_base_dir); isset_hdfs_base_dir = true; } else { xfer += iprot->skip(ftype); } break; case 3: if (ftype == ::apache::thrift::protocol::T_STRING) { xfer += iprot->readString(this->table_name); isset_table_name = true; } else { xfer += iprot->skip(ftype); } break; case 4: if (ftype == ::apache::thrift::protocol::T_STRING) { xfer += iprot->readString(this->table_db); isset_table_db = true; } else { xfer += iprot->skip(ftype); } break; default: xfer += iprot->skip(ftype); break; } xfer += iprot->readFieldEnd(); } xfer += iprot->readStructEnd(); if (!isset_is_overwrite) throw TProtocolException(TProtocolException::INVALID_DATA); if (!isset_hdfs_base_dir) throw TProtocolException(TProtocolException::INVALID_DATA); if (!isset_table_name) throw TProtocolException(TProtocolException::INVALID_DATA); if (!isset_table_db) throw TProtocolException(TProtocolException::INVALID_DATA); return xfer; } uint32_t TFinalizeParams::write(::apache::thrift::protocol::TProtocol* oprot) const { uint32_t xfer = 0; uint32_t fcnt = 0; xfer += oprot->writeStructBegin("TFinalizeParams"); ++fcnt; xfer += oprot->writeFieldBegin("is_overwrite", ::apache::thrift::protocol::T_BOOL, 1); xfer += oprot->writeBool(this->is_overwrite); xfer += oprot->writeFieldEnd(); ++fcnt; xfer += oprot->writeFieldBegin("hdfs_base_dir", ::apache::thrift::protocol::T_STRING, 2); xfer += oprot->writeString(this->hdfs_base_dir); xfer += oprot->writeFieldEnd(); ++fcnt; xfer += oprot->writeFieldBegin("table_name", ::apache::thrift::protocol::T_STRING, 3); xfer += oprot->writeString(this->table_name); xfer += oprot->writeFieldEnd(); ++fcnt; xfer += oprot->writeFieldBegin("table_db", ::apache::thrift::protocol::T_STRING, 4); xfer += oprot->writeString(this->table_db); xfer += oprot->writeFieldEnd(); xfer += oprot->writeFieldStop(); xfer += oprot->writeStructEnd(); return xfer; } void swap(TFinalizeParams &a, TFinalizeParams &b) { using ::std::swap; swap(a.is_overwrite, b.is_overwrite); swap(a.hdfs_base_dir, b.hdfs_base_dir); swap(a.table_name, b.table_name); swap(a.table_db, b.table_db); } const char* TQueryExecRequest::ascii_fingerprint = "1D4C017A9088C19C6BE21EB79C551FB1"; const uint8_t TQueryExecRequest::binary_fingerprint[16] = {0x1D,0x4C,0x01,0x7A,0x90,0x88,0xC1,0x9C,0x6B,0xE2,0x1E,0xB7,0x9C,0x55,0x1F,0xB1}; uint32_t TQueryExecRequest::read(::apache::thrift::protocol::TProtocol* iprot) { uint32_t xfer = 0; std::string fname; ::apache::thrift::protocol::TType ftype; int16_t fid; xfer += iprot->readStructBegin(fname); using ::apache::thrift::protocol::TProtocolException; bool isset_fragments = false; bool isset_query_globals = false; bool isset_stmt_type = false; while (true) { xfer += iprot->readFieldBegin(fname, ftype, fid); if (ftype == ::apache::thrift::protocol::T_STOP) { break; } switch (fid) { case 1: if (ftype == ::apache::thrift::protocol::T_STRUCT) { xfer += this->desc_tbl.read(iprot); this->__isset.desc_tbl = true; } else { xfer += iprot->skip(ftype); } break; case 2: if (ftype == ::apache::thrift::protocol::T_LIST) { { this->fragments.clear(); uint32_t _size84; ::apache::thrift::protocol::TType _etype87; xfer += iprot->readListBegin(_etype87, _size84); this->fragments.resize(_size84); uint32_t _i88; for (_i88 = 0; _i88 < _size84; ++_i88) { xfer += this->fragments[_i88].read(iprot); } xfer += iprot->readListEnd(); } isset_fragments = true; } else { xfer += iprot->skip(ftype); } break; case 3: if (ftype == ::apache::thrift::protocol::T_LIST) { { this->dest_fragment_idx.clear(); uint32_t _size89; ::apache::thrift::protocol::TType _etype92; xfer += iprot->readListBegin(_etype92, _size89); this->dest_fragment_idx.resize(_size89); uint32_t _i93; for (_i93 = 0; _i93 < _size89; ++_i93) { xfer += iprot->readI32(this->dest_fragment_idx[_i93]); } xfer += iprot->readListEnd(); } this->__isset.dest_fragment_idx = true; } else { xfer += iprot->skip(ftype); } break; case 4: if (ftype == ::apache::thrift::protocol::T_MAP) { { this->per_node_scan_ranges.clear(); uint32_t _size94; ::apache::thrift::protocol::TType _ktype95; ::apache::thrift::protocol::TType _vtype96; xfer += iprot->readMapBegin(_ktype95, _vtype96, _size94); uint32_t _i98; for (_i98 = 0; _i98 < _size94; ++_i98) { ::impala::TPlanNodeId _key99; xfer += iprot->readI32(_key99); std::vector< ::impala::TScanRangeLocations> & _val100 = this->per_node_scan_ranges[_key99]; { _val100.clear(); uint32_t _size101; ::apache::thrift::protocol::TType _etype104; xfer += iprot->readListBegin(_etype104, _size101); _val100.resize(_size101); uint32_t _i105; for (_i105 = 0; _i105 < _size101; ++_i105) { xfer += _val100[_i105].read(iprot); } xfer += iprot->readListEnd(); } } xfer += iprot->readMapEnd(); } this->__isset.per_node_scan_ranges = true; } else { xfer += iprot->skip(ftype); } break; case 5: if (ftype == ::apache::thrift::protocol::T_STRUCT) { xfer += this->result_set_metadata.read(iprot); this->__isset.result_set_metadata = true; } else { xfer += iprot->skip(ftype); } break; case 6: if (ftype == ::apache::thrift::protocol::T_STRUCT) { xfer += this->finalize_params.read(iprot); this->__isset.finalize_params = true; } else { xfer += iprot->skip(ftype); } break; case 7: if (ftype == ::apache::thrift::protocol::T_STRUCT) { xfer += this->query_globals.read(iprot); isset_query_globals = true; } else { xfer += iprot->skip(ftype); } break; case 8: if (ftype == ::apache::thrift::protocol::T_STRING) { xfer += iprot->readString(this->query_plan); this->__isset.query_plan = true; } else { xfer += iprot->skip(ftype); } break; case 9: if (ftype == ::apache::thrift::protocol::T_I32) { int32_t ecast106; xfer += iprot->readI32(ecast106); this->stmt_type = ( ::impala::TStmtType::type)ecast106; isset_stmt_type = true; } else { xfer += iprot->skip(ftype); } break; default: xfer += iprot->skip(ftype); break; } xfer += iprot->readFieldEnd(); } xfer += iprot->readStructEnd(); if (!isset_fragments) throw TProtocolException(TProtocolException::INVALID_DATA); if (!isset_query_globals) throw TProtocolException(TProtocolException::INVALID_DATA); if (!isset_stmt_type) throw TProtocolException(TProtocolException::INVALID_DATA); return xfer; } uint32_t TQueryExecRequest::write(::apache::thrift::protocol::TProtocol* oprot) const { uint32_t xfer = 0; uint32_t fcnt = 0; xfer += oprot->writeStructBegin("TQueryExecRequest"); if (this->__isset.desc_tbl) { ++fcnt; xfer += oprot->writeFieldBegin("desc_tbl", ::apache::thrift::protocol::T_STRUCT, 1); xfer += this->desc_tbl.write(oprot); xfer += oprot->writeFieldEnd(); } ++fcnt; xfer += oprot->writeFieldBegin("fragments", ::apache::thrift::protocol::T_LIST, 2); { xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRUCT, static_cast<uint32_t>(this->fragments.size())); std::vector< ::impala::TPlanFragment> ::const_iterator _iter107; for (_iter107 = this->fragments.begin(); _iter107 != this->fragments.end(); ++_iter107) { xfer += (*_iter107).write(oprot); } xfer += oprot->writeListEnd(); } xfer += oprot->writeFieldEnd(); if (this->__isset.dest_fragment_idx) { ++fcnt; xfer += oprot->writeFieldBegin("dest_fragment_idx", ::apache::thrift::protocol::T_LIST, 3); { xfer += oprot->writeListBegin(::apache::thrift::protocol::T_I32, static_cast<uint32_t>(this->dest_fragment_idx.size())); std::vector<int32_t> ::const_iterator _iter108; for (_iter108 = this->dest_fragment_idx.begin(); _iter108 != this->dest_fragment_idx.end(); ++_iter108) { xfer += oprot->writeI32((*_iter108)); } xfer += oprot->writeListEnd(); } xfer += oprot->writeFieldEnd(); } if (this->__isset.per_node_scan_ranges) { ++fcnt; xfer += oprot->writeFieldBegin("per_node_scan_ranges", ::apache::thrift::protocol::T_MAP, 4); { xfer += oprot->writeMapBegin(::apache::thrift::protocol::T_I32, ::apache::thrift::protocol::T_LIST, static_cast<uint32_t>(this->per_node_scan_ranges.size())); std::map< ::impala::TPlanNodeId, std::vector< ::impala::TScanRangeLocations> > ::const_iterator _iter109; for (_iter109 = this->per_node_scan_ranges.begin(); _iter109 != this->per_node_scan_ranges.end(); ++_iter109) { xfer += oprot->writeI32(_iter109->first); { xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRUCT, static_cast<uint32_t>(_iter109->second.size())); std::vector< ::impala::TScanRangeLocations> ::const_iterator _iter110; for (_iter110 = _iter109->second.begin(); _iter110 != _iter109->second.end(); ++_iter110) { xfer += (*_iter110).write(oprot); } xfer += oprot->writeListEnd(); } } xfer += oprot->writeMapEnd(); } xfer += oprot->writeFieldEnd(); } if (this->__isset.result_set_metadata) { ++fcnt; xfer += oprot->writeFieldBegin("result_set_metadata", ::apache::thrift::protocol::T_STRUCT, 5); xfer += this->result_set_metadata.write(oprot); xfer += oprot->writeFieldEnd(); } if (this->__isset.finalize_params) { ++fcnt; xfer += oprot->writeFieldBegin("finalize_params", ::apache::thrift::protocol::T_STRUCT, 6); xfer += this->finalize_params.write(oprot); xfer += oprot->writeFieldEnd(); } ++fcnt; xfer += oprot->writeFieldBegin("query_globals", ::apache::thrift::protocol::T_STRUCT, 7); xfer += this->query_globals.write(oprot); xfer += oprot->writeFieldEnd(); if (this->__isset.query_plan) { ++fcnt; xfer += oprot->writeFieldBegin("query_plan", ::apache::thrift::protocol::T_STRING, 8); xfer += oprot->writeString(this->query_plan); xfer += oprot->writeFieldEnd(); } ++fcnt; xfer += oprot->writeFieldBegin("stmt_type", ::apache::thrift::protocol::T_I32, 9); xfer += oprot->writeI32((int32_t)this->stmt_type); xfer += oprot->writeFieldEnd(); xfer += oprot->writeFieldStop(); xfer += oprot->writeStructEnd(); return xfer; } void swap(TQueryExecRequest &a, TQueryExecRequest &b) { using ::std::swap; swap(a.desc_tbl, b.desc_tbl); swap(a.fragments, b.fragments); swap(a.dest_fragment_idx, b.dest_fragment_idx); swap(a.per_node_scan_ranges, b.per_node_scan_ranges); swap(a.result_set_metadata, b.result_set_metadata); swap(a.finalize_params, b.finalize_params); swap(a.query_globals, b.query_globals); swap(a.query_plan, b.query_plan); swap(a.stmt_type, b.stmt_type); swap(a.__isset, b.__isset); } const char* TDdlExecRequest::ascii_fingerprint = "0CD54BC026F4A54FCCF01B6B6F3FADA6"; const uint8_t TDdlExecRequest::binary_fingerprint[16] = {0x0C,0xD5,0x4B,0xC0,0x26,0xF4,0xA5,0x4F,0xCC,0xF0,0x1B,0x6B,0x6F,0x3F,0xAD,0xA6}; uint32_t TDdlExecRequest::read(::apache::thrift::protocol::TProtocol* iprot) { uint32_t xfer = 0; std::string fname; ::apache::thrift::protocol::TType ftype; int16_t fid; xfer += iprot->readStructBegin(fname); using ::apache::thrift::protocol::TProtocolException; bool isset_ddl_type = false; while (true) { xfer += iprot->readFieldBegin(fname, ftype, fid); if (ftype == ::apache::thrift::protocol::T_STOP) { break; } switch (fid) { case 1: if (ftype == ::apache::thrift::protocol::T_I32) { int32_t ecast111; xfer += iprot->readI32(ecast111); this->ddl_type = (TDdlType::type)ecast111; isset_ddl_type = true; } else { xfer += iprot->skip(ftype); } break; case 2: if (ftype == ::apache::thrift::protocol::T_STRUCT) { xfer += this->use_db_params.read(iprot); this->__isset.use_db_params = true; } else { xfer += iprot->skip(ftype); } break; case 3: if (ftype == ::apache::thrift::protocol::T_STRUCT) { xfer += this->describe_table_params.read(iprot); this->__isset.describe_table_params = true; } else { xfer += iprot->skip(ftype); } break; case 4: if (ftype == ::apache::thrift::protocol::T_STRUCT) { xfer += this->show_dbs_params.read(iprot); this->__isset.show_dbs_params = true; } else { xfer += iprot->skip(ftype); } break; case 5: if (ftype == ::apache::thrift::protocol::T_STRUCT) { xfer += this->show_tables_params.read(iprot); this->__isset.show_tables_params = true; } else { xfer += iprot->skip(ftype); } break; case 6: if (ftype == ::apache::thrift::protocol::T_STRUCT) { xfer += this->alter_table_params.read(iprot); this->__isset.alter_table_params = true; } else { xfer += iprot->skip(ftype); } break; case 7: if (ftype == ::apache::thrift::protocol::T_STRUCT) { xfer += this->create_db_params.read(iprot); this->__isset.create_db_params = true; } else { xfer += iprot->skip(ftype); } break; case 8: if (ftype == ::apache::thrift::protocol::T_STRUCT) { xfer += this->create_table_params.read(iprot); this->__isset.create_table_params = true; } else { xfer += iprot->skip(ftype); } break; case 9: if (ftype == ::apache::thrift::protocol::T_STRUCT) { xfer += this->create_table_like_params.read(iprot); this->__isset.create_table_like_params = true; } else { xfer += iprot->skip(ftype); } break; case 10: if (ftype == ::apache::thrift::protocol::T_STRUCT) { xfer += this->drop_db_params.read(iprot); this->__isset.drop_db_params = true; } else { xfer += iprot->skip(ftype); } break; case 11: if (ftype == ::apache::thrift::protocol::T_STRUCT) { xfer += this->drop_table_params.read(iprot); this->__isset.drop_table_params = true; } else { xfer += iprot->skip(ftype); } break; default: xfer += iprot->skip(ftype); break; } xfer += iprot->readFieldEnd(); } xfer += iprot->readStructEnd(); if (!isset_ddl_type) throw TProtocolException(TProtocolException::INVALID_DATA); return xfer; } uint32_t TDdlExecRequest::write(::apache::thrift::protocol::TProtocol* oprot) const { uint32_t xfer = 0; uint32_t fcnt = 0; xfer += oprot->writeStructBegin("TDdlExecRequest"); ++fcnt; xfer += oprot->writeFieldBegin("ddl_type", ::apache::thrift::protocol::T_I32, 1); xfer += oprot->writeI32((int32_t)this->ddl_type); xfer += oprot->writeFieldEnd(); if (this->__isset.use_db_params) { ++fcnt; xfer += oprot->writeFieldBegin("use_db_params", ::apache::thrift::protocol::T_STRUCT, 2); xfer += this->use_db_params.write(oprot); xfer += oprot->writeFieldEnd(); } if (this->__isset.describe_table_params) { ++fcnt; xfer += oprot->writeFieldBegin("describe_table_params", ::apache::thrift::protocol::T_STRUCT, 3); xfer += this->describe_table_params.write(oprot); xfer += oprot->writeFieldEnd(); } if (this->__isset.show_dbs_params) { ++fcnt; xfer += oprot->writeFieldBegin("show_dbs_params", ::apache::thrift::protocol::T_STRUCT, 4); xfer += this->show_dbs_params.write(oprot); xfer += oprot->writeFieldEnd(); } if (this->__isset.show_tables_params) { ++fcnt; xfer += oprot->writeFieldBegin("show_tables_params", ::apache::thrift::protocol::T_STRUCT, 5); xfer += this->show_tables_params.write(oprot); xfer += oprot->writeFieldEnd(); } if (this->__isset.alter_table_params) { ++fcnt; xfer += oprot->writeFieldBegin("alter_table_params", ::apache::thrift::protocol::T_STRUCT, 6); xfer += this->alter_table_params.write(oprot); xfer += oprot->writeFieldEnd(); } if (this->__isset.create_db_params) { ++fcnt; xfer += oprot->writeFieldBegin("create_db_params", ::apache::thrift::protocol::T_STRUCT, 7); xfer += this->create_db_params.write(oprot); xfer += oprot->writeFieldEnd(); } if (this->__isset.create_table_params) { ++fcnt; xfer += oprot->writeFieldBegin("create_table_params", ::apache::thrift::protocol::T_STRUCT, 8); xfer += this->create_table_params.write(oprot); xfer += oprot->writeFieldEnd(); } if (this->__isset.create_table_like_params) { ++fcnt; xfer += oprot->writeFieldBegin("create_table_like_params", ::apache::thrift::protocol::T_STRUCT, 9); xfer += this->create_table_like_params.write(oprot); xfer += oprot->writeFieldEnd(); } if (this->__isset.drop_db_params) { ++fcnt; xfer += oprot->writeFieldBegin("drop_db_params", ::apache::thrift::protocol::T_STRUCT, 10); xfer += this->drop_db_params.write(oprot); xfer += oprot->writeFieldEnd(); } if (this->__isset.drop_table_params) { ++fcnt; xfer += oprot->writeFieldBegin("drop_table_params", ::apache::thrift::protocol::T_STRUCT, 11); xfer += this->drop_table_params.write(oprot); xfer += oprot->writeFieldEnd(); } xfer += oprot->writeFieldStop(); xfer += oprot->writeStructEnd(); return xfer; } void swap(TDdlExecRequest &a, TDdlExecRequest &b) { using ::std::swap; swap(a.ddl_type, b.ddl_type); swap(a.use_db_params, b.use_db_params); swap(a.describe_table_params, b.describe_table_params); swap(a.show_dbs_params, b.show_dbs_params); swap(a.show_tables_params, b.show_tables_params); swap(a.alter_table_params, b.alter_table_params); swap(a.create_db_params, b.create_db_params); swap(a.create_table_params, b.create_table_params); swap(a.create_table_like_params, b.create_table_like_params); swap(a.drop_db_params, b.drop_db_params); swap(a.drop_table_params, b.drop_table_params); swap(a.__isset, b.__isset); } const char* TMetadataOpRequest::ascii_fingerprint = "4F3B3DA03A312B25CD984C98432A660A"; const uint8_t TMetadataOpRequest::binary_fingerprint[16] = {0x4F,0x3B,0x3D,0xA0,0x3A,0x31,0x2B,0x25,0xCD,0x98,0x4C,0x98,0x43,0x2A,0x66,0x0A}; uint32_t TMetadataOpRequest::read(::apache::thrift::protocol::TProtocol* iprot) { uint32_t xfer = 0; std::string fname; ::apache::thrift::protocol::TType ftype; int16_t fid; xfer += iprot->readStructBegin(fname); using ::apache::thrift::protocol::TProtocolException; bool isset_opcode = false; while (true) { xfer += iprot->readFieldBegin(fname, ftype, fid); if (ftype == ::apache::thrift::protocol::T_STOP) { break; } switch (fid) { case 1: if (ftype == ::apache::thrift::protocol::T_I32) { int32_t ecast112; xfer += iprot->readI32(ecast112); this->opcode = (TMetadataOpcode::type)ecast112; isset_opcode = true; } else { xfer += iprot->skip(ftype); } break; case 2: if (ftype == ::apache::thrift::protocol::T_STRUCT) { xfer += this->get_info_req.read(iprot); this->__isset.get_info_req = true; } else { xfer += iprot->skip(ftype); } break; case 3: if (ftype == ::apache::thrift::protocol::T_STRUCT) { xfer += this->get_type_info_req.read(iprot); this->__isset.get_type_info_req = true; } else { xfer += iprot->skip(ftype); } break; case 4: if (ftype == ::apache::thrift::protocol::T_STRUCT) { xfer += this->get_catalogs_req.read(iprot); this->__isset.get_catalogs_req = true; } else { xfer += iprot->skip(ftype); } break; case 5: if (ftype == ::apache::thrift::protocol::T_STRUCT) { xfer += this->get_schemas_req.read(iprot); this->__isset.get_schemas_req = true; } else { xfer += iprot->skip(ftype); } break; case 6: if (ftype == ::apache::thrift::protocol::T_STRUCT) { xfer += this->get_tables_req.read(iprot); this->__isset.get_tables_req = true; } else { xfer += iprot->skip(ftype); } break; case 7: if (ftype == ::apache::thrift::protocol::T_STRUCT) { xfer += this->get_table_types_req.read(iprot); this->__isset.get_table_types_req = true; } else { xfer += iprot->skip(ftype); } break; case 8: if (ftype == ::apache::thrift::protocol::T_STRUCT) { xfer += this->get_columns_req.read(iprot); this->__isset.get_columns_req = true; } else { xfer += iprot->skip(ftype); } break; case 9: if (ftype == ::apache::thrift::protocol::T_STRUCT) { xfer += this->get_functions_req.read(iprot); this->__isset.get_functions_req = true; } else { xfer += iprot->skip(ftype); } break; default: xfer += iprot->skip(ftype); break; } xfer += iprot->readFieldEnd(); } xfer += iprot->readStructEnd(); if (!isset_opcode) throw TProtocolException(TProtocolException::INVALID_DATA); return xfer; } uint32_t TMetadataOpRequest::write(::apache::thrift::protocol::TProtocol* oprot) const { uint32_t xfer = 0; uint32_t fcnt = 0; xfer += oprot->writeStructBegin("TMetadataOpRequest"); ++fcnt; xfer += oprot->writeFieldBegin("opcode", ::apache::thrift::protocol::T_I32, 1); xfer += oprot->writeI32((int32_t)this->opcode); xfer += oprot->writeFieldEnd(); if (this->__isset.get_info_req) { ++fcnt; xfer += oprot->writeFieldBegin("get_info_req", ::apache::thrift::protocol::T_STRUCT, 2); xfer += this->get_info_req.write(oprot); xfer += oprot->writeFieldEnd(); } if (this->__isset.get_type_info_req) { ++fcnt; xfer += oprot->writeFieldBegin("get_type_info_req", ::apache::thrift::protocol::T_STRUCT, 3); xfer += this->get_type_info_req.write(oprot); xfer += oprot->writeFieldEnd(); } if (this->__isset.get_catalogs_req) { ++fcnt; xfer += oprot->writeFieldBegin("get_catalogs_req", ::apache::thrift::protocol::T_STRUCT, 4); xfer += this->get_catalogs_req.write(oprot); xfer += oprot->writeFieldEnd(); } if (this->__isset.get_schemas_req) { ++fcnt; xfer += oprot->writeFieldBegin("get_schemas_req", ::apache::thrift::protocol::T_STRUCT, 5); xfer += this->get_schemas_req.write(oprot); xfer += oprot->writeFieldEnd(); } if (this->__isset.get_tables_req) { ++fcnt; xfer += oprot->writeFieldBegin("get_tables_req", ::apache::thrift::protocol::T_STRUCT, 6); xfer += this->get_tables_req.write(oprot); xfer += oprot->writeFieldEnd(); } if (this->__isset.get_table_types_req) { ++fcnt; xfer += oprot->writeFieldBegin("get_table_types_req", ::apache::thrift::protocol::T_STRUCT, 7); xfer += this->get_table_types_req.write(oprot); xfer += oprot->writeFieldEnd(); } if (this->__isset.get_columns_req) { ++fcnt; xfer += oprot->writeFieldBegin("get_columns_req", ::apache::thrift::protocol::T_STRUCT, 8); xfer += this->get_columns_req.write(oprot); xfer += oprot->writeFieldEnd(); } if (this->__isset.get_functions_req) { ++fcnt; xfer += oprot->writeFieldBegin("get_functions_req", ::apache::thrift::protocol::T_STRUCT, 9); xfer += this->get_functions_req.write(oprot); xfer += oprot->writeFieldEnd(); } xfer += oprot->writeFieldStop(); xfer += oprot->writeStructEnd(); return xfer; } void swap(TMetadataOpRequest &a, TMetadataOpRequest &b) { using ::std::swap; swap(a.opcode, b.opcode); swap(a.get_info_req, b.get_info_req); swap(a.get_type_info_req, b.get_type_info_req); swap(a.get_catalogs_req, b.get_catalogs_req); swap(a.get_schemas_req, b.get_schemas_req); swap(a.get_tables_req, b.get_tables_req); swap(a.get_table_types_req, b.get_table_types_req); swap(a.get_columns_req, b.get_columns_req); swap(a.get_functions_req, b.get_functions_req); swap(a.__isset, b.__isset); } const char* TMetadataOpResponse::ascii_fingerprint = "AA4955CB4C4B7C6D8052EE00C6221E71"; const uint8_t TMetadataOpResponse::binary_fingerprint[16] = {0xAA,0x49,0x55,0xCB,0x4C,0x4B,0x7C,0x6D,0x80,0x52,0xEE,0x00,0xC6,0x22,0x1E,0x71}; uint32_t TMetadataOpResponse::read(::apache::thrift::protocol::TProtocol* iprot) { uint32_t xfer = 0; std::string fname; ::apache::thrift::protocol::TType ftype; int16_t fid; xfer += iprot->readStructBegin(fname); using ::apache::thrift::protocol::TProtocolException; bool isset_result_set_metadata = false; bool isset_results = false; while (true) { xfer += iprot->readFieldBegin(fname, ftype, fid); if (ftype == ::apache::thrift::protocol::T_STOP) { break; } switch (fid) { case 1: if (ftype == ::apache::thrift::protocol::T_STRUCT) { xfer += this->result_set_metadata.read(iprot); isset_result_set_metadata = true; } else { xfer += iprot->skip(ftype); } break; case 2: if (ftype == ::apache::thrift::protocol::T_LIST) { { this->results.clear(); uint32_t _size113; ::apache::thrift::protocol::TType _etype116; xfer += iprot->readListBegin(_etype116, _size113); this->results.resize(_size113); uint32_t _i117; for (_i117 = 0; _i117 < _size113; ++_i117) { xfer += this->results[_i117].read(iprot); } xfer += iprot->readListEnd(); } isset_results = true; } else { xfer += iprot->skip(ftype); } break; default: xfer += iprot->skip(ftype); break; } xfer += iprot->readFieldEnd(); } xfer += iprot->readStructEnd(); if (!isset_result_set_metadata) throw TProtocolException(TProtocolException::INVALID_DATA); if (!isset_results) throw TProtocolException(TProtocolException::INVALID_DATA); return xfer; } uint32_t TMetadataOpResponse::write(::apache::thrift::protocol::TProtocol* oprot) const { uint32_t xfer = 0; uint32_t fcnt = 0; xfer += oprot->writeStructBegin("TMetadataOpResponse"); ++fcnt; xfer += oprot->writeFieldBegin("result_set_metadata", ::apache::thrift::protocol::T_STRUCT, 1); xfer += this->result_set_metadata.write(oprot); xfer += oprot->writeFieldEnd(); ++fcnt; xfer += oprot->writeFieldBegin("results", ::apache::thrift::protocol::T_LIST, 2); { xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRUCT, static_cast<uint32_t>(this->results.size())); std::vector< ::impala::TResultRow> ::const_iterator _iter118; for (_iter118 = this->results.begin(); _iter118 != this->results.end(); ++_iter118) { xfer += (*_iter118).write(oprot); } xfer += oprot->writeListEnd(); } xfer += oprot->writeFieldEnd(); xfer += oprot->writeFieldStop(); xfer += oprot->writeStructEnd(); return xfer; } void swap(TMetadataOpResponse &a, TMetadataOpResponse &b) { using ::std::swap; swap(a.result_set_metadata, b.result_set_metadata); swap(a.results, b.results); } const char* TExecRequest::ascii_fingerprint = "1C016EECD0A86E8488A03ED102679100"; const uint8_t TExecRequest::binary_fingerprint[16] = {0x1C,0x01,0x6E,0xEC,0xD0,0xA8,0x6E,0x84,0x88,0xA0,0x3E,0xD1,0x02,0x67,0x91,0x00}; uint32_t TExecRequest::read(::apache::thrift::protocol::TProtocol* iprot) { uint32_t xfer = 0; std::string fname; ::apache::thrift::protocol::TType ftype; int16_t fid; xfer += iprot->readStructBegin(fname); using ::apache::thrift::protocol::TProtocolException; bool isset_stmt_type = false; bool isset_query_options = false; while (true) { xfer += iprot->readFieldBegin(fname, ftype, fid); if (ftype == ::apache::thrift::protocol::T_STOP) { break; } switch (fid) { case 1: if (ftype == ::apache::thrift::protocol::T_I32) { int32_t ecast119; xfer += iprot->readI32(ecast119); this->stmt_type = ( ::impala::TStmtType::type)ecast119; isset_stmt_type = true; } else { xfer += iprot->skip(ftype); } break; case 2: if (ftype == ::apache::thrift::protocol::T_STRUCT) { xfer += this->query_options.read(iprot); isset_query_options = true; } else { xfer += iprot->skip(ftype); } break; case 3: if (ftype == ::apache::thrift::protocol::T_STRUCT) { xfer += this->query_exec_request.read(iprot); this->__isset.query_exec_request = true; } else { xfer += iprot->skip(ftype); } break; case 4: if (ftype == ::apache::thrift::protocol::T_STRUCT) { xfer += this->ddl_exec_request.read(iprot); this->__isset.ddl_exec_request = true; } else { xfer += iprot->skip(ftype); } break; case 5: if (ftype == ::apache::thrift::protocol::T_STRUCT) { xfer += this->result_set_metadata.read(iprot); this->__isset.result_set_metadata = true; } else { xfer += iprot->skip(ftype); } break; case 6: if (ftype == ::apache::thrift::protocol::T_STRUCT) { xfer += this->explain_result.read(iprot); this->__isset.explain_result = true; } else { xfer += iprot->skip(ftype); } break; default: xfer += iprot->skip(ftype); break; } xfer += iprot->readFieldEnd(); } xfer += iprot->readStructEnd(); if (!isset_stmt_type) throw TProtocolException(TProtocolException::INVALID_DATA); if (!isset_query_options) throw TProtocolException(TProtocolException::INVALID_DATA); return xfer; } uint32_t TExecRequest::write(::apache::thrift::protocol::TProtocol* oprot) const { uint32_t xfer = 0; uint32_t fcnt = 0; xfer += oprot->writeStructBegin("TExecRequest"); ++fcnt; xfer += oprot->writeFieldBegin("stmt_type", ::apache::thrift::protocol::T_I32, 1); xfer += oprot->writeI32((int32_t)this->stmt_type); xfer += oprot->writeFieldEnd(); ++fcnt; xfer += oprot->writeFieldBegin("query_options", ::apache::thrift::protocol::T_STRUCT, 2); xfer += this->query_options.write(oprot); xfer += oprot->writeFieldEnd(); if (this->__isset.query_exec_request) { ++fcnt; xfer += oprot->writeFieldBegin("query_exec_request", ::apache::thrift::protocol::T_STRUCT, 3); xfer += this->query_exec_request.write(oprot); xfer += oprot->writeFieldEnd(); } if (this->__isset.ddl_exec_request) { ++fcnt; xfer += oprot->writeFieldBegin("ddl_exec_request", ::apache::thrift::protocol::T_STRUCT, 4); xfer += this->ddl_exec_request.write(oprot); xfer += oprot->writeFieldEnd(); } if (this->__isset.result_set_metadata) { ++fcnt; xfer += oprot->writeFieldBegin("result_set_metadata", ::apache::thrift::protocol::T_STRUCT, 5); xfer += this->result_set_metadata.write(oprot); xfer += oprot->writeFieldEnd(); } if (this->__isset.explain_result) { ++fcnt; xfer += oprot->writeFieldBegin("explain_result", ::apache::thrift::protocol::T_STRUCT, 6); xfer += this->explain_result.write(oprot); xfer += oprot->writeFieldEnd(); } xfer += oprot->writeFieldStop(); xfer += oprot->writeStructEnd(); return xfer; } void swap(TExecRequest &a, TExecRequest &b) { using ::std::swap; swap(a.stmt_type, b.stmt_type); swap(a.query_options, b.query_options); swap(a.query_exec_request, b.query_exec_request); swap(a.ddl_exec_request, b.ddl_exec_request); swap(a.result_set_metadata, b.result_set_metadata); swap(a.explain_result, b.explain_result); swap(a.__isset, b.__isset); } } // namespace
[ "hlshih@gmail.com" ]
hlshih@gmail.com
99022096b56dedc0d40c695934faf466c0df6e80
4a65b0e5b77d57a6dde55e2bf001c415f148ef21
/Src/EditableStringView.cpp
9e89d173e341a15f4d0e8af9df98f728792b6e46
[ "MIT" ]
permissive
thinkpractice/bme
99829da10f79b224cececb996ba1480d11dab2d1
8f55457fa2900e41ff112188b8683b4312e99d73
refs/heads/master
2021-06-01T22:26:05.779520
2016-11-19T17:24:40
2016-11-19T17:24:40
56,915,046
1
0
null
null
null
null
UTF-8
C++
false
false
3,578
cpp
/***************************************************************** * Copyright (c) 2005 Tim de Jong * * * * All rights reserved. * * Distributed under the terms of the MIT License. * *****************************************************************/ #ifndef EDITABLE_STRING_VIEW #include "EditableStringView.h" #endif #include <be/app/Messenger.h> #include <be/interface/Window.h> #include <iostream> EditableStringView::EditableStringView(BRect frame, const char *name, const char *text, BMessage *message, const char* label, uint32 resizingMode, uint32 flags) : BControl(frame, name, label, message, resizingMode, flags), m_editing(false) { //construct label view m_labelView = new BStringView(Bounds(), name, text, resizingMode, flags); m_labelView->AddFilter(new MouseDownFilter(this)); AddChild(m_labelView); //construct edit view BRect textRect = Bounds(); m_editView = new BTextView(Bounds(),"editView", textRect, B_FOLLOW_ALL_SIDES, B_WILL_DRAW); m_editView->AddFilter(new KeyFilter(this)); m_editScroll = new BScrollView("editScroll",m_editView); AddChild(m_editScroll); m_editScroll->Hide(); } EditableStringView::~EditableStringView() { } void EditableStringView::MessageReceived(BMessage *message) { switch(message->what) { case K_CHANGE_VIEW_MSG: { m_editing = !m_editing; if (m_editing) { //start the editing process m_editScroll->Show(); m_editView->MakeFocus(true); m_editView->SelectAll(); m_labelView->Hide(); } else { //end editing m_editScroll->Hide(); m_labelView->Show(); m_labelView->SetText(m_editView->Text()); //notify user that the label has been changed Invoke(); } } break; default: BView::MessageReceived(message); break; } } void EditableStringView::SetFont(const BFont *font, uint32 properties) { m_labelView->SetFont(font, properties); m_editView->SetFont(font, properties); BView::SetFont(font, properties); } void EditableStringView::SetText(const char *string) { m_labelView->SetText(string); m_editView->SetText(string); } const char* EditableStringView::Text() const { return m_editView->Text(); } //======================================MouseDownFilter==================================================== MouseDownFilter::MouseDownFilter(BView *owner) : BMessageFilter(B_ANY_DELIVERY,B_ANY_SOURCE), m_owner(owner) { } MouseDownFilter::~MouseDownFilter() { } filter_result MouseDownFilter::Filter(BMessage *message, BHandler **target) { filter_result result = B_DISPATCH_MESSAGE; switch (message->what) { case B_MOUSE_DOWN: { //send message to owner BMessenger owner(m_owner); owner.SendMessage(new BMessage(K_CHANGE_VIEW_MSG)); result = B_SKIP_MESSAGE; } break; } return result; } //=====================================KeyFilter=========================================================== KeyFilter::KeyFilter(BView *owner) : BMessageFilter(B_ANY_DELIVERY,B_ANY_SOURCE), m_owner(owner) { } KeyFilter::~KeyFilter() { } filter_result KeyFilter::Filter(BMessage *message, BHandler **target) { filter_result result = B_DISPATCH_MESSAGE; switch (message->what) { case B_KEY_DOWN: { int8 byte; if (message->FindInt8("byte", &byte) == B_OK) { if (byte == B_ENTER) { //send message to owner BMessenger owner(m_owner); owner.SendMessage(new BMessage(K_CHANGE_VIEW_MSG)); result = B_SKIP_MESSAGE; } } } break; } return result; }
[ "opensource@thinkpractice.nl" ]
opensource@thinkpractice.nl
ef7489c3be39b6d2d486b116b0a217453588bc6f
21e0ab3aa39d592a52f834a8e442cac022580c1d
/10.1.cpp
0a5a2268c5ce71c858a3dac6328be3226099a2ba
[]
no_license
longnt0108/demo
ab2bbeffd9b171a301a9dfd73bf0914eefd75f91
29943897b3d563a5104650934020f364ea5aa408
refs/heads/master
2023-04-07T20:38:18.261498
2020-06-27T14:53:27
2020-06-27T14:53:27
null
0
0
null
null
null
null
UTF-8
C++
false
false
870
cpp
#include<bits/stdc++.h> using namespace std; struct node { long long val; int level; }; int minOperations(long long x) { unordered_set<long long> visit; queue<node> q; node n = {x, 0}; q.push(n); while (!q.empty()) { node t = q.front(); q.pop(); if (t.val == 1) return t.level; visit.insert(t.val); for(long long j=sqrt(t.val);j>1;j--) { if (t.val%j==0) { if(visit.find(t.val/j) == visit.end()) { n.val = t.val/j; n.level = t.level+1; q.push(n); } } } if (visit.find(t.val-1) == visit.end() ) { n.val = t.val-1; n.level = t.level+1; q.push(n); } } } int main() { int t=1; cin>>t; long long n; while (t--) { cin >> n; cout<<minOperations(n)<<endl; } return 0; }
[ "noreply@github.com" ]
longnt0108.noreply@github.com
8ee17980724818e501b03634ca1d051ebcc3bcc6
170957e55bba18bf1c2d44195329b25e3305323c
/Arduino/led_control/led_control.ino
5b61e1285fa1498f1801f300e0cc04ec405138c7
[]
no_license
nikolaevis/Arduino-ultrasonic-sensor-control
7278af2e002a4d641baa4fcfe687d1b53b21499c
11e40ef48577dc046ecc7ee94878853e9aefffad
refs/heads/master
2021-01-01T18:46:30.665629
2018-06-06T11:42:45
2018-06-06T11:42:45
98,433,628
0
0
null
null
null
null
UTF-8
C++
false
false
1,837
ino
/* Simple LED sketch */ int led1 = 3;// Pin 3 int led2 = 4;// Pin 4 int led3 = 5;// Pin 5 void setup() { pinMode(led1, OUTPUT); // Set pin 3 as digital out pinMode(led2, OUTPUT); // Set pin 4 as digital out pinMode(led3, OUTPUT); // Set pin 5 as digital out // Start up serial connection Serial.begin(9600); // baud rate Serial.flush(); } void loop() { String input = ""; // Read any serial input while (Serial.available() > 0) { input += (char) Serial.read(); // Read in one char at a time delay(5); // Delay for 5 ms so the next char has time to be received } //handshake if (input == "<Hello Arduino>"){ Serial.println("<Hello there>"); digitalWrite(led1, HIGH); digitalWrite(led2, HIGH); digitalWrite(led3, HIGH); delay(100); digitalWrite(led1, LOW); digitalWrite(led2, LOW); digitalWrite(led3, LOW); } if (input == "on1") { digitalWrite(led1, HIGH); // on } else if (input == "off1") { digitalWrite(led1, LOW); // off } else if (input == "on2") { digitalWrite(led2, HIGH); // on } else if (input == "off2") { digitalWrite(led2, LOW); // off } else if (input == "on3") { digitalWrite(led3, HIGH); // on } else if (input == "off3") { digitalWrite(led3, LOW); // off } else if (input == "on_all") { digitalWrite(led1, HIGH); // on digitalWrite(led2, HIGH); // on digitalWrite(led3, HIGH); // on } else if (input == "off_all") { digitalWrite(led1, LOW); // on digitalWrite(led2, LOW); // on digitalWrite(led3, LOW); // off } }
[ "igor_nikolaev@cz.ibm.com" ]
igor_nikolaev@cz.ibm.com
f136d6cfad26054247607d98ac7fa0b5818e3d2d
9d2c5d766a9bc46bb9c2e8c2981147c7b8a61edb
/server.cpp
f7e1d9a46f595cc86039436da85e13e7c09d6b4c
[]
no_license
anamika25/TFTP-Server
6202b4fe9b73f1e2db7f07c4652e6356de642c7c
4c508fe8a5ceddfc5f372a1620b5be1cb8d47c7a
refs/heads/master
2021-09-05T18:07:13.753509
2018-01-30T05:11:12
2018-01-30T05:11:12
119,483,050
0
0
null
null
null
null
UTF-8
C++
false
false
11,063
cpp
#include <stdio.h> #include <cstdio> #include <stdlib.h> #include <string.h> #include <unistd.h> #include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> #include <arpa/inet.h> #include <netdb.h> #include <sys/time.h> #include <time.h> #include <iostream> #include <string> #include <set> #include <map> #include <sstream> using namespace std; // port to listen #define PORT "9048" // get sockaddr, IPv4/IPv6 void *get_in_addr(struct sockaddr *socket_addr) { if (socket_addr->sa_family == AF_INET) { return &(((struct sockaddr_in*)socket_addr)->sin_addr); } return &(((struct sockaddr_in6*)socket_addr)->sin6_addr); } struct tftp_packet { int16_t opcode; int16_t blockno; int16_t errcode; char filename[30]; }; struct client_info { struct sockaddr_in client_addr; char filename[30]; struct timeval time_start, time_end; int last_ack; FILE *fp; FILE *fp_end; int16_t block_num; int block_size = false; //bool retran ; }; void packi16 (char *buf, unsigned short int i) { i = htons(i); memcpy(buf,&i,2); } unsigned short int unpacki16(char *buf) { unsigned short int i; memcpy(&i,buf,2); i = ntohs(i); return i; } int main(int argc, char* argv[]) { if(argc!=3) { cout<<"please enter server, server_ip_address, server_port \n"<<endl; } fd_set master; // master file descriptor list fd_set read_fds; // temp file descriptor list for select() /*struct SBCP_packet packet_recv, packet_send; //set<string> user_list; char user_name[16]; char message[512]; char reason[32]; int client_count = 0; string msg="";*/ map<int,client_info*> list_of_clients; struct client_info *client; int fdmax; // maximum file descriptor number int listener; // listening socket descriptor int newfd; // newly accept()ed socket descriptor struct sockaddr_in serveraddr, clientaddr; // client address socklen_t addrlen, templen; char buf[700]; // buffer for incoming data //char buf_send[700]; //buffer for outgoing data //int nbytes; char remoteIP[INET6_ADDRSTRLEN]; //int yes=1; // for setsockopt() SO_REUSEADDR, below int i, j, rv; struct addrinfo hints, *ai, *p; FD_ZERO(&master); // clear the master and temp sets FD_ZERO(&read_fds); // get us a socket and bind it memset(&hints, 0, sizeof hints); hints.ai_family = AF_UNSPEC; hints.ai_socktype = SOCK_DGRAM; hints.ai_flags = AI_PASSIVE; if ((rv = getaddrinfo(argv[1], argv[2], &hints, &ai)) != 0) { fprintf(stderr, "getaddrinfo: %s\n", gai_strerror(rv)); exit(1); } for(p = ai; p != NULL; p = p->ai_next) { listener = socket(p->ai_family, p->ai_socktype, p->ai_protocol); if (listener < 0) { perror("socket error"); continue; } // lose the pesky "address already in use" error message //setsockopt(listener, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(int)); if (bind(listener, p->ai_addr, p->ai_addrlen) < 0) { close(listener); perror("bind error"); continue; } break; } // if we got here, it means we didn't get bound if (p == NULL) { fprintf(stderr, "selectserver: failed to bind\n"); exit(2); } freeaddrinfo(ai); // all done with this /* listen if (listen(listener, 100) == -1) { perror("listen"); exit(3); }*/ // add the listener to the master set FD_SET(listener, &master); // keep track of the biggest file descriptor fdmax = listener; // so far, it's this one // main loop for(;;) { //cout<<"entering main loop"<<endl; read_fds = master; // copy it if (select(fdmax+1, &read_fds, NULL, NULL,NULL) == -1) { perror("select"); exit(4); } //cout<<"listener:"<<listener<<endl; //put check for timeout for (auto it = list_of_clients.begin(); it != list_of_clients.end(); it++) { gettimeofday(&(it->second->time_end), NULL); double interval = it->second->time_end.tv_usec - it->second->time_start.tv_usec; if (interval >= 100000) { cout << "timeout for filename " << it->second->filename << endl; //it->second->retran = true; fseek(it->second->fp, -it->second->block_size, SEEK_CUR); uint16_t opcode = htons(3); uint16_t block_num = htons(it->second->block_num); char buf_send[600] = { 0 }; memcpy(buf_send, &opcode, 2); memcpy(buf_send + 2, &block_num, 2); int size = ftell(it->second->fp_end) - ftell(it->second->fp); if (size >= 512) size = 512; else it->second->last_ack = 1; fread(buf_send + 4, 1, size, it->second->fp); sendto(i, buf_send, size + 4, 0, (struct sockaddr *)&(it->second->client_addr), addrlen); cout << "retransmitting block num= " << it->second->block_num << endl; } } // run through the existing connections looking for data to read for(i = 0; i <= fdmax; i++) { if (FD_ISSET(i, &read_fds)) // we have a client { if(i==listener) //new client { addrlen = sizeof(clientaddr); if(recvfrom(listener, buf, 512,0, (struct sockaddr *)&clientaddr ,(socklen_t*)&addrlen)==-1) { perror("recvfrom"); return -1; } //read packet struct tftp_packet *received; received = (struct tftp_packet *)malloc(sizeof(struct tftp_packet)); received->opcode = unpacki16(buf); //action according to opcode if(received->opcode==1) //RRQ { char temp[30]; int index=2, temp_index=0; while(buf[index]!='\0') { temp[temp_index++] = buf[index++]; } temp[temp_index]='\0'; //received->filename = (char *)malloc(strlen(temp)*sizeof(char)); strcpy(received->filename,temp); newfd = socket(AF_INET, SOCK_DGRAM, 0); //create new socket cout<<"Received RRQ for file "<<received->filename<<" on socket "<<newfd<<endl; if (newfd<0) { perror("accept"); return -1; } FD_SET(newfd, &master); if (newfd > fdmax) fdmax = newfd; srand(time(NULL)); short int client_port = rand() % 1001 + 3000; memset(&serveraddr, 0, sizeof(serveraddr)); serveraddr.sin_family = AF_INET; serveraddr.sin_port = htons(client_port); serveraddr.sin_addr.s_addr = htonl(INADDR_ANY); if (bind(newfd, (struct sockaddr *)&serveraddr, sizeof(serveraddr))<0) { perror("bind"); return 1; } //fill the client information client = new client_info; strcpy(client->filename, received->filename); client->last_ack = 0; client->client_addr = clientaddr; list_of_clients[newfd] = client; list_of_clients[newfd]->fp = fopen(received->filename, "r"); if (list_of_clients[newfd]->fp == NULL) //failed to open the file { uint16_t opcode = htons(5); uint16_t err_code = htons(1); char buf_send[100] = {0}; memcpy(buf_send, &opcode, 2); memcpy(buf_send+2, &err_code, 2); memcpy(buf_send+4, "File not found", strlen("File not found")); addrlen = sizeof(struct sockaddr_in); if (sendto(newfd, buf_send, 100, 0, (struct sockaddr *)&list_of_clients[newfd]->client_addr, addrlen)!=-1) { cout << "Error Message sent: failed to open file"<<endl; } else { cout << "Error Message failed to send"<<endl; } map<int, client_info *>::iterator it = list_of_clients.find(newfd); list_of_clients.erase(it); close(newfd); cout<<"connection closed due to error"<<endl; FD_CLR(newfd, &master); } else { uint16_t opcode = htons(3); uint16_t block_num = htons(1); char buf_send[600] = { 0 }; memcpy(buf_send, &opcode, 2); memcpy(buf_send + 2, &block_num, 2); list_of_clients[newfd]->fp_end = list_of_clients[newfd]->fp; fseek(list_of_clients[newfd]->fp_end, 0, SEEK_END); list_of_clients[newfd]->fp = fopen(received->filename, "r"); //fseek(list_of_clients[newfd]->fp, 0, SEEK_SET); //rewind(list_of_clients[newfd]->fp); int size = ftell(list_of_clients[newfd]->fp_end) - ftell(list_of_clients[newfd]->fp); //cout<<"size="<<size<<endl; if (size >= 512) size = 512; else list_of_clients[newfd]->last_ack = 1; list_of_clients[newfd]->block_size = size; list_of_clients[newfd]->block_num = 1; gettimeofday(&(list_of_clients[newfd]->time_start), NULL); fread(buf_send + 4, 1, size, list_of_clients[newfd]->fp); /* if ( fgets (buf_send , 50 , list_of_clients[newfd]->fp) != NULL ) puts (buf_send); else cout<<"size="<<size; cout<<endl;*/ sendto(newfd, buf_send, size + 4, 0, (struct sockaddr *)&list_of_clients[newfd]->client_addr, addrlen); cout << "sent block num= " << list_of_clients[newfd]->block_num << endl; } } delete(received); } else //old client { addrlen = sizeof(clientaddr); if(recvfrom(i, buf, 512,0, (struct sockaddr *)&clientaddr ,(socklen_t*)&addrlen)==-1) { perror("recvfrom"); return -1; } //read packet struct tftp_packet *received; received = (struct tftp_packet *)malloc(sizeof(struct tftp_packet)); received->opcode = unpacki16(buf); if ((received->opcode == 4)) { if (list_of_clients[i]->last_ack) //connection close as the ACK is for the last block { fclose(list_of_clients[i]->fp); auto it = list_of_clients.find(i); list_of_clients.erase(it); cout<<"file transfer completed"<<endl; break; } received->blockno = unpacki16(buf + 2); if (list_of_clients[i]->block_num == received->blockno) //send the next block with block_num+1 { //fseek(list_of_clients[i]->fp, -list_of_clients[i]->block_size, SEEK_CUR); cout<<"Received ACK for file "<<list_of_clients[i]->filename<<" on socket "<<newfd<<" for block "<<received->blockno<<endl; uint16_t opcode = htons(3); uint16_t block_num = htons(received->blockno + 1); char buf_send[600] = { 0 }; memcpy(buf_send, &opcode, 2); memcpy(buf_send + 2, &block_num, 2); //list_of_clients[i]->fp_end = list_of_clients[newfd]->fp; //fseek(list_of_clients[i]->fp_end, 0, SEEK_END); int size = ftell(list_of_clients[i]->fp_end) - ftell(list_of_clients[i]->fp); //cout<<"size="<<size<<endl; if (size >= 512) size = 512; else list_of_clients[i]->last_ack = 1; list_of_clients[i]->block_size = size; list_of_clients[i]->block_num++; gettimeofday(&(list_of_clients[i]->time_start), NULL); fread(buf_send + 4, 1, size, list_of_clients[i]->fp); sendto(i, buf_send, size + 4, 0, (struct sockaddr *)&list_of_clients[i]->client_addr, addrlen); cout << "sent block num= " <<list_of_clients[i]->block_num << endl; } } delete(received); } } } } return 0; }
[ "{ID?}-{username}@users.noreply.github.com" ]
{ID?}-{username}@users.noreply.github.com
071d9c3301858fecb3e1e406c86c970bb874b952
c6b738445a406886733f4ee39ae71b18b31e22d2
/test/overload/include_pass.cpp
708fc67d84c1eb3a1133520979410808f20a3938
[]
no_license
viboes/tags
4a79810cc48a7a83abefa0e1cfe1ee24d708c510
6285ffa0472da8c6b2f1b7a6d8bbffb800bb9558
refs/heads/master
2021-01-19T01:32:46.758433
2018-04-02T16:26:53
2018-04-02T16:26:53
26,433,487
13
2
null
null
null
null
UTF-8
C++
false
false
14,796
cpp
////////////////////////////////////////////////////////////////////////////// // // (C) Copyright Vicente J. Botet Escriba 2014. // Distributed under the Boost Software License, Version 1.0. // (See accompanying file // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // ////////////////////////////////////////////////////////////////////////////// #include <yafpl/v1/functional/overload.hpp> #include <iostream> #include <string> #include <vector> #include <cassert> #include <boost/detail/lightweight_test.hpp> struct X { X& f(char) { std::cout << "X::f" << std::endl; return *this; } int g(char) { return 33; } bool operator==(X const&) { return true; } }; struct Y { }; struct final_function_object_const final { void operator ()(int arg) const { } }; struct final_function_object_non_const final { void operator ()(int arg) { } }; struct function_with_state { void operator ()(int arg) { invoked = true; } bool invoked = false; }; struct function_without_state { constexpr void operator ()(int arg) const noexcept { } }; struct function_without_state_x { constexpr void operator ()(float arg) const noexcept { } }; struct convertible_to_function_object { operator function_without_state() const { return function_without_state{}; } }; struct function_without_state_throw { void operator ()(int arg) const { throw 1;} }; struct function_without_state2 { constexpr int operator ()(int arg) const noexcept { return arg;} }; struct function_without_state3 { int operator ()(int arg) const noexcept { return arg;} }; struct function_with_rvalue_ref_q { int operator ()(int arg) && { return 1; } int operator ()(int arg) const && { return 2; } int operator ()(int arg) & { return 3;} int operator ()(int arg) const & { return 4;} }; struct final_function_with_rvalue_ref_q final { int operator ()(int arg) && { return 1; } int operator ()(int arg) const && { return 2; } int operator ()(int arg) & { return 3;} int operator ()(int arg) const & { return 4;} }; struct function_with_lvalue_ref_q { void operator ()(int arg) & { } }; struct function_with_no_ref_q { void operator ()(int arg) { } }; struct function_with_ref_q { int operator ()(int arg) & { return 1; } int operator ()(int arg) && { return 2; } }; struct function_with_cv_q { int operator ()(int arg) { return 0; } int operator ()(int arg) const { return 1; } int operator ()(int arg) volatile { return 2; } int operator ()(int arg) const volatile { return 3; } }; int nonMember( float ) { std::cout << "int(float)" << std::endl; return 42; } int nonMember_throw( float ) { throw 1;; } namespace cppljevans { //Purpose: // See if can multi-inherit classes // with member function with same // name but different signature. // //Result: // Works. // //=========== template<int I> struct udt_i /**@brief * User Defined Type. */ { friend std::ostream& operator<< ( std::ostream& os , udt_i const& ) { return os<<"udt_i<"<<I<<">"; } }; template<int I> struct functor_i /**@brief * User Defined Functor. */ { using arg_t=udt_i<I>; void operator()(arg_t const&a) { std::cout<<"functor_i<"<<I<<">::operator()("<<a<<" const&).\n"; } }; template<typename Functor> struct forwarder /**@brief * this->operator() forwards to Functor::operator() */ { Functor functor_v; forwarder(Functor const& functor_a) : functor_v(functor_a) {} using arg_t=typename Functor::arg_t; void operator()(arg_t const&arg_v) { functor_v(arg_v); } }; #ifdef __clang__ template<typename... Functors> struct overloader /**@brief * "Mixin" all the Functors::operator()'s * into this class. */ : public forwarder<Functors>... { overloader(Functors&&... functors_a) : forwarder<Functors>(functors_a)... {} }; #else template<typename... Functors> struct overloader /**@brief * "Mixin" all the Functors::operator()'s * into this class. */ ; template<> struct overloader<> { void operator()() { } }; template<typename Functor0, typename... Functors> struct overloader<Functor0, Functors...> : public forwarder<Functor0>, overloader<Functors...> { overloader(Functor0&& functor0, Functors&&... functors_a) : forwarder<Functor0>(std::forward<Functor0>(functor0)) , overloader<Functors...>(std::forward<Functors>(functors_a)...) {} using forwarder<Functor0>::operator(); using overloader<Functors...>::operator(); }; #endif } int main() { { using namespace cppljevans; overloader < functor_i<0> , functor_i<1> , functor_i<2> > ovldr ( functor_i<0>{} , functor_i<1>{} , functor_i<2>{} ) ; ovldr(udt_i<0>{}); ovldr(udt_i<1>{}); ovldr(udt_i<2>{}); } using namespace yafpl; // { // auto f = overload( // [](int i, double d) {}, // [](std::string str, int i) { // }, // [](double d, int i) { // BOOST_TEST(false); // } // ); // f(1,1); // ambiguous call compile fails // } { final_function_object_const foo; auto f = overload(foo); f(1); } { final_function_object_non_const foo; auto f = overload(foo, // foo should be copied [](std::string str) { BOOST_TEST(false); return 1; } ); f(1); } { final_function_object_const foo; auto f = overload<int>(foo); f(1); } { final_function_object_non_const foo; auto f = overload<int>(foo, // foo should be copied [](std::string str) { BOOST_TEST(false); return 1; } ); f(1); } { final_function_object_non_const foo; overload<int>(foo, [](std::string str) { BOOST_TEST(false); return 1; } )(1); } #if 0 //../include/yafpl/v1/functional/overload.hpp:29:18: error: no member named 'operator()' in 'convertible_to_function_object' // using F::operator(); ~~~^ { convertible_to_function_object foo; auto f = overload<int>(foo); f(1); } #endif { function_without_state foo; auto f = overload<int>(foo, // foo should be copied [](std::string str) { BOOST_TEST(false); return 1; } //, nonMember ); f(1); } { function_without_state foo; auto f = overload(foo, // foo should be copied [](std::string str) { BOOST_TEST(false); }, nonMember ); f(1); } { function_without_state foo; auto f = overload(std::move(foo), // foo should be copied [](std::string str) { BOOST_TEST(false); }, [](...) { std::cout << "int(...)" << std::endl; } ); f(1); } { function_with_state foo; BOOST_TEST(! foo.invoked); overload(std::ref(foo), [](std::string str) { BOOST_TEST(false); })(1); BOOST_TEST(foo.invoked); } { overload(function_with_state{}, [](std::string str) { BOOST_TEST(false); })(1); } { function_with_state foo; BOOST_TEST(! foo.invoked); overload(foo, [](std::string str) { BOOST_TEST(false); })(1); BOOST_TEST(! foo.invoked); } { function_with_state foo; BOOST_TEST(! foo.invoked); overload(std::ref(foo), [](std::string str) { })("aaa"); BOOST_TEST(! foo.invoked); } { auto f = overload( [](int ) { std::cout << "int(int)" << std::endl; return 1; }, [](auto const&) { std::cout << "int(auto const&)" << std::endl; return -1; } ); BOOST_TEST(f(std::vector<int>{}) == -1); } { auto f = overload<int>( [](int ) { std::cout << "int(int)" << std::endl; return 1; }, [](auto const&) { std::cout << "int(auto const&)" << std::endl; return -1; } ); BOOST_TEST(f(std::vector<int>{}) == -1); } { auto f = overload( [](std::vector<int>&& ) { std::cout << "int(std::vector<int>&&)" << std::endl; return 1; }, [](...) { std::cout << "int(...)" << std::endl; return -1; } ); BOOST_TEST(f(std::vector<int>{}) == 1); } { auto f = overload<int>( [](std::vector<int>&& ) { std::cout << "int(std::vector<int>&&)" << std::endl; return 1; }, [](...) { std::cout << "int(...)" << std::endl; return -1; } ); BOOST_TEST(f(std::vector<int>{}) == 1); } { auto f = overload( [](int i) { std::cout << "int(int)" << std::endl; return i; }, [](std::string && i) { std::cout << "string(string&&)" << std::endl; return i; }, [](...) { std::cout << "int(...)" << std::endl; return -1; } ); BOOST_TEST(f(1) == 1); BOOST_TEST(f(std::string("1")) == "1"); BOOST_TEST_EQ(f(X{}), -1); } { auto f = overload<int>( [](int i) { std::cout << "int(int)" << std::endl; return i; }, [](std::string && i) { std::cout << "string(string&&)" << std::endl; return i; }, [](...) { std::cout << "int(...)" << std::endl; return -1; } ); BOOST_TEST(f(1) == 1); BOOST_TEST(f(std::string("1")) == "1"); BOOST_TEST_EQ(f(X{}), -1); } { auto f = overload( nonMember #if defined __GNUC__ and ! defined __clang__ , &X::f #endif , [](...) { std::cout << "int(...)" << std::endl; return -1; } ); BOOST_TEST(f(1.0) == 42); #if defined __GNUC__ and ! defined __clang__ X x; BOOST_TEST(f(x, 'c') == x); #endif BOOST_TEST_EQ(f(Y{}), -1); } { auto f = overload<X&>( &X::f ); X x; BOOST_TEST(f(x, 'c') == x); } { auto f = overload<int>( &X::g ); X x; BOOST_TEST(f(x, 'c') == 33); } { auto f = overload( &X::g ); X x; BOOST_TEST(f(x, 'c') == 33); } { auto f1 = overload( nonMember ); BOOST_TEST(f1(1.0) == 42); } { auto f1 = overload<int>( &nonMember ); BOOST_TEST(f1(1.0) == 42); } { auto f1 = overload( //overload/include_pass.cpp:429:12: error: attempt to use a deleted function &nonMember , &X::g ); X x; BOOST_TEST(f1(x, 'c') == 33); #if defined __GNUC__ and ! defined __clang__ BOOST_TEST(f1(1.0) == 42); #endif } { auto f = overload<int>( nonMember //overload/include_pass.cpp:429:12: error: attempt to use a deleted function , &X::g , [](...) { std::cout << "int(...)" << std::endl; return -1; } ); #if defined __GNUC__ and ! defined __clang__ BOOST_TEST(f(1.0) == 42); #endif X x; BOOST_TEST(f(x, 'c') == 33); #if defined __GNUC__ and ! defined __clang__ BOOST_TEST(f(Y{})== -1); #endif } { constexpr auto f = overload(function_without_state{} #if defined __GNUC__ and ! defined __clang__ , [](std::string str) { return 1; } #endif , nonMember ); static_assert(noexcept(f(1)), ""); f(1); } { constexpr auto f = overload(function_without_state2{} #if defined __GNUC__ and ! defined __clang__ , [](std::string str) { return 1; } #endif ); constexpr auto x = f(1); static_assert(1 == x, ""); } { static_assert(noexcept(function_without_state3{}(1)), ""); constexpr auto f = overload(function_without_state3{}); static_assert(noexcept(f(1)), ""); #if 0 constexpr auto x = f(1); // COMPILE ERROR as expected //overload/include_pass.cpp:409:25: erreur: call to non-constexpr function ‘int function_without_state3::operator()(int) const’ // constexpr auto x = f(1); static_assert(1 == x, ""); #endif auto y = f(1); BOOST_TEST(1 == y); } { static_assert(! noexcept(nonMember_throw(1.0)), ""); constexpr auto f = overload(&nonMember_throw); static_assert(! noexcept(f(1.0)), ""); } { //overload/include_pass.cpp:468:9: note: non-literal type '(lambda at overload/include_pass.cpp:468:9)' cannot be used in a constant expression constexpr auto f = overload<int>(function_without_state2{} #if defined __GNUC__ and ! defined __clang__ , [](std::string str) { return 1; } #endif ); f(1); } { // overload noexcept #if defined __GNUC__ and ! defined __clang__ static_assert(noexcept(overload(function_without_state{},function_without_state_x{})), ""); #endif auto f = overload(function_without_state{},function_without_state_x{}); f(1); } { #if defined __GNUC__ and ! defined __clang__ static_assert(noexcept(overload(nonMember)), ""); #endif auto f = overload(nonMember, [](std::string str) noexcept { return 1; } ); auto y = f(1.0); BOOST_TEST(42 == y); } { auto f = overload(function_with_no_ref_q{}); f(1); } { auto f = overload(function_with_lvalue_ref_q{}); f(1); } { BOOST_TEST(1 ==function_with_rvalue_ref_q{}(1)); BOOST_TEST(1 ==detail::wrap_call<function_with_rvalue_ref_q>(function_with_rvalue_ref_q{})(1)); auto f = overload(function_with_rvalue_ref_q{}); BOOST_TEST_EQ(3, f(1)); } { BOOST_TEST(1 ==overload(function_with_rvalue_ref_q{})(1)); } { auto f = overload(function_with_ref_q{}); BOOST_TEST(1 ==f(1)); } { detail::wrap_call<final_function_with_rvalue_ref_q>(final_function_with_rvalue_ref_q{})(1); BOOST_TEST(1 ==overload(final_function_with_rvalue_ref_q{})(1)); } { auto f = overload(final_function_with_rvalue_ref_q{}); BOOST_TEST(3 ==f(1)); } { BOOST_TEST(2 == overload(function_with_ref_q{})(1)); } { auto f = overload(function_with_cv_q{}); BOOST_TEST(0 ==f(1)); } { const auto f = overload(function_with_cv_q{}); BOOST_TEST(1 ==f(1)); } { volatile auto f = overload(function_with_cv_q{}); BOOST_TEST(2 ==f(1)); } { const volatile auto f = overload(function_with_cv_q{}); BOOST_TEST(3 ==f(1)); } { constexpr auto f = overload(function_with_cv_q{}); BOOST_TEST(1 ==f(1)); } { BOOST_TEST(0 ==overload(function_with_cv_q{})(1)); } return boost::report_errors(); }
[ "vicente.botet@wanadoo.fr" ]
vicente.botet@wanadoo.fr
5140067ed69b9740dab3d1d695da532b8010f542
eaa12bb5236314fccc27241efbc642b0eb1ab1dd
/Source/vendor/glm/ext/scalar_ulp.inl
bb767758a854e05d383ed7588332436f5c649b8c
[]
no_license
AdhavanT/OpenGL_Practice
30b70f9a468ad6e136d4beaad4682d14aff424df
a8b1022edc2b711255eefd332c6db1d77ee78e26
refs/heads/master
2022-12-10T12:28:44.164774
2020-08-22T14:07:55
2020-08-22T14:07:55
243,744,550
0
0
null
null
null
null
UTF-8
C++
false
false
7,161
inl
/// Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. /// /// Developed at SunPro, a Sun Microsystems, Inc. business. /// Permission to use, copy, modify, and distribute this /// software is freely granted, provided that this notice /// is preserved. #include "../detail/type_float.hpp" #include "../ext/scalar_constants.hpp" #include <cmath> #include <cfloat> #if(GLM_COMPILER & GLM_COMPILER_VC) # pragma warning(push) # pragma warning(disable : 4127) #endif typedef union { float value; /* FIXME: Assumes 32 bit int. */ unsigned int word; } ieee_float_shape_type; typedef union { double value; struct { int lsw; int msw; } parts; } ieee_double_shape_type; #define GLM_EXTRACT_WORDS(ix0,ix1,d) \ do { \ ieee_double_shape_type ew_u; \ ew_u.value = (d); \ (ix0) = ew_u.parts.msw; \ (ix1) = ew_u.parts.lsw; \ } while (0) #define GLM_GET_FLOAT_WORD(i,d) \ do { \ ieee_float_shape_type gf_u; \ gf_u.value = (d); \ (i) = gf_u.word; \ } while (0) #define GLM_SET_FLOAT_WORD(d,i) \ do { \ ieee_float_shape_type sf_u; \ sf_u.word = (i); \ (d) = sf_u.value; \ } while (0) #define GLM_INSERT_WORDS(d,ix0,ix1) \ do { \ ieee_double_shape_type iw_u; \ iw_u.parts.msw = (ix0); \ iw_u.parts.lsw = (ix1); \ (d) = iw_u.value; \ } while (0) namespace glm { namespace detail { GLM_FUNC_QUALIFIER float nextafterf(float x, float y) { volatile float t; int hx, hy, ix, iy; GLM_GET_FLOAT_WORD(hx, x); GLM_GET_FLOAT_WORD(hy, y); ix = hx & 0x7fffffff; // |x| iy = hy & 0x7fffffff; // |y| if ((ix > 0x7f800000) || // x is nan (iy > 0x7f800000)) // y is nan return x + y; if (abs(y - x) <= epsilon<float>()) return y; // x=y, return y if (ix == 0) { // x == 0 GLM_SET_FLOAT_WORD(x, (hy & 0x80000000) | 1);// return +-minsubnormal t = x * x; if (abs(t - x) <= epsilon<float>()) return t; else return x; // raise underflow flag } if (hx >= 0) { // x > 0 if (hx > hy) // x > y, x -= ulp hx -= 1; else // x < y, x += ulp hx += 1; } else { // x < 0 if (hy >= 0 || hx > hy) // x < y, x -= ulp hx -= 1; else // x > y, x += ulp hx += 1; } hy = hx & 0x7f800000; if (hy >= 0x7f800000) return x + x; // overflow if (hy < 0x00800000) // underflow { t = x * x; if (abs(t - x) > epsilon<float>()) { // raise underflow flag GLM_SET_FLOAT_WORD(y, hx); return y; } } GLM_SET_FLOAT_WORD(x, hx); return x; } GLM_FUNC_QUALIFIER double nextafter(double x, double y) { volatile double t; int hx, hy, ix, iy; unsigned int lx, ly; GLM_EXTRACT_WORDS(hx, lx, x); GLM_EXTRACT_WORDS(hy, ly, y); ix = hx & 0x7fffffff; // |x| iy = hy & 0x7fffffff; // |y| if (((ix >= 0x7ff00000) && ((ix - 0x7ff00000) | lx) != 0) || // x is nan ((iy >= 0x7ff00000) && ((iy - 0x7ff00000) | ly) != 0)) // y is nan return x + y; if (abs(y - x) <= epsilon<double>()) return y; // x=y, return y if ((ix | lx) == 0) { // x == 0 GLM_INSERT_WORDS(x, hy & 0x80000000, 1); // return +-minsubnormal t = x * x; if (abs(t - x) <= epsilon<double>()) return t; else return x; // raise underflow flag } if (hx >= 0) { // x > 0 if (hx > hy || ((hx == hy) && (lx > ly))) { // x > y, x -= ulp if (lx == 0) hx -= 1; lx -= 1; } else { // x < y, x += ulp lx += 1; if (lx == 0) hx += 1; } } else { // x < 0 if (hy >= 0 || hx > hy || ((hx == hy) && (lx > ly))) {// x < y, x -= ulp if (lx == 0) hx -= 1; lx -= 1; } else { // x > y, x += ulp lx += 1; if (lx == 0) hx += 1; } } hy = hx & 0x7ff00000; if (hy >= 0x7ff00000) return x + x; // overflow if (hy < 0x00100000) { // underflow t = x * x; if (abs(t - x) > epsilon<double>()) { // raise underflow flag GLM_INSERT_WORDS(y, hx, lx); return y; } } GLM_INSERT_WORDS(x, hx, lx); return x; } }//namespace detail }//namespace glm #if(GLM_COMPILER & GLM_COMPILER_VC) # pragma warning(pop) #endif namespace glm { template<> GLM_FUNC_QUALIFIER float nextFloat(float x) { # if GLM_HAS_CXX11_STL return std::nextafter(x, std::numeric_limits<float>::max()); # elif((GLM_COMPILER & GLM_COMPILER_VC) || ((GLM_COMPILER & GLM_COMPILER_INTEL) && (GLM_PLATFORM & GLM_PLATFORM_WINDOWS))) return detail::nextafterf(x, FLT_MAX); # elif(GLM_PLATFORM & GLM_PLATFORM_ANDROID) return __builtin_nextafterf(x, FLT_MAX); # else return nextafterf(x, FLT_MAX); # endif } template<> GLM_FUNC_QUALIFIER double nextFloat(double x) { # if GLM_HAS_CXX11_STL return std::nextafter(x, std::numeric_limits<double>::max()); # elif((GLM_COMPILER & GLM_COMPILER_VC) || ((GLM_COMPILER & GLM_COMPILER_INTEL) && (GLM_PLATFORM & GLM_PLATFORM_WINDOWS))) return detail::nextafter(x, std::numeric_limits<double>::max()); # elif(GLM_PLATFORM & GLM_PLATFORM_ANDROID) return __builtin_nextafter(x, DBL_MAX); # else return nextafter(x, DBL_MAX); # endif } template<typename T> GLM_FUNC_QUALIFIER T nextFloat(T x, int ULPs) { GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'next_float' only accept floating-point input"); assert(ULPs >= 0); T temp = x; for (int i = 0; i < ULPs; ++i) temp = nextFloat(temp); return temp; } GLM_FUNC_QUALIFIER float prevFloat(float x) { # if GLM_HAS_CXX11_STL return std::nextafter(x, std::numeric_limits<float>::min()); # elif((GLM_COMPILER & GLM_COMPILER_VC) || ((GLM_COMPILER & GLM_COMPILER_INTEL) && (GLM_PLATFORM & GLM_PLATFORM_WINDOWS))) return detail::nextafterf(x, FLT_MIN); # elif(GLM_PLATFORM & GLM_PLATFORM_ANDROID) return __builtin_nextafterf(x, FLT_MIN); # else return nextafterf(x, FLT_MIN); # endif } GLM_FUNC_QUALIFIER double prevFloat(double x) { # if GLM_HAS_CXX11_STL return std::nextafter(x, std::numeric_limits<double>::min()); # elif((GLM_COMPILER & GLM_COMPILER_VC) || ((GLM_COMPILER & GLM_COMPILER_INTEL) && (GLM_PLATFORM & GLM_PLATFORM_WINDOWS))) return _nextafter(x, DBL_MIN); # elif(GLM_PLATFORM & GLM_PLATFORM_ANDROID) return __builtin_nextafter(x, DBL_MIN); # else return nextafter(x, DBL_MIN); # endif } template<typename T> GLM_FUNC_QUALIFIER T prevFloat(T x, int ULPs) { GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'prev_float' only accept floating-point input"); assert(ULPs >= 0); T temp = x; for (int i = 0; i < ULPs; ++i) temp = prevFloat(temp); return temp; } GLM_FUNC_QUALIFIER int floatDistance(float x, float y) { detail::float_t<float> const a(x); detail::float_t<float> const b(y); return abs(a.i - b.i); } GLM_FUNC_QUALIFIER int64 floatDistance(double x, double y) { detail::float_t<double> const a(x); detail::float_t<double> const b(y); return abs(a.i - b.i); } }//namespace glm
[ "adhavthiru@gmail.com" ]
adhavthiru@gmail.com
bed83d44393ca4b1c55f7f9dd1320dd097c7b371
24893618660f768d9c411c0723ccbe822a628913
/Mammoth/TSE/CDesignTable.cpp
f1dc9c37aba899117bbe92e9857d7ca3ea73e53d
[ "LicenseRef-scancode-warranty-disclaimer" ]
no_license
kronosaur/TranscendenceDev
da4940b77dd1e2846f8d1bfa83e349b1277e506d
a53798ed0f23cbbafa69b85dc1b9ec26b1d5bdda
refs/heads/master
2023-07-09T11:17:37.539313
2023-07-01T05:05:49
2023-07-01T05:05:49
164,558,909
31
14
NOASSERTION
2022-05-12T21:06:30
2019-01-08T04:15:34
C++
UTF-8
C++
false
false
5,722
cpp
// CDesignTable.cpp // // CDesignTable class #include "PreComp.h" ALERROR CDesignTable::AddEntry (CDesignType *pEntry) // AddEntry // // Adds an entry to the table. Returns ERR_OUTOFROOM if we already have an // entry with that UNID. { if (!pEntry) throw CException(ERR_FAIL); bool bNew; m_Table.SetAt(pEntry->GetUNID(), pEntry, &bNew); if (!bNew) return ERR_OUTOFROOM; return NOERROR; } ALERROR CDesignTable::AddOrReplaceEntry (CDesignType *pEntry, CDesignType **retpOldEntry) // AddOrReplaceEntry // // Adds or replaces an entry { bool bAdded; CDesignType **pSlot = m_Table.SetAt(pEntry->GetUNID(), &bAdded); if (retpOldEntry) *retpOldEntry = (!bAdded ? *pSlot : NULL); *pSlot = pEntry; return NOERROR; } void CDesignTable::Delete (DWORD dwUNID) // Delete // // Delete by UNID { int iIndex; if (m_Table.FindPos(dwUNID, &iIndex)) { if (m_bFreeTypes) m_Table[iIndex]->Delete(); m_Table.Delete(iIndex); } } void CDesignTable::DeleteAll (void) // DeleteAll // // Removes all entries and deletes the object that they point to { int i; if (m_bFreeTypes) { for (i = 0; i < GetCount(); i++) GetEntry(i)->Delete(); } m_Table.DeleteAll(); } CDesignType *CDesignTable::FindByUNID (DWORD dwUNID) const // FindByUNID // // Returns a pointer to the given entry or NULL { CDesignType * const *pObj = m_Table.GetAt(dwUNID); return (pObj ? *pObj : NULL); } ALERROR CDesignTable::Merge (const CDynamicDesignTable &Source, CDesignList *ioOverride) // Merge // // Merge the given table into ours. { DEBUG_TRY int i; for (i = 0; i < Source.GetCount(); i++) { CDesignType *pNewType = Source.GetType(i); // If this is an override then we put it on a different table and // leave the type alone. if (pNewType->IsModification()) { if (ioOverride) ioOverride->AddEntry(pNewType); } // Otherwise, add or replace else AddOrReplaceEntry(pNewType); } return NOERROR; DEBUG_CATCH } ALERROR CDesignTable::Merge (const CDesignTable &Source, CDesignList &Override, const TArray<DWORD> &ExtensionsIncluded, const TSortMap<DWORD, bool> &TypesUsed, DWORD dwAPIVersion) // Merge // // Merge the given table into ours. Entries in Table override our entries // if they have the same UNID. { int i; TArray<CDesignType *> Replaced; // We move through both tables in order and handle when we get an // addition or overlap. int iSrcPos = 0; int iDestPos = 0; // Merge while (iSrcPos < Source.GetCount()) { CDesignType *pNewType = Source.m_Table.GetValue(iSrcPos); // If this is an optional type then we need to figure out whether we're // going to include it or not. bool bMustExist = false; bool bExcluded = false; if (pNewType->IsOptional()) { bMustExist = (TypesUsed.GetCount() > 0 && TypesUsed.Find(pNewType->GetUNID())); bExcluded = !pNewType->IsIncluded(dwAPIVersion, ExtensionsIncluded); } // If this is an override type, then we add to a special table. // // NOTE: It is OK if we add multiple types of the same UNID. As long // as we add them in order, we're OK. if (pNewType->IsModification()) { // Modifications always rely on some underlying type, so if we're // excluding this modification, we can skip it, even if the type // itself is required by the save file. if (!bExcluded) Override.AddEntry(pNewType); iSrcPos++; } // If we're at the end of the destination then just insert else if (iDestPos == m_Table.GetCount()) { // Do not add excluded type, unless required by the save file. // The latter can happen if we make a type optional after a save // file has been created. if (!bExcluded || bMustExist) { m_Table.InsertSorted(pNewType->GetUNID(), pNewType); iDestPos++; } // Advance iSrcPos++; } // Otherwise, see if we need to insert or replace else { int iCompare = AscendingSort * KeyCompare(pNewType->GetUNID(), m_Table.GetKey(iDestPos)); // If the same key then we replace if (iCompare == 0) { // We found the UNID in the destination table, so we don't have // to worry about the type existing--it does. if (!bExcluded) { // If we have to free our originals, then remember them here. if (m_bFreeTypes) { CDesignType *pOriginalType = m_Table.GetValue(iDestPos); Replaced.Insert(pOriginalType); } // If the new type is different than the original, then warn // LATER: This should probably be an error. if (m_Table.GetValue(iDestPos)->GetType() != pNewType->GetType()) ::kernelDebugLogPattern("WARNING: Override of %08x is changing the type.", pNewType->GetUNID()); // Replace m_Table.GetValue(iDestPos) = pNewType; // Advance iDestPos++; } iSrcPos++; } // If the source is less than dest then we insert at this // position. else if (iCompare == 1) { if (!bExcluded || bMustExist) { m_Table.InsertSorted(pNewType->GetUNID(), pNewType, iDestPos); iDestPos++; } // Advance iSrcPos++; } // Otherwise, go to the next destination slot else // LATER: We could optimize this case by skipping ahead in an // inner loop. Otherwise we're recalculating pNewType and all // its state (particularly for optional types). iDestPos++; } } // Delete replaced entries for (i = 0; i < Replaced.GetCount(); i++) Replaced[i]->Delete(); return NOERROR; } void CDesignTable::SetHierarchyResolved (bool bValue) // SetHierarchyResolved // // Sets the hierarchy resolved flag. { for (int i = 0; i < m_Table.GetCount(); i++) m_Table[i]->SetHierarchyResolved(bValue); }
[ "public@neurohack.com" ]
public@neurohack.com
162bed304530afad15b3e0fadf0f95f071f1da24
8eb53dd4d630f370f9d878274e445a5806410c23
/addition/CellConnection.h
bca478cc7b7c93350e841e50d33a6300ef33af20
[]
no_license
XCodeMegic/CellView
d2f3e6f986b81084879c69b6dd0b2dbfa27b5481
b37cf54c34fc40eb7895c3bcfc84f3776f64b889
refs/heads/master
2021-01-13T15:37:49.510772
2016-12-20T03:06:39
2016-12-20T03:06:39
76,914,052
0
0
null
null
null
null
UTF-8
C++
false
false
545
h
#pragma once #include "extdefined.h" #include "x_motion.h" #include "connectionlistener.h" class CCellConnection : public gloox::ConnectionListener { public: CCellConnection(gloox::Client *client); virtual ~CCellConnection(); protected: //ConnectionListener virtual void onConnect(); virtual void onDisconnect(gloox::ConnectionError e); virtual bool onTLSConnect(const gloox::CertInfo& info); private: XMotion *m_motion; gloox::Client *m_client; public: void SetMotion(XMotion *mt) { m_motion = mt; } };
[ "xzq_@xxxx.x" ]
xzq_@xxxx.x
3ab55f74b81e9cf44071d5ee247ee642102bca70
d9034557db7da3a94a68b982c708df056d37dcc3
/Libs/Bill/BillRepository.cpp
511bde7e111ceb469aff108441cb8efecc385ef4
[]
no_license
KhoiHoang2410/CoffeeManagement
143febc11500a0b5ede80602fc7f6ff8e1396df0
052eb37dc7241a250e7010063e1be795e1d85936
refs/heads/main
2023-05-01T09:03:54.375712
2021-05-23T08:44:18
2021-05-23T08:44:18
365,730,599
0
0
null
null
null
null
UTF-8
C++
false
false
2,678
cpp
// // BillRepository.cpp // CoffeeManagement // // Created by Khoi Hoang on 21/05/2021. // #include "../../Include/Bill/BillRepository.hpp" #include "../../Include/Helper.hpp" #include <tuple> #include <fstream> #include <iostream> using namespace std; void BillRepository::CreateBill(string employeeName) { billRepository.push_back(Bill(employeeName)); } void BillRepository::AddBill(string employeeName, vector<string> productName, vector<double> price, vector<int> amount) { billRepository.push_back(Bill(employeeName, productName, price, amount)); } void BillRepository::AddItemToBill(string productName, int price) { billRepository.back().AddProduct(productName, price); } void BillRepository::RemoveAnItemFromBill(int id) { billRepository.back().RemoveProduct(id); } void BillRepository::ExportPriceLastBill() const { billRepository.back().Total(); } void BillRepository::ExportLastBill() const { billRepository.back().ExportData(); } bool BillRepository::ExportAllData() const { for (int i=0; i<billRepository.size(); ++i) { billRepository[i].ExportData(); cout << endl; } return 1; } int BillRepository::Size() { return billRepository.size(); } tuple<vector<string>, vector<vector<string> >, vector<vector<int> >, vector<vector<double> > > BillRepository::ImportDataFromFile(string fileName) { ifstream cin(fileName); if (!cin.is_open()) { PutError("BillRepository::ImportDataFromFile", "File not Found", 1); } vector<vector<string> > productNames; vector<vector<int> > amounts; vector<vector<double> > prices; vector<string> employeeNames; int n, m, amount; double price; string employee, productName; cin >> n; OutPut("BillRepository::ImportDataFromFile", fileName + " " + to_string(n)); for(int i=0; i < n; i++) { getline(cin, employee); getline(cin, employee); cin >> m; employeeNames.push_back(employee); productNames.push_back(vector<string>()); amounts.push_back(vector<int>()); prices.push_back(vector<double>()); for (int j=0; j < m; ++j) { getline(cin, productName); getline(cin, productName); cin >> amount >> price; productNames.back().push_back(productName); prices.back().push_back(price); amounts.back().push_back(amount); } } cin.close(); OutPut("BillRepository::ImportDataFromFile", "Import success"); return make_tuple(employeeNames, productNames, amounts, prices); } void BillRepository::AddBill(Bill bill) { billRepository.push_back(bill); }
[ "khoi.hoang@kaligo.com" ]
khoi.hoang@kaligo.com
169f289295df40ddb74b44def83b3c31f2e18b0f
fb3c1e036f18193d6ffe59f443dad8323cb6e371
/src/flash/AVMSWF/api/flash/media/AS3AudioDecoder.h
da858ed910c9eb1a4bddd1eaf752aa696e293c9e
[]
no_license
playbar/nstest
a61aed443af816fdc6e7beab65e935824dcd07b2
d56141912bc2b0e22d1652aa7aff182e05142005
refs/heads/master
2021-06-03T21:56:17.779018
2016-08-01T03:17:39
2016-08-01T03:17:39
64,627,195
3
1
null
null
null
null
UTF-8
C++
false
false
2,197
h
#ifndef _AS3AudioDecoder_ #define _AS3AudioDecoder_ namespace avmplus { namespace NativeID { class AudioDecoderClassSlots { friend class SlotOffsetsAndAsserts; public://Declare your STATIC AS3 slots here!!! // DOLBY_DIGITAL:String = "DolbyDigital" // DOLBY_DIGITAL_PLUS:String = "DolbyDigitalPlus" // DTS:String = "DTS" // DTS_EXPRESS:String = "DTSExpress" // DTS_HD_HIGH_RESOLUTION_AUDIO:String = "DTSHDHighResolutionAudio" // DTS_HD_MASTER_AUDIO:String = "DTSHDMasterAudio" Stringp DOLBY_DIGITAL; Stringp DOLBY_DIGITAL_PLUS; Stringp DTS; Stringp DTS_EXPRESS; Stringp DTS_HD_HIGH_RESOLUTION_AUDIO; Stringp DTS_HD_MASTER_AUDIO; private: }; class AudioDecoderObjectSlots { friend class SlotOffsetsAndAsserts; public: //Declare your MEMBER AS3 slots here!!! private: }; } } namespace avmshell{ class AudioDecoderClass : public ClassClosure//EventClass { public: AudioDecoderClass(VTable *vtable); ScriptObject *createInstance(VTable *ivtable, ScriptObject *delegate); inline Stringp getSlotDOLBY_DIGITAL(){return m_slots_AudioDecoderClass.DOLBY_DIGITAL;} inline Stringp getSlotDOLBY_DIGITAL_PLUS(){return m_slots_AudioDecoderClass.DOLBY_DIGITAL_PLUS;} inline Stringp getSlotDTS(){return m_slots_AudioDecoderClass.DTS;} inline Stringp getSlotDTS_EXPRESS(){return m_slots_AudioDecoderClass.DTS_EXPRESS;} inline Stringp getSlotDTS_HD_HIGH_RESOLUTION_AUDIO(){return m_slots_AudioDecoderClass.DTS_HD_HIGH_RESOLUTION_AUDIO;} inline Stringp getSlotDTS_HD_MASTER_AUDIO(){return m_slots_AudioDecoderClass.DTS_HD_MASTER_AUDIO;} public: private: #ifdef _SYMBIAN public: #endif friend class avmplus::NativeID::SlotOffsetsAndAsserts; avmplus::NativeID::AudioDecoderClassSlots m_slots_AudioDecoderClass; }; class AudioDecoderObject : public ScriptObject { public: AudioDecoderObject(VTable* _vtable, ScriptObject* _delegate, int capacity); private: #ifdef _SYMBIAN public: #endif friend class avmplus::NativeID::SlotOffsetsAndAsserts; avmplus::NativeID::AudioDecoderObjectSlots m_slots_AudioDecoderObject; }; } #endif
[ "hgl868@126.com" ]
hgl868@126.com
c6893b0263737cf2aa782cb2f1b86bb7f4bce8e7
6d64c36b9e0c158829ca11e275fe8759e2bc0eff
/src/qt/addressbookpage.cpp
519ff3652baac8ffc4249be61cddd9877ab7db75
[ "MIT" ]
permissive
thehomosapien/dutcoin
65e4ae372f7622b96df4d80a87706d609c4e56f0
43a2a3e42713260eec7dac62145c991e59bb3287
refs/heads/master
2020-07-01T03:36:21.234004
2019-08-07T13:01:27
2019-08-07T13:01:27
200,853,776
0
0
null
null
null
null
UTF-8
C++
false
false
10,127
cpp
// Copyright (c) 2011-2014 The Bitcoin developers // Copyright (c) 2014-2015 The Dash developers // Copyright (c) 2015-2017 The PIVX developers // Distributed under the MIT/X11 software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #if defined(HAVE_CONFIG_H) #include "config/dutcoin-config.h" #endif #include "addressbookpage.h" #include "ui_addressbookpage.h" #include "addresstablemodel.h" #include "bitcoingui.h" #include "csvmodelwriter.h" #include "editaddressdialog.h" #include "guiutil.h" #include <QIcon> #include <QMenu> #include <QMessageBox> #include <QSortFilterProxyModel> AddressBookPage::AddressBookPage(Mode mode, Tabs tab, QWidget* parent) : QDialog(parent), ui(new Ui::AddressBookPage), model(0), mode(mode), tab(tab) { ui->setupUi(this); #ifdef Q_OS_MAC // Icons on push buttons are very uncommon on Mac ui->newAddress->setIcon(QIcon()); ui->copyAddress->setIcon(QIcon()); ui->deleteAddress->setIcon(QIcon()); ui->exportButton->setIcon(QIcon()); #endif switch (mode) { case ForSelection: switch (tab) { case SendingTab: setWindowTitle(tr("Choose the address to send coins to")); break; case ReceivingTab: setWindowTitle(tr("Choose the address to receive coins with")); break; } connect(ui->tableView, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(accept())); ui->tableView->setEditTriggers(QAbstractItemView::NoEditTriggers); ui->tableView->setFocus(); ui->closeButton->setText(tr("C&hoose")); ui->exportButton->hide(); break; case ForEditing: switch (tab) { case SendingTab: setWindowTitle(tr("Sending addresses")); break; case ReceivingTab: setWindowTitle(tr("Receiving addresses")); break; } break; } switch (tab) { case SendingTab: ui->labelExplanation->setText(tr("These are your DUT addresses for sending payments. Always check the amount and the receiving address before sending coins.")); ui->deleteAddress->setVisible(true); break; case ReceivingTab: ui->labelExplanation->setText(tr("These are your DUT addresses for receiving payments. It is recommended to use a new receiving address for each transaction.")); ui->deleteAddress->setVisible(false); break; } // Context menu actions QAction* copyAddressAction = new QAction(tr("&Copy Address"), this); QAction* copyLabelAction = new QAction(tr("Copy &Label"), this); QAction* editAction = new QAction(tr("&Edit"), this); deleteAction = new QAction(ui->deleteAddress->text(), this); // Build context menu contextMenu = new QMenu(); contextMenu->addAction(copyAddressAction); contextMenu->addAction(copyLabelAction); contextMenu->addAction(editAction); if (tab == SendingTab) contextMenu->addAction(deleteAction); contextMenu->addSeparator(); // Connect signals for context menu actions connect(copyAddressAction, SIGNAL(triggered()), this, SLOT(on_copyAddress_clicked())); connect(copyLabelAction, SIGNAL(triggered()), this, SLOT(onCopyLabelAction())); connect(editAction, SIGNAL(triggered()), this, SLOT(onEditAction())); connect(deleteAction, SIGNAL(triggered()), this, SLOT(on_deleteAddress_clicked())); connect(ui->tableView, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(contextualMenu(QPoint))); connect(ui->closeButton, SIGNAL(clicked()), this, SLOT(accept())); } AddressBookPage::~AddressBookPage() { delete ui; } void AddressBookPage::setModel(AddressTableModel* model) { this->model = model; if (!model) return; proxyModel = new QSortFilterProxyModel(this); proxyModel->setSourceModel(model); proxyModel->setDynamicSortFilter(true); proxyModel->setSortCaseSensitivity(Qt::CaseInsensitive); proxyModel->setFilterCaseSensitivity(Qt::CaseInsensitive); switch (tab) { case ReceivingTab: // Receive filter proxyModel->setFilterRole(AddressTableModel::TypeRole); proxyModel->setFilterFixedString(AddressTableModel::Receive); break; case SendingTab: // Send filter proxyModel->setFilterRole(AddressTableModel::TypeRole); proxyModel->setFilterFixedString(AddressTableModel::Send); break; } ui->tableView->setModel(proxyModel); ui->tableView->sortByColumn(0, Qt::AscendingOrder); // Set column widths #if QT_VERSION < 0x050000 ui->tableView->horizontalHeader()->setResizeMode(AddressTableModel::Label, QHeaderView::Stretch); ui->tableView->horizontalHeader()->setResizeMode(AddressTableModel::Address, QHeaderView::ResizeToContents); #else ui->tableView->horizontalHeader()->setSectionResizeMode(AddressTableModel::Label, QHeaderView::Stretch); ui->tableView->horizontalHeader()->setSectionResizeMode(AddressTableModel::Address, QHeaderView::ResizeToContents); #endif connect(ui->tableView->selectionModel(), SIGNAL(selectionChanged(QItemSelection, QItemSelection)), this, SLOT(selectionChanged())); // Select row for newly created address connect(model, SIGNAL(rowsInserted(QModelIndex, int, int)), this, SLOT(selectNewAddress(QModelIndex, int, int))); selectionChanged(); } void AddressBookPage::on_copyAddress_clicked() { GUIUtil::copyEntryData(ui->tableView, AddressTableModel::Address); } void AddressBookPage::onCopyLabelAction() { GUIUtil::copyEntryData(ui->tableView, AddressTableModel::Label); } void AddressBookPage::onEditAction() { if (!model) return; if (!ui->tableView->selectionModel()) return; QModelIndexList indexes = ui->tableView->selectionModel()->selectedRows(); if (indexes.isEmpty()) return; EditAddressDialog dlg( tab == SendingTab ? EditAddressDialog::EditSendingAddress : EditAddressDialog::EditReceivingAddress, this); dlg.setModel(model); QModelIndex origIndex = proxyModel->mapToSource(indexes.at(0)); dlg.loadRow(origIndex.row()); dlg.exec(); } void AddressBookPage::on_newAddress_clicked() { if (!model) return; EditAddressDialog dlg( tab == SendingTab ? EditAddressDialog::NewSendingAddress : EditAddressDialog::NewReceivingAddress, this); dlg.setModel(model); if (dlg.exec()) { newAddressToSelect = dlg.getAddress(); } } void AddressBookPage::on_deleteAddress_clicked() { QTableView* table = ui->tableView; if (!table->selectionModel()) return; QModelIndexList indexes = table->selectionModel()->selectedRows(); if (!indexes.isEmpty()) { table->model()->removeRow(indexes.at(0).row()); } } void AddressBookPage::selectionChanged() { // Set button states based on selected tab and selection QTableView* table = ui->tableView; if (!table->selectionModel()) return; if (table->selectionModel()->hasSelection()) { switch (tab) { case SendingTab: // In sending tab, allow deletion of selection ui->deleteAddress->setEnabled(true); ui->deleteAddress->setVisible(true); deleteAction->setEnabled(true); break; case ReceivingTab: // Deleting receiving addresses, however, is not allowed ui->deleteAddress->setEnabled(false); ui->deleteAddress->setVisible(false); deleteAction->setEnabled(false); break; } ui->copyAddress->setEnabled(true); } else { ui->deleteAddress->setEnabled(false); ui->copyAddress->setEnabled(false); } } void AddressBookPage::done(int retval) { QTableView* table = ui->tableView; if (!table->selectionModel() || !table->model()) return; // Figure out which address was selected, and return it QModelIndexList indexes = table->selectionModel()->selectedRows(AddressTableModel::Address); foreach (QModelIndex index, indexes) { QVariant address = table->model()->data(index); returnValue = address.toString(); } if (returnValue.isEmpty()) { // If no address entry selected, return rejected retval = Rejected; } QDialog::done(retval); } void AddressBookPage::on_exportButton_clicked() { // CSV is currently the only supported format QString filename = GUIUtil::getSaveFileName(this, tr("Export Address List"), QString(), tr("Comma separated file (*.csv)"), NULL); if (filename.isNull()) return; CSVModelWriter writer(filename); // name, column, role writer.setModel(proxyModel); writer.addColumn("Label", AddressTableModel::Label, Qt::EditRole); writer.addColumn("Address", AddressTableModel::Address, Qt::EditRole); if (!writer.write()) { QMessageBox::critical(this, tr("Exporting Failed"), tr("There was an error trying to save the address list to %1. Please try again.").arg(filename)); } } void AddressBookPage::contextualMenu(const QPoint& point) { QModelIndex index = ui->tableView->indexAt(point); if (index.isValid()) { contextMenu->exec(QCursor::pos()); } } void AddressBookPage::selectNewAddress(const QModelIndex& parent, int begin, int /*end*/) { QModelIndex idx = proxyModel->mapFromSource(model->index(begin, AddressTableModel::Address, parent)); if (idx.isValid() && (idx.data(Qt::EditRole).toString() == newAddressToSelect)) { // Select row of newly created address, once ui->tableView->setFocus(); ui->tableView->selectRow(idx.row()); newAddressToSelect.clear(); } }
[ "rishabhshukla@opulasoft.com" ]
rishabhshukla@opulasoft.com
6d478e5f2c0bf884cd63153dbca54e975746a619
7e9a3bea88da528fc8e201a018612d6e552a238a
/TopicExtraction/ArticleHandler.cpp
ad60f9ecbc15b05e357aef78d98db1c0593086de
[ "BSD-3-Clause" ]
permissive
fusiyuan2010/cs634
0eb4ccb5c3d6fec225b86bd4a8c89de7bf731a44
846c9c36e88ac0a10f98c2b6dffc6dfd87b1f4f4
refs/heads/master
2016-09-03T06:32:11.472042
2014-05-03T22:42:03
2014-05-03T22:42:03
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,913
cpp
#include "ArticleHandler.h" #include <cstdio> #include <cmath> #include <cstring> #include <utility> void SimpleArticleHandler::AddArticle(const std::vector<std::string> &title, const std::vector<std::string> &article, time_t timestamp) { printf("Article %ld:\nTitle:", timestamp); for(const std::string &s : title) { printf("%s ", s.c_str()); } printf("\nContent:"); int acount = 0; for(const std::string &s : article) { printf("%s ", s.c_str()); if (++acount == 20) break; } printf("\n"); } void TFIDFArticleHandler::AddArticle(const std::vector<std::string> &title, const std::vector<std::string> &article, time_t timestamp) { /* currently title is not used */ /* skip too short useless articles */ double avg_len = 0; for(const auto &t : article) { avg_len += t.size(); } avg_len /= (double)article.size(); if (article.size() < 10 || avg_len <= 4.5) return; articles_.emplace_back(Article(title, article, timestamp)); int i = rand() % articles_.size(); /* reorder */ std::swap(articles_[i], articles_[articles_.size() - 1]); } void TFIDFArticleHandler::GetTFIDF() { for(auto &d : articles_) { int max_term_freq = 0; for(auto &t: d.terms_) { if (++d.term_freq_[t] > max_term_freq) max_term_freq = d.term_freq_[t]; } for(const auto &t: d.term_freq_) { df_[t.first]++; if (tfidf_fomula_ == 1) d.term_weight_[t.first] = t.second; else if (tfidf_fomula_ == 2) d.term_weight_[t.first] = 0.5 + 0.5 * t.second / max_term_freq; else d.term_weight_[t.first] = 1; d.freq_terms_.insert(make_pair(t.second, t.first)); } } for(auto &d : articles_) { for(auto &t : d.term_weight_) { if (tfidf_fomula_ != 3) { if (df_[t.first] < 3) continue; t.second *= log(articles_.size() / df_[t.first]); } d.tfidf_terms_.insert(make_pair(t.second, t.first)); } } } void TFIDFArticleHandler::ShowResult(FILE *f) { for(auto &d : articles_) { int i = 0; fprintf(f, "==========================\nTime stamp: %ld\n", d.timestamp_); fprintf(f, "Title: "); for(const auto &s : d.title_) fprintf(f, "%s ", s.c_str()); fprintf(f, "\n"); for(std::map<double, std::string>::const_reverse_iterator it = d.tfidf_terms_.rbegin(); it != d.tfidf_terms_.rend(); ++it) { if (++i <= 20) fprintf(f, "%s : %lf\n", it->second.c_str(), it->first); } } }
[ "fusiyuan2010@gmail.com" ]
fusiyuan2010@gmail.com
67e8df65e35771455e3b1ce337a6cc1544e1cadd
8889c4dd54494a7d6ee63b69922331154ffd6ba4
/app/kubeDimension/dependencies/osrm-backend/extractor/extractor.cpp
029c47c0a3c5a5a2f7ced2214a54f863ca849989
[ "BSD-2-Clause" ]
permissive
hello-web/kubeDimension
27d5e95f7b2d5c5b3743a0a53c6ac2b55c7bc509
a52277e0622676ff65e9d210386aac018e3b43fa
refs/heads/master
2021-05-30T02:19:22.596418
2015-11-30T02:46:21
2015-11-30T02:46:21
null
0
0
null
null
null
null
UTF-8
C++
false
false
23,723
cpp
/* Copyright (c) 2015, Project OSRM contributors All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "extractor.hpp" #include "extraction_containers.hpp" #include "extraction_node.hpp" #include "extraction_way.hpp" #include "extractor_callbacks.hpp" #include "restriction_parser.hpp" #include "scripting_environment.hpp" #include "../data_structures/raster_source.hpp" #include "../util/make_unique.hpp" #include "../util/simple_logger.hpp" #include "../util/timing_util.hpp" #include "../util/lua_util.hpp" #include "../util/graph_loader.hpp" #include "../typedefs.h" #include "../data_structures/static_graph.hpp" #include "../data_structures/static_rtree.hpp" #include "../data_structures/restriction_map.hpp" #include "../data_structures/compressed_edge_container.hpp" #include "../algorithms/tarjan_scc.hpp" #include "../algorithms/crc32_processor.hpp" #include <boost/filesystem.hpp> #include <boost/filesystem/fstream.hpp> #include <boost/optional/optional.hpp> #include <luabind/luabind.hpp> #include <osmium/io/any_input.hpp> #include <tbb/parallel_for.h> #include <tbb/task_scheduler_init.h> #include <cstdlib> #include <algorithm> #include <atomic> #include <chrono> #include <fstream> #include <iostream> #include <thread> #include <unordered_map> #include <vector> /** * TODO: Refactor this function into smaller functions for better readability. * * This function is the entry point for the whole extraction process. The goal of the extraction * step is to filter and convert the OSM geometry to something more fitting for routing. * That includes: * - extracting turn restrictions * - splitting ways into (directional!) edge segments * - checking if nodes are barriers or traffic signal * - discarding all tag information: All relevant type information for nodes/ways * is extracted at this point. * * The result of this process are the following files: * .names : Names of all streets, stored as long consecutive string with prefix sum based index * .osrm : Nodes and edges in a intermediate format that easy to digest for osrm-prepare * .restrictions : Turn restrictions that are used my osrm-prepare to construct the edge-expanded graph * */ int extractor::run() { try { LogPolicy::GetInstance().Unmute(); TIMER_START(extracting); const unsigned recommended_num_threads = tbb::task_scheduler_init::default_num_threads(); const auto number_of_threads = std::min(recommended_num_threads, config.requested_num_threads); tbb::task_scheduler_init init(number_of_threads); SimpleLogger().Write() << "Input file: " << config.input_path.filename().string(); SimpleLogger().Write() << "Profile: " << config.profile_path.filename().string(); SimpleLogger().Write() << "Threads: " << number_of_threads; // setup scripting environment ScriptingEnvironment scripting_environment(config.profile_path.string().c_str()); ExtractionContainers extraction_containers; auto extractor_callbacks = osrm::make_unique<ExtractorCallbacks>(extraction_containers); const osmium::io::File input_file(config.input_path.string()); osmium::io::Reader reader(input_file); const osmium::io::Header header = reader.header(); std::atomic<unsigned> number_of_nodes{0}; std::atomic<unsigned> number_of_ways{0}; std::atomic<unsigned> number_of_relations{0}; std::atomic<unsigned> number_of_others{0}; SimpleLogger().Write() << "Parsing in progress.."; TIMER_START(parsing); lua_State *segment_state = scripting_environment.get_lua_state(); if (lua_function_exists(segment_state, "source_function")) { // bind a single instance of SourceContainer class to relevant lua state SourceContainer sources; luabind::globals(segment_state)["sources"] = sources; luabind::call_function<void>(segment_state, "source_function"); } std::string generator = header.get("generator"); if (generator.empty()) { generator = "unknown tool"; } SimpleLogger().Write() << "input file generated by " << generator; // write .timestamp data file std::string timestamp = header.get("osmosis_replication_timestamp"); if (timestamp.empty()) { timestamp = "n/a"; } SimpleLogger().Write() << "timestamp: " << timestamp; boost::filesystem::ofstream timestamp_out(config.timestamp_file_name); timestamp_out.write(timestamp.c_str(), timestamp.length()); timestamp_out.close(); // initialize vectors holding parsed objects tbb::concurrent_vector<std::pair<std::size_t, ExtractionNode>> resulting_nodes; tbb::concurrent_vector<std::pair<std::size_t, ExtractionWay>> resulting_ways; tbb::concurrent_vector<boost::optional<InputRestrictionContainer>> resulting_restrictions; // setup restriction parser const RestrictionParser restriction_parser(scripting_environment.get_lua_state()); while (const osmium::memory::Buffer buffer = reader.read()) { // create a vector of iterators into the buffer std::vector<osmium::memory::Buffer::const_iterator> osm_elements; for (auto iter = std::begin(buffer), end = std::end(buffer); iter != end; ++iter) { osm_elements.push_back(iter); } // clear resulting vectors resulting_nodes.clear(); resulting_ways.clear(); resulting_restrictions.clear(); // parse OSM entities in parallel, store in resulting vectors tbb::parallel_for( tbb::blocked_range<std::size_t>(0, osm_elements.size()), [&](const tbb::blocked_range<std::size_t> &range) { ExtractionNode result_node; ExtractionWay result_way; lua_State *local_state = scripting_environment.get_lua_state(); for (auto x = range.begin(), end = range.end(); x != end; ++x) { const auto entity = osm_elements[x]; switch (entity->type()) { case osmium::item_type::node: result_node.clear(); ++number_of_nodes; luabind::call_function<void>( local_state, "node_function", boost::cref(static_cast<const osmium::Node &>(*entity)), boost::ref(result_node)); resulting_nodes.push_back(std::make_pair(x, result_node)); break; case osmium::item_type::way: result_way.clear(); ++number_of_ways; luabind::call_function<void>( local_state, "way_function", boost::cref(static_cast<const osmium::Way &>(*entity)), boost::ref(result_way)); resulting_ways.push_back(std::make_pair(x, result_way)); break; case osmium::item_type::relation: ++number_of_relations; resulting_restrictions.push_back(restriction_parser.TryParse( static_cast<const osmium::Relation &>(*entity))); break; default: ++number_of_others; break; } } }); // put parsed objects thru extractor callbacks for (const auto &result : resulting_nodes) { extractor_callbacks->ProcessNode( static_cast<const osmium::Node &>(*(osm_elements[result.first])), result.second); } for (const auto &result : resulting_ways) { extractor_callbacks->ProcessWay( static_cast<const osmium::Way &>(*(osm_elements[result.first])), result.second); } for (const auto &result : resulting_restrictions) { extractor_callbacks->ProcessRestriction(result); } } TIMER_STOP(parsing); SimpleLogger().Write() << "Parsing finished after " << TIMER_SEC(parsing) << " seconds"; SimpleLogger().Write() << "Raw input contains " << number_of_nodes.load() << " nodes, " << number_of_ways.load() << " ways, and " << number_of_relations.load() << " relations, and " << number_of_others.load() << " unknown entities"; extractor_callbacks.reset(); if (extraction_containers.all_edges_list.empty()) { SimpleLogger().Write(logWARNING) << "The input data is empty, exiting."; return 1; } extraction_containers.PrepareData(config.output_file_name, config.restriction_file_name, config.names_file_name, segment_state); TIMER_STOP(extracting); SimpleLogger().Write() << "extraction finished after " << TIMER_SEC(extracting) << "s"; } catch (const std::exception &e) { SimpleLogger().Write(logWARNING) << e.what(); return 1; } try { // Transform the node-based graph that OSM is based on into an edge-based graph // that is better for routing. Every edge becomes a node, and every valid // movement (e.g. turn from A->B, and B->A) becomes an edge // // // // Create a new lua state SimpleLogger().Write() << "Generating edge-expanded graph representation"; TIMER_START(expansion); std::vector<EdgeBasedNode> node_based_edge_list; DeallocatingVector<EdgeBasedEdge> edge_based_edge_list; std::vector<QueryNode> internal_to_external_node_map; auto graph_size = BuildEdgeExpandedGraph(internal_to_external_node_map, node_based_edge_list, edge_based_edge_list); auto number_of_node_based_nodes = graph_size.first; auto max_edge_id = graph_size.second; TIMER_STOP(expansion); SimpleLogger().Write() << "building r-tree ..."; TIMER_START(rtree); FindComponents(max_edge_id, edge_based_edge_list, node_based_edge_list); BuildRTree(node_based_edge_list, internal_to_external_node_map); TIMER_STOP(rtree); SimpleLogger().Write() << "writing node map ..."; WriteNodeMapping(internal_to_external_node_map); WriteEdgeBasedGraph(config.edge_graph_output_path, max_edge_id, edge_based_edge_list); SimpleLogger().Write() << "Expansion : " << (number_of_node_based_nodes / TIMER_SEC(expansion)) << " nodes/sec and " << ((max_edge_id + 1) / TIMER_SEC(expansion)) << " edges/sec"; SimpleLogger().Write() << "To prepare the data for routing, run: " << "./osrm-prepare " << config.output_file_name << std::endl; } catch (const std::exception &e) { SimpleLogger().Write(logWARNING) << e.what(); return 1; } return 0; } /** \brief Setups scripting environment (lua-scripting) Also initializes speed profile. */ void extractor::SetupScriptingEnvironment(lua_State *lua_state, SpeedProfileProperties &speed_profile) { // open utility libraries string library; luaL_openlibs(lua_state); // adjust lua load path luaAddScriptFolderToLoadPath(lua_state, config.profile_path.string().c_str()); // Now call our function in a lua script if (0 != luaL_dofile(lua_state, config.profile_path.string().c_str())) { std::stringstream msg; msg << lua_tostring(lua_state, -1) << " occured in scripting block"; throw osrm::exception(msg.str()); } if (0 != luaL_dostring(lua_state, "return traffic_signal_penalty\n")) { std::stringstream msg; msg << lua_tostring(lua_state, -1) << " occured in scripting block"; throw osrm::exception(msg.str()); } speed_profile.traffic_signal_penalty = 10 * lua_tointeger(lua_state, -1); SimpleLogger().Write(logDEBUG) << "traffic_signal_penalty: " << speed_profile.traffic_signal_penalty; if (0 != luaL_dostring(lua_state, "return u_turn_penalty\n")) { std::stringstream msg; msg << lua_tostring(lua_state, -1) << " occured in scripting block"; throw osrm::exception(msg.str()); } speed_profile.u_turn_penalty = 10 * lua_tointeger(lua_state, -1); speed_profile.has_turn_penalty_function = lua_function_exists(lua_state, "turn_function"); } void extractor::FindComponents(unsigned max_edge_id, const DeallocatingVector<EdgeBasedEdge> &input_edge_list, std::vector<EdgeBasedNode> &input_nodes) const { struct UncontractedEdgeData { }; struct InputEdge { unsigned source; unsigned target; UncontractedEdgeData data; bool operator<(const InputEdge &rhs) const { return source < rhs.source || (source == rhs.source && target < rhs.target); } bool operator==(const InputEdge &rhs) const { return source == rhs.source && target == rhs.target; } }; using UncontractedGraph = StaticGraph<UncontractedEdgeData>; std::vector<InputEdge> edges; edges.reserve(input_edge_list.size() * 2); for (const auto &edge : input_edge_list) { BOOST_ASSERT_MSG(static_cast<unsigned int>(std::max(edge.weight, 1)) > 0, "edge distance < 1"); if (edge.forward) { edges.push_back({edge.source, edge.target, {}}); } if (edge.backward) { edges.push_back({edge.target, edge.source, {}}); } } // connect forward and backward nodes of each edge for (const auto &node : input_nodes) { if (node.reverse_edge_based_node_id != SPECIAL_NODEID) { edges.push_back({node.forward_edge_based_node_id, node.reverse_edge_based_node_id, {}}); edges.push_back({node.reverse_edge_based_node_id, node.forward_edge_based_node_id, {}}); } } tbb::parallel_sort(edges.begin(), edges.end()); auto new_end = std::unique(edges.begin(), edges.end()); edges.resize(new_end - edges.begin()); auto uncontractor_graph = std::make_shared<UncontractedGraph>(max_edge_id + 1, edges); TarjanSCC<UncontractedGraph> component_search( std::const_pointer_cast<const UncontractedGraph>(uncontractor_graph)); component_search.run(); for (auto &node : input_nodes) { auto forward_component = component_search.get_component_id(node.forward_edge_based_node_id); BOOST_ASSERT(node.reverse_edge_based_node_id == SPECIAL_EDGEID || forward_component == component_search.get_component_id(node.reverse_edge_based_node_id)); const unsigned component_size = component_search.get_component_size(forward_component); const bool is_tiny_component = component_size < 1000; node.component_id = is_tiny_component ? (1 + forward_component) : 0; } } /** \brief Build load restrictions from .restriction file */ std::shared_ptr<RestrictionMap> extractor::LoadRestrictionMap() { boost::filesystem::ifstream input_stream(config.restriction_file_name, std::ios::in | std::ios::binary); std::vector<TurnRestriction> restriction_list; loadRestrictionsFromFile(input_stream, restriction_list); SimpleLogger().Write() << " - " << restriction_list.size() << " restrictions."; return std::make_shared<RestrictionMap>(restriction_list); } /** \brief Load node based graph from .osrm file */ std::shared_ptr<NodeBasedDynamicGraph> extractor::LoadNodeBasedGraph(std::unordered_set<NodeID> &barrier_nodes, std::unordered_set<NodeID> &traffic_lights, std::vector<QueryNode> &internal_to_external_node_map) { std::vector<NodeBasedEdge> edge_list; boost::filesystem::ifstream input_stream(config.output_file_name, std::ios::in | std::ios::binary); std::vector<NodeID> barrier_list; std::vector<NodeID> traffic_light_list; NodeID number_of_node_based_nodes = loadNodesFromFile( input_stream, barrier_list, traffic_light_list, internal_to_external_node_map); SimpleLogger().Write() << " - " << barrier_list.size() << " bollard nodes, " << traffic_light_list.size() << " traffic lights"; // insert into unordered sets for fast lookup barrier_nodes.insert(barrier_list.begin(), barrier_list.end()); traffic_lights.insert(traffic_light_list.begin(), traffic_light_list.end()); barrier_list.clear(); barrier_list.shrink_to_fit(); traffic_light_list.clear(); traffic_light_list.shrink_to_fit(); loadEdgesFromFile(input_stream, edge_list); if (edge_list.empty()) { SimpleLogger().Write(logWARNING) << "The input data is empty, exiting."; return std::shared_ptr<NodeBasedDynamicGraph>(); } return NodeBasedDynamicGraphFromEdges(number_of_node_based_nodes, edge_list); } /** \brief Building an edge-expanded graph from node-based input and turn restrictions */ std::pair<std::size_t, std::size_t> extractor::BuildEdgeExpandedGraph(std::vector<QueryNode> &internal_to_external_node_map, std::vector<EdgeBasedNode> &node_based_edge_list, DeallocatingVector<EdgeBasedEdge> &edge_based_edge_list) { lua_State *lua_state = luaL_newstate(); luabind::open(lua_state); SpeedProfileProperties speed_profile; SetupScriptingEnvironment(lua_state, speed_profile); std::unordered_set<NodeID> barrier_nodes; std::unordered_set<NodeID> traffic_lights; auto restriction_map = LoadRestrictionMap(); auto node_based_graph = LoadNodeBasedGraph(barrier_nodes, traffic_lights, internal_to_external_node_map); CompressedEdgeContainer compressed_edge_container; GraphCompressor graph_compressor(speed_profile); graph_compressor.Compress(barrier_nodes, traffic_lights, *restriction_map, *node_based_graph, compressed_edge_container); EdgeBasedGraphFactory edge_based_graph_factory( node_based_graph, compressed_edge_container, barrier_nodes, traffic_lights, std::const_pointer_cast<RestrictionMap const>(restriction_map), internal_to_external_node_map, speed_profile); compressed_edge_container.SerializeInternalVector(config.geometry_output_path); edge_based_graph_factory.Run(config.edge_output_path, lua_state, config.edge_segment_lookup_path, config.edge_penalty_path, config.generate_edge_lookup #ifdef DEBUG_GEOMETRY , config.debug_turns_path #endif ); lua_close(lua_state); edge_based_graph_factory.GetEdgeBasedEdges(edge_based_edge_list); edge_based_graph_factory.GetEdgeBasedNodes(node_based_edge_list); auto max_edge_id = edge_based_graph_factory.GetHighestEdgeID(); const std::size_t number_of_node_based_nodes = node_based_graph->GetNumberOfNodes(); return std::make_pair(number_of_node_based_nodes, max_edge_id); } /** \brief Writing info on original (node-based) nodes */ void extractor::WriteNodeMapping(const std::vector<QueryNode> & internal_to_external_node_map) { boost::filesystem::ofstream node_stream(config.node_output_path, std::ios::binary); const unsigned size_of_mapping = internal_to_external_node_map.size(); node_stream.write((char *)&size_of_mapping, sizeof(unsigned)); if (size_of_mapping > 0) { node_stream.write((char *)internal_to_external_node_map.data(), size_of_mapping * sizeof(QueryNode)); } node_stream.close(); } /** \brief Building rtree-based nearest-neighbor data structure Saves tree into '.ramIndex' and leaves into '.fileIndex'. */ void extractor::BuildRTree(const std::vector<EdgeBasedNode> &node_based_edge_list, const std::vector<QueryNode> &internal_to_external_node_map) { StaticRTree<EdgeBasedNode>(node_based_edge_list, config.rtree_nodes_output_path.c_str(), config.rtree_leafs_output_path.c_str(), internal_to_external_node_map); } void extractor::WriteEdgeBasedGraph(std::string const &output_file_filename, size_t const max_edge_id, DeallocatingVector<EdgeBasedEdge> const & edge_based_edge_list) { std::ofstream file_out_stream; file_out_stream.open(output_file_filename.c_str(), std::ios::binary); const FingerPrint fingerprint = FingerPrint::GetValid(); file_out_stream.write((char *)&fingerprint, sizeof(FingerPrint)); std::cout << "[extractor] Writing edge-based-graph egdes ... " << std::flush; TIMER_START(write_edges); size_t number_of_used_edges = edge_based_edge_list.size(); file_out_stream.write((char *)&number_of_used_edges, sizeof(size_t)); file_out_stream.write((char *)&max_edge_id, sizeof(size_t)); for (const auto& edge : edge_based_edge_list) { file_out_stream.write((char *) &edge, sizeof(EdgeBasedEdge)); } TIMER_STOP(write_edges); std::cout << "ok, after " << TIMER_SEC(write_edges) << "s" << std::endl; SimpleLogger().Write() << "Processed " << number_of_used_edges << " edges"; file_out_stream.close(); }
[ "luc@blippar.com" ]
luc@blippar.com
e7784c07f88a05496ed700b341a85f7f95b2656e
6616e8cab837f20e2cc41585609a2e6d2c053de7
/handTracker/src-gen/HandTrackerCompdef/HandTracker.h
009f985d3bc53f80c62b0c187f9d6790aa38341b
[]
no_license
EkaterinaKapanzha/PapPercComp
792c643b8466edf331cf77eb82cc071117ef9b71
fa454bd7747fc980d77447aadb6ffa6b188c0802
refs/heads/master
2022-10-06T22:58:27.262434
2020-06-08T11:33:02
2020-06-08T11:33:02
270,269,240
0
0
null
2020-06-07T10:22:55
2020-06-07T10:22:54
null
UTF-8
C++
false
false
1,748
h
// -------------------------------------------------------- // Code generated by Papyrus C++ // -------------------------------------------------------- #ifndef HANDTRACKERCOMPDEF_HANDTRACKER_H #define HANDTRACKERCOMPDEF_HANDTRACKER_H /************************************************************ HandTracker class header ************************************************************/ #include "HandTrackerCompdef/Pkg_HandTrackerCompdef.h" #include "rclcpp_lifecycle/lifecycle_node.hpp" #include "sensor_msgs/msg/image.hpp" #include "std_msgs/msg/float32multi_array.hpp" // Include from Include stereotype (header) #include <rclcpp/rclcpp.hpp> // End of Include stereotype (header) namespace ros2Library { namespace rclcpp { class NodeOptions; } } namespace ros2Library { namespace rclcpp { class Subscription; } } namespace HandTrackerCompdef { /************************************************************/ /** * */ class HandTracker: public rclcpp_lifecycle::LifecycleNode { public: /** * */ rclcpp::Subscription<sensor_msgs::msg::Image>::SharedPtr image_S_sub_; /** * */ rclcpp_lifecycle::LifecyclePublisher<std_msgs::msg::Float32MultiArray>::SharedPtr points_P_pub_; /** * * @param options */ HandTracker(rclcpp::NodeOptions /*in*/options); }; /************************************************************/ /* External declarations (package visibility) */ /************************************************************/ /* Inline functions */ } // of namespace HandTrackerCompdef /************************************************************ End of HandTracker class header ************************************************************/ #endif
[ "ekaterina.kapanzha@gmail.com" ]
ekaterina.kapanzha@gmail.com
dc3b4d286d2af100e2c7e55548fcd0956f33c551
92b52435650d53c956187a85af2705652232fee7
/include/Analysis/token.h
7a9684453a95444629a274f12a4cb817448e73f2
[]
no_license
LarichevVitaly/Compiler
f91ee8083bc08c6a45fa07f2effe641b13c98fa5
d92f9dbb93641b762926353f1d3de46d939fa2fb
refs/heads/master
2021-01-18T12:15:41.456341
2016-02-24T18:27:02
2016-02-24T18:27:02
null
0
0
null
null
null
null
UTF-8
C++
false
false
398
h
#ifndef COMPILER_TOKEN_H #define COMPILER_TOKEN_H #include <iostream> #include "Const.h" #include "Console/Console.h" class Token { public: Token(); ~Token(); void Set(std::string value,TokenType type); const char * GetStringType(); const char * GetValue(); private: std::string value; TokenType type; }; #endif //COMPILER_TOKEN_H
[ "dikiigr@gmail.com" ]
dikiigr@gmail.com
b14054b753e8ada3ecf9cbc49f1b24499d942887
5d01a2a16078b78fbb7380a6ee548fc87a80e333
/ETS/Components/MM/EtsMmQuotesCV/MmQvExpAtom.h
015c31481c0c1cbbc1821d6d69e734e4df30173d
[]
no_license
WilliamQf-AI/IVRMstandard
2fd66ae6e81976d39705614cfab3dbfb4e8553c5
761bbdd0343012e7367ea111869bb6a9d8f043c0
refs/heads/master
2023-04-04T22:06:48.237586
2013-04-17T13:56:40
2013-04-17T13:56:40
null
0
0
null
null
null
null
UTF-8
C++
false
false
3,603
h
// MmQvExpAtom.h : Declaration of the CMmQvExpAtom #ifndef __MMQVEXPATOM_H__ #define __MMQVEXPATOM_H__ #pragma once #include "resource.h" // main symbols #include "EtsMmQuotes.h" #include "MmQvStrikeColl.h" _COM_SMARTPTR_TYPEDEF(IMmQvExpAtom, IID_IMmQvExpAtom); struct __MmQvExpAtom { DATE m_dtExpiryMonth; DATE m_dtExpiry; DOUBLE m_dRate; DOUBLE m_dRateCust; VARIANT_BOOL m_bVisible; IMmQvStrikeCollPtr m_spStrike; IMmQvStrikeAtomPtr m_spAtmStrike; _bstr_t m_bstrRootNames; DOUBLE m_dHTBRate; DATE m_dtExpiryOV; DATE m_dtTradingClose; __MmQvExpAtom() : m_dtExpiryMonth(0.), m_dtExpiry(0.), m_dRate(0.), m_dRateCust(0.), m_bVisible(VARIANT_FALSE), m_dHTBRate(BAD_DOUBLE_VALUE), m_dtExpiryOV(0), m_dtTradingClose(0) { } }; // CMmQvExpAtom class ATL_NO_VTABLE CMmQvExpAtom : public CComObjectRootEx<CComMultiThreadModel>, public CComCoClass<CMmQvExpAtom, &CLSID_MmQvExpAtom>, public ISupportErrorInfoImpl<&IID_IMmQvExpAtom>, public IDispatchImpl<IMmQvExpAtom, &IID_IMmQvExpAtom, &LIBID_EtsMmQuotesLib, /*wMajor =*/ 1, /*wMinor =*/ 0>, public __MmQvExpAtom { typedef std::set<_bstr_t> CRootNamesCollection; public: CMmQvExpAtom() :m_pStrike(NULL) { m_pUnkMarshaler = NULL; } DECLARE_REGISTRY_RESOURCEID(IDR_MMQVEXPATOM) BEGIN_COM_MAP(CMmQvExpAtom) COM_INTERFACE_ENTRY(IMmQvExpAtom) COM_INTERFACE_ENTRY(IDispatch) COM_INTERFACE_ENTRY(ISupportErrorInfo) COM_INTERFACE_ENTRY_AGGREGATE(IID_IMarshal, m_pUnkMarshaler.p) END_COM_MAP() DECLARE_PROTECT_FINAL_CONSTRUCT() DECLARE_GET_CONTROLLING_UNKNOWN() HRESULT FinalConstruct() { HRESULT hr = S_OK; try { _CHK(CComObject<CMmQvStrikeColl>::CreateInstance(&m_pStrike), _T("Fail to create strikes.")); m_spStrike.Attach(m_pStrike, TRUE); hr = CoCreateFreeThreadedMarshaler( GetControllingUnknown(), &m_pUnkMarshaler.p); } catch(const _com_error& e) { hr = Error((PTCHAR)CComErrorWrapper::ErrorDescription(e), IID_IMmQvExpAtom, e.Error()); } return hr; } void FinalRelease() { m_spStrike = NULL; m_spAtmStrike = NULL; m_pUnkMarshaler.Release(); } bool AddRoot(_bstr_t& bsRootName) { CRootNamesCollection::iterator itrFind = m_Roots.find(bsRootName); if(itrFind != m_Roots.end()) { if(m_Roots.empty()) m_bstrRootNames = bsRootName; else m_bstrRootNames += _bstr_t(L",") + bsRootName; m_Roots.insert(bsRootName); return true; } return false; } public: CComObject<CMmQvStrikeColl>* m_pStrike; private: CRootNamesCollection m_Roots; CComPtr<IUnknown> m_pUnkMarshaler; public: IMPLEMENT_SIMPLE_PROPERTY(DATE, ExpiryMonth, m_dtExpiryMonth) IMPLEMENT_SIMPLE_PROPERTY(DATE, Expiry, m_dtExpiry) IMPLEMENT_SIMPLE_PROPERTY(DOUBLE, Rate, m_dRate) IMPLEMENT_SIMPLE_PROPERTY(DOUBLE, HTBRate, m_dHTBRate) IMPLEMENT_SIMPLE_PROPERTY(DOUBLE, RateCust, m_dRateCust) IMPLEMENT_SIMPLE_PROPERTY(VARIANT_BOOL, Visible, m_bVisible) IMPLEMENT_OBJECTREADONLY_PROPERTY(IMmQvStrikeColl*, Strike, m_spStrike) IMPLEMENT_OBJECT_PROPERTY(IMmQvStrikeAtom*, NearAtmStrike, m_spAtmStrike) IMPLEMENT_BSTRT_PROPERTY(RootNames, m_bstrRootNames) STDMETHOD(get_NearAtmVola)(DOUBLE* pVal); STDMETHOD(FindAtmStrike)(DOUBLE UnderlyingSpot); IMPLEMENT_SIMPLE_PROPERTY(DATE, ExpiryOV, m_dtExpiryOV) IMPLEMENT_SIMPLE_PROPERTY(DATE, TradingClose, m_dtTradingClose) }; OBJECT_ENTRY_AUTO(__uuidof(MmQvExpAtom), CMmQvExpAtom) #endif //__MMQVEXPATOM_H__
[ "chuchev@egartech.com" ]
chuchev@egartech.com
354dc3d9c57b2446e0e9ae5def6e8427b3edb031
05e1f94ae1a5513a222d38dfe4c3c6737cb84251
/Mulberry/branches/users/kenneth_porter/FromTrunk/Linux/Sources/Application/Calendar/Component_Editing/CNewToDoTiming.h
02252f938942a3162d77b9679bf250c44edd45c7
[ "Apache-2.0" ]
permissive
eskilblomfeldt/mulberry-svn
16ca9d4d6ec05cbbbd18045c7b59943b0aca9335
7ed26b61244e47d4d4d50a1c7cc2d31efa548ad7
refs/heads/master
2020-05-20T12:35:42.340160
2014-12-24T18:03:50
2014-12-24T18:03:50
29,127,476
0
0
null
null
null
null
UTF-8
C++
false
false
2,132
h
/* Copyright (c) 2007 Cyrus Daboo. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ #ifndef H_CNewToDoTiming #define H_CNewToDoTiming #include "CNewTimingPanel.h" class CDateTimeZoneSelect; class CDurationSelect; class JXRadioGroup; class JXTextCheckbox; class JXTextRadioButton; // =========================================================================== // CNewToDoTiming class CNewToDoTiming : public CNewTimingPanel { public: CNewToDoTiming(JXContainer* enclosure, const HSizingOption hSizing, const VSizingOption vSizing, const JCoordinate x, const JCoordinate y, const JCoordinate w, const JCoordinate h) : CNewTimingPanel(enclosure, hSizing, vSizing, x, y, w, h) {} virtual ~CNewToDoTiming() {} virtual void OnCreate(); virtual bool GetAllDay() const; virtual void GetTimezone(iCal::CICalendarTimezone& tz) const; virtual void SetToDo(const iCal::CICalendarVToDo& vtodo); virtual void GetToDo(iCal::CICalendarVToDo& vtodo); virtual void SetReadOnly(bool read_only); protected: enum { eDue_NoDue = 1, eDue_DueBy, eDue_Start }; // UI Objects // begin JXLayout1 JXTextCheckbox* mAllDay; JXRadioGroup* mDueGroup; JXTextRadioButton* mNoDue; JXTextRadioButton* mDueBy; CDateTimeZoneSelect* mDueDateTimeZone; JXTextRadioButton* mStarts; CDateTimeZoneSelect* mStartDateTimeZone; CDurationSelect* mDuration; // end JXLayout1 virtual void Receive(JBroadcaster* sender, const Message& message); void DoAllDay(bool set); void DoDueGroup(JIndex group); }; #endif
[ "svnusers@a91246af-f21b-0410-bd1c-c3c7fc455132" ]
svnusers@a91246af-f21b-0410-bd1c-c3c7fc455132
2f03c1cc6bee6559b5af9d0098a185e781dd40d7
8e3e4a8aa16934a32ad6882225cbae405ae511f5
/synth_02/89_midi_util.ino
dddf29c6bf9842c9d3f1ad6c251267bdc5a86330
[]
no_license
apiel/sequencer
da5db792ef0ae796f9dbefbfbad362222c3712e0
8eac658bdc17ecf2ff9f8b9a5ce44845c2e81a9c
refs/heads/main
2023-03-19T23:35:37.046268
2021-03-10T17:27:45
2021-03-10T17:27:45
326,249,794
0
0
null
null
null
null
UTF-8
C++
false
false
1,390
ino
#define KNOB_MAX_VALUE 127 #define KNOB_INIT_VALUE 200 byte knobValues[KNOB_COUNT] = { KNOB_INIT_VALUE, KNOB_INIT_VALUE, KNOB_INIT_VALUE, KNOB_INIT_VALUE, KNOB_INIT_VALUE, KNOB_INIT_VALUE, KNOB_INIT_VALUE, KNOB_INIT_VALUE, KNOB_INIT_VALUE, KNOB_INIT_VALUE, KNOB_INIT_VALUE, KNOB_INIT_VALUE, KNOB_INIT_VALUE, KNOB_INIT_VALUE, KNOB_INIT_VALUE, KNOB_INIT_VALUE, KNOB_INIT_VALUE, KNOB_INIT_VALUE}; int getKnobDirection(byte knob, byte val) { int direction = 0; if (knobValues[knob] == KNOB_INIT_VALUE) { knobValues[knob] = val; } else if (val == 0) { direction = -1; knobValues[knob] = 0; } else if (val == KNOB_MAX_VALUE) { direction = 1; knobValues[knob] = KNOB_MAX_VALUE; } else { direction = val - knobValues[knob]; knobValues[knob] = between(knobValues[knob] + direction, 0, KNOB_MAX_VALUE); } return direction; } // used for first row from x touch mini to know which item // number is it, e.g. which tone selected byte getItemKey(byte key) { if (getItemKeyA(key) < 255) { return getItemKeyA(key); } return getItemKeyB(key); } byte getItemKeyA(byte key) { if (key >= 8 && key <= 15) { return key - 8; } return 255; } byte getItemKeyB(byte key) { if (key >= 32 && key <= 39) { return key - 32; } return 255; }
[ "alexandre.piel@gmail.com" ]
alexandre.piel@gmail.com
39c1c8c324c3e64b5febdbf599d114641baf14a6
f175bcab3c2f0aad7378c94ac220256982ab2027
/Temp/il2cppOutput/il2cppOutput/Facebook_Unity_Facebook_Unity_Editor_EditorFacebookG63110230.h
a2e9b4a711b77da2e6c19eed2d320ff70ffafdd8
[]
no_license
al2css/erpkunity
6618387e9a5b44378e70ccb859d3b33a7837268c
c618dc989963bcd7b7ec9fa9b17c39fff88bb89b
refs/heads/master
2020-07-22T04:59:49.139202
2017-06-23T16:33:13
2017-06-23T16:33:13
94,344,128
0
0
null
null
null
null
UTF-8
C++
false
false
585
h
#pragma once #include "il2cpp-config.h" #ifndef _MSC_VER # include <alloca.h> #else # include <malloc.h> #endif #include <stdint.h> #include "Facebook_Unity_Facebook_Unity_FacebookGameObject2922570967.h" #ifdef __clang__ #pragma clang diagnostic push #pragma clang diagnostic ignored "-Winvalid-offsetof" #pragma clang diagnostic ignored "-Wunused-variable" #endif // Facebook.Unity.Editor.EditorFacebookGameObject struct EditorFacebookGameObject_t63110230 : public FacebookGameObject_t2922570967 { public: public: }; #ifdef __clang__ #pragma clang diagnostic pop #endif
[ "alecsdulgheru@gmail.com" ]
alecsdulgheru@gmail.com
e20446854aa385c3e2e3254f93be9431c11dd62e
05de431b4040d8ff839895f2233512ee66d2a1c4
/Calculator/main.cpp
f7664a25905584214b5b8101d211ddaf9faac9fd
[]
no_license
chavychaze/Calculator
08b7e632861ea45c37137a1c420d5f9cd01fca53
0622334cd686880d5520a58f80382d9d15f1c810
refs/heads/master
2021-06-17T19:13:17.724840
2017-06-20T13:58:12
2017-06-20T13:58:12
null
0
0
null
null
null
null
UTF-8
C++
false
false
5,880
cpp
// The desk calulator // reads from standard input or command line // uses namespaces and no exceptions #include <map> #include<iostream> #include<cctype> #include<string> using namespace std; namespace Error { struct Zero_divide { }; struct Syntax_error { const char* p; Syntax_error(const char* q) { p = q; } }; } namespace Lexer { enum Token_value { NAME, NUMBER, END, PLUS = '+', MINUS = '-', MUL = '*', DIV = '/', PRINT = ';', ASSIGN = '=', LP = '(', RP = ')' }; Token_value curr_tok; double number_value; string string_value; Token_value get_token(); } namespace Parser { double prim(bool get); // handle primaries double term(bool get); // multiply and divide double expr(bool get); // and subtract using namespace Lexer; using namespace Error; } namespace Symbol_table { map<string, double> table; } namespace Driver { int no_of_errors; std::istream* input; void skip(); } Lexer::Token_value Lexer::get_token() { char ch; do { // skip whitespace except '\n' if (!Driver::input->get(ch)) return curr_tok = END; } while (ch != '\n' && isspace(ch)); switch (ch) { case 0: return END; case ';': case '\n': return curr_tok = PRINT; case '*': case '/': case '+': case '-': case '(': case ')': case '=': return curr_tok = Token_value(ch); case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case '.': Driver::input->putback(ch); *Driver::input >> number_value; return curr_tok = NUMBER; default: // NAME, NAME =, or error if (isalpha(ch)) { string_value = ch; while (Driver::input->get(ch) && isalnum(ch)) string_value += ch; // string_value.push_back(ch); // to work around library bug Driver::input->putback(ch); return curr_tok = NAME; } throw Error::Syntax_error("bad token"); } } double Parser::prim(bool get) // handle primaries { if (get) get_token(); switch (curr_tok) { case Lexer::NUMBER: // floating point constant get_token(); return number_value; case Lexer::NAME: { double& v = Symbol_table::table[string_value]; if (get_token() == ASSIGN) v = expr(1); return v; } case Lexer::MINUS: // unary minus return -prim(1); case Lexer::LP: { double e = expr(1); if (curr_tok != RP) throw Error::Syntax_error("`)' expected"); get_token(); // eat ')' return e; } case Lexer::END: return 1; default: throw Error::Syntax_error("primary expected"); } } double Parser::term(bool get) // multiply and divide { double left = prim(get); for (;;) // ``forever'' switch (curr_tok) { case Lexer::MUL: left *= prim(true); break; case Lexer::DIV: if (double d = prim(true)) { left /= d; break; } throw Error::Zero_divide(); default: return left; } } double Parser::expr(bool get) // add and subtract { double left = term(get); for (;;) // ``forever'' switch (curr_tok) { case Lexer::PLUS: left += term(true); break; case Lexer::MINUS: left -= term(true); break; default: return left; } } void Driver::skip() { no_of_errors++; while (*input) { // discard characters until newline or semicolon char ch; input->get(ch); switch (ch) { case '\n': case ';': return; } } } int fib(int n) //fibonacci formula { // Declare an array to store Fibonacci numbers. int f[1000]; //can't inpute [n+1] int i; // 0th and 1st number of the series are 0 and 1 f[0] = 0; f[1] = 1; for (i = 2; i <= n; i++) { // Add the previous 2 numbers in the series and store it f[i] = f[i - 1] + f[i - 2]; } return f[n]; } #include <vector> #include <algorithm> int median(int iArray[]) { vector<int> mArray(iArray, iArray + 14); //set this number to match the number of items in your int array vector<int>::iterator it; sort(mArray.begin(), mArray.end()); // Find the median. float median, middle, middleh; float middlel; vector<int>::iterator z; switch (mArray.size() % 2) { case(0): // even z = mArray.begin(); middlel = mArray.size() / 2; z += middlel; middleh = (*z + *(--z)) / 2; cout << "Median is: " << middleh << endl; break; case(1): // odd z = mArray.begin(); middle = mArray.size() / 2; cout << "Median is : " << *(z += middle) << endl; break; } // display the sorted array. for (it = mArray.begin(); it != mArray.end(); it++) { cout << *it << " "; } return *it; } #include <fstream> void load_data() { string load; getline(cin, load); if (load == "load") { //to load saved file ifstream loadFile; loadFile.open("Save.txt", ifstream::in); cout << "The file contained: "; while (loadFile.good()) { cout << (char)loadFile.get(); } cout << " " << endl; loadFile.close(); } } #include <strstream> int main(int argc, char* argv[]) { using namespace Driver; switch (argc) { case 1: // read from standard input input = &cin; break; case 2: // read argument string input = new istrstream(argv[1], strlen(argv[1])); break; default: cerr << "too many arguments\n"; return 1; } // insert pre-defined names: Symbol_table::table["pi"] = 3.1415926535897932385; Symbol_table::table["e"] = 2.7182818284590452354; while (*input) { cout << "new expression:\n"; try { Lexer::get_token(); if (Lexer::curr_tok == Lexer::END) break; if (Lexer::curr_tok == Lexer::PRINT) continue; cout << Parser::expr(false) << '\n'; string textToSave; //block to save all inpute getline(cin, textToSave); ofstream saveFile("Save.txt"); saveFile << textToSave; saveFile.close(); } catch (Error::Zero_divide) { cerr << "attempt to divide by zero\n"; skip(); } catch (Error::Syntax_error e) { cerr << "syntax error:" << e.p << "\n"; skip(); } } string ld = "load"; if (cin >> ld) load_data(); if (input != &std::cin) delete input; return no_of_errors; }
[ "inAsobolrip1@gmail.com" ]
inAsobolrip1@gmail.com
2d35bb480ddec10ab2765bc45683b6ab5b4d90f9
7e7a3cd90fdeb556dd3459eb5e6a8f68a0718d1d
/Support/util/file.cpp
6add6896d5695331c9691013da78494145115f5b
[ "Apache-2.0" ]
permissive
robojan/EmuAll
7d3c792fce79db4b10613b93f0a0a7c23f42a530
0a589136df9fefbfa142e605e1d3a0c94f726bad
refs/heads/master
2021-01-21T04:50:46.603365
2016-07-22T10:44:18
2016-07-22T10:44:18
44,864,341
1
0
null
null
null
null
UTF-8
C++
false
false
9,830
cpp
#include <emuall/util/file.h> #include <cerrno> #include <vector> class File::Prvt { public: std::shared_ptr<FILE> _file; std::string _filename; fileOpenMode _mode; errno_t _lastErrno; }; File::File(const char *filename, fileOpenMode mode) { _prvt = new Prvt; _prvt->_filename = filename; _prvt->_mode = mode; _prvt->_lastErrno = 0; _prvt->_file = nullptr; Open(); } File::File() { _prvt = new Prvt; _prvt->_mode = openReadOnly; _prvt->_lastErrno = 0; _prvt->_file = nullptr; } File::File(File &other) { _prvt = other._prvt; other._prvt = new Prvt; _prvt->_mode = openReadOnly; _prvt->_lastErrno = 0; _prvt->_file = nullptr; } File::~File() { Close(); delete _prvt; } bool File::Seek(long offset, File::seekOrigins origin) { if (_prvt->_file.get() == NULL) { _prvt->_lastErrno = errno = ENOSR; return false; } size_t pos = ftell(_prvt->_file.get()); if ((origin == File::seekBeginning && offset == pos) || (origin == File::seekCurrent && offset == 0)) return true; if (fseek(_prvt->_file.get(), offset, origin) != 0) { _prvt->_lastErrno = errno; throw FileException(_prvt->_lastErrno, "File seek failed: %s", strerror(_prvt->_lastErrno)); } return true; } long int File::GetPosition() { if (_prvt->_file.get() == NULL) { _prvt->_lastErrno = errno = ENOSR; throw FileException(_prvt->_lastErrno, "File not opened: %s", strerror(_prvt->_lastErrno)); return -1L; } return ftell(_prvt->_file.get()); } long int File::GetSize() { if (_prvt->_file.get() == NULL) { _prvt->_lastErrno = errno = ENOSR; throw FileException(_prvt->_lastErrno, "File not opened: %s", strerror(_prvt->_lastErrno)); } long int currentPos = ftell(_prvt->_file.get()); bool success = Seek(0, seekEnd); long int endPos = ftell(_prvt->_file.get()); success &= Seek(currentPos, seekBeginning); if (success) { return endPos; } _prvt->_lastErrno = errno; throw FileException(_prvt->_lastErrno, "Getting file size failed: %s", strerror(_prvt->_lastErrno)); } bool File::IsEOF() const { return _prvt->_file.get() == NULL || feof(_prvt->_file.get()) != 0; } bool File::Open() { if (_prvt->_filename.empty() || _prvt->_mode == 0) { _prvt->_lastErrno = errno = EINVAL; throw FileException(_prvt->_lastErrno, "No filename or mode was given"); } if (_prvt->_file.get() != NULL) { FILE *tmp = freopen(_prvt->_filename.c_str(), GetOpenModeString(_prvt->_mode), _prvt->_file.get()); _prvt->_file = std::shared_ptr<FILE>(tmp, std::fclose); } else { FILE *tmp = fopen(_prvt->_filename.c_str(), GetOpenModeString(_prvt->_mode)); _prvt->_file = std::shared_ptr<FILE>(tmp, std::fclose); } if (_prvt->_file.get() == NULL) { _prvt->_lastErrno = errno; throw FileException(_prvt->_lastErrno, "Could not open file: %s", strerror(_prvt->_lastErrno)); } return true; } bool File::Open(fileOpenMode mode) { _prvt->_mode = mode; if (_prvt->_file.get() != NULL) { if (freopen(_prvt->_filename.c_str(), GetOpenModeString(_prvt->_mode), _prvt->_file.get()) == NULL) { _prvt->_lastErrno = errno; throw FileException(_prvt->_lastErrno, "Could not open file: %s", strerror(_prvt->_lastErrno)); } return true; } else { return Open(); } } bool File::IsOpen() const { return _prvt->_file.get() != NULL; } bool File::Close() { _prvt->_file.reset(); return true; } size_t File::Read(void *ptr, size_t size) { if (_prvt->_file.get() == NULL) { _prvt->_lastErrno = errno = ENOSR; throw FileException(_prvt->_lastErrno, "File not opened: %s", strerror(_prvt->_lastErrno)); } size_t result = fread(ptr, 1, size, _prvt->_file.get()); if (result != size) { if (IsEOF()) { throw EndOfFileException(); } _prvt->_lastErrno = errno; throw FileException(_prvt->_lastErrno, "File reading failed: %s", strerror(_prvt->_lastErrno)); } return result; } size_t File::Write(const void *ptr, size_t size) { if (_prvt->_file.get() == NULL) { _prvt->_lastErrno = errno = ENOSR; throw FileException(_prvt->_lastErrno, "File not opened: %s", strerror(_prvt->_lastErrno)); } size_t result = fwrite(ptr, 1, size, _prvt->_file.get()); if (result != size) { _prvt->_lastErrno = errno; throw FileException(_prvt->_lastErrno, "File writing failed: %s", strerror(_prvt->_lastErrno)); } return result; } int File::GetC() { if (_prvt->_file.get() == NULL) { _prvt->_lastErrno = errno = ENOSR; throw FileException(_prvt->_lastErrno, "File not opened: %s", strerror(_prvt->_lastErrno)); } int result = fgetc(_prvt->_file.get()); if (IsEOF()) { throw EndOfFileException(); } return result; } bool File::GetC(unsigned char *c) { int result; if (c == NULL) { _prvt->_lastErrno = errno = EINVAL; throw FileException(_prvt->_lastErrno, "File not opened: %s", strerror(_prvt->_lastErrno)); } if ((result = GetC()) == EOF) { if (IsEOF()) { throw EndOfFileException(); } _prvt->_lastErrno = errno; throw FileException(_prvt->_lastErrno, "File reading failed: %s", strerror(_prvt->_lastErrno)); } *c = (unsigned char)result; return true; } bool File::GetC(char *c) { int result; if (c == NULL) { _prvt->_lastErrno = errno = EINVAL; throw FileException(_prvt->_lastErrno, "File not opened: %s", strerror(_prvt->_lastErrno)); } if ((result = GetC()) == EOF) { if (IsEOF()) { throw EndOfFileException(); } _prvt->_lastErrno = errno; throw FileException(_prvt->_lastErrno, "File reading failed: %s", strerror(_prvt->_lastErrno)); } *c = (char) result; return true; } bool File::PutC(unsigned char c) { if (_prvt->_file.get() == NULL) { _prvt->_lastErrno = errno = ENOSR; throw FileException(_prvt->_lastErrno, "File not opened: %s", strerror(_prvt->_lastErrno)); } if (fputc(c, _prvt->_file.get()) != c) { _prvt->_lastErrno = errno; throw FileException(_prvt->_lastErrno, "File writing failed: %s", strerror(_prvt->_lastErrno)); } return true; } bool File::PutC(char c) { if (_prvt->_file.get() == NULL) { _prvt->_lastErrno = errno = ENOSR; throw FileException(_prvt->_lastErrno, "File not opened: %s", strerror(_prvt->_lastErrno)); } if (fputc(c, _prvt->_file.get()) != c) { _prvt->_lastErrno = errno; throw FileException(_prvt->_lastErrno, "File writing failed: %s", strerror(_prvt->_lastErrno)); } return true; } const char *File::GetOpenModeString(fileOpenMode mode) { switch (mode) { case openReadOnly: return "r"; case openWriteOnly: return "w"; case openAppend: return "a"; case openRW: return "r+"; case openRWCreate: return "w+"; case openAppendRead: return "a+"; case openWriteOnlyFail: return "wx"; case openRWCreateFail: return "w+x"; // Keep raw and text mode seperated case openRawReadOnly: return "rb"; case openRawWriteOnly: return "wb"; case openRawAppend: return "ab"; case openRawRW: return "rb+"; case openRawRWCreate: return "wb+"; case openRawAppendRead: return "ab+"; case openRawWriteOnlyFail: return "wbx"; case openRawRWCreateFail: return "wb+x"; default: return "rb"; } } errno_t File::GetLastErrno() const { return _prvt->_lastErrno; } void File::ClearErrno() { _prvt->_lastErrno = 0; } File & File::operator=(File &other) { _prvt = other._prvt; other._prvt = new Prvt; return *this; } RawFile::RawFile(const char *filepath, fileOpenMode mode, bool littleEndian) : File(filepath, mode), _conv(!littleEndian) { } RawFile::RawFile(bool littleEndian) : File(), _conv(!littleEndian) { } RawFile::RawFile(RawFile &other) : File(other), _conv(other._conv) { } RawFile::~RawFile() { } RawFile & RawFile::operator=(RawFile &other) { File::operator=(other); _conv = other._conv; return *this; } uint8_t RawFile::GetU8() { uint8_t x; Read(&x, sizeof(x)); return x; } int8_t RawFile::GetI8() { int8_t x; Read(&x, sizeof(x)); return x; } uint16_t RawFile::GetU16() { uint16_t x; Read(&x, sizeof(x)); return _conv.convu16(x); } int16_t RawFile::GetI16() { int16_t x; Read(&x, sizeof(x)); return _conv.convi16(x); } uint32_t RawFile::GetU24() { uint32_t x = 0; GetC(((uint8_t *) &x) + 0); GetC(((uint8_t *) &x) + 1); GetC(((uint8_t *) &x) + 2); return _conv.convu32(x); } int32_t RawFile::GetI24() { int32_t x; GetC(((uint8_t *) &x) + 0); GetC(((uint8_t *) &x) + 1); GetC(((uint8_t *) &x) + 2); return _conv.convi32(x); } uint32_t RawFile::GetU32() { uint32_t x; Read(&x, sizeof(x)); return _conv.convu32(x); } int32_t RawFile::GetI32() { int32_t x; Read(&x, sizeof(x)); return _conv.convi32(x); } uint64_t RawFile::GetU64() { uint64_t x; Read(&x, sizeof(x)); return _conv.convu64(x); } int64_t RawFile::GetI64() { int64_t x; Read(&x, sizeof(x)); return _conv.convi64(x); } float RawFile::GetFloat() { float x; Read(&x, sizeof(x)); return _conv.convf(x); } double RawFile::GetDouble() { double x; Read(&x, sizeof(x)); return _conv.convd(x); } void RawFile::PutU8(uint8_t x) { Write(&x, sizeof(x)); } void RawFile::PutI8(int8_t x) { Write(&x, sizeof(x)); } void RawFile::PutU16(uint16_t x) { uint16_t t = _conv.convu16(x); Write(&t, sizeof(t)); } void RawFile::PutI16(int16_t x) { int16_t t = _conv.convi16(x); Write(&t, sizeof(t)); } void RawFile::PutU24(uint32_t x) { uint32_t t = _conv.convu32(x); Write(&t, 3); } void RawFile::PutI24(int32_t x) { int32_t t = _conv.convi32(x); Write(&t, 3); } void RawFile::PutU32(uint32_t x) { uint32_t t = _conv.convu32(x); Write(&t, sizeof(t)); } void RawFile::PutI32(int32_t x) { int32_t t = _conv.convi32(x); Write(&t, sizeof(t)); } void RawFile::PutU64(uint64_t x) { uint64_t t = _conv.convu64(x); Write(&t, sizeof(t)); } void RawFile::PutI64(int64_t x) { int64_t t = _conv.convi64(x); Write(&t, sizeof(t)); } void RawFile::PutFloat(float x) { float t = _conv.convf(x); Write(&t, sizeof(t)); } void RawFile::PutDouble(double x) { double t = _conv.convd(x); Write(&t, sizeof(t)); }
[ "robojan1@hotmail.com" ]
robojan1@hotmail.com
df4f6474cc7722b5672ae2135e097e3131c5a3c8
a1e63481e515b2c41bc8cbda4daa9671d44b5ca0
/1557.frankr.cpp
b5e405cd2afd43faf5efe7328105b12d705e0c55
[]
no_license
frarteaga/cojSolutions
b05134ed793b7f36f2dbcc74f61d55b3e5c6a825
b93b53e092e417670584ec240cfa5010d33b55cf
refs/heads/master
2020-04-15T15:01:24.156176
2019-12-30T14:32:48
2019-12-30T14:32:48
55,257,183
3
2
null
null
null
null
UTF-8
C++
false
false
2,349
cpp
//1557 - Assignments //dp + bitmask memo //frankr@coj #include <iostream> #include <cstring> using namespace std; typedef long long LL; const int MAXN = 20; int c, n; int P[MAXN][MAXN]; int T[MAXN + 1][MAXN + 1]; LL fact[MAXN + 1]; bool calc[1 << MAXN]; LL dp[1 << MAXN]; LL f(int S){ if (!calc[S]){ LL r = 0; int Ce = __builtin_popcount(S); //if (Ce == 1) // r = P[__builtin_ctz(S)][0]; //else for (int i = 0 ; i < n ; i++) if (((1 << i) & S) && (P[i][Ce - 1])) r += f(S ^ (1 << i)); calc[S] = true; dp[S] = r; } return dp[S]; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); fact[0] = 1; for (int i = 1 ; i <= MAXN ; i++) fact[i] = fact[i - 1] * i; cin >> c; //cout << __builtin_ctz(c); while (c--){ cin >> n; for (int i = 0 ; i < n ; i++) for (int j = 0 ; j < n ; j++){ cin >> P[i][j]; T[i + 1][j + 1] = P[i][j] + T[i][j + 1] + T[i + 1][j] - T[i][j]; if (i == j && T[i + 1][i + 1] == (i + 1) * (i + 1)){ calc[(1 << i) - 1] = true; dp[(1 << i) - 1] = fact[i + 1]; } } for (int i = 0 ; i < (1 << n) ; i++) calc[i] = false; for (int i = 0 ; i < n ; i++){ calc[1 << i] = true; dp[1 << i] = P[i][0]; } cout << f((1 << n) - 1) << '\n'; } return 0; } /* 20 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 */
[ "farteaga@ipvce.lt.rimed.cu" ]
farteaga@ipvce.lt.rimed.cu
de78026d1cbe39a402f61600249758e5e2122f98
42aee3f10fd1bf1ff3073d68cb75c82628dbf324
/psql_mongo_replication/include/psql_mongo_replication/psql_mongo_replication.hpp
a020109f0409f161d42944099fe984478ea098fc
[]
no_license
FriendOrYes/psql_mongo_replication
5ad9450a84619e11a27b87f3179edf4cdaec1e63
7b9d8a388134081b37c64c2eb9f9c000a99cb0e4
refs/heads/master
2022-11-01T18:02:16.986739
2020-06-11T13:43:51
2020-06-11T13:43:51
268,163,010
0
0
null
null
null
null
UTF-8
C++
false
false
1,123
hpp
#pragma once #include <memory> #include <thread> #include <mutex> #include <vector> struct pg_recvlogical_connection_settings_t; namespace psql_mongo_replication { class mongo_replication; class psql_to_mongo { private: std::vector<std::unique_ptr<mongo_replication>> _mongo_replications_db; static unsigned char on_changes_static(const void* context, const char* changes, unsigned size); psql_mongo_replication::mongo_replication* get_db_instance(int id); std::unique_ptr<std::thread> _replication_thread; std::mutex _mutex; public: psql_to_mongo(); ~psql_to_mongo(); void on_changes(const char* changes, unsigned size); void connect_to_mongo_db(const pg_recvlogical_connection_settings_t& connection); void reconnect(int id); void unconnect_from_mongo_db(); void connect_to_mongo_dbs(const pg_recvlogical_connection_settings_t* connection, unsigned count); void start_replication(const pg_recvlogical_connection_settings_t& host_connection); }; }
[ "a.chaban@infomir.com" ]
a.chaban@infomir.com
943364c6a7846f38e811a010081e671fd60d6ef6
b8487f927d9fb3fa5529ad3686535714c687dd50
/unittests/Parser/JSONParserTest.cpp
656816857be8f2df770522cf7779fdd5472e05cd
[ "MIT" ]
permissive
hoangtuanhedspi/hermes
4a1399f05924f0592c36a9d4b3fd1f804f383c14
02dbf3c796da4d09ec096ae1d5808dcb1b6062bf
refs/heads/master
2020-07-12T21:21:53.781167
2019-08-27T22:58:17
2019-08-27T22:59:55
204,908,743
1
0
MIT
2019-08-28T17:44:49
2019-08-28T10:44:49
null
UTF-8
C++
false
false
5,278
cpp
/* * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the LICENSE * file in the root directory of this source tree. */ #include "hermes/Parser/JSONParser.h" #include "hermes/Support/JSONEmitter.h" #include "gtest/gtest.h" using namespace hermes; using namespace hermes::parser; namespace { TEST(JSONParserTest, SmokeTest1) { static const char json[] = "{\n" " '6': null,\n" " '1': null,\n" " '2': null,\n" " '3': null,\n" " '4': null,\n" " '5': null\n" "}"; JSLexer::Allocator alloc; JSONFactory factory(alloc); SourceErrorManager sm; JSONParser parser(factory, json, sm); auto parsed = parser.parse(); ASSERT_TRUE(parsed.hasValue()); } TEST(JSONParserTest, SmokeTest2) { JSLexer::Allocator alloc; JSONFactory factory(alloc); SourceErrorManager sm; JSONParser parser( factory, "{" " 'key1' : 1," " 'key2' : 'value2'," " 'key3' : {'nested1': true}," " \"key4\" : [false, null, 'value2']" "}", sm); // Check basic assumptions. ASSERT_STREQ("key4", factory.getString("key4")->c_str()); ASSERT_STREQ("key3", factory.getString("key3")->c_str()); ASSERT_STREQ("key2", factory.getString("key2")->c_str()); ASSERT_STREQ("key1", factory.getString("key1")->c_str()); ASSERT_STREQ("key0", factory.getString("key0")->c_str()); ASSERT_EQ(factory.getNumber(1.0)->getValue(), 1.0); ASSERT_EQ(factory.getString("key2"), factory.getString("key2")); // Parse an object. auto t1 = parser.parse(); ASSERT_TRUE(t1.hasValue()); auto *o1 = llvm::dyn_cast<JSONObject>(t1.getValue()); ASSERT_NE(nullptr, o1); ASSERT_EQ(4u, o1->size()); ASSERT_EQ(0u, o1->count("key0")); ASSERT_EQ(o1->end(), o1->find("key0")); ASSERT_EQ(1u, o1->count("key1")); auto kv1 = o1->find("key1"); ASSERT_NE(o1->end(), kv1); ASSERT_EQ((*kv1).first, factory.getString("key1")); ASSERT_EQ((*kv1).second, factory.getNumber(1.0)); ASSERT_EQ(o1->at("key1"), (*kv1).second); ASSERT_EQ(o1->operator[]("key1"), (*kv1).second); ASSERT_EQ(1u, o1->count("key2")); auto kv2 = o1->find("key2"); ASSERT_NE(o1->end(), kv2); ASSERT_EQ((*kv2).first, factory.getString("key2")); ASSERT_EQ((*kv2).second, factory.getString("value2")); JSONValue *value2 = (*kv2).second; ASSERT_EQ(1u, o1->count("key3")); ASSERT_EQ(1u, o1->count("key4")); // Keys are ordered in insertion order. auto it = o1->begin(); ASSERT_STREQ("key1", (*it).first->c_str()); ASSERT_EQ(o1->find("key1"), it); ++it; ASSERT_STREQ("key2", (*it).first->c_str()); ASSERT_EQ(o1->find("key2"), it); ++it; ASSERT_STREQ("key3", (*it).first->c_str()); ASSERT_EQ(o1->find("key3"), it); ++it; ASSERT_STREQ("key4", (*it).first->c_str()); ASSERT_EQ(o1->find("key4"), it); ++it; ASSERT_EQ(o1->end(), it); // Check the nested object auto *o2 = llvm::dyn_cast<JSONObject>((*o1)["key3"]); ASSERT_NE(nullptr, o2); auto it2 = o2->begin(); ASSERT_STREQ("nested1", (*it2).first->c_str()); ASSERT_EQ(factory.getBoolean(true), (*it2).second); ++it2; ASSERT_EQ(o2->end(), it2); // Check the array auto *a1 = llvm::dyn_cast<JSONArray>(o1->at("key4")); ASSERT_NE(nullptr, a1); ASSERT_EQ(3u, a1->size()); auto it3 = a1->begin(); ASSERT_EQ(*it3, a1->at(0)); ASSERT_EQ(*it3, (*a1)[0]); ASSERT_EQ(*it3, factory.getBoolean(false)); ++it3; ASSERT_EQ(*it3, a1->at(1)); ASSERT_EQ(*it3, factory.getNull()); ++it3; ASSERT_EQ(*it3, a1->at(2)); ASSERT_EQ(value2, *it3); // This also checks the uniquing ++it3; ASSERT_EQ(a1->end(), it3); } TEST(JSONParserTest, HiddenClassTest) { JSLexer::Allocator alloc; JSONFactory factory(alloc); SourceErrorManager sm; JSONParser parser( factory, "[ {'key1': 1, 'key2': {'key2': 5, 'key1': 6}}, " "{'key2': 10, 'key1': 20}]", sm); auto t1 = parser.parse(); ASSERT_TRUE(t1.hasValue()); auto array = llvm::dyn_cast<JSONArray>(t1.getValue()); ASSERT_NE(nullptr, array); ASSERT_EQ(2u, array->size()); auto o1 = llvm::dyn_cast<JSONObject>(array->at(0)); ASSERT_NE(nullptr, o1); auto o2 = llvm::dyn_cast<JSONObject>(o1->at("key2")); ASSERT_NE(nullptr, o2); ASSERT_EQ(o1->getHiddenClass(), o2->getHiddenClass()); auto o3 = llvm::dyn_cast<JSONObject>(array->at(1)); ASSERT_NE(nullptr, o3); ASSERT_EQ(o1->getHiddenClass(), o3->getHiddenClass()); } TEST(JSONParserTest, EmitTest) { JSLexer::Allocator alloc; JSONFactory factory(alloc); SourceErrorManager sm; std::string storage; llvm::raw_string_ostream OS(storage); JSONEmitter emitter(OS); JSONParser parser( factory, "{" " 'key1' : 1," " 'key2' : 'value2'," " 'key3' : {'nested1': true}," " \"key4\" : [false, null, 'value2']" "}", sm); auto t1 = parser.parse(); ASSERT_TRUE(t1.hasValue()); t1.getValue()->emitInto(emitter); // This intermediate variable is necessary because // MSVC's macro preprocessor does not behave as expected with R-literals. const char *expected = R"#({"key1":1,"key2":"value2","key3":{"nested1":true},)#" R"#("key4":[false,null,"value2"]})#"; EXPECT_EQ(OS.str(), expected); } }; // anonymous namespace
[ "facebook-github-bot@users.noreply.github.com" ]
facebook-github-bot@users.noreply.github.com
9f78062d4af7a32ff6c2265c3d12614eb89c23f4
a7d39b83bee548cc4d280d05434ba80bd4f08e36
/gefranseven_moudle_thread.cpp
9aa9a793fa1b677852d9994ffc7920db73a4d78a
[]
no_license
kimbakcho/QCserver2
5cf1b8cbf28e9b04e2c2eddf0a3e5acb74903f9e
f78db7ed417074fad874ab14aab03eaf285ea970
refs/heads/master
2020-12-25T09:57:14.469564
2016-07-20T00:15:06
2016-07-20T00:15:06
62,351,198
0
0
null
null
null
null
UTF-8
C++
false
false
533
cpp
#include "gefranseven_moudle_thread.h" #include "gefranseven_base_logic.h" gefranseven_moudle_thread::gefranseven_moudle_thread(QObject *parent) { playflag = true; this->parent = parent; } void gefranseven_moudle_thread::run(){ gefranseven_base_logic *parent_logic = (gefranseven_base_logic *)this->parent; while(playflag){ parent_logic->mutex.lock(); parent_logic->waitcondition.wait(&(parent_logic->mutex)); parent_logic->url_gefranbaseloop(); parent_logic->mutex.unlock(); } }
[ "vngkgk624@naver.com" ]
vngkgk624@naver.com
00b10a5d6370b17fbf729657f00aef08cfe26827
0eff74b05b60098333ad66cf801bdd93becc9ea4
/second/download/xgboost/xgboost-gumtree/dmlc_xgboost_old_new_new_log_622.cpp
71f6a1cbdf6243ac1564b6687e30815d786bfbf6
[]
no_license
niuxu18/logTracker-old
97543445ea7e414ed40bdc681239365d33418975
f2b060f13a0295387fe02187543db124916eb446
refs/heads/master
2021-09-13T21:39:37.686481
2017-12-11T03:36:34
2017-12-11T03:36:34
null
0
0
null
null
null
null
UTF-8
C++
false
false
87
cpp
utils::Assert(index >= start_ && index < end_,"The query index out of sampling bound");
[ "993273596@qq.com" ]
993273596@qq.com
edaebe49a7dbe4d9738bb163bad025db97481e4f
33eaafc0b1b10e1ae97a67981fe740234bc5d592
/tests/RandomSAT/z3-master/src/muz/pdr/pdr_reachable_cache.cpp
85100c19f4508cfba05598f8d290848573202d1c
[ "MIT" ]
permissive
akinanop/mvl-solver
6c21bec03422bb2366f146cb02e6bf916eea6dd0
bfcc5b243e43bddcc34aba9c34e67d820fc708c8
refs/heads/master
2021-01-16T23:30:46.413902
2021-01-10T16:53:23
2021-01-10T16:53:23
48,694,935
6
2
null
2016-08-30T10:47:25
2015-12-28T13:55:32
C++
UTF-8
C++
false
false
3,230
cpp
/*++ Copyright (c) 2011 Microsoft Corporation Module Name: reachable_cache.cpp Abstract: Object for caching of reachable states. Author: Krystof Hoder (t-khoder) 2011-9-14. Revision History: --*/ #include "pdr_reachable_cache.h" namespace pdr { reachable_cache::reachable_cache(pdr::manager & pm, datalog::PDR_CACHE_MODE cm) : m(pm.get_manager()), m_pm(pm), m_ctx(0), m_ref_holder(m), m_disj_connector(m), m_cache_mode(cm) { if (m_cache_mode == datalog::CONSTRAINT_CACHE) { m_ctx = pm.mk_fresh(); m_ctx->assert_expr(m_pm.get_background()); } } void reachable_cache::add_disjuncted_formula(expr * f) { app_ref new_connector(m.mk_fresh_const("disj_conn", m.mk_bool_sort()), m); app_ref neg_new_connector(m.mk_not(new_connector), m); app_ref extended_form(m); if(m_disj_connector) { extended_form = m.mk_or(m_disj_connector, neg_new_connector, f); } else { extended_form = m.mk_or(neg_new_connector, f); } if (m_ctx) { m_ctx->assert_expr(extended_form); } m_disj_connector = new_connector; } void reachable_cache::add_reachable(expr * cube) { switch (m_cache_mode) { case datalog::NO_CACHE: break; case datalog::HASH_CACHE: m_stats.m_inserts++; m_cache.insert(cube); m_ref_holder.push_back(cube); break; case datalog::CONSTRAINT_CACHE: m_stats.m_inserts++; TRACE("pdr", tout << mk_pp(cube, m) << "\n";); add_disjuncted_formula(cube); break; default: UNREACHABLE(); } } bool reachable_cache::is_reachable(expr * cube) { bool found = false; switch (m_cache_mode) { case datalog::NO_CACHE: return false; case datalog::HASH_CACHE: found = m_cache.contains(cube); break; case datalog::CONSTRAINT_CACHE: { if(!m_disj_connector) { found = false; break; } expr * connector = m_disj_connector.get(); expr_ref_vector assms(m); assms.push_back(connector); m_ctx->push(); m_ctx->assert_expr(cube); lbool res = m_ctx->check(assms); m_ctx->pop(); TRACE("pdr", tout << "is_reachable: " << res << " " << mk_pp(cube, m) << "\n";); found = res == l_true; break; } default: UNREACHABLE(); break; } if (found) m_stats.m_hits++; m_stats.m_miss++; return found; } void reachable_cache::collect_statistics(statistics& st) const { st.update("cache inserts", m_stats.m_inserts); st.update("cache miss", m_stats.m_miss); st.update("cache hits", m_stats.m_hits); } void reachable_cache::reset_statistics() { m_stats.reset(); } }
[ "nikaponens@gmail.com" ]
nikaponens@gmail.com
9aacec50263e2cfcd8e4f5e94ae15220915c54a9
7f62f204ffde7fed9c1cb69e2bd44de9203f14c8
/NtlLib/Server/NtlSystem/NtlMemoryPool.h
f0be3595b948606f02d0dc7e36238bcec12a8af1
[]
no_license
4l3dx/DBOGLOBAL
9853c49f19882d3de10b5ca849ba53b44ab81a0c
c5828b24e99c649ae6a2953471ae57a653395ca2
refs/heads/master
2022-05-28T08:57:10.293378
2020-05-01T00:41:08
2020-05-01T00:41:08
259,094,679
3
3
null
2020-04-29T17:06:22
2020-04-26T17:43:08
null
UHC
C++
false
false
12,367
h
//*********************************************************************************** // // File : NtlMemoryPool.h // // Begin : 2005-12-13 // // Copyright : ⓒ NTL-Inc Co., Ltd // // Author : Hyun Woo, Koo ( zeroera@ntl-inc.com ) // // Desc : NTL 객체 메모리 풀 ( static 및 dynamic ) // //*********************************************************************************** #pragma once //----------------------------------------------------------------------------------- // class CNtlMemoryPool_Dynamic //----------------------------------------------------------------------------------- #define __DONOT_USE_MEMORYPOOL__ #include <deque> #include "NtlMutex.h" template<class TYPE> class CNtlMemoryPool_Dynamic { public: CNtlMemoryPool_Dynamic(int nReserved = 0); virtual ~CNtlMemoryPool_Dynamic() { Destroy(); } public: // void Destroy(); // TYPE* Alloc(); // void Free(TYPE * t); // 전체 메모리 생성 개수 int GetTotalCount() { return m_nTotalCount; } // 할당 가능한 공간 반환(리스트에 있는 여분의 공간의 개수) int GetAvailableCount() { return store.size(); } // 처음 생성시 예약한 개수 int GetReservedCount() { return m_nReserved; } // 클라이언트에 메모리를 할당해준 개수 int GetAllocatedCount() { return GetTotalCount() - GetAvailableCount(); } private: void Init(); bool Reserve(int nCount); private: typedef std::deque<TYPE*> LIST; typedef typename LIST::iterator LISTIST; LIST m_store; int m_nTotalCount; // 메모리 생성 개수 int m_nReserved; // 예약한 개수 }; //----------------------------------------------------------------------------------- // Purpose : // Return : //----------------------------------------------------------------------------------- template <class TYPE> inline CNtlMemoryPool_Dynamic<TYPE>::CNtlMemoryPool_Dynamic(int nReserved) : m_nReserved( nReserved ), m_nTotalCount( 0 ) { if( nReserved > 0 ) { Reserve( m_nReserved ); } } //----------------------------------------------------------------------------------- // Purpose : // Return : //----------------------------------------------------------------------------------- template <class TYPE> inline void CNtlMemoryPool_Dynamic<TYPE>::Destroy() { LISTIST it = m_store.begin(); while( it != m_store.end() ) { free( *it ); it = m_store.erase(it); m_nTotalCount--; } } //----------------------------------------------------------------------------------- // Purpose : // Return : //----------------------------------------------------------------------------------- template <class TYPE> inline bool CNtlMemoryPool_Dynamic<TYPE>::Reserve(int nCount) { for( int i = 0; i < nCount; i++ ) { TYPE * pObject = (TYPE*) malloc( sizeof(TYPE) ); if ( NULL == pObject ) { Destroy(); return false; } m_store.push_back( pObject ); m_nTotalCount++; } return true; } //----------------------------------------------------------------------------------- // Purpose : // Return : //----------------------------------------------------------------------------------- template <class TYPE> inline TYPE* CNtlMemoryPool_Dynamic<TYPE>::Alloc() { TYPE * pObject = NULL; if( true == m_store.empty() ) { pObject = (TYPE*) malloc( sizeof(TYPE) ); if ( NULL == pObject ) { return NULL; } m_nTotalCount++; } else { pObject = *m_store.begin(); m_store.pop_front(); } return pObject; } //----------------------------------------------------------------------------------- // Purpose : // Return : //----------------------------------------------------------------------------------- template <class TYPE> inline void CNtlMemoryPool_Dynamic<TYPE>::Free(TYPE * t) { m_store.push_front(t); } //----------------------------------------------------------------------------------- // DYNAMIC MEMORY POOL MACRO //----------------------------------------------------------------------------------- #define DECLARE_DYNAMIC_MEMORYPOOL(classname) \ public: \ void * operator new( size_t stAllocationBlock ); \ void operator delete( void * pMem ); \ private: \ static CNtlMemoryPool_Dynamic<classname> __m_memoryPool__; #define DEFINE_DYNAMIC_MEMORYPOOL(classname, reserve) \ CNtlMemoryPool_Dynamic<classname> classname::__m_memoryPool__(reserve); \ void * classname::operator new( size_t stAllocationBlock ) \ { \ (void) stAllocationBlock; \ classname * pMem = __m_memoryPool__.Alloc(); \ return pMem; \ } \ \ void classname::operator delete( void * pMem ) \ { \ __m_memoryPool__.Free((classname*)pMem); \ } #ifdef __DONOT_USE_MEMORYPOOL__ #undef DECLARE_DYNAMIC_MEMORYPOOL #define DECLARE_DYNAMIC_MEMORYPOOL(classname) #undef DEFINE_DYNAMIC_MEMORYPOOL #define DEFINE_DYNAMIC_MEMORYPOOL(classname, reserve) #endif //----------------------------------------------------------------------------------- // DYNAMIC MEMORY POOL MACRO ( THREAD SAFE ) //----------------------------------------------------------------------------------- #define DECLARE_DYNAMIC_MEMORYPOOL_THREADSAFE(classname) \ public: \ void * operator new( size_t stAllocationBlock ); \ void operator delete( void * pMem ); \ private: \ static CNtlMutex __m_poolMutex__; \ static CNtlMemoryPool_Dynamic<classname> __m_memoryPool__; #define DEFINE_DYNAMIC_MEMORYPOOL_THREADSAFE(classname, reserve) \ CNtlMutex classname::__m_poolMutex__; \ CNtlMemoryPool_Dynamic<classname> classname::__m_memoryPool__(reserve); \ void * classname::operator new( size_t stAllocationBlock ) \ { \ (void) stAllocationBlock; \ __m_poolMutex__.Lock(); \ classname * pMem = __m_memoryPool__.Alloc(); \ __m_poolMutex__.Unlock(); \ return pMem; \ } \ \ void classname::operator delete( void * pMem ) \ { \ __m_poolMutex__.Lock(); \ __m_memoryPool__.Free((classname*)pMem); \ __m_poolMutex__.Unlock(); \ } #ifdef __DONOT_USE_MEMORYPOOL__ #undef DECLARE_DYNAMIC_MEMORYPOOL_THREADSAFE #define DECLARE_DYNAMIC_MEMORYPOOL_THREADSAFE(classname) #undef DEFINE_DYNAMIC_MEMORYPOOL_THREADSAFE #define DEFINE_DYNAMIC_MEMORYPOOL_THREADSAFE(classname, reserve) #endif ///////////////////////////////////////////////////////////////////////////////////// // // class CNtlMemoryPool_Static // ///////////////////////////////////////////////////////////////////////////////////// template <class TYPE> class CNtlMemoryPool_Static { public: CNtlMemoryPool_Static(int nSize = 0); virtual ~CNtlMemoryPool_Static() { Destroy(); } public: bool Create(int nSize); bool Destroy(); TYPE * Alloc(); void Free(TYPE * t); protected: int m_nPoolSize; int m_nAllocPos; TYPE * m_pTypeStore; TYPE ** m_ppTypePtrStore; }; //----------------------------------------------------------------------------------- // Purpose : // Return : //----------------------------------------------------------------------------------- template <class TYPE> inline CNtlMemoryPool_Static<TYPE>::CNtlMemoryPool_Static(int nSize) : m_nPoolSize( nSize ), m_nAllocPos( 0 ), m_pTypeStore( 0 ), m_ppTypePtrStore( 0 ) { if( nSize ) { Create( nSize ); } } //----------------------------------------------------------------------------------- // Purpose : // Return : //----------------------------------------------------------------------------------- template <class TYPE> inline bool CNtlMemoryPool_Static<TYPE>::Create(int nSize) { if( nSize <= 0 ) { return false; } m_nPoolSize = nSize; m_pTypeStore = (TYPE*) malloc( sizeof(TYPE) * m_nPoolSize ); if( NULL == m_pTypeStore ) { return false; } m_ppTypePtrStore = (TYPE**) malloc( sizeof(TYPE*) * m_nPoolSize ); if( NULL == m_ppTypePtrStore ) { return false; } for(int i = 0; i < nSize; i++) { m_ppTypePtrStore[i] = &m_pTypeStore[i]; } m_nAllocPos = 0; return true; } //----------------------------------------------------------------------------------- // Purpose : // Return : //----------------------------------------------------------------------------------- template <class TYPE> inline bool CNtlMemoryPool_Static<TYPE>::Destroy() { if( !m_nPoolSize ) return false; if( m_pTypeStore ) { free( m_pTypeStore ); m_pTypeStore = NULL; } if( m_ppTypePtrStore) { free( m_ppTypePtrStore ); m_ppTypePtrStore = NULL; } m_nPoolSize = 0; m_nAllocPos = 0; return true; } //----------------------------------------------------------------------------------- // Purpose : // Return : //----------------------------------------------------------------------------------- template <class TYPE> inline TYPE * CNtlMemoryPool_Static<TYPE>::Alloc() { if( m_nAllocPos >= m_nPoolSize ) { return (TYPE*) 0; printf("alloc fail \n"); } printf("alloc success \n"); return m_ppTypePtrStore[ m_nAllocPos++ ]; } //----------------------------------------------------------------------------------- // Purpose : // Return : //----------------------------------------------------------------------------------- template <class TYPE> inline void CNtlMemoryPool_Static<TYPE>::Free(TYPE * t) { if( m_nAllocPos <= 0 ) return; m_ppTypePtrStore[--m_nAllocPos] = t; } //----------------------------------------------------------------------------------- // STATIC MEMORY POOL DECLARE MACRO //----------------------------------------------------------------------------------- #define DECLARE_STATIC_MEMORYPOOL(classname) \ public: \ void * operator new( size_t stAllocationBlock ); \ void operator delete( void * pMem ); \ private: \ static CNtlMemoryPool_Static<classname> __m_memoryPool__; #define DEFINE_STATIC_MEMORYPOOL(classname, reserve) \ CNtlMemoryPool_Static<classname> classname::__m_memoryPool__(reserve); \ void * classname::operator new( size_t stAllocationBlock ) \ { \ (void) stAllocationBlock; \ classname * pMem = __m_memoryPool__.Alloc(); \ return pMem; \ } \ \ void classname::operator delete( void * pMem ) \ { \ __m_memoryPool__.Free((classname*)pMem); \ } #ifdef __DONOT_USE_MEMORYPOOL__ #undef DECLARE_STATIC_MEMORYPOOL #define DECLARE_STATIC_MEMORYPOOL(classname) #undef DEFINE_STATIC_MEMORYPOOL #define DEFINE_STATIC_MEMORYPOOL(classname, reserve) #endif //----------------------------------------------------------------------------------- // STATIC MEMORY POOL DECLARE MACRO ( THREAD SAFE ) //----------------------------------------------------------------------------------- #define DECLARE_STATIC_MEMORYPOOL_THREADSAFE(classname) \ public: \ void * operator new( size_t stAllocationBlock ); \ void operator delete( void * pMem ); \ private: \ static CNtlMutex __m_poolMutex__; \ static CNtlMemoryPool_Static<classname> __m_memoryPool__; \ #define DEFINE_STATIC_MEMORYPOOL_THREADSAFE(classname, reserve) \ CNtlMutex classname::__m_poolMutex__; \ CNtlMemoryPool_Static<classname> classname::__m_memoryPool__(reserve); \ void * classname::operator new( size_t stAllocationBlock ) \ { \ (void) stAllocationBlock; \ __m_poolMutex__.Lock(); \ classname * pMem = __m_memoryPool__.Alloc(); \ __m_poolMutex__.Unlock(); \ return pMem; \ } \ \ void classname::operator delete( void * pMem ) \ { \ __m_poolMutex__.Lock(); \ __m_memoryPool__.Free((classname*)pMem); \ __m_poolMutex__.Unlock(); \ } #ifdef __DONOT_USE_MEMORYPOOL__ #undef DECLARE_STATIC_MEMORYPOOL_THREADSAFE #define DECLARE_STATIC_MEMORYPOOL_THREADSAFE(classname) #undef DEFINE_STATIC_MEMORYPOOL_THREADSAFE #define DEFINE_STATIC_MEMORYPOOL_THREADSAFE(classname, reserve) #endif
[ "64261665+dboguser@users.noreply.github.com" ]
64261665+dboguser@users.noreply.github.com
b7e580f4d93b85a5727b6437c7638e3200a19db8
f157ec8df33573e770d7cf52a8526d21c72f9b48
/LibMerge/Transform.h
361f1356ab0479d1599607e93a9b4278b583ac40
[]
no_license
a995049470/Zero
c98eec3597fd7f07be9e9c2c23cf9c991ad3c3e5
f5cf7fc92193d5e9a8e4b9ac655678c2d4748d0a
refs/heads/master
2020-12-13T23:28:31.473558
2020-03-03T14:55:20
2020-03-03T14:55:20
234,562,129
0
0
null
null
null
null
MacCentralEurope
C++
false
false
855
h
#pragma once #include <glm/glm.hpp> #include <glm/gtc/matrix_transform.hpp> #include <glm/gtc/type_ptr.hpp> #include "Quaternion.h" using namespace glm; #define RIGHT vec3(1, 0, 0) #define UP vec3(0, 1, 0) #define FORWARD vec3(0, 0, 1) class Transform { public: Transform(); void Move(vec3 dis); void SetPosition(vec3 _val); vec3 GetPosition(); void SetScale(vec3 _val); vec3 GetScale(); void SetEulerAngle(vec3 _val); vec3 GetEulerAngle(); vec4 GetQuaternion(); mat4 GetModelMatrix(); vec3 GetUpDir(); vec3 GetFrontDir(); vec3 GetRightDir(); void Rotate(vec3 ag); void Rotate(vec3 aixs, float angle); private: Quaternion m_Qua; vec3 m_Position; vec3 m_Scale; // pitch»∆Right–ż◊™ yaw»∆Up–ż◊™ roll »∆Front–ż◊™ bool m_IsDity; mat4 m_ModelMatrix; vec3 m_UpDir; vec3 m_FrontDir; vec3 m_RightDir; };
[ "17855834269@163.com" ]
17855834269@163.com
eb2735fdfd3ec935fca390d4757fa38f129194f0
6dbc8ca5076f632a697cfb4d4ab06c50f4a7d3dc
/meta-tanowrt/conf/distro/include/tanowrt.inc
bfb522121929c11524ce6a46bc4ceac7fac344c1
[ "MIT", "LicenseRef-scancode-unknown" ]
permissive
tano-systems/meta-tanowrt
97487726127121916ce42896d950522eed0a2809
3ff38a82bce33e6d17bb250399d6e5d289917c81
refs/heads/master
2023-03-09T13:25:10.986084
2023-02-27T19:20:18
2023-02-27T19:20:37
135,370,024
30
20
MIT
2022-11-02T10:08:38
2018-05-30T01:11:44
Shell
UTF-8
C++
false
false
2,498
inc
# # SPDX-License-Identifier: MIT # Copyright (c) 2018-2020 Tano Systems LLC. All rights reserved. # require conf/distro/include/tanowrt-toolchain.inc require conf/distro/include/tanowrt-sdk.inc IMAGE_CLASSES += "tanowrt-image-types" # Required for rrdtool 1.0.50 HOSTTOOLS += "pod2man" # Virtual runtimes VIRTUAL-RUNTIME_dev_manager = "udev" VIRTUAL-RUNTIME_login_manager = "busybox" VIRTUAL-RUNTIME_init_manager = "procd" VIRTUAL-RUNTIME_kmod_manager = "ubox" VIRTUAL-RUNTIME_syslog = "rsyslog" VIRTUAL-RUNTIME_base-utils = "busybox" VIRTUAL-RUNTIME_network_manager = "netifd" # Start with default set of distro features DISTRO_FEATURES = "${DISTRO_FEATURES_DEFAULT} ${DISTRO_FEATURES_LIBC}" DISTRO_FEATURES:append = " swupdate " # Set procd as init manager DISTRO_FEATURES:append = " procd " # Enable cgroups support DISTRO_FEATURES:append = " cgroup " # Seccomp support DISTRO_FEATURES:append = " seccomp " # Enable wifi support DISTRO_FEATURES:append = " wifi " # Enable watchdog support DISTRO_FEATURES:append = " watchdog " # Graphics DISTRO_FEATURES:append = " graphics screen splash opengl wayland " # IPv6 DISTRO_FEATURES:append = " ipv6" # Remove sysvinit and systemd from DISTRO_FEATURES DISTRO_FEATURES_BACKFILL_CONSIDERED:append = " sysvinit systemd" # Clean DISTRO_FEATURES DISTRO_FEATURES:remove = "\ 3g \ nfc \ pulseaudio \ bluetooth \ irda \ pcmcia \ bluez5 \ largefile \ sysvinit \ systemd \ pam \ x11 \ " # Licenses LICENSE_FLAGS_ACCEPTED = "commercial_gst-ffmpeg commercial_gstreamer1.0-libav commercial" # Image IMAGE_FSTYPES:remove = "tar.xz.md5" # Root home path ROOT_HOME ??= "/root" # Set preferred Qt version QT_PROVIDER ?= "qt5" require conf/distro/include/tanowrt-packageconfig.inc require conf/distro/include/tanowrt-prefs.inc require conf/distro/include/tanowrt-repairs.inc require conf/distro/include/tanowrt-mirrors.inc require conf/distro/include/tanowrt-swupdate.inc # Unbreak multimachine builds LICENSE_DIRECTORY = "${DEPLOY_DIR}/licenses/${MACHINE_ARCH}" # Distro maintainer MAINTAINER = "TanoWrt Developers <https://github.com/tano-systems/meta-tanowrt>" DISTRO_EXTRA_RRECOMMENDS += "openssh-sftp-server" # Enable cryptodev/devcrypto engine in OpenSSL PACKAGECONFIG:append:pn-openssl = " cryptodev-linux" INHERIT += "do-populate-lic-deps" INHERIT += "tanowrt-paths" # # QEMU # QEMU_TARGETS = "arm aarch64 i386 x86_64" # # Dynamic includes # include conf/distro/include/tanowrt-hw.inc
[ "a.kikin@tano-systems.com" ]
a.kikin@tano-systems.com
39e5fcff79ebb8905e55e066802e975f95e506c7
46d93bce5be0405c33bfd9efc8ec46341a345282
/rvalue_references/MyInt.hpp
30f23331bc2989cde3dd3e95e3add2b06b07d7b2
[]
no_license
yashpatel007/Function-wrapper
47de9051cf6ec7a5df911549b088d1831cfdfd37
a721617ac18decbfc34d8ffa807bf28d0b9d8dd9
refs/heads/master
2021-04-21T03:10:04.542239
2019-12-11T18:48:42
2019-12-11T18:48:42
249,744,347
1
0
null
null
null
null
UTF-8
C++
false
false
417
hpp
#ifndef MY_INT_HPP #define MY_INT_HPP #include <iostream> class MyInt { friend std::ostream &operator<<(std::ostream &os, const MyInt &mi) { return os << mi.i; } public: MyInt() { count++; } MyInt(const MyInt &mi) : i(mi.i) { count++; } MyInt(int i) : i(i) { count++; } private: int i; public: static std::size_t count; }; #endif
[ "hqin4@binghamton.edu" ]
hqin4@binghamton.edu
ab411f812b135a409ee67ffa038461895dad3d77
65a6f59dd89d02eb66a0a758ae5da44b9007a4e9
/mde/DiesteinMDE/SendEMail.cpp
a8b4c8f64525295c8b44433a34f12c776fc6c4a1
[ "Unlicense" ]
permissive
hjgode/mde6
9b15c80e6f03269357a164a5d613373ccfac1ae6
d40e93f101b7bcb14dd16e2c83535348cf62d61f
refs/heads/master
2020-05-25T12:57:45.366421
2019-05-21T10:19:31
2019-05-21T10:19:31
187,810,000
0
0
null
null
null
null
ISO-8859-1
C++
false
false
11,775
cpp
// SendEMail.cpp : Definiert die Initialisierungsroutinen für die DLL. // #include "stdafx.h" #include "cstools4.h" #include "SendEMail.h" #include "afxwin.h" #ifdef _DEBUG #define new DEBUG_NEW #endif //********************************************************************************* //********************************************************************************* //********************************************************************************* //********************************************************************************* //********************************************************************************* // Einsprungpunkt //--------------------------------------------------------------------------------------------- BOOL EMAIL_Send( const TCHAR *strFrom, const TCHAR *strTo, const TCHAR *strBcc, // kann NULL oder "" sein const TCHAR *strCc, // kann NULL oder "" sein const TCHAR *strSubject, // kann NULL oder "" sein const TCHAR *strMessage, // kann NULL oder "" sein const TCHAR *strAttachment,// kann NULL oder "" sein const TCHAR *strHostName, UINT nHostPort, // kann 0 sein const TCHAR *strUserName, // kann NULL oder "" sein const TCHAR *strPassword, // kann NULL oder "" sein BOOL bAuthenticate, TCHAR *strError) // Receive String { if (!MimeInitialize(_T("DKHLQKCTJOHBMVNF"), NULL) || !SmtpInitialize(_T("DKHLQKCTJOHBMVNF"), NULL)) //CSTOOLS4_LICENSE_KEY { _tcscpy(strError,_T("Falscher Lizenzkey")); return FALSE; } CSendEMail myEmail(strFrom,strTo,strBcc,strCc,strSubject,strMessage,strAttachment, strHostName,nHostPort,strUserName,strPassword,bAuthenticate); myEmail.Send(); _tcscpy(strError,myEmail.m_strError); MimeUninitialize(); SmtpUninitialize(); if(myEmail.m_strError.IsEmpty()) return TRUE; return FALSE; } //--------------------------------------------------------------------------------------------- CSendEMail::CSendEMail( const TCHAR *strFrom, const TCHAR *strTo, const TCHAR *strBcc, const TCHAR *strCc, const TCHAR *strSubject, const TCHAR *strMessage, const TCHAR *strAttachment, const TCHAR *strHostName, UINT nHostPort, const TCHAR *strUserName, const TCHAR *strPassword, BOOL bAuthenticate) { m_strFrom = strFrom; m_strTo = strTo; if(strBcc) m_strBcc = strBcc; // kann NULL sein if(strCc) m_strCc = strCc; if(strSubject) m_strSubject = strSubject; if(strMessage) m_strMessage = strMessage; if(strAttachment) m_strAttachment = strAttachment; m_strHostName = strHostName; m_nHostPort = nHostPort; if(!nHostPort) m_nHostPort = SMTP_PORT_DEFAULT; if(strUserName) m_strUserName = strUserName; if(strPassword) m_strPassword = strPassword; m_bAuthenticate = bAuthenticate; m_hClient = INVALID_CLIENT; m_hMessage = INVALID_MESSAGE; m_bCanceled = FALSE; } //----------------------------------------------------------------------------------- CSendEMail::~CSendEMail() { if(m_hClient != INVALID_CLIENT) { SmtpDisconnect(m_hClient); m_hClient = INVALID_CLIENT; } if(m_hMessage != INVALID_MESSAGE) { MimeDeleteMessage(m_hMessage); m_hMessage = INVALID_MESSAGE; } } //------------------------------------------------------------------------------- void CSendEMail::ShowError(DWORD dwError) { TCHAR szError[128]; *(szError) = 0; if(dwError == 0) dwError = GetLastError(); // Because the error codes all shared between all of the // SocketTools libraries, the descriptions are the same, // regardless of what function actually generated the error if((MimeGetErrorString(dwError,szError,126)) == 0) m_strError.Format(_T("Unknown SocketTools error 0x%08lX"),dwError); else m_strError = szError; m_strError = _T("Errortest"); //AfxMessageBox(m_strError,MB_OK|MB_ICONEXCLAMATION); } // This event handler function is called as the message is being // submitted to the mail server //void CALLBACK CSendMailDlg::EventHandler(HCLIENT hClient, UINT nEventId, DWORD dwError, DWORD dwParam) //{ // CSendMailDlg *pThis = (CSendMailDlg *)dwParam; // // if (pThis == NULL) // return; // // SMTPTRANSFERSTATUS smtpStatus; // INT nResult = SmtpGetTransferStatus(hClient, &smtpStatus); // // if (nResult != SMTP_ERROR && smtpStatus.dwBytesTotal > 0) // { // INT nPercent = (INT)((DOUBLE)(100.0 * (DOUBLE)smtpStatus.dwBytesCopied / (DOUBLE)smtpStatus.dwBytesTotal)); // if (nPercent > 100) // nPercent = 100; // // pThis->m_ctlProgress.SetPos(nPercent); // pThis->m_ctlProgress.RedrawWindow(); // } // // TCHAR szStatus[256]; // // wsprintf(szStatus, _T("Submitting message to server %lu/%lu"), // smtpStatus.dwBytesCopied, smtpStatus.dwBytesTotal); // // pThis->m_ctlStatus.SetWindowText(szStatus); // pThis->m_ctlStatus.RedrawWindow(); //} void CSendEMail::Send() { BOOL bResult; int nResult; // Compose the message based on the input provided by the user m_hMessage = MimeComposeMessage( m_strFrom, m_strTo, m_strCc, m_strSubject, m_strMessage, NULL, MIME_CHARSET_ISOLATIN1, MIME_ENCODING_8BIT ); if(m_hMessage == INVALID_MESSAGE) { ShowError(); return; } // If a file attachment was specified, then attach it to the // message that was created CStringArray strArr; int start = 0; CString str = m_strAttachment.Tokenize(_T(";,"),start); while(!str.IsEmpty()) { str.Trim(); strArr.Add(str); str = m_strAttachment.Tokenize(_T(";,"),start); } for(int i = 0; i < strArr.GetCount(); i++) { if(strArr.GetAt(i).GetLength() > 0) { bResult = MimeAttachFile(m_hMessage,strArr.GetAt(i),MIME_ATTACH_BASE64); if(!bResult) { ShowError(); return; } } } // Get the contents of the complete message, including the headers, // main message body and optional file attachment data; it will be // returned a global memory handle HGLOBAL hgblMessage = NULL; DWORD dwMessageSize = 0; bResult = MimeExportMessageEx( m_hMessage, MIME_EXPORT_HGLOBAL, MIME_OPTION_DEFAULT, &hgblMessage, &dwMessageSize); if(!bResult) { ShowError(); return; } // Parse the sender email address to make sure that we only have // the actual address, not their name, etc. TCHAR szSender[256]; MimeParseAddress(m_strFrom, NULL, szSender, 256); // Create a list of all of the recipient addresses; we will use // this when submitting the message to the SMTP server LPTSTR lpszRecipients = NULL; DWORD cchRecipients = 0; INT nRecipients = 0; // Determine the number of characters that should be allocated to store // all of the addresses in the current message nRecipients = MimeEnumMessageRecipients( m_hMessage, m_strBcc, NULL, &cchRecipients); // Allocate the memory for the string buffer that will contain all // of the recipient addresses and call MimeEnumMessageRecipients // again to store those addresses in the buffer if((nRecipients > 0) && (cchRecipients > 0)) { lpszRecipients = (LPTSTR)LocalAlloc(LPTR,cchRecipients*sizeof(TCHAR)); if(lpszRecipients == NULL) return; // Virtual memory exhausted nRecipients = MimeEnumMessageRecipients( m_hMessage, m_strBcc, lpszRecipients, &cchRecipients); } if(nRecipients == 0) { AfxMessageBox(_T("kein Empfänger"), MB_ICONEXCLAMATION); return; } else { TCHAR *lpszAddress = lpszRecipients; int cchAddress; while(lpszAddress != NULL) { if((cchAddress = (int)_tcslen(lpszAddress)) == 0) break; // Change the null characters which separate each address // into commas, creating a comma-separated list of addresses if (*(lpszAddress + cchAddress + 1) != '\0') *(lpszAddress + cchAddress) = ','; lpszAddress += cchAddress + 1; } } // Connect to the SMTP server that was specified by the user m_hClient = SmtpConnect( m_strHostName, m_nHostPort, 10,//SMTP_TIMEOUT, SMTP_OPTION_EXTENDED, NULL, NULL); if(m_hClient == INVALID_CLIENT) { ShowError(); return; } // If the user has checked the 'requires authentication' checkbox, // then authenticate the client session with the server if(m_bAuthenticate) { BOOL bExtended; DWORD dwOptions; INT nResult; // Determine if this server really does support extended // options, and if it does, what they are bExtended = SmtpGetExtendedOptions(m_hClient, &dwOptions); if(bExtended && (dwOptions & SMTP_EXTOPT_AUTHLOGIN)) { nResult = SmtpAuthenticate( m_hClient, SMTP_AUTH_DEFAULT, m_strUserName, m_strPassword); if(nResult == SMTP_ERROR) { // Display a friendly error message here if the user could // not be authenticated; some SMTP servers can return rather // cryptic messages m_strError = _T("Falscher Authorisierungskode"); return; } } else { // This server doesn't support authentication; the user needs // to clear the checkbox and try again m_strError = _T("Kein Authorisierungskode"); return; } } // Register a handler for the SMTP_EVENT_PROGRESS event so that // we can update the progress bar control; note that since the // event handler is static, we pass the 'this' pointer as the // optional parameter and then use that in the handler //nResult = SmtpRegisterEvent( // m_hClient, // SMTP_EVENT_PROGRESS, // EventHandler, // (DWORD)this); // //if(nResult == SMTP_ERROR) // { // ShowError(); // return; // } nResult = SmtpSendMessage( m_hClient, szSender, lpszRecipients, hgblMessage, dwMessageSize, SMTP_MESSAGE_HGLOBAL); // Free memory allocated for the message GlobalFree(hgblMessage); if(nResult == SMTP_ERROR) { DWORD dwError = SmtpGetLastError(); if(dwError != ST_ERROR_NO_VALID_RECIPIENTS) ShowError(); else { // If the error is ST_ERROR_NO_VALID_RECIPIENTS the server is // probably rejecting the message because its being asked to // relay a message to a user outside of its domain, and the client // session has not been authenticated. // Display a helpful error message, disconnect from the server // and allow the user to try again, rather than closing the // dialog m_strError = _T("Ungültiger Empfänger"); SmtpDisconnect(m_hClient); m_hClient = INVALID_CLIENT; MimeDeleteMessage(m_hMessage); m_hMessage = INVALID_MESSAGE; return; } } else { // AfxMessageBox(_T("Email-Versand erfolgreich"),MB_ICONINFORMATION); } }
[ "hjgode@gmail.com" ]
hjgode@gmail.com
f6543929105126ba6bd6c5c1f60b54f20107d932
db24d9a142f687fbc19f9a1481144bb3f43bd42d
/src/Map/WorldMap.h
fb3cec715d5305ca4fc872f59853f23d4469b737
[]
no_license
jdoolittle126/Cube-Game
26d6047446cd3678666eaa316e054e26f446b67f
2c906b54122b6076c2069b15d7011b97f4896d9f
refs/heads/master
2021-08-08T14:45:52.474381
2020-08-12T02:19:47
2020-08-12T02:19:47
210,674,126
0
0
null
null
null
null
UTF-8
C++
false
false
1,104
h
#pragma once #include "../Managers/GameManager.h" #include "MapTileManager.h" #include "MapTile.h" class WorldMap { private: std::vector<MapTile*> tiles; MapTileManager tile_manager; GLuint vaoId; void build_vao() { glGenVertexArrays(1, &vaoId); glBindVertexArray(vaoId); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, UniqueMapTile::eboId); glEnableVertexAttribArray(0); glEnableVertexAttribArray(1); glEnableVertexAttribArray(2); glBindBuffer(GL_ARRAY_BUFFER, UniqueMapTile::vboId); glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, 0); glBindBuffer(GL_ARRAY_BUFFER, UniqueMapTile::nboId); glVertexAttribPointer(2, 3, GL_FLOAT, GL_FALSE, 0, 0); glBindVertexArray(0); } public: WorldMap(GLuint textureId) : tile_manager(textureId){ build_vao(); } ~WorldMap() { while(!tiles.empty()) delete tiles.back(), tiles.pop_back(); } void update(float delta); void display(float delta, GameManager & manager); void create_tile(float x, float y, float z, int tex_x, int tex_y); void destroy_tile(float x, float y, float z); std::vector<cube_bound> get_world_bounds(); };
[ "jdoolittle126@gmail.com" ]
jdoolittle126@gmail.com
678f238f01c31e5d8ada3c37cd6b05492c651cdf
768371d8c4db95ad629da1bf2023b89f05f53953
/applayerpluginsandutils/httpprotocolplugins/httpclient/chttpconnectfilter.cpp
e3673e15fd3a874e067a966bbfc2fe0dcb89b486
[]
no_license
SymbianSource/oss.FCL.sf.mw.netprotocols
5eae982437f5b25dcf3d7a21aae917f5c7c0a5bd
cc43765893d358f20903b5635a2a125134a2ede8
refs/heads/master
2021-01-13T08:23:16.214294
2010-10-03T21:53:08
2010-10-03T21:53:08
71,899,655
2
0
null
null
null
null
UTF-8
C++
false
false
12,767
cpp
// Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies). // All rights reserved. // This component and the accompanying materials are made available // under the terms of "Eclipse Public License v1.0" // which accompanies this distribution, and is available // at the URL "http://www.eclipse.org/legal/epl-v10.html". // // Initial Contributors: // Nokia Corporation - initial contribution. // // Contributors: // // Description: // #include "chttpconnectfilter.h" #include <httpstringconstants.h> #include <httperr.h> #include <http/rhttpheaders.h> _LIT8(KUAProfile, "x-wap-profile"); // 'this' used in base member initializer list, The 'this' pointer being used is a base class pointer. #pragma warning( disable : 4355 ) CHttpConnectFilter* CHttpConnectFilter::NewL(RHTTPSession aSession) { CHttpConnectFilter* self = new (ELeave) CHttpConnectFilter(aSession); CleanupStack::PushL(self); self->ConstructL(); CleanupStack::Pop(self); return self; } CHttpConnectFilter::~CHttpConnectFilter() { iConnectTransactions.Close(); iPendingTransactions.Close(); // If this object has been destroyed from the cleanup stack during creation // of the object, it might still be loaded - check. Normally the delete is // initiated by the 'delete this' in MHFUnload. if( iLoadCount ) { // As already in a destructor, MHFUnload must not delete this again. iLoadCount = -1; RStringF filterName = iStringPool.StringF(HTTP::EHttpConnectFilter, iStringTable); iSession.FilterCollection().RemoveFilter(filterName); } } CHttpConnectFilter::CHttpConnectFilter(RHTTPSession aSession) : CBase(), iSession(aSession), iStringTable(RHTTPSession::GetTable()), iStringPool(aSession.StringPool()), iCallback(*this) { } void CHttpConnectFilter::ConstructL() { // Register the filter. RStringF filterName = iStringPool.StringF(HTTP::EHttpConnectFilter, iStringTable); iSession.FilterCollection().AddFilterL( *this, THTTPEvent::ENeedTunnel, MHTTPFilter::EProtocolHandler +20, filterName ); iSession.FilterCollection().AddFilterL( *this, THTTPEvent::ECancel, MHTTPFilter::EProtocolHandler +20, filterName ); } TInt CHttpConnectFilter::FindConnectRequest(RStringF aTunnelHost, RStringF aProxy) { TInt id = KErrNotFound; TInt index = iConnectTransactions.Count(); RStringF tunnelName = iStringPool.StringF(HTTP::ETunnel, iStringTable); while( index > 0 && id == KErrNotFound ) { --index; RHTTPTransaction trans = iConnectTransactions[index]; THTTPHdrVal tunnelVal; #ifdef _DEBUG TBool found = #endif trans.PropertySet().Property(tunnelName, tunnelVal); __ASSERT_DEBUG( found, User::Invariant() ); if( aTunnelHost == tunnelVal.StrF() ) { // Ok the tunnel matches - check to see if a specific proxy is being // used. THTTPHdrVal proxyVal = RStringF(); trans.PropertySet().Property(iStringPool.StringF(HTTP::EProxyAddress, iStringTable), proxyVal); if( proxyVal.StrF() == aProxy ) { // There already is a CONNECT request for this tunnel - no need to // create another. id = trans.Id(); } } } return id; } TInt CHttpConnectFilter::CreateConnectTransactionL(RStringF aTunnelHost, RStringF aProxy, RStringF aUserAgent, RStringF aProfile) { // The Request-URI for the CONNECT request is in the 'authority' form, as // described in RFC2616, section 5.1.2, but need to pass the request uri as // a TUriC8... _LIT8(KSchemeString, "https://%S"); // uses more code to use RString EHTTPS than we save by adding the 5 bytes here TUriParser8 connectUri; HBufC8* uri = HBufC8::NewLC(aTunnelHost.DesC().Length()+8); uri->Des().AppendFormat(KSchemeString(), &aTunnelHost.DesC()); connectUri.Parse(*uri); // Open a CONNECT transaction... RStringF connectMethod = iStringPool.StringF(HTTP::ECONNECT, iStringTable); iNewConnectTransaction = iSession.OpenTransactionL( connectUri, iCallback, connectMethod ); CleanupStack::PopAndDestroy(uri); // As the CONNECT transaction is prepared, submitted and stored, it is // possible to orphan this transaction - it will need to be closed if a // leave occurs. iCloseConnectTransaction = ETrue; // Set aTunnelHost as the ETunnel property in the transaction. RStringF tunnelName = iStringPool.StringF(HTTP::ETunnel, iStringTable); THTTPHdrVal tunnelVal(aTunnelHost); iNewConnectTransaction.PropertySet().SetPropertyL(tunnelName, tunnelVal); if( aProxy.DesC().Length() > 0 ) { // ok need to use a specific proxy - set the appropriate properties in // the transaction. RHTTPPropertySet properties = iNewConnectTransaction.PropertySet(); properties.SetPropertyL( iStringPool.StringF(HTTP::EProxyUsage, iStringTable), iStringPool.StringF(HTTP::EUseProxy, iStringTable) ); properties.SetPropertyL( iStringPool.StringF(HTTP::EProxyAddress, iStringTable), aProxy ); } // get new transaction headers RHTTPHeaders hdr = iNewConnectTransaction.Request().GetHeaderCollection(); if(aUserAgent.DesC().Length() > 0) { // add the User-agent header hdr.SetFieldL( iStringPool.StringF(HTTP::EUserAgent, iStringTable), THTTPHdrVal(aUserAgent) ); } if(aProfile.DesC().Length() > 0) { // add the User Agent profile header //Note: if mmp file defines SRCDBG the next 4 lines cause a compiler bug in thumb udeb builds // can workaround compiler bug by removing local variable & using this line instead: // hdr.SetFieldL(iStringPool.OpenFStringL(KUAProfile), THTTPHdrVal(aProfile)); // but its not leave safe, but could be used for debugging if SRCDBG is really needed RStringF profileHeader = iStringPool.OpenFStringL(KUAProfile); CleanupClosePushL(profileHeader); hdr.SetFieldL(profileHeader, THTTPHdrVal(aProfile)); CleanupStack::PopAndDestroy(&profileHeader); } // Submit the CONNECT request... iNewConnectTransaction.SubmitL(); // Store CONNECT transaction... User::LeaveIfError(iConnectTransactions.Append(iNewConnectTransaction)); return iNewConnectTransaction.Id(); } void CHttpConnectFilter::CloseConnectTransaction(TInt aConnectId) { // Run through connect transaction array, remove and close the one with // this id. const TInt count = iConnectTransactions.Count(); for( TInt index = 0; index < count; ++index ) { RHTTPTransaction trans = iConnectTransactions[index]; if( trans.Id() == aConnectId ) { trans.Close(); iConnectTransactions.Remove(index); return; } } // If no CONNECT transaction found with that id - something has gone wrong. User::Invariant(); } /* * Methods from MHTTPFilterBase */ void CHttpConnectFilter::MHFRunL(RHTTPTransaction aTransaction, const THTTPEvent& aEvent) { switch( aEvent.iStatus ) { case THTTPEvent::ENeedTunnel: { // Transaction needs a tunnel - need to see if a CONNECT request has // been made for this origin server via the same proxy. aTransaction.Cancel(); // The transaction must have the ETunnel property - this contains the // host/port of where the tunnel needs to lead to. RHTTPPropertySet properties = aTransaction.PropertySet(); THTTPHdrVal tunnelVal; #ifdef _DEBUG TBool found = #endif properties.Property(iStringPool.StringF(HTTP::ETunnel, iStringTable), tunnelVal); __ASSERT_DEBUG( found, User::Invariant() ); __ASSERT_DEBUG( tunnelVal.Type() == THTTPHdrVal::KStrFVal, User::Invariant() ); // Also, check to see if the transaction has a specific proxy to use. // NOTE - no need to check HTTP::EUseProxy, only need to see if // the HTTP::EProxyAddress is set/ THTTPHdrVal proxyVal = RStringF(); properties.Property(iStringPool.StringF(HTTP::EProxyAddress, iStringTable), proxyVal); // See if there already is CONNECT transaction for this tunnel host/port. TInt connectId = FindConnectRequest(tunnelVal.StrF(), proxyVal.StrF()); if( connectId == KErrNotFound ) { // get request headers RHTTPHeaders hdr = aTransaction.Request().GetHeaderCollection(); // extract user-agent header THTTPHdrVal userAgent = RStringF(); hdr.GetField(iStringPool.StringF(HTTP::EUserAgent, iStringTable), 0, userAgent); // extract UA profile header RStringF profileHeader = iStringPool.OpenFStringL(KUAProfile); THTTPHdrVal profile = RStringF(); hdr.GetField(profileHeader, 0, profile); profileHeader.Close(); // Create a CONNECT transaction for the host/port. connectId = CreateConnectTransactionL(tunnelVal.StrF(), proxyVal.StrF(), userAgent.StrF(), profile.StrF()); } // Associate this transaction with the CONNECT transaction. TPendingTransaction pending = TPendingTransaction(aTransaction, connectId); User::LeaveIfError(iPendingTransactions.Append(pending)); // If a new CONNECT request was created, it is now safe. iCloseConnectTransaction = EFalse; } break; case THTTPEvent::ECancel: { // Check if this transaction is in the pending queue TBool found = EFalse; TInt index = iPendingTransactions.Count(); while( index > 0 && !found ) { --index; TPendingTransaction pending = iPendingTransactions[index]; if( pending.iPendingTransaction == aTransaction ) { // This transaction was waiting for a tunnel - remove it from the // queue. Let the CONNECT transaction for the tunnel continue as // there could be other pending transactions waiting for that // same tunnel. iPendingTransactions.Remove(index); found = ETrue; } } } break; default: break; } } void CHttpConnectFilter::MHFSessionRunL(const THTTPSessionEvent& /*aEvent*/) { } TInt CHttpConnectFilter::MHFRunError(TInt aError, RHTTPTransaction aTransaction, const THTTPEvent& /*aEvent*/) { // Something has gone a bit wrong - does the connect transaction need to be // closed? if( iCloseConnectTransaction ) { // Yep, this means that leave occured after the new connect transaction // was opened. iNewConnectTransaction.Close(); } // Send the error to the client if(aTransaction.SendEvent(aError, THTTPEvent::EIncoming, THTTPFilterHandle(THTTPFilterHandle::ECurrentFilter)) != KErrNone ) { aTransaction.Fail(); } return KErrNone; } TInt CHttpConnectFilter::MHFSessionRunError(TInt aError, const THTTPSessionEvent& /*aEvent*/) { return aError; } /* * Methods from MHTTPFilter */ void CHttpConnectFilter::MHFLoad(RHTTPSession, THTTPFilterHandle) { ++iLoadCount; } void CHttpConnectFilter::MHFUnload(RHTTPSession /*aSession*/, THTTPFilterHandle) { if( --iLoadCount > 0 ) return; delete this; } /* * Methods from MHttpConnectObserver */ void CHttpConnectFilter::ConnectCompleteL(TInt aConnectId) { // Close this CONNECT transaction CloseConnectTransaction(aConnectId); // Locate the pending transactions that were waiting for this tunnel. TInt index = iPendingTransactions.Count(); while( index > 0 ) { --index; TPendingTransaction pending = iPendingTransactions[index]; if( pending.iConnectId == aConnectId ) { // This transaction was waiting for the tunnel - re-submit it. pending.iPendingTransaction.SubmitL(); // Remove this entry. iPendingTransactions.Remove(index); } } } void CHttpConnectFilter::ConnectErrorL(TInt aConnectId) { // Close this CONNECT transaction CloseConnectTransaction(aConnectId); // Locate the pending transactions that were waiting for this tunnel. TInt index = iPendingTransactions.Count(); while( index > 0 ) { --index; TPendingTransaction pending = iPendingTransactions[index]; if( pending.iConnectId == aConnectId ) { // This transaction was waiting for the tunnel - send error. Pretend // that the error came from the protocol handler. This ensures all // filters are notified. pending.iPendingTransaction.SendEventL( KErrHttpCannotEstablishTunnel, THTTPEvent::EIncoming, THTTPFilterHandle(THTTPFilterHandle::EProtocolHandler) ); // Remove this entry. iPendingTransactions.Remove(index); } } } void CHttpConnectFilter::FailPendingTransactions(TInt aConnectId) { // No need to close the CONNECT transaction - would have closed already. // Locate the pending transactions that were waiting for this tunnel. TInt index = iPendingTransactions.Count(); while( index > 0 ) { --index; TPendingTransaction pending = iPendingTransactions[index]; if( pending.iConnectId == aConnectId ) { // This transaction was waiting for the tunnel - fail it! pending.iPendingTransaction.Fail(); // Remove this entry. iPendingTransactions.Remove(index); } } }
[ "kirill.dremov@nokia.com" ]
kirill.dremov@nokia.com
afd3a3e39f0ca62f16c2ba3f71aea24bc23c9d3a
942bc7a374ced8f96a139feac1a01148cc4e60d7
/include/nsbb/nsedilex.h
e6fb31a75e02cb8af4e32a26c88c2270b75f4bb6
[]
no_license
p-ameline/Episodus
915b0dfa324a0b9374b887f0fc9fd74a599b9ae3
8bba0a26e267cff40a7669c6ae47647c68a30834
refs/heads/master
2022-04-07T12:39:09.224028
2020-03-06T09:20:03
2020-03-06T09:20:03
119,287,108
1
3
null
null
null
null
ISO-8859-1
C++
false
false
3,597
h
#ifndef __NSEDILEX_H #define __NSEDILEX_H // #include <owl\owlpch.h> #include <owl\applicat.h> #include "owl\validate.h" #include <string.h> #include <cstring.h> #include "nsbb\nsdicogl.h" #include "nsbb\nsbb_dlg.h" #include "nsbb\nsbbtran.h" #include "nsbb\nsExport.h" // // // class NSEditLexiqueDerive ; class NSContexte ; class _NSBBCLASSE NSEditLexique : public NSEditDicoGlobal { public: NSControle* pControle ; string sContenuPere ; NSEditLexiqueDerive* pNSEdit ; //fils fictif string sComplement ; bool bWinStd ; // Gestion standard windows // // Constructeur et destructeur // NSEditLexique(TWindow* parent, NSContexte* pCtx, int resourceId, NSDico* pDictio, uint textLimit = 0, string sTypeLexique = "", TModule* module = 0) ; NSEditLexique(TWindow* parent, NSContexte* pCtx, int resourceId, NSDico* pDictio, const char far* text, int x, int y, int w, int h, uint textLimit = 0, bool multiline = false, string sTypeLexique = "", TModule* module = 0) ; ~NSEditLexique() ; // // méthodes // void SetupWindow() ; void UpdateDico() ; void SetPositionLexique() ; void ElementSelectionne() ; void EvChar(uint key, uint repeatCount, uint flags) ; void EvKeyDown(uint key, uint repeatCount, uint flags) ; void EvKeyUp(uint key, uint repeatcount, uint flags) ; void EvRButtonDown(uint modKeys, NS_CLASSLIB::TPoint& point) ; void CmEditPaste() ; uint EvGetDlgCode(MSG far* ) ; void EvKillFocus(THandle hWndGetFocus) ; void EvSetFocus(HWND hWndLostFocus) ; WNDTYPE donneType() { return (isEditLexique) ; } uint Transferer(TTransferDirection direction, CTRL_ACTIVITY* pActif, Message* pMessage = 0) ; uint TempTransferer(CTRL_ACTIVITY* pActif, Message* pMessage = 0) ; void activeControle(int activation, Message* pMessage = 0) ; void CreerEditDerive(string sCode, string sContenu) ; void CreerBBItem() ; bool isFreeTextEnabled() { return _bIsFreeTextEnabled ; } void setFreeTextEnabled(bool bT) { _bIsFreeTextEnabled = bT ; } protected: string getTextAsString() ; bool _bIsFreeTextEnabled ; DECLARE_RESPONSE_TABLE(NSEditLexique) ; }; // //classe du controle fictif crée en choisissant un élément dans le lexique // class NSComboSemantique ; class NSEditLexiqueDerive : public NSRoot { public: string sContenuTransfert ; //label dans le champ edit NSControle* pControle ; string sIdentite ; //code lexique NSContexte* pContexte ; string sComplement ; NSEditLexique* pEditPere ; NSComboSemantique* pComboPere ; // // Constructeur et destructeur // NSEditLexiqueDerive(NSContexte* pCtx, NSEditLexique* pEdit) ; NSEditLexiqueDerive(NSContexte* pCtx, NSComboSemantique* pCombo) ; ~NSEditLexiqueDerive() ; // // méthodes // WNDTYPE donneType() { return(isEditLexiqueDerive) ; } virtual uint Transferer(TTransferDirection direction, CTRL_ACTIVITY* pActif, Message* pMessage = 0) ; uint TempTransferer(CTRL_ACTIVITY* pActif, Message* pMessage = 0) ; void activeControle(int activation, Message* pMessage = 0) ; bool canWeClose() ; }; #endif
[ "philippe.ameline@free.fr" ]
philippe.ameline@free.fr
1457ea95ff5e724dcaf814f65ce505d0ff9ab275
834511cf7be1baf12df0d58996ba3a9f2ca67ee0
/FitnessClub.h
28e8eb3312eda2240741c439be172e833b54bb3a
[]
no_license
ammonjerro/Fitness_Club
60921d9224a1f5eaf495a806e857852b783a7d48
277472194a526cd74fba5bc8e253bd0e7360fc71
refs/heads/master
2020-12-06T08:40:51.644135
2020-01-08T03:14:30
2020-01-08T03:14:30
232,412,207
0
0
null
null
null
null
UTF-8
C++
false
false
7,059
h
#ifndef FITNESS_CLUB_FITNESSCLUB_H #define FITNESS_CLUB_FITNESSCLUB_H #include <vector> #include <iostream> #include "Member.h" #include "Trainer.h" #include "Consultant.h" #include "Receptionist.h" #include "Contract.h" using namespace std; class FitnessClub{ private: //basic information string name; string address; string city; int openTime; int closeTime; //finance information float totalBudget; float additionalExpenses; //lists of main objects vector <Employee*> Employees; vector <Member*> Members; vector <Contract*> Contracts; static vector<Product*> Products; //Stores the list of products that can be sold by a receptionist public: //Constructor FitnessClub(string name, string address, string city); //Getters and Setters void SetTotalBudget(float value){totalBudget=value;} //Members management void AddMember(int id, string name, string surname, string address, string gender); //Creates and adds member to the member list void RemoveMember(Member* member); //Removes member from the list, and deallocates memory, can only be performed if member doesn't have an active contract Member* FindMember(int id); // Searches for a member of a given ID in vector of Members and returns pointer to it or NULL if wasn't found //Method FindMember has many overloads, to allow searching by various data //Employment management //Methods with returning type bool return true when operation was successful and false otherwise bool EmployTrainer(string name, string surname, string nip, string address, int id, int rank); //creates new Trainer object, assigns its fields with given values, adds it to Trainer list bool EmployConsultant(string name, string surname, string nip, string address, int id, int rank); //creates new Consultant object, assigns its fields with given values, adds it to Trainer list bool EmployReceptionist(string name, string surname, string nip, string address, int id, int rank); //creates new Receptionist object, assigns its fields with given values, adds it to Trainer list void FireEmployee(Employee* emp); //if they have been associated with any contracts it chooses randomly from other employees and changes the pointers, then removes it from the list of employees, and deallocates memory void ResetEmployees(); //invokes each employee's method ResetValues() resets hours worked etc, usually done at the end of the month Trainer* RandomTrainer(); Consultant* RandomConsultant(); bool IdExistsEmployees(int id); bool IdExistsContracts(int id); bool IdExistsMembers(int id); //Methods Find(**) have many overloads, to allow searching by various data, below examples of ones with ID argument Employee* FindEmployee(int id); //searches vector of Employees for the one of a given ID and returns pointer to it or NULL if wasn't found Trainer* FindTrainer(int id); //searches vector of Employees for the one of a given ID and returns pointer to it or NULL if wasn't found Consultant* FindConsultant(int id);//searches vector of Employees for the one of a given ID and returns pointer to it or NULL if wasn't found Receptionist* FindReceptionist(int id);//searches vector of Employees for the one of a given ID and returns pointer to it or NULL if wasn't found void PrintEmployee(Employee* emp); //Uses given employee's override method GetInformation() and prints it in console //string GetInformation(Employee* emp); //Uses given employee's override method GetInformation() //Contracts management bool AddContract(Member* member, Consultant* consultant, Trainer* trainer, int id, float membershipFee, float trainingFee, float terminationFee, int duration); //First validates the arguments(for example if first 3 are not NULL), then creates new Contract object, associates it with given people setting proper pointers, sets values of other fields, adds it to the Contract list bool TerminateContract(Contract* contract); //executes payment following the terms of terminationFee, sets associated member hasContract value to "false", then removes contract from the list, and deallocates memory bool TransferContract(Member* from, Member* to); //first it checks if both members have contracts and determines if operation is possible, then changes given's contract pointer to the latter member and sets proper hasContract values Contract* FindContract(int id); //searches the list of contracts by ID, returns NULL if contract wasn't found Contract* FindContract(Member* member); //searches the list of contracts by member associated with it, returns NULL if contract wasn't found void DeleteContract(Contract* contract); //Removes contract from the list, deallocates memory //Finances management void ChargeMonthlyFee(Contract* contract); //Adds proper amount of funds to totalBudget void ChargeTrainingFee(Contract* contract); //Adds proper amount of funds to totalBudget bool ChargeMembers(); //executes payments on all members - int fact it just uses the methods above on each member(we assume that members have infinite money) bool ChargeTerminationFee(Contract* contract); //Adds proper amount of funds to totalBudget void GatherFromReceptionists(); //For each receptionist employed acquires proper amount of funds from products sold float GetSalary(Employee* emp); //calculates the salary of a given Employee depending on his role in the club bool PaySalary(Employee* emp); //pays to Employee - in fact it just subtracts specific amount from the totalBudget (calculated by GetSalary()) void PaySalaryToAll(); // pays to all Employees - performs PaySalary() to all employees void PayAdditionalExpenses(); // subtracts the value of AdditionalExpenses from totalBudget, which is a simple representation of such expenses like a rent or electricity of a club void SetAdditionalExpenses(float value); //Organization bool setOpenHours(int open, int closed); //changes values of openTime and closeTime void DecrementContractDurations(); void DeleteExpiredContracts(); void NextMonth(); //charges members, pays salaries, resets hours worked, decrements contracts durations, deletes expired contracts string GetInformation(); //creates a string containing information about a club void PrintInformation(); //uses GetInformation and prints it to the console void PrintEmployees(); void PrintMembers(); //Products static bool AddProduct(int id, string name, float price); //creates new Product and adds it to the Products vector; static void RemoveProduct(Product* product); //remove Product from the list, and deallocates memory static bool ChangeProductPrice(Product* product, float newPrice); //changes given product price static Product* FindProduct(int id); //Searches the list of avaliable products in reception by ID, returns NULL if not found; static void PrintProducts(); }; #endif //FITNESS_CLUB_FITNESSCLUB_H
[ "marclisek@gmail.com" ]
marclisek@gmail.com
afcfb69bf8be0a6b8bcb1d2e58fc1808b3a44ac4
e448cc834e8b12f2fecb4609dfdf06c6cf0e15f6
/KeyBinding.cpp
6a64f28a5f3933482b7b2544c50f0dff5485ced4
[]
no_license
julianh2o/Gravity
8d89bca275e4137f980a5733da2ca239ffeb6804
2f8771f527ed6a66b0f78b3bb762e6381e7ad1bd
refs/heads/master
2020-04-28T20:04:20.360150
2009-09-20T04:21:21
2009-09-20T04:21:21
null
0
0
null
null
null
null
UTF-8
C++
false
false
890
cpp
/* * KeyBinding.cpp * Gravity * * Created by Julian on 8/18/09. * Copyright 2009 Julian Hartline. All rights reserved. * */ // This class manages keybindings, bind() is called with a name for the binding // and the SDLKey to be associated with it. check() uses the given KeyState object // to return a boolean based on the state of the keyboard. #include "KeyBinding.h" KeyBinding::KeyBinding() { } // binds a string name to a SDLKey void KeyBinding::bind(std::string s, SDLKey k) { keys[s] = k; } void KeyBinding::unbind(std::string s) { keys.erase(s); } // Returns the state of the keyboard according to the given keystate bool KeyBinding::check(std::string s) { if (keys.find(s) != keys.end()) { return keyDown(keys[s]); } } bool KeyBinding::check(std::string s, SDL_Event event) { if (keys.find(s) != keys.end()) { return event.key.keysym.sym == keys[s]; } }
[ "julianh2o@gmail.com" ]
julianh2o@gmail.com
ee8c65a55f4e824bc15248e76e662b04569be3fa
1fdb58238276134582516207f8282c21732e0f6d
/build-UNEDUCADED-Desktop_Qt_5_12_2_MSVC2017_64bit-Debug/debug/moc_mainwindow.cpp
12a53eb044b349d1f4d2ffd1cf50f092fe8e4076
[]
no_license
dsmMinseo/UNEDUCADED
777cd352adc5651549f2ff932190f0725b10c59f
ece624cbe98d6bb93c697e0c923b26651bb61a46
refs/heads/master
2020-05-03T19:39:39.699059
2019-06-17T05:33:16
2019-06-17T05:33:16
178,788,157
0
2
null
2019-05-24T01:56:05
2019-04-01T04:55:55
C++
UTF-8
C++
false
false
5,488
cpp
/**************************************************************************** ** Meta object code from reading C++ file 'mainwindow.h' ** ** Created by: The Qt Meta Object Compiler version 67 (Qt 5.12.2) ** ** WARNING! All changes made in this file will be lost! *****************************************************************************/ #include "../../UNEDUCADED/mainwindow.h" #include <QtCore/qbytearray.h> #include <QtCore/qmetatype.h> #if !defined(Q_MOC_OUTPUT_REVISION) #error "The header file 'mainwindow.h' doesn't include <QObject>." #elif Q_MOC_OUTPUT_REVISION != 67 #error "This file was generated using the moc from 5.12.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 QT_WARNING_PUSH QT_WARNING_DISABLE_DEPRECATED struct qt_meta_stringdata_MainWindow_t { QByteArrayData data[13]; char stringdata0[264]; }; #define QT_MOC_LITERAL(idx, ofs, len) \ Q_STATIC_BYTE_ARRAY_DATA_HEADER_INITIALIZER_WITH_OFFSET(len, \ qptrdiff(offsetof(qt_meta_stringdata_MainWindow_t, stringdata0) + ofs \ - idx * sizeof(QByteArrayData)) \ ) static const qt_meta_stringdata_MainWindow_t qt_meta_stringdata_MainWindow = { { QT_MOC_LITERAL(0, 0, 10), // "MainWindow" QT_MOC_LITERAL(1, 11, 21), // "on_undoButton_clicked" QT_MOC_LITERAL(2, 33, 0), // "" QT_MOC_LITERAL(3, 34, 21), // "on_redoButton_clicked" QT_MOC_LITERAL(4, 56, 21), // "on_moveButton_clicked" QT_MOC_LITERAL(5, 78, 23), // "on_rotateButton_clicked" QT_MOC_LITERAL(6, 102, 22), // "on_scaleButton_clicked" QT_MOC_LITERAL(7, 125, 21), // "on_flipButton_clicked" QT_MOC_LITERAL(8, 147, 21), // "on_textButton_clicked" QT_MOC_LITERAL(9, 169, 23), // "on_lengthButton_clicked" QT_MOC_LITERAL(10, 193, 22), // "on_colorButton_clicked" QT_MOC_LITERAL(11, 216, 23), // "on_actionFont_triggered" QT_MOC_LITERAL(12, 240, 23) // "on_actionSave_triggered" }, "MainWindow\0on_undoButton_clicked\0\0" "on_redoButton_clicked\0on_moveButton_clicked\0" "on_rotateButton_clicked\0on_scaleButton_clicked\0" "on_flipButton_clicked\0on_textButton_clicked\0" "on_lengthButton_clicked\0on_colorButton_clicked\0" "on_actionFont_triggered\0on_actionSave_triggered" }; #undef QT_MOC_LITERAL static const uint qt_meta_data_MainWindow[] = { // content: 8, // revision 0, // classname 0, 0, // classinfo 11, 14, // methods 0, 0, // properties 0, 0, // enums/sets 0, 0, // constructors 0, // flags 0, // signalCount // slots: name, argc, parameters, tag, flags 1, 0, 69, 2, 0x08 /* Private */, 3, 0, 70, 2, 0x08 /* Private */, 4, 0, 71, 2, 0x08 /* Private */, 5, 0, 72, 2, 0x08 /* Private */, 6, 0, 73, 2, 0x08 /* Private */, 7, 0, 74, 2, 0x08 /* Private */, 8, 0, 75, 2, 0x08 /* Private */, 9, 0, 76, 2, 0x08 /* Private */, 10, 0, 77, 2, 0x08 /* Private */, 11, 0, 78, 2, 0x08 /* Private */, 12, 0, 79, 2, 0x08 /* Private */, // slots: parameters QMetaType::Void, QMetaType::Void, QMetaType::Void, QMetaType::Void, QMetaType::Void, QMetaType::Void, QMetaType::Void, QMetaType::Void, QMetaType::Void, QMetaType::Void, QMetaType::Void, 0 // eod }; void MainWindow::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a) { if (_c == QMetaObject::InvokeMetaMethod) { auto *_t = static_cast<MainWindow *>(_o); Q_UNUSED(_t) switch (_id) { case 0: _t->on_undoButton_clicked(); break; case 1: _t->on_redoButton_clicked(); break; case 2: _t->on_moveButton_clicked(); break; case 3: _t->on_rotateButton_clicked(); break; case 4: _t->on_scaleButton_clicked(); break; case 5: _t->on_flipButton_clicked(); break; case 6: _t->on_textButton_clicked(); break; case 7: _t->on_lengthButton_clicked(); break; case 8: _t->on_colorButton_clicked(); break; case 9: _t->on_actionFont_triggered(); break; case 10: _t->on_actionSave_triggered(); break; default: ; } } Q_UNUSED(_a); } QT_INIT_METAOBJECT const QMetaObject MainWindow::staticMetaObject = { { &QMainWindow::staticMetaObject, qt_meta_stringdata_MainWindow.data, qt_meta_data_MainWindow, qt_static_metacall, nullptr, nullptr } }; const QMetaObject *MainWindow::metaObject() const { return QObject::d_ptr->metaObject ? QObject::d_ptr->dynamicMetaObject() : &staticMetaObject; } void *MainWindow::qt_metacast(const char *_clname) { if (!_clname) return nullptr; if (!strcmp(_clname, qt_meta_stringdata_MainWindow.stringdata0)) return static_cast<void*>(this); return QMainWindow::qt_metacast(_clname); } int MainWindow::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QMainWindow::qt_metacall(_c, _id, _a); if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { if (_id < 11) qt_static_metacall(this, _c, _id, _a); _id -= 11; } else if (_c == QMetaObject::RegisterMethodArgumentMetaType) { if (_id < 11) *reinterpret_cast<int*>(_a[0]) = -1; _id -= 11; } return _id; } QT_WARNING_POP QT_END_MOC_NAMESPACE
[ "20012011ryu@gmail.com" ]
20012011ryu@gmail.com
061fd53f5111a496075c82f454ac2771d42240ad
c301c81f7560125e130a9eb67f5231b3d08a9d67
/lc/lc/2021_target/core/bt/lc_1485_clone_bt_random_ptr.cpp
d9eeb5a8be02d7bbaf144311adbd16a0d29f0ffb
[]
no_license
vikashkumarjha/missionpeace
f55f593b52754c9681e6c32d46337e5e4b2d5f8b
7d5db52486c55b48fe761e0616d550439584f199
refs/heads/master
2021-07-11T07:34:08.789819
2021-07-06T04:25:18
2021-07-06T04:25:18
241,745,271
0
0
null
null
null
null
UTF-8
C++
false
false
2,143
cpp
/** * Definition for a Node. * struct Node { * int val; * Node *left; * Node *right; * Node *random; * Node() : val(0), left(nullptr), right(nullptr), random(nullptr) {} * Node(int x) : val(x), left(nullptr), right(nullptr), random(nullptr) {} * Node(int x, Node *left, Node *right, Node *random) : val(x), left(left), right(right), random(random) {} * }; */ class Solution { public: void dfs(Node *root, unordered_map<Node*,NodeCopy*> &m) { if (!root) return; m[root] = new NodeCopy(root->val); dfs(root->left, m); dfs(root->right, m); } NodeCopy* copyRandomBinaryTree(Node* root) { unordered_map<Node*,NodeCopy*> m; dfs(root, m); for ( auto it : m) { if (it.first) { it.second->left = m[it.first->left]; it.second->right = m[it.first->right]; it.second->random = m[it.first->random]; } } return m[root]; } }; This can be solved with a simple DFS with a HashMap. First we check if the node is null, if not, we check if it's in our map, if not - we create a copy of our current node and run DFS again on the left, right and random nodes. One edge case to notice is that if there's a cycle in the tree (a random pointer looking at previous visited node) then the map would never be filled. To solve this we need to create the CopyNode, and immediately put it in the map. That way, when there's a cycle - we'd just return the node we put in the map and end the infinite loop. NodeCopy* help(Node* root){ if(root==NULL) return NULL; if(mmap.count(root)==1)return mmap[root]; NodeCopy* newroot=new NodeCopy(root->val); mmap[root]=newroot; newroot->left=help(root->left); newroot->right=help(root->right); newroot->random=help(root->random); return newroot; } NodeCopy* copyRandomBinaryTree(Node* root) { return help(root); } unordered_map<Node*, NodeCopy*> mmap;
[ "codingprepviks@gmail.com" ]
codingprepviks@gmail.com
546748a0d2af4968d91fa79594a7dcc893f46c77
202771bbbc2afc7027b74993e7000f3ea39255b4
/src/Jugador.h
81f74268421146b43f68106dc15e180770aa4423
[]
no_license
Gonan98/sfml-dungeon-game
f563b433bdf244a7212db000e63e9ae959b8e087
acf321cffdef1d0367709ffca535f34c94a1ee1b
refs/heads/master
2021-05-26T00:46:25.591376
2020-07-09T23:14:12
2020-07-09T23:14:12
254,148,855
1
0
null
2020-06-24T19:20:27
2020-04-08T16:57:20
C++
UTF-8
C++
false
false
562
h
#ifndef _JUGADOR_H_ #define _JUGADOR_H_ #include "Entidad.h" #include <string> class Jugador : public Entidad{ private: int vidas; int puntaje; std::string nombre; public: Jugador(); Jugador(Texture& t, Animacion* animacion, std::string nombre, float x, float y, float dx, float dy); ~Jugador(); int getVidas(); int getPuntaje(); std::string getNombre(); void setVidas(int); void setPuntaje(int); void setNombre(std::string); void dibujar(sf::RenderWindow &w); void mover(Direccion dir); void hurt(int damage); bool interactuar(); }; #endif
[ "andreg-16@hotmail.com" ]
andreg-16@hotmail.com
c2ae790deea334a86b0f3716174081126f5e86eb
5a075cc56820038a97d225b9f4a17a003021fa78
/uva/401.cpp
c98a11af403da2606e40aba05f535c64af10888e
[]
no_license
nahid0335/Problem-solving
e5f1fc9d70c10992655c8dceceec6eb89da953c0
89c1e94048b9f8fb7259294b8f5a3176723041e7
refs/heads/master
2020-11-26T07:02:56.944184
2019-12-19T09:33:58
2019-12-19T09:33:58
228,997,106
1
0
null
null
null
null
UTF-8
C++
false
false
1,187
cpp
#include<bits/stdc++.h> using namespace std; int main() { freopen("input.txt","r",stdin); freopen("output.txt","w",stdout); string s,x,y; char m[3000]; int k=1; memset(m,NULL,sizeof(m)); m['A']='A'; m['E']='3'; m['H']='H'; m['I']='I'; m['J']='L'; m['L']='J'; m['M']='M'; m['O']='O'; m['S']='2'; m['T']='T'; m['U']='U'; m['V']='V'; m['W']='W'; m['X']='X'; m['Y']='Y'; m['Z']='5'; m['1']='1'; m['2']='S'; m['3']='E'; m['5']='Z'; m['8']='8'; while(cin>>s) { x=y=""; int l; l=s.size(); for(int i=l-1;i>=0;i--) { x+=s[i]; y+=m[s[i]]; } if (s==x && s==y) { cout<<s<<" -- is a mirrored palindrome."<<endl; } else if(s==x && s!=y) { cout<<s<<" -- is a regular palindrome."<<endl; } else if(s!=x && s==y) { cout<<s<<" -- is a mirrored string."<<endl; } else if(s!=x && s!=y) { cout<<s<<" -- is not a palindrome."<<endl; } cout<<endl; } return 0; }
[ "nahid0335@gmail.com" ]
nahid0335@gmail.com
690401a1f966ec107f72ddded2f261c055754e16
92813adb7d3c96ebf96060fb23bc5f0ceb187d1e
/src/qt/bitcoinaddressvalidator.cpp
f077978ae1188f4c3cd633dd6e971cbfbc7390f5
[ "MIT" ]
permissive
needycoin/needycore
9bbe28cc50a0c7884e466e027eb6a31d74bc936b
05c0ce57f27d66c37696a9c5eb3c067120fd68b8
refs/heads/master
2020-08-27T06:52:45.921084
2020-08-04T21:12:46
2020-08-04T21:12:46
258,763,520
1
1
null
null
null
null
UTF-8
C++
false
false
2,711
cpp
// Copyright (c) 2011-2014 The Bitcoin developers // Copyright (c) 2014-2015 The Dash developers // Copyright (c) 2015-2017 The PIVX developers // Copyright (c) 2018 The Needycoin developers // Distributed under the MIT/X11 software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #include "bitcoinaddressvalidator.h" #include "base58.h" /* Base58 characters are: "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz" This is: - All numbers except for '0' - All upper-case letters except for 'I' and 'O' - All lower-case letters except for 'l' */ BitcoinAddressEntryValidator::BitcoinAddressEntryValidator(QObject* parent) : QValidator(parent) { } QValidator::State BitcoinAddressEntryValidator::validate(QString& input, int& pos) const { Q_UNUSED(pos); // Empty address is "intermediate" input if (input.isEmpty()) return QValidator::Intermediate; // Correction for (int idx = 0; idx < input.size();) { bool removeChar = false; QChar ch = input.at(idx); // Corrections made are very conservative on purpose, to avoid // users unexpectedly getting away with typos that would normally // be detected, and thus sending to the wrong address. switch (ch.unicode()) { // Qt categorizes these as "Other_Format" not "Separator_Space" case 0x200B: // ZERO WIDTH SPACE case 0xFEFF: // ZERO WIDTH NO-BREAK SPACE removeChar = true; break; default: break; } // Remove whitespace if (ch.isSpace()) removeChar = true; // To next character if (removeChar) input.remove(idx, 1); else ++idx; } // Validation QValidator::State state = QValidator::Acceptable; for (int idx = 0; idx < input.size(); ++idx) { int ch = input.at(idx).unicode(); if (((ch >= '0' && ch <= '9') || (ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z')) && ch != 'l' && ch != 'I' && ch != '0' && ch != 'O') { // Alphanumeric and not a 'forbidden' character } else { state = QValidator::Invalid; } } return state; } BitcoinAddressCheckValidator::BitcoinAddressCheckValidator(QObject* parent) : QValidator(parent) { } QValidator::State BitcoinAddressCheckValidator::validate(QString& input, int& pos) const { Q_UNUSED(pos); // Validate the passed Needycoin address CBitcoinAddress addr(input.toStdString()); if (addr.IsValid()) return QValidator::Acceptable; return QValidator::Invalid; }
[ "you@example.com" ]
you@example.com
eb61fb621cac61358a38b74a2c3f9c0a0310c984
8cc6d6f590285ef00e0f30e0151c4d407847b651
/build_test/windows-build/Sources/include/armory/trait/ConvexBreaker.h
73c71d61ec87e6029362ef7272ccfffd60f96263
[]
no_license
piboistudios/ArmoryDeformIssues
e087d5097af74f958fd89dd8dd17ca57627bf6d1
84e8b14c5098a4a4db310c5177c5dcd46f40212d
refs/heads/master
2020-03-24T11:42:11.270376
2018-07-28T16:33:45
2018-07-28T16:33:45
142,692,926
0
0
null
null
null
null
UTF-8
C++
false
true
4,230
h
// Generated by Haxe 3.4.4 (git build master @ 99b08bb) #ifndef INCLUDED_armory_trait_ConvexBreaker #define INCLUDED_armory_trait_ConvexBreaker #ifndef HXCPP_H #include <hxcpp.h> #endif HX_DECLARE_CLASS2(armory,trait,ConvexBreaker) HX_DECLARE_CLASS2(armory,trait,CutResult) HX_DECLARE_CLASS2(armory,trait,Line3) HX_DECLARE_CLASS2(armory,trait,Plane) HX_DECLARE_CLASS1(haxe,IMap) HX_DECLARE_CLASS2(haxe,ds,ObjectMap) HX_DECLARE_CLASS2(iron,data,Data) HX_DECLARE_CLASS2(iron,data,MeshData) HX_DECLARE_CLASS2(iron,math,Mat4) HX_DECLARE_CLASS2(iron,math,Vec4) HX_DECLARE_CLASS2(iron,object,MeshObject) HX_DECLARE_CLASS2(iron,object,Object) namespace armory{ namespace trait{ class HXCPP_CLASS_ATTRIBUTES ConvexBreaker_obj : public hx::Object { public: typedef hx::Object super; typedef ConvexBreaker_obj OBJ_; ConvexBreaker_obj(); public: enum { _hx_ClassId = 0x45a066b1 }; void __construct(hx::Null< Float > __o_minSizeForBreak,hx::Null< Float > __o_smallDelta); inline void *operator new(size_t inSize, bool inContainer=true,const char *inName="armory.trait.ConvexBreaker") { return hx::Object::operator new(inSize,inContainer,inName); } inline void *operator new(size_t inSize, int extra) { return hx::Object::operator new(inSize+extra,true,"armory.trait.ConvexBreaker"); } static hx::ObjectPtr< ConvexBreaker_obj > __new(hx::Null< Float > __o_minSizeForBreak,hx::Null< Float > __o_smallDelta); static hx::ObjectPtr< ConvexBreaker_obj > __alloc(hx::Ctx *_hx_ctx,hx::Null< Float > __o_minSizeForBreak,hx::Null< Float > __o_smallDelta); static void * _hx_vtable; static Dynamic __CreateEmpty(); static Dynamic __Create(hx::DynamicArray inArgs); //~ConvexBreaker_obj(); HX_DO_RTTI_ALL; hx::Val __Field(const ::String &inString, hx::PropertyAccess inCallProp); static bool __GetStatic(const ::String &inString, Dynamic &outValue, hx::PropertyAccess inCallProp); hx::Val __SetField(const ::String &inString,const hx::Val &inValue, hx::PropertyAccess inCallProp); static bool __SetStatic(const ::String &inString, Dynamic &ioValue, hx::PropertyAccess inCallProp); void __GetFields(Array< ::String> &outFields); static void __register(); void __Mark(HX_MARK_PARAMS); void __Visit(HX_VISIT_PARAMS); bool _hx_isInstanceOf(int inClassId); ::String __ToString() const { return HX_HCSTRING("ConvexBreaker","\x25","\x36","\x4a","\x83"); } static void __boot(); static int meshIndex; Float minSizeForBreak; Float smallDelta; ::armory::trait::Line3 tempLine; ::armory::trait::Plane tempPlane; ::armory::trait::Plane tempPlane2; ::iron::math::Vec4 tempCM1; ::iron::math::Vec4 tempCM2; ::iron::math::Vec4 tempVec4; ::iron::math::Vec4 tempVec42; ::iron::math::Vec4 tempVec43; ::armory::trait::CutResult tempCutResult; ::Array< bool > segments; ::haxe::ds::ObjectMap userDataMap; void initBreakableObject( ::iron::object::MeshObject object,Float mass, ::iron::math::Vec4 velocity, ::iron::math::Vec4 angularVelocity,bool breakable); ::Dynamic initBreakableObject_dyn(); ::Array< ::Dynamic> subdivideByImpact( ::iron::object::MeshObject object, ::iron::math::Vec4 pointOfImpact, ::iron::math::Vec4 normal,int maxRadialIterations,int maxRandomIterations); ::Dynamic subdivideByImpact_dyn(); ::iron::math::Vec4 transformFreeVector( ::iron::math::Vec4 v, ::iron::math::Mat4 m); ::Dynamic transformFreeVector_dyn(); ::iron::math::Vec4 transformFreeVectorInverse( ::iron::math::Vec4 v, ::iron::math::Mat4 m); ::Dynamic transformFreeVectorInverse_dyn(); ::iron::math::Vec4 transformTiedVectorInverse( ::iron::math::Vec4 v, ::iron::math::Mat4 m); ::Dynamic transformTiedVectorInverse_dyn(); void transformPlaneToLocalSpace( ::armory::trait::Plane plane, ::iron::math::Mat4 m, ::armory::trait::Plane resultPlane); ::Dynamic transformPlaneToLocalSpace_dyn(); int cutByPlane( ::iron::object::MeshObject object, ::armory::trait::Plane plane, ::armory::trait::CutResult output); ::Dynamic cutByPlane_dyn(); ::iron::data::MeshData makeMeshData(::Array< ::Dynamic> points); ::Dynamic makeMeshData_dyn(); }; } // end namespace armory } // end namespace trait #endif /* INCLUDED_armory_trait_ConvexBreaker */
[ "gabriel.speed.bullock@gmail.com" ]
gabriel.speed.bullock@gmail.com
f1d55defd6b2afd7ac4fafaf7985dd34be2f1b5a
0b66a94448cb545504692eafa3a32f435cdf92fa
/tags/0.8/cbear.berlios.de/windows/int_ptr.hpp
99b3b1f1769f9193b4ef825c7c4951f66e9407bd
[ "MIT" ]
permissive
BackupTheBerlios/cbear-svn
e6629dfa5175776fbc41510e2f46ff4ff4280f08
0109296039b505d71dc215a0b256f73b1a60b3af
refs/heads/master
2021-03-12T22:51:43.491728
2007-09-28T01:13:48
2007-09-28T01:13:48
40,608,034
0
0
null
null
null
null
UTF-8
C++
false
false
386
hpp
#ifndef CBEAR_BERLIOS_DE_WINDOWS_INT_PTR_HPP_INCLUDED #define CBEAR_BERLIOS_DE_WINDOWS_INT_PTR_HPP_INCLUDED #include <cbear.berlios.de/windows/basetsd.h> namespace cbear_berlios_de { namespace windows { // Signed integral type for pointer precision. Use when casting a pointer to an // integer to perform pointer arithmetic. typedef INT_PTR int_ptr_t; } } #endif
[ "sergey_shandar@e6e9985e-9100-0410-869a-e199dc1b6838" ]
sergey_shandar@e6e9985e-9100-0410-869a-e199dc1b6838
51876bbffd356a65aa2b76d8d2a7ccc766ba8731
92f1c33f2909f3f39ab7eecddeb879518c2e534e
/wezel.cpp
c29e8cda2c57e092106fa96a72dc286158cda739
[]
no_license
kiug/lsp
c0b35b1000237d9a6ce66ec2081c6cdf045a670d
74af2c6ec6ba402ed00d54f25db8d13cf2de7c39
refs/heads/master
2016-09-06T05:45:53.101103
2015-08-14T07:46:18
2015-08-14T07:46:18
40,702,191
0
1
null
null
null
null
UTF-8
C++
false
false
100
cpp
#include "wezel.h" #include "widok.h" #include <QDebug> Wezel::Wezel() { } Wezel::~Wezel() { }
[ "karoldro@gmail.com" ]
karoldro@gmail.com
91277c1e737f3712a0cdbc42e45b9e68dd508132
353526f7d936010872ffd88830be36faedcbb4ca
/test.cpp
b7949e6077d859d29b934d2bf1d2a8fce7a1ebf0
[]
no_license
Huang9495/A-Simple-and-efficient-Video-parser
8c7702cbb87c2c53ae828a7cd52a2c4291888177
86a1d5c34bb0944960c8c35173323a8630fc6df7
refs/heads/master
2021-04-15T18:57:10.484367
2018-04-28T08:12:29
2018-04-28T08:12:29
126,679,142
0
1
null
null
null
null
UTF-8
C++
false
false
800
cpp
#include "stdafx.h" #include <opencv2/highgui/highgui.hpp> #include <iostream> #include <stdio.h> #include <opencv/cv.h> using namespace cv; int main(int argc, char *argv[]) { CvCapture* capture = cvCaptureFromAVI("video_route"); int i = 0; IplImage* img = 0; char image_name[25]; cvNamedWindow( "vivi"); //读取和显示 while(1) { img = cvQueryFrame(capture); //获取一帧图片 if(img == NULL) break; cvShowImage( "vivi", img ); //将其显示 //char key = cvWaitKey(20); cvWaitKey(20); //eidt string sprintf(image_name, "%s%d%s", "image_route", ++i, ".jpg");//保存的图片名 cvSaveImage( image_name, img); //保存一帧图片 //cvSaveImage(address, img ,0); } cvReleaseCapture(&capture); //显示窗口的名称 cvDestroyWindow("vivi"); return 0; }
[ "noreply@github.com" ]
Huang9495.noreply@github.com
fdc13350162fb71760ddf8cc8c93a7229a6832e9
bb24e332a82af41807c9b67c85d5d15336dc0470
/src/Rifle.hpp
b4c97c6a5547aa414456be813fda6fd5782cd1f5
[ "MIT" ]
permissive
Muikkunen/Lieburo
04fa604ac9585539ba0b9566e9ab971a99f64650
48216f2cbf8c8d96687581f595c2822136b614b4
refs/heads/master
2021-01-13T16:20:45.473695
2017-01-23T19:53:43
2017-01-23T19:53:43
79,841,610
0
0
null
2017-01-23T19:51:34
2017-01-23T19:51:34
null
UTF-8
C++
false
false
199
hpp
#pragma once #include "Weapon.hpp" #include "Game.hpp" class Rifle : public Weapon { public: Rifle(Game* game); virtual void shoot(float angle, b2Vec2 position, b2Vec2 preSpeed, Game* game); };
[ "alvar.martti@gmail.com" ]
alvar.martti@gmail.com
7aa1b63810ed03544e193bb26f6b4f5a2eb1c7bb
d1c1eea01b817e6bc39bd7fbcf74188f3dd8d622
/A - HTML /main.cpp
042d7314b98f9dddff01d68c2942c93081980e61
[]
no_license
kamol7/Online-Judge-Problems-solved
93d488341a2b0299fdd638b1615d1fee8de82e31
3d135f288b2001a8372fa3df101284a6cc8a3ff0
refs/heads/master
2020-07-30T19:29:23.900029
2019-09-23T11:00:10
2019-09-23T11:00:10
210,332,744
0
0
null
null
null
null
UTF-8
C++
false
false
1,236
cpp
#include <iostream> #include <string> using namespace std; int main() { //std::cout << "Hello, World!" << std::endl; std::string x=""; for(int i=0;i<80;i++) x+="-"; int line=0; int size=0; string takeInput; while(cin>>takeInput){ if(takeInput== "<br>"){ cout<<endl; line=0; } else if( takeInput== "<hr>"){ if(line==0) { cout<<x<<endl; } else { cout<<"\n"<<x<<endl; } line=0; } else { size= takeInput.size(); if(size==80){ if(line ==0)cout<<takeInput<<endl; else { line=0; cout<<"\n"<<takeInput<<endl; } } else if(line+size<80){ if(line==0){ cout<<takeInput; line--; } else cout<<" "<<takeInput; line+=size+1; } else{ cout<<"\n"<<takeInput; line=size; } } takeInput.clear(); } if(line>0) cout<<endl; return 0; }
[ "ckamol7@gmail.com" ]
ckamol7@gmail.com
6d079461e1fa6dab33301bd518685ad4eb612bec
2e41d302378e32ed9cf9e3c61c0d228c4a89373c
/Seminarski/main.cpp
8fefe9cb9d50333b8c6bbc59a735a6c339cb30f2
[]
no_license
SKantar/Reversi
44534082170b5100a3ece3920785c4fc13d830a1
569d05357df1f874b96056c1f70976f241f108a9
refs/heads/master
2020-04-29T13:47:20.454480
2016-10-26T10:53:30
2016-10-26T10:53:30
30,535,276
0
1
null
null
null
null
UTF-8
C++
false
false
3,593
cpp
#define WINVER 0x500 #include <windows.h> #include <iostream> #include "Application.h" #include "Dragndrop.h" #include "Board.h" #include "Reversi.h" #include <vector> //#include "MS_IKSOKS.h" using namespace std; int WINAPI WinMain (HINSTANCE hThisInstance, HINSTANCE hPrevInstance, LPSTR lpszArgument, int nCmdShow) { application.initialize(hThisInstance, hPrevInstance, lpszArgument, nCmdShow); application.setTitle("Reversi"); application.setBackgroundColor(RGB(20,100,50)); application.setDimensions(770,800); /* vector <ReversiFigura> f; for(int i = 0; i < MAXN; i++) for(int j = 0; j < MAXM; j++) if(i == 3 && j == 4) f.push_back(new ReversiFigura(1,i,j)); else if(i == 4 && j == 3) f.push_back(new ReversiFigura(1,i,j)); else if(i == 3 && j == 3) f.push_back(new ReversiFigura(2,i,j)); else if(i == 4 && j == 4) f.push_back(new ReversiFigura(2,i,j)); else f.push_back(new ReversiFigura(0,i,j));*/ Reversi reversi; ReversiFigura f1(0, 0, 0); ReversiFigura f2(0, 0, 1); ReversiFigura f3(0, 0, 2); ReversiFigura f4(0, 0, 3); ReversiFigura f5(0, 0, 4); ReversiFigura f6(0, 0, 5); ReversiFigura f7(0, 0, 6); ReversiFigura f8(0, 0, 7); ReversiFigura f9(0, 1, 0); ReversiFigura f10(0, 1, 1); ReversiFigura f11(0, 1, 2); ReversiFigura f12(0, 1, 3); ReversiFigura f13(0, 1, 4); ReversiFigura f14(0, 1, 5); ReversiFigura f15(0, 1, 6); ReversiFigura f16(0, 1, 7); ReversiFigura f17(0, 2, 0); ReversiFigura f18(0, 2, 1); ReversiFigura f19(0, 2, 2); ReversiFigura f20(0, 2, 3); ReversiFigura f21(0, 2, 4); ReversiFigura f22(0, 2, 5); ReversiFigura f23(0, 2, 6); ReversiFigura f24(0, 2, 7); ReversiFigura f25(0, 3, 0); ReversiFigura f26(0, 3, 1); ReversiFigura f27(0, 3, 2); ReversiFigura f28(1, 3, 3); ReversiFigura f29(2, 3, 4); ReversiFigura f30(0, 3, 5); ReversiFigura f31(0, 3, 6); ReversiFigura f32(0, 3, 7); ReversiFigura f33(0, 4, 0); ReversiFigura f34(0, 4, 1); ReversiFigura f35(0, 4, 2); ReversiFigura f36(2, 4, 3); ReversiFigura f37(1, 4, 4); ReversiFigura f38(0, 4, 5); ReversiFigura f39(0, 4, 6); ReversiFigura f40(0, 4, 7); ReversiFigura f41(0, 5, 0); ReversiFigura f42(0, 5, 1); ReversiFigura f43(0, 5, 2); ReversiFigura f44(0, 5, 3); ReversiFigura f45(0, 5, 4); ReversiFigura f46(0, 5, 5); ReversiFigura f47(0, 5, 6); ReversiFigura f48(0, 5, 7); ReversiFigura f49(0, 6, 0); ReversiFigura f50(0, 6, 1); ReversiFigura f51(0, 6, 2); ReversiFigura f52(0, 6, 3); ReversiFigura f53(0, 6, 4); ReversiFigura f54(0, 6, 5); ReversiFigura f55(0, 6, 6); ReversiFigura f56(0, 6, 7); ReversiFigura f57(0, 7, 0); ReversiFigura f58(0, 7, 1); ReversiFigura f59(0, 7, 2); ReversiFigura f60(0, 7, 3); ReversiFigura f61(0, 7, 4); ReversiFigura f62(0, 7, 5); ReversiFigura f63(0, 7, 6); ReversiFigura f64(0, 7, 7); //ReversiFigura c1(1, -1, 0); //ReversiFigura c2(2, 8, 0); /* IksOksFigura f1(false, 100,100); IksOksFigura f12(true, 100,100); IksOksFigura f13(false, 100,100); IksOksFigura f4(true, 100,100); IksOksFigura f2(false, 100,100); IksOksFigura f3(true, 100,100); IksOksFigura f5(false, 100,100); IksOksFigura f6(true, 100,100); IksOksFigura f7(false, 100,100); */ application.run(); return 0; }
[ "skantar12@gmail.com" ]
skantar12@gmail.com
ba331fa56a80ffb26c85720f47afc19a4b2b2380
d83cfab7bea45f6f553cf7ab87e3b7d9ac9c8721
/src/ui/Tools/ToolsPanelHandler.cpp
b49c36926a598a30950391aeab7a3398af76bb22
[]
no_license
edherbert/Rockpool
f40b0e1ea9c39fdd0c957597af61d62c80c75405
47ce54779c4690e73aaf4cd67d5e9061bc41f1df
refs/heads/master
2021-08-14T14:03:34.749396
2017-11-15T23:33:12
2017-11-15T23:33:12
107,127,160
0
0
null
null
null
null
UTF-8
C++
false
false
2,743
cpp
#include "ToolsPanelHandler.h" #include "../wxIDs.h" #include "ToolPreferencesHandler.h" ToolsPanelHandler::ToolsPanelHandler(MainFrame *mainFrame, wxAuiManager *auiManager) : wxApp(){ this->auiManager = auiManager; this->mainFrame = mainFrame; wxBitmap bitmap(wxT("../media/img/icon.png")); toolbar = new wxAuiToolBar(mainFrame, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxAUI_TB_DEFAULT_STYLE); toolbar->SetToolBitmapSize(wxSize(20, 23)); toolbar->AddTool(TOOL_PANEL_TERRAIN_EDIT, bitmap, bitmap, true); toolbar->AddTool(TOOL_PANEL_TERRAIN_TEXTURE, bitmap, bitmap, true); toolbar->AddTool(TOOL_PANEL_TERRAIN_HEIGHT, bitmap, bitmap, true); toolbar->AddTool(TOOL_PANEL_TERRAIN_SMOOTH, bitmap, bitmap, true); tools[0] = TOOL_PANEL_TERRAIN_EDIT; tools[1] = TOOL_PANEL_TERRAIN_TEXTURE; tools[2] = TOOL_PANEL_TERRAIN_HEIGHT; tools[3] = TOOL_PANEL_TERRAIN_SMOOTH; auiManager->AddPane(toolbar, wxAuiPaneInfo().Name(wxT("Terrains Toolbar")).Caption(wxT("Terrains Toolbar")).ToolbarPane().Top()); toolbar->Realize(); Connect(TOOL_PANEL_TERRAIN_EDIT, wxEVT_TOOL, wxCommandEventHandler(ToolsPanelHandler::terrainEditToolCallback)); Connect(TOOL_PANEL_TERRAIN_TEXTURE, wxEVT_TOOL, wxCommandEventHandler(ToolsPanelHandler::terrainTextureToolCallback)); Connect(TOOL_PANEL_TERRAIN_HEIGHT, wxEVT_TOOL, wxCommandEventHandler(ToolsPanelHandler::terrainHeightToolCallback)); Connect(TOOL_PANEL_TERRAIN_SMOOTH, wxEVT_TOOL, wxCommandEventHandler(ToolsPanelHandler::terrainSmoothToolCallback)); //setTool(TOOL_PANEL_TERRAIN_EDIT); setTool(TOOL_PANEL_TERRAIN_TEXTURE); setToolPanelVisibility(false); } ToolsPanelHandler::~ToolsPanelHandler(){ } void ToolsPanelHandler::setTool(int toolId){ for(int i = 0; i < sizeof(tools) / sizeof(int); i++){ toolbar->ToggleTool(tools[i], false); } currentTool = toolId; toolbar->ToggleTool(toolId, true); mainFrame->getToolPreferencesHandler()->setToolPreference(toolId); } void ToolsPanelHandler::terrainEditToolCallback(wxCommandEvent &event){ setTool(TOOL_PANEL_TERRAIN_EDIT); } void ToolsPanelHandler::terrainTextureToolCallback(wxCommandEvent &event){ setTool(TOOL_PANEL_TERRAIN_TEXTURE); } void ToolsPanelHandler::terrainHeightToolCallback(wxCommandEvent &event){ setTool(TOOL_PANEL_TERRAIN_HEIGHT); } void ToolsPanelHandler::terrainSmoothToolCallback(wxCommandEvent &event){ setTool(TOOL_PANEL_TERRAIN_SMOOTH); } int ToolsPanelHandler::getCurrentTool(){ return currentTool; } void ToolsPanelHandler::setToolPanelVisibility(bool val){ if(val) toolbar->Show(); else toolbar->Hide(); mainFrame->showTerrainToolbar->Check(val); auiManager->Update(); }
[ "edwardherbert802@yahoo.com" ]
edwardherbert802@yahoo.com
0f682df95b7ce1b3b66fd627035b60a9878c40c1
ecfb2256ddb3febd10f8b732c25eaf07b0de52fb
/54_Movement_detection_Optical_Flow/main.cpp
2cd662a602e3578a955e75de0ca4b66310d1a690
[]
no_license
inovision/visioncomputador
65900fab1647012e3af82ea96bea99f65475ea96
ca90cfc6d00375608af474183af7be905c6c437c
refs/heads/master
2021-04-03T09:29:14.794279
2018-04-11T19:08:23
2018-04-11T19:08:23
124,695,174
0
0
null
null
null
null
UTF-8
C++
false
false
2,860
cpp
#include <iostream> #include <opencv/cv.hpp> using namespace std; using namespace cv; #define MAX_CORNERS 500 #define ESCAPE 27 int main() { //Mat frame, back, fore, dest; VideoCapture capture("c://edx//IcabMovimientoEscenaEstatica.mp4"); //Ptr<BackgroundSubtractorMOG2> bg = createBackgroundSubtractorMOG2(500, 16, true); //VideoCapture capture; // Objects Mat frame; // keyboard pressed char keypressed = 0; bool success; // Load image from disk //capture.open(0); // if not success, exit program // if (!capture.isOpened()){ // cout << "error in VideoCapture: check path file" << endl; // getchar(); // return 1; // } /// Parameters for Shi-Tomasi algorithm vector<Point2f> cornersA, cornersB; double qualityLevel = 0.01; double minDistance = 10; int blockSize = 3; bool useHarrisDetector = false; double k = 0.04; int maxCorners = MAX_CORNERS; // winsize has to be 11 or 13, otherwise nothing is found vector<uchar> status; vector<float> error; int winsize = 11; int maxlvl = 5; // Objects Mat img_prev, img_next, grayA, grayB; success = capture.read(frame); // if no success exit program if (success == false){ cout << "Cannot read the frame from file" << endl; getchar(); return 1; } img_prev = frame.clone(); // Windows for all the images namedWindow("Corners A", CV_WINDOW_AUTOSIZE); namedWindow("Corners B", CV_WINDOW_AUTOSIZE); while (keypressed != ESCAPE) { // read frame by frame in a loop success = capture.read(frame); // if no success exit program if (success == false){ cout << "Cannot read the frame from file" << endl; return 1; } img_next = frame.clone(); // convert to grayScale cvtColor(img_prev, grayA, CV_RGB2GRAY); cvtColor(img_next, grayB, CV_RGB2GRAY); /// Apply corner detection goodFeaturesToTrack(grayA, cornersA, maxCorners, qualityLevel, minDistance, Mat(), blockSize, useHarrisDetector, k); calcOpticalFlowPyrLK(grayA, grayB, cornersA, cornersB, status, error, Size(winsize, winsize), maxlvl); /// Draw corners detected //cout << "Number of cornersA detected: " << cornersA.size() << endl; //cout << "Optical Flow corners detected: " << cornersB.size() << endl; for (uint i = 0; i < cornersA.size(); i++) { line(img_prev, cornersA[i], cornersB[i], Scalar(0, 255, 0), 2); } // Show image in the name of the window imshow("Corners A", img_prev); imshow("Corners B", img_next); // Function for show the image in ms. keypressed = waitKey(1); img_prev = img_next; } // Free memory img_prev.release(); img_next.release(); grayA.release(); grayB.release(); destroyAllWindows(); // End of the program return 0; }
[ "pablo.an@gmail.com" ]
pablo.an@gmail.com
11405f404ae3eb7503bfc75212ef27d2fa6dad10
5c0f282a4e3e8fec68b20317c9a07247bd8b4616
/src/core/hw/gfxip/computeCmdBuffer.cpp
2c74c651be85c9286dbc85ce0cc3860f1f54d347
[ "MIT" ]
permissive
PetarKirov/pal
b3baabdccb5df38e711fa3641d450e9c34f877ea
d535f5dc4179fc14249a5eb41e59aa96a5cd318f
refs/heads/master
2021-08-31T19:50:18.201096
2017-12-21T13:40:00
2017-12-22T08:06:20
null
0
0
null
null
null
null
UTF-8
C++
false
false
9,802
cpp
/* ******************************************************************************* * * Copyright (c) 2015-2017 Advanced Micro Devices, Inc. All rights reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. ******************************************************************************/ #include "core/cmdAllocator.h" #include "core/device.h" #include "core/hw/gfxip/computeCmdBuffer.h" #include "core/hw/gfxip/gfxDevice.h" #include "core/hw/gfxip/pipeline.h" #include "palShader.h" #include <limits.h> using namespace Util; namespace Pal { // ===================================================================================================================== // Dummy function for catching illegal attempts to set graphics user-data entries on a Compute command buffer. static void PAL_STDCALL DummyCmdSetUserDataGfx( ICmdBuffer* pCmdBuffer, uint32 firstEntry, uint32 entryCount, const uint32* pEntryValues) { PAL_ASSERT_ALWAYS(); } // ===================================================================================================================== ComputeCmdBuffer::ComputeCmdBuffer( const GfxDevice& device, const CmdBufferCreateInfo& createInfo, PrefetchMgr* pPrefetchMgr, GfxCmdStream* pCmdStream) : GfxCmdBuffer(device, createInfo, pPrefetchMgr, pCmdStream), m_device(device), m_pCmdStream(pCmdStream) { PAL_ASSERT(createInfo.queueType == QueueTypeCompute); memset(&m_computeState, 0, sizeof(m_computeState)); memset(&m_computeRestoreState, 0, sizeof(m_computeRestoreState)); SwitchCmdSetUserDataFunc(PipelineBindPoint::Compute, &GfxCmdBuffer::CmdSetUserDataCs); SwitchCmdSetUserDataFunc(PipelineBindPoint::Graphics, &DummyCmdSetUserDataGfx); } // ===================================================================================================================== // Resets the command buffer's previous contents and state, then puts it into a building state allowing new commands // to be recorded. // Also starts command buffer dumping, if it is enabled. Result ComputeCmdBuffer::Begin( const CmdBufferBuildInfo& info) { const Result result = GfxCmdBuffer::Begin(info); #if PAL_ENABLE_PRINTS_ASSERTS if ((result == Result::Success) && (IsDumpingEnabled())) { char filename[MaxFilenameLength] = {}; // filename is: computexx_yyyyy, where "xx" is the number of compute command buffers that have been created so // far (one based) and "yyyyy" is the number of times this command buffer has been begun (also // one based). // // All streams associated with this command buffer are included in this one file. Snprintf(filename, MaxFilenameLength, "compute%02d_%05d", UniqueId(), NumBegun()); OpenCmdBufDumpFile(&filename[0]); } #endif return result; } // ===================================================================================================================== // Puts the command stream into a state that is ready for command building. Result ComputeCmdBuffer::BeginCommandStreams( CmdStreamBeginFlags cmdStreamFlags, bool doReset) { Result result = GfxCmdBuffer::BeginCommandStreams(cmdStreamFlags, doReset); if (doReset) { m_pCmdStream->Reset(nullptr, true); } if (result == Result::Success) { result = m_pCmdStream->Begin(cmdStreamFlags, m_pMemAllocator); } return result; } // ===================================================================================================================== // Completes recording of a command buffer in the building state, making it executable. // Also ends command buffer dumping, if it is enabled. Result ComputeCmdBuffer::End() { Result result = GfxCmdBuffer::End(); if (result == Result::Success) { result = m_pCmdStream->End(); } if (result == Result::Success) { #if PAL_ENABLE_PRINTS_ASSERTS if (IsDumpingEnabled() && DumpFile()->IsOpen()) { if (m_device.Parent()->Settings().submitTimeCmdBufDumpMode == CmdBufDumpModeBinaryHeaders) { const CmdBufferDumpFileHeader fileHeader = { static_cast<uint32>(sizeof(CmdBufferDumpFileHeader)), // Structure size 1, // Header version m_device.Parent()->ChipProperties().familyId, // ASIC family m_device.Parent()->ChipProperties().deviceId, // Reserved, but use for PCI device ID 0 // Reserved }; DumpFile()->Write(&fileHeader, sizeof(fileHeader)); CmdBufferListHeader listHeader = { static_cast<uint32>(sizeof(CmdBufferListHeader)), // Structure size 0, // Engine index 0 // Number of command buffer chunks }; listHeader.count = m_pCmdStream->GetNumChunks(); DumpFile()->Write(&listHeader, sizeof(listHeader)); } DumpCmdStreamsToFile(DumpFile(), m_device.Parent()->Settings().submitTimeCmdBufDumpMode); DumpFile()->Close(); } #endif } return result; } // ===================================================================================================================== // Explicitly resets a command buffer, releasing any internal resources associated with it and putting it in the reset // state. Result ComputeCmdBuffer::Reset( ICmdAllocator* pCmdAllocator, bool returnGpuMemory) { Result result = GfxCmdBuffer::Reset(pCmdAllocator, returnGpuMemory); m_pCmdStream->Reset(static_cast<CmdAllocator*>(pCmdAllocator), returnGpuMemory); return result; } // ===================================================================================================================== // Resets all of the command buffer state tracked. After a reset there should be no state bound. void ComputeCmdBuffer::ResetState() { GfxCmdBuffer::ResetState(); memset(&m_computeState, 0, sizeof(m_computeState)); memset(&m_computeRestoreState, 0, sizeof(m_computeRestoreState)); } // ===================================================================================================================== void ComputeCmdBuffer::CmdBindPipeline( const PipelineBindParams& params) { PAL_ASSERT(params.pipelineBindPoint == PipelineBindPoint::Compute); m_computeState.pipelineState.pPipeline = static_cast<const Pipeline*>(params.pPipeline); m_computeState.pipelineState.dirtyFlags.pipelineDirty = 1; m_computeState.dynamicCsInfo = params.cs; } #if PAL_ENABLE_PRINTS_ASSERTS // ===================================================================================================================== // Dumps this command buffer's single command stream to the given file with an appropriate header. void ComputeCmdBuffer::DumpCmdStreamsToFile( File* pFile, CmdBufDumpMode mode ) const { m_pCmdStream->DumpCommands(pFile, "# Compute Queue - Command length = ", mode); } #endif // ===================================================================================================================== CmdStream* ComputeCmdBuffer::GetCmdStreamByEngine( uint32 engineType) { return TestAnyFlagSet(m_engineSupport, engineType) ? m_pCmdStream : nullptr; } // ===================================================================================================================== // Helper method for handling the state "leakage" from a nested command buffer back to its caller. Since the callee has // tracked its own state during the building phase, we can access the final state of the command buffer since its stored // in the ComputeCmdBuffer object itself. void ComputeCmdBuffer::LeakNestedCmdBufferState( const ComputeCmdBuffer& cmdBuffer) // [in] Nested command buffer whose state we're absorbing. { LeakPerPipelineStateChanges(cmdBuffer.m_computeState.pipelineState, cmdBuffer.m_computeState.csUserDataEntries, &m_computeState.pipelineState, &m_computeState.csUserDataEntries); // NOTE: Compute command buffers shouldn't have changed either of their CmdSetUserData callbacks. PAL_ASSERT(memcmp(&m_funcTable, &cmdBuffer.m_funcTable, sizeof(m_funcTable)) == 0); } } // Pal
[ "jacob.he@amd.com" ]
jacob.he@amd.com
a9b4ec4bbf73a176419d703c5139049d8639eb85
f83ef53177180ebfeb5a3e230aa29794f52ce1fc
/ACE/ACE_wrappers/TAO/orbsvcs/orbsvcs/Notify/MonitorControlExt/MonitorEventChannelFactory.h
311fb73d097ce5f23e9517a77da624429f126cde
[ "Apache-2.0", "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-proprietary-license", "LicenseRef-scancode-sun-iiop" ]
permissive
msrLi/portingSources
fe7528b3fd08eed4a1b41383c88ee5c09c2294ef
57d561730ab27804a3172b33807f2bffbc9e52ae
refs/heads/master
2021-07-08T01:22:29.604203
2019-07-10T13:07:06
2019-07-10T13:07:06
196,183,165
2
1
Apache-2.0
2020-10-13T14:30:53
2019-07-10T10:16:46
null
UTF-8
C++
false
false
3,006
h
#ifndef MONITOREVENTCHANNELFACTORY_H #define MONITOREVENTCHANNELFACTORY_H #include /**/ "ace/pre.h" #include "ace/Hash_Map_Manager_T.h" #if !defined (ACE_LACKS_PRAGMA_ONCE) # pragma once #endif /* ACE_LACKS_PRAGMA_ONCE */ #include "ace/Vector_T.h" #include "ace/Monitor_Base.h" #include "orbsvcs/Notify/EventChannelFactory.h" #include "orbsvcs/Notify/MonitorControl/Timestamp_Monitor.h" #include "orbsvcs/Notify/MonitorControlExt/NotifyMonitoringExtS.h" #if defined (TAO_HAS_MONITOR_FRAMEWORK) && (TAO_HAS_MONITOR_FRAMEWORK == 1) using namespace ACE_VERSIONED_NAMESPACE_NAME::ACE::Monitor_Control; TAO_BEGIN_VERSIONED_NAMESPACE_DECL class TAO_Notify_MC_Ext_Export TAO_MonitorEventChannelFactory : public TAO_Notify_EventChannelFactory, public virtual POA_NotifyMonitoringExt::EventChannelFactory { public: /// Construct a named event channel factory and associate various /// statistic objects with it in the statistic registry TAO_MonitorEventChannelFactory (const char* name); /// Remove the factory name from the factory names statistic ~TAO_MonitorEventChannelFactory (void); /// Create a named event channel and associate various statistic /// objects with it in the statistic registry virtual CosNotifyChannelAdmin::EventChannel_ptr create_named_channel(const CosNotification::QoSProperties& initial_qos, const CosNotification::AdminProperties& initial_admin, CosNotifyChannelAdmin::ChannelID_out id, const char* name); /// Create an event channel and use the id as the name. virtual CosNotifyChannelAdmin::EventChannel_ptr create_channel(const CosNotification::QoSProperties& initial_qos, const CosNotification::AdminProperties& initial_admin, CosNotifyChannelAdmin::ChannelID_out id); /// Hook into the remove() call from the base class and remove it from /// our map before passing control back to the base. virtual void remove (TAO_Notify_EventChannel* channel); // This is public to allow the Unbinder class access // for SunCC 5.5 and above typedef ACE_Hash_Map_Manager<ACE_CString, CosNotifyChannelAdmin::ChannelID, ACE_SYNCH_NULL_MUTEX> Map; private: size_t get_consumers (CosNotifyChannelAdmin::ChannelID id); size_t get_suppliers (CosNotifyChannelAdmin::ChannelID id); size_t get_ecs (Monitor_Control_Types::NameList* names, bool active); friend class EventChannels; class Unbinder { public: Unbinder (Map& map, const ACE_CString& name); ~Unbinder (void); void release (void); private: Map& map_; const ACE_CString& name_; bool released_; }; TAO_SYNCH_RW_MUTEX mutex_; ACE_CString name_; Map map_; ACE_Vector<ACE_CString> stat_names_; }; TAO_END_VERSIONED_NAMESPACE_DECL #endif /* TAO_HAS_MONITOR_FRAMEWORK==1 */ #include /**/ "ace/post.h" #endif /* MONITOREVENTCHANNELFACTORY_H */
[ "lihuibin705@163.com" ]
lihuibin705@163.com
e1a35958aaa0c76e7b8551d3790c5e6e4ea54796
0a6e2a8fc086e80ef3d2b38e6773b7d2c29d1e95
/TextEditor.cpp
9ecada127ba5f95b7372be3380711141e82eb859
[]
no_license
Sholes/SimpleTextEditor
0455cec4a4a34a33dc79254f48dcaa0b0b255d12
f9cdcf4e97322f7869293576787b8067c88f6320
refs/heads/master
2021-01-19T01:02:53.014959
2016-06-24T03:29:09
2016-06-24T03:29:09
61,854,227
1
0
null
null
null
null
UTF-8
C++
false
false
2,842
cpp
/* you must implement a simple text editor. Initially, your editor contains an empty string, . You must perform operations of the following types: append - Append string to the end of . delete - Delete the last characters of . print - Print the character of . undo - Undo the last (not previously undone) operation of type or , reverting to the state it was in prior to that operation. Input Format The first line contains an integer, , denoting the number of operations. Each line of the subsequent lines (where ) defines an operation to be performed. Each operation starts with a single integer, (where ), denoting a type of operation as defined in the Problem Statement above. If the operation requires an argument, is followed by its space-separated argument. For example, if and , line will be 1 abcd. All input characters are lowercase English letters. It is guaranteed that the sequence of operations given as input is possible to perform. Output Format Each operation of type must print the character on a new line. */ #include <cmath> #include <cstdio> #include <vector> #include <iostream> #include <algorithm> #include<string> #define INT_MAX 2147483647 using namespace std; int main() { /* Enter your code here. Read input from STDIN. Print output to STDOUT */ int testcases; string app; string stack=""; string prevstate; int count=0; cin>>testcases; int c,len1,del; for(int i=0;i<testcases;i++) { cin>>c; if(c==1) { cin>>app; prevstate=stack; stack.append(app); /*cout<<append<<endl; len1=append.length(); for(int j=count;j<(count+len1);j++) { stack[j]=append[j]; count=count+len1; }*/ cout<<"now "<<stack<<endl; } else if(c==2) { cin>>del; int len=stack.length(); prevstate=stack; //for(int i=(stack.length()-1);del>0;i--) stack.erase((len-del),del); cout<<"erase "<<stack<<endl; } else if(c==3) { int display; cin>>display; cout<<"dis..."<<stack[display-1]<<endl; } else if(c==4) { cout<<prevstate; stack=prevstate; cout<<"after undo..."<<stack<<endl; } } return 0; }
[ "noreply@github.com" ]
Sholes.noreply@github.com
80188c5482e70772353aef60522185e8e7172247
6365e88f444f10075cf92a5bb2c9494c29391cde
/text_stat.cpp
fda1b436371f670a19449d1b2b01e944b5521367
[]
no_license
Cserki/BevprogII
e940e75365ad72adb74f34fb9b39335501e40945
133dd8eaa011b6ba18781bced023191b6eb9a448
refs/heads/master
2020-05-25T10:55:09.103884
2019-05-21T05:46:37
2019-05-21T05:46:37
187,768,883
0
0
null
null
null
null
UTF-8
C++
false
false
699
cpp
#include "text_stat.hpp" #include "graphics.hpp" #include <iostream> #include <vector> using namespace genv; text_stat::text_stat(int x, int y, int sx, int sy,std::vector<std::string> vec) : widget(x,y,sx,sy,vec){ _focus=false; stat_str=options[0]; } void text_stat::draw(){ gout << color(180,180,180) << move_to(_x,_y) << box(_size_x,_size_y); gout << color(0,0,0) << move_to(_x+2,_y+2) << box(_size_x-4,_size_y-4); gout << color(255,255,255) << move_to(_x+5,_y+_size_y/2) << text(stat_str); } void text_stat::handle(event ev){} bool text_stat::in_focus(){ return _focus; } std::string text_stat::return_choosen(){ return choosen; }
[ "noreply@github.com" ]
Cserki.noreply@github.com
62b734f3c927f8e3de3278a08cecb15f58383353
110e9389c53f8a86f231d9947694caa75f2b7beb
/include/rl_string_view.h
3361407765f9d10bc9f334b723a223c16b90db0a
[ "MIT" ]
permissive
slahabar/reinforcement_learning
687d80750f9f697337914e4f9dab3ff61fe44ee5
54f003dc0757ad8fca97cf2fca03fffeb4a558b2
refs/heads/master
2023-02-07T23:48:41.092052
2023-01-10T20:51:09
2023-01-10T20:51:09
232,201,786
0
0
MIT
2020-01-06T23:10:53
2020-01-06T23:10:52
null
UTF-8
C++
false
false
125
h
#pragma once #include "nonstd/string_view.h" namespace reinforcement_learning { using string_view = nonstd::string_view; }
[ "noreply@github.com" ]
slahabar.noreply@github.com
ce29b5a15442c851cf288b440d6a24847878a041
54b9e1d9945cbcd39aa0fbc955d81e402042a471
/src/components/IF/httpd_protocol.h
662569501ca7e7b5a2b56240a19f4b02f8993c74
[]
no_license
huangdeng525/dcop
17364e209cac590a7f2c2f7ba57a4526d38cf670
e7f254d2a4c99743b32d436d974ef5cef3a1caaf
refs/heads/master
2021-06-18T18:47:42.665179
2020-12-30T09:23:12
2020-12-30T09:23:12
144,436,513
1
0
null
2018-08-12T04:03:47
2018-08-12T04:03:46
null
GB18030
C++
false
false
3,360
h
/// ------------------------------------------------- /// httpd_protocol.h : 超文本协议私有头文件 /// ------------------------------------------------- /// Copyright (c) 2015, Wang Yujia <combo.xy@163.com> /// All rights reserved. /// ------------------------------------------------- #ifndef _HTTPD_PROTOCOL_H_ #define _HTTPD_PROTOCOL_H_ #include "BaseClass.h" #include "httpd_handle.h" #include "stream/dstream.h" /// ------------------------------------------------- /// 超文本请求对象接口类 /// ------------------------------------------------- INTF_VER(IHttpRequest, 1, 0, 0); interface IHttpRequest : public Instance { /// 输入请求 virtual void Input(IHttpHandle *http, const char *req) = 0; }; /// ------------------------------------------------- /// 超文本响应对象接口类 /// ------------------------------------------------- INTF_VER(IHttpResponse, 1, 0, 0); interface IHttpResponse : public Instance { /// 输出响应 virtual void Output(IHttpHandle *http, CDStream &rsp, DWORD *pdwHeadSize = 0) = 0; }; /// ------------------------------------------------- /// 超文本请求对象实现类 /// ------------------------------------------------- class CHttpRequest : public IHttpRequest { public: /// 命令组成定义 enum HEAD_LINE { HEAD_LINE_METHOD = 0, HEAD_LINE_URI, HEAD_LINE_PROTOCOL, }; /// 请求方法(文本) static const char *Method[]; /// 协议版本(文本) static const char *Protocol[]; public: static void StrDecode(char *str); static int hexit(char c); public: CHttpRequest(Instance *piParent, int argc, char **argv); ~CHttpRequest(); DCOP_DECLARE_INSTANCE; void Input(IHttpHandle *http, const char *req); private: void Analyze(IHttpHandle *http, const char *req); DWORD GetHeadLine(IHttpHandle *http, const char *head); DWORD GetMethod(const char *head, IHttpHandle::METHOD &method); DWORD GetProtocol(const char *head, IHttpHandle::PROTOCOL &protocol); void GetHeadItem(IHttpHandle *http, CDString *head); }; /// ------------------------------------------------- /// 超文本响应对象实现类 /// ------------------------------------------------- class CHttpResponse : public IHttpResponse { public: /// 协议版本(服务器支持的最高版本) static const char *Protocol; /// 状态码(文本) static const char *Status[]; /// 服务器信息 static const char *Server; /// HTTP已经规定了使用RFC1123时间格式 static const char *RFC1123FMT; /// MIME(文本) static const char *MIME[]; /// 内容压缩(文本) static const char *Compress[]; public: static const char *GetStatus(IHttpHandle *http); static const char *GetContentType(IHttpHandle *http); static const char *GetContentType(const char *name); public: CHttpResponse(Instance *piParent, int argc, char **argv); ~CHttpResponse(); DCOP_DECLARE_INSTANCE; void Output(IHttpHandle *http, CDStream &rsp, DWORD *pdwHeadSize); private: void GetHeadItem(IHttpHandle *http, CDStream &rsp); bool IsCompressSupport(IHttpHandle *http, IHttpHandle::COMPRESS compress); void DeflateContent(IHttpHandle *http); void GzipContent(IHttpHandle *http); }; #endif // #ifndef _HTTPD_PROTOCOL_H_
[ "combo.xy@163.com" ]
combo.xy@163.com
353e6e8b67cd99fa2b157b838f789f2e2f6a973e
a1faa72eea32203df772b03d1940129a9fdfd0e5
/tutorial-3/include/glhelper.h
dbb4daa863bcec5c4722eb1653c2c459a1c26e74
[]
no_license
ChuaSTGrace/CSD2100_OpenGL-Dev
e47d6fd0922d6cbba10b4d9c7628ae55e6d22ac4
b7b40b4ea88b4d9637c5a2b035417dacd0930d2f
refs/heads/master
2023-07-22T12:01:36.893814
2021-09-10T02:13:07
2021-09-10T02:13:07
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,988
h
/* ! @file glhelper.h @author pghali@digipen.edu @date 10/11/2016 This file contains the declaration of namespace Helper that encapsulates the functionality required to create an OpenGL context using GLFW; use GLEW to load OpenGL extensions; initialize OpenGL state; and finally initialize the OpenGL application by calling initalization functions associated with objects participating in the application. *//*__________________________________________________________________________*/ /* guard ----------------------------------------------------------------------------- */ #ifndef GLHELPER_H #define GLHELPER_H /* includes ----------------------------------------------------------------------------- */ #include <GL/glew.h> // for access to OpenGL API declarations #include <GLFW/glfw3.h> #include <string> /* _________________________________________________________________________ */ struct GLHelper /*! GLHelper structure to encapsulate initialization stuff ... */ { static bool init(GLint w, GLint h, std::string t); static void cleanup(); // callbacks ... static void error_cb(int error, char const* description); static void fbsize_cb(GLFWwindow *ptr_win, int width, int height); // I/O callbacks ... static void key_cb(GLFWwindow *pwin, int key, int scancode, int action, int mod); static void mousebutton_cb(GLFWwindow *pwin, int button, int action, int mod); static void mousescroll_cb(GLFWwindow *pwin, double xoffset, double yoffset); static void mousepos_cb(GLFWwindow *pwin, double xpos, double ypos); static double update_time(double fpsCalcInt = 1.0); static GLboolean mouseLeft; static GLboolean keystateP; static GLint width, height; static GLdouble fps; static std::string title; static GLFWwindow *ptr_window; static void print_specs (); }; #endif /* GLHELPER_H */
[ "jeejiamin@gmail.com" ]
jeejiamin@gmail.com
b43b0272a94ccaf3416bd8adf0169fe84c1094dd
83dd4a88a518784300b340b221427f26b05edc5d
/Techgig/Code Gladiator 2019/Stage 1/Solution_2_new.cpp
914822e23d3c7c8f6b3635d6ba46482f5ddf13cf
[]
no_license
abhishek09091/competitive-programming
0671ca18e9ea90b31f7c10c5339bdb5a47f9f307
56f40c4ea60a5f599e6bd562d400e77a91cb5d02
refs/heads/master
2020-05-03T13:12:40.693399
2020-01-14T20:28:59
2020-01-14T20:28:59
178,647,746
0
2
null
null
null
null
UTF-8
C++
false
false
2,125
cpp
/** Input : 5 5 -1 7 8 -5 4 4 3 2 1 -1 4 11 12 -2 -1 4 4 5 4 3 4 5 10 4 -1 Output: 48 13 12 44 10 **/ #include<bits/stdc++.h> using namespace std; bool** dp; vector<vector<int>> display(const vector<int>& v, vector<vector<int>> result) { vector<int> temp; for (int i = 0; i < v.size(); ++i) { cout<<v[i]; temp.push_back(v[i]); } result.push_back(temp); cout<<endl; return result; } vector<vector<int>> printSubsetsRec(int arr[], int i, int sum, vector<int>& p, vector<vector<int>> result) { if (i == 0 && sum != 0 && dp[0][sum]) { p.push_back(arr[i]); result = display(p,result); return result; } if (i == 0 && sum == 0) { result = display(p,result); return result; } if (dp[i-1][sum]){ vector<int> b = p; printSubsetsRec(arr, i-1, sum, b,result); } if (sum >= arr[i] && dp[i-1][sum-arr[i]]) { p.push_back(arr[i]); printSubsetsRec(arr, i-1, sum-arr[i], p,result); } } vector<vector<int>> printAllSubsets(int arr[], int n, int sum) { vector<vector<int>> result; if (n == 0 || sum < 0) return result; dp = new bool*[n]; for (int i=0; i<n; ++i) { dp[i] = new bool[sum + 1]; dp[i][0] = true; } if (arr[0] <= sum) dp[0][arr[0]] = true; for (int i = 1; i < n; ++i) for (int j = 0; j < sum + 1; ++j) dp[i][j] = (arr[i] <= j) ? dp[i-1][j] || dp[i-1][j-arr[i]] : dp[i - 1][j]; if (dp[n-1][sum] == false) { printf("There are no subsets with sum %d\n", sum); return result; } vector<int> p; result = printSubsetsRec(arr, n-1, sum, p,result); return result; } int findMaxSum(int arr[], int n) { int in = arr[0]; int ex = 0; int exNew; int i; for (i = 1; i < n; i++) { exNew = (in > ex)? in: ex; in = ex + arr[i]; ex = exNew; } return ((in > ex)? in : ex); } int main(){ int t; cin>>t; while(t--){ int n; cin>>n; int arr[n]; for(int i=0; i<n; i++){ cin>>arr[i]; } int result = findMaxSum(arr,n); vector<vector<int>> result_vector = printAllSubsets(arr,n,result); } return 0; }
[ "abhishek.09091@gmail.com" ]
abhishek.09091@gmail.com
843ab3ccdbf662827d3f5c88dc1c2f3a24a15459
2f4cee019d13607191758faedddc8b88130be52d
/Paradis_Hydrogen/ParadisJHU06012020/ParadisJHU06012020/ezmath/Face.h
2f8746b11aea1dfa26a130b7aec8857ba2ae251e
[]
no_license
JinnyJingLuo/Expanse
ee0ed9f448fb230a09af049ac673c26d3397a76a
207059c02868a6e1881a6748396e248e16d2e995
refs/heads/master
2023-05-06T13:17:38.859013
2021-05-26T07:11:04
2021-05-26T07:11:04
370,536,257
0
0
null
null
null
null
UTF-8
C++
false
false
460
h
#ifndef FACE_H_ #define FACE_H_ #include "GeometricComponent.h" #include "Point.h" #include "string" using namespace EZ; using namespace std; namespace GeometrySystem { class Face : public GeometricComponent { public: Face(); Face(const Face& oFace); virtual ~Face(); Face& operator=(const Face& oFace); void Reset(); virtual bool IsVisibleFromPoint(const Point& oPoint) const = 0; private: protected: void Initialize(); }; } #endif
[ "jluo32@login02.expanse.sdsc.edu" ]
jluo32@login02.expanse.sdsc.edu
1be81eac83eb2e87991954b55ecda2d121ba12dd
c5e8b8d8bc38d6f1df7668ac185795d99a4ae31a
/emJetAnalysis/src/EjCalculateAN.cxx
4dc4edf2c0d834719d21e1745db761faaf714569
[]
no_license
xilinliang/STAR-1
3bc7ddffa9a9a05f108a4dd66e32a1a417cd9e54
32e74b318e64ef9e5cc5cda410b20425031dbf6a
refs/heads/master
2023-07-26T21:28:00.157084
2021-01-24T04:35:25
2021-01-24T04:35:25
315,710,751
0
0
null
null
null
null
UTF-8
C++
false
false
13,942
cxx
// Filename: EjCalculateAN.cxx // Description: // Author: Latif Kabir < kabir@bnl.gov > // Created: Fri May 8 15:08:25 2020 (-0400) // URL: jlab.org/~latif #include <iostream> #include "RootInclude.h" #include "cppInclude.h" #include "BrightStInclude.h" #include "Hists.h" using namespace std; void EjCalculateAN(TString inFileName, TString outName, TString det) { /* We need to bin in: energy (5), number of photons (6), phi (16), spin (2), pt(6). Let's create TH2D histograms of array size [2(spin)][4(energy)][#photon(5)]. The 2D histogram to be filled with phi bins along x and pt bins along y. We need another similar array for yellow beam as well. */ TString inFile = inFileName; if(gSystem->AccessPathName(inFile)) { cout << "Input file not found: "<< inFile <<endl; return; } TFile *file = new TFile(inFile); const Int_t kSpinBins = 2; const Int_t kEnergyBins = 5; const Int_t kPhotonBins = 6; TH2D *bHist[kSpinBins][kEnergyBins][kPhotonBins]; // [spin][energy bin][#photons] TH2D *yHist[kSpinBins][kEnergyBins][kPhotonBins]; // [spin][energy bin][#photons] Double_t ptBins[] = {2.0, 2.5, 3.0, 3.5, 4.0, 4.5, 5.0, 6.0, 8.0, 10.0}; //For info only Double_t engBins[] = {0.0, 20.0, 40.0, 60.0, 80.0, 100.0}; //For info only Double_t photonBins[] = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0};// Last bin contains 6 or more photons //Int_t nPtBins = sizeof(ptBins) / sizeof(Double_t) - 1; for(Int_t i = 0; i < kSpinBins; ++i) { for(Int_t j = 0; j < kEnergyBins; ++j) { for(Int_t k = 0; k < kPhotonBins; ++k) { TString bTitle = Form("bHist_%i_%i_%i", i, j, k); TString yTitle = Form("yHist_%i_%i_%i", i, j, k); bHist[i][j][k] = (TH2D*)file->Get(bTitle); yHist[i][j][k] = (TH2D*)file->Get(yTitle); } } } const Int_t nHalfPhiBins = bHist[0][0][0]->GetNbinsX() / 2; //Phi bins per hemisphere const Int_t nPtBins = bHist[0][0][0]->GetNbinsY(); //Note: left-right is with respect to the beam (here blue beam) Int_t phiBins_left[] = {9, 10, 11, 12, 13, 14, 15, 16}; //<----------- Update here if nPhiBins changes Int_t phiBins_right[] = {1, 2, 3, 4, 5, 6, 7, 8}; //<----------- Update here if nPhiBins changes Double_t phiValues[nHalfPhiBins]; Double_t bAnRaw[kEnergyBins][kPhotonBins][nHalfPhiBins][nPtBins]; Double_t bAnRawError[kEnergyBins][kPhotonBins][nHalfPhiBins][nPtBins]; Double_t bAn[kEnergyBins][kPhotonBins][nPtBins]; Double_t bAnError[kEnergyBins][kPhotonBins][nPtBins]; memset(bAn, 0, sizeof(bAn)); memset(bAnError, 0, sizeof(bAnError)); Double_t yAnRaw[kEnergyBins][kPhotonBins][nHalfPhiBins][nPtBins]; Double_t yAnRawError[kEnergyBins][kPhotonBins][nHalfPhiBins][nPtBins]; Double_t yAn[kEnergyBins][kPhotonBins][nPtBins]; // A_N with polarization correction Double_t yAnError[kEnergyBins][kPhotonBins][nPtBins]; // A_N error with polarization correction memset(yAn, 0, sizeof(yAn)); memset(yAnError, 0, sizeof(yAnError)); Double_t bNu_l; Double_t bNu_r; Double_t bNd_l; Double_t bNd_r; Double_t yNu_l; Double_t yNu_r; Double_t yNd_l; Double_t yNd_r; Double_t numer; Double_t denom; Double_t numerErrSq; Double_t denomErrSq; for(Int_t i = 0; i < kEnergyBins; ++i) { for(Int_t j = 0; j < kPhotonBins; ++j) { for(Int_t k = 0; k < nHalfPhiBins; ++k) { for(Int_t l = 0; l < nPtBins; ++l) { if(i == 0 && j == 0 && l == 0) phiValues[k] = bHist[0][i][j]->GetXaxis()->GetBinCenter(phiBins_left[k]); bNd_l = bHist[0][i][j]->GetBinContent(phiBins_left[k], l + 1); bNu_l = bHist[1][i][j]->GetBinContent(phiBins_left[k], l + 1); bNd_r = bHist[0][i][j]->GetBinContent((phiBins_right[k]), l + 1); bNu_r = bHist[1][i][j]->GetBinContent((phiBins_right[k]), l + 1); yNd_l = yHist[0][i][j]->GetBinContent(phiBins_left[k], l + 1); yNu_l = yHist[1][i][j]->GetBinContent(phiBins_left[k], l + 1); yNd_r = yHist[0][i][j]->GetBinContent((phiBins_right[k]), l + 1); yNu_r = yHist[1][i][j]->GetBinContent((phiBins_right[k]), l + 1); //You need to ensure that the Left-Right pairing is done exactly as in the formula //----- Blue beam measured asymmetry ------------ numer = sqrt(bNu_l*bNd_r) - sqrt(bNd_l*bNu_r); denom = sqrt(bNu_l*bNd_r) + sqrt(bNd_l*bNu_r); numerErrSq = (bNd_l + bNu_r + bNu_l + bNd_r) / 4.0; denomErrSq = (bNd_l + bNu_r + bNu_l + bNd_r) / 4.0; if(denom == 0) { bAnRaw[i][j][k][l] = -999; bAnRawError[i][j][k][l] = -999; } else { bAnRaw[i][j][k][l] = numer / denom; bAnRawError[i][j][k][l] = fabs( bAnRaw[i][j][k][l]) * sqrt( numerErrSq / pow(numer, 2) + denomErrSq / pow(denom, 2)); //See error propagation in the analysis note } //cout << "Raw Asym:"<< bAnRaw[i][j][k][l] << " +- "<< bAnRawError[i][j][k][l] <<endl; //----- Yellow beam measured asymmetry ------------ numer = sqrt(yNu_l*yNd_r) - sqrt(yNd_l*yNu_r); denom = sqrt(yNu_l*yNd_r) + sqrt(yNd_l*yNu_r); numerErrSq = (yNd_l + yNu_r + yNu_l + yNd_r) / 4.0; denomErrSq = (yNd_l + yNu_r + yNu_l + yNd_r) / 4.0; if(denom == 0) { yAnRaw[i][j][k][l] = -999; yAnRawError[i][j][k][l] = -999; } else { yAnRaw[i][j][k][l] = numer / denom; yAnRawError[i][j][k][l] = fabs(yAnRaw[i][j][k][l]) * sqrt( numerErrSq / pow(numer, 2) + denomErrSq / pow(denom, 2)); //See error propagation in the analysis note } } } } } gROOT->SetBatch(kTRUE); TFile *outFile = new TFile(outName, "recreate"); TGraphErrors *bGr[kEnergyBins][kPhotonBins][nPtBins]; TGraphErrors *yGr[kEnergyBins][kPhotonBins][nPtBins]; TF1 *bFitFnc[kEnergyBins][kPhotonBins][nPtBins]; TF1 *yFitFnc[kEnergyBins][kPhotonBins][nPtBins]; TGraphErrors *bGrPhy[kEnergyBins][kPhotonBins]; TGraphErrors *yGrPhy[kEnergyBins][kPhotonBins]; Int_t nPointsB; Int_t nPointsY; Int_t nPointsPhyB; Int_t nPointsPhyY; Double_t polB = 0.5365 ; // RMS: 0.0403 in fraction Double_t polY = 0.5614; // RMS: 0.0380 if(det == "fms") { polB = 0.5365; // RMS: 0.0403 in fraction polY = 0.5614; // RMS: 0.0380 } else if(det == "eemc") { polB = 0.5365; // RMS: 0.0403 in fraction polY = 0.5614; // RMS: 0.0380 } else { cout << "Invalid detector" <<endl; return; } for(Int_t i = 0; i < kEnergyBins; ++i) { for(Int_t j = 0; j < kPhotonBins; ++j) { bGrPhy[i][j] = new TGraphErrors(); yGrPhy[i][j] = new TGraphErrors(); bGrPhy[i][j]->SetName(Form("bEbin%i_PhotonBin%i", i, j)); bGrPhy[i][j]->SetTitle(Form("%.1f GeV < E < %.1f GeV, No. of Photons %i; P_{T} [GeV/c]; A_{N}", engBins[i], engBins[i + 1], j + 1)); yGrPhy[i][j]->SetName(Form("yEbin%i_PhotonBin%i", i, j)); yGrPhy[i][j]->SetTitle(Form(" %.1f GeV < E < %.1f GeV, No. of Photons %i; P_{T} [GeV/c]; A_{N}", engBins[i], engBins[i + 1], j + 1)); bGrPhy[i][j]->SetMarkerColor(kBlack); bGrPhy[i][j]->SetLineColor(kBlack); bGrPhy[i][j]->SetMarkerStyle(kFullCircle); bGrPhy[i][j]->SetMaximum(0.1); bGrPhy[i][j]->SetMinimum(-0.1); yGrPhy[i][j]->SetMaximum(0.1); yGrPhy[i][j]->SetMinimum(-0.1); yGrPhy[i][j]->SetMarkerColor(kRed); yGrPhy[i][j]->SetLineColor(kRed); yGrPhy[i][j]->SetMarkerStyle(kOpenCircle); nPointsPhyB = 0; nPointsPhyY = 0; for(Int_t k = 0; k < nPtBins; ++k) { bGr[i][j][k] = new TGraphErrors(); yGr[i][j][k] = new TGraphErrors(); bGr[i][j][k]->SetName(Form("bEbin%i_PhotonBin%i_PtBin%i", i, j, k)); bGr[i][j][k]->SetTitle(Form("Blue Beam, %.1f GeV < E < %.1f GeV, No. of Photons %i, %.1f GeV/c < Pt < %.1f GeV/c; #phi [rad]; A_{raw}", engBins[i], engBins[i + 1] , j + 1, ptBins[k], ptBins[k + 1])); yGr[i][j][k]->SetName(Form("yEbin%i_PhotonBin%i_PtBin%i", i, j, k)); yGr[i][j][k]->SetTitle(Form("Yellow Beam, %.1f GeV < E < %.1f GeV, No. of Photons %i, %.1f GeV/c < Pt < %.1f GeV/c; #phi [rad]; A_{raw}", engBins[i], engBins[i + 1] , j + 1, ptBins[k], ptBins[k + 1])); bGr[i][j][k]->SetMaximum(0.1); bGr[i][j][k]->SetMinimum(-0.1); yGr[i][j][k]->SetMaximum(0.1); yGr[i][j][k]->SetMinimum(-0.1); bFitFnc[i][j][k] = new TF1(Form("bFitFnc_%i_%i_%i", i, j, k), "[0]*cos(x) + [1]"); yFitFnc[i][j][k] = new TF1(Form("yFitFnc_%i_%i_%i", i, j, k), "[0]*cos(x) + [1]"); nPointsB = 0; nPointsY = 0; for(Int_t l = 0; l < nHalfPhiBins; ++l) { if(bAnRaw[i][j][l][k] != -999) { bGr[i][j][k]->SetPoint(nPointsB, phiValues[l], bAnRaw[i][j][l][k]); bGr[i][j][k]->SetPointError(nPointsB, 0, bAnRawError[i][j][l][k]); ++nPointsB; } if(yAnRaw[i][j][l][k] != -999) { yGr[i][j][k]->SetPoint(nPointsY, phiValues[l], yAnRaw[i][j][l][k]); yGr[i][j][k]->SetPointError(nPointsY, 0, yAnRawError[i][j][l][k]); ++nPointsY; } } bGr[i][j][k]->Fit(Form("bFitFnc_%i_%i_%i", i, j, k)); yGr[i][j][k]->Fit(Form("yFitFnc_%i_%i_%i", i, j, k)); if(bGr[i][j][k]->GetN() >= 0.5*nHalfPhiBins) { bAn[i][j][k] = bFitFnc[i][j][k]->GetParameter(0) / polB; bAnError[i][j][k] = bFitFnc[i][j][k]->GetParError(0) / polB; bGrPhy[i][j]->SetPoint(nPointsPhyB, (ptBins[k] + ptBins[k+1])*0.5 , bAn[i][j][k]); bGrPhy[i][j]->SetPointError(nPointsPhyB, 0, bAnError[i][j][k]); ++nPointsPhyB; } if(yGr[i][j][k]->GetN() >= 0.5*nHalfPhiBins) { yAn[i][j][k] = yFitFnc[i][j][k]->GetParameter(0) / polY; yAnError[i][j][k] = yFitFnc[i][j][k]->GetParError(0) / polY; yGrPhy[i][j]->SetPoint(nPointsPhyY, (ptBins[k] + ptBins[k+1])*0.5 , yAn[i][j][k]); yGrPhy[i][j]->SetPointError(nPointsPhyY, 0, yAnError[i][j][k]); ++nPointsPhyY; } bGr[i][j][k]->Write(); yGr[i][j][k]->Write(); } bGrPhy[i][j]->Write(); yGrPhy[i][j]->Write(); } } //------------------ Plot physics A_N -------------------- Int_t canvasCount = 1; //------------- For FMS -------------------- if(det == "fms") { TCanvas *c1 = new TCanvas("EMjet_A_N_fms", "EM Jet A_{N}"); c1->Divide(kEnergyBins -1, kPhotonBins -1); for(Int_t i = 0; i < kPhotonBins - 1; ++i) { for(Int_t j = 1; j < kEnergyBins; ++j) { c1->cd(canvasCount); bGrPhy[j][i]->Draw("AP"); yGrPhy[j][i]->Draw("P"); TLine* L1Temp = new TLine(1.5, 0, 9.5, 0); L1Temp->Draw("same"); ++canvasCount; } } c1->Write(); //This area is just for plotting final physics result ---------------- //--- For Fms --- //only consider energy ranges 20 -40, 40 - 60, 60 - 80 i.e. bin index 1, 2, 3 and nPhotons = 1 - 5 TCanvas* c2 = new TCanvas("asym_fms","Asymmetries",1000,600); float varMins[5] = { 1.8, 1.8, 1.8, 1.8, 1.8}; float varMaxs[5] = { 8.2, 8.2, 8.2, 8.2, 8.2}; const char* xTitles[3] = { "p_{T} [GeV/c]","p_{T} [GeV/c]","p_{T} [GeV/c]" }; const char* yTitles[5] = { "A_{N}", "A_{N}", "A_{N}", "A_{N}", "A_{N}" }; PanelPlot* asymPlot = new PanelPlot(c2, 3, 5, 2, "asym_fms", xTitles, yTitles); for (int i = 0; i < 5; i++) { for (int j = 0; j < 3; j++) { asymPlot->GetPlot(j,i)->SetXRange( varMins[i], varMaxs[i]); asymPlot->GetPlot(j,i)->SetYRange( -0.05, 0.05); // if(i == 4 && j == 0) // legend causes shift in x axis base for the panel // { // asymPlot->GetPlot(j,i)->Add(bGrPhy[j+1][4 - i], Plot::Point | Plot::Erry, 0, "x_{F} > 0"); // asymPlot->GetPlot(j,i)->Add(yGrPhy[j+1][4 - i], Plot::Point | Plot::Erry, 8, "x_{F} < 0"); // } // else { asymPlot->GetPlot(j,i)->Add(bGrPhy[j+1][4 - i], Plot::Point | Plot::Erry, 0); asymPlot->GetPlot(j,i)->Add(yGrPhy[j+1][4 - i], Plot::Point | Plot::Erry, 8); } if(i == 0 && j == 0) asymPlot->GetPlot(j,i)->AddText(2.5, -0.04, "Preliminary", 0.10); } } asymPlot->Draw(); c2->Write(); } //---------- For EEMC Jet ----------------------- if(det == "eemc") { TCanvas *c3 = new TCanvas("EMjet_A_N_eemc", "EM Jet A_{N}"); canvasCount = 1; c3->Divide(5, 2); for(Int_t i = 0; i < 2; ++i) { for(Int_t j = 0; j < 5; ++j) { c3->cd(canvasCount); bGrPhy[i][j]->Draw("AP"); yGrPhy[i][j]->Draw("P"); TLine* L1Temp = new TLine(2.5, 0, 9.5, 0); L1Temp->Draw("same"); ++canvasCount; } } c3->Write(); //--- For Eemc --- //only consider energy ranges 0 - 20, i.e. bin index 0, 1 and nPhotons = 1 - 5 TCanvas* c4 = new TCanvas("asym_eemc","Asymmetries", 1000, 600); float varMins_e[] = { 1.8, 4.5, 1.8, 1.8, 1.8}; float varMaxs_e[] = { 9.2, 9.2, 9.2, 9.2, 9.2}; const char* xTitles_e[] = { "p_{T} [GeV/c]","p_{T} [GeV/c]"}; const char* yTitles_e[] = { "A_{N}", "A_{N}", "A_{N}", "A_{N}", "A_{N}" }; PanelPlot* asymPlot_e = new PanelPlot(c4, 1, 5, 2, "asym_eemc", xTitles_e, yTitles_e); for(int i = 0; i < 5; i++) { for(int j = 0; j < 1; j++) { asymPlot_e->GetPlot(j,i)->SetXRange( varMins_e[j], varMaxs_e[j]); asymPlot_e->GetPlot(j,i)->SetYRange( -0.005, 0.005); // if(i == 4 && j == 0) // { // asymPlot_e->GetPlot(j,i)->Add(bGrPhy[j][4 - i], Plot::Point | Plot::Erry, 0, "x_{F} > 0"); // asymPlot_e->GetPlot(j,i)->Add(yGrPhy[j][4 - i], Plot::Point | Plot::Erry, 8, "x_{F} < 0"); // } // else { asymPlot_e->GetPlot(j,i)->Add(bGrPhy[j][4 - i], Plot::Point | Plot::Erry, 0); asymPlot_e->GetPlot(j,i)->Add(yGrPhy[j][4 - i], Plot::Point | Plot::Erry, 8); } if(i == 0 && j == 0) asymPlot_e->GetPlot(j,i)->AddText(2.5, -0.004, "Preliminary", 0.10); } } asymPlot_e->Draw(); c4->Write(); } /* Plot the saved fitted graphs as: gStyle->SetOptFit(1) bEbin1_PhotonBin0_PtBin0->Draw("AP*") */ //outFile->Write(); }
[ "siplukabir@gmail.com" ]
siplukabir@gmail.com
75c1ff6268d0b6ba23056d9892718c6d559220b1
a08e005474521e6b10573aed863a3ff8067c9c13
/src/crypto/hmac_sha512.cpp
cbd32f34e6521c5952e9678a3268e9de2bc5cb9e
[ "MIT" ]
permissive
BitcoinClassicDev/BitcoinClassic
c18048431dccd4346865f9c5ee3c079831c8adde
87f76317eb80c25c54e9104c61bdf570fc7721f3
refs/heads/master
2020-09-16T00:57:59.563234
2019-12-02T19:18:14
2019-12-02T19:18:14
223,602,827
1
1
null
null
null
null
UTF-8
C++
false
false
916
cpp
// Copyright (c) 2014-2018 The BitcoinClassic Core developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #include <crypto/hmac_sha512.h> #include <string.h> CHMAC_SHA512::CHMAC_SHA512(const unsigned char* key, size_t keylen) { unsigned char rkey[128]; if (keylen <= 128) { memcpy(rkey, key, keylen); memset(rkey + keylen, 0, 128 - keylen); } else { CSHA512().Write(key, keylen).Finalize(rkey); memset(rkey + 64, 0, 64); } for (int n = 0; n < 128; n++) rkey[n] ^= 0x5c; outer.Write(rkey, 128); for (int n = 0; n < 128; n++) rkey[n] ^= 0x5c ^ 0x36; inner.Write(rkey, 128); } void CHMAC_SHA512::Finalize(unsigned char hash[OUTPUT_SIZE]) { unsigned char temp[64]; inner.Finalize(temp); outer.Write(temp, 64).Finalize(hash); }
[ "root@DESKTOP-325AAR8.localdomain" ]
root@DESKTOP-325AAR8.localdomain
e51ee0314e2f4a8feae0a2d70165a4c8fc737ba6
520b75c144414d2af5a655e592fa65787ee89aaa
/AOJ/Volume20/2035.cpp
d99574137c4413ec5f0c1e6cfa0d94a19ad38a74
[]
no_license
arrows-1011/CPro
4ac069683c672ba685534444412aa2e28026879d
2e1a9242b2433851f495468e455ee854a8c4dac7
refs/heads/master
2020-04-12T09:36:40.846130
2017-06-10T08:02:10
2017-06-10T08:02:10
46,426,455
1
1
null
null
null
null
UTF-8
C++
false
false
950
cpp
#include <iostream> #include <algorithm> using namespace std; #define MAX 2001 int dp[MAX][MAX]; int arr[MAX][MAX]; void init(int N){ for(int i = 0 ; i < N ; i++){ for(int j = 0 ; j < N ; j++){ dp[i][j] = 0; arr[i][j] = MAX; } } } int main(){ string s; while(cin >> s){ string t = s; reverse(t.begin(), t.end()); int len = s.size(); init(len+1); for(int i = 0 ; i < len ; i++){ for(int j = 0 ; j < len ; j++){ if(s[i] == t[j]){ dp[i+1][j+1] = dp[i][j] + 1; arr[i+1][j+1] = 0; }else{ if(dp[i][j+1] < dp[i+1][j]){ dp[i+1][j+1] = dp[i+1][j]; arr[i+1][j+1] = -1; }else{ dp[i+1][j+1] = dp[i][j+1]; arr[i+1][j+1] = 1; } } } } string str; for(int i = len, j = len ; i > 0 && j > 0 ;){ if(!arr[i][j]){ str += s[i-1]; i--, j--; }else if(arr[i][j] == 1){ i--; }else{ j--; } } cout << str << endl; } return 0; }
[ "s1210207@gmail.com" ]
s1210207@gmail.com
af887093fb8388d99e222bfa88e018044abbb866
c424a4fced037afe2d9eb213be9f65f5df30cc8f
/Integral calculus/Cpp/dowhile.cpp
59acaafba9c3bc0b7c4fa2f0f30bc588b68d137b
[]
no_license
carlosal1015/Calculus-One-and-Several-Variables
0fec0402435a1f33d2e350573a463fffa0e17bcb
e2b85587a00fb913c561a9c7d652e817b3c66703
refs/heads/master
2021-01-23T05:04:03.931801
2018-10-29T18:20:50
2018-10-29T18:20:50
86,271,081
1
2
null
null
null
null
UTF-8
C++
false
false
198
cpp
#include<iostream> using namespace std; int main () { int i = 10; do // Ejecuta y luego cumple el código. { cout << i << endl; i++; }while(i <= 5); cin.get(); return 0; }
[ "noreply@github.com" ]
carlosal1015.noreply@github.com
89873794754d2917234829eb370a518aa0a33999
8e151199d01e1918a4bb1ee7bb1509061ccd327b
/Classes/Options.h
b5dfb3ad77e076aa80cc8b2e0a989c3d841cc6e7
[]
no_license
zhaozw/gods-invader
8a7cc9b449ef861dd2f4495f4060ee0f0af90695
089ecbfde7d0fd8aa55f696548a4736eab91b4d8
refs/heads/master
2021-01-21T11:23:59.057483
2013-04-10T09:54:32
2013-04-10T09:54:32
9,603,862
0
1
null
null
null
null
UTF-8
C++
false
false
505
h
#ifndef CONST_OPTIONS_H #define CONST_OPTIONS_H class Entity; class Options { public: static int CENTER_X; static int CENTER_Y; static int SCREEN_WIDTH; static int SCREEN_HEIGHT; static int SCREEN_CENTER_X; static int SCREEN_CENTER_Y; static int CAMERA_WIDTH; static int CAMERA_HEIGHT; static int CAMERA_CENTER_X; static int CAMERA_CENTER_Y; static float MIN_Z; static float MAX_Z; static bool MUSIC_ENABLE; static bool SOUND_ENABLE; static Entity* BASE; }; #endif
[ "igor.mats@yandex.ru" ]
igor.mats@yandex.ru
1fdb796c1990d86930e9e811e1992c8084f6c21f
6446d917ab76942bb20e1465b6a070ee0686a1c2
/chap03/termination.cpp
dc862c0f508dd728e3dd8bdefde0b5ec2d672c6d
[]
no_license
elect000/C-
52dd5aaf549c20e4d4bead74d486c6de8bcddeae
0f6096f79be2be39c91cc38a5cc5687659aab4c6
refs/heads/master
2020-12-30T23:35:06.172463
2017-05-26T10:41:12
2017-05-26T10:41:12
86,602,947
0
0
null
null
null
null
UTF-8
C++
false
false
504
cpp
#include <ctime> #include <iostream> #include <cstdlib> using namespace std; void good_bye () { cout << "プログラムは正常に終了しました。" << '\n'; } void put_time () { time_t current = time(NULL); struct tm* lct = localtime(&current); cout << lct->tm_hour << ":" << lct->tm_min << ":" << lct->tm_sec << '\n'; } int main() { int x; atexit(good_bye); atexit(put_time); cout << "[0]正常終了 [1]異常終了:"; cin >> x; if (x) { abort(); } return 0; }
[ "e.tmailbank@gmail.com" ]
e.tmailbank@gmail.com
c977bd3f66596533ccca364d72843aa96e0a30d9
98e5fd588b356aff074e907c27aede0b609aae85
/programming/codeforce/327/b.cpp
bda3b4e9898ab00d77beaaba8714f61f9401debf
[]
no_license
ayushshukla92/algorithms
060521612773e93bf4804abd5644fc35d4d32eb7
a3d5baa3c71de5fa9a8049d436c802c75ad32cd2
refs/heads/master
2016-08-12T02:01:53.233754
2015-11-04T11:09:00
2015-11-04T11:09:00
45,024,626
0
0
null
null
null
null
UTF-8
C++
false
false
1,747
cpp
#include <iostream> #include <algorithm> #include <string> #include <queue> #include <list> #include <stack> #include <vector> #include <map> #include <unordered_map> #include <set> #include <unordered_set> #include <cstdlib> #include <sstream> #include <cmath> #include <cctype> #include <cstdio> #include <cstring> using namespace std; typedef pair <int, int> PII; typedef vector <int> VI; typedef vector<vector<int> > VVI; typedef vector<vector<char> > VVC; typedef vector <bool> VB; typedef vector < pair<int,int> > VP; typedef vector <double> VD; typedef long long ll; typedef long double ld; // Input macros #define SC(n) scanf(" %c",&n) #define SD(n) scanf("%d",&n) #define SF(n) scanf("%f",&n) #define SLF(n) scanf("%lf",&n) #define ALL(a) a.begin(), a.end() #define IN(a,b) ( (b).find(a) != (b).end()) #define error(x) cerr << #x << " = " << (x) <<endl #define Error(a,b) cerr<<"( "<<#a<<" , "<<#b<<" ) = ( "<<(a)<<" , "<<(b)<<" )\n"; #define PB push_back #define PF push_front #define EL endl #define CO cout #define F first #define S second #define MAX 1000000007 template <typename T> void print(vector<T> &v) { for(T t : v){ cout<<t<<' '; } CO<<EL; } //-----------------------------------------utilities end--------------------------- int main() { int n,m; SD(n); SD(m); string s; cin>>s; unordered_map<char,int> mp; std::vector<char> v(26); for (int i = 0; i < 26; ++i) { char c= 'a'+i; mp[c] = i; v[i] = c; } while(m--){ char x,y; cin>>x>>y; int ix = mp[x]; int iy = mp[y]; swap(v[ix],v[iy]); mp[ x ] = iy; mp[y] = ix; } for (int i = 0; i < s.length(); ++i) { s[i] = v[ s[i]-'a' ]; } cout<<s; return 0; }
[ "ayush.shukla92@gmail.com" ]
ayush.shukla92@gmail.com
72776e52a0da51d9738e057e8e17d489959d37e7
67aceb910483ef1b11f10a377bd7cc6970bd9b4a
/EngineQ/TODO/MathTests/Helpers.hpp
a7436d0d96a61f22ae6ed1bea39b8d9ff41e3118
[]
no_license
Tsuguri/EngineQ
3a408e790a766eb1689a9c0545ddd725f0442ce7
805adfacf54e98fd55e93a3d2adc8ce037f9a21c
refs/heads/master
2020-08-08T00:18:28.580155
2019-10-08T12:25:39
2019-10-08T12:25:39
213,633,437
0
0
null
null
null
null
UTF-8
C++
false
false
841
hpp
#pragma once using namespace EngineQ::Math; namespace Microsoft { namespace VisualStudio { namespace CppUnitTestFramework { template<> inline std::wstring ToString<Quaternion>(const Quaternion& t) { RETURN_WIDE_STRING(t.ToString().c_str()); } template<> inline std::wstring ToString<Matrix3>(const Matrix3& t) { RETURN_WIDE_STRING(t.ToString().c_str()); } template<> inline std::wstring ToString<Matrix4>(const Matrix4& t) { RETURN_WIDE_STRING(t.ToString().c_str()); } template<> inline std::wstring ToString<Vector2>(const Vector2& t) { RETURN_WIDE_STRING(t.ToString().c_str()); } template<> inline std::wstring ToString<Vector3>(const Vector3& t) { RETURN_WIDE_STRING(t.ToString().c_str()); } template<> inline std::wstring ToString<Vector4>(const Vector4& t) { RETURN_WIDE_STRING(t.ToString().c_str()); } } } }
[ "Piotr Pełka" ]
Piotr Pełka
20414b07af67557b11362212239f0871ede679b0
6f2b6e9d77fc4dd5e1dae8ba6e5a66eb7c7ae849
/sstd_boost/sstd/boost/qvm/gen/mat_operations3.hpp
d32dca11ac2e96edddf491d3176e41bca4d2b2a6
[ "BSL-1.0" ]
permissive
KqSMea8/sstd_library
9e4e622e1b01bed5de7322c2682539400d13dd58
0fcb815f50d538517e70a788914da7fbbe786ce1
refs/heads/master
2020-05-03T21:07:01.650034
2019-04-01T00:10:47
2019-04-01T00:10:47
null
0
0
null
null
null
null
UTF-8
C++
false
false
71,477
hpp
//Copyright (c) 2008-2017 Emil Dotchevski and Reverge Studios, Inc. //Distributed under the Boost Software License, Version 1.0. (See accompanying //file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) #ifndef BOOST_QVM_B3A6DB3C87C3E99245ED1C6B747DE #define BOOST_QVM_B3A6DB3C87C3E99245ED1C6B747DE //This file was generated by a program. Do not edit manually. #include <sstd/boost/qvm/assert.hpp> #include <sstd/boost/qvm/deduce_mat.hpp> #include <sstd/boost/qvm/deduce_vec.hpp> #include <sstd/boost/qvm/error.hpp> #include <sstd/boost/qvm/gen/mat_assign3.hpp> #include <sstd/boost/qvm/quat_traits.hpp> #include <sstd/boost/qvm/scalar_traits.hpp> #include <sstd/boost/qvm/throw_exception.hpp> namespace boost { namespace qvm { template <class A,class B> BOOST_QVM_INLINE_OPERATIONS typename lazy_enable_if_c< mat_traits<A>::rows==3 && mat_traits<B>::rows==3 && mat_traits<A>::cols==3 && mat_traits<B>::cols==3, deduce_mat2<A,B,3,3> >::type operator+( A const & a, B const & b ) { typedef typename deduce_mat2<A,B,3,3>::type R; BOOST_QVM_STATIC_ASSERT(mat_traits<R>::rows==3); BOOST_QVM_STATIC_ASSERT(mat_traits<R>::cols==3); R r; mat_traits<R>::template write_element<0,0>(r)=mat_traits<A>::template read_element<0,0>(a)+mat_traits<B>::template read_element<0,0>(b); mat_traits<R>::template write_element<0,1>(r)=mat_traits<A>::template read_element<0,1>(a)+mat_traits<B>::template read_element<0,1>(b); mat_traits<R>::template write_element<0,2>(r)=mat_traits<A>::template read_element<0,2>(a)+mat_traits<B>::template read_element<0,2>(b); mat_traits<R>::template write_element<1,0>(r)=mat_traits<A>::template read_element<1,0>(a)+mat_traits<B>::template read_element<1,0>(b); mat_traits<R>::template write_element<1,1>(r)=mat_traits<A>::template read_element<1,1>(a)+mat_traits<B>::template read_element<1,1>(b); mat_traits<R>::template write_element<1,2>(r)=mat_traits<A>::template read_element<1,2>(a)+mat_traits<B>::template read_element<1,2>(b); mat_traits<R>::template write_element<2,0>(r)=mat_traits<A>::template read_element<2,0>(a)+mat_traits<B>::template read_element<2,0>(b); mat_traits<R>::template write_element<2,1>(r)=mat_traits<A>::template read_element<2,1>(a)+mat_traits<B>::template read_element<2,1>(b); mat_traits<R>::template write_element<2,2>(r)=mat_traits<A>::template read_element<2,2>(a)+mat_traits<B>::template read_element<2,2>(b); return r; } namespace sfinae { using ::boost::qvm::operator+; } namespace qvm_detail { template <int R,int C> struct plus_mm_defined; template <> struct plus_mm_defined<3,3> { static bool const value=true; }; } template <class A,class B> BOOST_QVM_INLINE_OPERATIONS typename lazy_enable_if_c< mat_traits<A>::rows==3 && mat_traits<B>::rows==3 && mat_traits<A>::cols==1 && mat_traits<B>::cols==1, deduce_mat2<A,B,3,1> >::type operator+( A const & a, B const & b ) { typedef typename deduce_mat2<A,B,3,1>::type R; BOOST_QVM_STATIC_ASSERT(mat_traits<R>::rows==3); BOOST_QVM_STATIC_ASSERT(mat_traits<R>::cols==1); R r; mat_traits<R>::template write_element<0,0>(r)=mat_traits<A>::template read_element<0,0>(a)+mat_traits<B>::template read_element<0,0>(b); mat_traits<R>::template write_element<1,0>(r)=mat_traits<A>::template read_element<1,0>(a)+mat_traits<B>::template read_element<1,0>(b); mat_traits<R>::template write_element<2,0>(r)=mat_traits<A>::template read_element<2,0>(a)+mat_traits<B>::template read_element<2,0>(b); return r; } namespace sfinae { using ::boost::qvm::operator+; } namespace qvm_detail { template <int R,int C> struct plus_mm_defined; template <> struct plus_mm_defined<3,1> { static bool const value=true; }; } template <class A,class B> BOOST_QVM_INLINE_OPERATIONS typename lazy_enable_if_c< mat_traits<A>::rows==1 && mat_traits<B>::rows==1 && mat_traits<A>::cols==3 && mat_traits<B>::cols==3, deduce_mat2<A,B,1,3> >::type operator+( A const & a, B const & b ) { typedef typename deduce_mat2<A,B,1,3>::type R; BOOST_QVM_STATIC_ASSERT(mat_traits<R>::rows==1); BOOST_QVM_STATIC_ASSERT(mat_traits<R>::cols==3); R r; mat_traits<R>::template write_element<0,0>(r)=mat_traits<A>::template read_element<0,0>(a)+mat_traits<B>::template read_element<0,0>(b); mat_traits<R>::template write_element<0,1>(r)=mat_traits<A>::template read_element<0,1>(a)+mat_traits<B>::template read_element<0,1>(b); mat_traits<R>::template write_element<0,2>(r)=mat_traits<A>::template read_element<0,2>(a)+mat_traits<B>::template read_element<0,2>(b); return r; } namespace sfinae { using ::boost::qvm::operator+; } namespace qvm_detail { template <int R,int C> struct plus_mm_defined; template <> struct plus_mm_defined<1,3> { static bool const value=true; }; } template <class A,class B> BOOST_QVM_INLINE_OPERATIONS typename lazy_enable_if_c< mat_traits<A>::rows==3 && mat_traits<B>::rows==3 && mat_traits<A>::cols==3 && mat_traits<B>::cols==3, deduce_mat2<A,B,3,3> >::type operator-( A const & a, B const & b ) { typedef typename deduce_mat2<A,B,3,3>::type R; BOOST_QVM_STATIC_ASSERT(mat_traits<R>::rows==3); BOOST_QVM_STATIC_ASSERT(mat_traits<R>::cols==3); R r; mat_traits<R>::template write_element<0,0>(r)=mat_traits<A>::template read_element<0,0>(a)-mat_traits<B>::template read_element<0,0>(b); mat_traits<R>::template write_element<0,1>(r)=mat_traits<A>::template read_element<0,1>(a)-mat_traits<B>::template read_element<0,1>(b); mat_traits<R>::template write_element<0,2>(r)=mat_traits<A>::template read_element<0,2>(a)-mat_traits<B>::template read_element<0,2>(b); mat_traits<R>::template write_element<1,0>(r)=mat_traits<A>::template read_element<1,0>(a)-mat_traits<B>::template read_element<1,0>(b); mat_traits<R>::template write_element<1,1>(r)=mat_traits<A>::template read_element<1,1>(a)-mat_traits<B>::template read_element<1,1>(b); mat_traits<R>::template write_element<1,2>(r)=mat_traits<A>::template read_element<1,2>(a)-mat_traits<B>::template read_element<1,2>(b); mat_traits<R>::template write_element<2,0>(r)=mat_traits<A>::template read_element<2,0>(a)-mat_traits<B>::template read_element<2,0>(b); mat_traits<R>::template write_element<2,1>(r)=mat_traits<A>::template read_element<2,1>(a)-mat_traits<B>::template read_element<2,1>(b); mat_traits<R>::template write_element<2,2>(r)=mat_traits<A>::template read_element<2,2>(a)-mat_traits<B>::template read_element<2,2>(b); return r; } namespace sfinae { using ::boost::qvm::operator-; } namespace qvm_detail { template <int R,int C> struct minus_mm_defined; template <> struct minus_mm_defined<3,3> { static bool const value=true; }; } template <class A,class B> BOOST_QVM_INLINE_OPERATIONS typename lazy_enable_if_c< mat_traits<A>::rows==3 && mat_traits<B>::rows==3 && mat_traits<A>::cols==1 && mat_traits<B>::cols==1, deduce_mat2<A,B,3,1> >::type operator-( A const & a, B const & b ) { typedef typename deduce_mat2<A,B,3,1>::type R; BOOST_QVM_STATIC_ASSERT(mat_traits<R>::rows==3); BOOST_QVM_STATIC_ASSERT(mat_traits<R>::cols==1); R r; mat_traits<R>::template write_element<0,0>(r)=mat_traits<A>::template read_element<0,0>(a)-mat_traits<B>::template read_element<0,0>(b); mat_traits<R>::template write_element<1,0>(r)=mat_traits<A>::template read_element<1,0>(a)-mat_traits<B>::template read_element<1,0>(b); mat_traits<R>::template write_element<2,0>(r)=mat_traits<A>::template read_element<2,0>(a)-mat_traits<B>::template read_element<2,0>(b); return r; } namespace sfinae { using ::boost::qvm::operator-; } namespace qvm_detail { template <int R,int C> struct minus_mm_defined; template <> struct minus_mm_defined<3,1> { static bool const value=true; }; } template <class A,class B> BOOST_QVM_INLINE_OPERATIONS typename lazy_enable_if_c< mat_traits<A>::rows==1 && mat_traits<B>::rows==1 && mat_traits<A>::cols==3 && mat_traits<B>::cols==3, deduce_mat2<A,B,1,3> >::type operator-( A const & a, B const & b ) { typedef typename deduce_mat2<A,B,1,3>::type R; BOOST_QVM_STATIC_ASSERT(mat_traits<R>::rows==1); BOOST_QVM_STATIC_ASSERT(mat_traits<R>::cols==3); R r; mat_traits<R>::template write_element<0,0>(r)=mat_traits<A>::template read_element<0,0>(a)-mat_traits<B>::template read_element<0,0>(b); mat_traits<R>::template write_element<0,1>(r)=mat_traits<A>::template read_element<0,1>(a)-mat_traits<B>::template read_element<0,1>(b); mat_traits<R>::template write_element<0,2>(r)=mat_traits<A>::template read_element<0,2>(a)-mat_traits<B>::template read_element<0,2>(b); return r; } namespace sfinae { using ::boost::qvm::operator-; } namespace qvm_detail { template <int R,int C> struct minus_mm_defined; template <> struct minus_mm_defined<1,3> { static bool const value=true; }; } template <class A,class B> BOOST_QVM_INLINE_OPERATIONS typename enable_if_c< mat_traits<A>::rows==3 && mat_traits<B>::rows==3 && mat_traits<A>::cols==3 && mat_traits<B>::cols==3, A &>::type operator+=( A & a, B const & b ) { mat_traits<A>::template write_element<0,0>(a)+=mat_traits<B>::template read_element<0,0>(b); mat_traits<A>::template write_element<0,1>(a)+=mat_traits<B>::template read_element<0,1>(b); mat_traits<A>::template write_element<0,2>(a)+=mat_traits<B>::template read_element<0,2>(b); mat_traits<A>::template write_element<1,0>(a)+=mat_traits<B>::template read_element<1,0>(b); mat_traits<A>::template write_element<1,1>(a)+=mat_traits<B>::template read_element<1,1>(b); mat_traits<A>::template write_element<1,2>(a)+=mat_traits<B>::template read_element<1,2>(b); mat_traits<A>::template write_element<2,0>(a)+=mat_traits<B>::template read_element<2,0>(b); mat_traits<A>::template write_element<2,1>(a)+=mat_traits<B>::template read_element<2,1>(b); mat_traits<A>::template write_element<2,2>(a)+=mat_traits<B>::template read_element<2,2>(b); return a; } namespace sfinae { using ::boost::qvm::operator+=; } namespace qvm_detail { template <int R,int C> struct plus_eq_mm_defined; template <> struct plus_eq_mm_defined<3,3> { static bool const value=true; }; } template <class A,class B> BOOST_QVM_INLINE_OPERATIONS typename enable_if_c< mat_traits<A>::rows==3 && mat_traits<B>::rows==3 && mat_traits<A>::cols==1 && mat_traits<B>::cols==1, A &>::type operator+=( A & a, B const & b ) { mat_traits<A>::template write_element<0,0>(a)+=mat_traits<B>::template read_element<0,0>(b); mat_traits<A>::template write_element<1,0>(a)+=mat_traits<B>::template read_element<1,0>(b); mat_traits<A>::template write_element<2,0>(a)+=mat_traits<B>::template read_element<2,0>(b); return a; } namespace sfinae { using ::boost::qvm::operator+=; } namespace qvm_detail { template <int R,int C> struct plus_eq_mm_defined; template <> struct plus_eq_mm_defined<3,1> { static bool const value=true; }; } template <class A,class B> BOOST_QVM_INLINE_OPERATIONS typename enable_if_c< mat_traits<A>::rows==1 && mat_traits<B>::rows==1 && mat_traits<A>::cols==3 && mat_traits<B>::cols==3, A &>::type operator+=( A & a, B const & b ) { mat_traits<A>::template write_element<0,0>(a)+=mat_traits<B>::template read_element<0,0>(b); mat_traits<A>::template write_element<0,1>(a)+=mat_traits<B>::template read_element<0,1>(b); mat_traits<A>::template write_element<0,2>(a)+=mat_traits<B>::template read_element<0,2>(b); return a; } namespace sfinae { using ::boost::qvm::operator+=; } namespace qvm_detail { template <int R,int C> struct plus_eq_mm_defined; template <> struct plus_eq_mm_defined<1,3> { static bool const value=true; }; } template <class A,class B> BOOST_QVM_INLINE_OPERATIONS typename enable_if_c< mat_traits<A>::rows==3 && mat_traits<B>::rows==3 && mat_traits<A>::cols==3 && mat_traits<B>::cols==3, A &>::type operator-=( A & a, B const & b ) { mat_traits<A>::template write_element<0,0>(a)-=mat_traits<B>::template read_element<0,0>(b); mat_traits<A>::template write_element<0,1>(a)-=mat_traits<B>::template read_element<0,1>(b); mat_traits<A>::template write_element<0,2>(a)-=mat_traits<B>::template read_element<0,2>(b); mat_traits<A>::template write_element<1,0>(a)-=mat_traits<B>::template read_element<1,0>(b); mat_traits<A>::template write_element<1,1>(a)-=mat_traits<B>::template read_element<1,1>(b); mat_traits<A>::template write_element<1,2>(a)-=mat_traits<B>::template read_element<1,2>(b); mat_traits<A>::template write_element<2,0>(a)-=mat_traits<B>::template read_element<2,0>(b); mat_traits<A>::template write_element<2,1>(a)-=mat_traits<B>::template read_element<2,1>(b); mat_traits<A>::template write_element<2,2>(a)-=mat_traits<B>::template read_element<2,2>(b); return a; } namespace sfinae { using ::boost::qvm::operator-=; } namespace qvm_detail { template <int R,int C> struct minus_eq_mm_defined; template <> struct minus_eq_mm_defined<3,3> { static bool const value=true; }; } template <class A,class B> BOOST_QVM_INLINE_OPERATIONS typename enable_if_c< mat_traits<A>::rows==3 && mat_traits<B>::rows==3 && mat_traits<A>::cols==1 && mat_traits<B>::cols==1, A &>::type operator-=( A & a, B const & b ) { mat_traits<A>::template write_element<0,0>(a)-=mat_traits<B>::template read_element<0,0>(b); mat_traits<A>::template write_element<1,0>(a)-=mat_traits<B>::template read_element<1,0>(b); mat_traits<A>::template write_element<2,0>(a)-=mat_traits<B>::template read_element<2,0>(b); return a; } namespace sfinae { using ::boost::qvm::operator-=; } namespace qvm_detail { template <int R,int C> struct minus_eq_mm_defined; template <> struct minus_eq_mm_defined<3,1> { static bool const value=true; }; } template <class A,class B> BOOST_QVM_INLINE_OPERATIONS typename enable_if_c< mat_traits<A>::rows==1 && mat_traits<B>::rows==1 && mat_traits<A>::cols==3 && mat_traits<B>::cols==3, A &>::type operator-=( A & a, B const & b ) { mat_traits<A>::template write_element<0,0>(a)-=mat_traits<B>::template read_element<0,0>(b); mat_traits<A>::template write_element<0,1>(a)-=mat_traits<B>::template read_element<0,1>(b); mat_traits<A>::template write_element<0,2>(a)-=mat_traits<B>::template read_element<0,2>(b); return a; } namespace sfinae { using ::boost::qvm::operator-=; } namespace qvm_detail { template <int R,int C> struct minus_eq_mm_defined; template <> struct minus_eq_mm_defined<1,3> { static bool const value=true; }; } template <class A,class B> BOOST_QVM_INLINE_OPERATIONS typename lazy_enable_if_c< mat_traits<A>::rows==3 && mat_traits<A>::cols==3 && is_scalar<B>::value, deduce_mat<A> >::type operator*( A const & a, B b ) { typedef typename deduce_mat<A>::type R; R r; mat_traits<R>::template write_element<0,0>(r)=mat_traits<A>::template read_element<0,0>(a)*b; mat_traits<R>::template write_element<0,1>(r)=mat_traits<A>::template read_element<0,1>(a)*b; mat_traits<R>::template write_element<0,2>(r)=mat_traits<A>::template read_element<0,2>(a)*b; mat_traits<R>::template write_element<1,0>(r)=mat_traits<A>::template read_element<1,0>(a)*b; mat_traits<R>::template write_element<1,1>(r)=mat_traits<A>::template read_element<1,1>(a)*b; mat_traits<R>::template write_element<1,2>(r)=mat_traits<A>::template read_element<1,2>(a)*b; mat_traits<R>::template write_element<2,0>(r)=mat_traits<A>::template read_element<2,0>(a)*b; mat_traits<R>::template write_element<2,1>(r)=mat_traits<A>::template read_element<2,1>(a)*b; mat_traits<R>::template write_element<2,2>(r)=mat_traits<A>::template read_element<2,2>(a)*b; return r; } namespace sfinae { using ::boost::qvm::operator*; } namespace qvm_detail { template <int R,int C> struct mul_ms_defined; template <> struct mul_ms_defined<3,3> { static bool const value=true; }; } template <class A,class B> BOOST_QVM_INLINE_OPERATIONS typename lazy_enable_if_c< is_scalar<A>::value && mat_traits<B>::rows==3 && mat_traits<B>::cols==3, deduce_mat<B> >::type operator*( A a, B const & b ) { typedef typename deduce_mat<B>::type R; R r; mat_traits<R>::template write_element<0,0>(r)=a*mat_traits<B>::template read_element<0,0>(b); mat_traits<R>::template write_element<0,1>(r)=a*mat_traits<B>::template read_element<0,1>(b); mat_traits<R>::template write_element<0,2>(r)=a*mat_traits<B>::template read_element<0,2>(b); mat_traits<R>::template write_element<1,0>(r)=a*mat_traits<B>::template read_element<1,0>(b); mat_traits<R>::template write_element<1,1>(r)=a*mat_traits<B>::template read_element<1,1>(b); mat_traits<R>::template write_element<1,2>(r)=a*mat_traits<B>::template read_element<1,2>(b); mat_traits<R>::template write_element<2,0>(r)=a*mat_traits<B>::template read_element<2,0>(b); mat_traits<R>::template write_element<2,1>(r)=a*mat_traits<B>::template read_element<2,1>(b); mat_traits<R>::template write_element<2,2>(r)=a*mat_traits<B>::template read_element<2,2>(b); return r; } namespace sfinae { using ::boost::qvm::operator*; } namespace qvm_detail { template <int R,int C> struct mul_sm_defined; template <> struct mul_sm_defined<3,3> { static bool const value=true; }; } template <class A,class B> BOOST_QVM_INLINE_OPERATIONS typename lazy_enable_if_c< mat_traits<A>::rows==3 && mat_traits<A>::cols==1 && is_scalar<B>::value, deduce_mat<A> >::type operator*( A const & a, B b ) { typedef typename deduce_mat<A>::type R; R r; mat_traits<R>::template write_element<0,0>(r)=mat_traits<A>::template read_element<0,0>(a)*b; mat_traits<R>::template write_element<1,0>(r)=mat_traits<A>::template read_element<1,0>(a)*b; mat_traits<R>::template write_element<2,0>(r)=mat_traits<A>::template read_element<2,0>(a)*b; return r; } namespace sfinae { using ::boost::qvm::operator*; } namespace qvm_detail { template <int R,int C> struct mul_ms_defined; template <> struct mul_ms_defined<3,1> { static bool const value=true; }; } template <class A,class B> BOOST_QVM_INLINE_OPERATIONS typename lazy_enable_if_c< is_scalar<A>::value && mat_traits<B>::rows==3 && mat_traits<B>::cols==1, deduce_mat<B> >::type operator*( A a, B const & b ) { typedef typename deduce_mat<B>::type R; R r; mat_traits<R>::template write_element<0,0>(r)=a*mat_traits<B>::template read_element<0,0>(b); mat_traits<R>::template write_element<1,0>(r)=a*mat_traits<B>::template read_element<1,0>(b); mat_traits<R>::template write_element<2,0>(r)=a*mat_traits<B>::template read_element<2,0>(b); return r; } namespace sfinae { using ::boost::qvm::operator*; } namespace qvm_detail { template <int R,int C> struct mul_sm_defined; template <> struct mul_sm_defined<3,1> { static bool const value=true; }; } template <class A,class B> BOOST_QVM_INLINE_OPERATIONS typename lazy_enable_if_c< mat_traits<A>::rows==1 && mat_traits<A>::cols==3 && is_scalar<B>::value, deduce_mat<A> >::type operator*( A const & a, B b ) { typedef typename deduce_mat<A>::type R; R r; mat_traits<R>::template write_element<0,0>(r)=mat_traits<A>::template read_element<0,0>(a)*b; mat_traits<R>::template write_element<0,1>(r)=mat_traits<A>::template read_element<0,1>(a)*b; mat_traits<R>::template write_element<0,2>(r)=mat_traits<A>::template read_element<0,2>(a)*b; return r; } namespace sfinae { using ::boost::qvm::operator*; } namespace qvm_detail { template <int R,int C> struct mul_ms_defined; template <> struct mul_ms_defined<1,3> { static bool const value=true; }; } template <class A,class B> BOOST_QVM_INLINE_OPERATIONS typename lazy_enable_if_c< is_scalar<A>::value && mat_traits<B>::rows==1 && mat_traits<B>::cols==3, deduce_mat<B> >::type operator*( A a, B const & b ) { typedef typename deduce_mat<B>::type R; R r; mat_traits<R>::template write_element<0,0>(r)=a*mat_traits<B>::template read_element<0,0>(b); mat_traits<R>::template write_element<0,1>(r)=a*mat_traits<B>::template read_element<0,1>(b); mat_traits<R>::template write_element<0,2>(r)=a*mat_traits<B>::template read_element<0,2>(b); return r; } namespace sfinae { using ::boost::qvm::operator*; } namespace qvm_detail { template <int R,int C> struct mul_sm_defined; template <> struct mul_sm_defined<1,3> { static bool const value=true; }; } template <class A,class B> BOOST_QVM_INLINE_OPERATIONS typename enable_if_c< mat_traits<A>::rows==3 && mat_traits<A>::cols==3 && is_scalar<B>::value, A &>::type operator*=( A & a, B b ) { mat_traits<A>::template write_element<0,0>(a)*=b; mat_traits<A>::template write_element<0,1>(a)*=b; mat_traits<A>::template write_element<0,2>(a)*=b; mat_traits<A>::template write_element<1,0>(a)*=b; mat_traits<A>::template write_element<1,1>(a)*=b; mat_traits<A>::template write_element<1,2>(a)*=b; mat_traits<A>::template write_element<2,0>(a)*=b; mat_traits<A>::template write_element<2,1>(a)*=b; mat_traits<A>::template write_element<2,2>(a)*=b; return a; } namespace sfinae { using ::boost::qvm::operator*=; } namespace qvm_detail { template <int R,int C> struct mul_eq_ms_defined; template <> struct mul_eq_ms_defined<3,3> { static bool const value=true; }; } template <class A,class B> BOOST_QVM_INLINE_OPERATIONS typename enable_if_c< mat_traits<A>::rows==3 && mat_traits<A>::cols==1 && is_scalar<B>::value, A &>::type operator*=( A & a, B b ) { mat_traits<A>::template write_element<0,0>(a)*=b; mat_traits<A>::template write_element<1,0>(a)*=b; mat_traits<A>::template write_element<2,0>(a)*=b; return a; } namespace sfinae { using ::boost::qvm::operator*=; } namespace qvm_detail { template <int R,int C> struct mul_eq_ms_defined; template <> struct mul_eq_ms_defined<3,1> { static bool const value=true; }; } template <class A,class B> BOOST_QVM_INLINE_OPERATIONS typename enable_if_c< mat_traits<A>::rows==1 && mat_traits<A>::cols==3 && is_scalar<B>::value, A &>::type operator*=( A & a, B b ) { mat_traits<A>::template write_element<0,0>(a)*=b; mat_traits<A>::template write_element<0,1>(a)*=b; mat_traits<A>::template write_element<0,2>(a)*=b; return a; } namespace sfinae { using ::boost::qvm::operator*=; } namespace qvm_detail { template <int R,int C> struct mul_eq_ms_defined; template <> struct mul_eq_ms_defined<1,3> { static bool const value=true; }; } template <class A,class B> BOOST_QVM_INLINE_OPERATIONS typename lazy_enable_if_c< mat_traits<A>::rows==3 && mat_traits<A>::cols==3 && is_scalar<B>::value, deduce_mat<A> >::type operator/( A const & a, B b ) { typedef typename deduce_mat<A>::type R; R r; mat_traits<R>::template write_element<0,0>(r)=mat_traits<A>::template read_element<0,0>(a)/b; mat_traits<R>::template write_element<0,1>(r)=mat_traits<A>::template read_element<0,1>(a)/b; mat_traits<R>::template write_element<0,2>(r)=mat_traits<A>::template read_element<0,2>(a)/b; mat_traits<R>::template write_element<1,0>(r)=mat_traits<A>::template read_element<1,0>(a)/b; mat_traits<R>::template write_element<1,1>(r)=mat_traits<A>::template read_element<1,1>(a)/b; mat_traits<R>::template write_element<1,2>(r)=mat_traits<A>::template read_element<1,2>(a)/b; mat_traits<R>::template write_element<2,0>(r)=mat_traits<A>::template read_element<2,0>(a)/b; mat_traits<R>::template write_element<2,1>(r)=mat_traits<A>::template read_element<2,1>(a)/b; mat_traits<R>::template write_element<2,2>(r)=mat_traits<A>::template read_element<2,2>(a)/b; return r; } namespace sfinae { using ::boost::qvm::operator/; } namespace qvm_detail { template <int R,int C> struct div_ms_defined; template <> struct div_ms_defined<3,3> { static bool const value=true; }; } template <class A,class B> BOOST_QVM_INLINE_OPERATIONS typename lazy_enable_if_c< is_scalar<A>::value && mat_traits<B>::rows==3 && mat_traits<B>::cols==3, deduce_mat<B> >::type operator/( A a, B const & b ) { typedef typename deduce_mat<B>::type R; R r; mat_traits<R>::template write_element<0,0>(r)=a/mat_traits<B>::template read_element<0,0>(b); mat_traits<R>::template write_element<0,1>(r)=a/mat_traits<B>::template read_element<0,1>(b); mat_traits<R>::template write_element<0,2>(r)=a/mat_traits<B>::template read_element<0,2>(b); mat_traits<R>::template write_element<1,0>(r)=a/mat_traits<B>::template read_element<1,0>(b); mat_traits<R>::template write_element<1,1>(r)=a/mat_traits<B>::template read_element<1,1>(b); mat_traits<R>::template write_element<1,2>(r)=a/mat_traits<B>::template read_element<1,2>(b); mat_traits<R>::template write_element<2,0>(r)=a/mat_traits<B>::template read_element<2,0>(b); mat_traits<R>::template write_element<2,1>(r)=a/mat_traits<B>::template read_element<2,1>(b); mat_traits<R>::template write_element<2,2>(r)=a/mat_traits<B>::template read_element<2,2>(b); return r; } namespace sfinae { using ::boost::qvm::operator/; } namespace qvm_detail { template <int R,int C> struct div_sm_defined; template <> struct div_sm_defined<3,3> { static bool const value=true; }; } template <class A,class B> BOOST_QVM_INLINE_OPERATIONS typename lazy_enable_if_c< mat_traits<A>::rows==3 && mat_traits<A>::cols==1 && is_scalar<B>::value, deduce_mat<A> >::type operator/( A const & a, B b ) { typedef typename deduce_mat<A>::type R; R r; mat_traits<R>::template write_element<0,0>(r)=mat_traits<A>::template read_element<0,0>(a)/b; mat_traits<R>::template write_element<1,0>(r)=mat_traits<A>::template read_element<1,0>(a)/b; mat_traits<R>::template write_element<2,0>(r)=mat_traits<A>::template read_element<2,0>(a)/b; return r; } namespace sfinae { using ::boost::qvm::operator/; } namespace qvm_detail { template <int R,int C> struct div_ms_defined; template <> struct div_ms_defined<3,1> { static bool const value=true; }; } template <class A,class B> BOOST_QVM_INLINE_OPERATIONS typename lazy_enable_if_c< is_scalar<A>::value && mat_traits<B>::rows==3 && mat_traits<B>::cols==1, deduce_mat<B> >::type operator/( A a, B const & b ) { typedef typename deduce_mat<B>::type R; R r; mat_traits<R>::template write_element<0,0>(r)=a/mat_traits<B>::template read_element<0,0>(b); mat_traits<R>::template write_element<1,0>(r)=a/mat_traits<B>::template read_element<1,0>(b); mat_traits<R>::template write_element<2,0>(r)=a/mat_traits<B>::template read_element<2,0>(b); return r; } namespace sfinae { using ::boost::qvm::operator/; } namespace qvm_detail { template <int R,int C> struct div_sm_defined; template <> struct div_sm_defined<3,1> { static bool const value=true; }; } template <class A,class B> BOOST_QVM_INLINE_OPERATIONS typename lazy_enable_if_c< mat_traits<A>::rows==1 && mat_traits<A>::cols==3 && is_scalar<B>::value, deduce_mat<A> >::type operator/( A const & a, B b ) { typedef typename deduce_mat<A>::type R; R r; mat_traits<R>::template write_element<0,0>(r)=mat_traits<A>::template read_element<0,0>(a)/b; mat_traits<R>::template write_element<0,1>(r)=mat_traits<A>::template read_element<0,1>(a)/b; mat_traits<R>::template write_element<0,2>(r)=mat_traits<A>::template read_element<0,2>(a)/b; return r; } namespace sfinae { using ::boost::qvm::operator/; } namespace qvm_detail { template <int R,int C> struct div_ms_defined; template <> struct div_ms_defined<1,3> { static bool const value=true; }; } template <class A,class B> BOOST_QVM_INLINE_OPERATIONS typename enable_if_c< mat_traits<A>::rows==3 && mat_traits<A>::cols==3 && is_scalar<B>::value, A &>::type operator/=( A & a, B b ) { mat_traits<A>::template write_element<0,0>(a)/=b; mat_traits<A>::template write_element<0,1>(a)/=b; mat_traits<A>::template write_element<0,2>(a)/=b; mat_traits<A>::template write_element<1,0>(a)/=b; mat_traits<A>::template write_element<1,1>(a)/=b; mat_traits<A>::template write_element<1,2>(a)/=b; mat_traits<A>::template write_element<2,0>(a)/=b; mat_traits<A>::template write_element<2,1>(a)/=b; mat_traits<A>::template write_element<2,2>(a)/=b; return a; } namespace sfinae { using ::boost::qvm::operator/=; } namespace qvm_detail { template <int R,int C> struct div_eq_ms_defined; template <> struct div_eq_ms_defined<3,3> { static bool const value=true; }; } template <class A,class B> BOOST_QVM_INLINE_OPERATIONS typename enable_if_c< mat_traits<A>::rows==3 && mat_traits<A>::cols==1 && is_scalar<B>::value, A &>::type operator/=( A & a, B b ) { mat_traits<A>::template write_element<0,0>(a)/=b; mat_traits<A>::template write_element<1,0>(a)/=b; mat_traits<A>::template write_element<2,0>(a)/=b; return a; } namespace sfinae { using ::boost::qvm::operator/=; } namespace qvm_detail { template <int R,int C> struct div_eq_ms_defined; template <> struct div_eq_ms_defined<3,1> { static bool const value=true; }; } template <class A,class B> BOOST_QVM_INLINE_OPERATIONS typename enable_if_c< mat_traits<A>::rows==1 && mat_traits<A>::cols==3 && is_scalar<B>::value, A &>::type operator/=( A & a, B b ) { mat_traits<A>::template write_element<0,0>(a)/=b; mat_traits<A>::template write_element<0,1>(a)/=b; mat_traits<A>::template write_element<0,2>(a)/=b; return a; } namespace sfinae { using ::boost::qvm::operator/=; } namespace qvm_detail { template <int R,int C> struct div_eq_ms_defined; template <> struct div_eq_ms_defined<1,3> { static bool const value=true; }; } template <class R,class A> BOOST_QVM_INLINE_OPERATIONS typename enable_if_c< mat_traits<R>::rows==3 && mat_traits<A>::rows==3 && mat_traits<R>::cols==3 && mat_traits<A>::cols==3, R>::type convert_to( A const & a ) { R r; mat_traits<R>::template write_element<0,0>(r) = mat_traits<A>::template read_element<0,0>(a); mat_traits<R>::template write_element<0,1>(r) = mat_traits<A>::template read_element<0,1>(a); mat_traits<R>::template write_element<0,2>(r) = mat_traits<A>::template read_element<0,2>(a); mat_traits<R>::template write_element<1,0>(r) = mat_traits<A>::template read_element<1,0>(a); mat_traits<R>::template write_element<1,1>(r) = mat_traits<A>::template read_element<1,1>(a); mat_traits<R>::template write_element<1,2>(r) = mat_traits<A>::template read_element<1,2>(a); mat_traits<R>::template write_element<2,0>(r) = mat_traits<A>::template read_element<2,0>(a); mat_traits<R>::template write_element<2,1>(r) = mat_traits<A>::template read_element<2,1>(a); mat_traits<R>::template write_element<2,2>(r) = mat_traits<A>::template read_element<2,2>(a); return r; } template <class R,class A> BOOST_QVM_INLINE typename enable_if_c< is_mat<R>::value && is_quat<A>::value && mat_traits<R>::rows==3 && mat_traits<R>::cols==3, R>::type convert_to( A const & q ) { typedef typename mat_traits<R>::scalar_type T; T const a=quat_traits<A>::template read_element<0>(q); T const b=quat_traits<A>::template read_element<1>(q); T const c=quat_traits<A>::template read_element<2>(q); T const d=quat_traits<A>::template read_element<3>(q); T const bb = b*b; T const cc = c*c; T const dd = d*d; T const bc = b*c; T const bd = b*d; T const cd = c*d; T const ab = a*b; T const ac = a*c; T const ad = a*d; T const one = scalar_traits<T>::value(1); T const two = one+one; R r; mat_traits<R>::template write_element<0,0>(r) = one - two*(cc+dd); mat_traits<R>::template write_element<0,1>(r) = two*(bc-ad); mat_traits<R>::template write_element<0,2>(r) = two*(bd+ac); mat_traits<R>::template write_element<1,0>(r) = two*(bc+ad); mat_traits<R>::template write_element<1,1>(r) = one - two*(bb+dd); mat_traits<R>::template write_element<1,2>(r) = two*(cd-ab); mat_traits<R>::template write_element<2,0>(r) = two*(bd-ac); mat_traits<R>::template write_element<2,1>(r) = two*(cd+ab); mat_traits<R>::template write_element<2,2>(r) = one - two*(bb+cc); return r; } namespace sfinae { using ::boost::qvm::convert_to; } namespace qvm_detail { template <int R,int C> struct convert_to_m_defined; template <> struct convert_to_m_defined<3,3> { static bool const value=true; }; } template <class R,class A> BOOST_QVM_INLINE_OPERATIONS typename enable_if_c< mat_traits<R>::rows==3 && mat_traits<A>::rows==3 && mat_traits<R>::cols==1 && mat_traits<A>::cols==1, R>::type convert_to( A const & a ) { R r; mat_traits<R>::template write_element<0,0>(r) = mat_traits<A>::template read_element<0,0>(a); mat_traits<R>::template write_element<1,0>(r) = mat_traits<A>::template read_element<1,0>(a); mat_traits<R>::template write_element<2,0>(r) = mat_traits<A>::template read_element<2,0>(a); return r; } namespace sfinae { using ::boost::qvm::convert_to; } namespace qvm_detail { template <int R,int C> struct convert_to_m_defined; template <> struct convert_to_m_defined<3,1> { static bool const value=true; }; } template <class R,class A> BOOST_QVM_INLINE_OPERATIONS typename enable_if_c< mat_traits<R>::rows==1 && mat_traits<A>::rows==1 && mat_traits<R>::cols==3 && mat_traits<A>::cols==3, R>::type convert_to( A const & a ) { R r; mat_traits<R>::template write_element<0,0>(r) = mat_traits<A>::template read_element<0,0>(a); mat_traits<R>::template write_element<0,1>(r) = mat_traits<A>::template read_element<0,1>(a); mat_traits<R>::template write_element<0,2>(r) = mat_traits<A>::template read_element<0,2>(a); return r; } namespace sfinae { using ::boost::qvm::convert_to; } namespace qvm_detail { template <int R,int C> struct convert_to_m_defined; template <> struct convert_to_m_defined<1,3> { static bool const value=true; }; } template <class A,class B> BOOST_QVM_INLINE_OPERATIONS typename enable_if_c< mat_traits<A>::rows==3 && mat_traits<B>::rows==3 && mat_traits<A>::cols==3 && mat_traits<B>::cols==3, bool>::type operator==( A const & a, B const & b ) { return mat_traits<A>::template read_element<0,0>(a)==mat_traits<B>::template read_element<0,0>(b) && mat_traits<A>::template read_element<0,1>(a)==mat_traits<B>::template read_element<0,1>(b) && mat_traits<A>::template read_element<0,2>(a)==mat_traits<B>::template read_element<0,2>(b) && mat_traits<A>::template read_element<1,0>(a)==mat_traits<B>::template read_element<1,0>(b) && mat_traits<A>::template read_element<1,1>(a)==mat_traits<B>::template read_element<1,1>(b) && mat_traits<A>::template read_element<1,2>(a)==mat_traits<B>::template read_element<1,2>(b) && mat_traits<A>::template read_element<2,0>(a)==mat_traits<B>::template read_element<2,0>(b) && mat_traits<A>::template read_element<2,1>(a)==mat_traits<B>::template read_element<2,1>(b) && mat_traits<A>::template read_element<2,2>(a)==mat_traits<B>::template read_element<2,2>(b); } namespace sfinae { using ::boost::qvm::operator==; } namespace qvm_detail { template <int R,int C> struct eq_mm_defined; template <> struct eq_mm_defined<3,3> { static bool const value=true; }; } template <class A,class B> BOOST_QVM_INLINE_OPERATIONS typename enable_if_c< mat_traits<A>::rows==3 && mat_traits<B>::rows==3 && mat_traits<A>::cols==1 && mat_traits<B>::cols==1, bool>::type operator==( A const & a, B const & b ) { return mat_traits<A>::template read_element<0,0>(a)==mat_traits<B>::template read_element<0,0>(b) && mat_traits<A>::template read_element<1,0>(a)==mat_traits<B>::template read_element<1,0>(b) && mat_traits<A>::template read_element<2,0>(a)==mat_traits<B>::template read_element<2,0>(b); } namespace sfinae { using ::boost::qvm::operator==; } namespace qvm_detail { template <int R,int C> struct eq_mm_defined; template <> struct eq_mm_defined<3,1> { static bool const value=true; }; } template <class A,class B> BOOST_QVM_INLINE_OPERATIONS typename enable_if_c< mat_traits<A>::rows==1 && mat_traits<B>::rows==1 && mat_traits<A>::cols==3 && mat_traits<B>::cols==3, bool>::type operator==( A const & a, B const & b ) { return mat_traits<A>::template read_element<0,0>(a)==mat_traits<B>::template read_element<0,0>(b) && mat_traits<A>::template read_element<0,1>(a)==mat_traits<B>::template read_element<0,1>(b) && mat_traits<A>::template read_element<0,2>(a)==mat_traits<B>::template read_element<0,2>(b); } namespace sfinae { using ::boost::qvm::operator==; } namespace qvm_detail { template <int R,int C> struct eq_mm_defined; template <> struct eq_mm_defined<1,3> { static bool const value=true; }; } template <class A,class B> BOOST_QVM_INLINE_OPERATIONS typename enable_if_c< mat_traits<A>::rows==3 && mat_traits<B>::rows==3 && mat_traits<A>::cols==3 && mat_traits<B>::cols==3, bool>::type operator!=( A const & a, B const & b ) { return !(mat_traits<A>::template read_element<0,0>(a)==mat_traits<B>::template read_element<0,0>(b)) || !(mat_traits<A>::template read_element<0,1>(a)==mat_traits<B>::template read_element<0,1>(b)) || !(mat_traits<A>::template read_element<0,2>(a)==mat_traits<B>::template read_element<0,2>(b)) || !(mat_traits<A>::template read_element<1,0>(a)==mat_traits<B>::template read_element<1,0>(b)) || !(mat_traits<A>::template read_element<1,1>(a)==mat_traits<B>::template read_element<1,1>(b)) || !(mat_traits<A>::template read_element<1,2>(a)==mat_traits<B>::template read_element<1,2>(b)) || !(mat_traits<A>::template read_element<2,0>(a)==mat_traits<B>::template read_element<2,0>(b)) || !(mat_traits<A>::template read_element<2,1>(a)==mat_traits<B>::template read_element<2,1>(b)) || !(mat_traits<A>::template read_element<2,2>(a)==mat_traits<B>::template read_element<2,2>(b)); } namespace sfinae { using ::boost::qvm::operator!=; } namespace qvm_detail { template <int R,int C> struct neq_mm_defined; template <> struct neq_mm_defined<3,3> { static bool const value=true; }; } template <class A,class B> BOOST_QVM_INLINE_OPERATIONS typename enable_if_c< mat_traits<A>::rows==3 && mat_traits<B>::rows==3 && mat_traits<A>::cols==1 && mat_traits<B>::cols==1, bool>::type operator!=( A const & a, B const & b ) { return !(mat_traits<A>::template read_element<0,0>(a)==mat_traits<B>::template read_element<0,0>(b)) || !(mat_traits<A>::template read_element<1,0>(a)==mat_traits<B>::template read_element<1,0>(b)) || !(mat_traits<A>::template read_element<2,0>(a)==mat_traits<B>::template read_element<2,0>(b)); } namespace sfinae { using ::boost::qvm::operator!=; } namespace qvm_detail { template <int R,int C> struct neq_mm_defined; template <> struct neq_mm_defined<3,1> { static bool const value=true; }; } template <class A,class B> BOOST_QVM_INLINE_OPERATIONS typename enable_if_c< mat_traits<A>::rows==1 && mat_traits<B>::rows==1 && mat_traits<A>::cols==3 && mat_traits<B>::cols==3, bool>::type operator!=( A const & a, B const & b ) { return !(mat_traits<A>::template read_element<0,0>(a)==mat_traits<B>::template read_element<0,0>(b)) || !(mat_traits<A>::template read_element<0,1>(a)==mat_traits<B>::template read_element<0,1>(b)) || !(mat_traits<A>::template read_element<0,2>(a)==mat_traits<B>::template read_element<0,2>(b)); } namespace sfinae { using ::boost::qvm::operator!=; } namespace qvm_detail { template <int R,int C> struct neq_mm_defined; template <> struct neq_mm_defined<1,3> { static bool const value=true; }; } template <class A> BOOST_QVM_INLINE_OPERATIONS typename lazy_enable_if_c< mat_traits<A>::rows==3 && mat_traits<A>::cols==3, deduce_mat<A> >::type operator-( A const & a ) { typedef typename deduce_mat<A>::type R; R r; mat_traits<R>::template write_element<0,0>(r)=-mat_traits<A>::template read_element<0,0>(a); mat_traits<R>::template write_element<0,1>(r)=-mat_traits<A>::template read_element<0,1>(a); mat_traits<R>::template write_element<0,2>(r)=-mat_traits<A>::template read_element<0,2>(a); mat_traits<R>::template write_element<1,0>(r)=-mat_traits<A>::template read_element<1,0>(a); mat_traits<R>::template write_element<1,1>(r)=-mat_traits<A>::template read_element<1,1>(a); mat_traits<R>::template write_element<1,2>(r)=-mat_traits<A>::template read_element<1,2>(a); mat_traits<R>::template write_element<2,0>(r)=-mat_traits<A>::template read_element<2,0>(a); mat_traits<R>::template write_element<2,1>(r)=-mat_traits<A>::template read_element<2,1>(a); mat_traits<R>::template write_element<2,2>(r)=-mat_traits<A>::template read_element<2,2>(a); return r; } namespace sfinae { using ::boost::qvm::operator-; } namespace qvm_detail { template <int R,int C> struct minus_m_defined; template <> struct minus_m_defined<3,3> { static bool const value=true; }; } template <class A> BOOST_QVM_INLINE_OPERATIONS typename lazy_enable_if_c< mat_traits<A>::rows==3 && mat_traits<A>::cols==1, deduce_mat<A> >::type operator-( A const & a ) { typedef typename deduce_mat<A>::type R; R r; mat_traits<R>::template write_element<0,0>(r)=-mat_traits<A>::template read_element<0,0>(a); mat_traits<R>::template write_element<1,0>(r)=-mat_traits<A>::template read_element<1,0>(a); mat_traits<R>::template write_element<2,0>(r)=-mat_traits<A>::template read_element<2,0>(a); return r; } namespace sfinae { using ::boost::qvm::operator-; } namespace qvm_detail { template <int R,int C> struct minus_m_defined; template <> struct minus_m_defined<3,1> { static bool const value=true; }; } template <class A> BOOST_QVM_INLINE_OPERATIONS typename lazy_enable_if_c< mat_traits<A>::rows==1 && mat_traits<A>::cols==3, deduce_mat<A> >::type operator-( A const & a ) { typedef typename deduce_mat<A>::type R; R r; mat_traits<R>::template write_element<0,0>(r)=-mat_traits<A>::template read_element<0,0>(a); mat_traits<R>::template write_element<0,1>(r)=-mat_traits<A>::template read_element<0,1>(a); mat_traits<R>::template write_element<0,2>(r)=-mat_traits<A>::template read_element<0,2>(a); return r; } namespace sfinae { using ::boost::qvm::operator-; } namespace qvm_detail { template <int R,int C> struct minus_m_defined; template <> struct minus_m_defined<1,3> { static bool const value=true; }; } template <class A> BOOST_QVM_INLINE_OPERATIONS typename enable_if_c< mat_traits<A>::rows==3 && mat_traits<A>::cols==3, typename mat_traits<A>::scalar_type>::type determinant( A const & a ) { typedef typename mat_traits<A>::scalar_type T; T const a00=mat_traits<A>::template read_element<0,0>(a); T const a01=mat_traits<A>::template read_element<0,1>(a); T const a02=mat_traits<A>::template read_element<0,2>(a); T const a10=mat_traits<A>::template read_element<1,0>(a); T const a11=mat_traits<A>::template read_element<1,1>(a); T const a12=mat_traits<A>::template read_element<1,2>(a); T const a20=mat_traits<A>::template read_element<2,0>(a); T const a21=mat_traits<A>::template read_element<2,1>(a); T const a22=mat_traits<A>::template read_element<2,2>(a); T det=(a00*(a11*a22-a12*a21)-a01*(a10*a22-a12*a20)+a02*(a10*a21-a11*a20)); return det; } namespace sfinae { using ::boost::qvm::determinant; } namespace qvm_detail { template <int D> struct determinant_defined; template <> struct determinant_defined<3> { static bool const value=true; }; } template <class A,class B> BOOST_QVM_INLINE_OPERATIONS typename lazy_enable_if_c< mat_traits<A>::rows==3 && mat_traits<A>::cols==3 && is_scalar<B>::value, deduce_mat<A> >::type inverse( A const & a, B det ) { typedef typename mat_traits<A>::scalar_type T; BOOST_QVM_ASSERT(det!=scalar_traits<B>::value(0)); T const a00=mat_traits<A>::template read_element<0,0>(a); T const a01=mat_traits<A>::template read_element<0,1>(a); T const a02=mat_traits<A>::template read_element<0,2>(a); T const a10=mat_traits<A>::template read_element<1,0>(a); T const a11=mat_traits<A>::template read_element<1,1>(a); T const a12=mat_traits<A>::template read_element<1,2>(a); T const a20=mat_traits<A>::template read_element<2,0>(a); T const a21=mat_traits<A>::template read_element<2,1>(a); T const a22=mat_traits<A>::template read_element<2,2>(a); T const f=scalar_traits<T>::value(1)/det; typedef typename deduce_mat<A>::type R; R r; mat_traits<R>::template write_element<0,0>(r)= f*(a11*a22-a12*a21); mat_traits<R>::template write_element<0,1>(r)=-f*(a01*a22-a02*a21); mat_traits<R>::template write_element<0,2>(r)= f*(a01*a12-a02*a11); mat_traits<R>::template write_element<1,0>(r)=-f*(a10*a22-a12*a20); mat_traits<R>::template write_element<1,1>(r)= f*(a00*a22-a02*a20); mat_traits<R>::template write_element<1,2>(r)=-f*(a00*a12-a02*a10); mat_traits<R>::template write_element<2,0>(r)= f*(a10*a21-a11*a20); mat_traits<R>::template write_element<2,1>(r)=-f*(a00*a21-a01*a20); mat_traits<R>::template write_element<2,2>(r)= f*(a00*a11-a01*a10); return r; } template <class A> BOOST_QVM_INLINE_OPERATIONS typename lazy_enable_if_c< mat_traits<A>::rows==3 && mat_traits<A>::cols==3, deduce_mat<A> >::type inverse( A const & a ) { typedef typename mat_traits<A>::scalar_type T; T det=determinant(a); if( det==scalar_traits<T>::value(0) ) BOOST_QVM_THROW_EXCEPTION(zero_determinant_error()); return inverse(a,det); } namespace sfinae { using ::boost::qvm::inverse; } namespace qvm_detail { template <int D> struct inverse_m_defined; template <> struct inverse_m_defined<3> { static bool const value=true; }; } template <class A,class B> BOOST_QVM_INLINE_OPERATIONS typename lazy_enable_if_c< mat_traits<A>::rows==3 && mat_traits<B>::rows==3 && mat_traits<A>::cols==3 && mat_traits<B>::cols==3, deduce_mat2<A,B,3,3> >::type operator*( A const & a, B const & b ) { typedef typename mat_traits<A>::scalar_type Ta; typedef typename mat_traits<B>::scalar_type Tb; Ta const a00 = mat_traits<A>::template read_element<0,0>(a); Ta const a01 = mat_traits<A>::template read_element<0,1>(a); Ta const a02 = mat_traits<A>::template read_element<0,2>(a); Ta const a10 = mat_traits<A>::template read_element<1,0>(a); Ta const a11 = mat_traits<A>::template read_element<1,1>(a); Ta const a12 = mat_traits<A>::template read_element<1,2>(a); Ta const a20 = mat_traits<A>::template read_element<2,0>(a); Ta const a21 = mat_traits<A>::template read_element<2,1>(a); Ta const a22 = mat_traits<A>::template read_element<2,2>(a); Tb const b00 = mat_traits<B>::template read_element<0,0>(b); Tb const b01 = mat_traits<B>::template read_element<0,1>(b); Tb const b02 = mat_traits<B>::template read_element<0,2>(b); Tb const b10 = mat_traits<B>::template read_element<1,0>(b); Tb const b11 = mat_traits<B>::template read_element<1,1>(b); Tb const b12 = mat_traits<B>::template read_element<1,2>(b); Tb const b20 = mat_traits<B>::template read_element<2,0>(b); Tb const b21 = mat_traits<B>::template read_element<2,1>(b); Tb const b22 = mat_traits<B>::template read_element<2,2>(b); typedef typename deduce_mat2<A,B,3,3>::type R; BOOST_QVM_STATIC_ASSERT(mat_traits<R>::rows==3); BOOST_QVM_STATIC_ASSERT(mat_traits<R>::cols==3); R r; mat_traits<R>::template write_element<0,0>(r)=a00*b00+a01*b10+a02*b20; mat_traits<R>::template write_element<0,1>(r)=a00*b01+a01*b11+a02*b21; mat_traits<R>::template write_element<0,2>(r)=a00*b02+a01*b12+a02*b22; mat_traits<R>::template write_element<1,0>(r)=a10*b00+a11*b10+a12*b20; mat_traits<R>::template write_element<1,1>(r)=a10*b01+a11*b11+a12*b21; mat_traits<R>::template write_element<1,2>(r)=a10*b02+a11*b12+a12*b22; mat_traits<R>::template write_element<2,0>(r)=a20*b00+a21*b10+a22*b20; mat_traits<R>::template write_element<2,1>(r)=a20*b01+a21*b11+a22*b21; mat_traits<R>::template write_element<2,2>(r)=a20*b02+a21*b12+a22*b22; return r; } namespace sfinae { using ::boost::qvm::operator*; } namespace qvm_detail { template <int R,int CR,int C> struct mul_mm_defined; template <> struct mul_mm_defined<3,3,3> { static bool const value=true; }; } template <class A,class B> BOOST_QVM_INLINE_OPERATIONS typename enable_if_c< mat_traits<A>::rows==3 && mat_traits<B>::rows==3 && mat_traits<A>::cols==3 && mat_traits<B>::cols==3, A &>::type operator*=( A & a, B const & b ) { typedef typename mat_traits<A>::scalar_type Ta; typedef typename mat_traits<B>::scalar_type Tb; Ta const a00 = mat_traits<A>::template read_element<0,0>(a); Ta const a01 = mat_traits<A>::template read_element<0,1>(a); Ta const a02 = mat_traits<A>::template read_element<0,2>(a); Ta const a10 = mat_traits<A>::template read_element<1,0>(a); Ta const a11 = mat_traits<A>::template read_element<1,1>(a); Ta const a12 = mat_traits<A>::template read_element<1,2>(a); Ta const a20 = mat_traits<A>::template read_element<2,0>(a); Ta const a21 = mat_traits<A>::template read_element<2,1>(a); Ta const a22 = mat_traits<A>::template read_element<2,2>(a); Tb const b00 = mat_traits<B>::template read_element<0,0>(b); Tb const b01 = mat_traits<B>::template read_element<0,1>(b); Tb const b02 = mat_traits<B>::template read_element<0,2>(b); Tb const b10 = mat_traits<B>::template read_element<1,0>(b); Tb const b11 = mat_traits<B>::template read_element<1,1>(b); Tb const b12 = mat_traits<B>::template read_element<1,2>(b); Tb const b20 = mat_traits<B>::template read_element<2,0>(b); Tb const b21 = mat_traits<B>::template read_element<2,1>(b); Tb const b22 = mat_traits<B>::template read_element<2,2>(b); mat_traits<A>::template write_element<0,0>(a)=a00*b00+a01*b10+a02*b20; mat_traits<A>::template write_element<0,1>(a)=a00*b01+a01*b11+a02*b21; mat_traits<A>::template write_element<0,2>(a)=a00*b02+a01*b12+a02*b22; mat_traits<A>::template write_element<1,0>(a)=a10*b00+a11*b10+a12*b20; mat_traits<A>::template write_element<1,1>(a)=a10*b01+a11*b11+a12*b21; mat_traits<A>::template write_element<1,2>(a)=a10*b02+a11*b12+a12*b22; mat_traits<A>::template write_element<2,0>(a)=a20*b00+a21*b10+a22*b20; mat_traits<A>::template write_element<2,1>(a)=a20*b01+a21*b11+a22*b21; mat_traits<A>::template write_element<2,2>(a)=a20*b02+a21*b12+a22*b22; return a; } namespace sfinae { using ::boost::qvm::operator*=; } namespace qvm_detail { template <int D> struct mul_eq_mm_defined; template <> struct mul_eq_mm_defined<3> { static bool const value=true; }; } template <class A,class B> BOOST_QVM_INLINE_OPERATIONS typename lazy_enable_if_c< mat_traits<A>::rows==3 && mat_traits<B>::rows==3 && mat_traits<A>::cols==3 && mat_traits<B>::cols==1, deduce_mat2<A,B,3,1> >::type operator*( A const & a, B const & b ) { typedef typename mat_traits<A>::scalar_type Ta; typedef typename mat_traits<B>::scalar_type Tb; Ta const a00 = mat_traits<A>::template read_element<0,0>(a); Ta const a01 = mat_traits<A>::template read_element<0,1>(a); Ta const a02 = mat_traits<A>::template read_element<0,2>(a); Ta const a10 = mat_traits<A>::template read_element<1,0>(a); Ta const a11 = mat_traits<A>::template read_element<1,1>(a); Ta const a12 = mat_traits<A>::template read_element<1,2>(a); Ta const a20 = mat_traits<A>::template read_element<2,0>(a); Ta const a21 = mat_traits<A>::template read_element<2,1>(a); Ta const a22 = mat_traits<A>::template read_element<2,2>(a); Tb const b00 = mat_traits<B>::template read_element<0,0>(b); Tb const b10 = mat_traits<B>::template read_element<1,0>(b); Tb const b20 = mat_traits<B>::template read_element<2,0>(b); typedef typename deduce_mat2<A,B,3,1>::type R; BOOST_QVM_STATIC_ASSERT(mat_traits<R>::rows==3); BOOST_QVM_STATIC_ASSERT(mat_traits<R>::cols==1); R r; mat_traits<R>::template write_element<0,0>(r)=a00*b00+a01*b10+a02*b20; mat_traits<R>::template write_element<1,0>(r)=a10*b00+a11*b10+a12*b20; mat_traits<R>::template write_element<2,0>(r)=a20*b00+a21*b10+a22*b20; return r; } namespace sfinae { using ::boost::qvm::operator*; } namespace qvm_detail { template <int R,int CR,int C> struct mul_mm_defined; template <> struct mul_mm_defined<3,3,1> { static bool const value=true; }; } template <class A,class B> BOOST_QVM_INLINE_OPERATIONS typename lazy_enable_if_c< mat_traits<A>::rows==1 && mat_traits<B>::rows==3 && mat_traits<A>::cols==3 && mat_traits<B>::cols==3, deduce_mat2<A,B,1,3> >::type operator*( A const & a, B const & b ) { typedef typename mat_traits<A>::scalar_type Ta; typedef typename mat_traits<B>::scalar_type Tb; Ta const a00 = mat_traits<A>::template read_element<0,0>(a); Ta const a01 = mat_traits<A>::template read_element<0,1>(a); Ta const a02 = mat_traits<A>::template read_element<0,2>(a); Tb const b00 = mat_traits<B>::template read_element<0,0>(b); Tb const b01 = mat_traits<B>::template read_element<0,1>(b); Tb const b02 = mat_traits<B>::template read_element<0,2>(b); Tb const b10 = mat_traits<B>::template read_element<1,0>(b); Tb const b11 = mat_traits<B>::template read_element<1,1>(b); Tb const b12 = mat_traits<B>::template read_element<1,2>(b); Tb const b20 = mat_traits<B>::template read_element<2,0>(b); Tb const b21 = mat_traits<B>::template read_element<2,1>(b); Tb const b22 = mat_traits<B>::template read_element<2,2>(b); typedef typename deduce_mat2<A,B,1,3>::type R; BOOST_QVM_STATIC_ASSERT(mat_traits<R>::rows==1); BOOST_QVM_STATIC_ASSERT(mat_traits<R>::cols==3); R r; mat_traits<R>::template write_element<0,0>(r)=a00*b00+a01*b10+a02*b20; mat_traits<R>::template write_element<0,1>(r)=a00*b01+a01*b11+a02*b21; mat_traits<R>::template write_element<0,2>(r)=a00*b02+a01*b12+a02*b22; return r; } namespace sfinae { using ::boost::qvm::operator*; } namespace qvm_detail { template <int R,int CR,int C> struct mul_mm_defined; template <> struct mul_mm_defined<1,3,3> { static bool const value=true; }; } } } #endif
[ "zhaixueqiang@hotmail.com" ]
zhaixueqiang@hotmail.com
682fc09686bdff6f101e90cfe72bbbe759a01cee
77e82ee53d0284f8297f3c952e60bd614bafb40f
/topcoder/Unblur.cxx
c77b4851e066e75c22862fc5dc67e2986dc32de9
[]
no_license
jackytck/practice
04ae4e5deef2af942cea605d3a599441b9c5db96
d022660003fa248fd159f9a4c4c1816b7b4688a4
refs/heads/master
2021-01-01T05:30:41.570650
2012-07-22T11:53:53
2012-07-22T11:53:53
null
0
0
null
null
null
null
UTF-8
C++
false
false
5,585
cxx
#line 2 "Unblur.cxx" #include <vector> #include <list> #include <map> #include <set> #include <deque> #include <stack> #include <bitset> #include <algorithm> #include <functional> #include <numeric> #include <utility> #include <sstream> #include <iostream> #include <iomanip> #include <cstdio> #include <cmath> #include <cstdlib> #include <ctime> #define sz size() #define PB push_back #define clr(x) memset(x, 0, sizeof(x)) #define forn(i,n) for(__typeof(n) i = 0; i < (n); i++) #define ford(i,n) for(int i = (n) - 1; i >= 0; i--) #define forv(i,v) forn(i, v.sz) #define For(i, st, en) for(__typeof(en) i = (st); i < (en); i++) using namespace std; class Unblur { public: vector <string> original(vector <string> blurred) { vector <string> ret; int h = blurred.sz, w = blurred[0].sz; vector <vector <int> > un(h, vector <int> (w, 0)); forn(y, h) forn(x, w) { if(x == 0 || x == w-1 || y == 0 || y == h-1) continue; int sum = blurred[y-1][x-1] - '0'; un[y][x] = sum; forn(i, 3) forn(j, 3) { if(i==0 && j==0) continue; int px = x-i, py = y-j; if(px >= 0 && py >= 0) un[y][x] -= un[py][px]; } } forv(i, un) { string s = ""; forv(j, un[i]) s += un[i][j] == 0 ? "." : "#"; ret.PB(s); } return ret; } // BEGIN CUT HERE public: void run_test(int Case) { if ((Case == -1) || (Case == 0)) test_case_0(); if ((Case == -1) || (Case == 1)) test_case_1(); if ((Case == -1) || (Case == 2)) test_case_2(); if ((Case == -1) || (Case == 3)) test_case_3(); if ((Case == -1) || (Case == 4)) test_case_4(); } private: template <typename T> string print_array(const vector<T> &V) { ostringstream os; os << "{ "; for (typename vector<T>::const_iterator iter = V.begin(); iter != V.end(); ++iter) os << '\"' << *iter << "\","; os << " }"; return os.str(); } void verify_case(int Case, const vector <string> &Expected, const vector <string> &Received) { cerr << "Test Case #" << Case << "..."; if (Expected == Received) cerr << "PASSED" << endl; else { cerr << "FAILED" << endl; cerr << "\tExpected: " << print_array(Expected) << endl; cerr << "\tReceived: " << print_array(Received) << endl; } } void test_case_0() { string Arr0[] = { "1221", "1221", "1221" }; vector <string> Arg0(Arr0, Arr0 + (sizeof(Arr0) / sizeof(Arr0[0]))); string Arr1[] = { "....", ".##.", "...." }; vector <string> Arg1(Arr1, Arr1 + (sizeof(Arr1) / sizeof(Arr1[0]))); verify_case(0, Arg1, original(Arg0)); } void test_case_1() { string Arr0[] = { "00000", "00000", "00000", "00000" }; vector <string> Arg0(Arr0, Arr0 + (sizeof(Arr0) / sizeof(Arr0[0]))); string Arr1[] = { ".....", ".....", ".....", "....." }; vector <string> Arg1(Arr1, Arr1 + (sizeof(Arr1) / sizeof(Arr1[0]))); verify_case(1, Arg1, original(Arg0)); } void test_case_2() { string Arr0[] = { "0011212121100", "0123333333210", "0123333333210", "1233333333321", "1233333333321", "1233333333321", "0112121212110" } ; vector <string> Arg0(Arr0, Arr0 + (sizeof(Arr0) / sizeof(Arr0[0]))); string Arr1[] = { ".............", "...#.#.#.#...", "..#.#.#.#.#..", ".............", ".#.#.#.#.#.#.", "..#.#.#.#.#..", "............." }; vector <string> Arg1(Arr1, Arr1 + (sizeof(Arr1) / sizeof(Arr1[0]))); verify_case(2, Arg1, original(Arg0)); } void test_case_3() { string Arr0[] = { "1233321000000000123332100000000000000000000", "1244422233222332334343323322232112332223321", "1255523344343443545343434434343233432334432", "0033303455465775633011445546454355753457753", "0033303333364543533011433336333364521346542", "0033303455464532445343545546454355753446542", "0022202344342200234343434434343233432323221", "0011101233221100123332223322232112332211111" } ; vector <string> Arg0(Arr0, Arr0 + (sizeof(Arr0) / sizeof(Arr0[0]))); string Arr1[] = { "...........................................", ".#####...........#####.....................", "...#...####.####.#...#.####.###..####.####.", "...#...#..#.#..#.#.....#..#.#..#.#....#..#.", "...#...#..#.####.#.....#..#.#..#.###..####.", "...#...#..#.#....#...#.#..#.#..#.#....#.#..", "...#...####.#....#####.####.###..####.#..#.", "..........................................." }; vector <string> Arg1(Arr1, Arr1 + (sizeof(Arr1) / sizeof(Arr1[0]))); verify_case(3, Arg1, original(Arg0)); } void test_case_4() { string Arr0[] = { "0000123210000", "0012456542100", "0135789875310", "0258988898520", "1479865689741", "2589742479852", "2589742479852", "1479865689741", "0258988898520", "0135789875310", "0012456542100", "0000123210000" } ; vector <string> Arg0(Arr0, Arr0 + (sizeof(Arr0) / sizeof(Arr0[0]))); string Arr1[] = { ".............", ".....###.....", "...#######...", "..#########..", "..####.####..", ".####...####.", ".####...####.", "..####.####..", "..#########..", "...#######...", ".....###.....", "............." }; vector <string> Arg1(Arr1, Arr1 + (sizeof(Arr1) / sizeof(Arr1[0]))); verify_case(4, Arg1, original(Arg0)); } // END CUT HERE }; // BEGIN CUT HERE int main() { Unblur ___test; ___test.run_test(-1); } // END CUT HERE
[ "jackytck@gmail.com" ]
jackytck@gmail.com
36931e5c4ed6229f822f4566e6195b80f6b14337
6f40f4d12f74bc4fb08b68a3dcb31ce441ac9e4b
/include/fileloader.h
cff6d57c92b939196ab74a6bc18b19a7f1cdba85
[]
no_license
AtomicAustin/DIVA
e4d49452297e46c499f96a5cffb288ded056cbe3
6e264304ffbda8ce0ab5052be853d97297ad2355
refs/heads/master
2021-01-20T04:50:20.660353
2017-05-26T18:45:35
2017-05-26T18:45:35
89,741,651
0
0
null
null
null
null
UTF-8
C++
false
false
1,115
h
/******************************************************** *** D.I.V.A : File Loader BETA *** *** Austin Herman - austin.herman@valvoline.com *** *** Updated: *** *** 5/08/2017 Delimiter functionality *** *** 5/08/2017 added filepath *** ********************************************************/ #ifndef FILELOADER_H #define FILELOADER_H #include <iostream> #include <fstream> #include <string> #include "Types.h" #include "ColorMode.h" using namespace fndr; class FileLoader { public: FileLoader(); std::vector<Doc_Value> loadFile(Input_Package); std::vector<Doc_Value> loadLibrary(Input_Package); Doc_Value storeElements(std::string&, Doc_Value); std::string removeTabs(std::string&); //virtual ~FileLoader(); protected: private: ColorMode curColor; std::string _810library; std::string _850library; std::string _855library; std::string _856library; std::string _857library; std::string ufile; std::string delimiter; }; #endif // FILELOADER_H
[ "noreply@github.com" ]
AtomicAustin.noreply@github.com
580b38d9f6501963d0253c8079be95b7ab3d3d43
4e1f1eb081d177a607ea6f335978676546f6779e
/Exercice5_Liste_Distribuee/ListeDoublementChainee.cpp
69b8273917c36af9f3a74f69f8862256b06a988f
[]
no_license
BenjaminLaschkar/Devoir1_Structure_de_donnee
f3f4e6feefae5ed24a41b2ae9a450bdd583df036
8e04321d4660a0bd93f7671e66c6030c541d05e3
refs/heads/master
2021-09-15T07:26:15.249209
2018-05-28T15:11:40
2018-05-28T15:11:40
133,123,288
2
0
null
null
null
null
WINDOWS-1250
C++
false
false
2,272
cpp
#include "stdafx.h" #include "ListeDoublementChainee.h" #include <iostream> using namespace std; ListeDoublementChainee::ListeDoublementChainee(int i) { debut = new Node(i, NULL, NULL); debut->suivant = debut->precedent = debut; taille = 1; } ListeDoublementChainee::~ListeDoublementChainee() { Node *tmp = this->debut; Node *temp; while (tmp->precedent) { tmp = tmp->precedent; } while (tmp) { temp = tmp->suivant; delete tmp; tmp = temp; } tmp = temp = NULL; } bool ListeDoublementChainee::estVide() { return (this->taille == 0); } bool ListeDoublementChainee::rechercheID(int cherche) { int compteur = 0; Node *tmp = debut; while (tmp->suivant != debut) { if (tmp->ID == cherche) compteur++; tmp = tmp->suivant; } if (compteur > 0) { cout << "'" << cherche << "' a été trouvé " << compteur << " fois." << endl; return true; } else { cout << "'" << cherche << "' n'a pas été trouvé" << endl; return false; } } void ListeDoublementChainee::afficher(bool dir) { if (dir) { Node *tmp = debut; do { cout << tmp->ID; tmp = tmp->precedent; } while (tmp != debut); } else { Node *tmp = debut->suivant; do { cout << tmp->ID; tmp = tmp->suivant; } while (tmp != debut->suivant); } cout << endl; } void ListeDoublementChainee::ajouterID(int ID) { this->debut->ID = ID; } void ListeDoublementChainee::ajouterPrecedent(Node* Precedent) { this->debut->precedent = Precedent; } void ListeDoublementChainee::ajouterSuivant(Node* Suivant) { this->debut->suivant = Suivant; } void ListeDoublementChainee::insertNodeApres(int i) { Node *s = debut->suivant; Node *p = debut; Node *temp = new Node(i, p, s); taille++; } void ListeDoublementChainee::insertNodeAvant(int i) { Node *s = debut; Node *p = debut->precedent; Node *temp = new Node(i, p, s); taille++; } void ListeDoublementChainee::supprimerID(int Cherche, bool all) { // si vrai, il supprime tous les noeuds comprenant la recherche Node *tmp = debut; // si faux, il supprime uniquement le premier noeud while (tmp) { if (tmp->ID == Cherche) { cout << "Suppression " << Cherche << endl; tmp->precedent->suivant = tmp->suivant; tmp->suivant->precedent = tmp->precedent; if (false) return; } tmp = tmp->suivant; } }
[ "rendu.clement@gmail.com" ]
rendu.clement@gmail.com
5d729401371a44b1c26c8d729de3a995abd97d97
7d74a4fab1662506f57be03b165dc7ea03c6ea17
/src/core/renderer/sprite_animation.hpp
20611e24ed53265890b81ececdd7c9e6c4f7337d
[ "MIT" ]
permissive
lowkey42/teamproject
2e9a7ec29e41d3b382ea8384a1051ef0f5fd922b
41e7dfe27161f319d08d02982443720af55398a3
refs/heads/develop
2020-04-04T05:55:47.308995
2016-10-04T20:34:05
2016-10-04T20:34:05
49,599,482
1
0
null
2016-07-14T21:10:40
2016-01-13T20:22:12
C++
UTF-8
C++
false
false
3,844
hpp
/**************************************************************************\ * Animation data for textures and sprites * * ___ * * /\/\ __ _ __ _ _ __ _ _ _ __ ___ /___\_ __ _ _ ___ * * / \ / _` |/ _` | '_ \| | | | '_ ` _ \ // // '_ \| | | / __| * * / /\/\ \ (_| | (_| | | | | |_| | | | | | | / \_//| |_) | |_| \__ \ * * \/ \/\__,_|\__, |_| |_|\__,_|_| |_| |_| \___/ | .__/ \__,_|___/ * * |___/ |_| * * * * Copyright (c) 2016 Florian Oetke * * * * This file is part of MagnumOpus and distributed under the MIT License * * See LICENSE file for details. * \**************************************************************************/ #pragma once #include "texture.hpp" #include "sprite_batch.hpp" #include "material.hpp" #include "../asset/asset_manager.hpp" #include <glm/vec3.hpp> #include <glm/vec4.hpp> #include <string> #include <vector> #include <stdexcept> namespace lux { namespace util { class Message_bus; } namespace renderer { using Animation_clip_id = util::Str_id; class Sprite_animation_state; struct Animation_event { util::Str_id name; void* owner; }; struct Sprite_animation_Clip; class Sprite_animation_set { public: Sprite_animation_set(asset::istream&); auto operator=(Sprite_animation_set&&)noexcept -> Sprite_animation_set&; ~Sprite_animation_set(); private: friend class Sprite_animation_state; struct PImpl; std::unique_ptr<PImpl> _impl; void _register_inst(Sprite_animation_state&)const; void _unregister_inst(Sprite_animation_state&)const; }; using Sprite_animation_set_ptr = asset::Ptr<Sprite_animation_set>; class Sprite_animation_state { public: Sprite_animation_state(void* owner=nullptr, Sprite_animation_set_ptr data={}, Animation_clip_id initial_clip=""_strid); Sprite_animation_state(Sprite_animation_state&&)noexcept; auto operator=(Sprite_animation_state&&)noexcept -> Sprite_animation_state&; ~Sprite_animation_state(); auto owner()noexcept {return _owner;} void update(Time dt, util::Message_bus&); auto uv_rect()const -> glm::vec4; auto material()const -> const Material&; auto animation_set()const {return _animation_set;} void animation_set(Sprite_animation_set_ptr set, Animation_clip_id clip=""_strid); auto get_clip()const noexcept {return _curr_clip_id;} void set_clip(Animation_clip_id id); auto set_clip_if(Animation_clip_id id, Animation_clip_id expected) { if(_curr_clip_id==expected) { set_clip(id); return true; } return false; } void set_next_clip(Animation_clip_id id) { _queued_clip_id = id; } void speed(float factor) { _speed_factor = factor; } auto playing()const noexcept {return _playing;} void reset(); private: void* _owner; Sprite_animation_set_ptr _animation_set; Animation_clip_id _curr_clip_id; util::maybe<Sprite_animation_Clip&> _curr_clip; util::maybe<Animation_clip_id> _queued_clip_id = util::nothing(); int_fast16_t _frame = 0; Time _runtime {}; float _speed_factor = 1.f; bool _playing = true; }; } /* namespace renderer */ namespace asset { template<> struct Loader<renderer::Sprite_animation_set> { static auto load(istream in) { return std::make_shared<renderer::Sprite_animation_set>(in); } static void store(ostream, const renderer::Sprite_animation_set&) { FAIL("NOT IMPLEMENTED!"); } }; } }
[ "mephistopheles@onlinehome.de" ]
mephistopheles@onlinehome.de
37f12bf61166e652202d5c2124304ffdf880af1d
1914d1b5f4616fbe246bfd180020556a442e25a7
/Hackerrank/infinitum11/subset_gcd.cpp
093f370ab74c9aed2ec00135b3ad813301ca8626
[]
no_license
dipkakwani/Puzzles
0d939f636b03d2c96db83cc05779e9ba29060b8f
7ef7d1057d15ba3abd1716ff42b20b5fb276e7d8
refs/heads/master
2021-01-10T12:04:48.588038
2016-05-07T14:02:53
2016-05-07T14:02:53
52,711,668
1
0
null
null
null
null
UTF-8
C++
false
false
1,246
cpp
#include <cstdio> #include <cstdlib> #include <cstring> #include <bits/stdc++.h> #define MAX 100000 using namespace std; typedef long long ll; char memo[1000000001]; ll gcd(ll a, ll b) { return (b == 0)?a:gcd(b, a % b); } ll GCD(ll a[MAX], int start, int end) { ll res = 0; for (int i = start; i != end; i++) res = gcd(res, a[i]); return res; } bool subset_gcd(ll a[MAX], ll k, int start, ll res, int size) { if (memo[res] != '0') return (memo[res] == '1')?0:1; if (res == k) { memo[k] = '2'; return 1; } if (start >= size) { memo[res] = '1'; return 0; } ll g = gcd(res, a[start]); memo[res] = (subset_gcd(a, k, start + 1, res, size) == 1)?'2':'1'; memo[g] = (subset_gcd(a, k, start + 1, g, size) == 1)?'2':'1'; return (memo[res] - '1') || (memo[g] - '1'); } int main() { ll a[MAX]; int t; cin >> t; while (t--) { int n; ll k; cin >> n >> k; for (int i = 0; i < n; i++) cin >> a[i]; memset(memo, '0', *max_element(a, a + n) + 1); if (subset_gcd(a, k, 0, 0, n)) cout << "YES\n"; else cout << "NO\n"; } return 0; }
[ "dipkakwani@gmail.com" ]
dipkakwani@gmail.com
cdd442e0125272152fc3d4fe2c842a3ebf7d1983
c7ef72740216bec011da20f9b404f845be9b00eb
/xic/src/edit/prpedit.cc
7e9047342dd968f46f0c1745b45e0ffc07924446
[ "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
Augertron/xictools
8e27b842ae8fbcaf05c5329a32f79e6b3486fdc5
be58bd6c964f3265ccdc4649c8ba0fabcefd3524
refs/heads/master
2020-05-16T06:50:04.067760
2019-03-15T03:37:26
2019-03-15T03:37:26
null
0
0
null
null
null
null
UTF-8
C++
false
false
123,512
cc
/*========================================================================* * * * Distributed by Whiteley Research Inc., Sunnyvale, California, USA * * http://wrcad.com * * Copyright (C) 2017 Whiteley Research Inc., all rights reserved. * * Author: Stephen R. Whiteley, except as indicated. * * * * As fully as possible recognizing licensing terms and conditions * * imposed by earlier work from which this work was derived, if any, * * this work is released under the Apache License, Version 2.0 (the * * "License"). You may not use this file except in compliance with * * the License, and compliance with inherited licenses which are * * specified in a sub-header below this one if applicable. A copy * * of the License is provided with this distribution, or you may * * obtain a copy of the License at * * * * http://www.apache.org/licenses/LICENSE-2.0 * * * * See the License for the specific language governing permissions * * and limitations under the License. * * * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES * * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON- * * INFRINGEMENT. IN NO EVENT SHALL WHITELEY RESEARCH INCORPORATED * * OR STEPHEN R. WHITELEY BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, * * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE * * USE OR OTHER DEALINGS IN THE SOFTWARE. * * * *========================================================================* * XicTools Integrated Circuit Design System * * * * Xic Integrated Circuit Layout and Schematic Editor * * * *========================================================================* $Id:$ *========================================================================*/ #include "config.h" #include "main.h" #include "edit.h" #include "undolist.h" #include "pcell.h" #include "pcell_params.h" #include "scedif.h" #include "dsp_tkif.h" #include "dsp_inlines.h" #include "cd_propnum.h" #include "cd_lgen.h" #include "fio.h" #include "events.h" #include "menu.h" #include "ebtn_menu.h" #include "promptline.h" #include "errorlog.h" #include "select.h" //---------------------------------------------------------------------- // The prpty command - modify properties of objects using // PopUpProperties() //---------------------------------------------------------------------- namespace { // Add/replace the property specified, do undo list processing. // Used for physical mode properties only. // bool prpty_replace(CDo *odesc, CDs *sdesc, CDp *pdesc, int value, const char *string) { if (!odesc || !string) return (true); if (value == XICP_NOMERGE) { // This property is restricted to boxes, polys, and wires. if (odesc->type() != CDBOX && odesc->type() != CDPOLYGON && odesc->type() != CDWIRE) { Log()->ErrorLog(mh::Properties, "NoMerge applicable to boxes, polygons, and wires only."); return (false); } } else if (value == XICP_EXT_FLATTEN) { // Instances only. if (odesc->type() != CDINSTANCE) { Log()->ErrorLog(mh::Properties, "Flatten applicable to instances only."); return (false); } } CDp *newp = new CDp(string, value); Ulist()->RecordPrptyChange(sdesc, odesc, pdesc, newp); return (true); } // This is passed to the "long text" editor and to its callback. // struct ltobj { ltobj(CDs *s, CDo *o, CDp *p, int v) { sdesc = s; odesc = o; pdesc = p ? p->dup() : 0; value = v; } ~ltobj() { delete pdesc; } CDs *sdesc; CDo *odesc; CDp *pdesc; int value; }; // Doubly linked list of objects to view/process // struct sSel { sSel(CDo *p) { pointer = p; next = prev = 0; } CDo *pointer; sSel *next; sSel *prev; }; inline CDo *od_of(sSel *sl) { return (sl ? sl->pointer : 0); } CDp *prpmatch(CDo*, CDp*, int); int maskof(int); // for Vmask #define NAME_MASK 0x1 #define MODEL_MASK 0x2 #define VALUE_MASK 0x4 #define PARAM_MASK 0x8 #define OTHER_MASK 0x10 #define NOPHYS_MASK 0x20 #define FLATTEN_MASK 0x40 #define NOSYMB_MASK 0x80 #define RANGE_MASK 0x100 #define DEVREF_MASK 0x200 namespace ed_prpedit { enum { PRPquiescent, PRPadding, PRPdeleting }; typedef unsigned char PRPmodif; struct PrptyState : public CmdState { PrptyState(const char*, const char*); virtual ~PrptyState(); void setCaller(GRobject c) { Caller = c; } // Control interface, wrapped into cEdit. bool pSetup(); bool pCallback(CDo*); void pRelist(); void pSetGlobal(bool); void pSetInfoMode(bool b) { InfoMode = b; } void pUpdateList(CDo*, CDo*); void pAdd(int); void pEdit(Ptxt*); void pRemove(Ptxt*); void b1down() { cEventHdlr::sel_b1down(); } void b1up(); void desel(); void esc(); bool key(int, const char*, int); void undo(); void redo(); static void ltcallback(hyList*, void*); private: void prp_showselect(bool); bool prp_get_prompt(bool, CDo*, char*); void prp_updtext(sSel*); void prp_add_elec(Ptxt*, int, bool); void prp_add_elec_noglob(); void prp_add_elec_glob_all(); void prp_add_elec_glob_seq(); void prp_add_phys(Ptxt*, int, bool); void prp_add_phys_noglob(); void prp_add_phys_glob_all(); void prp_add_phys_glob_seq(); bool prp_get_add_type(bool); bool prp_get_string(bool, bool); void prp_rm(Ptxt*); bool prp_get_rm_type(bool); void prp_remove(sSel*, CDp*); static int btn_callback(Ptxt*); static void down_callback(); static void up_callback(); void message() { PL()->ShowPrompt(msg1); } void SetLevel1(bool show) { Level = 1; if (show) message(); } void SetLevel2() { Level = 2; } GRobject Caller; bool GotOne; PRPmodif Modifying; // set when in adprp or rmprp bool Global; // global mode add/remove bool InfoMode; // use info window pop-up bool ShowAllSel; // show all objects in list as selected sSel *Shead; sSel *Scur; char Types[8]; BBox AOI; int Value; // current property value for adprp, rmprp int Vmask; // type vector for rmprp CDp *SelPrp; // selected property struct { char *string; hyList *hyl; } Udata; // property string for adprp, rmprp static const char *msg1; static const char *nosel; }; PrptyState *PrptyCmd; } } using namespace ed_prpedit; const char *PrptyState::msg1 = "Select objects"; const char *PrptyState::nosel = "No objects have been selected."; namespace { // While the prpty command is active, this code is called from the // desel button. It deselects all selected objects. // void prptyDesel(CmdDesc*) { // Nothing to do, the work is done in PrptyCmd::desel. } // Reset the desel button when active to property specific action. // void switchPropertiesMenu(bool state) { if (state) XM()->RegisterDeselOverride(&prptyDesel); else XM()->RegisterDeselOverride(0); } } // Menu function for prpty command. If objects have been selected, // link them into a new sSel list, and set Level2, where each object // is highlighted and properties displayed. The arrow keys cycle // through this list. Otherwise set Level1, which enables selection // of objects. // void cEdit::propertiesExec(CmdDesc *cmd) { if (PrptyCmd) { PrptyCmd->esc(); return; } Deselector ds(cmd); if (noEditing()) return; if (!XM()->CheckCurCell(true, false, DSP()->CurMode())) return; if (DSP()->CurMode() == Electrical && Menu()->MenuButtonStatus("main", MenuSYMBL) == 1) { PL()->ShowPrompt("Can't show properties in symbolic mode."); return; } switchPropertiesMenu(true); ED()->PopUpProperties(0, MODE_ON, PRPinactive); PrptyCmd = new PrptyState("PRPTY", "xic:prpty"); PrptyCmd->setCaller(cmd ? cmd->caller : 0); if (!PrptyCmd->pSetup()) { delete PrptyCmd; return; } ds.clear(); } // For graphics. // CmdState* cEdit::prptyCmd() { return (PrptyCmd); } bool cEdit::prptyCallback(CDo *odesc) { if (PrptyCmd) return (PrptyCmd->pCallback(odesc)); return (false); } // Update the properties lists. // void cEdit::prptyRelist() { if (PrptyCmd) PrptyCmd->pRelist(); PopUpCellProperties(MODE_UPD); } void cEdit::prptySetGlobal(bool glob) { if (PrptyCmd) PrptyCmd->pSetGlobal(glob); } // Set/unset info mode (from the pop-up). // void cEdit::prptySetInfoMode(bool b) { if (PrptyCmd) PrptyCmd->pSetInfoMode(b); } void cEdit::prptyUpdateList(CDo *odesc, CDo *onew) { if (PrptyCmd) PrptyCmd->pUpdateList(odesc, onew); } void cEdit::prptyAdd(int which) { if (PrptyCmd) PrptyCmd->pAdd(which); } void cEdit::prptyEdit(Ptxt *line) { if (PrptyCmd) PrptyCmd->pEdit(line); } void cEdit::prptyRemove(Ptxt *line) { if (PrptyCmd) PrptyCmd->pRemove(line); } // End of cEdit functions for PrptyState. PrptyState::PrptyState(const char *nm, const char *hk) : CmdState(nm, hk) { Caller = 0; if (DSP()->CurMode() == Electrical) { ScedIf()->connectAll(false); Types[0] = CDINSTANCE; Types[1] = CDWIRE; Types[2] = CDLABEL; Types[3] = '\0'; } else strcpy(Types, Selections.selectTypes()); GotOne = Selections.hasTypes(CurCell(), Types, false); if (!GotOne) SetLevel1(false); else SetLevel2(); Modifying = PRPquiescent; Global = false; InfoMode = false; ShowAllSel = false; Shead = Scur = 0; Value = Vmask = 0; SelPrp = 0; Udata.string = 0; Udata.hyl = 0; } PrptyState::~PrptyState() { PrptyCmd = 0; } bool PrptyState::pSetup() { if (!EV()->PushCallback(this)) { switchPropertiesMenu(false); return (false); } sSel *sd = 0, *sd0 = 0; sSelGen sg(Selections, CurCell()); CDo *od; while ((od = sg.next()) != 0) { if (!strchr(Types, od->type())) continue; if (!sd) sd = sd0 = new sSel(od); else { sd->next = new sSel(od); sd->next->prev = sd; sd = sd->next; } } if (!ShowAllSel) Selections.deselectTypes(CurCell(), 0); Shead = Scur = sd0; ED()->PopUpProperties(od_of(Scur), MODE_UPD, PRPactive); if (!Scur) message(); return (true); } // This function is called by the editor if the user points at an // object on screen. This pops up a secondary window listing the // properties of the "alternate" object, allowing cut/paste. A // true return suppresses hypertext return in editor. // bool PrptyState::pCallback(CDo *odesc) { if (InfoMode || (EV()->Cursor().get_downstate() & (GR_SHIFT_MASK | GR_CONTROL_MASK))) { if (odesc && XM()->IsBoundaryVisible(CurCell(), odesc)) ED()->PopUpPropertyInfo(odesc, MODE_ON); return (true); } if (Modifying == PRPdeleting) return (true); return (false); } void PrptyState::pRelist() { CDo *od = Scur ? Scur->pointer : 0; ED()->PopUpProperties(od, MODE_UPD, PRPnochange); ED()->PopUpPropertyInfo(0, MODE_UPD); } // Set/unset global mode (from the pop-up). // void PrptyState::pSetGlobal(bool glob) { Global = glob; if (!ShowAllSel) { CDs *cursd = CurCell(); if (glob) { for (sSel *s = Shead; s; s = s->next) { // Skip display, then revert to vanilla. Selections.insertObject(cursd, s->pointer, true); s->pointer->set_state(CDobjVanilla); } } else Selections.deselectTypes(cursd, 0); prp_showselect(true); } } // If an object is being deleted, remove it from the list or replace // it with onew. This is needed if a device label is updated, and the // label is in the list, and for objects changing due to applied pseudo- // properties. // void PrptyState::pUpdateList(CDo *odesc, CDo *onew) { for (sSel *sd = Shead; sd; sd = sd->next) { if (sd->pointer == odesc) { if (onew) sd->pointer = onew; else { if (sd == Scur) { if (sd->next) Scur = sd->next; else if (sd->prev) Scur = sd->prev; else Scur = 0; } if (sd->prev) sd->prev->next = sd->next; else Shead = sd->next; if (sd->next) sd->next->prev = sd->prev; delete sd; } break; } } if (Global) { sSelGen sg(Selections, CurCell()); CDo *od; while ((od = sg.next()) != 0) { if (od == odesc) { if (onew) { // Keep state, replace sets to selected. CDobjState st = onew->state(); sg.replace(onew); onew->set_state(st); } else sg.remove(); break; } } } ED()->PropertyPurge(odesc, Scur ? Scur->pointer : 0); ED()->PropertyInfoPurge(odesc, onew); } void PrptyState::pAdd(int which) { PL()->RegisterArrowKeyCallbacks(0, 0); ED()->RegisterPrptyBtnCallback(0); if (DSP()->CurMode() == Physical) prp_add_phys(0, which, false); else prp_add_elec(0, which, false); if (PrptyCmd) pRelist(); } // Edit the property given in line. // void PrptyState::pEdit(Ptxt *line) { PL()->RegisterArrowKeyCallbacks(0, 0); ED()->RegisterPrptyBtnCallback(0); if (DSP()->CurMode() == Physical) prp_add_phys(line, -1, true); else prp_add_elec(line, -1, true); if (PrptyCmd) pRelist(); } // Remove the property whose string appears in line, or if in global // mode remove properties from all objects in the object list. // void PrptyState::pRemove(Ptxt *line) { PL()->RegisterArrowKeyCallbacks(0, 0); ED()->RegisterPrptyBtnCallback(0); prp_rm(line); } void PrptyState::b1up() { if (InfoMode || (EV()->Cursor().get_downstate() & (GR_SHIFT_MASK | GR_CONTROL_MASK))) { CDol *sl0; if (!cEventHdlr::sel_b1up(&AOI, Types, &sl0)) return; if (!sl0) return; CDo *od = 0; for (CDol *sl = sl0; sl; sl = sl->next) { if (XM()->IsBoundaryVisible(CurCell(), sl->odesc)) { od = sl->odesc; break; } } CDol::destroy(sl0); if (od) ED()->PopUpPropertyInfo(od, MODE_ON); return; } sSel *sd = 0, *sd0 = 0; if (Level == 1) { if (!Global && !ShowAllSel) { CDol *sl0; if (!cEventHdlr::sel_b1up(&AOI, Types, &sl0)) return; if (!sl0) return; for (CDol *sl = sl0; sl; sl = sl->next) { if (!sd) sd = sd0 = new sSel(sl->odesc); else { sd->next = new sSel(sl->odesc); sd->next->prev = sd; sd = sd->next; } } CDol::destroy(sl0); } else { if (!cEventHdlr::sel_b1up(&AOI, Types, 0)) return; sSelGen sg(Selections, CurCell()); CDo *od; while ((od = sg.next()) != 0) { if (!sd) sd = sd0 = new sSel(od); else { sd->next = new sSel(od); sd->next->prev = sd; sd = sd->next; } } if (!sd) return; } Shead = Scur = sd0; ED()->PopUpProperties(od_of(Scur), MODE_UPD, PRPnochange); SetLevel2(); } else { sSel *newsel = 0, *n0 = 0; CDol *sl0; if (!cEventHdlr::sel_b1up(&AOI, Types, &sl0)) return; if (!sl0) return; for (CDol *sl = sl0; sl; sl = sl->next) { // is object already in list? for (sd = Shead ; sd; sd = sd->next) if (sd->pointer == sl->odesc) break; if (sd) { // Object is already in list if (!sl->next && !newsel) { // This is the last new object, and no other new objects // were found to not be in the existing list. // if (sd == Scur && (sd->prev || sd->next)) { // This is also the currently marked object, // deselect and remove from list. // Selections.removeObject(CurCell(), sd->pointer); if (sd->prev) sd->prev->next = sd->next; else Shead = sd->next; if (sd->next) { sd->next->prev = sd->prev; Scur = sd->next; } else Scur = sd->prev; delete sd; } else // Make the new object the currently marked object Scur = sd; CDol::destroy(sl0); ED()->PopUpProperties(od_of(Scur), MODE_UPD, PRPnochange); return; } continue; } else { // Object not in list. Select it, and add it to the "new" // list. // if (Global || ShowAllSel) { sl->odesc->set_state(CDobjVanilla); Selections.insertObject(CurCell(), sl->odesc); } if (newsel == 0) newsel = n0 = new sSel(sl->odesc); else { newsel->next = new sSel(sl->odesc); newsel->next->prev = newsel; newsel = newsel->next; } } } // // If we get here, a new object was found. Link the new list // into the present list at the present position. Advance the // present position to the first new object. It is possible that // Scur/Shead is null, if objects have been merged away through // pseudo-props // CDol::destroy(sl0); n0->prev = Scur; if (Scur) { newsel->next = Scur->next; Scur->next = n0; } if (newsel->next) newsel->next->prev = newsel; Scur = n0; if (!Shead) Shead = Scur; ED()->PopUpProperties(od_of(Scur), MODE_UPD, PRPnochange); } } // While the prpty command is active, this code is called from the // desel button. It deselects all selected objects. // void PrptyState::desel() { if (!Scur) return; ED()->PopUpProperties(0, MODE_UPD, PRPnochange); while ((Scur = Shead) != 0) { Shead = Scur->next; Selections.removeObject(CurCell(), Scur->pointer); delete Scur; } Scur = Shead = 0; if (EV()->CurCmd() && EV()->CurCmd() != this) EV()->CurCmd()->esc(); SetLevel1(true); } void PrptyState::esc() { PL()->AbortLongText(); cEventHdlr::sel_esc(); Selections.deselectTypes(CurCell(), 0); while ((Scur = Shead)) { Shead = Scur->next; delete Scur; } Scur = Shead = 0; PL()->ErasePrompt(); EV()->PopCallback(this); Menu()->Deselect(Caller); switchPropertiesMenu(false); ED()->PopUpPropertyInfo(0, MODE_OFF); ED()->PopUpProperties(0, MODE_UPD, PRPinactive); delete this; } // If the user points at an object, it is selected, added to the sSel // list if not already there, and becomes the currently marked object. // If it is already the currently marked object, deselect it and // remove it from the list. // Look for arrow keys, which cycle the currently marked object // through the list. Also respond to accelerators for the button // commands. // bool PrptyState::key(int code, const char*, int mstate) { if (Level == 1) return (false); if (code == LEFT_KEY || code == DOWN_KEY) { if (mstate & (GR_SHIFT_MASK | GR_CONTROL_MASK)) return (false); if (!Scur) return (true); if (Scur->prev) Scur = Scur->prev; else { while (Scur->next) Scur = Scur->next; } ED()->PopUpProperties(od_of(Scur), MODE_UPD, PRPnochange); return (true); } if (code == RIGHT_KEY || code == UP_KEY) { if (mstate & (GR_SHIFT_MASK | GR_CONTROL_MASK)) return (false); if (!Scur) return (true); if (Scur->next) Scur = Scur->next; else { while (Scur->prev) Scur = Scur->prev; } ED()->PopUpProperties(od_of(Scur), MODE_UPD, PRPnochange); return (true); } return (false); } // Undo the last adprp or rmprp, set currently marked object to // undone object, if not global. // void PrptyState::undo() { if (Level == 1) cEventHdlr::sel_undo(); else { Oper *cur = Ulist()->UndoList(); if (cur && (!strcmp(cur->cmd(), "adprp") || !strcmp(cur->cmd(), "rmprp"))) { if (cur->prp_list()) { CDo *odesc = cur->prp_list()->odesc(); bool global = (cur->prp_list()->next_chg() != 0); if (!cEventHdlr::sel_undo() && !global) { sSel *sd; for (sd = Shead; sd; sd = sd->next) if (sd->pointer == odesc) break; if (sd) { Scur = sd; ED()->PopUpProperties(od_of(Scur), MODE_UPD, PRPnochange); } } } else if (cur->obj_list()) { if (!cEventHdlr::sel_undo() && Ulist()->HasRedo()) { Ochg *xc = Ulist()->RedoList()->obj_list(); while (xc) { for (sSel *sd = Shead; sd; sd = sd->next) { if (xc->oadd() && xc->odel() && sd->pointer == xc->odel()) { sd->pointer = xc->oadd(); break; } } xc = xc->next_chg(); } ED()->PopUpProperties(od_of(Scur), MODE_UPD, PRPnochange); } } else cEventHdlr::sel_undo(); } else { // Limit undo to property setting operations if (cur && (!strcmp(cur->cmd(), "set") || !strcmp(cur->cmd(), "ddprp"))) // "set" comes from !set device@param Ulist()->UndoOperation(); else { Ulist()->RotateUndo(0); cEventHdlr::sel_undo(); Ulist()->RotateUndo(cur); } } } } // Redo the last adprp or rmprp, set currently marked object to // object redone, if not global. // void PrptyState::redo() { if (Level == 1) cEventHdlr::sel_redo(); else { Oper *cur = Ulist()->RedoList(); if (cur && (!strcmp(cur->cmd(), "adprp") || !strcmp(cur->cmd(), "rmprp"))) { if (cur->prp_list()) { CDo *odesc = cur->prp_list()->odesc(); bool global = (cur->prp_list()->next_chg() != 0); Ulist()->RedoOperation(); if (!global) { sSel *sd; for (sd = Shead; sd; sd = sd->next) if (sd->pointer == odesc) break; if (sd) { Scur = sd; ED()->PopUpProperties(od_of(Scur), MODE_UPD, PRPnochange); } } } else if (cur->obj_list()) { Ulist()->RedoOperation(); if (Ulist()->HasUndo()) { Ochg *xc = Ulist()->UndoList()->obj_list(); while (xc) { for (sSel *sd = Shead; sd; sd = sd->next) { if (xc->oadd() && xc->odel() && sd->pointer == xc->odel()) { sd->pointer = xc->oadd(); break; } } xc = xc->next_chg(); } ED()->PopUpProperties(od_of(Scur), MODE_UPD, PRPnochange); } } else Ulist()->RedoOperation(); } else { // Limit redo to property setting operations if (cur && (!strcmp(cur->cmd(), "set") || !strcmp(cur->cmd(), "ddprp"))) Ulist()->RedoOperation(); else { Ulist()->RotateRedo(0); cEventHdlr::sel_redo(); Ulist()->RotateRedo(cur); } } } } // Static function. // Asynchronous property change from text editor for physical // mode. Since physical cell properties are ascii strings, we // have to explicitly change the property when done editing. // void PrptyState::ltcallback(hyList *h, void *arg) { ltobj *lt = (ltobj*)arg; if (PrptyCmd) PrptyCmd->prp_showselect(false); CDs *cursdp = CurCell(Physical); if (!cursdp) return; Ulist()->ListCheck("adprp", cursdp, false); char *string; if (h->ref_type() == HLrefLongText) string = hyList::string(h, HYcvAscii, true); else string = hyList::string(h, HYcvPlain, true); hyList::destroy(h); if (PrptyCmd && PrptyCmd->Global) { for (sSel *sd = PrptyCmd->Shead; sd; sd = sd->next) { DSP()->ShowOdescPhysProperties(sd->pointer, ERASE); prpty_replace(sd->pointer, cursdp, prpmatch(sd->pointer, lt->pdesc, lt->value), lt->value, string); } Ulist()->CommitChanges(true); for (sSel *sd = PrptyCmd->Shead; sd; sd = sd->next) DSP()->ShowOdescPhysProperties(sd->pointer, DISPLAY); } else { DSP()->ShowOdescPhysProperties(lt->odesc, ERASE); prpty_replace(lt->odesc, cursdp, prpmatch(lt->odesc, lt->pdesc, lt->value), lt->value, string); Ulist()->CommitChanges(true); DSP()->ShowOdescPhysProperties(lt->odesc, DISPLAY); } delete [] string; delete lt; if (PrptyCmd) PrptyCmd->prp_showselect(true); } // Turn on/off the display of selected objects other than the currently // marked object. // void PrptyState::prp_showselect(bool show) { if (Global || ShowAllSel) { if (!show) for (sSel *s = Shead; s; s = s->next) Selections.showUnselected(CurCell(), s->pointer); else for (sSel *s = Shead; s; s = s->next) Selections.showSelected(CurCell(), s->pointer); } } // Create the prompt used to solicit the property string. // Return the existing property, if applicable. // The prompt is returned in buf. // The odesc argument is the source of the returned prpty desc. // If true is returned, don't prompt but use string in buf. // bool PrptyState::prp_get_prompt(bool global, CDo *odesc, char *buf) { const char *glmsg = "Global %s? "; if (DSP()->CurMode() == Electrical) { // use the existing string as default switch (Value) { case P_NAME: if (global) sprintf(buf, glmsg, "name"); else strcpy(buf, "Name? "); break; case P_MODEL: if (global) sprintf(buf, glmsg, "model"); else strcpy(buf, "Model name? "); break; case P_VALUE: if (global) sprintf(buf, glmsg, "value"); else strcpy(buf, "Value? "); break; case P_PARAM: if (global) sprintf(buf, glmsg, "parameter string"); else strcpy(buf, "Parameter string? "); break; case P_OTHER: if (global) sprintf(buf, glmsg, "string"); else strcpy(buf, "Property string? "); break; case P_NOPHYS: strcpy(buf, "nophys"); return (true); case P_FLATTEN: strcpy(buf, "flatten"); return (true); case P_SYMBLC: strcpy(buf, "0"); return (true); case P_RANGE: if (global) sprintf(buf, glmsg, "range"); else strcpy(buf, "Range? (2 unsigned integers, begin and end) "); break; case P_DEVREF: if (global) sprintf(buf, glmsg, "reference device string"); else strcpy(buf, "Reference device String? "); break; default: Value = P_MODEL; return (prp_get_prompt(global, odesc, buf)); } } else { if (global) sprintf(buf, "Global property %d string? ", Value); else sprintf(buf, "Property %d string? ", Value); } return (false); } // Push new text into executing input window. // void PrptyState::prp_updtext(sSel *sl) { char buf[256]; if (!sl || !sl->pointer) return; CDs *cursd = CurCell(); if (!cursd) return; prp_get_prompt(false, sl->pointer, buf); CDp *pdesc = SelPrp; if (pdesc && pdesc->value() != Value) // shouldn't happen Value = pdesc->value(); if (DSP()->CurMode() == Electrical) { bool use_lt = false; if (Value == P_VALUE || Value == P_PARAM || Value == P_OTHER) use_lt = true; if (pdesc) { if (Value == P_NAME) { // don't show default name if (((CDp_cname*)pdesc)->assigned_name()) { hyList *h = new hyList(0, ((CDp_cname*)pdesc)->assigned_name(), HYcvPlain); PL()->EditHypertextPrompt(buf, h, false, PLedUpdate); hyList::destroy(h); } else PL()->EditHypertextPrompt(buf, 0, false, PLedUpdate); } else { switch (Value) { case P_MODEL: case P_VALUE: case P_PARAM: case P_OTHER: case P_DEVREF: PL()->EditHypertextPrompt(buf, ((CDp_user*)pdesc)->data(), use_lt, PLedUpdate); break; default: // shouldn't be here return; } } } else PL()->EditHypertextPrompt(buf, 0, use_lt, PLedUpdate); } else { bool use_lt = true; hyList *hp = 0; if (!pdesc && Value >= XprpType && Value < XprpEnd) { char *s = XM()->GetPseudoProp(sl->pointer, Value); hp = new hyList(cursd, s, HYcvPlain); delete [] s; use_lt = false; } else if (pdesc && pdesc->string() && *pdesc->string()) { const char *lttok = HYtokPre HYtokLT HYtokSuf; if (lstring::prefix(lttok, pdesc->string())) { if (use_lt) hp = new hyList(cursd, pdesc->string(), HYcvAscii); else hp = new hyList(cursd, pdesc->string() + strlen(lttok), HYcvPlain); } else hp = new hyList(cursd, pdesc->string(), HYcvPlain); } PL()->EditHypertextPrompt(buf, hp, use_lt, PLedUpdate); hyList::destroy(hp); } } namespace { // These are the properties cycled through with the arrow keys // when editing. In physical mode, anything in the list is fine. // bool is_prp_editable(const CDp *pd) { if (DSP()->CurMode() == Electrical) { if (!pd) return (false); switch (pd->value()) { case P_NAME: case P_MODEL: case P_VALUE: case P_PARAM: case P_OTHER: case P_RANGE: case P_DEVREF: return (true); default: return (false); } } return (true); } } namespace { // Return true is the argument is a valid string for a P_NAME // property. The first character must be alpha, and we can't // include any SPICE token separators. // bool nameprp_ok(const char *str) { if (!str) return (false); if (!isalpha(*str)) return (false); str++; while (*str) { if (isspace(*str) || *str == '=' || *str == ',') return (false); str++; } return (true); } } // Add: line = 0, which is always > 0, edit false // Edit: line 0 or not, which is always -1, edit true // void PrptyState::prp_add_elec(Ptxt *line, int which, bool edit) { if (!Shead) { PL()->ShowPrompt(nosel); return; } if (!CurCell(Electrical) || DSP()->CurMode() != Electrical) return; if (!line) { switch (which) { case P_NAME: case P_MODEL: case P_VALUE: case P_PARAM: case P_RANGE: case P_DEVREF: line = ED()->PropertySelect(which); break; default: if (which < 0) line = ED()->PropertyCycle(0, &is_prp_editable, false); break; } } if (line && !line->prpty()) line = 0; Value = which; SelPrp = 0; if (line) { SelPrp = line->prpty(); Value = SelPrp->value(); } if (!SelPrp && edit) { PL()->ShowPrompt("No editable property found - use Add."); Value = -1; return; } if (Value < 0) return; switch (Value) { case P_NOPHYS: case P_FLATTEN: case P_SYMBLC: if (!edit) break; // fallthrough default: PL()->ShowPrompt("This property can not be edited."); return; case P_NAME: case P_MODEL: case P_VALUE: case P_PARAM: case P_OTHER: case P_RANGE: case P_DEVREF: case XICP_PC_PARAMS: break; } if (Scur->pointer->type() != CDINSTANCE) { PL()->ShowPrompt("Can't modify properties of current object."); return; } CDc *cdesc = OCALL(Scur->pointer); CDs *msdesc = cdesc->masterCell(); if (!msdesc) { PL()->ShowPrompt("Internal: instance has no cell pointer!"); return; } if (!msdesc->isDevice()) { switch (Value) { case P_NAME: case P_PARAM: case P_OTHER: case P_NOPHYS: case P_FLATTEN: case P_SYMBLC: case P_RANGE: break; default: PL()->ShowPrompt("Can't add this property type to subcircuit."); return; } } else if (Value == P_FLATTEN || Value == P_SYMBLC) { PL()->ShowPrompt("Can't add this property type to device."); return; } if (Value == P_NAME && Global && !edit) { PL()->ShowPrompt("You don't want to set all names the same."); return; } Modifying = PRPadding; prp_showselect(false); if (edit) { PL()->RegisterArrowKeyCallbacks(down_callback, up_callback); ED()->RegisterPrptyBtnCallback(btn_callback); } bool ret = prp_get_string(false, edit); if (edit) { PL()->RegisterArrowKeyCallbacks(0, 0); ED()->RegisterPrptyBtnCallback(0); } if (!PrptyCmd) return; if (ret && Udata.hyl) { if (Value == P_NAME) { char *pstr = hyList::string(Udata.hyl, HYcvPlain, false); if (!nameprp_ok(pstr)) { delete [] pstr; PL()->ShowPrompt( "Bad name, must start with alpha, exclude SPICE token " "separators space, ',' and '='."); return; } delete [] pstr; } if (Global) { if (edit) prp_add_elec_glob_seq(); else prp_add_elec_glob_all(); } else prp_add_elec_noglob(); } if (PrptyCmd) { if (Scur) prp_showselect(true); SelPrp = 0; Value = -1; Modifying = PRPquiescent; } } void PrptyState::prp_add_elec_noglob() { CDs *cursde = CurCell(Electrical); if (!cursde) return; Ulist()->ListCheck("adprp", cursde, false); CDc *cdesc = OCALL(Scur->pointer); CDp *pdesc = SelPrp; if (!pdesc && Value != P_OTHER) pdesc = cdesc->prpty(Value); ED()->prptyModify(cdesc, pdesc, Value, 0, Udata.hyl); Ulist()->CommitChanges(true); // Might have exited during modify. if (PrptyCmd) { hyList::destroy(Udata.hyl); Udata.hyl = 0; } } void PrptyState::prp_add_elec_glob_all() { CDs *cursde = CurCell(Electrical); if (!cursde) return; Ulist()->ListCheck("adprp", cursde, false); bool changemade = false; for (sSel *sd = Shead; sd; sd = sd->next) { if (sd->pointer->type() != CDINSTANCE) continue; CDc *cdesc = OCALL(sd->pointer); CDs *msdesc = cdesc->masterCell(); if (!msdesc) continue; if (!msdesc->isDevice() && Value != P_NAME && Value != P_PARAM && Value != P_RANGE && Value != P_FLATTEN) continue; ED()->prptyModify(cdesc, prpmatch(sd->pointer, 0, Value), Value, 0, Udata.hyl); changemade = true; // Might have exited during modify. if (!PrptyCmd) break; } if (changemade) Ulist()->CommitChanges(true); if (PrptyCmd) { hyList::destroy(Udata.hyl); Udata.hyl = 0; } } void PrptyState::prp_add_elec_glob_seq() { CDs *cursde = CurCell(Electrical); if (!cursde) return; // rotate the list so that Scur is head if (Scur != Shead) { sSel *s = Scur; while (s->next) s = s->next; s->next = Shead; Shead->prev = s; while (s->next != Scur) s = s->next; s->next = 0; Shead = Scur; Shead->prev = 0; } bool changemade = false; bool first = true; for (sSel *sd = Shead; sd; sd = sd->next) { bool ret = true; CDc *cdesc = OCALL(sd->pointer); if (!first) { if (sd->pointer->type() != CDINSTANCE) continue; CDs *msdesc = cdesc->masterCell(); if (!msdesc) continue; if (!msdesc->isDevice() && Value != P_NAME && Value != P_PARAM && Value != P_RANGE && Value != P_FLATTEN) continue; Scur = sd; ED()->PopUpProperties(od_of(Scur), MODE_UPD, PRPnochange); ret = prp_get_string(false, false); if (!PrptyCmd) return; } if (!ret || !Udata.hyl) break; if (first) { Ulist()->ListCheck("adprp", cursde, false); first = false; } ED()->prptyModify(cdesc, prpmatch(cdesc, SelPrp, Value), Value, 0, Udata.hyl); changemade = true; // Might have exited during modify. if (PrptyCmd) { hyList::destroy(Udata.hyl); Udata.hyl = 0; } else break; } if (changemade) Ulist()->CommitChanges(true); if (PrptyCmd) Scur = Shead; } // Add: line = 0, which is always -1, edit false // Edit: line 0 or not, which is always -1, edit true // void PrptyState::prp_add_phys(Ptxt *line, int which, bool edit) { if (!Shead) { PL()->ShowPrompt(nosel); return; } if (!CurCell(Physical) || DSP()->CurMode() != Physical) return; if (!line && edit) line = ED()->PropertyCycle(0, &is_prp_editable, false); bool phony_add = false; if (line && !line->prpty()) { // If pseudo-property in edit mode, treat as Add... const char *s = strchr(line->head(), '('); if (s) { s++; Value = atoi(s); if (prpty_pseudo(Value)) { SelPrp = 0; edit = false; phony_add = true; } } // shouldn't get here if (!phony_add) { PL()->ShowPrompt("Property not editable."); Value = -1; return; } } if (!phony_add) { SelPrp = 0; Value = which; if (line) { SelPrp = line->prpty(); Value = SelPrp->value(); } if (Value == XICP_PC || prpty_reserved(Value) || (edit && prpty_pseudo(Value))) { PL()->ShowPrompt("This property can not be edited."); SelPrp = 0; Value = -1; return; } if (!SelPrp && edit) { PL()->ShowPrompt( "No editable property selected - select first or use Add."); Value = -1; return; } } Modifying = PRPadding; prp_showselect(false); bool ret = true; if (Value < 0) { ret = prp_get_add_type(false); if (!PrptyCmd) return; } if (Value == XICP_PC || prpty_reserved(Value)) { PL()->ShowPrompt("This property can't be set by user."); SelPrp = 0; Value = -1; return; } if (ret && Scur && Value >= 0) { if (Value == XICP_NOMERGE) { if (edit) { PL()->ShowPrompt("Property not editable."); return; } delete [] Udata.string; Udata.string = lstring::copy("nomerge"); if (Global) prp_add_phys_glob_all(); else prp_add_phys_noglob(); } else if (Value == XICP_EXT_FLATTEN) { if (edit) { PL()->ShowPrompt("Property not editable."); return; } delete [] Udata.string; Udata.string = lstring::copy("flatten"); if (Global) prp_add_phys_glob_all(); else prp_add_phys_noglob(); } else { if (edit) { PL()->RegisterArrowKeyCallbacks(down_callback, up_callback); ED()->RegisterPrptyBtnCallback(btn_callback); } ret = prp_get_string(false, edit); if (edit) { PL()->RegisterArrowKeyCallbacks(0, 0); ED()->RegisterPrptyBtnCallback(0); } if (!PrptyCmd) return; if (!ret || !Udata.string) { delete [] Udata.string; Udata.string = 0; } else { if (Global) { if (edit) prp_add_phys_glob_seq(); else prp_add_phys_glob_all(); } else prp_add_phys_noglob(); } } } if (PrptyCmd) { if (Scur) prp_showselect(true); SelPrp = 0; Value = -1; Modifying = PRPquiescent; } } void PrptyState::prp_add_phys_noglob() { CDs *cursdp = CurCell(Physical); if (!cursdp) return; Ulist()->ListCheck("adprp", cursdp, false); DSP()->ShowOdescPhysProperties(Scur->pointer, ERASE); prpty_replace(Scur->pointer, cursdp, SelPrp, Value, Udata.string); // Explicit redraw needed for pseudo-properties. // Might have exited during modify. Ulist()->CommitChanges(true); if (PrptyCmd) { delete [] Udata.string; Udata.string = 0; if (Scur) DSP()->ShowOdescPhysProperties(Scur->pointer, DISPLAY); } } void PrptyState::prp_add_phys_glob_all() { CDs *cursdp = CurCell(Physical); if (!cursdp) return; Ulist()->ListCheck("adprp", cursdp, false); sSel *sn; for (sSel *sd = Shead; sd; sd = sn) { sn = sd->next; prpty_replace(sd->pointer, cursdp, 0, Value, Udata.string); // Might have exited during modify. if (!PrptyCmd) break; } if (PrptyCmd) { delete [] Udata.string; Udata.string = 0; for (sSel *sd = Shead; sd; sd = sd->next) DSP()->ShowOdescPhysProperties(sd->pointer, ERASE); } // Explicit redraw needed for pseudo-properties Ulist()->CommitChanges(true); if (PrptyCmd) { for (sSel *sd = Shead; sd; sd = sd->next) DSP()->ShowOdescPhysProperties(sd->pointer, DISPLAY); } } void PrptyState::prp_add_phys_glob_seq() { CDs *cursdp = CurCell(Physical); if (!cursdp) return; // rotate the list so that Scur is head if (Scur != Shead) { sSel *s = Scur; while (s->next) s = s->next; s->next = Shead; Shead->prev = s; while (s->next != Scur) s = s->next; s->next = 0; Shead = Scur; Shead->prev = 0; } bool changemade = false; bool first = true; sSel *sn; for (sSel *sd = Shead; sd; sd = sn) { sn = sd->next; bool ret = true; if (!first) { Scur = sd; ED()->PopUpProperties(od_of(Scur), MODE_UPD, PRPnochange); ret = prp_get_string(false, false); if (!PrptyCmd) return; } if (!ret || !Udata.string) break; if (first) { Ulist()->ListCheck("adprp", cursdp, false); first = false; } prpty_replace(sd->pointer, cursdp, prpmatch(sd->pointer, SelPrp, Value), Value, Udata.string); changemade = true; // Might have exited during modify. if (PrptyCmd) { delete [] Udata.string; Udata.string = 0; } else break; } if (PrptyCmd) Scur = Shead; if (changemade) { if (PrptyCmd) { for (sSel *sd = Shead; sd; sd = sd->next) DSP()->ShowOdescPhysProperties(sd->pointer, ERASE); } // Explicit redraw needed for pseudo-properties Ulist()->CommitChanges(true); if (PrptyCmd) { for (sSel *sd = Shead; sd; sd = sd->next) DSP()->ShowOdescPhysProperties(sd->pointer, DISPLAY); } } } // Solicit from the user the type or value of a property being added. // Return false if Esc entered, true otherwise. The value is put into // Value, which is -1 if no value was recognized. // bool PrptyState::prp_get_add_type(bool global) { const char *msg = global ? "Press Enter, or give property number to add to selected objects? " : "Property number? "; char tbuf[64]; *tbuf = '\0'; if (!global && Value >= 0) sprintf(tbuf, "%d", Value); Value = -1; char *in = PL()->EditPrompt(msg, (global || !*tbuf) ? 0 : tbuf); for (;;) { PL()->ErasePrompt(); if (!in) return (false); int d; if (sscanf(in, "%d", &d) == 1 && d >= 0) { if (prpty_reserved(d)) msg = "Given value is for internal use only, try again: "; else { Value = d; break; } } else msg = "Bad input, try again: "; Value = -1; in = PL()->EditPrompt(msg, (global || !*tbuf) ? 0 : tbuf); } return (true); } // Query the user for the property string to be used in added properties. // Return false if Esc entered, true otherwise. // It is assumed here that a null string is a valid return. // bool PrptyState::prp_get_string(bool global, bool allow_switch) { CDs *cursd = CurCell(); if (!cursd) return (false); if (Value == XICP_PC_PARAMS && Scur->pointer->type() == CDINSTANCE) { char *pstr; bool ret = ED()->reparameterize((CDc*)Scur->pointer, &pstr); if (ret) Udata.string = pstr; else { Log()->ErrorLogV(mh::PCells, "Error, reparameterize failed:\n%s", Errs()->get_error()); } return (ret); } char buf[256], tbuf[256]; bool immut = prp_get_prompt(global, Scur->pointer, tbuf); Udata.string = 0; Udata.hyl = 0; if (allow_switch && !immut) { sprintf(buf, "(Up/down arrows to select) %s", tbuf); strcpy(tbuf, buf); } if (DSP()->CurMode() == Electrical) { hyList *hnew; if (immut) { if (Value == P_NOPHYS) { char *in = PL()->EditPrompt("Device shorted in LVS? ", "n"); in = lstring::strip_space(in); if (!in) { PL()->ErasePrompt(); return (false); } if (in && (*in == 'y' || *in == 'Y')) strcpy(tbuf, "shorted"); } hnew = new hyList(cursd, tbuf, HYcvPlain); } else if (Value == P_NAME) { if (SelPrp && ((CDp_cname*)SelPrp)->assigned_name()) { hyList *h = new hyList(0, ((CDp_cname*)SelPrp)->assigned_name(), HYcvPlain); hnew = PL()->EditHypertextPrompt(tbuf, h, false); hyList::destroy(h); } else hnew = PL()->EditHypertextPrompt(tbuf, 0, false); } else { bool use_lt = false; if (Value == P_VALUE || Value == P_PARAM || Value == P_OTHER) use_lt = true; if (SelPrp) { switch (Value) { case P_MODEL: case P_VALUE: case P_PARAM: case P_OTHER: case P_DEVREF: hnew = PL()->EditHypertextPrompt(tbuf, ((CDp_user*)SelPrp)->data(), use_lt); break; default: // shouldn't be here hnew = PL()->EditHypertextPrompt(tbuf, 0, use_lt); break; } } else hnew = PL()->EditHypertextPrompt(tbuf, 0, use_lt); } PL()->ErasePrompt(); if (!hnew) return (false); hnew->trim_white_space(); if (hnew->ref_type() == HLrefText && !hnew->text()[0]) { hyList::destroy(hnew); hnew = 0; } Udata.hyl = hnew; } else { if (immut) { Udata.string = lstring::copy(tbuf); return (true); } bool use_lt = true; hyList *hp = 0; if (!SelPrp && (Value >= XprpType && Value < XprpEnd)) { char *s = XM()->GetPseudoProp(Scur->pointer, Value); hp = new hyList(cursd, s, HYcvPlain); delete [] s; use_lt = false; } else if (SelPrp && SelPrp->string() && *SelPrp->string()) { const char *lttok = HYtokPre HYtokLT HYtokSuf; if (lstring::prefix(lttok, SelPrp->string())) { if (use_lt) hp = new hyList(cursd, SelPrp->string(), HYcvAscii); else hp = new hyList(cursd, SelPrp->string() + strlen(lttok), HYcvPlain); } else hp = new hyList(cursd, SelPrp->string(), HYcvPlain); } ltobj *lt = new ltobj(cursd, Scur->pointer, SelPrp, Value); hyList *hnew = PL()->EditHypertextPrompt(tbuf, hp, use_lt, PLedStart, PLedNormal, ltcallback, lt); hyList::destroy(hp); PL()->ErasePrompt(); if (!hnew) { delete lt; return (false); } if (hnew->ref_type() == HLrefLongText) // text editor popped, calls ltcallback when done return (true); delete lt; if (hnew->ref_type() == HLrefText && !hnew->text()[0]) { hyList::destroy(hnew); hnew = 0; } if (hnew) { Udata.string = hyList::string(hnew, HYcvPlain, true); hyList::destroy(hnew); } } return (true); } void PrptyState::prp_rm(Ptxt *line) { if (!Shead) { PL()->ShowPrompt(nosel); return; } if (!line) return; CDs *cursd = CurCell(); if (!cursd) return; SelPrp = line->prpty(); if (DSP()->CurMode() == Electrical) { if (SelPrp) { switch (SelPrp->value()) { case P_NAME: case P_MODEL: case P_VALUE: case P_PARAM: case P_OTHER: case P_NOPHYS: case P_FLATTEN: case P_SYMBLC: case P_RANGE: case P_DEVREF: break; default: SelPrp = 0; break; } } } if (!SelPrp) { PL()->ShowPrompt("This property can not be deleted."); return; } Modifying = PRPdeleting; prp_showselect(false); bool ret = true; if (SelPrp) { Value = SelPrp->value(); Vmask = maskof(Value); } else { Value = -1; Vmask = 0; ret = prp_get_rm_type(Global); if (!PrptyCmd) return; } if (ret && Scur) { if (Global) { Ulist()->ListCheck("rmprp", cursd, false); for (sSel *sd = Shead; sd; sd = sd->next) { if (DSP()->CurMode() == Electrical && sd->pointer->type() != CDINSTANCE) continue; prp_remove(sd, SelPrp); } Ulist()->CommitChanges(true); } else { if (DSP()->CurMode() == Electrical && Scur->pointer->type() != CDINSTANCE) PL()->ShowPrompt("Can't delete properties of this object."); else { Ulist()->ListCheck("rmprp", cursd, false); prp_remove(Scur, SelPrp); Ulist()->CommitChanges(true); } } } if (PrptyCmd) { if (Scur) prp_showselect(true); Value = -1; Vmask = 0; SelPrp = 0; Modifying = PRPquiescent; } } // Solicit the type(s) or number of a property to be removed. // Return false if Esc entered, true otherwise. // bool PrptyState::prp_get_rm_type(bool global) { if (DSP()->CurMode() == Electrical) { const char *glmsg = global ? "Property types (nmvpoys) to remove from all selected devices? " : "Property types (nmvpoys) to be removed? "; Vmask = 0; for (;;) { char *in = PL()->EditPrompt(glmsg, 0); PL()->ErasePrompt(); if (!in) return (false); for (char *s = in; *s; s++) { switch (*s) { case 'n': case 'N': Vmask |= NAME_MASK; break; case 'm': case 'M': Vmask |= MODEL_MASK; break; case 'v': case 'V': Vmask |= VALUE_MASK; break; case 'i': case 'I': case 'p': case 'P': Vmask |= PARAM_MASK; break; case 'o': case 'O': Vmask |= OTHER_MASK; break; case 'y': case 'Y': Vmask |= NOPHYS_MASK; break; case 'f': case 'F': Vmask |= FLATTEN_MASK; break; case 's': case 'S': Vmask |= NOSYMB_MASK; break; case 'r': case 'R': Vmask |= RANGE_MASK; break; case 'd': case 'D': Vmask |= DEVREF_MASK; break; } } if (Vmask) break; glmsg = "Bad input, try again. You must give one or more of n,m,v,p,o. "; } } else { const char *msg2 = global ? "Property number to remove from all selected ojbects? " : "Property number to be removed? "; for (;;) { char *in = PL()->EditPrompt(msg2, 0); PL()->ErasePrompt(); if (!in) return (false); int d; if (sscanf(in, "%d", &d) == 1 && d >= 0) { if (prpty_reserved(d)) msg2 = "Given value is for internal use only, try again: "; else { Value = d; break; } } else msg2 = "Bad input, try again: "; } } return (true); } // Remove properties from the object in sd. The values to remove // are in Value or Vmask. Remove all of the properties of the given // type. If pdesc is given, remove properties that "match" pdesc. // void PrptyState::prp_remove(sSel *sd, CDp *pdesc) { CDs *cursd = CurCell(); if (!cursd) return; if (DSP()->CurMode() == Electrical) { if (sd->pointer->type() != CDINSTANCE) return; if (pdesc) { pdesc = prpmatch(sd->pointer, pdesc, pdesc->value()); if (!pdesc) return; if (pdesc->value() == P_NAME) { Udata.hyl = 0; // replace the property with default ED()->prptyModify(OCALL(sd->pointer), pdesc, P_NAME, 0, 0); } else { Ulist()->RecordPrptyChange(cursd, sd->pointer, pdesc, 0); CDla *olabel = pdesc->bound(); if (olabel) { Ulist()->RecordObjectChange(cursd, olabel, 0); DSP()->RedisplayArea(&olabel->oBB()); } } return; } for (int i = 0; ; i++) { int value; if (i == 0) { if (!(Vmask & MODEL_MASK)) continue; value = P_MODEL; } else if (i == 1) { if (!(Vmask & VALUE_MASK)) continue; value = P_VALUE; } else if (i == 2) { if (!(Vmask & PARAM_MASK)) continue; value = P_PARAM; } else if (i == 3) { if (!(Vmask & OTHER_MASK)) continue; value = P_OTHER; } else if (i == 4) { if (!(Vmask & NOPHYS_MASK)) continue; value = P_NOPHYS; } else if (i == 5) { if (!(Vmask & FLATTEN_MASK)) continue; value = P_FLATTEN; } else if (i == 6) { if (!(Vmask & NOSYMB_MASK)) continue; value = P_SYMBLC; } else if (i == 7) { if (!(Vmask & RANGE_MASK)) continue; value = P_RANGE; } else if (i == 8) { if (!(Vmask & NAME_MASK)) continue; value = P_NAME; } else if (i == 9) { if (!(Vmask & DEVREF_MASK)) continue; value = P_DEVREF; } else break; while ((pdesc = sd->pointer->prpty(value)) != 0) { if (value == P_NAME) { Udata.hyl = 0; // replace the property with default ED()->prptyModify(OCALL(sd->pointer), pdesc, P_NAME, 0, 0); } else { Ulist()->RecordPrptyChange(cursd, sd->pointer, pdesc, 0); CDla *olabel = pdesc->bound(); if (olabel) { Ulist()->RecordObjectChange(cursd, olabel, 0); DSP()->RedisplayArea(&olabel->oBB()); } } } } } else { if (pdesc) { // Remove at most one matching property pdesc = prpmatch(sd->pointer, pdesc, pdesc->value()); if (pdesc) { DSP()->ShowOdescPhysProperties(sd->pointer, ERASE); Ulist()->RecordPrptyChange(cursd, sd->pointer, pdesc, 0); DSP()->ShowOdescPhysProperties(sd->pointer, DISPLAY); } } else { // Remove all properties of value Value DSP()->ShowOdescPhysProperties(sd->pointer, ERASE); while ((pdesc = sd->pointer->prpty(Value)) != 0) Ulist()->RecordPrptyChange(cursd, sd->pointer, pdesc, 0); DSP()->ShowOdescPhysProperties(sd->pointer, DISPLAY); } } } // Static function. // Called from the Properties panel, sets the current editing // property to the one just clicked on. // int PrptyState::btn_callback(Ptxt *pt) { if (!pt->prpty()) return (false); PrptyCmd->SelPrp = pt->prpty(); PrptyCmd->Value = PrptyCmd->SelPrp->value(); PrptyCmd->prp_updtext(PrptyCmd->Scur); return (true); } // Static function. // Called from the hypertext editor, advances prompt to next // property. // void PrptyState::down_callback() { if (!PrptyCmd || !PrptyCmd->Scur || !PrptyCmd->Scur->pointer->prpty_list()) return; Ptxt *pt = ED()->PropertyCycle(PrptyCmd->SelPrp, &is_prp_editable, false); if (!pt) return; PrptyCmd->SelPrp = pt->prpty(); PrptyCmd->Value = PrptyCmd->SelPrp->value(); PrptyCmd->prp_updtext(PrptyCmd->Scur); } // Static function. // Called from the hypertext editor, advances prompt to previous // property. // void PrptyState::up_callback() { if (!PrptyCmd || !PrptyCmd->Scur || !PrptyCmd->Scur->pointer->prpty_list()) return; Ptxt *pt = ED()->PropertyCycle(PrptyCmd->SelPrp, &is_prp_editable, true); if (!pt) return; PrptyCmd->SelPrp = pt->prpty(); PrptyCmd->Value = PrptyCmd->SelPrp->value(); PrptyCmd->prp_updtext(PrptyCmd->Scur); } // End of PrptyState functions. namespace { // Return a property from odesc that "matches" pdesc, or val if // pdesc is nil. // CDp * prpmatch(CDo *odesc, CDp *pdesc, int val) { if (!odesc) return (0); if (DSP()->CurMode() == Electrical) { if (!pdesc) { if (val >= 0 && val != P_OTHER) return (odesc->prpty(val)); } else { if (pdesc->value() != P_OTHER) return (odesc->prpty(pdesc->value())); // Return a P_OTHER property with matching text char *s1 = hyList::string(((CDp_user*)pdesc)->data(), HYcvPlain, false); for (CDp *pd = odesc->prpty_list(); pd; pd = pd->next_prp()) { if (pd->value() == P_OTHER) { char *s2 = hyList::string(((CDp_user*)pd)->data(), HYcvPlain, false); int j = strcmp(s1, s2); delete [] s2; if (!j) { delete [] s1; return (pd); } } } delete [] s1; } } else if (pdesc && pdesc->string()) { for (CDp *pd = odesc->prpty_list(); pd; pd = pd->next_prp()) { if (pd->value() == pdesc->value() && pd->string() && !strcmp(pdesc->string(), pd->string())) return (pd); } } return (0); } int maskof(int prpty) { if (DSP()->CurMode() == Physical) return(0); switch(prpty) { case P_NAME: return (NAME_MASK); case P_MODEL: return (MODEL_MASK); case P_VALUE: return (VALUE_MASK); case P_PARAM: return (PARAM_MASK); case P_OTHER: return (OTHER_MASK); case P_NOPHYS: return (NOPHYS_MASK); case P_FLATTEN: return (FLATTEN_MASK); case P_SYMBLC: return (NOSYMB_MASK); case P_RANGE: return (RANGE_MASK); case P_DEVREF: return (DEVREF_MASK); default: return (0); } } } //---------------------------------------------------------------------- // The props command - show physical properties on-screen, and allow // editing //---------------------------------------------------------------------- namespace { // We don't show internal properties. // inline bool is_showable(CDp *pdesc) { if (prpty_internal(pdesc->value())) return (false); return (true); } struct sPrpPointer { sPrpPointer() { ctrl_d_entered = false; } ~sPrpPointer() { ctrl_d_entered = false; } static void ctrl_d_cb(); bool point_at_prpty(WindowDesc*, int, int, CDo**, CDp**); bool is_ctrl_d() { return (ctrl_d_entered); } private: void find_loc(CDo*, int*, int*, int); static bool ctrl_d_entered; }; } bool sPrpPointer::ctrl_d_entered = false; // If x,y fall on a physical property text area, allow editing of the // property. Return true if the editor was entered. // bool cEdit::editPhysPrpty() { WindowDesc *wdesc = EV()->CurrentWin(); if (!wdesc || wdesc->Mode() != Physical || !wdesc->Attrib()->show_phys_props()) return (false); if (DSP()->CurMode() != Physical) return (false); CDs *cursd = CurCell(); if (!cursd) return (false); int x, y; EV()->Cursor().get_raw(&x, &y); CDo *odesc = 0; CDp *pdesc = 0; sPrpPointer PP; if (PP.point_at_prpty(wdesc, x, y, &odesc, &pdesc)) { char tbuf[64]; sprintf(tbuf, "%d", pdesc->value()); PL()->RegisterCtrlDCallback(PP.ctrl_d_cb); char *in = PL()->EditPrompt("Edit number: ", tbuf); PL()->RegisterCtrlDCallback(0); if (in) { int val; if (sscanf(in, "%d", &val) < 1) val = pdesc->value(); const char *lttok = HYtokPre HYtokLT HYtokSuf; hyList *hp; if (pdesc->string() && lstring::prefix(lttok, pdesc->string())) hp = new hyList(cursd, pdesc->string(), HYcvAscii); else hp = new hyList(cursd, pdesc->string(), HYcvPlain); ltobj *lt = new ltobj(cursd, odesc, pdesc, val); PL()->RegisterCtrlDCallback(PP.ctrl_d_cb); hyList *hnew = PL()->EditHypertextPrompt("Edit string: ", hp, true, PLedStart, PLedNormal, PrptyState::ltcallback, lt); PL()->RegisterCtrlDCallback(0); hyList::destroy(hp); if (!hnew) { PL()->ErasePrompt(); return (true); } if (hnew->ref_type() == HLrefLongText) { // text editor popped, calls ltcallback when done PL()->ErasePrompt(); return (true); } if (hnew->ref_type() == HLrefText && !hnew->text()[0]) { hyList::destroy(hnew); hnew = 0; } if (hnew) { char *string = hyList::string(hnew, HYcvPlain, true); hyList::destroy(hnew); DSP()->ShowOdescPhysProperties(odesc, ERASE); Ulist()->ListCheck("editpp", cursd, false); CDp *op = pdesc; pdesc = new CDp(string, val); delete [] string; Ulist()->RecordPrptyChange(cursd, odesc, op, pdesc); Ulist()->CommitChanges(); DSP()->ShowOdescPhysProperties(odesc, DISPLAY); PL()->ErasePrompt(); return (true); } } if (PP.is_ctrl_d()) { DSP()->ShowOdescPhysProperties(odesc, ERASE); Ulist()->ListCheck("delpp", cursd, false); Ulist()->RecordPrptyChange(cursd, odesc, pdesc, 0); Ulist()->CommitChanges(); DSP()->ShowOdescPhysProperties(odesc, DISPLAY); } PL()->ErasePrompt(); return (true); } return (false); } namespace { void sPrpPointer::ctrl_d_cb() { ctrl_d_entered = true; } // If x,y fall on a physical property text area, return true and set the // pointer args to the object and the property. // bool sPrpPointer::point_at_prpty(WindowDesc *wdesc, int xp, int yp, CDo **oret, CDp **pret) { CDs *cursdp = CurCell(Physical); if (!cursdp) return (false); int delta = wdesc->LogScale(DSP()->PhysPropSize()); BBox BB; BB.left = xp - delta; BB.right = xp + delta; BB.bottom = yp - delta; BB.top = yp + delta; CDg gdesc; gdesc.init_gen(cursdp, CellLayer(), &BB); CDo *pointer; while ((pointer = gdesc.next()) != 0) { if (!pointer->is_normal()) continue; CDp *pdesc = pointer->prpty_list(); if (!pdesc) continue; bool locfound = false; int x = 0, y = 0; for ( ; pdesc; pdesc = pdesc->next_prp()) { if (is_showable(pdesc)) { if (!locfound) { find_loc(pointer, &x, &y, delta); locfound = true; } int w, h, nl; { char buf[32]; sprintf(buf, "%d ", pdesc->value()); sLstr lstr; lstr.add(buf); lstr.add(pdesc->string()); nl = DSP()->DefaultLabelSize(lstr.string(), Physical, &w, &h); } w = (w*delta*nl)/h; h = delta*nl; y -= h - delta; if (xp >= x && xp <= x+w && yp >= y-delta && yp <= y) { *oret = pointer; *pret = pdesc; return (true); } y -= delta; } } } CDsLgen lgen(cursdp); CDl *ld; while ((ld = lgen.next()) != 0) { gdesc.init_gen(cursdp, ld, &BB); while ((pointer = gdesc.next()) != 0) { if (!pointer->is_normal()) continue; CDp *pdesc = pointer->prpty_list(); if (!pdesc) continue; bool locfound = false; int x = 0, y = 0; for ( ; pdesc; pdesc = pdesc->next_prp()) { if (is_showable(pdesc)) { if (!locfound) { find_loc(pointer, &x, &y, delta); locfound = true; } int w, h, nl; { char buf[32]; sprintf(buf, "%d ", pdesc->value()); sLstr lstr; lstr.add(buf); lstr.add(pdesc->string()); nl = DSP()->DefaultLabelSize(lstr.string(), Physical, &w, &h); } w = (w*delta*nl)/h; h = delta*nl; y -= h - delta; if (xp >= x && xp <= x+w && yp >= y && yp <= y+h) { *oret = pointer; *pret = pdesc; return (true); } y -= delta; } } } } return (false); } // Return screen coordinates for physical properties of odesc. // Arg delta is approx. text height. // void sPrpPointer::find_loc(CDo *odesc, int *x, int *y, int delta) { if (odesc->type() == CDWIRE) { // leftmost end const Point *pts = OWIRE(odesc)->points(); int num = OWIRE(odesc)->numpts(); int wid = OWIRE(odesc)->wire_width()/2; if (pts[0].x < pts[num-1].x || (pts[0].x == pts[num-1].x && pts[0].y > pts[num-1].y)) { *x = pts[0].x - wid; *y = pts[0].y + wid - delta; } else { *x = pts[num-1].x - wid; *y = pts[num-1].y + wid - delta; } } else if (odesc->type() == CDPOLYGON) { // leftmost vertex with largest y const Point *pts = OPOLY(odesc)->points(); int num = OPOLY(odesc)->numpts(); int minx = CDinfinity; int maxy = -CDinfinity; int iref = 0; for (int i = 0; i < num; i++) { if (pts[i].x < minx || (pts[i].x == minx && pts[i].y > maxy)) { minx = pts[i].x; maxy = pts[i].y; iref = i; } } *x = pts[iref].x; *y = pts[iref].y - delta; } else { // upper left corner *x = odesc->oBB().left; *y = odesc->oBB().top - delta; } } // End of sPrpPointer functions. } //---------------------------------------------------------------------- // Pseudo-property processing - modify objects according to text. //---------------------------------------------------------------------- namespace { Point *scalepts(const BBox*, const BBox*, const Point*, int); Point *getpts(const char*, int*); } // Set attributes for pseudo-prooperty value. If the object is a // copy, it is modified directly. Otherwise the database object is // replaced. We don't do merging here, since 1) the new box probably // has to be moved, such as for XprpMagn, and 2) this confuses the // Properties Editor. // bool cEdit::acceptPseudoProp(CDo *odesc, CDs *sdesc, int val, const char *string) { if (!odesc || !sdesc) return (false); if (!string) { Errs()->add_error("null string encountered"); return (false); } if (val == XprpFlags) { char *tok; unsigned flags = 0; while ((tok = lstring::gettok(&string)) != 0) { if (isdigit(*tok)) { for (char *t = tok; *t; t++) { if (!isdigit(*t)) break; int n = *t - '0'; if (n >= DSP_NUMWINS) break; flags |= CDexpand << n; } } else { for (FlagDef *f = OdescFlags; f->name; f++) { if (lstring::cieq(tok, f->name)) flags |= f->value; } } delete [] tok; } odesc->set_flags(flags); return (true); } if (val == XprpState) { if (lstring::cieq(string, "normal")) odesc->set_state(CDobjVanilla); else if (lstring::cieq(string, "selected")) odesc->set_state(CDobjSelected); else if (lstring::cieq(string, "deleted")) odesc->set_state(CDobjDeleted); else if (lstring::cieq(string, "incomplete")) odesc->set_state(CDobjIncomplete); else if (lstring::cieq(string, "internal")) odesc->set_state(CDobjInternal); else { Errs()->add_error("error, unknown state keyword"); return (false); } return (true); } if (val == XprpGroup) { int d; if (sscanf(string, "%d", &d) != 1) { Errs()->add_error("syntax error, expecting integer"); return (false); } odesc->set_group(d); return (true); } #ifdef HAVE_COMPUTED_GOTO COMPUTED_JUMP(odesc) #else CONDITIONAL_JUMP(odesc) #endif box: return (acceptBoxPseudoProp(odesc, sdesc, val, string)); poly: return (acceptPolyPseudoProp((CDpo*)odesc, sdesc, val, string)); wire: return (acceptWirePseudoProp((CDw*)odesc, sdesc, val, string)); label: return (acceptLabelPseudoProp((CDla*)odesc, sdesc, val, string)); inst: return (acceptInstPseudoProp((CDc*)odesc, sdesc, val, string)); } // Handle pseudo-properties applied to boxes. // bool cEdit::acceptBoxPseudoProp(CDo *odesc, CDs *sdesc, int val, const char *string) { // For boxes, accept all (physical or electrical, copy or not). if (val == XprpBB) { BBox BB; if (sscanf(string, "%d,%d %d,%d", &BB.left, &BB.bottom, &BB.right, &BB.top) != 4) { Errs()->add_error( "syntax error, expecting l,b r,t coordinates"); return (false); } BB.fix(); if (odesc->is_copy()) odesc->set_oBB(BB); else { CDo *newo = sdesc->newBox(odesc, &BB, odesc->ldesc(), odesc->prpty_list()); if (!newo) { Errs()->add_error("newBox failed"); return (false); } } return (true); } if (val == XprpLayer) { CDl *ld = CDldb()->findLayer(string, sdesc->displayMode()); if (!ld) { Errs()->add_error("layer %s not found", string); return (false); } if (odesc->is_copy()) odesc->set_ldesc(ld); else { CDo *newo = sdesc->newBox(odesc, &odesc->oBB(), ld, odesc->prpty_list()); if (!newo) { Errs()->add_error("newBox failed"); return (false); } } return (true); } if (val == XprpCoords) { Poly poly; poly.points = getpts(string, &poly.numpts); if (!poly.points) return (false); if (poly.is_rect()) { BBox BB(poly.points); delete [] poly.points; if (odesc->is_copy()) odesc->set_oBB(BB); else { CDo *newo = sdesc->newBox(odesc, &BB, odesc->ldesc(), odesc->prpty_list()); if (!newo) { Errs()->add_error("newBox failed"); return (false); } } return (true); } if (poly.numpts < 4) { delete [] poly.points; Errs()->add_error("poly/box has too few points"); return (false); } if (odesc->is_copy()) { delete [] poly.points; Errs()->add_error("can't change box copy to polygon."); return (false); } else { CDo *newo = sdesc->newPoly(odesc, &poly, odesc->ldesc(), odesc->prpty_list(), false); if (!newo) { Errs()->add_error("newPoly failed"); return (false); } } return (true); } if (val == XprpMagn) { double mag; if (sscanf(string, "%lf", &mag) != 1) { Errs()->add_error("syntax error, number expected"); return (false); } if (mag < CDMAGMIN || mag > CDMAGMAX) { Errs()->add_error("error, number %g-%g expected", CDMAGMIN, CDMAGMAX); return (false); } // The box lower-left corner remains fixed. BBox BB(odesc->oBB().left, odesc->oBB().bottom, odesc->oBB().left + mmRnd(mag*odesc->oBB().width()), odesc->oBB().bottom + mmRnd(mag*odesc->oBB().height())); if (odesc->is_copy()) odesc->set_oBB(BB); else { CDo *newo = sdesc->newBox(odesc, &BB, odesc->ldesc(), odesc->prpty_list()); if (!newo) { Errs()->add_error("newBox failed"); return (false); } } return (true); } if (val == XprpXY) { int n; Point *p = getpts(string, &n); if (!p) return (false); int px = p->x; int py = p->y; delete [] p; if (px != odesc->oBB().left || py != odesc->oBB().bottom) { BBox BB(px, py, px + odesc->oBB().right - odesc->oBB().left, py + odesc->oBB().top - odesc->oBB().bottom); if (odesc->is_copy()) odesc->set_oBB(BB); else { CDo *newo = sdesc->newBox(odesc, &BB, odesc->ldesc(), odesc->prpty_list()); if (!newo) { delete [] p; Errs()->add_error("newBox failed"); return (false); } } } return (true); } if (val == XprpWidth) { int w; if (sscanf(string, "%d", &w) != 1 || w <= 0) { Errs()->add_error("error, bad width"); return (false); } BBox BB(odesc->oBB()); BB.right = BB.left + w; if (odesc->is_copy()) odesc->set_oBB(BB); else { CDo *newo = sdesc->newBox(odesc, &BB, odesc->ldesc(), odesc->prpty_list()); if (!newo) { Errs()->add_error("newBox failed"); return (false); } } return (true); } if (val == XprpHeight) { int h; if (sscanf(string, "%d", &h) != 1 || h <= 0) { Errs()->add_error("error, bad height"); return (false); } BBox BB(odesc->oBB()); BB.top = BB.bottom + h; if (odesc->is_copy()) odesc->set_oBB(BB); else { CDo *newo = sdesc->newBox(odesc, &BB, odesc->ldesc(), odesc->prpty_list()); if (!newo) { Errs()->add_error("newBox failed"); return (false); } } return (true); } Errs()->add_error("unknown pseudo-property %d", val); return (false); } // Handle pseudo-properties applied to polygons. // bool cEdit::acceptPolyPseudoProp(CDpo *pdesc, CDs *sdesc, int val, const char *string) { // For polys, accept all (physical or electrical, copy or not). if (val == XprpBB) { BBox BB; if (sscanf(string, "%d,%d %d,%d", &BB.left, &BB.bottom, &BB.right, &BB.top) != 4) { Errs()->add_error( "syntax error, expecting l,b r,t coordinates"); return (false); } BB.fix(); int num = pdesc->numpts(); Poly po(num, scalepts(&BB, &pdesc->oBB(), pdesc->points(), num)); if (pdesc->is_copy()) { pdesc->set_oBB(BB); delete [] pdesc->points(); pdesc->set_points(po.points); } else { CDo *newo = sdesc->newPoly(pdesc, &po, pdesc->ldesc(), pdesc->prpty_list(), false); if (!newo) { Errs()->add_error("newPoly failed"); return (false); } } return (true); } if (val == XprpLayer) { CDl *ld = CDldb()->findLayer(string, sdesc->displayMode()); if (!ld) { Errs()->add_error("layer %s not found", string); return (false); } if (pdesc->is_copy()) pdesc->set_ldesc(ld); else { int num = pdesc->numpts(); Poly po(num, Point::dup(pdesc->points(), num)); CDo *newo = sdesc->newPoly(pdesc, &po, ld, pdesc->prpty_list(), false); if (!newo) { Errs()->add_error("newPoly failed"); return (false); } } return (true); } if (val == XprpCoords) { Poly po; po.points = getpts(string, &po.numpts); if (!po.points) return (false); if (po.is_rect() && !pdesc->is_copy()) { BBox BB(po.points); delete [] po.points; CDo *newo = sdesc->newBox(pdesc, &BB, pdesc->ldesc(), pdesc->prpty_list()); if (!newo) { Errs()->add_error("newBox failed"); return (false); } return (true); } if (po.numpts < 4) { delete [] po.points; Errs()->add_error("poly has too few points"); return (false); } if (pdesc->is_copy()) { delete [] pdesc->points(); pdesc->set_points(po.points); pdesc->set_numpts(po.numpts); pdesc->computeBB(); } else { CDo *newo = sdesc->newPoly(pdesc, &po, pdesc->ldesc(), pdesc->prpty_list(), false); if (!newo) { Errs()->add_error("newPoly failed"); return (false); } } return (true); } if (val == XprpMagn) { double mag; if (sscanf(string, "%lf", &mag) != 1) { Errs()->add_error("syntax error, number expected"); return (false); } if (mag < CDMAGMIN || mag > CDMAGMAX) { Errs()->add_error("error, number %g-%g expected", CDMAGMIN, CDMAGMAX); return (false); } // The first vertex remains fixed. int num = pdesc->numpts(); Poly po(num, new Point[num]); const Point *pts = pdesc->points(); int xr = pts[0].x; int yr = pts[0].y; po.points[0].set(xr, yr); for (int i = 1; i < po.numpts; i++) { po.points[i].set(xr + mmRnd(mag*(pts[i].x - xr)), yr + mmRnd(mag*(pts[i].y - yr))); } if (pdesc->is_copy()) { delete [] pdesc->points(); pdesc->set_points(po.points); pdesc->computeBB(); } else { CDo *newo = sdesc->newPoly(pdesc, &po, pdesc->ldesc(), pdesc->prpty_list(), false); if (!newo) { Errs()->add_error("newPoly failed"); return (false); } } return (true); } if (val == XprpXY) { int n; Point *p = getpts(string, &n); if (!p) return (false); int px = p->x; int py = p->y; delete [] p; int num = pdesc->numpts(); Poly po(num, 0); const Point *pts = pdesc->points(); if (px != pts->x || py != pts->y) { po.points = new Point[num]; int dx = px - pts->x; int dy = py - pts->y; for (int i = 0; i < po.numpts; i++) { po.points[i].x = pts[i].x + dx; po.points[i].y = pts[i].y + dy; } if (pdesc->is_copy()) { delete [] pdesc->points(); pdesc->set_points(po.points); pdesc->computeBB(); } else { CDo *newo = sdesc->newPoly(pdesc, &po, pdesc->ldesc(), pdesc->prpty_list(), false); if (!newo) { Errs()->add_error("newPoly failed"); return (false); } } } return (true); } if (val == XprpWidth) { int w; if (sscanf(string, "%d", &w) != 1 || w <= 0) { Errs()->add_error("error, bad width"); return (false); } BBox BB(pdesc->oBB()); BB.right = BB.left + w; int num = pdesc->numpts(); Poly po(num, scalepts(&BB, &pdesc->oBB(), pdesc->points(), num)); if (pdesc->is_copy()) { pdesc->set_oBB(BB); delete [] pdesc->points(); pdesc->set_points(po.points); } else { CDo *newo = sdesc->newPoly(pdesc, &po, pdesc->ldesc(), pdesc->prpty_list(), false); if (!newo) { Errs()->add_error("newPoly failed"); return (false); } } return (true); } if (val == XprpHeight) { int h; if (sscanf(string, "%d", &h) != 1 || h <= 0) { Errs()->add_error("error, bad height"); return (false); } BBox BB(pdesc->oBB()); BB.top = BB.bottom + h; int num = pdesc->numpts(); Poly po(num, scalepts(&BB, &pdesc->oBB(), pdesc->points(), num)); if (pdesc->is_copy()) { pdesc->set_oBB(BB); delete [] pdesc->points(); pdesc->set_points(po.points); } else { CDo *newo = sdesc->newPoly(pdesc, &po, pdesc->ldesc(), pdesc->prpty_list(), false); if (!newo) { Errs()->add_error("newPoly failed"); return (false); } } return (true); } Errs()->add_error("unknown pseudo-property %d", val); return (false); } // Handle pseudo-properties applied to wires. // bool cEdit::acceptWirePseudoProp(CDw *wdesc, CDs *sdesc, int val, const char *string) { // For wires, electrical wires on the active layer or that // would be moved to the active layer are rejected, all other // wires are accepted. if (sdesc->isElectrical() && wdesc->ldesc()->isWireActive()) { Errs()->add_error( "Can't modify wires on an active layer with pseudo-properties."); return (false); } if (val == XprpBB) { BBox BB; if (sscanf(string, "%d,%d %d,%d", &BB.left, &BB.bottom, &BB.right, &BB.top) != 4) { Errs()->add_error( "syntax error, expecting l,b r,t coordinates"); return (false); } BB.fix(); int num = wdesc->numpts(); Wire wire(num, scalepts(&BB, &wdesc->oBB(), wdesc->points(), num), wdesc->attributes()); if (wdesc->is_copy()) { delete [] wdesc->points(); wdesc->set_points(wire.points); wdesc->computeBB(); } else { CDo *newo = sdesc->newWire(wdesc, &wire, wdesc->ldesc(), wdesc->prpty_list(), false); if (!newo) { Errs()->add_error("newWire failed"); return (false); } } return (true); } if (val == XprpLayer) { CDl *ld = CDldb()->findLayer(string, sdesc->displayMode()); if (!ld) { Errs()->add_error("layer %s not found", string); return (false); } if (sdesc->isElectrical() && ld->isWireActive()) { Errs()->add_error( "Can't move wire to active layer with pseudo-properties"); return (false); } if (wdesc->is_copy()) wdesc->set_ldesc(ld); else { int num = wdesc->numpts(); Wire wire(num, Point::dup(wdesc->points(), num), wdesc->attributes()); CDo *newo = sdesc->newWire(wdesc, &wire, ld, wdesc->prpty_list(), false); if (!newo) { Errs()->add_error("newWire failed"); return (false); } } return (true); } if (val == XprpCoords) { Wire wire(0, 0, wdesc->attributes()); wire.points = getpts(string, &wire.numpts); if (!wire.points) return (false); if (wdesc->is_copy()) { delete [] wdesc->points(); wdesc->set_points(wire.points); wdesc->set_numpts(wire.numpts); wdesc->computeBB(); } else { CDo *newo = sdesc->newWire(wdesc, &wire, wdesc->ldesc(), wdesc->prpty_list(), false); if (!newo) { Errs()->add_error("newWire failed"); return (false); } } return (true); } if (val == XprpWwidth) { int d; if (sscanf(string, "%d", &d) != 1 || d <= 0) { Errs()->add_error("error, positive integer expected"); return (false); } if (wdesc->is_copy()) { wdesc->set_wire_width(d); wdesc->computeBB(); } else { int num = wdesc->numpts(); Wire wire(num, Point::dup(wdesc->points(), num), wdesc->attributes()); wire.set_wire_width(d); if (wire.wire_width() != wdesc->wire_width()) { CDo *newo = sdesc->newWire(wdesc, &wire, wdesc->ldesc(), wdesc->prpty_list(), false); if (!newo) { Errs()->add_error("newWire failed"); return (false); } } } return (true); } if (val == XprpWstyle) { const char *s = string; while (isspace(*s)) s++; int d = -1; switch (*s) { case '0': case 'f': case 'F': d = CDWIRE_FLUSH; break; case '1': case 'r': case 'R': d = CDWIRE_ROUND; break; case '2': case 'e': case 'E': d = CDWIRE_EXTEND; break; default: break; } if (d < 0) { Errs()->add_error("error, integer 0-2 or 'f', 'r', 'e' expected"); return (false); } if (wdesc->is_copy()) { wdesc->set_wire_style((WireStyle)d); wdesc->computeBB(); } else { int num = wdesc->numpts(); Wire wire(num, Point::dup(wdesc->points(), num), wdesc->attributes()); wire.set_wire_style((WireStyle)d); if (wire.wire_style() != wdesc->wire_style()) { CDo *newo = sdesc->newWire(wdesc, &wire, wdesc->ldesc(), wdesc->prpty_list(), false); if (!newo) { Errs()->add_error("newWire failed"); return (false); } } } return (true); } if (val == XprpMagn) { double mag; if (sscanf(string, "%lf", &mag) != 1) { Errs()->add_error("syntax error, number expected"); return (false); } if (mag < CDMAGMIN || mag > CDMAGMAX) { Errs()->add_error("error, number %g-%g expected", CDMAGMIN, CDMAGMAX); return (false); } // The first vertex remains fixed. int num = wdesc->numpts(); Wire wire(num, 0, wdesc->attributes()); const Point *pts = wdesc->points(); wire.points = new Point[wire.numpts]; int xr = pts[0].x; int yr = pts[0].y; wire.points[0].set(xr, yr); for (int i = 1; i < wire.numpts; i++) { wire.points[i].set(xr + mmRnd(mag*(pts[i].x - xr)), yr + mmRnd(mag*(pts[i].y - yr))); } // Note that the Magn does not change wire width, only the // point list. Use XprpWwidth. if (wdesc->is_copy()) { delete [] wdesc->points(); wdesc->set_points(wire.points); wdesc->computeBB(); } else { CDo *newo = sdesc->newWire(wdesc, &wire, wdesc->ldesc(), wdesc->prpty_list(), false); if (!newo) { Errs()->add_error("newWire failed"); return (false); } } return (true); } if (val == XprpXY) { int n; Point *p = getpts(string, &n); if (!p) return (false); int px = p->x; int py = p->y; delete [] p; int num = wdesc->numpts(); Wire wire(num, 0, wdesc->attributes()); const Point *pts = wdesc->points(); if (px != pts->x || py != pts->y) { wire.points = new Point[wire.numpts]; int dx = px - pts->x; int dy = py - pts->y; for (int i = 0; i < wire.numpts; i++) { wire.points[i].x = pts[i].x + dx; wire.points[i].y = pts[i].y + dy; } if (wdesc->is_copy()) { delete [] wdesc->points(); wdesc->set_points(wire.points); wdesc->computeBB(); } else { CDo *newo = sdesc->newWire(wdesc, &wire, wdesc->ldesc(), wdesc->prpty_list(), false); if (!newo) { Errs()->add_error("newWire failed"); return (false); } } } return (true); } if (val == XprpWidth) { int w; if (sscanf(string, "%d", &w) != 1 || w <= 0) { Errs()->add_error("error, bad width"); return (false); } BBox BB(wdesc->oBB()); BB.right = BB.left + w; int num = wdesc->numpts(); Wire wire(num, scalepts(&BB, &wdesc->oBB(), wdesc->points(), num), wdesc->attributes()); if (wdesc->is_copy()) { delete [] wdesc->points(); wdesc->set_points(wire.points); wdesc->computeBB(); } else { CDo *newo = sdesc->newWire(wdesc, &wire, wdesc->ldesc(), wdesc->prpty_list(), false); if (!newo) { Errs()->add_error("newWire failed"); return (false); } } return (true); } if (val == XprpHeight) { int h; if (sscanf(string, "%d", &h) != 1 || h <= 0) { Errs()->add_error("error, bad height"); return (false); } BBox BB(wdesc->oBB()); BB.top = BB.bottom + h; int num = wdesc->numpts(); Wire wire(num, scalepts(&BB, &wdesc->oBB(), wdesc->points(), num), wdesc->attributes()); if (wdesc->is_copy()) { delete [] wdesc->points(); wdesc->set_points(wire.points); wdesc->computeBB(); } else { CDo *newo = sdesc->newWire(wdesc, &wire, wdesc->ldesc(), wdesc->prpty_list(), false); if (!newo) { Errs()->add_error("newWire failed"); return (false); } } return (true); } Errs()->add_error("unknown pseudo-property %d", val); return (false); } // Handle pseudo-properties applied to labels. // bool cEdit::acceptLabelPseudoProp(CDla *ladesc, CDs *sdesc, int val, const char *string) { // For labels, accept all (physical or electrical, copy or not). // Have to be careful with electrical property labels. if (val == XprpBB) { BBox BB; if (sscanf(string, "%d,%d %d,%d", &BB.left, &BB.bottom, &BB.right, &BB.top) != 4) { Errs()->add_error( "syntax error, expecting l,b r,t coordinates"); return (false); } BB.fix(); if (ladesc->is_copy()) { ladesc->set_xpos(BB.left); ladesc->set_ypos(BB.bottom); ladesc->set_width(BB.width()); ladesc->set_height(BB.height()); ladesc->computeBB(); } else { Label lab(ladesc->la_label()); lab.x = BB.left; lab.y = BB.bottom; lab.width = BB.width(); lab.height = BB.height(); CDla *newo = sdesc->newLabel(ladesc, &lab, ladesc->ldesc(), ladesc->prpty_list(), true); if (!newo) { Errs()->add_error("newLabel failed"); return (false); } if (sdesc->isElectrical()) sdesc->prptyLabelUpdate(newo, ladesc); } return (true); } if (val == XprpLayer) { CDl *ld = CDldb()->findLayer(string, sdesc->displayMode()); if (!ld) { Errs()->add_error("layer %s not found", string); return (false); } if (ladesc->is_copy()) ladesc->set_ldesc(ld); else { Label ltmp(ladesc->la_label()); CDla *newo = sdesc->newLabel(ladesc, &ltmp, ld, ladesc->prpty_list(), true); if (!newo) { Errs()->add_error("newLabel failed"); return (false); } if (sdesc->isElectrical()) sdesc->prptyLabelUpdate(newo, ladesc); } return (true); } if (val == XprpCoords) { int numpts; Point *p = getpts(string, &numpts); if (!p) return (false); Poly ptmp(numpts, p); if (ptmp.is_rect()) { BBox BB(p); delete [] p; if (ladesc->is_copy()) { ladesc->set_xpos(BB.left); ladesc->set_ypos(BB.bottom); ladesc->set_width(BB.width()); ladesc->set_height(BB.height()); ladesc->computeBB(); } else { Label lab(ladesc->la_label()); lab.x = BB.left; lab.y = BB.bottom; lab.width = BB.width(); lab.height = BB.height(); CDla *newo = sdesc->newLabel(ladesc, &lab, ladesc->ldesc(), ladesc->prpty_list(), true); if (!newo) { Errs()->add_error("newLabel failed"); return (false); } if (sdesc->isElectrical()) sdesc->prptyLabelUpdate(newo, ladesc); } return (true); } Errs()->add_error( "syntax error, expecting rectangular closed path"); delete [] p; return (false); } if (val == XprpText) { if (!string || !*string) { Errs()->add_error("empty string not allowed in label"); return (false); } hyList *hl = new hyList(sdesc, string, HYcvAscii); if (!hl) { Errs()->add_error("internal error: null hyperlist"); return (false); } if (ladesc->is_copy()) { char *oldstr = hyList::string(ladesc->label(), HYcvPlain, false); if (!oldstr) oldstr = lstring::copy("X"); double oldwidth, oldheight; int oldlines = CD()->DefaultLabelSize(oldstr, Physical, &oldwidth, &oldheight); int oldlineht = ladesc->height()/oldlines; delete [] oldstr; double newwidth, newheight; int newlines = CD()->DefaultLabelSize(string, Physical, &newwidth, &newheight); int newlineht = (int)(newheight/newlines); hyList::destroy(ladesc->label()); ladesc->set_label(hl); ladesc->set_height(oldlineht * newlines); ladesc->set_width((int)((newwidth * oldlineht)/newlineht)); ladesc->computeBB(); } else { // This will handle electrical property changes. CDo *newo = changeLabel(ladesc, sdesc, hl); hyList::destroy(hl); if (!newo) { Errs()->add_error("changeLabel failed"); return (false); } } return (true); } if (val == XprpXform) { // format: [+|-] 0xhex | tok,tok,... bool had_p = false, had_m = false; const char *s = string; while (isspace(*s)) s++; if (*s == '+') { had_p = true; s++; } else if (*s == '-') { had_m = true; s++; } unsigned int xf = string_to_xform(s); if (ladesc->is_copy()) { if (had_p) ladesc->set_xform(ladesc->xform() | xf); else if (had_m) ladesc->set_xform(ladesc->xform() & ~xf); else ladesc->set_xform(xf); ladesc->computeBB(); } else { Label lab(ladesc->la_label()); if (had_p) lab.xform |= xf; else if (had_m) lab.xform &= ~xf; else lab.xform = xf; CDla *newo = sdesc->newLabel(ladesc, &lab, ladesc->ldesc(), ladesc->prpty_list(), true); if (!newo) { Errs()->add_error("newLabel failed"); return (false); } if (sdesc->isElectrical()) sdesc->prptyLabelUpdate(newo, ladesc); } return (true); } if (val == XprpMagn) { double mag; if (sscanf(string, "%lf", &mag) != 1) { Errs()->add_error("syntax error, number expected"); return (false); } if (mag < CDMAGMIN || mag > CDMAGMAX) { Errs()->add_error("error, number %g-%g expected", CDMAGMIN, CDMAGMAX); return (false); } if (ladesc->is_copy()) { ladesc->set_width(mmRnd(mag*ladesc->width())); ladesc->set_height(mmRnd(mag*ladesc->height())); ladesc->computeBB(); } else { Label lab(ladesc->la_label()); lab.width = mmRnd(mag*ladesc->width()); lab.height = mmRnd(mag*ladesc->height()); CDla *newo = sdesc->newLabel(ladesc, &lab, ladesc->ldesc(), ladesc->prpty_list(), true); if (!newo) { Errs()->add_error("newLabel failed"); return (false); } if (sdesc->isElectrical()) sdesc->prptyLabelUpdate(newo, ladesc); } return (true); } if (val == XprpXY) { int n; Point *p = getpts(string, &n); if (!p) return (false); int px = p->x; int py = p->y; delete [] p; if (px != ladesc->xpos() || py != ladesc->ypos()) { if (ladesc->is_copy()) { ladesc->set_xpos(px); ladesc->set_ypos(py); ladesc->computeBB(); } else { Label lab(ladesc->la_label()); lab.x = px; lab.y = py; CDla *newo = sdesc->newLabel(ladesc, &lab, ladesc->ldesc(), ladesc->prpty_list(), true); if (!newo) { Errs()->add_error("newLabel failed"); return (false); } if (sdesc->isElectrical()) sdesc->prptyLabelUpdate(newo, ladesc); } } return (true); } if (val == XprpWidth) { int w; if (sscanf(string, "%d", &w) != 1 || w <= 0) { Errs()->add_error("error, bad width"); return (false); } if (ladesc->is_copy()) { ladesc->set_width(w); ladesc->computeBB(); } else { Label lab(ladesc->la_label()); lab.width = w; CDla *newo = sdesc->newLabel(ladesc, &lab, ladesc->ldesc(), ladesc->prpty_list(), true); if (!newo) { Errs()->add_error("newLabel failed"); return (false); } if (sdesc->isElectrical()) sdesc->prptyLabelUpdate(newo, ladesc); } return (true); } if (val == XprpHeight) { int h; if (sscanf(string, "%d", &h) != 1 || h <= 0) { Errs()->add_error("error, bad height"); return (false); } if (ladesc->is_copy()) { ladesc->set_height(h); ladesc->computeBB(); } else { Label lab(ladesc->la_label()); lab.height = h; CDla *newo = sdesc->newLabel(ladesc, &lab, ladesc->ldesc(), ladesc->prpty_list(), true); if (!newo) { Errs()->add_error("newLabel failed"); return (false); } if (sdesc->isElectrical()) sdesc->prptyLabelUpdate(newo, ladesc); } return (true); } Errs()->add_error("unknown pseudo-property %d", val); return (false); } // Handle pseudo-properties applied to instances. // bool cEdit::acceptInstPseudoProp(CDc *cdesc, CDs *sdesc, int val, const char *string) { // For instances, don't accept electrical mode, copies are ok. if (sdesc->isElectrical()) { Errs()->add_error( "Can't change electrical instance with pseudo-properties."); return (false); } if (val == XprpArray) { int nx, ny, dx, dy; if (sscanf(string, "%d,%d %d,%d", &nx, &ny, &dx, &dy) != 4) { Errs()->add_error( "syntax error, expecting nx,dx ny,dy values"); return (false); } if (nx < 1 || ny < 1) { Errs()->add_error("error, nx or ny less than 1"); return (false); } if (cdesc->is_copy()) { cTfmStack stk; stk.TPush(); stk.TApplyTransform(cdesc); CDtx tx; stk.TCurrent(&tx); stk.TPop(); CDap ap(nx, ny, dx, dy); CDattr at(&tx, &ap); cdesc->setAttr(CD()->RecordAttr(&at)); } else { CallDesc calldesc; cdesc->call(&calldesc); cTfmStack stk; stk.TPush(); stk.TApplyTransform(cdesc); CDtx tx; stk.TCurrent(&tx); stk.TPop(); CDap ap(nx, ny, dx, dy); CDc *newodesc; if (OIfailed(sdesc->makeCall(&calldesc, &tx, &ap, CDcallNone, &newodesc))) { Errs()->add_error("makeCall failed"); return (false); } newodesc->prptyAddCopyList(cdesc->prpty_list()); Ulist()->RecordObjectChange(sdesc, cdesc, newodesc); } return (true); } if (val == XprpTransf) { cTfmStack stk; stk.TPush(); for (const char *s = string; *s; s++) { if (isspace(*s)) continue; if (*s == 'T') { s++; char *tok = lstring::gettok(&s); if (!tok) { stk.TPop(); Errs()->add_error( "syntax error, expecting translation x"); return (false); } int x = atoi(tok); delete [] tok; tok = lstring::gettok(&s); if (!tok) { stk.TPop(); Errs()->add_error( "syntax error, expecting translation y"); return (false); } int y = atoi(tok); delete [] tok; stk.TTranslate(x, y); s--; } else if (*s == 'R') { s++; char *tok = lstring::gettok(&s); if (!tok) { stk.TPop(); Errs()->add_error( "syntax error, expecting rotation angle"); return (false); } s--; int r = atoi(tok); delete [] tok; int x, y; if (r == 0) x = 1, y = 0; else if (r == 45) x = 1, y = 1; else if (r == 90) x = 0, y = 1; else if (r == 135) x = -1, y = 1; else if (r == 180) x = -1, y = 0; else if (r == 225) x = -1, y = -1; else if (r == 270) x = 0, y = -1; else if (r == 315) x = 1, y = -1; else { stk.TPop(); Errs()->add_error("error, bad angle"); return (false); } stk.TRotate(x, y); } else if (*s == 'M') { s++; if (*s == 'X') stk.TMX(); else if (*s == 'Y') stk.TMY(); else { stk.TPop(); Errs()->add_error( "syntax error, expecting MX or MY"); return (false); } } else { stk.TPop(); Errs()->add_error( "syntax error, unknown transformation"); return (false); } } CDtx tx; stk.TCurrent(&tx); stk.TPop(); if (cdesc->is_copy()) { CDap ap(cdesc); CDattr at(&tx, &ap); cdesc->setPosX(tx.tx); cdesc->setPosY(tx.ty); cdesc->setAttr(CD()->RecordAttr(&at)); } else { CallDesc calldesc; cdesc->call(&calldesc); CDap ap(cdesc); CDc *newodesc; if (OIfailed(sdesc->makeCall(&calldesc, &tx, &ap, CDcallNone, &newodesc))) { Errs()->add_error("makeCall failed"); return (false); } newodesc->prptyAddCopyList(cdesc->prpty_list()); Ulist()->RecordObjectChange(sdesc, cdesc, newodesc); } return (true); } if (val == XprpMagn) { double mag; if (sscanf(string, "%lf", &mag) != 1) { Errs()->add_error("syntax error, number expected"); return (false); } if (mag < CDMAGMIN || mag > CDMAGMAX) { Errs()->add_error("error, number %g-%g expected", CDMAGMIN, CDMAGMAX); return (false); } if (cdesc->is_copy()) { cTfmStack stk; stk.TPush(); stk.TApplyTransform(cdesc); CDtx tx; stk.TCurrent(&tx); stk.TPop(); CDap ap(cdesc); tx.magn = mag; CDattr at(&tx, &ap); cdesc->setAttr(CD()->RecordAttr(&at)); } else { CallDesc calldesc; cdesc->call(&calldesc); cTfmStack stk; stk.TPush(); stk.TApplyTransform(cdesc); CDtx tx; stk.TCurrent(&tx); stk.TPop(); CDap ap(cdesc); tx.magn = mag; CDc *newodesc; if (OIfailed(sdesc->makeCall(&calldesc, &tx, &ap, CDcallNone, &newodesc))) { Errs()->add_error("makeCall failed"); return (false); } newodesc->prptyAddCopyList(cdesc->prpty_list()); Ulist()->RecordObjectChange(sdesc, cdesc, newodesc); } return (true); } if (val == XprpName) { if (cdesc->is_copy()) { Errs()->add_error("Can't re-master an instance copy."); return (false); } else { if (sdesc->cellname() == DSP()->CurCellName()) { CDcbin cbin; if (!openCell(string, &cbin, 0)) { Errs()->add_error("OpenSymbol failed"); return (false); } if (!replaceInstance(cdesc, &cbin, true, false)) { Errs()->add_error("ReplaceCell failed"); return (false); } return (true); } Errs()->add_error("instance parent not current cell"); } return (false); } if (val == XprpXY) { int n; Point *p = getpts(string, &n); if (!p) return (false); int px = p->x; int py = p->y; delete [] p; if (px != cdesc->posX() || py != cdesc->posY()) { if (cdesc->is_copy()) { cTfmStack stk; stk.TPush(); stk.TApplyTransform(cdesc); CDtx tx; stk.TCurrent(&tx); stk.TPop(); CDap ap(cdesc); tx.tx = px; tx.ty = py; CDattr at(&tx, &ap); cdesc->setPosX(tx.tx); cdesc->setPosY(tx.ty); cdesc->setAttr(CD()->RecordAttr(&at)); } else { CallDesc calldesc; cdesc->call(&calldesc); cTfmStack stk; stk.TPush(); stk.TApplyTransform(cdesc); CDtx tx; stk.TCurrent(&tx); stk.TPop(); CDap ap(cdesc); tx.tx = px; tx.ty = py; CDc *newodesc; if (OIfailed(sdesc->makeCall(&calldesc, &tx, &ap, CDcallNone, &newodesc))) { Errs()->add_error("makeCall failed"); return (false); } newodesc->prptyAddCopyList(cdesc->prpty_list()); Ulist()->RecordObjectChange(sdesc, cdesc, newodesc); } } return (true); } Errs()->add_error("unknown pseudo-property %d", val); return (false); } namespace { // Scale points according to new BB // Point * scalepts(const BBox *BB, const BBox *oBB, const Point *pts, int numpts) { Point *npts = new Point[numpts]; double rx = BB->width()/(double)oBB->width(); double ry = BB->height()/(double)oBB->height(); for (int i = 0; i < numpts; i++) { npts[i].x = mmRnd((pts[i].x - oBB->left)*rx + BB->left); npts[i].y = mmRnd((pts[i].y - oBB->bottom)*ry + BB->bottom); } return (npts); } // Parse a list of "%d,%d" coordinates // Point * getpts(const char *string, int *num) { const char *s = string; int cnt = 0; while (*s) { lstring::advtok(&s); cnt++; } if (!cnt) { Errs()->add_error("no coords found!"); return (0); } Point *pts = new Point[cnt]; cnt = 0; while ((s = lstring::gettok(&string)) != 0) { if (sscanf(s, "%d,%d", &pts[cnt].x, &pts[cnt].y) != 2) { delete [] s; delete [] pts; Errs()->add_error("parse error reading coords!"); return (0); } delete [] s; cnt++; } *num = cnt; return (pts); } }
[ "stevew@wrcad.com" ]
stevew@wrcad.com
a8d13b51c1b878df8159eadc0fc113ab11268e05
67ba655579bd283ab497a151fa20b7ed3befaf75
/cpp_concurrency/blog_code/Threads_2.cpp
86e372d07de51cc16405c6d0b13d245b48365a25
[]
no_license
JeffYoung17/Course_Learning
f8ca46fb57afd879b1bc577cf91c13b6b92b065e
d16b0e93df91d6c185341b8825c31b364c194a4c
refs/heads/master
2020-04-04T03:50:20.752189
2019-02-19T11:56:16
2019-02-19T11:56:16
155,727,976
0
0
null
null
null
null
UTF-8
C++
false
false
392
cpp
#include <iostream> #include <thread> #include <string> #include <cstring> using namespace std; void func(int i, double d, const std::string& s) // 因为对于s是常引用,所以启动线程的时候std::ref("hello")可有可无 { cout << i << " " << d << " " << s << endl; } int main(int argc, char** argv) { std::thread t(func, 1, 3.14, "hello"); t.join(); return 0; }
[ "jeffyoung17@163.com" ]
jeffyoung17@163.com
d979e55629a2b99b60faa8d7812c017587563248
41bc79f836e2aead9bdc0bade84dc06397d9b3d2
/Arduino_Software/libraries/Adafruit_LED_Backpack_Library/Adafruit_LEDBackpack.cpp
0767d2bbb71e53655307fb80b43b5bf9a70d1ebb
[ "MIT" ]
permissive
edinnen/Thanksgiving_Intranet
44ffce06913139d50bd171993ab271ec615c0c69
1e2b4a3f705228e9a92e82ce42217cb9ba6f07b0
refs/heads/master
2023-01-06T18:36:51.544023
2022-12-28T19:15:50
2022-12-28T19:15:50
94,859,889
2
0
MIT
2020-11-10T05:49:29
2017-06-20T06:58:57
Raku
UTF-8
C++
false
false
16,636
cpp
/*! * @file Adafruit_LEDBackpack.cpp * * @mainpage Adafruit LED Backpack library for Arduino. * * @section intro_sec Introduction * * This is an Arduino library for our I2C LED Backpacks: * ----> http://www.adafruit.com/products/ * ----> http://www.adafruit.com/products/ * * These displays use I2C to communicate, 2 pins are required to * interface. There are multiple selectable I2C addresses. For backpacks * with 2 Address Select pins: 0x70, 0x71, 0x72 or 0x73. For backpacks * with 3 Address Select pins: 0x70 thru 0x77 * * Adafruit invests time and resources providing this open source code, * please support Adafruit and open-source hardware by purchasing * products from Adafruit! * * @section dependencies Dependencies * * This library depends on <a * href="https://github.com/adafruit/Adafruit-GFX-Library"> Adafruit_GFX</a> * being present on your system. Please make sure you have installed the latest * version before using this library. * * @section author Author * * Written by Limor Fried/Ladyada for Adafruit Industries. * * @section license License * * MIT license, all text above must be included in any redistribution * */ #include <Wire.h> #include "Adafruit_GFX.h" #include "Adafruit_LEDBackpack.h" #ifndef _BV #define _BV(bit) (1 << (bit)) ///< Bit-value if not defined by Arduino #endif #ifndef _swap_int16_t #define _swap_int16_t(a, b) \ { \ int16_t t = a; \ a = b; \ b = t; \ } ///< 16-bit var swap #endif static const uint8_t numbertable[] = { 0x3F, /* 0 */ 0x06, /* 1 */ 0x5B, /* 2 */ 0x4F, /* 3 */ 0x66, /* 4 */ 0x6D, /* 5 */ 0x7D, /* 6 */ 0x07, /* 7 */ 0x7F, /* 8 */ 0x6F, /* 9 */ 0x77, /* a */ 0x7C, /* b */ 0x39, /* C */ 0x5E, /* d */ 0x79, /* E */ 0x71, /* F */ }; static const uint16_t alphafonttable[] PROGMEM = { 0b0000000000000001, 0b0000000000000010, 0b0000000000000100, 0b0000000000001000, 0b0000000000010000, 0b0000000000100000, 0b0000000001000000, 0b0000000010000000, 0b0000000100000000, 0b0000001000000000, 0b0000010000000000, 0b0000100000000000, 0b0001000000000000, 0b0010000000000000, 0b0100000000000000, 0b1000000000000000, 0b0000000000000000, 0b0000000000000000, 0b0000000000000000, 0b0000000000000000, 0b0000000000000000, 0b0000000000000000, 0b0000000000000000, 0b0000000000000000, 0b0001001011001001, 0b0001010111000000, 0b0001001011111001, 0b0000000011100011, 0b0000010100110000, 0b0001001011001000, 0b0011101000000000, 0b0001011100000000, 0b0000000000000000, // 0b0000000000000110, // ! 0b0000001000100000, // " 0b0001001011001110, // # 0b0001001011101101, // $ 0b0000110000100100, // % 0b0010001101011101, // & 0b0000010000000000, // ' 0b0010010000000000, // ( 0b0000100100000000, // ) 0b0011111111000000, // * 0b0001001011000000, // + 0b0000100000000000, // , 0b0000000011000000, // - 0b0000000000000000, // . 0b0000110000000000, // / 0b0000110000111111, // 0 0b0000000000000110, // 1 0b0000000011011011, // 2 0b0000000010001111, // 3 0b0000000011100110, // 4 0b0010000001101001, // 5 0b0000000011111101, // 6 0b0000000000000111, // 7 0b0000000011111111, // 8 0b0000000011101111, // 9 0b0001001000000000, // : 0b0000101000000000, // ; 0b0010010000000000, // < 0b0000000011001000, // = 0b0000100100000000, // > 0b0001000010000011, // ? 0b0000001010111011, // @ 0b0000000011110111, // A 0b0001001010001111, // B 0b0000000000111001, // C 0b0001001000001111, // D 0b0000000011111001, // E 0b0000000001110001, // F 0b0000000010111101, // G 0b0000000011110110, // H 0b0001001000000000, // I 0b0000000000011110, // J 0b0010010001110000, // K 0b0000000000111000, // L 0b0000010100110110, // M 0b0010000100110110, // N 0b0000000000111111, // O 0b0000000011110011, // P 0b0010000000111111, // Q 0b0010000011110011, // R 0b0000000011101101, // S 0b0001001000000001, // T 0b0000000000111110, // U 0b0000110000110000, // V 0b0010100000110110, // W 0b0010110100000000, // X 0b0001010100000000, // Y 0b0000110000001001, // Z 0b0000000000111001, // [ 0b0010000100000000, // 0b0000000000001111, // ] 0b0000110000000011, // ^ 0b0000000000001000, // _ 0b0000000100000000, // ` 0b0001000001011000, // a 0b0010000001111000, // b 0b0000000011011000, // c 0b0000100010001110, // d 0b0000100001011000, // e 0b0000000001110001, // f 0b0000010010001110, // g 0b0001000001110000, // h 0b0001000000000000, // i 0b0000000000001110, // j 0b0011011000000000, // k 0b0000000000110000, // l 0b0001000011010100, // m 0b0001000001010000, // n 0b0000000011011100, // o 0b0000000101110000, // p 0b0000010010000110, // q 0b0000000001010000, // r 0b0010000010001000, // s 0b0000000001111000, // t 0b0000000000011100, // u 0b0010000000000100, // v 0b0010100000010100, // w 0b0010100011000000, // x 0b0010000000001100, // y 0b0000100001001000, // z 0b0000100101001001, // { 0b0001001000000000, // | 0b0010010010001001, // } 0b0000010100100000, // ~ 0b0011111111111111, }; void Adafruit_LEDBackpack::setBrightness(uint8_t b) { if (b > 15) b = 15; Wire.beginTransmission(i2c_addr); Wire.write(HT16K33_CMD_BRIGHTNESS | b); Wire.endTransmission(); } void Adafruit_LEDBackpack::blinkRate(uint8_t b) { Wire.beginTransmission(i2c_addr); if (b > 3) b = 0; // turn off if not sure Wire.write(HT16K33_BLINK_CMD | HT16K33_BLINK_DISPLAYON | (b << 1)); Wire.endTransmission(); } Adafruit_LEDBackpack::Adafruit_LEDBackpack(void) {} void Adafruit_LEDBackpack::begin(uint8_t _addr = 0x70) { i2c_addr = _addr; Wire.begin(); Wire.beginTransmission(i2c_addr); Wire.write(0x21); // turn on oscillator Wire.endTransmission(); // internal RAM powers up with garbage/random values. // ensure internal RAM is cleared before turning on display // this ensures that no garbage pixels show up on the display // when it is turned on. clear(); writeDisplay(); blinkRate(HT16K33_BLINK_OFF); setBrightness(15); // max brightness } void Adafruit_LEDBackpack::writeDisplay(void) { Wire.beginTransmission(i2c_addr); Wire.write((uint8_t)0x00); // start at address $00 for (uint8_t i = 0; i < 8; i++) { Wire.write(displaybuffer[i] & 0xFF); Wire.write(displaybuffer[i] >> 8); } Wire.endTransmission(); } void Adafruit_LEDBackpack::clear(void) { for (uint8_t i = 0; i < 8; i++) { displaybuffer[i] = 0; } } /******************************* QUAD ALPHANUM OBJECT */ Adafruit_AlphaNum4::Adafruit_AlphaNum4(void) {} void Adafruit_AlphaNum4::writeDigitRaw(uint8_t n, uint16_t bitmask) { displaybuffer[n] = bitmask; } void Adafruit_AlphaNum4::writeDigitAscii(uint8_t n, uint8_t a, bool d) { uint16_t font = pgm_read_word(alphafonttable + a); displaybuffer[n] = font; /* Serial.print(a, DEC); Serial.print(" / '"); Serial.write(a); Serial.print("' = 0x"); Serial.println(font, HEX); */ if (d) displaybuffer[n] |= (1 << 14); } /******************************* 24 BARGRAPH OBJECT */ Adafruit_24bargraph::Adafruit_24bargraph(void) {} void Adafruit_24bargraph::setBar(uint8_t bar, uint8_t color) { uint16_t a, c; if (bar < 12) c = bar / 4; else c = (bar - 12) / 4; a = bar % 4; if (bar >= 12) a += 4; // Serial.print("Ano = "); Serial.print(a); Serial.print(" Cath = "); // Serial.println(c); if (color == LED_RED) { // Turn on red LED. displaybuffer[c] |= _BV(a); // Turn off green LED. displaybuffer[c] &= ~_BV(a + 8); } else if (color == LED_YELLOW) { // Turn on red and green LED. displaybuffer[c] |= _BV(a) | _BV(a + 8); } else if (color == LED_OFF) { // Turn off red and green LED. displaybuffer[c] &= ~_BV(a) & ~_BV(a + 8); } else if (color == LED_GREEN) { // Turn on green LED. displaybuffer[c] |= _BV(a + 8); // Turn off red LED. displaybuffer[c] &= ~_BV(a); } } /******************************* 16x8 MATRIX OBJECT */ Adafruit_8x16matrix::Adafruit_8x16matrix(void) : Adafruit_GFX(8, 16) {} void Adafruit_8x16matrix::drawPixel(int16_t x, int16_t y, uint16_t color) { // check rotation, move pixel around if necessary switch (getRotation()) { case 2: _swap_int16_t(x, y); x = 16 - x - 1; break; case 3: x = 16 - x - 1; y = 8 - y - 1; break; case 0: _swap_int16_t(x, y); y = 8 - y - 1; break; } /* Serial.print("("); Serial.print(x); Serial.print(","); Serial.print(y); Serial.println(")"); */ if ((y < 0) || (y >= 8)) return; if ((x < 0) || (x >= 16)) return; if (color) { displaybuffer[y] |= 1 << x; } else { displaybuffer[y] &= ~(1 << x); } } /******************************* 16x8 MINI MATRIX OBJECT */ Adafruit_8x16minimatrix::Adafruit_8x16minimatrix(void) : Adafruit_GFX(8, 16) {} void Adafruit_8x16minimatrix::drawPixel(int16_t x, int16_t y, uint16_t color) { if ((y < 0) || (x < 0)) return; if ((getRotation() % 2 == 0) && ((y >= 16) || (x >= 8))) return; if ((getRotation() % 2 == 1) && ((x >= 16) || (y >= 8))) return; // check rotation, move pixel around if necessary switch (getRotation()) { case 2: if (y >= 8) { x += 8; y -= 8; } _swap_int16_t(x, y); break; case 3: x = 16 - x - 1; if (x >= 8) { x -= 8; y += 8; } break; case 0: y = 16 - y - 1; x = 8 - x - 1; if (y >= 8) { x += 8; y -= 8; } _swap_int16_t(x, y); break; case 1: y = 8 - y - 1; if (x >= 8) { x -= 8; y += 8; } break; } if (color) { displaybuffer[x] |= 1 << y; } else { displaybuffer[x] &= ~(1 << y); } } /******************************* 8x8 MATRIX OBJECT */ Adafruit_8x8matrix::Adafruit_8x8matrix(void) : Adafruit_GFX(8, 8) {} void Adafruit_8x8matrix::drawPixel(int16_t x, int16_t y, uint16_t color) { if ((y < 0) || (y >= 8)) return; if ((x < 0) || (x >= 8)) return; // check rotation, move pixel around if necessary switch (getRotation()) { case 1: _swap_int16_t(x, y); x = 8 - x - 1; break; case 2: x = 8 - x - 1; y = 8 - y - 1; break; case 3: _swap_int16_t(x, y); y = 8 - y - 1; break; } // wrap around the x x += 7; x %= 8; if (color) { displaybuffer[y] |= 1 << x; } else { displaybuffer[y] &= ~(1 << x); } } /******************************* 8x8 BICOLOR MATRIX OBJECT */ Adafruit_BicolorMatrix::Adafruit_BicolorMatrix(void) : Adafruit_GFX(8, 8) {} void Adafruit_BicolorMatrix::drawPixel(int16_t x, int16_t y, uint16_t color) { if ((y < 0) || (y >= 8)) return; if ((x < 0) || (x >= 8)) return; switch (getRotation()) { case 1: _swap_int16_t(x, y); x = 8 - x - 1; break; case 2: x = 8 - x - 1; y = 8 - y - 1; break; case 3: _swap_int16_t(x, y); y = 8 - y - 1; break; } if (color == LED_GREEN) { // Turn on green LED. displaybuffer[y] |= 1 << x; // Turn off red LED. displaybuffer[y] &= ~(1 << (x + 8)); } else if (color == LED_RED) { // Turn on red LED. displaybuffer[y] |= 1 << (x + 8); // Turn off green LED. displaybuffer[y] &= ~(1 << x); } else if (color == LED_YELLOW) { // Turn on green and red LED. displaybuffer[y] |= (1 << (x + 8)) | (1 << x); } else if (color == LED_OFF) { // Turn off green and red LED. displaybuffer[y] &= ~(1 << x) & ~(1 << (x + 8)); } } /******************************* 7 SEGMENT OBJECT */ Adafruit_7segment::Adafruit_7segment(void) { position = 0; } void Adafruit_7segment::print(unsigned long n, int base) { if (base == 0) write(n); else printNumber(n, base); } void Adafruit_7segment::print(char c, int base) { print((long)c, base); } void Adafruit_7segment::print(unsigned char b, int base) { print((unsigned long)b, base); } void Adafruit_7segment::print(int n, int base) { print((long)n, base); } void Adafruit_7segment::print(unsigned int n, int base) { print((unsigned long)n, base); } void Adafruit_7segment::println(void) { position = 0; } void Adafruit_7segment::println(char c, int base) { print(c, base); println(); } void Adafruit_7segment::println(unsigned char b, int base) { print(b, base); println(); } void Adafruit_7segment::println(int n, int base) { print(n, base); println(); } void Adafruit_7segment::println(unsigned int n, int base) { print(n, base); println(); } void Adafruit_7segment::println(long n, int base) { print(n, base); println(); } void Adafruit_7segment::println(unsigned long n, int base) { print(n, base); println(); } void Adafruit_7segment::println(double n, int digits) { print(n, digits); println(); } void Adafruit_7segment::print(double n, int digits) { printFloat(n, digits); } size_t Adafruit_7segment::write(uint8_t c) { uint8_t r = 0; if (c == '\n') position = 0; if (c == '\r') position = 0; if ((c >= '0') && (c <= '9')) { writeDigitNum(position, c - '0'); r = 1; } position++; if (position == 2) position++; return r; } void Adafruit_7segment::writeDigitRaw(uint8_t d, uint8_t bitmask) { if (d > 4) return; displaybuffer[d] = bitmask; } void Adafruit_7segment::drawColon(bool state) { if (state) displaybuffer[2] = 0x2; else displaybuffer[2] = 0; } void Adafruit_7segment::writeColon(void) { Wire.beginTransmission(i2c_addr); Wire.write((uint8_t)0x04); // start at address $02 Wire.write(displaybuffer[2] & 0xFF); Wire.write(displaybuffer[2] >> 8); Wire.endTransmission(); } void Adafruit_7segment::writeDigitNum(uint8_t d, uint8_t num, bool dot) { if (d > 4) return; writeDigitRaw(d, numbertable[num] | (dot << 7)); } void Adafruit_7segment::print(long n, int base) { printNumber(n, base); } void Adafruit_7segment::printNumber(long n, uint8_t base) { printFloat(n, 0, base); } void Adafruit_7segment::printFloat(double n, uint8_t fracDigits, uint8_t base) { uint8_t numericDigits = 4; // available digits on display bool isNegative = false; // true if the number is negative // is the number negative? if (n < 0) { isNegative = true; // need to draw sign later --numericDigits; // the sign will take up one digit n *= -1; // pretend the number is positive } // calculate the factor required to shift all fractional digits // into the integer part of the number double toIntFactor = 1.0; for (int i = 0; i < fracDigits; ++i) toIntFactor *= base; // create integer containing digits to display by applying // shifting factor and rounding adjustment uint32_t displayNumber = n * toIntFactor + 0.5; // calculate upper bound on displayNumber given // available digits on display uint32_t tooBig = 1; for (int i = 0; i < numericDigits; ++i) tooBig *= base; // if displayNumber is too large, try fewer fractional digits while (displayNumber >= tooBig) { --fracDigits; toIntFactor /= base; displayNumber = n * toIntFactor + 0.5; } // did toIntFactor shift the decimal off the display? if (toIntFactor < 1) { printError(); } else { // otherwise, display the number int8_t displayPos = 4; if (displayNumber) // if displayNumber is not 0 { for (uint8_t i = 0; displayNumber || i <= fracDigits; ++i) { bool displayDecimal = (fracDigits != 0 && i == fracDigits); writeDigitNum(displayPos--, displayNumber % base, displayDecimal); if (displayPos == 2) writeDigitRaw(displayPos--, 0x00); displayNumber /= base; } } else { writeDigitNum(displayPos--, 0, false); } // display negative sign if negative if (isNegative) writeDigitRaw(displayPos--, 0x40); // clear remaining display positions while (displayPos >= 0) writeDigitRaw(displayPos--, 0x00); } } void Adafruit_7segment::printError(void) { for (uint8_t i = 0; i < SEVENSEG_DIGITS; ++i) { writeDigitRaw(i, (i == 2 ? 0x00 : 0x40)); } }
[ "stuartdehaas@gmail.com" ]
stuartdehaas@gmail.com
5587adbeb596df8cb5ac329dc23eebc7542cecc4
eeb9de1ca9fbdb7540c5cf361a13e70e1b73293e
/1368.cpp
66ee4b3516082c15238b656d4782b11d797a5caa
[]
no_license
RatanNarayanHegde/CompetitiveProgramming
64eee84381e49442615b5ba53359faebb46d717b
4c11a3bdf739a9b3ef2ab52ac78b9181c78bb069
refs/heads/master
2023-04-28T14:37:15.694314
2021-05-25T07:44:38
2021-05-25T07:44:38
347,784,805
0
0
null
null
null
null
UTF-8
C++
false
false
1,870
cpp
#include<bits/stdc++.h> using namespace std; #define ff first #define fo(i,n) for(i=0;i<n;i++) #define Fo(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1) #define deb(x) cout << #x << "=" << x << endl #define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl #define ss second #define int long long #define pb push_back #define mp make_pair #define pii pair<int,int> #define vi vector<int> #define mii map<int,int> #define pqb priority_queue<int> #define pqs priority_queue<int,vi,greater<int> > #define setbits(x) __builtin_popcountll(x) #define zrobits(x) __builtin_ctzll(x) #define mod 1000000007 #define inf 1e18 #define ps(x,y) fixed<<setprecision(y)<<x #define w(x) int x; cin>>x; while(x--) #define FIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0) mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); const int N = 3e5, M = N; //======================= void solve() { int i, j, n, m; cin>>n; int times; for(int i=1;i<=40;i++){ if(pow(i,10)>=n){ times=i; break; } } if(times==1){ cout<<"codeforces";return; } int count=0; int curr = pow(times-1,10); while(curr<n){ count++; curr*=times; curr/=(times-1); } // cout<<count; string str="codeforces"; string res; for(int i=0;i<10;i++){ if(count){ for(int j=0;j<times;j++){ res+=str[i]; } count--; } else{ for(int j=0;j<times-1;j++){ res+=str[i]; } } } // cout<<times; cout<<res; } int32_t main() { FIO; #ifndef ONLINE_JUDGE freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #endif solve(); return 0; }
[ "ratanhegde@pop-os.localdomain" ]
ratanhegde@pop-os.localdomain
9e2f9221c15b7d4cc1a18ba788916fa703c935c6
a7a2f3503d37531fa17524dac445aa7efa4f1d9d
/src/NEO/Transaction.cpp
66b88d9ef83dd16a0598e7556614d03c051971f5
[ "MIT" ]
permissive
vcoolish/wallet-core
efb18153238b9eac7586d93217891f42fa5ca21c
c9e32ea6b52958a386ffce8a31e6d70494bbb3da
refs/heads/master
2023-04-06T07:49:19.561856
2022-06-10T04:40:24
2022-06-10T04:40:24
210,317,098
0
0
MIT
2019-09-23T09:35:26
2019-09-23T09:35:25
null
UTF-8
C++
false
false
2,747
cpp
// Copyright © 2017-2020 Trust Wallet. // // This file is part of Trust. The full Trust copyright notice, including // terms governing use, modification, and redistribution, is contained in the // file LICENSE at the root of the source code distribution tree. #include <ctype.h> #include "../uint256.h" #include "../Data.h" #include "../Hash.h" #include "Transaction.h" #include "MinerTransaction.h" using namespace std; using namespace TW; using namespace TW::NEO; int64_t Transaction::size() const { return serialize().size(); } void Transaction::deserialize(const Data& data, int initial_pos) { type = (TransactionType) data[initial_pos++]; version = data[initial_pos++]; initial_pos = deserializeExclusiveData(data, initial_pos); attributes.clear(); initial_pos = Serializable::deserialize<TransactionAttribute>(attributes, data, initial_pos); inInputs.clear(); initial_pos = Serializable::deserialize<CoinReference>(inInputs, data, initial_pos); outputs.clear(); Serializable::deserialize<TransactionOutput>(outputs, data, initial_pos); } Transaction * Transaction::deserializeFrom(const Data& data, int initial_pos) { Transaction * resp = nullptr; switch ((TransactionType) data[initial_pos]) { case TransactionType::TT_MinerTransaction: resp = new MinerTransaction(); break; default: throw std::invalid_argument("Transaction::deserializeFrom Invalid transaction type"); break; } resp->deserialize(data, initial_pos); return resp; } Data Transaction::serialize() const { Data resp; resp.push_back((byte) type); resp.push_back(version); append(resp, serializeExclusiveData()); append(resp, Serializable::serialize(attributes)); append(resp, Serializable::serialize(inInputs)); append(resp, Serializable::serialize(outputs)); if(witnesses.size()) { resp.push_back((byte) witnesses.size()); for (const auto& witnesse : witnesses) append(resp, witnesse.serialize()); } return resp; } bool Transaction::operator==(const Transaction &other) const { if (this == &other) { return true; } return this->type == other.type && this->version == other.version && this->attributes.size() == other.attributes.size() && this->inInputs.size() == other.inInputs.size() && this->outputs.size() == other.outputs.size() && this->attributes == other.attributes && this->inInputs == other.inInputs && this->outputs == other.outputs; } Data Transaction::getHash() const { return Hash::sha256(Hash::sha256(serialize())); } uint256_t Transaction::getHashUInt256() const { return load(getHash()); }
[ "noreply@github.com" ]
vcoolish.noreply@github.com
a0b9ab5393537619f5e8a9788fa734a8340b0bf5
19d1c24484c1771c0be7cdef45f3342a6889a4cb
/nnforge/cuda/maxout_layer_tester_cuda.h
80cb5fe4b8b48118718bfd5067def043e5630985
[ "Apache-2.0" ]
permissive
dreadlord1984/nnForge
06bc261fa9d9d58c45aafdbf3f7026990809c288
b4c795ab6ddf3ce9dfe8a628dd1ad33dd19dee9b
refs/heads/master
2021-01-18T13:40:21.646717
2014-08-06T18:23:53
2014-08-06T18:23:53
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,667
h
/* * Copyright 2011-2013 Maxim Milakov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #pragma once #include "layer_tester_cuda.h" namespace nnforge { namespace cuda { class maxout_layer_tester_cuda : public layer_tester_cuda { public: maxout_layer_tester_cuda(); virtual ~maxout_layer_tester_cuda(); virtual void enqueue_test( cudaStream_t stream_id, const std::vector<const_cuda_linear_buffer_device_smart_ptr>& schema_data, const std::vector<const_cuda_linear_buffer_device_smart_ptr>& data, cuda_linear_buffer_device_smart_ptr input_buffer, const std::vector<cuda_linear_buffer_device_smart_ptr>& additional_buffers, unsigned int entry_count); virtual cuda_linear_buffer_device_smart_ptr get_output_buffer( cuda_linear_buffer_device_smart_ptr input_buffer, const std::vector<cuda_linear_buffer_device_smart_ptr>& additional_buffers); protected: virtual void tester_configured(); virtual std::vector<size_t> get_sizes_of_additional_buffers_per_entry() const; private: int feature_map_subsampling_size; }; } }
[ "maxim.milakov@gmail.com" ]
maxim.milakov@gmail.com
5fddedf0b6ef257bf775fc8730d514eddcea70c4
7597b69c2b1a785d3d622e254c953fc129c9746d
/libcryptopp/include/modes.h
5a30fd84be77dd56e129073376ea2231f1eb30fc
[]
no_license
wonlake/ThirdPartyLib
2f38cc806b946c24032e60f053cf370575029d05
6b11d060300bb4beb2f8e4cf0fe8af0a85d2de3e
refs/heads/master
2022-05-09T21:04:13.036440
2022-04-18T13:33:14
2022-04-18T13:33:14
116,561,211
0
0
null
null
null
null
UTF-8
C++
false
false
21,685
h
// modes.h - originally written and placed in the public domain by Wei Dai //! \file modes.h //! \brief Classes for block cipher modes of operation #ifndef CRYPTOPP_MODES_H #define CRYPTOPP_MODES_H #include "cryptlib.h" #include "secblock.h" #include "misc.h" #include "strciphr.h" #include "argnames.h" #include "algparam.h" // Issue 340 #if CRYPTOPP_GCC_DIAGNOSTIC_AVAILABLE # pragma GCC diagnostic push # pragma GCC diagnostic ignored "-Wconversion" # pragma GCC diagnostic ignored "-Wsign-conversion" #endif #if CRYPTOPP_MSC_VERSION # pragma warning(push) # pragma warning(disable: 4231 4275) # if (CRYPTOPP_MSC_VERSION >= 1400) # pragma warning(disable: 6011 6386 28193) # endif #endif NAMESPACE_BEGIN(CryptoPP) //! \class CipherModeDocumentation //! \brief Block cipher mode of operation information //! \details Each class derived from this one defines two types, Encryption and Decryption, //! both of which implement the SymmetricCipher interface. //! For each mode there are two classes, one of which is a template class, //! and the other one has a name that ends in "_ExternalCipher". //! The "external cipher" mode objects hold a reference to the underlying block cipher, //! instead of holding an instance of it. The reference must be passed in to the constructor. //! For the "cipher holder" classes, the CIPHER template parameter should be a class //! derived from BlockCipherDocumentation, for example DES or AES. //! \details See NIST SP 800-38A for definitions of these modes. See //! AuthenticatedSymmetricCipherDocumentation for authenticated encryption modes. struct CipherModeDocumentation : public SymmetricCipherDocumentation { }; //! \class CipherModeBase //! \brief Block cipher mode of operation information class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE CipherModeBase : public SymmetricCipher { public: virtual ~CipherModeBase() {} size_t MinKeyLength() const {return m_cipher->MinKeyLength();} size_t MaxKeyLength() const {return m_cipher->MaxKeyLength();} size_t DefaultKeyLength() const {return m_cipher->DefaultKeyLength();} size_t GetValidKeyLength(size_t n) const {return m_cipher->GetValidKeyLength(n);} bool IsValidKeyLength(size_t n) const {return m_cipher->IsValidKeyLength(n);} unsigned int OptimalDataAlignment() const {return m_cipher->OptimalDataAlignment();} unsigned int IVSize() const {return BlockSize();} virtual IV_Requirement IVRequirement() const =0; void SetCipher(BlockCipher &cipher) { this->ThrowIfResynchronizable(); this->m_cipher = &cipher; this->ResizeBuffers(); } void SetCipherWithIV(BlockCipher &cipher, const byte *iv, int feedbackSize = 0) { this->ThrowIfInvalidIV(iv); this->m_cipher = &cipher; this->ResizeBuffers(); this->SetFeedbackSize(feedbackSize); if (this->IsResynchronizable()) this->Resynchronize(iv); } protected: CipherModeBase() : m_cipher(NULLPTR) {} inline unsigned int BlockSize() const {CRYPTOPP_ASSERT(m_register.size() > 0); return (unsigned int)m_register.size();} virtual void SetFeedbackSize(unsigned int feedbackSize) { if (!(feedbackSize == 0 || feedbackSize == BlockSize())) throw InvalidArgument("CipherModeBase: feedback size cannot be specified for this cipher mode"); } virtual void ResizeBuffers(); BlockCipher *m_cipher; AlignedSecByteBlock m_register; }; //! \class ModePolicyCommonTemplate //! \brief Block cipher mode of operation common operations //! \tparam POLICY_INTERFACE common operations template <class POLICY_INTERFACE> class CRYPTOPP_NO_VTABLE ModePolicyCommonTemplate : public CipherModeBase, public POLICY_INTERFACE { unsigned int GetAlignment() const {return m_cipher->OptimalDataAlignment();} void CipherSetKey(const NameValuePairs &params, const byte *key, size_t length); }; template <class POLICY_INTERFACE> void ModePolicyCommonTemplate<POLICY_INTERFACE>::CipherSetKey(const NameValuePairs &params, const byte *key, size_t length) { m_cipher->SetKey(key, length, params); ResizeBuffers(); int feedbackSize = params.GetIntValueWithDefault(Name::FeedbackSize(), 0); SetFeedbackSize(feedbackSize); } //! \class CFB_ModePolicy //! \brief CFB block cipher mode of operation class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE CFB_ModePolicy : public ModePolicyCommonTemplate<CFB_CipherAbstractPolicy> { public: CRYPTOPP_STATIC_CONSTEXPR const char* CRYPTOPP_API StaticAlgorithmName() {return "CFB";} virtual ~CFB_ModePolicy() {} IV_Requirement IVRequirement() const {return RANDOM_IV;} protected: unsigned int GetBytesPerIteration() const {return m_feedbackSize;} byte * GetRegisterBegin() {return m_register + BlockSize() - m_feedbackSize;} bool CanIterate() const {return m_feedbackSize == BlockSize();} void Iterate(byte *output, const byte *input, CipherDir dir, size_t iterationCount); void TransformRegister(); void CipherResynchronize(const byte *iv, size_t length); void SetFeedbackSize(unsigned int feedbackSize); void ResizeBuffers(); SecByteBlock m_temp; unsigned int m_feedbackSize; }; inline void CopyOrZero(void *dest, size_t d, const void *src, size_t s) { CRYPTOPP_ASSERT(dest); CRYPTOPP_ASSERT(d >= s); if (src) memcpy_s(dest, d, src, s); else memset(dest, 0, d); } //! \class OFB_ModePolicy //! \brief OFB block cipher mode of operation class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE OFB_ModePolicy : public ModePolicyCommonTemplate<AdditiveCipherAbstractPolicy> { public: CRYPTOPP_STATIC_CONSTEXPR const char* CRYPTOPP_API StaticAlgorithmName() {return "OFB";} bool CipherIsRandomAccess() const {return false;} IV_Requirement IVRequirement() const {return UNIQUE_IV;} private: unsigned int GetBytesPerIteration() const {return BlockSize();} unsigned int GetIterationsToBuffer() const {return m_cipher->OptimalNumberOfParallelBlocks();} void WriteKeystream(byte *keystreamBuffer, size_t iterationCount); void CipherResynchronize(byte *keystreamBuffer, const byte *iv, size_t length); }; //! \class CTR_ModePolicy //! \brief CTR block cipher mode of operation class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE CTR_ModePolicy : public ModePolicyCommonTemplate<AdditiveCipherAbstractPolicy> { public: CRYPTOPP_STATIC_CONSTEXPR const char* CRYPTOPP_API StaticAlgorithmName() {return "CTR";} virtual ~CTR_ModePolicy() {} bool CipherIsRandomAccess() const {return true;} IV_Requirement IVRequirement() const {return RANDOM_IV;} protected: virtual void IncrementCounterBy256(); unsigned int GetAlignment() const {return m_cipher->OptimalDataAlignment();} unsigned int GetBytesPerIteration() const {return BlockSize();} unsigned int GetIterationsToBuffer() const {return m_cipher->OptimalNumberOfParallelBlocks();} void WriteKeystream(byte *buffer, size_t iterationCount) {OperateKeystream(WRITE_KEYSTREAM, buffer, NULLPTR, iterationCount);} bool CanOperateKeystream() const {return true;} void OperateKeystream(KeystreamOperation operation, byte *output, const byte *input, size_t iterationCount); void CipherResynchronize(byte *keystreamBuffer, const byte *iv, size_t length); void SeekToIteration(lword iterationCount); AlignedSecByteBlock m_counterArray; }; //! \class BlockOrientedCipherModeBase //! \brief Block cipher mode of operation default implementation class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE BlockOrientedCipherModeBase : public CipherModeBase { public: virtual ~BlockOrientedCipherModeBase() {} void UncheckedSetKey(const byte *key, unsigned int length, const NameValuePairs &params); unsigned int MandatoryBlockSize() const {return BlockSize();} bool IsRandomAccess() const {return false;} bool IsSelfInverting() const {return false;} bool IsForwardTransformation() const {return m_cipher->IsForwardTransformation();} void Resynchronize(const byte *iv, int length=-1) {memcpy_s(m_register, m_register.size(), iv, ThrowIfInvalidIVLength(length));} protected: bool RequireAlignedInput() const {return true;} virtual void ResizeBuffers(); SecByteBlock m_buffer; }; //! \class ECB_OneWay //! \brief ECB block cipher mode of operation default implementation class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE ECB_OneWay : public BlockOrientedCipherModeBase { public: CRYPTOPP_STATIC_CONSTEXPR const char* CRYPTOPP_API StaticAlgorithmName() {return "ECB";} void SetKey(const byte *key, size_t length, const NameValuePairs &params = g_nullNameValuePairs) {m_cipher->SetKey(key, length, params); BlockOrientedCipherModeBase::ResizeBuffers();} IV_Requirement IVRequirement() const {return NOT_RESYNCHRONIZABLE;} unsigned int OptimalBlockSize() const {return BlockSize() * m_cipher->OptimalNumberOfParallelBlocks();} void ProcessData(byte *outString, const byte *inString, size_t length); }; //! \class CBC_ModeBase //! \brief CBC block cipher mode of operation default implementation class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE CBC_ModeBase : public BlockOrientedCipherModeBase { public: CRYPTOPP_STATIC_CONSTEXPR const char* CRYPTOPP_API StaticAlgorithmName() {return "CBC";} IV_Requirement IVRequirement() const {return UNPREDICTABLE_RANDOM_IV;} bool RequireAlignedInput() const {return false;} unsigned int MinLastBlockSize() const {return 0;} }; //! \class CBC_Encryption //! \brief CBC block cipher mode of operation encryption operation class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE CBC_Encryption : public CBC_ModeBase { public: void ProcessData(byte *outString, const byte *inString, size_t length); }; //! \class CBC_CTS_Encryption //! \brief CBC-CTS block cipher mode of operation encryption operation class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE CBC_CTS_Encryption : public CBC_Encryption { public: CRYPTOPP_STATIC_CONSTEXPR const char* CRYPTOPP_API StaticAlgorithmName() {return "CBC/CTS";} void SetStolenIV(byte *iv) {m_stolenIV = iv;} unsigned int MinLastBlockSize() const {return BlockSize()+1;} size_t ProcessLastBlock(byte *outString, size_t outLength, const byte *inString, size_t inLength); protected: void UncheckedSetKey(const byte *key, unsigned int length, const NameValuePairs &params) { CBC_Encryption::UncheckedSetKey(key, length, params); m_stolenIV = params.GetValueWithDefault(Name::StolenIV(), (byte *)NULLPTR); } byte *m_stolenIV; }; //! \class CBC_Decryption //! \brief CBC block cipher mode of operation decryption operation class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE CBC_Decryption : public CBC_ModeBase { public: virtual ~CBC_Decryption() {} void ProcessData(byte *outString, const byte *inString, size_t length); protected: virtual void ResizeBuffers(); AlignedSecByteBlock m_temp; }; //! \class CBC_CTS_Decryption //! \brief CBC-CTS block cipher mode of operation decryption operation class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE CBC_CTS_Decryption : public CBC_Decryption { public: unsigned int MinLastBlockSize() const {return BlockSize()+1;} size_t ProcessLastBlock(byte *outString, size_t outLength, const byte *inString, size_t inLength); }; //! \class CipherModeFinalTemplate_CipherHolder //! \brief Block cipher mode of operation aggregate template <class CIPHER, class BASE> class CipherModeFinalTemplate_CipherHolder : protected ObjectHolder<CIPHER>, public AlgorithmImpl<BASE, CipherModeFinalTemplate_CipherHolder<CIPHER, BASE> > { public: static std::string CRYPTOPP_API StaticAlgorithmName() {return CIPHER::StaticAlgorithmName() + "/" + BASE::StaticAlgorithmName();} CipherModeFinalTemplate_CipherHolder() { this->m_cipher = &this->m_object; this->ResizeBuffers(); } CipherModeFinalTemplate_CipherHolder(const byte *key, size_t length) { this->m_cipher = &this->m_object; this->SetKey(key, length); } CipherModeFinalTemplate_CipherHolder(const byte *key, size_t length, const byte *iv) { this->m_cipher = &this->m_object; this->SetKey(key, length, MakeParameters(Name::IV(), ConstByteArrayParameter(iv, this->m_cipher->BlockSize()))); } CipherModeFinalTemplate_CipherHolder(const byte *key, size_t length, const byte *iv, int feedbackSize) { this->m_cipher = &this->m_object; this->SetKey(key, length, MakeParameters(Name::IV(), ConstByteArrayParameter(iv, this->m_cipher->BlockSize()))(Name::FeedbackSize(), feedbackSize)); } }; //! \class CipherModeFinalTemplate_ExternalCipher //! \tparam BASE CipherModeFinalTemplate_CipherHolder base class //! \details Base class for external mode cipher combinations template <class BASE> class CipherModeFinalTemplate_ExternalCipher : public BASE { public: CipherModeFinalTemplate_ExternalCipher() {} CipherModeFinalTemplate_ExternalCipher(BlockCipher &cipher) {this->SetCipher(cipher);} CipherModeFinalTemplate_ExternalCipher(BlockCipher &cipher, const byte *iv, int feedbackSize = 0) {this->SetCipherWithIV(cipher, iv, feedbackSize);} std::string AlgorithmName() const {return (this->m_cipher ? this->m_cipher->AlgorithmName() + "/" : std::string("")) + BASE::StaticAlgorithmName();} }; CRYPTOPP_DLL_TEMPLATE_CLASS CFB_CipherTemplate<AbstractPolicyHolder<CFB_CipherAbstractPolicy, CFB_ModePolicy> >; CRYPTOPP_DLL_TEMPLATE_CLASS CFB_EncryptionTemplate<AbstractPolicyHolder<CFB_CipherAbstractPolicy, CFB_ModePolicy> >; CRYPTOPP_DLL_TEMPLATE_CLASS CFB_DecryptionTemplate<AbstractPolicyHolder<CFB_CipherAbstractPolicy, CFB_ModePolicy> >; //! \class CFB_Mode //! \brief CFB block cipher mode of operation //! \sa <A HREF="http://www.cryptopp.com/wiki/Modes_of_Operation">Modes of Operation</A> //! on the Crypto++ wiki. template <class CIPHER> struct CFB_Mode : public CipherModeDocumentation { typedef CipherModeFinalTemplate_CipherHolder<typename CIPHER::Encryption, ConcretePolicyHolder<Empty, CFB_EncryptionTemplate<AbstractPolicyHolder<CFB_CipherAbstractPolicy, CFB_ModePolicy> > > > Encryption; typedef CipherModeFinalTemplate_CipherHolder<typename CIPHER::Encryption, ConcretePolicyHolder<Empty, CFB_DecryptionTemplate<AbstractPolicyHolder<CFB_CipherAbstractPolicy, CFB_ModePolicy> > > > Decryption; }; //! \class CFB_Mode_ExternalCipher //! \brief CFB mode, external cipher. //! \sa <A HREF="http://www.cryptopp.com/wiki/Modes_of_Operation">Modes of Operation</A> //! on the Crypto++ wiki. struct CFB_Mode_ExternalCipher : public CipherModeDocumentation { typedef CipherModeFinalTemplate_ExternalCipher<ConcretePolicyHolder<Empty, CFB_EncryptionTemplate<AbstractPolicyHolder<CFB_CipherAbstractPolicy, CFB_ModePolicy> > > > Encryption; typedef CipherModeFinalTemplate_ExternalCipher<ConcretePolicyHolder<Empty, CFB_DecryptionTemplate<AbstractPolicyHolder<CFB_CipherAbstractPolicy, CFB_ModePolicy> > > > Decryption; }; //! \class CFB_FIPS_Mode //! \brief CFB block cipher mode of operation providing FIPS validated cryptography. //! \details Requires full block plaintext according to FIPS 800-38A //! \sa <A HREF="http://www.cryptopp.com/wiki/Modes_of_Operation">Modes of Operation</A> //! on the Crypto++ wiki. template <class CIPHER> struct CFB_FIPS_Mode : public CipherModeDocumentation { typedef CipherModeFinalTemplate_CipherHolder<typename CIPHER::Encryption, ConcretePolicyHolder<Empty, CFB_RequireFullDataBlocks<CFB_EncryptionTemplate<AbstractPolicyHolder<CFB_CipherAbstractPolicy, CFB_ModePolicy> > > > > Encryption; typedef CipherModeFinalTemplate_CipherHolder<typename CIPHER::Encryption, ConcretePolicyHolder<Empty, CFB_RequireFullDataBlocks<CFB_DecryptionTemplate<AbstractPolicyHolder<CFB_CipherAbstractPolicy, CFB_ModePolicy> > > > > Decryption; }; //! \class CFB_FIPS_Mode_ExternalCipher //! \brief CFB mode, external cipher, providing FIPS validated cryptography. //! \details Requires full block plaintext according to FIPS 800-38A //! \sa <A HREF="http://www.cryptopp.com/wiki/Modes_of_Operation">Modes of Operation</A> //! on the Crypto++ wiki. struct CFB_FIPS_Mode_ExternalCipher : public CipherModeDocumentation { typedef CipherModeFinalTemplate_ExternalCipher<ConcretePolicyHolder<Empty, CFB_RequireFullDataBlocks<CFB_EncryptionTemplate<AbstractPolicyHolder<CFB_CipherAbstractPolicy, CFB_ModePolicy> > > > > Encryption; typedef CipherModeFinalTemplate_ExternalCipher<ConcretePolicyHolder<Empty, CFB_RequireFullDataBlocks<CFB_DecryptionTemplate<AbstractPolicyHolder<CFB_CipherAbstractPolicy, CFB_ModePolicy> > > > > Decryption; }; CRYPTOPP_DLL_TEMPLATE_CLASS AdditiveCipherTemplate<AbstractPolicyHolder<AdditiveCipherAbstractPolicy, OFB_ModePolicy> >; //! \class OFB_Mode //! \brief OFB block cipher mode of operation //! \sa <A HREF="http://www.cryptopp.com/wiki/Modes_of_Operation">Modes of Operation</A> //! on the Crypto++ wiki. template <class CIPHER> struct OFB_Mode : public CipherModeDocumentation { typedef CipherModeFinalTemplate_CipherHolder<typename CIPHER::Encryption, ConcretePolicyHolder<Empty, AdditiveCipherTemplate<AbstractPolicyHolder<AdditiveCipherAbstractPolicy, OFB_ModePolicy> > > > Encryption; typedef Encryption Decryption; }; //! \class OFB_Mode_ExternalCipher //! \brief OFB mode, external cipher. //! \sa <A HREF="http://www.cryptopp.com/wiki/Modes_of_Operation">Modes of Operation</A> //! on the Crypto++ wiki. struct OFB_Mode_ExternalCipher : public CipherModeDocumentation { typedef CipherModeFinalTemplate_ExternalCipher<ConcretePolicyHolder<Empty, AdditiveCipherTemplate<AbstractPolicyHolder<AdditiveCipherAbstractPolicy, OFB_ModePolicy> > > > Encryption; typedef Encryption Decryption; }; CRYPTOPP_DLL_TEMPLATE_CLASS AdditiveCipherTemplate<AbstractPolicyHolder<AdditiveCipherAbstractPolicy, CTR_ModePolicy> >; CRYPTOPP_DLL_TEMPLATE_CLASS CipherModeFinalTemplate_ExternalCipher<ConcretePolicyHolder<Empty, AdditiveCipherTemplate<AbstractPolicyHolder<AdditiveCipherAbstractPolicy, CTR_ModePolicy> > > >; //! \class CTR_Mode //! \brief CTR block cipher mode of operation //! \sa <A HREF="http://www.cryptopp.com/wiki/Modes_of_Operation">Modes of Operation</A> //! on the Crypto++ wiki. template <class CIPHER> struct CTR_Mode : public CipherModeDocumentation { typedef CipherModeFinalTemplate_CipherHolder<typename CIPHER::Encryption, ConcretePolicyHolder<Empty, AdditiveCipherTemplate<AbstractPolicyHolder<AdditiveCipherAbstractPolicy, CTR_ModePolicy> > > > Encryption; typedef Encryption Decryption; }; //! \class CTR_Mode_ExternalCipher //! \brief CTR mode, external cipher. //! \sa <A HREF="http://www.cryptopp.com/wiki/Modes_of_Operation">Modes of Operation</A> //! on the Crypto++ wiki. struct CTR_Mode_ExternalCipher : public CipherModeDocumentation { typedef CipherModeFinalTemplate_ExternalCipher<ConcretePolicyHolder<Empty, AdditiveCipherTemplate<AbstractPolicyHolder<AdditiveCipherAbstractPolicy, CTR_ModePolicy> > > > Encryption; typedef Encryption Decryption; }; //! \class ECB_Mode //! \brief ECB block cipher mode of operation //! \sa <A HREF="http://www.cryptopp.com/wiki/Modes_of_Operation">Modes of Operation</A> //! on the Crypto++ wiki. template <class CIPHER> struct ECB_Mode : public CipherModeDocumentation { typedef CipherModeFinalTemplate_CipherHolder<typename CIPHER::Encryption, ECB_OneWay> Encryption; typedef CipherModeFinalTemplate_CipherHolder<typename CIPHER::Decryption, ECB_OneWay> Decryption; }; CRYPTOPP_DLL_TEMPLATE_CLASS CipherModeFinalTemplate_ExternalCipher<ECB_OneWay>; //! \class ECB_Mode_ExternalCipher //! \brief ECB mode, external cipher. //! \sa <A HREF="http://www.cryptopp.com/wiki/Modes_of_Operation">Modes of Operation</A> //! on the Crypto++ wiki. struct ECB_Mode_ExternalCipher : public CipherModeDocumentation { typedef CipherModeFinalTemplate_ExternalCipher<ECB_OneWay> Encryption; typedef Encryption Decryption; }; //! \class CBC_Mode //! \brief CBC block cipher mode of operation //! \sa <A HREF="http://www.cryptopp.com/wiki/Modes_of_Operation">Modes of Operation</A> //! on the Crypto++ wiki. template <class CIPHER> struct CBC_Mode : public CipherModeDocumentation { typedef CipherModeFinalTemplate_CipherHolder<typename CIPHER::Encryption, CBC_Encryption> Encryption; typedef CipherModeFinalTemplate_CipherHolder<typename CIPHER::Decryption, CBC_Decryption> Decryption; }; CRYPTOPP_DLL_TEMPLATE_CLASS CipherModeFinalTemplate_ExternalCipher<CBC_Encryption>; CRYPTOPP_DLL_TEMPLATE_CLASS CipherModeFinalTemplate_ExternalCipher<CBC_Decryption>; //! \class CBC_Mode_ExternalCipher //! \brief CBC mode, external cipher //! \sa <A HREF="http://www.cryptopp.com/wiki/Modes_of_Operation">Modes of Operation</A> //! on the Crypto++ wiki. struct CBC_Mode_ExternalCipher : public CipherModeDocumentation { typedef CipherModeFinalTemplate_ExternalCipher<CBC_Encryption> Encryption; typedef CipherModeFinalTemplate_ExternalCipher<CBC_Decryption> Decryption; }; //! \class CBC_CTS_Mode //! \brief CBC-CTS block cipher mode of operation //! \sa <A HREF="http://www.cryptopp.com/wiki/Modes_of_Operation">Modes of Operation</A> //! on the Crypto++ wiki. template <class CIPHER> struct CBC_CTS_Mode : public CipherModeDocumentation { typedef CipherModeFinalTemplate_CipherHolder<typename CIPHER::Encryption, CBC_CTS_Encryption> Encryption; typedef CipherModeFinalTemplate_CipherHolder<typename CIPHER::Decryption, CBC_CTS_Decryption> Decryption; }; CRYPTOPP_DLL_TEMPLATE_CLASS CipherModeFinalTemplate_ExternalCipher<CBC_CTS_Encryption>; CRYPTOPP_DLL_TEMPLATE_CLASS CipherModeFinalTemplate_ExternalCipher<CBC_CTS_Decryption>; //! \class CBC_CTS_Mode_ExternalCipher //! \brief CBC mode with ciphertext stealing, external cipher //! \sa <A HREF="http://www.cryptopp.com/wiki/Modes_of_Operation">Modes of Operation</A> //! on the Crypto++ wiki. struct CBC_CTS_Mode_ExternalCipher : public CipherModeDocumentation { typedef CipherModeFinalTemplate_ExternalCipher<CBC_CTS_Encryption> Encryption; typedef CipherModeFinalTemplate_ExternalCipher<CBC_CTS_Decryption> Decryption; }; NAMESPACE_END // Issue 340 #if CRYPTOPP_MSC_VERSION # pragma warning(pop) #endif #if CRYPTOPP_GCC_DIAGNOSTIC_AVAILABLE # pragma GCC diagnostic pop #endif #endif
[ "mei_jun1999@126.com" ]
mei_jun1999@126.com
a62a8c79cd240b734108492d70157ee093d8bc2b
09a74d737490b78f51533e51e370a55e38692cbd
/NBMediaPlayer/src/decoder/NBMediaDecoder.h
bfcaddecee6df0907dac7265ef50d848b513b9cb
[ "MIT" ]
permissive
zuohouwei/NewBlashPlayer
90b57076c9c0b142e338910a6b8d69e376ecf4c8
af2104ff143ea885ff7a6808aa12b65c12203c1f
refs/heads/master
2020-04-07T02:01:16.622611
2018-11-05T14:59:49
2018-11-05T14:59:49
null
0
0
null
null
null
null
UTF-8
C++
false
false
716
h
// // Created by parallels on 9/10/18. // #ifndef NBMEDIADECODER_H #define NBMEDIADECODER_H #include "NBMediaSource.h" #include "foundation/NBMetaData.h" class NBMediaDecoder { public: /** the audio decoder only support software * the video decoder select hardware in auto mode */ enum { NB_DECODER_FLAG_AUTO_SELECT = 0x01, NB_DECODER_FLAG_FORCE_SOFTWARE = 0x02 }; public: static NBMediaSource* Create(NBMetaData* metaData, NBMediaSource* mediaTrack, void* window, uint32_t flags = NB_DECODER_FLAG_AUTO_SELECT); static void Destroy(NBMediaSource* mediaSource); private: NBMediaDecoder() { } ~NBMediaDecoder() { } }; #endif //NBMEDIADECODER_H
[ "bobmarshall890120@gmail.com" ]
bobmarshall890120@gmail.com
9ae17fb08ad291d1b43591e60be420e3a425cad1
bcf3265a67256c2b6483281232a15621cbfd8574
/Server/Src/LogicServer/Guild.h
61cb011b8006a2f53b4b618b59ce205c46b8c1e1
[]
no_license
bbeyondllove/mmo_game_frame
ef7a7d7f68b86f080f5006d85535ad1b17b2ebb5
28cd973669f8ff42d35e227c728378817dc7afac
refs/heads/main
2023-04-07T16:10:45.758435
2021-04-06T04:37:12
2021-04-06T04:37:12
354,854,562
4
2
null
null
null
null
UTF-8
C++
false
false
595
h
#ifndef __GUILD_HEADER_H__ #define __GUILD_HEADER_H__ #include "GuildData.h" class CGuild { public: CGuild(); ~CGuild(); public: BOOL Init(); BOOL LoadGuildMember(CppMySQLQuery& QueryResult); CHAR* GetGuildName(); UINT64 GetGuildID(); MemberDataObject* GetGuildMember(UINT64 uID); MemberDataObject* GetLeader(); MemberDataObject* AddGuildMember(UINT64 uRoleID); BOOL BroadMessageToAll(UINT32 dwMsgID, const google::protobuf::Message& pdata); public: UINT64 m_u64LeaderID; GuildDataObject* m_pGuildData; std::map<UINT64, MemberDataObject*> m_mapMemberData; }; #endif
[ "469841047@qq.com" ]
469841047@qq.com
d91740406ecea008d4fcb209e5ce55363fd5e195
08eacc2c591fc45310c8bf697abe9464fb87cd74
/atcoder/abc/abc179/d.cpp
0a515089398c0725cb28b53d4b45b9aedceb70d6
[]
no_license
urashima0429/keipro_practice
1074266ee5b0de7002f5c540650a9f8543b0a53c
364d28502e53c6679ea81bc40fb80e6a022bbf8d
refs/heads/master
2021-06-14T23:42:11.242546
2021-03-16T06:21:36
2021-03-16T06:21:36
169,205,471
0
0
null
null
null
null
UTF-8
C++
false
false
1,007
cpp
#include <iostream> using namespace std; typedef long long ll; const ll MOD = 998244353; const int MAX_N = 200010; int N, K; ll bit[MAX_N]; ll sum (int i){ ll s = 0; while(i > 0){ s = (s + bit[i]) % MOD; i -= i & -i; } return s; } void add (int i, ll x){ while(i <= N){ bit[i] = (bit[i] + x) % MOD; i += i & -i; } } int main(){ int L[12], R[12]; cin >> N >> K; for (int i = 0; i < K; ++i){ cin >> L[i] >> R[i]; } for (int i = 1; i < N; ++i){ ll s = 0; for (int j = 0; j < K; ++j){ s = ( s + sum( max(0, i-L[j]) )) % MOD; s = ( s - sum( max(0, i-R[j]-1))) % MOD; if (L[j] <= i && i <= R[j]) { s = (s + 1) % MOD; } } add(i, (s + MOD) % MOD); } ll ans = sum(N-1) - sum(N-2); ans = ans % MOD; ans = ans + MOD; ans = ans % MOD; cout << ans << endl; }
[ "urashima0429@gmail.com" ]
urashima0429@gmail.com
89b522292fc8f3f47675b790242f3a8a018e0c32
e5720f95696653b496e5f927eac7492bfb9f132c
/0501-1000/0551-Student-Attendance-Record-I/cpp_0551/main.cpp
3f48e1624b7b162d695220864db15c4ffb292915
[ "MIT" ]
permissive
ooooo-youwillsee/leetcode
818cca3dd1fd07caf186ab6d41fb8c44f6cc9bdc
2cabb7e3e2465e33e4c96f0ad363cf6ce6976288
refs/heads/master
2022-05-24T15:37:19.652999
2022-05-15T01:25:31
2022-05-15T01:25:31
218,205,693
12
0
null
null
null
null
UTF-8
C++
false
false
225
cpp
#include <iostream> #include "Solution1.h" void test(string s) { Solution solution; cout << solution.checkRecord(s) << endl; } int main() { test("PPALLP"); // 1 test("PPALLL"); // 0 test("AA"); // 0 return 0; }
[ "297872913@qq.com" ]
297872913@qq.com
947104dae24b756d26e65a205d5cd86810e78110
66c22ed409b2eee7e1b570749601ccd567a718a4
/Src/EntityManager.h
42d1d49dd3e686584f28ce09b63d72627ecc96ab
[]
no_license
XoDeR/Rio.EntitySystem
71e155f0970b88102887db1ba7c808325b2e2c55
6a89ad8db1956fea79c213979455a20d05bb8e4c
refs/heads/master
2021-01-22T05:24:18.493795
2015-06-18T15:50:30
2015-06-18T15:50:30
37,669,192
0
0
null
null
null
null
UTF-8
C++
false
false
377
h
#pragma once #include "Common.h" #include "Entity.h" class EntityManager { public: Entity createEntity(); void removeEntity(Entity e); bool isActive(Entity e); void registerRemoveComponentCallback(function<void(uint32_t)> removeCallback); private: vector<uint8_t> generation; deque<uint32_t> freeIndices; vector<function<void(uint32_t)>> removeComponentCallbackList; };
[ "xoder.vs@gmail.com" ]
xoder.vs@gmail.com
5cd5886998e446ffe7759056abb52355beeba99a
8dce1bf646ecd4512ee5725a42af0406b8f3ff87
/src/main.h
2300354b35e7283ac45cf729d7f30bb6dde31781
[ "MIT" ]
permissive
forkee/FootyCash
746c2e7fb98a1ba6053e66ae49aac16ef2922723
693712e9a196d51020fa2d5a78a0cbc4f823e39a
refs/heads/master
2021-06-21T12:51:16.191353
2017-08-14T08:45:09
2017-08-14T08:45:09
null
0
0
null
null
null
null
UTF-8
C++
false
false
38,630
h
// Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2012 The Bitcoin developers // Distributed under the MIT/X11 software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #ifndef BITCOIN_MAIN_H #define BITCOIN_MAIN_H #include "core.h" #include "bignum.h" #include "sync.h" #include "txmempool.h" #include "net.h" #include "script.h" #include "scrypt.h" #include <list> class CBlock; class CBlockIndex; class CInv; class CKeyItem; class CNode; class CReserveKey; class CWallet; /** The maximum allowed size for a serialized block, in bytes (network rule) */ static const unsigned int MAX_BLOCK_SIZE = 1000000; /** The maximum size for mined blocks */ static const unsigned int MAX_BLOCK_SIZE_GEN = MAX_BLOCK_SIZE/2; /** The maximum size for transactions we're willing to relay/mine **/ static const unsigned int MAX_STANDARD_TX_SIZE = MAX_BLOCK_SIZE_GEN/5; /** The maximum allowed number of signature check operations in a block (network rule) */ static const unsigned int MAX_BLOCK_SIGOPS = MAX_BLOCK_SIZE/50; /** Maxiumum number of signature check operations in an IsStandard() P2SH script */ static const unsigned int MAX_P2SH_SIGOPS = 15; /** The maximum number of sigops we're willing to relay/mine in a single tx */ static const unsigned int MAX_TX_SIGOPS = MAX_BLOCK_SIGOPS/5; /** The maximum number of orphan transactions kept in memory */ static const unsigned int MAX_ORPHAN_TRANSACTIONS = MAX_BLOCK_SIZE/100; /** Default for -maxorphanblocks, maximum number of orphan blocks kept in memory */ static const unsigned int DEFAULT_MAX_ORPHAN_BLOCKS = 750; /** The maximum number of entries in an 'inv' protocol message */ static const unsigned int MAX_INV_SZ = 50000; /** Fees smaller than this (in satoshi) are considered zero fee (for transaction creation) */ static const int64_t MIN_TX_FEE = 10000; /** Fees smaller than this (in satoshi) are considered zero fee (for relaying) */ static const int64_t MIN_RELAY_TX_FEE = MIN_TX_FEE; inline bool MoneyRange(int64_t nValue) { return (nValue >= 0 && nValue <= Params().MaxMoney()); } /** Threshold for nLockTime: below this value it is interpreted as block number, otherwise as UNIX timestamp. */ static const unsigned int LOCKTIME_THRESHOLD = 500000000; // Tue Nov 5 00:53:20 1985 UTC extern CScript COINBASE_FLAGS; extern CCriticalSection cs_main; extern CTxMemPool mempool; extern std::map<uint256, CBlockIndex*> mapBlockIndex; extern std::set<std::pair<COutPoint, unsigned int> > setStakeSeen; extern CBlockIndex* pindexGenesisBlock; extern unsigned int nNodeLifespan; extern int nBestHeight; extern uint256 nBestChainTrust; extern uint256 nBestInvalidTrust; extern uint256 hashBestChain; extern CBlockIndex* pindexBest; extern uint64_t nLastBlockTx; extern uint64_t nLastBlockSize; extern int64_t nLastCoinStakeSearchInterval; extern const std::string strMessageMagic; extern int64_t nTimeBestReceived; extern bool fImporting; extern bool fReindex; struct COrphanBlock; extern std::map<uint256, COrphanBlock*> mapOrphanBlocks; extern bool fHaveGUI; // Settings extern bool fUseFastIndex; extern unsigned int nDerivationMethodIndex; extern bool fMinimizeCoinAge; // Minimum disk space required - used in CheckDiskSpace() static const uint64_t nMinDiskSpace = 52428800; class CReserveKey; class CTxDB; class CTxIndex; class CWalletInterface; /** Register a wallet to receive updates from core */ void RegisterWallet(CWalletInterface* pwalletIn); /** Unregister a wallet from core */ void UnregisterWallet(CWalletInterface* pwalletIn); /** Unregister all wallets from core */ void UnregisterAllWallets(); /** Push an updated transaction to all registered wallets */ void SyncWithWallets(const CTransaction& tx, const CBlock* pblock = NULL, bool fConnect = true); /** Ask wallets to resend their transactions */ void ResendWalletTransactions(bool fForce = false); /** Register with a network node to receive its signals */ void RegisterNodeSignals(CNodeSignals& nodeSignals); /** Unregister a network node */ void UnregisterNodeSignals(CNodeSignals& nodeSignals); void PushGetBlocks(CNode* pnode, CBlockIndex* pindexBegin, uint256 hashEnd); bool ProcessBlock(CNode* pfrom, CBlock* pblock); bool CheckDiskSpace(uint64_t nAdditionalBytes=0); FILE* OpenBlockFile(unsigned int nFile, unsigned int nBlockPos, const char* pszMode="rb"); FILE* AppendBlockFile(unsigned int& nFileRet); bool LoadBlockIndex(bool fAllowNew=true); void PrintBlockTree(); CBlockIndex* FindBlockByHeight(int nHeight); bool ProcessMessages(CNode* pfrom); bool SendMessages(CNode* pto, bool fSendTrickle); void ThreadImport(std::vector<boost::filesystem::path> vImportFiles); bool CheckProofOfWork(uint256 hash, unsigned int nBits); unsigned int GetNextTargetRequired(const CBlockIndex* pindexLast, bool fProofOfStake); int64_t GetProofOfWorkReward(int64_t nFees, int64_t nHeight); int64_t GetProofOfStakeReward(const CBlockIndex* pindexPrev, Bignum nCoinAge, int64_t nFees, int64_t nHeight); bool IsInitialBlockDownload(); bool IsConfirmedInNPrevBlocks(const CTxIndex& txindex, const CBlockIndex* pindexFrom, int nMaxDepth, int& nActualDepth); std::string GetWarnings(std::string strFor); bool GetTransaction(const uint256 &hash, CTransaction &tx, uint256 &hashBlock); uint256 WantedByOrphan(const COrphanBlock* pblockOrphan); const CBlockIndex* GetLastBlockIndex(const CBlockIndex* pindex, bool fProofOfStake); void ThreadStakeMiner(CWallet *pwallet); /** (try to) add transaction to memory pool **/ bool AcceptToMemoryPool(CTxMemPool& pool, CTransaction &tx, bool fLimitFree, bool* pfMissingInputs); /** Position on disk for a particular transaction. */ class CDiskTxPos { public: unsigned int nFile; unsigned int nBlockPos; unsigned int nTxPos; CDiskTxPos() { SetNull(); } CDiskTxPos(unsigned int nFileIn, unsigned int nBlockPosIn, unsigned int nTxPosIn) { nFile = nFileIn; nBlockPos = nBlockPosIn; nTxPos = nTxPosIn; } IMPLEMENT_SERIALIZE( READWRITE(FLATDATA(*this)); ) void SetNull() { nFile = (unsigned int) -1; nBlockPos = 0; nTxPos = 0; } bool IsNull() const { return (nFile == (unsigned int) -1); } friend bool operator==(const CDiskTxPos& a, const CDiskTxPos& b) { return (a.nFile == b.nFile && a.nBlockPos == b.nBlockPos && a.nTxPos == b.nTxPos); } friend bool operator!=(const CDiskTxPos& a, const CDiskTxPos& b) { return !(a == b); } std::string ToString() const { if (IsNull()) return "null"; else return strprintf("(nFile=%u, nBlockPos=%u, nTxPos=%u)", nFile, nBlockPos, nTxPos); } }; enum GetMinFee_mode { GMF_BLOCK, GMF_RELAY, GMF_SEND, }; typedef std::map<uint256, std::pair<CTxIndex, CTransaction> > MapPrevTx; int64_t GetMinFee(const CTransaction& tx, unsigned int nBlockSize = 1, enum GetMinFee_mode mode = GMF_BLOCK, unsigned int nBytes = 0); /** The basic transaction that is broadcasted on the network and contained in * blocks. A transaction can contain multiple inputs and outputs. */ class CTransaction { public: static const int CURRENT_VERSION=1; int nVersion; unsigned int nTime; std::vector<CTxIn> vin; std::vector<CTxOut> vout; unsigned int nLockTime; // Denial-of-service detection: mutable int nDoS; bool DoS(int nDoSIn, bool fIn) const { nDoS += nDoSIn; return fIn; } CTransaction() { SetNull(); } CTransaction(int nVersion, unsigned int nTime, const std::vector<CTxIn>& vin, const std::vector<CTxOut>& vout, unsigned int nLockTime) : nVersion(nVersion), nTime(nTime), vin(vin), vout(vout), nLockTime(nLockTime), nDoS(0) { } IMPLEMENT_SERIALIZE ( READWRITE(this->nVersion); nVersion = this->nVersion; READWRITE(nTime); READWRITE(vin); READWRITE(vout); READWRITE(nLockTime); ) void SetNull() { nVersion = CTransaction::CURRENT_VERSION; nTime = GetAdjustedTime(); vin.clear(); vout.clear(); nLockTime = 0; nDoS = 0; // Denial-of-service prevention } bool IsNull() const { return (vin.empty() && vout.empty()); } uint256 GetHash() const { return SerializeHash(*this); } bool IsCoinBase() const { return (vin.size() == 1 && vin[0].prevout.IsNull() && vout.size() >= 1); } bool IsCoinStake() const { // ppcoin: the coin stake transaction is marked with the first output empty return (vin.size() > 0 && (!vin[0].prevout.IsNull()) && vout.size() >= 2 && vout[0].IsEmpty()); } /** Amount of bitcoins spent by this transaction. @return sum of all outputs (note: does not include fees) */ int64_t GetValueOut() const { int64_t nValueOut = 0; BOOST_FOREACH(const CTxOut& txout, vout) { nValueOut += txout.nValue; if (!MoneyRange(txout.nValue) || !MoneyRange(nValueOut)) throw std::runtime_error("CTransaction::GetValueOut() : value out of range"); } return nValueOut; } /** Amount of bitcoins coming in to this transaction Note that lightweight clients may not know anything besides the hash of previous transactions, so may not be able to calculate this. @param[in] mapInputs Map of previous transactions that have outputs we're spending @return Sum of value of all inputs (scriptSigs) @see CTransaction::FetchInputs */ int64_t GetValueIn(const MapPrevTx& mapInputs) const; bool ReadFromDisk(CDiskTxPos pos, FILE** pfileRet=NULL) { CAutoFile filein = CAutoFile(OpenBlockFile(pos.nFile, 0, pfileRet ? "rb+" : "rb"), SER_DISK, CLIENT_VERSION); if (!filein) return error("CTransaction::ReadFromDisk() : OpenBlockFile failed"); // Read transaction if (fseek(filein, pos.nTxPos, SEEK_SET) != 0) return error("CTransaction::ReadFromDisk() : fseek failed"); try { filein >> *this; } catch (std::exception &e) { return error("%s() : deserialize or I/O error", __PRETTY_FUNCTION__); } // Return file pointer if (pfileRet) { if (fseek(filein, pos.nTxPos, SEEK_SET) != 0) return error("CTransaction::ReadFromDisk() : second fseek failed"); *pfileRet = filein.release(); } return true; } friend bool operator==(const CTransaction& a, const CTransaction& b) { return (a.nVersion == b.nVersion && a.nTime == b.nTime && a.vin == b.vin && a.vout == b.vout && a.nLockTime == b.nLockTime); } friend bool operator!=(const CTransaction& a, const CTransaction& b) { return !(a == b); } std::string ToString() const { std::string str; str += IsCoinBase()? "Coinbase" : (IsCoinStake()? "Coinstake" : "CTransaction"); str += strprintf("(hash=%s, nTime=%d, ver=%d, vin.size=%u, vout.size=%u, nLockTime=%d)\n", GetHash().ToString(), nTime, nVersion, vin.size(), vout.size(), nLockTime); for (unsigned int i = 0; i < vin.size(); i++) str += " " + vin[i].ToString() + "\n"; for (unsigned int i = 0; i < vout.size(); i++) str += " " + vout[i].ToString() + "\n"; return str; } bool ReadFromDisk(CTxDB& txdb, COutPoint prevout, CTxIndex& txindexRet); bool ReadFromDisk(CTxDB& txdb, COutPoint prevout); bool ReadFromDisk(COutPoint prevout); bool DisconnectInputs(CTxDB& txdb); /** Fetch from memory and/or disk. inputsRet keys are transaction hashes. @param[in] txdb Transaction database @param[in] mapTestPool List of pending changes to the transaction index database @param[in] fBlock True if being called to add a new best-block to the chain @param[in] fMiner True if being called by CreateNewBlock @param[out] inputsRet Pointers to this transaction's inputs @param[out] fInvalid returns true if transaction is invalid @return Returns true if all inputs are in txdb or mapTestPool */ bool FetchInputs(CTxDB& txdb, const std::map<uint256, CTxIndex>& mapTestPool, bool fBlock, bool fMiner, MapPrevTx& inputsRet, bool& fInvalid); /** Sanity check previous transactions, then, if all checks succeed, mark them as spent by this transaction. @param[in] inputs Previous transactions (from FetchInputs) @param[out] mapTestPool Keeps track of inputs that need to be updated on disk @param[in] posThisTx Position of this transaction on disk @param[in] pindexBlock @param[in] fBlock true if called from ConnectBlock @param[in] fMiner true if called from CreateNewBlock @return Returns true if all checks succeed */ bool ConnectInputs(CTxDB& txdb, MapPrevTx inputs, std::map<uint256, CTxIndex>& mapTestPool, const CDiskTxPos& posThisTx, const CBlockIndex* pindexBlock, bool fBlock, bool fMiner, unsigned int flags = STANDARD_SCRIPT_VERIFY_FLAGS); bool CheckTransaction() const; bool GetCoinAge(CTxDB& txdb, const CBlockIndex* pindexPrev, uint64_t& nCoinAge) const; const CTxOut& GetOutputFor(const CTxIn& input, const MapPrevTx& inputs) const; }; /** wrapper for CTxOut that provides a more compact serialization */ class CTxOutCompressor { private: CTxOut &txout; public: CTxOutCompressor(CTxOut &txoutIn) : txout(txoutIn) { } IMPLEMENT_SERIALIZE( READWRITE(VARINT(txout.nValue)); CScriptCompressor cscript(REF(txout.scriptPubKey)); READWRITE(cscript); ) }; /** Check for standard transaction types @param[in] mapInputs Map of previous transactions that have outputs we're spending @return True if all inputs (scriptSigs) use only standard transaction forms @see CTransaction::FetchInputs */ bool AreInputsStandard(const CTransaction& tx, const MapPrevTx& mapInputs); /** Count ECDSA signature operations the old-fashioned (pre-0.6) way @return number of sigops this transaction's outputs will produce when spent @see CTransaction::FetchInputs */ unsigned int GetLegacySigOpCount(const CTransaction& tx); /** Count ECDSA signature operations in pay-to-script-hash inputs. @param[in] mapInputs Map of previous transactions that have outputs we're spending @return maximum number of sigops required to validate this transaction's inputs @see CTransaction::FetchInputs */ unsigned int GetP2SHSigOpCount(const CTransaction& tx, const MapPrevTx& mapInputs); /** Check for standard transaction types @return True if all outputs (scriptPubKeys) use only standard transaction forms */ bool IsStandardTx(const CTransaction& tx, std::string& reason); bool IsFinalTx(const CTransaction &tx, int nBlockHeight = 0, int64_t nBlockTime = 0); /** A transaction with a merkle branch linking it to the block chain. */ class CMerkleTx : public CTransaction { private: int GetDepthInMainChainINTERNAL(CBlockIndex* &pindexRet) const; public: uint256 hashBlock; std::vector<uint256> vMerkleBranch; int nIndex; // memory only mutable bool fMerkleVerified; CMerkleTx() { Init(); } CMerkleTx(const CTransaction& txIn) : CTransaction(txIn) { Init(); } void Init() { hashBlock = 0; nIndex = -1; fMerkleVerified = false; } IMPLEMENT_SERIALIZE ( nSerSize += SerReadWrite(s, *(CTransaction*)this, nType, nVersion, ser_action); nVersion = this->nVersion; READWRITE(hashBlock); READWRITE(vMerkleBranch); READWRITE(nIndex); ) int SetMerkleBranch(const CBlock* pblock=NULL); // Return depth of transaction in blockchain: // -1 : not in blockchain, and not in memory pool (conflicted transaction) // 0 : in memory pool, waiting to be included in a block // >=1 : this many blocks deep in the main chain int GetDepthInMainChain(CBlockIndex* &pindexRet) const; int GetDepthInMainChain() const { CBlockIndex *pindexRet; return GetDepthInMainChain(pindexRet); } bool IsInMainChain() const { CBlockIndex *pindexRet; return GetDepthInMainChainINTERNAL(pindexRet) > 0; } int GetBlocksToMaturity() const; bool AcceptToMemoryPool(bool fLimitFree=true); }; /** A txdb record that contains the disk location of a transaction and the * locations of transactions that spend its outputs. vSpent is really only * used as a flag, but having the location is very helpful for debugging. */ class CTxIndex { public: CDiskTxPos pos; std::vector<CDiskTxPos> vSpent; CTxIndex() { SetNull(); } CTxIndex(const CDiskTxPos& posIn, unsigned int nOutputs) { pos = posIn; vSpent.resize(nOutputs); } IMPLEMENT_SERIALIZE ( if (!(nType & SER_GETHASH)) READWRITE(nVersion); READWRITE(pos); READWRITE(vSpent); ) void SetNull() { pos.SetNull(); vSpent.clear(); } bool IsNull() { return pos.IsNull(); } friend bool operator==(const CTxIndex& a, const CTxIndex& b) { return (a.pos == b.pos && a.vSpent == b.vSpent); } friend bool operator!=(const CTxIndex& a, const CTxIndex& b) { return !(a == b); } int GetDepthInMainChain() const; }; /** Nodes collect new transactions into a block, hash them into a hash tree, * and scan through nonce values to make the block's hash satisfy proof-of-work * requirements. When they solve the proof-of-work, they broadcast the block * to everyone and the block is added to the block chain. The first transaction * in the block is a special one that creates a new coin owned by the creator * of the block. * * Blocks are appended to blk0001.dat files on disk. Their location on disk * is indexed by CBlockIndex objects in memory. */ class CBlock { public: // header static const int CURRENT_VERSION = 7; int nVersion; uint256 hashPrevBlock; uint256 hashMerkleRoot; unsigned int nTime; unsigned int nBits; unsigned int nNonce; // network and disk std::vector<CTransaction> vtx; // ppcoin: block signature - signed by one of the coin base txout[N]'s owner std::vector<unsigned char> vchBlockSig; // memory only mutable std::vector<uint256> vMerkleTree; // Denial-of-service detection: mutable int nDoS; bool DoS(int nDoSIn, bool fIn) const { nDoS += nDoSIn; return fIn; } CBlock() { SetNull(); } IMPLEMENT_SERIALIZE ( READWRITE(this->nVersion); nVersion = this->nVersion; READWRITE(hashPrevBlock); READWRITE(hashMerkleRoot); READWRITE(nTime); READWRITE(nBits); READWRITE(nNonce); // ConnectBlock depends on vtx following header to generate CDiskTxPos if (!(nType & (SER_GETHASH|SER_BLOCKHEADERONLY))) { READWRITE(vtx); READWRITE(vchBlockSig); } else if (fRead) { const_cast<CBlock*>(this)->vtx.clear(); const_cast<CBlock*>(this)->vchBlockSig.clear(); } ) void SetNull() { nVersion = CBlock::CURRENT_VERSION; hashPrevBlock = 0; hashMerkleRoot = 0; nTime = 0; nBits = 0; nNonce = 0; vtx.clear(); vchBlockSig.clear(); vMerkleTree.clear(); nDoS = 0; } bool IsNull() const { return (nBits == 0); } uint256 GetHash() const { if (nVersion > 6) return Hash(BEGIN(nVersion), END(nNonce)); else return GetPoWHash(); } uint256 GetPoWHash() const { return scrypt_blockhash(CVOIDBEGIN(nVersion)); } int64_t GetBlockTime() const { return (int64_t)nTime; } void UpdateTime(const CBlockIndex* pindexPrev); // entropy bit for stake modifier if chosen by modifier unsigned int GetStakeEntropyBit() const { // Take last bit of block hash as entropy bit unsigned int nEntropyBit = ((GetHash().GetLow64()) & 1llu); LogPrint("stakemodifier", "GetStakeEntropyBit: hashBlock=%s nEntropyBit=%u\n", GetHash().ToString(), nEntropyBit); return nEntropyBit; } // ppcoin: two types of block: proof-of-work or proof-of-stake bool IsProofOfStake() const { return (vtx.size() > 1 && vtx[1].IsCoinStake()); } bool IsProofOfWork() const { return !IsProofOfStake(); } std::pair<COutPoint, unsigned int> GetProofOfStake() const { return IsProofOfStake()? std::make_pair(vtx[1].vin[0].prevout, vtx[1].nTime) : std::make_pair(COutPoint(), (unsigned int)0); } // ppcoin: get max transaction timestamp int64_t GetMaxTransactionTime() const { int64_t maxTransactionTime = 0; BOOST_FOREACH(const CTransaction& tx, vtx) maxTransactionTime = std::max(maxTransactionTime, (int64_t)tx.nTime); return maxTransactionTime; } uint256 BuildMerkleTree() const { vMerkleTree.clear(); BOOST_FOREACH(const CTransaction& tx, vtx) vMerkleTree.push_back(tx.GetHash()); int j = 0; for (int nSize = vtx.size(); nSize > 1; nSize = (nSize + 1) / 2) { for (int i = 0; i < nSize; i += 2) { int i2 = std::min(i+1, nSize-1); vMerkleTree.push_back(Hash(BEGIN(vMerkleTree[j+i]), END(vMerkleTree[j+i]), BEGIN(vMerkleTree[j+i2]), END(vMerkleTree[j+i2]))); } j += nSize; } return (vMerkleTree.empty() ? 0 : vMerkleTree.back()); } std::vector<uint256> GetMerkleBranch(int nIndex) const { if (vMerkleTree.empty()) BuildMerkleTree(); std::vector<uint256> vMerkleBranch; int j = 0; for (int nSize = vtx.size(); nSize > 1; nSize = (nSize + 1) / 2) { int i = std::min(nIndex^1, nSize-1); vMerkleBranch.push_back(vMerkleTree[j+i]); nIndex >>= 1; j += nSize; } return vMerkleBranch; } static uint256 CheckMerkleBranch(uint256 hash, const std::vector<uint256>& vMerkleBranch, int nIndex) { if (nIndex == -1) return 0; BOOST_FOREACH(const uint256& otherside, vMerkleBranch) { if (nIndex & 1) hash = Hash(BEGIN(otherside), END(otherside), BEGIN(hash), END(hash)); else hash = Hash(BEGIN(hash), END(hash), BEGIN(otherside), END(otherside)); nIndex >>= 1; } return hash; } bool WriteToDisk(unsigned int& nFileRet, unsigned int& nBlockPosRet) { // Open history file to append CAutoFile fileout = CAutoFile(AppendBlockFile(nFileRet), SER_DISK, CLIENT_VERSION); if (!fileout) return error("CBlock::WriteToDisk() : AppendBlockFile failed"); // Write index header unsigned int nSize = fileout.GetSerializeSize(*this); fileout << FLATDATA(Params().MessageStart()) << nSize; // Write block long fileOutPos = ftell(fileout); if (fileOutPos < 0) return error("CBlock::WriteToDisk() : ftell failed"); nBlockPosRet = fileOutPos; fileout << *this; // Flush stdio buffers and commit to disk before returning fflush(fileout); if (!IsInitialBlockDownload() || (nBestHeight+1) % 500 == 0) FileCommit(fileout); return true; } bool ReadFromDisk(unsigned int nFile, unsigned int nBlockPos, bool fReadTransactions=true) { SetNull(); // Open history file to read CAutoFile filein = CAutoFile(OpenBlockFile(nFile, nBlockPos, "rb"), SER_DISK, CLIENT_VERSION); if (!filein) return error("CBlock::ReadFromDisk() : OpenBlockFile failed"); if (!fReadTransactions) filein.nType |= SER_BLOCKHEADERONLY; // Read block try { filein >> *this; } catch (std::exception &e) { return error("%s() : deserialize or I/O error", __PRETTY_FUNCTION__); } // Check the header if (fReadTransactions && IsProofOfWork() && !CheckProofOfWork(GetPoWHash(), nBits)) return error("CBlock::ReadFromDisk() : errors in block header"); return true; } std::string ToString() const { std::stringstream s; s << strprintf("CBlock(hash=%s, ver=%d, hashPrevBlock=%s, hashMerkleRoot=%s, nTime=%u, nBits=%08x, nNonce=%u, vtx=%u, vchBlockSig=%s)\n", GetHash().ToString(), nVersion, hashPrevBlock.ToString(), hashMerkleRoot.ToString(), nTime, nBits, nNonce, vtx.size(), HexStr(vchBlockSig.begin(), vchBlockSig.end())); for (unsigned int i = 0; i < vtx.size(); i++) { s << " " << vtx[i].ToString() << "\n"; } s << " vMerkleTree: "; for (unsigned int i = 0; i < vMerkleTree.size(); i++) s << " " << vMerkleTree[i].ToString(); s << "\n"; return s.str(); } bool DisconnectBlock(CTxDB& txdb, CBlockIndex* pindex); bool ConnectBlock(CTxDB& txdb, CBlockIndex* pindex, bool fJustCheck=false); bool ReadFromDisk(const CBlockIndex* pindex, bool fReadTransactions=true); bool SetBestChain(CTxDB& txdb, CBlockIndex* pindexNew); bool AddToBlockIndex(unsigned int nFile, unsigned int nBlockPos, const uint256& hashProof); bool CheckBlock(bool fCheckPOW=true, bool fCheckMerkleRoot=true, bool fCheckSig=true) const; bool AcceptBlock(); bool SignBlock(CWallet& keystore, int64_t nFees); bool CheckBlockSignature() const; private: bool SetBestChainInner(CTxDB& txdb, CBlockIndex *pindexNew); }; /** The block chain is a tree shaped structure starting with the * genesis block at the root, with each block potentially having multiple * candidates to be the next block. pprev and pnext link a path through the * main/longest chain. A blockindex may have multiple pprev pointing back * to it, but pnext will only point forward to the longest branch, or will * be null if the block is not part of the longest chain. */ class CBlockIndex { public: const uint256* phashBlock; CBlockIndex* pprev; CBlockIndex* pnext; unsigned int nFile; unsigned int nBlockPos; uint256 nChainTrust; // ppcoin: trust score of block chain int nHeight; int64_t nMint; int64_t nMoneySupply; unsigned int nFlags; // ppcoin: block index flags enum { BLOCK_PROOF_OF_STAKE = (1 << 0), // is proof-of-stake block BLOCK_STAKE_ENTROPY = (1 << 1), // entropy bit for stake modifier BLOCK_STAKE_MODIFIER = (1 << 2), // regenerated stake modifier }; uint64_t nStakeModifier; // hash modifier for proof-of-stake uint256 bnStakeModifier; // proof-of-stake specific fields COutPoint prevoutStake; unsigned int nStakeTime; uint256 hashProof; // block header int nVersion; uint256 hashMerkleRoot; unsigned int nTime; unsigned int nBits; unsigned int nNonce; CBlockIndex() { phashBlock = NULL; pprev = NULL; pnext = NULL; nFile = 0; nBlockPos = 0; nHeight = 0; nChainTrust = 0; nMint = 0; nMoneySupply = 0; nFlags = 0; nStakeModifier = 0; bnStakeModifier = 0; hashProof = 0; prevoutStake.SetNull(); nStakeTime = 0; nVersion = 0; hashMerkleRoot = 0; nTime = 0; nBits = 0; nNonce = 0; } CBlockIndex(unsigned int nFileIn, unsigned int nBlockPosIn, CBlock& block) { phashBlock = NULL; pprev = NULL; pnext = NULL; nFile = nFileIn; nBlockPos = nBlockPosIn; nHeight = 0; nChainTrust = 0; nMint = 0; nMoneySupply = 0; nFlags = 0; nStakeModifier = 0; bnStakeModifier = 0; hashProof = 0; if (block.IsProofOfStake()) { SetProofOfStake(); prevoutStake = block.vtx[1].vin[0].prevout; nStakeTime = block.vtx[1].nTime; } else { prevoutStake.SetNull(); nStakeTime = 0; } nVersion = block.nVersion; hashMerkleRoot = block.hashMerkleRoot; nTime = block.nTime; nBits = block.nBits; nNonce = block.nNonce; } CBlock GetBlockHeader() const { CBlock block; block.nVersion = nVersion; if (pprev) block.hashPrevBlock = pprev->GetBlockHash(); block.hashMerkleRoot = hashMerkleRoot; block.nTime = nTime; block.nBits = nBits; block.nNonce = nNonce; return block; } uint256 GetBlockHash() const { return *phashBlock; } int64_t GetBlockTime() const { return (int64_t)nTime; } uint256 GetBlockTrust() const; bool IsInMainChain() const { return (pnext || this == pindexBest); } bool CheckIndex() const { return true; } int64_t GetPastTimeLimit() const { return GetBlockTime(); } enum { nMedianTimeSpan=11 }; int64_t GetMedianTimePast() const { int64_t pmedian[nMedianTimeSpan]; int64_t* pbegin = &pmedian[nMedianTimeSpan]; int64_t* pend = &pmedian[nMedianTimeSpan]; const CBlockIndex* pindex = this; for (int i = 0; i < nMedianTimeSpan && pindex; i++, pindex = pindex->pprev) *(--pbegin) = pindex->GetBlockTime(); std::sort(pbegin, pend); return pbegin[(pend - pbegin)/2]; } /** * Returns true if there are nRequired or more blocks of minVersion or above * in the last nToCheck blocks, starting at pstart and going backwards. */ static bool IsSuperMajority(int minVersion, const CBlockIndex* pstart, unsigned int nRequired, unsigned int nToCheck); bool IsProofOfWork() const { return !(nFlags & BLOCK_PROOF_OF_STAKE); } bool IsProofOfStake() const { return (nFlags & BLOCK_PROOF_OF_STAKE); } void SetProofOfStake() { nFlags |= BLOCK_PROOF_OF_STAKE; } unsigned int GetStakeEntropyBit() const { return ((nFlags & BLOCK_STAKE_ENTROPY) >> 1); } bool SetStakeEntropyBit(unsigned int nEntropyBit) { if (nEntropyBit > 1) return false; nFlags |= (nEntropyBit? BLOCK_STAKE_ENTROPY : 0); return true; } bool GeneratedStakeModifier() const { return (nFlags & BLOCK_STAKE_MODIFIER); } void SetStakeModifier(uint64_t nModifier, bool fGeneratedStakeModifier) { nStakeModifier = nModifier; if (fGeneratedStakeModifier) nFlags |= BLOCK_STAKE_MODIFIER; } std::string ToString() const { return strprintf("CBlockIndex(nprev=%p, pnext=%p, nFile=%u, nBlockPos=%-6d nHeight=%d, nMint=%s, nMoneySupply=%s, nFlags=(%s)(%d)(%s), nStakeModifier=%016x, hashProof=%s, prevoutStake=(%s), nStakeTime=%d merkle=%s, hashBlock=%s)", pprev, pnext, nFile, nBlockPos, nHeight, FormatMoney(nMint), FormatMoney(nMoneySupply), GeneratedStakeModifier() ? "MOD" : "-", GetStakeEntropyBit(), IsProofOfStake()? "PoS" : "PoW", nStakeModifier, hashProof.ToString(), prevoutStake.ToString(), nStakeTime, hashMerkleRoot.ToString(), GetBlockHash().ToString()); } }; /** Used to marshal pointers into hashes for db storage. */ class CDiskBlockIndex : public CBlockIndex { private: uint256 blockHash; public: uint256 hashPrev; uint256 hashNext; CDiskBlockIndex() { hashPrev = 0; hashNext = 0; blockHash = 0; } explicit CDiskBlockIndex(CBlockIndex* pindex) : CBlockIndex(*pindex) { hashPrev = (pprev ? pprev->GetBlockHash() : 0); hashNext = (pnext ? pnext->GetBlockHash() : 0); } IMPLEMENT_SERIALIZE ( if (!(nType & SER_GETHASH)) READWRITE(nVersion); READWRITE(hashNext); READWRITE(nFile); READWRITE(nBlockPos); READWRITE(nHeight); READWRITE(nMint); READWRITE(nMoneySupply); READWRITE(nFlags); READWRITE(nStakeModifier); READWRITE(bnStakeModifier); if (IsProofOfStake()) { READWRITE(prevoutStake); READWRITE(nStakeTime); } else if (fRead) { const_cast<CDiskBlockIndex*>(this)->prevoutStake.SetNull(); const_cast<CDiskBlockIndex*>(this)->nStakeTime = 0; } READWRITE(hashProof); // block header READWRITE(this->nVersion); READWRITE(hashPrev); READWRITE(hashMerkleRoot); READWRITE(nTime); READWRITE(nBits); READWRITE(nNonce); READWRITE(blockHash); ) uint256 GetBlockHash() const { if (fUseFastIndex && (nTime < GetAdjustedTime() - 24 * 60 * 60) && blockHash != 0) return blockHash; CBlock block; block.nVersion = nVersion; block.hashPrevBlock = hashPrev; block.hashMerkleRoot = hashMerkleRoot; block.nTime = nTime; block.nBits = nBits; block.nNonce = nNonce; const_cast<CDiskBlockIndex*>(this)->blockHash = block.GetHash(); return blockHash; } std::string ToString() const { std::string str = "CDiskBlockIndex("; str += CBlockIndex::ToString(); str += strprintf("\n hashBlock=%s, hashPrev=%s, hashNext=%s)", GetBlockHash().ToString(), hashPrev.ToString(), hashNext.ToString()); return str; } }; /** Describes a place in the block chain to another node such that if the * other node doesn't have the same branch, it can find a recent common trunk. * The further back it is, the further before the fork it may be. */ class CBlockLocator { protected: std::vector<uint256> vHave; public: CBlockLocator() { } explicit CBlockLocator(const CBlockIndex* pindex) { Set(pindex); } explicit CBlockLocator(uint256 hashBlock) { std::map<uint256, CBlockIndex*>::iterator mi = mapBlockIndex.find(hashBlock); if (mi != mapBlockIndex.end()) Set((*mi).second); } CBlockLocator(const std::vector<uint256>& vHaveIn) { vHave = vHaveIn; } IMPLEMENT_SERIALIZE ( if (!(nType & SER_GETHASH)) READWRITE(nVersion); READWRITE(vHave); ) void SetNull() { vHave.clear(); } bool IsNull() { return vHave.empty(); } void Set(const CBlockIndex* pindex) { vHave.clear(); int nStep = 1; while (pindex) { vHave.push_back(pindex->GetBlockHash()); // Exponentially larger steps back for (int i = 0; pindex && i < nStep; i++) pindex = pindex->pprev; if (vHave.size() > 10) nStep *= 2; } vHave.push_back(Params().HashGenesisBlock()); } int GetDistanceBack() { // Retrace how far back it was in the sender's branch int nDistance = 0; int nStep = 1; BOOST_FOREACH(const uint256& hash, vHave) { std::map<uint256, CBlockIndex*>::iterator mi = mapBlockIndex.find(hash); if (mi != mapBlockIndex.end()) { CBlockIndex* pindex = (*mi).second; if (pindex->IsInMainChain()) return nDistance; } nDistance += nStep; if (nDistance > 10) nStep *= 2; } return nDistance; } CBlockIndex* GetBlockIndex() { // Find the first block the caller has in the main chain BOOST_FOREACH(const uint256& hash, vHave) { std::map<uint256, CBlockIndex*>::iterator mi = mapBlockIndex.find(hash); if (mi != mapBlockIndex.end()) { CBlockIndex* pindex = (*mi).second; if (pindex->IsInMainChain()) return pindex; } } return pindexGenesisBlock; } uint256 GetBlockHash() { // Find the first block the caller has in the main chain BOOST_FOREACH(const uint256& hash, vHave) { std::map<uint256, CBlockIndex*>::iterator mi = mapBlockIndex.find(hash); if (mi != mapBlockIndex.end()) { CBlockIndex* pindex = (*mi).second; if (pindex->IsInMainChain()) return hash; } } return Params().HashGenesisBlock(); } int GetHeight() { CBlockIndex* pindex = GetBlockIndex(); if (!pindex) return 0; return pindex->nHeight; } }; class CWalletInterface { protected: virtual void SyncTransaction(const CTransaction &tx, const CBlock *pblock, bool fConnect) =0; virtual void EraseFromWallet(const uint256 &hash) =0; virtual void SetBestChain(const CBlockLocator &locator) =0; virtual void UpdatedTransaction(const uint256 &hash) =0; virtual void Inventory(const uint256 &hash) =0; virtual void ResendWalletTransactions(bool fForce) =0; friend void ::RegisterWallet(CWalletInterface*); friend void ::UnregisterWallet(CWalletInterface*); friend void ::UnregisterAllWallets(); }; #endif
[ "FootyCash@gmail.com" ]
FootyCash@gmail.com
6b3af69f4d3ea13d9e119caf66c91087c0a426a1
0eff74b05b60098333ad66cf801bdd93becc9ea4
/second/download/squid/gumtree/squid_repos_function_3485_squid-3.5.27.cpp
9d59d3a4ebdb740c55ce0d9ee0f3ce44ed05e693
[]
no_license
niuxu18/logTracker-old
97543445ea7e414ed40bdc681239365d33418975
f2b060f13a0295387fe02187543db124916eb446
refs/heads/master
2021-09-13T21:39:37.686481
2017-12-11T03:36:34
2017-12-11T03:36:34
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,897
cpp
void clientReplyContext::purgeDoPurgeHead(StoreEntry *newEntry) { if (newEntry && !newEntry->isNull()) { debugs(88, 4, "clientPurgeRequest: HEAD '" << newEntry->url() << "'" ); #if USE_HTCP neighborsHtcpClear(newEntry, NULL, http->request, HttpRequestMethod(Http::METHOD_HEAD), HTCP_CLR_PURGE); #endif newEntry->release(); purgeStatus = Http::scOkay; } /* And for Vary, release the base URI if none of the headers was included in the request */ if (!http->request->vary_headers.isEmpty() && http->request->vary_headers.find('=') != SBuf::npos) { StoreEntry *entry = storeGetPublic(urlCanonical(http->request), Http::METHOD_GET); if (entry) { debugs(88, 4, "clientPurgeRequest: Vary GET '" << entry->url() << "'" ); #if USE_HTCP neighborsHtcpClear(entry, NULL, http->request, HttpRequestMethod(Http::METHOD_GET), HTCP_CLR_PURGE); #endif entry->release(); purgeStatus = Http::scOkay; } entry = storeGetPublic(urlCanonical(http->request), Http::METHOD_HEAD); if (entry) { debugs(88, 4, "clientPurgeRequest: Vary HEAD '" << entry->url() << "'" ); #if USE_HTCP neighborsHtcpClear(entry, NULL, http->request, HttpRequestMethod(Http::METHOD_HEAD), HTCP_CLR_PURGE); #endif entry->release(); purgeStatus = Http::scOkay; } } /* * Make a new entry to hold the reply to be written * to the client. */ /* FIXME: This doesn't need to go through the store. Simply * push down the client chain */ createStoreEntry(http->request->method, RequestFlags()); triggerInitialStoreRead(); HttpReply *rep = new HttpReply; rep->setHeaders(purgeStatus, NULL, NULL, 0, 0, -1); http->storeEntry()->replaceHttpReply(rep); http->storeEntry()->complete(); }
[ "993273596@qq.com" ]
993273596@qq.com
e779f167f39d2eea0a3a4ee34786f3ff83def902
32cbb0a1fc652005198d6ed5ed52e25572612057
/core/unit_test/openmptarget/TestOpenMPTarget_TeamScratch.cpp
2593609e333cf98b37bf899c483e5b8ed7ce9a33
[ "BSD-3-Clause", "BSD-2-Clause" ]
permissive
ORNL-CEES/kokkos
3874d42a685084f0eb7999939cd9f1da9d42a2a6
70d113838b7dade09218a46c1e8aae44b6dbd321
refs/heads/hip
2020-05-04T03:32:58.012717
2020-01-24T20:43:25
2020-01-24T20:43:25
178,948,568
1
1
NOASSERTION
2020-03-01T19:21:45
2019-04-01T21:19:04
C++
UTF-8
C++
false
false
3,225
cpp
/* //@HEADER // ************************************************************************ // // Kokkos v. 2.0 // Copyright (2014) Sandia Corporation // // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation, // the U.S. Government retains certain rights in this software. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // 1. Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // // 2. Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // // 3. Neither the name of the Corporation nor the names of the // contributors may be used to endorse or promote products derived from // this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Questions? Contact Christian R. Trott (crtrott@sandia.gov) // // ************************************************************************ //@HEADER */ #include <openmptarget/TestOpenMPTarget_Category.hpp> #include <TestTeam.hpp> namespace Test { TEST_F(TEST_CATEGORY, team_shared_request) { TestSharedTeam<TEST_EXECSPACE, Kokkos::Schedule<Kokkos::Static> >(); TestSharedTeam<TEST_EXECSPACE, Kokkos::Schedule<Kokkos::Dynamic> >(); } TEST_F(TEST_CATEGORY, team_scratch_request) { TestScratchTeam<TEST_EXECSPACE, Kokkos::Schedule<Kokkos::Static> >(); TestScratchTeam<TEST_EXECSPACE, Kokkos::Schedule<Kokkos::Dynamic> >(); } #if defined(KOKKOS_ENABLE_CXX11_DISPATCH_LAMBDA) #if !defined(KOKKOS_ENABLE_CUDA) || (8000 <= CUDA_VERSION) TEST_F(TEST_CATEGORY, team_lambda_shared_request) { TestLambdaSharedTeam<Kokkos::HostSpace, TEST_EXECSPACE, Kokkos::Schedule<Kokkos::Static> >(); TestLambdaSharedTeam<Kokkos::HostSpace, TEST_EXECSPACE, Kokkos::Schedule<Kokkos::Dynamic> >(); } #endif #endif TEST_F(TEST_CATEGORY, shmem_size) { TestShmemSize<TEST_EXECSPACE>(); } TEST_F(TEST_CATEGORY, multi_level_scratch) { TestMultiLevelScratchTeam<TEST_EXECSPACE, Kokkos::Schedule<Kokkos::Static> >(); TestMultiLevelScratchTeam<TEST_EXECSPACE, Kokkos::Schedule<Kokkos::Dynamic> >(); } } // namespace Test
[ "crtrott@sandia.gov" ]
crtrott@sandia.gov