blob_id
stringlengths
40
40
directory_id
stringlengths
40
40
path
stringlengths
4
201
content_id
stringlengths
40
40
detected_licenses
listlengths
0
85
license_type
stringclasses
2 values
repo_name
stringlengths
7
100
snapshot_id
stringlengths
40
40
revision_id
stringlengths
40
40
branch_name
stringclasses
260 values
visit_date
timestamp[us]
revision_date
timestamp[us]
committer_date
timestamp[us]
github_id
int64
11.4k
681M
star_events_count
int64
0
209k
fork_events_count
int64
0
110k
gha_license_id
stringclasses
17 values
gha_event_created_at
timestamp[us]
gha_created_at
timestamp[us]
gha_language
stringclasses
80 values
src_encoding
stringclasses
28 values
language
stringclasses
1 value
is_vendor
bool
1 class
is_generated
bool
2 classes
length_bytes
int64
8
9.86M
extension
stringclasses
52 values
content
stringlengths
8
9.86M
authors
listlengths
1
1
author
stringlengths
0
119
881dac97ec95bfda4c98821474807dae123ed539
5508378e96a5953cab65ee09b0bcf3ef16b9fd46
/test_code/ball_tests/reflecttest.cpp
160c2d8a3f2784a3cd40fb0ab9f6c0f3d957f573
[]
no_license
koenigr/pipong
970167c33f39575168d14c4dbcc5883f1a059d1a
2cd25f8859a7872215a0060a4a3e3580a32a7aa1
refs/heads/master
2020-06-11T23:38:39.200865
2019-08-05T11:43:15
2019-08-05T11:43:15
194,123,826
0
0
null
null
null
null
UTF-8
C++
false
false
365
cpp
#include "../../gamestate/Ball.h" #include <iostream> int main() { Ball ball; std::cout << "Ball angle: " << ball.getAngle() << std::endl; ball.setAngle(1, 10); ball.reflectBall(1); ball.setAngle(1, 170); ball.reflectBall(3); ball.setAngle(1, 170); ball.reflectBall(0); ball.setAngle(1, 190); ball.reflectBall(2); }
[ "koenig_regina@arcor.de" ]
koenig_regina@arcor.de
e27356f09e9aa6b035b795d0d3d7a79d12145507
6581ff32670e4b30dd17c781975c95eac2153ebc
/libnode-v10.15.3/deps/v8/src/conversions.h
77d3e8bbcd4380c4f757ab2f56c6e5a6bad20d80
[ "bzip2-1.0.6", "BSD-3-Clause", "SunPro", "Apache-2.0", "LicenseRef-scancode-unicode", "Zlib", "ISC", "LicenseRef-scancode-public-domain", "NAIST-2003", "BSD-2-Clause", "Artistic-2.0", "LicenseRef-scancode-unknown-license-reference", "NTP", "LicenseRef-scancode-openssl", "MIT", "ICU", ...
permissive
pxscene/Spark-Externals
6f3a16bafae1d89015f635b1ad1aa2efe342a001
92501a5d10c2a167bac07915eb9c078dc9aab158
refs/heads/master
2023-01-22T12:48:39.455338
2020-05-01T14:19:54
2020-05-01T14:19:54
205,173,203
1
35
Apache-2.0
2023-01-07T09:41:55
2019-08-29T13:43:36
C
UTF-8
C++
false
false
6,546
h
// Copyright 2011 the V8 project authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef V8_CONVERSIONS_H_ #define V8_CONVERSIONS_H_ #include <limits> #include "src/base/logging.h" #include "src/utils.h" namespace v8 { namespace internal { class BigInt; template <typename T> class Handle; class UnicodeCache; // The limit for the the fractionDigits/precision for toFixed, toPrecision // and toExponential. const int kMaxFractionDigits = 100; // The fast double-to-(unsigned-)int conversion routine does not guarantee // rounding towards zero. // If x is NaN, the result is INT_MIN. Otherwise the result is the argument x, // clamped to [INT_MIN, INT_MAX] and then rounded to an integer. inline int FastD2IChecked(double x) { if (!(x >= INT_MIN)) return INT_MIN; // Negation to catch NaNs. if (x > INT_MAX) return INT_MAX; return static_cast<int>(x); } // The fast double-to-(unsigned-)int conversion routine does not guarantee // rounding towards zero. // The result is undefined if x is infinite or NaN, or if the rounded // integer value is outside the range of type int. inline int FastD2I(double x) { DCHECK(x <= INT_MAX); DCHECK(x >= INT_MIN); return static_cast<int32_t>(x); } inline unsigned int FastD2UI(double x); inline double FastI2D(int x) { // There is no rounding involved in converting an integer to a // double, so this code should compile to a few instructions without // any FPU pipeline stalls. return static_cast<double>(x); } inline double FastUI2D(unsigned x) { // There is no rounding involved in converting an unsigned integer to a // double, so this code should compile to a few instructions without // any FPU pipeline stalls. return static_cast<double>(x); } // This function should match the exact semantics of ECMA-262 20.2.2.17. inline float DoubleToFloat32(double x); // This function should match the exact semantics of ECMA-262 9.4. inline double DoubleToInteger(double x); // This function should match the exact semantics of ECMA-262 9.5. inline int32_t DoubleToInt32(double x); // This function should match the exact semantics of ECMA-262 9.6. inline uint32_t DoubleToUint32(double x); // Enumeration for allowing octals and ignoring junk when converting // strings to numbers. enum ConversionFlags { NO_FLAGS = 0, ALLOW_HEX = 1, ALLOW_OCTAL = 2, ALLOW_IMPLICIT_OCTAL = 4, ALLOW_BINARY = 8, ALLOW_TRAILING_JUNK = 16 }; // Converts a string into a double value according to ECMA-262 9.3.1 double StringToDouble(UnicodeCache* unicode_cache, Vector<const uint8_t> str, int flags, double empty_string_val = 0); double StringToDouble(UnicodeCache* unicode_cache, Vector<const uc16> str, int flags, double empty_string_val = 0); // This version expects a zero-terminated character array. double StringToDouble(UnicodeCache* unicode_cache, const char* str, int flags, double empty_string_val = 0); double StringToInt(Isolate* isolate, Handle<String> string, int radix); // This follows https://tc39.github.io/proposal-bigint/#sec-string-to-bigint // semantics: "" => 0n. MaybeHandle<BigInt> StringToBigInt(Isolate* isolate, Handle<String> string); // This version expects a zero-terminated character array. Radix will // be inferred from string prefix (case-insensitive): // 0x -> hex // 0o -> octal // 0b -> binary V8_EXPORT_PRIVATE MaybeHandle<BigInt> BigIntLiteral(Isolate* isolate, const char* string); const int kDoubleToCStringMinBufferSize = 100; // Converts a double to a string value according to ECMA-262 9.8.1. // The buffer should be large enough for any floating point number. // 100 characters is enough. const char* DoubleToCString(double value, Vector<char> buffer); // Convert an int to a null-terminated string. The returned string is // located inside the buffer, but not necessarily at the start. const char* IntToCString(int n, Vector<char> buffer); // Additional number to string conversions for the number type. // The caller is responsible for calling free on the returned pointer. char* DoubleToFixedCString(double value, int f); char* DoubleToExponentialCString(double value, int f); char* DoubleToPrecisionCString(double value, int f); char* DoubleToRadixCString(double value, int radix); static inline bool IsMinusZero(double value) { return bit_cast<int64_t>(value) == bit_cast<int64_t>(-0.0); } // Returns true if value can be converted to a SMI, and returns the resulting // integer value of the SMI in |smi_int_value|. inline bool DoubleToSmiInteger(double value, int* smi_int_value); inline bool IsSmiDouble(double value); // Integer32 is an integer that can be represented as a signed 32-bit // integer. It has to be in the range [-2^31, 2^31 - 1]. // We also have to check for negative 0 as it is not an Integer32. inline bool IsInt32Double(double value); // UInteger32 is an integer that can be represented as an unsigned 32-bit // integer. It has to be in the range [0, 2^32 - 1]. // We also have to check for negative 0 as it is not a UInteger32. inline bool IsUint32Double(double value); // Tries to convert |value| to a uint32, setting the result in |uint32_value|. // If the output does not compare equal to the input, returns false and the // value in |uint32_value| is left unspecified. // Used for conversions such as in ECMA-262 15.4.2.2, which check "ToUint32(len) // is equal to len". inline bool DoubleToUint32IfEqualToSelf(double value, uint32_t* uint32_value); // Convert from Number object to C integer. inline uint32_t PositiveNumberToUint32(Object* number); inline int32_t NumberToInt32(Object* number); inline uint32_t NumberToUint32(Object* number); inline int64_t NumberToInt64(Object* number); inline uint64_t PositiveNumberToUint64(Object* number); double StringToDouble(UnicodeCache* unicode_cache, Handle<String> string, int flags, double empty_string_val = 0.0); inline bool TryNumberToSize(Object* number, size_t* result); // Converts a number into size_t. inline size_t NumberToSize(Object* number); // returns DoubleToString(StringToDouble(string)) == string bool IsSpecialIndex(UnicodeCache* unicode_cache, String* string); } // namespace internal } // namespace v8 #endif // V8_CONVERSIONS_H_
[ "madanagopal_thirumalai@comcast.com" ]
madanagopal_thirumalai@comcast.com
313dd0e3a23207eee557be8a2773fed8f87c6058
11cd65ab418283f31ded8a81304fa9abb70c9c74
/SDK/LibFmod/examples/gapless_playback.cpp
ae05701d8a20752bacb5167f278024449ec56915
[]
no_license
sim9108/SDKS
16affd227b21ff40454e7fffd0fcde3ac7ad6844
358ff46d925de151c422ee008e1ddaea6be3d067
refs/heads/main
2023-03-15T22:47:10.973000
2022-05-16T12:50:00
2022-05-16T12:50:00
27,232,062
2
0
null
null
null
null
UTF-8
C++
false
false
9,606
cpp
/*============================================================================== Gapless Playback Example Copyright (c), Firelight Technologies Pty, Ltd 2004-2021. This example shows how to schedule channel playback into the future with sample accuracy. Use several scheduled channels to synchronize 2 or more sounds. ==============================================================================*/ #include "fmod.hpp" #include "common.h" enum NOTE { NOTE_C, NOTE_D, NOTE_E, }; NOTE note[] = { NOTE_E, /* Ma- */ NOTE_D, /* ry */ NOTE_C, /* had */ NOTE_D, /* a */ NOTE_E, /* lit- */ NOTE_E, /* tle */ NOTE_E, /* lamb, */ NOTE_E, /* ..... */ NOTE_D, /* lit- */ NOTE_D, /* tle */ NOTE_D, /* lamb, */ NOTE_D, /* ..... */ NOTE_E, /* lit- */ NOTE_E, /* tle */ NOTE_E, /* lamb, */ NOTE_E, /* ..... */ NOTE_E, /* Ma- */ NOTE_D, /* ry */ NOTE_C, /* had */ NOTE_D, /* a */ NOTE_E, /* lit- */ NOTE_E, /* tle */ NOTE_E, /* lamb, */ NOTE_E, /* its */ NOTE_D, /* fleece */ NOTE_D, /* was */ NOTE_E, /* white */ NOTE_D, /* as */ NOTE_C, /* snow. */ NOTE_C, /* ..... */ NOTE_C, /* ..... */ NOTE_C, /* ..... */ }; int FMOD_Main() { FMOD::System *system; FMOD::Sound *sound[3]; FMOD::Channel *channel = 0; FMOD::ChannelGroup *channelgroup = 0; FMOD_RESULT result; unsigned int dsp_block_len, count; int outputrate = 0; void *extradriverdata = 0; Common_Init(&extradriverdata); /* Create a System object and initialize. */ result = FMOD::System_Create(&system); ERRCHECK(result); result = system->init(100, FMOD_INIT_NORMAL, extradriverdata); ERRCHECK(result); /* Get information needed later for scheduling. The mixer block size, and the output rate of the mixer. */ result = system->getDSPBufferSize(&dsp_block_len, 0); ERRCHECK(result); result = system->getSoftwareFormat(&outputrate, 0, 0); ERRCHECK(result); /* Load 3 sounds - these are just sine wave tones at different frequencies. C, D and E on the musical scale. */ result = system->createSound(Common_MediaPath("c.ogg"), FMOD_DEFAULT, 0, &sound[NOTE_C]); ERRCHECK(result); result = system->createSound(Common_MediaPath("d.ogg"), FMOD_DEFAULT, 0, &sound[NOTE_D]); ERRCHECK(result); result = system->createSound(Common_MediaPath("e.ogg"), FMOD_DEFAULT, 0, &sound[NOTE_E]); ERRCHECK(result); /* Create a channelgroup that the channels will play on. We can use this channelgroup as our clock reference. It also means we can pause and pitch bend the channelgroup, without affecting the offsets of the delays, because the channelgroup clock which the channels feed off, will be pausing and speeding up/slowing down and still keeping the children in sync. */ result = system->createChannelGroup("Parent", &channelgroup); ERRCHECK(result); unsigned int numsounds = sizeof(note) / sizeof(note[0]); /* Play all the sounds at once! Space them apart with set delay though so that they sound like they play in order. */ for (count = 0; count < numsounds; count++) { static unsigned long long clock_start = 0; unsigned int slen; FMOD::Sound *s = sound[note[count]]; /* Pick a note from our tune. */ result = system->playSound(s, channelgroup, true, &channel); /* Play the sound on the channelgroup we want to use as the parent clock reference (for setDelay further down) */ ERRCHECK(result); if (!clock_start) { result = channel->getDSPClock(0, &clock_start); ERRCHECK(result); clock_start += (dsp_block_len * 2); /* Start the sound into the future, by 2 mixer blocks worth. */ /* Should be enough to avoid the mixer catching up and hitting the clock value before we've finished setting up everything. */ /* Alternatively the channelgroup we're basing the clock on could be paused to stop it ticking. */ } else { float freq; result = s->getLength(&slen, FMOD_TIMEUNIT_PCM); /* Get the length of the sound in samples. */ ERRCHECK(result); result = s->getDefaults(&freq, 0); /* Get the default frequency that the sound was recorded at. */ ERRCHECK(result); slen = (unsigned int)((float)slen / freq * outputrate); /* Convert the length of the sound to 'output samples' for the output timeline. */ clock_start += slen; /* Place the sound clock start time to this value after the last one. */ } result = channel->setDelay(clock_start, 0, false); /* Schedule the channel to start in the future at the newly calculated channelgroup clock value. */ ERRCHECK(result); result = channel->setPaused(false); /* Unpause the sound. Note that you won't hear the sounds, they are scheduled into the future. */ ERRCHECK(result); } /* Main loop. */ do { Common_Update(); if (Common_BtnPress(BTN_ACTION1)) /* Pausing the channelgroup as the clock parent, will pause any scheduled sounds from continuing */ { /* If you paused the channel, this would not stop the clock it is delayed against from ticking, */ bool paused; /* and you'd have to recalculate the delay for the channel into the future again before it was unpaused. */ result = channelgroup->getPaused(&paused); ERRCHECK(result); result = channelgroup->setPaused(!paused); ERRCHECK(result); } if (Common_BtnPress(BTN_ACTION2)) { for (count = 0; count < 50; count++) { float pitch; result = channelgroup->getPitch(&pitch); ERRCHECK(result); pitch += 0.01f; result = channelgroup->setPitch(pitch); ERRCHECK(result); result = system->update(); ERRCHECK(result); Common_Sleep(10); } } if (Common_BtnPress(BTN_ACTION3)) { for (count = 0; count < 50; count++) { float pitch; result = channelgroup->getPitch(&pitch); ERRCHECK(result); if (pitch > 0.1f) { pitch -= 0.01f; } result = channelgroup->setPitch(pitch); ERRCHECK(result); result = system->update(); ERRCHECK(result); Common_Sleep(10); } } result = system->update(); ERRCHECK(result); /* Print some information */ { bool playing = false; bool paused = false; int chansplaying; if (channelgroup) { result = channelgroup->isPlaying(&playing); if ((result != FMOD_OK) && (result != FMOD_ERR_INVALID_HANDLE)) { ERRCHECK(result); } result = channelgroup->getPaused(&paused); if ((result != FMOD_OK) && (result != FMOD_ERR_INVALID_HANDLE)) { ERRCHECK(result); } } result = system->getChannelsPlaying(&chansplaying, NULL); ERRCHECK(result); Common_Draw("=================================================="); Common_Draw("Gapless Playback example."); Common_Draw("Copyright (c) Firelight Technologies 2004-2021."); Common_Draw("=================================================="); Common_Draw(""); Common_Draw("Press %s to toggle pause", Common_BtnStr(BTN_ACTION1)); Common_Draw("Press %s to increase pitch", Common_BtnStr(BTN_ACTION2)); Common_Draw("Press %s to decrease pitch", Common_BtnStr(BTN_ACTION3)); Common_Draw("Press %s to quit", Common_BtnStr(BTN_QUIT)); Common_Draw(""); Common_Draw("Channels Playing %d : %s", chansplaying, paused ? "Paused " : playing ? "Playing" : "Stopped"); } Common_Sleep(50); } while (!Common_BtnPress(BTN_QUIT)); /* Shut down */ result = sound[NOTE_C]->release(); ERRCHECK(result); result = sound[NOTE_D]->release(); ERRCHECK(result); result = sound[NOTE_E]->release(); ERRCHECK(result); result = system->close(); ERRCHECK(result); result = system->release(); ERRCHECK(result); Common_Close(); return 0; }
[ "sim910@naver.com" ]
sim910@naver.com
f0da46aa1d24b7b16a6682b5d393cdfbe9d6ec2e
84ff348a95494de71c6d20ad81afa2ebd2b1fe76
/src/ripple/rpc/handlers/WalletPropose.cpp
506fde60feb6fd6dd4af86e56f7bfe34bfc10119
[ "LicenseRef-scancode-unknown-license-reference", "ISC", "MIT-Wu", "MIT", "BSL-1.0" ]
permissive
ripple-alpha/ripple-alpha-core
9b71b0bd62c58c16ab048b3c7ffc5882b8ee3645
be7061e8e521553a0212b87057db992a8a8c5bfc
refs/heads/master
2020-11-24T21:20:17.236091
2020-02-17T06:46:14
2020-02-17T06:46:14
228,344,340
1
1
NOASSERTION
2020-03-05T09:54:18
2019-12-16T08:58:46
C++
UTF-8
C++
false
false
5,762
cpp
//------------------------------------------------------------------------------ /* Copyright (c) 2012-2014 Ripple Labs Inc. Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ //============================================================================== #include <ripple/basics/strHex.h> #include <ripple/crypto/KeyType.h> #include <ripple/net/RPCErr.h> #include <ripple/protocol/ErrorCodes.h> #include <ripple/protocol/jss.h> #include <ripple/protocol/PublicKey.h> #include <ripple/protocol/SecretKey.h> #include <ripple/protocol/Seed.h> #include <ripple/rpc/Context.h> #include <ripple/rpc/impl/RPCHelpers.h> #include <ripple/rpc/handlers/WalletPropose.h> #include <ed25519-donna/ed25519.h> #include <boost/optional.hpp> #include <cmath> #include <map> namespace ripple { double estimate_entropy (std::string const& input) { // First, we calculate the Shannon entropy. This gives // the average number of bits per symbol that we would // need to encode the input. std::map<int, double> freq; for (auto const& c : input) freq[c]++; double se = 0.0; for (auto const& [_,f] : freq) { (void)_; auto x = f / input.length(); se += (x) * log2(x); } // We multiply it by the length, to get an estimate of // the number of bits in the input. We floor because it // is better to be conservative. return std::floor (-se * input.length()); } // { // passphrase: <string> // } Json::Value doWalletPropose (RPC::Context& context) { return walletPropose (context.params); } Json::Value walletPropose (Json::Value const& params) { boost::optional<KeyType> keyType; boost::optional<Seed> seed; bool rippleLibSeed = false; if (params.isMember (jss::key_type)) { if (! params[jss::key_type].isString()) { return RPC::expected_field_error ( jss::key_type, "string"); } keyType = keyTypeFromString ( params[jss::key_type].asString()); if (!keyType) return rpcError(rpcINVALID_PARAMS); } // ripple-lib encodes seed used to generate an Ed25519 wallet in a // non-standard way. While we never encode seeds that way, we try // to detect such keys to avoid user confusion. { if (params.isMember(jss::passphrase)) seed = RPC::parseRippleLibSeed(params[jss::passphrase]); else if (params.isMember(jss::seed)) seed = RPC::parseRippleLibSeed(params[jss::seed]); if(seed) { rippleLibSeed = true; // If the user *explicitly* requests a key type other than // Ed25519 we return an error. if (keyType.value_or(KeyType::ed25519) != KeyType::ed25519) return rpcError(rpcBAD_SEED); keyType = KeyType::ed25519; } } if (!seed) { if (params.isMember(jss::passphrase) || params.isMember(jss::seed) || params.isMember(jss::seed_hex)) { Json::Value err; seed = RPC::getSeedFromRPC(params, err); if (!seed) return err; } else { seed = randomSeed(); } } if (!keyType) keyType = KeyType::secp256k1; auto const publicKey = generateKeyPair (*keyType, *seed).first; Json::Value obj (Json::objectValue); auto const seed1751 = seedAs1751 (*seed); auto const seedHex = strHex (*seed); auto const seedBase58 = toBase58 (*seed); obj[jss::master_seed] = seedBase58; obj[jss::master_seed_hex] = seedHex; obj[jss::master_key] = seed1751; obj[jss::account_id] = toBase58(calcAccountID(publicKey)); obj[jss::public_key] = toBase58(TokenType::AccountPublic, publicKey); obj[jss::key_type] = to_string (*keyType); obj[jss::public_key_hex] = strHex (publicKey); // If a passphrase was specified, and it was hashed and used as a seed // run a quick entropy check and add an appropriate warning, because // "brain wallets" can be easily attacked. if (!rippleLibSeed && params.isMember (jss::passphrase)) { auto const passphrase = params[jss::passphrase].asString(); if (passphrase != seed1751 && passphrase != seedBase58 && passphrase != seedHex) { // 80 bits of entropy isn't bad, but it's better to // err on the side of caution and be conservative. if (estimate_entropy (passphrase) < 80.0) obj[jss::warning] = "This wallet was generated using a user-supplied " "passphrase that has low entropy and is vulnerable " "to brute-force attacks."; else obj[jss::warning] = "This wallet was generated using a user-supplied " "passphrase. It may be vulnerable to brute-force " "attacks."; } } return obj; } } // ripple
[ "development@ripplealpha.com" ]
development@ripplealpha.com
6b6b356fce9c21e8dcb075cad59d710b4350f51f
f4118e47a6dc256f7525fe2fbda41e8e0ce447b5
/code/frameworks/runtime-src/proj.win32/SimulatorWin.h
d1002dfd0a0ccbd47e422da031a778a371faa71a
[]
no_license
tkzcfc/ed_imgui
066668dd0a1f567c056b9f926288ed639b86033a
609e6b0aa570635816b94b57229cc4bb76f44114
refs/heads/master
2023-06-07T22:27:40.136889
2023-05-30T10:44:11
2023-05-30T10:44:11
221,164,955
6
2
null
null
null
null
UTF-8
C++
false
false
1,334
h
#pragma once #include "stdafx.h" #include "Resource.h" #include "cocos2d.h" #include "AppDelegate.h" #include "ProjectConfig/ProjectConfig.h" #include "ProjectConfig/SimulatorConfig.h" class SimulatorWin { public: static SimulatorWin *getInstance(); virtual ~SimulatorWin(); int run(); virtual void quit(); virtual void relaunch(); virtual void openNewPlayer(); virtual void openNewPlayerWithProjectConfig(const ProjectConfig &config); virtual void openProjectWithProjectConfig(const ProjectConfig &config); virtual int getPositionX(); virtual int getPositionY(); protected: SimulatorWin(); static SimulatorWin *_instance; ProjectConfig _project; HWND _hwnd; HWND _hwndConsole; AppDelegate *_app; FILE *_writeDebugLogFile; // void setupUI(); void setZoom(float frameScale); // debug log void writeDebugLog(const char *log); void parseCocosProjectConfig(ProjectConfig &config); // helper std::string convertPathFormatToUnixStyle(const std::string& path); std::string getUserDocumentPath(); std::string getApplicationExePath(); std::string getApplicationPath(); static char* convertTCharToUtf8(const TCHAR* src); static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam); };
[ "www.tkzc@foxmail.com" ]
www.tkzc@foxmail.com
e325b9108405977e6c550245a70d70a52274bb9a
ce224da6da1c2ab23dccf54788d7fa4e8d1e7f4c
/libs/hwdrivers/src/xSens_MT4/xstypes/include/xsens/xsbaud.h
e6ce755232176f72fdbff18c5c52de9a4ea32536
[ "BSD-3-Clause", "LicenseRef-scancode-unknown-license-reference" ]
permissive
astoeckel/mrpt
40d158fc9c857fcf1c7da952990b76cd332791e2
a587d5bcec68bdc8ce84d1030cd255667a5fbfa8
refs/heads/master
2021-01-18T05:59:35.665087
2016-01-21T13:33:50
2016-01-21T13:33:50
50,109,461
1
0
null
2016-01-21T13:30:50
2016-01-21T13:30:50
null
UTF-8
C++
false
false
1,903
h
/* +---------------------------------------------------------------------------+ | Mobile Robot Programming Toolkit (MRPT) | | http://www.mrpt.org/ | | | | Copyright (c) 2005-2015, Individual contributors, see AUTHORS file | | See: http://www.mrpt.org/Authors - All rights reserved. | | Released under BSD License. See details in http://www.mrpt.org/License | +---------------------------------------------------------------------------+ */ #ifndef XSBAUD_H #define XSBAUD_H #include "xstypesconfig.h" /*! \addtogroup enums Global enumerations @{ */ #include "xsbaudcode.h" #include "xsbaudrate.h" /*! @} */ typedef enum XsBaudCode XsBaudCode; typedef enum XsBaudRate XsBaudRate; #ifdef __cplusplus extern "C" { #endif XSTYPES_DLL_API XsBaudRate XsBaud_codeToRate(XsBaudCode baudcode); XSTYPES_DLL_API XsBaudCode XsBaud_rateToCode(XsBaudRate baudrate); XSTYPES_DLL_API int XsBaud_rateToNumeric(XsBaudRate baudrate); XSTYPES_DLL_API XsBaudRate XsBaud_numericToRate(int numeric); #ifdef __cplusplus } // extern "C" /*! \namespace XsBaud \brief Namespace for Baud rate and Baud code constants and conversions */ namespace XsBaud { /*! \copydoc XsBaud_codeToRate */ inline XsBaudRate codeToRate(XsBaudCode baudcode) { return XsBaud_codeToRate(baudcode); } /*! \copydoc XsBaud_rateToCode */ inline XsBaudCode rateToCode(XsBaudRate baudrate) { return XsBaud_rateToCode(baudrate); } /*! \copydoc XsBaud_rateToNumeric */ inline int rateToNumeric(XsBaudRate baudrate) { return XsBaud_rateToNumeric(baudrate); } /*! \copydoc XsBaud_numericToRate*/ inline XsBaudRate numericToRate(int numeric) { return XsBaud_numericToRate(numeric); } } #endif #endif // file guard
[ "joseluisblancoc@gmail.com" ]
joseluisblancoc@gmail.com
990c4e19ab5662982905356ec4f4bd7640e1f853
1be61f7f571d3b299e7120f526919b2f53b25906
/ocher/fmt/Meta.cpp
76a0c1d0de9fa35328b89ff419d8bf9bd6b5a81c
[]
no_license
ikarus9999/OcherBook
781e56e89691ff08ecd7fefa0d834dd0e52830e0
cec17ebc3a2d0b2ad3dde3ebad1b4ae802960647
refs/heads/master
2021-01-25T00:28:50.532929
2012-08-28T19:07:38
2012-08-28T19:07:38
4,875,864
1
0
null
2012-08-28T19:07:40
2012-07-03T18:35:54
C++
UTF-8
C++
false
false
29
cpp
#include "ocher/fmt/Meta.h"
[ "clc@alum.mit.edu" ]
clc@alum.mit.edu
2d12949115e52e5cfce19f23544c01f750589b35
37f34381d6233d66318795d81533dbe73c5a1288
/src/policy/rbf.cpp
922f08a761136015aefeb86d1fd0b9f784e94d1d
[ "MIT" ]
permissive
alphapayofficial/alphapay
71b004be073c63140bec123982edf3ba35feb6a5
471c411ad03b20b49db4f80874a3eac21e1ca91a
refs/heads/master
2020-12-02T06:33:50.398581
2017-07-11T06:14:28
2017-07-11T06:14:28
96,849,989
0
0
null
null
null
null
UTF-8
C++
false
false
1,542
cpp
// Copyright (c) 2016 The Alphapay Core developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #include "policy/rbf.h" bool SignalsOptInRBF(const CTransaction &tx) { BOOST_FOREACH(const CTxIn &txin, tx.vin) { if (txin.nSequence < std::numeric_limits<unsigned int>::max()-1) { return true; } } return false; } RBFTransactionState IsRBFOptIn(const CTransaction &tx, CTxMemPool &pool) { AssertLockHeld(pool.cs); CTxMemPool::setEntries setAncestors; // First check the transaction itself. if (SignalsOptInRBF(tx)) { return RBF_TRANSACTIONSTATE_REPLACEABLE_BIP125; } // If this transaction is not in our mempool, then we can't be sure // we will know about all its inputs. if (!pool.exists(tx.GetHash())) { return RBF_TRANSACTIONSTATE_UNKNOWN; } // If all the inputs have nSequence >= maxint-1, it still might be // signaled for RBF if any unconfirmed parents have signaled. uint64_t noLimit = std::numeric_limits<uint64_t>::max(); std::string dummy; CTxMemPoolEntry entry = *pool.mapTx.find(tx.GetHash()); pool.CalculateMemPoolAncestors(entry, setAncestors, noLimit, noLimit, noLimit, noLimit, dummy, false); BOOST_FOREACH(CTxMemPool::txiter it, setAncestors) { if (SignalsOptInRBF(it->GetTx())) { return RBF_TRANSACTIONSTATE_REPLACEABLE_BIP125; } } return RBF_TRANSACTIONSTATE_FINAL; }
[ "alphapay@yandex.com" ]
alphapay@yandex.com
b34b78ca3a80fabc8799b96810bcf79307458bca
074a35de9e1af589b221179c110a3e46a4f00a4b
/code/flow-goldberg.cpp
2b80bbd09c14fef1b029377e5e2739d5479f0859
[]
no_license
LukasFolwarczny/insalg
d657b678f391fc2a5b07ae4b09ed91faf1cf8d38
3fa8e4dcec23566312ab3ab74c3ecf7801193932
refs/heads/master
2021-01-19T08:50:17.933369
2013-12-14T15:40:30
2013-12-14T15:40:30
8,364,234
1
1
null
null
null
null
UTF-8
C++
false
false
3,243
cpp
#include "template.cpp" // Lukas Folwarczny, 2013 // http://atrey.karlin.mff.cuni.cz/~folwar/insalg/ // Goldberg algorithm for finding the maximum flow. // It is more widely known as the Push-Relabel algorithm. // This is the FIFO variant of Goldberg/Push-Relabel. // Algorithm runs in O(|V|^3). // Alpha-version - serious test have not yet been run. /*pdf*/ // Input: A symmetric oriented graph on the vertices {0,...,N-1} with M edges. // Multiedges are allowed. // C[i][0] gives the capacity of oriented edge E[i][0] -> E[i][1] // C[i][1] gives the capacity of oriented edge E[i][1] -> E[i][0] // s is a source vertex, t is a target vertex. // Returns field F, F[i][0] is flow in the edge E[i][0] -> E[i][1], F[i][1] is the flow in // the opposite edge. Size of the flow is stored in F_size. int ** goldberg(int N, int M, int E[][2], int C[][2], int s, int t, int * F_size) { int ** F = new int * [M]; for (int i = 0; i < M; i++) { F[i] = new int [2](); } int * H = new int [N](); // height of each vertex int * X = new int [N](); // excess at each vertex vector<int> * L = new vector<int> [N](); vector<int> * Ne = new vector<int> [N](); queue<int> Q; for (int i = 0; i < M; i++) { Ne[E[i][0]].push_back(i); Ne[E[i][1]].push_back(i); } // Init the algorithm - raise source and construct the initial preflow H[s] = N; for (int i = 0; i < Ne[s].size(); i++) { int e = Ne[s][i]; bool o = E[e][1] == s; int w = E[e][1-o]; F[e][o] = C[e][o]; X[s] -= C[e][o]; X[w] += C[e][o]; } // All active vertices go to the queue for (int v = 0; v < N; v++) if (X[v] > 0) Q.push(v); while (!Q.empty()) { int v = Q.front(); Q.pop(); if (v == t) continue; while (X[v] > 0 && !L[v].empty()) { int e = L[v].back(); L[v].pop_back(); int o = E[e][1] == v; int w = E[e][1-o]; // Delta is the amount of flow we push int delta = min(X[v], C[e][o] - F[e][o] + F[e][1-o]); if (delta == 0 || H[v] <= H[w]) continue; if (X[w] == 0) Q.push(w); X[v] -= delta; X[w] += delta; int x = C[e][o] - F[e][o]; F[e][o] += min(delta, C[e][o] - F[e][o]); delta -= x; if (delta > 0) F[e][1-o] -= delta; } if (X[v] > 0) { // If the vertex still has excess, we raise it and compute L - list // of edges ready to push H[v]++; for (int i = 0; i < Ne[v].size(); i++) { int e = Ne[v][i]; bool o = E[e][1] == v; int w = E[e][1-o]; if (H[v] > H[w] && C[e][o] - F[e][o] + F[e][1-o] > 0) { L[v].push_back(e); DP("e %d\n", e); } } Q.push(v); } } *F_size = X[t]; delete [] H; delete [] X; delete [] L; delete [] Ne; return F; } /*pdf*/ void goldberg_demo() { int N1 = 4, M1 = 5; int E1[5][2] = { {0, 1}, {0, 2}, {1, 2}, {1, 3}, {2, 3}}; int C1[5][2] = { {500, 0}, {400, 0}, {1, 0}, {200, 0}, {300, 0} }; int s1 = 0, t1 = 3; int F1size; int ** F1 = goldberg(N1, M1, E1, C1, s1, t1, &F1size); printf("Max flow size: %d\n", F1size); for (int i = 0; i < M1; i++) { printf("Edge e = %d -> %d, c(e) = %d, f(e) = %d\n", E1[i][0], E1[i][1], C1[i][0], F1[i][0]); printf("Edge e = %d -> %d, c(e) = %d, f(e) = %d\n", E1[i][1], E1[i][0], C1[i][1], F1[i][1]); } } #ifdef RUNDEMO int main() { goldberg_demo(); return 0; } #endif
[ "lfolwarczny@gmail.com" ]
lfolwarczny@gmail.com
49a53fe44b8b811929c1572ef224f797a2606642
fc6b47ee32a4af9a1b70bcae125f75f1f4f245a0
/Technosoft/ESM/Configurations/01/46/2_Drive IO.cp
e5fa64ab36bfda76864dbe5e88692736a998ff46
[ "Info-ZIP", "LicenseRef-scancode-unknown-license-reference" ]
permissive
trigrass2/LinearActuator
2ac23a00d4eb7e283d721fd7cf6afb307f29cdd1
c979efb577299302a0bdcbfe5bc7fe2f3e1b9be6
refs/heads/master
2021-06-10T02:15:39.408467
2016-12-29T16:27:30
2016-12-29T16:27:30
null
0
0
null
null
null
null
UTF-8
C++
false
false
5,000
cp
207 4 568 388 TEXT 1 468 280 495 302 " [V]" "Arial" 9 700 0 0 0 34 8388608 1 14737632 TEXT 1 364 280 391 302 " [V]" "Arial" 9 700 0 0 0 34 8388608 1 14737632 TEXT 1 389 87 412 108 " H" "Arial" 9 700 0 0 0 34 0 1 12648384 TEXT 1 361 142 384 163 " L" "Arial" 9 700 0 0 0 34 0 1 12632319 TEXT 1 361 87 384 108 " H" "Arial" 9 700 0 0 0 34 0 1 12648384 OUTPUT 1 361 93 384 148 0 "29 if !LSP" 29 0 TEXT 1 360 63 384 84 "\d30" "Courier New" 9 700 0 0 0 49 8388608 1 14737632 TEXT 1 333 142 356 163 " L" "Arial" 9 700 0 0 0 34 0 1 12632319 TEXT 1 333 87 356 108 " H" "Arial" 9 700 0 0 0 34 0 1 12648384 OUTPUT 1 333 93 356 148 0 "29 if !LSP" 29 0 TEXT 1 332 63 356 84 "\d29" "Courier New" 9 700 0 0 0 49 8388608 1 14737632 TEXT 1 389 142 412 163 " L" "Arial" 9 700 0 0 0 34 0 1 12632319 OUTPUT 1 389 93 412 148 0 "37/DIR" 37 0 TEXT 1 388 63 412 84 "\d37" "Courier New" 9 700 0 0 0 49 8388608 1 14737632 TEXT 1 84 64 108 85 "\d14" "Courier New" 9 700 0 0 0 49 8388608 1 14737632 TEXT 1 85 88 108 109 " H" "Arial" 9 700 0 0 0 34 0 1 12648384 TEXT 1 85 144 108 165 " L" "Arial" 9 700 0 0 0 34 0 1 12632319 INPUT 1 85 91 108 146 0 "14 if !REF" 14 0 TEXT 1 403 204 507 226 "Reference(AD5)" "Arial" 10 700 0 0 0 34 8388608 1 14737632 TEXT 1 302 204 404 226 " Feedback(AD2)" "Arial" 9 700 0 0 0 34 8388608 1 14737632 GAUGE_VERT 1 409 204 502 336 0 "AD5" "V" 0.000000000e+000 5.000000000e+000 0 0 "AD5" 8388608 0 GAUGE_VERT 1 306 204 399 336 0 "AD2" "V" 0.000000000e+000 5.000000000e+000 0 0 "AD2" 8388608 0 TEXT 1 259 172 376 199 " Analog Inputs" "Arial" 11 700 0 0 0 34 16777215 1 8388608 TEXT 1 252 166 551 343 "" "Courier New" 9 400 0 0 0 49 0 1 15790320 TEXT 1 497 38 541 60 " Error" "Arial" 9 700 0 0 0 34 8388608 1 14737632 TEXT 1 452 38 499 60 " Ready" "Arial" 9 700 0 0 0 34 8388608 1 14737632 TEXT 1 509 63 533 84 "\d12" "Courier New" 9 700 0 0 0 49 8388608 1 14737632 TEXT 1 465 63 489 84 "\d25" "Courier New" 9 700 0 0 0 49 8388608 1 14737632 TEXT 1 510 142 533 163 " L" "Arial" 9 700 0 0 0 34 0 1 12632319 TEXT 1 466 142 489 163 " L" "Arial" 9 700 0 0 0 34 0 1 12632319 TEXT 1 510 87 533 108 " H" "Arial" 9 700 0 0 0 34 0 1 12648384 TEXT 1 466 87 489 108 " H" "Arial" 9 700 0 0 0 34 0 1 12648384 OUTPUT 1 510 93 533 148 0 "" 12 0 OUTPUT 1 466 93 489 148 0 "" 25 0 TEXT 1 276 63 300 84 "\d13" "Courier New" 9 700 0 0 0 49 8388608 1 14737632 TEXT 1 416 63 440 84 "\d38" "Courier New" 9 700 0 0 0 49 8388608 1 14737632 TEXT 1 304 63 328 84 "\d14" "Courier New" 9 700 0 0 0 49 8388608 1 14737632 TEXT 1 417 142 440 163 " L" "Arial" 9 700 0 0 0 34 0 1 12632319 TEXT 1 305 142 328 163 " L" "Arial" 9 700 0 0 0 34 0 1 12632319 TEXT 1 277 142 300 163 " L" "Arial" 9 700 0 0 0 34 0 1 12632319 TEXT 1 417 87 440 108 " H" "Arial" 9 700 0 0 0 34 0 1 12648384 TEXT 1 305 87 328 108 " H" "Arial" 9 700 0 0 0 34 0 1 12648384 TEXT 1 277 87 300 108 " H" "Arial" 9 700 0 0 0 34 0 1 12648384 OUTPUT 1 277 93 300 148 0 "13 if !FBK" 13 0 OUTPUT 1 417 93 440 148 0 "38/PULSE" 38 0 OUTPUT 1 305 93 328 148 0 "14 if !REF & !DIR" 14 0 TEXT 1 266 38 453 60 " General purpose" "Arial" 9 700 0 0 0 34 8388608 1 14737632 TEXT 1 263 6 384 32 " Digital Outputs" "Arial" 11 700 0 0 0 34 16777215 1 8388608 TEXT 1 252 0 551 170 "" "Courier New" 9 400 0 0 0 49 0 1 15790320 INPUT 1 10 224 53 279 0 "\d2" 2 0 INPUT 1 198 224 241 279 0 "\d16" 16 0 TEXT 1 192 174 244 196 " Enable" "Arial" 9 700 0 0 0 34 8388608 1 14737632 INPUT 1 148 224 191 279 0 "\d34" 34 0 TEXT 1 147 198 189 223 " Indx2" "Arial" 9 700 0 0 0 34 8388608 1 14737632 TEXT 1 105 198 147 223 " Indx1" "Arial" 9 700 0 0 0 34 8388608 1 14737632 TEXT 1 100 174 194 196 " Captures" "Arial" 9 700 0 0 0 34 8388608 1 14737632 INPUT 1 105 224 148 279 0 "\d5" 5 0 INPUT 1 53 224 96 279 0 "\d24" 24 0 TEXT 1 53 198 95 223 " LSN" "Arial" 9 700 0 0 0 34 8388608 1 14737632 TEXT 1 11 198 53 223 " LSP" "Arial" 9 700 0 0 0 34 8388608 1 14737632 TEXT 1 7 174 101 196 " Limit switches" "Arial" 9 700 0 0 0 34 8388608 1 14737632 TEXT 1 47 38 178 60 " General purpose" "Arial" 9 700 0 0 0 34 8388608 1 14737632 TEXT 1 11 6 120 32 " Digital Inputs" "Arial" 11 700 0 0 0 34 16777215 1 8388608 TEXT 1 56 64 80 85 "\d13" "Courier New" 9 700 0 0 0 49 8388608 1 14737632 TEXT 1 140 64 164 85 "\d38" "Courier New" 9 700 0 0 0 49 8388608 1 14737632 TEXT 1 112 64 136 85 "\d37" "Courier New" 9 700 0 0 0 49 8388608 1 14737632 TEXT 1 141 144 164 165 " L" "Arial" 9 700 0 0 0 34 0 1 12632319 TEXT 1 113 144 136 165 " L" "Arial" 9 700 0 0 0 34 0 1 12632319 TEXT 1 57 144 80 165 " L" "Arial" 9 700 0 0 0 34 0 1 12632319 TEXT 1 141 88 164 109 " H" "Arial" 9 700 0 0 0 34 0 1 12648384 TEXT 1 113 88 136 109 " H" "Arial" 9 700 0 0 0 34 0 1 12648384 TEXT 1 57 88 80 109 " H" "Arial" 9 700 0 0 0 34 0 1 12648384 INPUT 1 57 92 80 147 0 "13 if !FBK" 13 0 INPUT 1 141 91 164 146 0 "" 38 0 INPUT 1 113 91 136 146 0 "" 37 0 TEXT 1 0 0 253 343 "" "Courier New" 9 400 0 0 0 49 0 1 15790320
[ "Sheaf Automotive" ]
Sheaf Automotive
6079dd5bc3b2364e49142e08387cdea7809c84f7
408a50711952446fed7b1bf9543915f6003d7342
/src/textview/TextDocumentView.cpp
e186e666f1f8cadd9f75b0d7168b7723b2d7fde1
[ "MIT" ]
permissive
BachToTheFuture/StyledEditPlus
fdfc72d76af1623d9fbf628469feade2a9123939
e6442e0e036428eeba6d33322b99856f1e158e00
refs/heads/master
2021-06-13T17:17:51.261504
2017-02-17T23:58:26
2017-02-17T23:58:26
null
0
0
null
null
null
null
UTF-8
C++
false
false
13,182
cpp
/* * Copyright 2013-2015, Stephan Aßmus <superstippi@gmx.de>. * All rights reserved. Distributed under the terms of the MIT License. */ #include "TextDocumentView.h" #include <algorithm> #include <stdio.h> #include <Clipboard.h> #include <Cursor.h> #include <MessageRunner.h> #include <ScrollBar.h> #include <Shape.h> #include <Window.h> enum { MSG_BLINK_CARET = 'blnk', }; TextDocumentView::TextDocumentView(const char* name) : BView(name, B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE | B_FRAME_EVENTS), fInsetLeft(0.0f), fInsetTop(0.0f), fInsetRight(0.0f), fInsetBottom(0.0f), fCaretBounds(), fCaretBlinker(NULL), fCaretBlinkToken(0), fSelectionEnabled(true), fShowCaret(false), fMouseDown(false) { fTextDocumentLayout.SetWidth(_TextLayoutWidth(Bounds().Width())); // Set default TextEditor SetTextEditor(TextEditorRef(new(std::nothrow) TextEditor(), true)); SetViewUIColor(B_DOCUMENT_BACKGROUND_COLOR); SetLowUIColor(ViewUIColor()); } TextDocumentView::~TextDocumentView() { // Don't forget to remove listeners SetTextEditor(TextEditorRef()); delete fCaretBlinker; } void TextDocumentView::MessageReceived(BMessage* message) { switch (message->what) { case B_COPY: Copy(be_clipboard); break; case B_SELECT_ALL: SelectAll(); break; case MSG_BLINK_CARET: { int32 token; if (message->FindInt32("token", &token) == B_OK && token == fCaretBlinkToken) { _BlinkCaret(); } break; } default: BView::MessageReceived(message); } } void TextDocumentView::Draw(BRect updateRect) { FillRect(updateRect, B_SOLID_LOW); fTextDocumentLayout.SetWidth(_TextLayoutWidth(Bounds().Width())); fTextDocumentLayout.Draw(this, BPoint(fInsetLeft, fInsetTop), updateRect); if (!fSelectionEnabled || fTextEditor.Get() == NULL) return; bool isCaret = fTextEditor->SelectionLength() == 0; if (isCaret) { if (fShowCaret && fTextEditor->IsEditingEnabled()) _DrawCaret(fTextEditor->CaretOffset()); } else { _DrawSelection(); } } void TextDocumentView::AttachedToWindow() { _UpdateScrollBars(); } void TextDocumentView::FrameResized(float width, float height) { fTextDocumentLayout.SetWidth(width); _UpdateScrollBars(); } void TextDocumentView::WindowActivated(bool active) { Invalidate(); } void TextDocumentView::MakeFocus(bool focus) { if (focus != IsFocus()) Invalidate(); BView::MakeFocus(focus); } void TextDocumentView::MouseDown(BPoint where) { if (!fSelectionEnabled) return; MakeFocus(); int32 modifiers = 0; int32 clicks = 0; if (Window() != NULL && Window()->CurrentMessage() != NULL){ Window()->CurrentMessage()->FindInt32("modifiers", &modifiers); Window()->CurrentMessage()->FindInt32("clicks", &clicks); } if (clicks >1){ bool rightOfCenter; int32 offset = fTextDocumentLayout.TextOffsetAt(where.x,where.y,rightOfCenter); float x1,y1,x2,y2; fTextDocumentLayout.GetTextBounds(offset,x1,y2,x2,y2); SetCaret(BPoint(x1,y1),false); SetCaret(BPoint(x2,y2), true); //TODO if its 2 then select the TextSpan //find the textoffset where the TextSpan starts //TextSpan.Text() ->Length //if its 3 then select the whole Paragraph //find the textoffset where the Paragraph starts //ParagraphAt -> Paragraph.Length() } else { fMouseDown = true; SetMouseEventMask(B_POINTER_EVENTS, B_LOCK_WINDOW_FOCUS); bool extendSelection = (modifiers & B_SHIFT_KEY) != 0; SetCaret(where, extendSelection); } } void TextDocumentView::MouseUp(BPoint where) { fMouseDown = false; } void TextDocumentView::MouseMoved(BPoint where, uint32 transit, const BMessage* dragMessage) { if (!fSelectionEnabled) return; BCursor iBeamCursor(B_CURSOR_ID_I_BEAM); SetViewCursor(&iBeamCursor); if (fMouseDown) SetCaret(where, true); } void TextDocumentView::KeyDown(const char* bytes, int32 numBytes) { if (fTextEditor.Get() == NULL) return; KeyEvent event; event.bytes = bytes; event.length = numBytes; event.key = 0; event.modifiers = modifiers(); if (Window() != NULL && Window()->CurrentMessage() != NULL) { BMessage* message = Window()->CurrentMessage(); message->FindInt32("raw_char", &event.key); message->FindInt32("modifiers", &event.modifiers); } fTextEditor->KeyDown(event); _ShowCaret(true); // TODO: It is necessary to invalidate all, since neither the caret bounds // are updated in a way that would work here, nor is the text updated // correcty which has been edited. Invalidate(); } void TextDocumentView::KeyUp(const char* bytes, int32 numBytes) { } BSize TextDocumentView::MinSize() { return BSize(fInsetLeft + fInsetRight + 50.0f, fInsetTop + fInsetBottom); } BSize TextDocumentView::MaxSize() { return BSize(B_SIZE_UNLIMITED, B_SIZE_UNLIMITED); } BSize TextDocumentView::PreferredSize() { return BSize(B_SIZE_UNLIMITED, B_SIZE_UNLIMITED); } bool TextDocumentView::HasHeightForWidth() { return true; } void TextDocumentView::GetHeightForWidth(float width, float* min, float* max, float* preferred) { TextDocumentLayout layout(fTextDocumentLayout); layout.SetWidth(_TextLayoutWidth(width)); float height = layout.Height() + 1 + fInsetTop + fInsetBottom; if (min != NULL) *min = height; if (max != NULL) *max = height; if (preferred != NULL) *preferred = height; } // #pragma mark - void TextDocumentView::SetTextDocument(const TextDocumentRef& document) { fTextDocument = document; fTextDocumentLayout.SetTextDocument(fTextDocument); if (fTextEditor.Get() != NULL) fTextEditor->SetDocument(document); InvalidateLayout(); Invalidate(); _UpdateScrollBars(); } void TextDocumentView::SetEditingEnabled(bool enabled) { if (fTextEditor.Get() != NULL) fTextEditor->SetEditingEnabled(enabled); } void TextDocumentView::SetTextEditor(const TextEditorRef& editor) { if (fTextEditor == editor) return; if (fTextEditor.Get() != NULL) { fTextEditor->SetDocument(TextDocumentRef()); fTextEditor->SetLayout(TextDocumentLayoutRef()); // TODO: Probably has to remove listeners } fTextEditor = editor; if (fTextEditor.Get() != NULL) { fTextEditor->SetDocument(fTextDocument); fTextEditor->SetLayout(TextDocumentLayoutRef( &fTextDocumentLayout)); // TODO: Probably has to add listeners } } void TextDocumentView::SetInsets(float inset) { SetInsets(inset, inset, inset, inset); } void TextDocumentView::SetInsets(float horizontal, float vertical) { SetInsets(horizontal, vertical, horizontal, vertical); } void TextDocumentView::SetInsets(float left, float top, float right, float bottom) { if (fInsetLeft == left && fInsetTop == top && fInsetRight == right && fInsetBottom == bottom) { return; } fInsetLeft = left; fInsetTop = top; fInsetRight = right; fInsetBottom = bottom; InvalidateLayout(); Invalidate(); } void TextDocumentView::SetSelectionEnabled(bool enabled) { if (fSelectionEnabled == enabled) return; fSelectionEnabled = enabled; Invalidate(); // TODO: Deselect } void TextDocumentView::SetCaret(BPoint location, bool extendSelection) { if (!fSelectionEnabled || fTextEditor.Get() == NULL) return; location.x -= fInsetLeft; location.y -= fInsetTop; fTextEditor->SetCaret(location, extendSelection); _ShowCaret(!extendSelection); Invalidate(); } void TextDocumentView::SelectAll() { if (!fSelectionEnabled || fTextEditor.Get() == NULL) return; fTextEditor->SelectAll(); _ShowCaret(false); Invalidate(); } bool TextDocumentView::HasSelection() const { return fTextEditor.Get() != NULL && fTextEditor->HasSelection(); } void TextDocumentView::GetSelection(int32& start, int32& end) const { if (fTextEditor.Get() != NULL) { start = fTextEditor->SelectionStart(); end = fTextEditor->SelectionEnd(); } } void TextDocumentView::Copy(BClipboard* clipboard) { if (!HasSelection() || fTextDocument.Get() == NULL) { // Nothing to copy, don't clear clipboard contents for now reason. return; } if (clipboard == NULL || !clipboard->Lock()) return; clipboard->Clear(); BMessage* clip = clipboard->Data(); if (clip != NULL) { int32 start; int32 end; GetSelection(start, end); BString text = fTextDocument->Text(start, end - start); clip->AddData("text/plain", B_MIME_TYPE, text.String(), text.Length()); // TODO: Support for "application/x-vnd.Be-text_run_array" clipboard->Commit(); } clipboard->Unlock(); } // #pragma mark - private float TextDocumentView::_TextLayoutWidth(float viewWidth) const { return viewWidth - (fInsetLeft + fInsetRight); } static const float kHorizontalScrollBarStep = 10.0f; static const float kVerticalScrollBarStep = 12.0f; void TextDocumentView::_UpdateScrollBars() { BRect bounds(Bounds()); BScrollBar* horizontalScrollBar = ScrollBar(B_HORIZONTAL); if (horizontalScrollBar != NULL) { long viewWidth = bounds.IntegerWidth(); long dataWidth = (long)ceilf( fTextDocumentLayout.Width() + fInsetLeft + fInsetRight); long maxRange = dataWidth - viewWidth; maxRange = std::max(maxRange, 0L); horizontalScrollBar->SetRange(0, (float)maxRange); horizontalScrollBar->SetProportion((float)viewWidth / dataWidth); horizontalScrollBar->SetSteps(kHorizontalScrollBarStep, dataWidth / 10); } BScrollBar* verticalScrollBar = ScrollBar(B_VERTICAL); if (verticalScrollBar != NULL) { long viewHeight = bounds.IntegerHeight(); long dataHeight = (long)ceilf( fTextDocumentLayout.Height() + fInsetTop + fInsetBottom); long maxRange = dataHeight - viewHeight; maxRange = std::max(maxRange, 0L); verticalScrollBar->SetRange(0, maxRange); verticalScrollBar->SetProportion((float)viewHeight / dataHeight); verticalScrollBar->SetSteps(kVerticalScrollBarStep, viewHeight); } } void TextDocumentView::_ShowCaret(bool show) { fShowCaret = show; if (fCaretBounds.IsValid()) Invalidate(fCaretBounds); else Invalidate(); // Cancel previous blinker, increment blink token so we only accept // the message from the blinker we just created fCaretBlinkToken++; BMessage message(MSG_BLINK_CARET); message.AddInt32("token", fCaretBlinkToken); delete fCaretBlinker; fCaretBlinker = new BMessageRunner(BMessenger(this), &message, 500000, 1); } void TextDocumentView::_BlinkCaret() { if (!fSelectionEnabled || fTextEditor.Get() == NULL) return; _ShowCaret(!fShowCaret); } void TextDocumentView::_DrawCaret(int32 textOffset) { if (!IsFocus() || Window() == NULL || !Window()->IsActive()) return; float x1; float y1; float x2; float y2; fTextDocumentLayout.GetTextBounds(textOffset, x1, y1, x2, y2); x2 = x1 + 1; fCaretBounds = BRect(x1, y1, x2, y2); fCaretBounds.OffsetBy(fInsetLeft, fInsetTop); SetDrawingMode(B_OP_INVERT); FillRect(fCaretBounds); } void TextDocumentView::_DrawSelection() { int32 start; int32 end; GetSelection(start, end); BShape shape; _GetSelectionShape(shape, start, end); SetDrawingMode(B_OP_SUBTRACT); SetLineMode(B_ROUND_CAP, B_ROUND_JOIN); MovePenTo(fInsetLeft - 0.5f, fInsetTop - 0.5f); if (IsFocus() && Window() != NULL && Window()->IsActive()) { SetHighColor(30, 30, 30); FillShape(&shape); } SetHighColor(40, 40, 40); StrokeShape(&shape); } void TextDocumentView::_GetSelectionShape(BShape& shape, int32 start, int32 end) { float startX1; float startY1; float startX2; float startY2; fTextDocumentLayout.GetTextBounds(start, startX1, startY1, startX2, startY2); startX1 = floorf(startX1); startY1 = floorf(startY1); startX2 = ceilf(startX2); startY2 = ceilf(startY2); float endX1; float endY1; float endX2; float endY2; fTextDocumentLayout.GetTextBounds(end, endX1, endY1, endX2, endY2); endX1 = floorf(endX1); endY1 = floorf(endY1); endX2 = ceilf(endX2); endY2 = ceilf(endY2); int32 startLineIndex = fTextDocumentLayout.LineIndexForOffset(start); int32 endLineIndex = fTextDocumentLayout.LineIndexForOffset(end); if (startLineIndex == endLineIndex) { // Selection on one line BPoint lt(startX1, startY1); BPoint rt(endX1, endY1); BPoint rb(endX1, endY2); BPoint lb(startX1, startY2); shape.MoveTo(lt); shape.LineTo(rt); shape.LineTo(rb); shape.LineTo(lb); shape.Close(); } else if (startLineIndex == endLineIndex - 1 && endX1 <= startX1) { // Selection on two lines, with gap: // --------- // ------### // ##------- // --------- float width = ceilf(fTextDocumentLayout.Width()); BPoint lt(startX1, startY1); BPoint rt(width, startY1); BPoint rb(width, startY2); BPoint lb(startX1, startY2); shape.MoveTo(lt); shape.LineTo(rt); shape.LineTo(rb); shape.LineTo(lb); shape.Close(); lt = BPoint(0, endY1); rt = BPoint(endX1, endY1); rb = BPoint(endX1, endY2); lb = BPoint(0, endY2); shape.MoveTo(lt); shape.LineTo(rt); shape.LineTo(rb); shape.LineTo(lb); shape.Close(); } else { // Selection over multiple lines float width = ceilf(fTextDocumentLayout.Width()); shape.MoveTo(BPoint(startX1, startY1)); shape.LineTo(BPoint(width, startY1)); shape.LineTo(BPoint(width, endY1)); shape.LineTo(BPoint(endX1, endY1)); shape.LineTo(BPoint(endX1, endY2)); shape.LineTo(BPoint(0, endY2)); shape.LineTo(BPoint(0, startY2)); shape.LineTo(BPoint(startX1, startY2)); shape.Close(); } }
[ "two4god@gmail.com" ]
two4god@gmail.com
8bbbba4955e9005cb19d7ae07e5622da116bfe84
60b974cfc58382e94af7de68abed22e249801139
/ABC/ABC121/ABC121A.cpp
0fe611a613d443a5212f2e3ed9a8b3b749275e06
[]
no_license
Masahiro-Obuchi/Atcoder
dc9dcbc6cf80a24f1f4b93b53b55f5b7250d98af
b0f07eddef7dd634d49f754ca653d1f7537a0555
refs/heads/master
2022-03-10T17:57:02.771330
2022-03-02T15:04:30
2022-03-02T15:04:30
182,256,969
0
1
null
2020-07-02T09:34:32
2019-04-19T11:49:46
C++
UTF-8
C++
false
false
255
cpp
#include <bits/stdc++.h> using namespace std; const long long MOD = 1000000007; const long long INF = 1LL << 60; int main() { int H, W; cin >> H >> W; int h, w; cin >> h >> w; int ans = (H - h) * (W - w); cout << ans << endl; }
[ "o.masahiro0328@gmail.com" ]
o.masahiro0328@gmail.com
5ea982c1823d0734b493f42c38be0d0f58797067
ba4c8a718594f43fb2c5a2ec11c066274ec70445
/openCV/sources/modules/ts/src/ts_gtest.cpp
1ed19e803f12abb4c2776112bccb4f97c66fa62c
[ "BSD-3-Clause" ]
permissive
jayparekhjp/openCV-Facial-Recognition
d7d83e1cd93a878d91e129dd5f754a50fde973a2
c351d55863bbc40c3225f55152dcd044f778119f
refs/heads/master
2020-04-02T03:18:43.346991
2018-10-20T23:45:42
2018-10-20T23:45:42
153,957,654
0
1
null
null
null
null
UTF-8
C++
false
false
365,795
cpp
// Copyright 2008, Google Inc. // 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. // * Neither the name of Google Inc. nor the names of its // contributors may be used to endorse or promote products derived from // this software without specific prior written permission. // // 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 // OWNER 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. // // Author: mheule@google.com (Markus Heule) // // Google C++ Testing Framework (Google Test) // // Sometimes it's desirable to build Google Test by compiling a single file. // This file serves this purpose. // This line ensures that gtest.h can be compiled on its own, even // when it's fused. #include "precomp.hpp" #ifdef __GNUC__ # pragma GCC diagnostic ignored "-Wmissing-declarations" # pragma GCC diagnostic ignored "-Wmissing-field-initializers" #endif // The following lines pull in the real gtest *.cc files. // Copyright 2005, Google Inc. // 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. // * Neither the name of Google Inc. nor the names of its // contributors may be used to endorse or promote products derived from // this software without specific prior written permission. // // 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 // OWNER 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. // // Author: wan@google.com (Zhanyong Wan) // // The Google C++ Testing Framework (Google Test) // Copyright 2007, Google Inc. // 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. // * Neither the name of Google Inc. nor the names of its // contributors may be used to endorse or promote products derived from // this software without specific prior written permission. // // 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 // OWNER 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. // // Author: wan@google.com (Zhanyong Wan) // // Utilities for testing Google Test itself and code that uses Google Test // (e.g. frameworks built on top of Google Test). #ifndef GTEST_INCLUDE_GTEST_GTEST_SPI_H_ #define GTEST_INCLUDE_GTEST_GTEST_SPI_H_ namespace testing { // This helper class can be used to mock out Google Test failure reporting // so that we can test Google Test or code that builds on Google Test. // // An object of this class appends a TestPartResult object to the // TestPartResultArray object given in the constructor whenever a Google Test // failure is reported. It can either intercept only failures that are // generated in the same thread that created this object or it can intercept // all generated failures. The scope of this mock object can be controlled with // the second argument to the two arguments constructor. class GTEST_API_ ScopedFakeTestPartResultReporter : public TestPartResultReporterInterface { public: // The two possible mocking modes of this object. enum InterceptMode { INTERCEPT_ONLY_CURRENT_THREAD, // Intercepts only thread local failures. INTERCEPT_ALL_THREADS // Intercepts all failures. }; // The c'tor sets this object as the test part result reporter used // by Google Test. The 'result' parameter specifies where to report the // results. This reporter will only catch failures generated in the current // thread. DEPRECATED explicit ScopedFakeTestPartResultReporter(TestPartResultArray* result); // Same as above, but you can choose the interception scope of this object. ScopedFakeTestPartResultReporter(InterceptMode intercept_mode, TestPartResultArray* result); // The d'tor restores the previous test part result reporter. virtual ~ScopedFakeTestPartResultReporter(); // Appends the TestPartResult object to the TestPartResultArray // received in the constructor. // // This method is from the TestPartResultReporterInterface // interface. virtual void ReportTestPartResult(const TestPartResult& result); private: void Init(); const InterceptMode intercept_mode_; TestPartResultReporterInterface* old_reporter_; TestPartResultArray* const result_; GTEST_DISALLOW_COPY_AND_ASSIGN_(ScopedFakeTestPartResultReporter); }; namespace internal { // A helper class for implementing EXPECT_FATAL_FAILURE() and // EXPECT_NONFATAL_FAILURE(). Its destructor verifies that the given // TestPartResultArray contains exactly one failure that has the given // type and contains the given substring. If that's not the case, a // non-fatal failure will be generated. class GTEST_API_ SingleFailureChecker { public: // The constructor remembers the arguments. SingleFailureChecker(const TestPartResultArray* results, TestPartResult::Type type, const string& substr); ~SingleFailureChecker(); private: const TestPartResultArray* const results_; const TestPartResult::Type type_; const string substr_; GTEST_DISALLOW_COPY_AND_ASSIGN_(SingleFailureChecker); }; } // namespace internal } // namespace testing // A set of macros for testing Google Test assertions or code that's expected // to generate Google Test fatal failures. It verifies that the given // statement will cause exactly one fatal Google Test failure with 'substr' // being part of the failure message. // // There are two different versions of this macro. EXPECT_FATAL_FAILURE only // affects and considers failures generated in the current thread and // EXPECT_FATAL_FAILURE_ON_ALL_THREADS does the same but for all threads. // // The verification of the assertion is done correctly even when the statement // throws an exception or aborts the current function. // // Known restrictions: // - 'statement' cannot reference local non-static variables or // non-static members of the current object. // - 'statement' cannot return a value. // - You cannot stream a failure message to this macro. // // Note that even though the implementations of the following two // macros are much alike, we cannot refactor them to use a common // helper macro, due to some peculiarity in how the preprocessor // works. The AcceptsMacroThatExpandsToUnprotectedComma test in // gtest_unittest.cc will fail to compile if we do that. #define EXPECT_FATAL_FAILURE(statement, substr) \ do { \ class GTestExpectFatalFailureHelper {\ public:\ static void Execute() { statement; }\ };\ ::testing::TestPartResultArray gtest_failures;\ ::testing::internal::SingleFailureChecker gtest_checker(\ &gtest_failures, ::testing::TestPartResult::kFatalFailure, (substr));\ {\ ::testing::ScopedFakeTestPartResultReporter gtest_reporter(\ ::testing::ScopedFakeTestPartResultReporter:: \ INTERCEPT_ONLY_CURRENT_THREAD, &gtest_failures);\ GTestExpectFatalFailureHelper::Execute();\ }\ } while (::testing::internal::AlwaysFalse()) #define EXPECT_FATAL_FAILURE_ON_ALL_THREADS(statement, substr) \ do { \ class GTestExpectFatalFailureHelper {\ public:\ static void Execute() { statement; }\ };\ ::testing::TestPartResultArray gtest_failures;\ ::testing::internal::SingleFailureChecker gtest_checker(\ &gtest_failures, ::testing::TestPartResult::kFatalFailure, (substr));\ {\ ::testing::ScopedFakeTestPartResultReporter gtest_reporter(\ ::testing::ScopedFakeTestPartResultReporter:: \ INTERCEPT_ALL_THREADS, &gtest_failures);\ GTestExpectFatalFailureHelper::Execute();\ }\ } while (::testing::internal::AlwaysFalse()) // A macro for testing Google Test assertions or code that's expected to // generate Google Test non-fatal failures. It asserts that the given // statement will cause exactly one non-fatal Google Test failure with 'substr' // being part of the failure message. // // There are two different versions of this macro. EXPECT_NONFATAL_FAILURE only // affects and considers failures generated in the current thread and // EXPECT_NONFATAL_FAILURE_ON_ALL_THREADS does the same but for all threads. // // 'statement' is allowed to reference local variables and members of // the current object. // // The verification of the assertion is done correctly even when the statement // throws an exception or aborts the current function. // // Known restrictions: // - You cannot stream a failure message to this macro. // // Note that even though the implementations of the following two // macros are much alike, we cannot refactor them to use a common // helper macro, due to some peculiarity in how the preprocessor // works. If we do that, the code won't compile when the user gives // EXPECT_NONFATAL_FAILURE() a statement that contains a macro that // expands to code containing an unprotected comma. The // AcceptsMacroThatExpandsToUnprotectedComma test in gtest_unittest.cc // catches that. // // For the same reason, we have to write // if (::testing::internal::AlwaysTrue()) { statement; } // instead of // GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement) // to avoid an MSVC warning on unreachable code. #define EXPECT_NONFATAL_FAILURE(statement, substr) \ do {\ ::testing::TestPartResultArray gtest_failures;\ ::testing::internal::SingleFailureChecker gtest_checker(\ &gtest_failures, ::testing::TestPartResult::kNonFatalFailure, \ (substr));\ {\ ::testing::ScopedFakeTestPartResultReporter gtest_reporter(\ ::testing::ScopedFakeTestPartResultReporter:: \ INTERCEPT_ONLY_CURRENT_THREAD, &gtest_failures);\ if (::testing::internal::AlwaysTrue()) { statement; }\ }\ } while (::testing::internal::AlwaysFalse()) #define EXPECT_NONFATAL_FAILURE_ON_ALL_THREADS(statement, substr) \ do {\ ::testing::TestPartResultArray gtest_failures;\ ::testing::internal::SingleFailureChecker gtest_checker(\ &gtest_failures, ::testing::TestPartResult::kNonFatalFailure, \ (substr));\ {\ ::testing::ScopedFakeTestPartResultReporter gtest_reporter(\ ::testing::ScopedFakeTestPartResultReporter::INTERCEPT_ALL_THREADS, \ &gtest_failures);\ if (::testing::internal::AlwaysTrue()) { statement; }\ }\ } while (::testing::internal::AlwaysFalse()) #endif // GTEST_INCLUDE_GTEST_GTEST_SPI_H_ #include <ctype.h> #include <math.h> #include <stdarg.h> #include <stdio.h> #include <stdlib.h> #include <time.h> #include <wchar.h> #include <wctype.h> #include <algorithm> #include <iomanip> #include <limits> #include <ostream> // NOLINT #include <sstream> #include <vector> #if GTEST_OS_LINUX // TODO(kenton@google.com): Use autoconf to detect availability of // gettimeofday(). # define GTEST_HAS_GETTIMEOFDAY_ 1 # include <fcntl.h> // NOLINT # include <limits.h> // NOLINT # include <sched.h> // NOLINT // Declares vsnprintf(). This header is not available on Windows. # include <strings.h> // NOLINT # include <sys/mman.h> // NOLINT # include <sys/time.h> // NOLINT # include <unistd.h> // NOLINT # include <string> #elif GTEST_OS_SYMBIAN # define GTEST_HAS_GETTIMEOFDAY_ 1 # include <sys/time.h> // NOLINT #elif GTEST_OS_ZOS # define GTEST_HAS_GETTIMEOFDAY_ 1 # include <sys/time.h> // NOLINT // On z/OS we additionally need strings.h for strcasecmp. # include <strings.h> // NOLINT #elif GTEST_OS_WINDOWS_MOBILE // We are on Windows CE. # include <windows.h> // NOLINT #elif GTEST_OS_WINDOWS // We are on Windows proper. # include <io.h> // NOLINT # include <sys/timeb.h> // NOLINT # include <sys/types.h> // NOLINT # include <sys/stat.h> // NOLINT # if GTEST_OS_WINDOWS_MINGW // MinGW has gettimeofday() but not _ftime64(). // TODO(kenton@google.com): Use autoconf to detect availability of // gettimeofday(). // TODO(kenton@google.com): There are other ways to get the time on // Windows, like GetTickCount() or GetSystemTimeAsFileTime(). MinGW // supports these. consider using them instead. # define GTEST_HAS_GETTIMEOFDAY_ 1 # include <sys/time.h> // NOLINT # endif // GTEST_OS_WINDOWS_MINGW // cpplint thinks that the header is already included, so we want to // silence it. # include <windows.h> // NOLINT #else // Assume other platforms have gettimeofday(). // TODO(kenton@google.com): Use autoconf to detect availability of // gettimeofday(). # define GTEST_HAS_GETTIMEOFDAY_ 1 // cpplint thinks that the header is already included, so we want to // silence it. # include <sys/time.h> // NOLINT # include <unistd.h> // NOLINT #endif // GTEST_OS_LINUX #if GTEST_HAS_EXCEPTIONS # include <stdexcept> #endif #if GTEST_CAN_STREAM_RESULTS_ # include <arpa/inet.h> // NOLINT # include <netdb.h> // NOLINT #endif // Indicates that this translation unit is part of Google Test's // implementation. It must come before gtest-internal-inl.h is // included, or there will be a compiler error. This trick is to // prevent a user from accidentally including gtest-internal-inl.h in // his code. #define GTEST_IMPLEMENTATION_ 1 // Copyright 2005, Google Inc. // 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. // * Neither the name of Google Inc. nor the names of its // contributors may be used to endorse or promote products derived from // this software without specific prior written permission. // // 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 // OWNER 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. // Utility functions and classes used by the Google C++ testing framework. // // Author: wan@google.com (Zhanyong Wan) // // This file contains purely Google Test's internal implementation. Please // DO NOT #INCLUDE IT IN A USER PROGRAM. #ifndef GTEST_SRC_GTEST_INTERNAL_INL_H_ #define GTEST_SRC_GTEST_INTERNAL_INL_H_ // GTEST_IMPLEMENTATION_ is defined to 1 iff the current translation unit is // part of Google Test's implementation; otherwise it's undefined. #if !GTEST_IMPLEMENTATION_ // A user is trying to include this from his code - just say no. # error "gtest-internal-inl.h is part of Google Test's internal implementation." # error "It must not be included except by Google Test itself." #endif // GTEST_IMPLEMENTATION_ #ifndef _WIN32_WCE # include <errno.h> #endif // !_WIN32_WCE #include <stddef.h> #include <stdlib.h> // For strtoll/_strtoul64/malloc/free. #include <string.h> // For memmove. #include <algorithm> #include <string> #include <vector> #if GTEST_CAN_STREAM_RESULTS_ # include <arpa/inet.h> // NOLINT # include <netdb.h> // NOLINT #endif #if GTEST_OS_WINDOWS # include <windows.h> // NOLINT #endif // GTEST_OS_WINDOWS namespace testing { // Declares the flags. // // We don't want the users to modify this flag in the code, but want // Google Test's own unit tests to be able to access it. Therefore we // declare it here as opposed to in gtest.h. GTEST_DECLARE_bool_(death_test_use_fork); namespace internal { // The value of GetTestTypeId() as seen from within the Google Test // library. This is solely for testing GetTestTypeId(). GTEST_API_ extern const TypeId kTestTypeIdInGoogleTest; // Names of the flags (needed for parsing Google Test flags). const char kAlsoRunDisabledTestsFlag[] = "also_run_disabled_tests"; const char kBreakOnFailureFlag[] = "break_on_failure"; const char kCatchExceptionsFlag[] = "catch_exceptions"; const char kColorFlag[] = "color"; const char kFilterFlag[] = "filter"; const char kParamFilterFlag[] = "param_filter"; const char kListTestsFlag[] = "list_tests"; const char kOutputFlag[] = "output"; const char kPrintTimeFlag[] = "print_time"; const char kRandomSeedFlag[] = "random_seed"; const char kRepeatFlag[] = "repeat"; const char kShuffleFlag[] = "shuffle"; const char kStackTraceDepthFlag[] = "stack_trace_depth"; const char kStreamResultToFlag[] = "stream_result_to"; const char kThrowOnFailureFlag[] = "throw_on_failure"; // A valid random seed must be in [1, kMaxRandomSeed]. const int kMaxRandomSeed = 99999; // g_help_flag is true iff the --help flag or an equivalent form is // specified on the command line. GTEST_API_ extern bool g_help_flag; // Returns the current time in milliseconds. GTEST_API_ TimeInMillis GetTimeInMillis(); // Returns true iff Google Test should use colors in the output. GTEST_API_ bool ShouldUseColor(bool stdout_is_tty); // Formats the given time in milliseconds as seconds. GTEST_API_ std::string FormatTimeInMillisAsSeconds(TimeInMillis ms); // Converts the given time in milliseconds to a date string in the ISO 8601 // format, without the timezone information. N.B.: due to the use the // non-reentrant localtime() function, this function is not thread safe. Do // not use it in any code that can be called from multiple threads. GTEST_API_ std::string FormatEpochTimeInMillisAsIso8601(TimeInMillis ms); // Parses a string for an Int32 flag, in the form of "--flag=value". // // On success, stores the value of the flag in *value, and returns // true. On failure, returns false without changing *value. GTEST_API_ bool ParseInt32Flag( const char* str, const char* flag, Int32* value); // Returns a random seed in range [1, kMaxRandomSeed] based on the // given --gtest_random_seed flag value. inline int GetRandomSeedFromFlag(Int32 random_seed_flag) { const unsigned int raw_seed = (random_seed_flag == 0) ? static_cast<unsigned int>(GetTimeInMillis()) : static_cast<unsigned int>(random_seed_flag); // Normalizes the actual seed to range [1, kMaxRandomSeed] such that // it's easy to type. const int normalized_seed = static_cast<int>((raw_seed - 1U) % static_cast<unsigned int>(kMaxRandomSeed)) + 1; return normalized_seed; } // Returns the first valid random seed after 'seed'. The behavior is // undefined if 'seed' is invalid. The seed after kMaxRandomSeed is // considered to be 1. inline int GetNextRandomSeed(int seed) { GTEST_CHECK_(1 <= seed && seed <= kMaxRandomSeed) << "Invalid random seed " << seed << " - must be in [1, " << kMaxRandomSeed << "]."; const int next_seed = seed + 1; return (next_seed > kMaxRandomSeed) ? 1 : next_seed; } // This class saves the values of all Google Test flags in its c'tor, and // restores them in its d'tor. class GTestFlagSaver { public: // The c'tor. GTestFlagSaver() { also_run_disabled_tests_ = GTEST_FLAG(also_run_disabled_tests); break_on_failure_ = GTEST_FLAG(break_on_failure); catch_exceptions_ = GTEST_FLAG(catch_exceptions); color_ = GTEST_FLAG(color); death_test_style_ = GTEST_FLAG(death_test_style); death_test_use_fork_ = GTEST_FLAG(death_test_use_fork); filter_ = GTEST_FLAG(filter); param_filter_ = GTEST_FLAG(param_filter); internal_run_death_test_ = GTEST_FLAG(internal_run_death_test); list_tests_ = GTEST_FLAG(list_tests); output_ = GTEST_FLAG(output); print_time_ = GTEST_FLAG(print_time); random_seed_ = GTEST_FLAG(random_seed); repeat_ = GTEST_FLAG(repeat); shuffle_ = GTEST_FLAG(shuffle); stack_trace_depth_ = GTEST_FLAG(stack_trace_depth); stream_result_to_ = GTEST_FLAG(stream_result_to); throw_on_failure_ = GTEST_FLAG(throw_on_failure); } // The d'tor is not virtual. DO NOT INHERIT FROM THIS CLASS. ~GTestFlagSaver() { GTEST_FLAG(also_run_disabled_tests) = also_run_disabled_tests_; GTEST_FLAG(break_on_failure) = break_on_failure_; GTEST_FLAG(catch_exceptions) = catch_exceptions_; GTEST_FLAG(color) = color_; GTEST_FLAG(death_test_style) = death_test_style_; GTEST_FLAG(death_test_use_fork) = death_test_use_fork_; GTEST_FLAG(filter) = filter_; GTEST_FLAG(param_filter) = param_filter_; GTEST_FLAG(internal_run_death_test) = internal_run_death_test_; GTEST_FLAG(list_tests) = list_tests_; GTEST_FLAG(output) = output_; GTEST_FLAG(print_time) = print_time_; GTEST_FLAG(random_seed) = random_seed_; GTEST_FLAG(repeat) = repeat_; GTEST_FLAG(shuffle) = shuffle_; GTEST_FLAG(stack_trace_depth) = stack_trace_depth_; GTEST_FLAG(stream_result_to) = stream_result_to_; GTEST_FLAG(throw_on_failure) = throw_on_failure_; } private: // Fields for saving the original values of flags. bool also_run_disabled_tests_; bool break_on_failure_; bool catch_exceptions_; std::string color_; std::string death_test_style_; bool death_test_use_fork_; std::string filter_; std::string param_filter_; std::string internal_run_death_test_; bool list_tests_; std::string output_; bool print_time_; internal::Int32 random_seed_; internal::Int32 repeat_; bool shuffle_; internal::Int32 stack_trace_depth_; std::string stream_result_to_; bool throw_on_failure_; } GTEST_ATTRIBUTE_UNUSED_; // Converts a Unicode code point to a narrow string in UTF-8 encoding. // code_point parameter is of type UInt32 because wchar_t may not be // wide enough to contain a code point. // If the code_point is not a valid Unicode code point // (i.e. outside of Unicode range U+0 to U+10FFFF) it will be converted // to "(Invalid Unicode 0xXXXXXXXX)". GTEST_API_ std::string CodePointToUtf8(UInt32 code_point); // Converts a wide string to a narrow string in UTF-8 encoding. // The wide string is assumed to have the following encoding: // UTF-16 if sizeof(wchar_t) == 2 (on Windows, Cygwin, Symbian OS) // UTF-32 if sizeof(wchar_t) == 4 (on Linux) // Parameter str points to a null-terminated wide string. // Parameter num_chars may additionally limit the number // of wchar_t characters processed. -1 is used when the entire string // should be processed. // If the string contains code points that are not valid Unicode code points // (i.e. outside of Unicode range U+0 to U+10FFFF) they will be output // as '(Invalid Unicode 0xXXXXXXXX)'. If the string is in UTF16 encoding // and contains invalid UTF-16 surrogate pairs, values in those pairs // will be encoded as individual Unicode characters from Basic Normal Plane. GTEST_API_ std::string WideStringToUtf8(const wchar_t* str, int num_chars); // Reads the GTEST_SHARD_STATUS_FILE environment variable, and creates the file // if the variable is present. If a file already exists at this location, this // function will write over it. If the variable is present, but the file cannot // be created, prints an error and exits. void WriteToShardStatusFileIfNeeded(); // Checks whether sharding is enabled by examining the relevant // environment variable values. If the variables are present, // but inconsistent (e.g., shard_index >= total_shards), prints // an error and exits. If in_subprocess_for_death_test, sharding is // disabled because it must only be applied to the original test // process. Otherwise, we could filter out death tests we intended to execute. GTEST_API_ bool ShouldShard(const char* total_shards_str, const char* shard_index_str, bool in_subprocess_for_death_test); // Parses the environment variable var as an Int32. If it is unset, // returns default_val. If it is not an Int32, prints an error and // and aborts. GTEST_API_ Int32 Int32FromEnvOrDie(const char* env_var, Int32 default_val); // Given the total number of shards, the shard index, and the test id, // returns true iff the test should be run on this shard. The test id is // some arbitrary but unique non-negative integer assigned to each test // method. Assumes that 0 <= shard_index < total_shards. GTEST_API_ bool ShouldRunTestOnShard( int total_shards, int shard_index, int test_id); // STL container utilities. // Returns the number of elements in the given container that satisfy // the given predicate. template <class Container, typename Predicate> inline int CountIf(const Container& c, Predicate predicate) { // Implemented as an explicit loop since std::count_if() in libCstd on // Solaris has a non-standard signature. int count = 0; for (typename Container::const_iterator it = c.begin(); it != c.end(); ++it) { if (predicate(*it)) ++count; } return count; } // Applies a function/functor to each element in the container. template <class Container, typename Functor> void ForEach(const Container& c, Functor functor) { std::for_each(c.begin(), c.end(), functor); } // Returns the i-th element of the vector, or default_value if i is not // in range [0, v.size()). template <typename E> inline E GetElementOr(const std::vector<E>& v, int i, E default_value) { return (i < 0 || i >= static_cast<int>(v.size())) ? default_value : v[i]; } // Performs an in-place shuffle of a range of the vector's elements. // 'begin' and 'end' are element indices as an STL-style range; // i.e. [begin, end) are shuffled, where 'end' == size() means to // shuffle to the end of the vector. template <typename E> void ShuffleRange(internal::Random* random, int begin, int end, std::vector<E>* v) { const int size = static_cast<int>(v->size()); GTEST_CHECK_(0 <= begin && begin <= size) << "Invalid shuffle range start " << begin << ": must be in range [0, " << size << "]."; GTEST_CHECK_(begin <= end && end <= size) << "Invalid shuffle range finish " << end << ": must be in range [" << begin << ", " << size << "]."; // Fisher-Yates shuffle, from // http://en.wikipedia.org/wiki/Fisher-Yates_shuffle for (int range_width = end - begin; range_width >= 2; range_width--) { const int last_in_range = begin + range_width - 1; const int selected = begin + random->Generate(range_width); std::swap((*v)[selected], (*v)[last_in_range]); } } // Performs an in-place shuffle of the vector's elements. template <typename E> inline void Shuffle(internal::Random* random, std::vector<E>* v) { ShuffleRange(random, 0, static_cast<int>(v->size()), v); } // A function for deleting an object. Handy for being used as a // functor. template <typename T> static void Delete(T* x) { delete x; } // A predicate that checks the key of a TestProperty against a known key. // // TestPropertyKeyIs is copyable. class TestPropertyKeyIs { public: // Constructor. // // TestPropertyKeyIs has NO default constructor. explicit TestPropertyKeyIs(const std::string& key) : key_(key) {} // Returns true iff the test name of test property matches on key_. bool operator()(const TestProperty& test_property) const { return test_property.key() == key_; } private: std::string key_; }; // Class UnitTestOptions. // // This class contains functions for processing options the user // specifies when running the tests. It has only static members. // // In most cases, the user can specify an option using either an // environment variable or a command line flag. E.g. you can set the // test filter using either GTEST_FILTER or --gtest_filter. If both // the variable and the flag are present, the latter overrides the // former. class GTEST_API_ UnitTestOptions { public: // Functions for processing the gtest_output flag. // Returns the output format, or "" for normal printed output. static std::string GetOutputFormat(); // Returns the absolute path of the requested output file, or the // default (test_detail.xml in the original working directory) if // none was explicitly specified. static std::string GetAbsolutePathToOutputFile(); // Functions for processing the gtest_filter flag. // Returns true iff the wildcard pattern matches the string. The // first ':' or '\0' character in pattern marks the end of it. // // This recursive algorithm isn't very efficient, but is clear and // works well enough for matching test names, which are short. static bool PatternMatchesString(const char *pattern, const char *str); // Returns true iff the user-specified filter matches the test case // name and the test name. static bool FilterMatchesTest(const std::string &test_case_name, const std::string &test_name); #if GTEST_OS_WINDOWS // Function for supporting the gtest_catch_exception flag. // Returns EXCEPTION_EXECUTE_HANDLER if Google Test should handle the // given SEH exception, or EXCEPTION_CONTINUE_SEARCH otherwise. // This function is useful as an __except condition. static int GTestShouldProcessSEH(DWORD exception_code); #endif // GTEST_OS_WINDOWS // Returns true if "name" matches the ':' separated list of glob-style // filters in "filter". static bool MatchesFilter(const std::string& name, const char* filter); }; // Returns the current application's name, removing directory path if that // is present. Used by UnitTestOptions::GetOutputFile. GTEST_API_ FilePath GetCurrentExecutableName(); // The role interface for getting the OS stack trace as a string. class OsStackTraceGetterInterface { public: OsStackTraceGetterInterface() {} virtual ~OsStackTraceGetterInterface() {} // Returns the current OS stack trace as an std::string. Parameters: // // max_depth - the maximum number of stack frames to be included // in the trace. // skip_count - the number of top frames to be skipped; doesn't count // against max_depth. virtual string CurrentStackTrace(int max_depth, int skip_count) = 0; // UponLeavingGTest() should be called immediately before Google Test calls // user code. It saves some information about the current stack that // CurrentStackTrace() will use to find and hide Google Test stack frames. virtual void UponLeavingGTest() = 0; private: GTEST_DISALLOW_COPY_AND_ASSIGN_(OsStackTraceGetterInterface); }; // A working implementation of the OsStackTraceGetterInterface interface. class OsStackTraceGetter : public OsStackTraceGetterInterface { public: OsStackTraceGetter() : caller_frame_(NULL) {} virtual string CurrentStackTrace(int max_depth, int skip_count) GTEST_LOCK_EXCLUDED_(mutex_); virtual void UponLeavingGTest() GTEST_LOCK_EXCLUDED_(mutex_); // This string is inserted in place of stack frames that are part of // Google Test's implementation. static const char* const kElidedFramesMarker; private: Mutex mutex_; // protects all internal state // We save the stack frame below the frame that calls user code. // We do this because the address of the frame immediately below // the user code changes between the call to UponLeavingGTest() // and any calls to CurrentStackTrace() from within the user code. void* caller_frame_; GTEST_DISALLOW_COPY_AND_ASSIGN_(OsStackTraceGetter); }; // Information about a Google Test trace point. struct TraceInfo { const char* file; int line; std::string message; }; // This is the default global test part result reporter used in UnitTestImpl. // This class should only be used by UnitTestImpl. class DefaultGlobalTestPartResultReporter : public TestPartResultReporterInterface { public: explicit DefaultGlobalTestPartResultReporter(UnitTestImpl* unit_test); // Implements the TestPartResultReporterInterface. Reports the test part // result in the current test. virtual void ReportTestPartResult(const TestPartResult& result); private: UnitTestImpl* const unit_test_; GTEST_DISALLOW_COPY_AND_ASSIGN_(DefaultGlobalTestPartResultReporter); }; // This is the default per thread test part result reporter used in // UnitTestImpl. This class should only be used by UnitTestImpl. class DefaultPerThreadTestPartResultReporter : public TestPartResultReporterInterface { public: explicit DefaultPerThreadTestPartResultReporter(UnitTestImpl* unit_test); // Implements the TestPartResultReporterInterface. The implementation just // delegates to the current global test part result reporter of *unit_test_. virtual void ReportTestPartResult(const TestPartResult& result); private: UnitTestImpl* const unit_test_; GTEST_DISALLOW_COPY_AND_ASSIGN_(DefaultPerThreadTestPartResultReporter); }; // The private implementation of the UnitTest class. We don't protect // the methods under a mutex, as this class is not accessible by a // user and the UnitTest class that delegates work to this class does // proper locking. class GTEST_API_ UnitTestImpl { public: explicit UnitTestImpl(UnitTest* parent); virtual ~UnitTestImpl(); // There are two different ways to register your own TestPartResultReporter. // You can register your own repoter to listen either only for test results // from the current thread or for results from all threads. // By default, each per-thread test result repoter just passes a new // TestPartResult to the global test result reporter, which registers the // test part result for the currently running test. // Returns the global test part result reporter. TestPartResultReporterInterface* GetGlobalTestPartResultReporter(); // Sets the global test part result reporter. void SetGlobalTestPartResultReporter( TestPartResultReporterInterface* reporter); // Returns the test part result reporter for the current thread. TestPartResultReporterInterface* GetTestPartResultReporterForCurrentThread(); // Sets the test part result reporter for the current thread. void SetTestPartResultReporterForCurrentThread( TestPartResultReporterInterface* reporter); // Gets the number of successful test cases. int successful_test_case_count() const; // Gets the number of failed test cases. int failed_test_case_count() const; // Gets the number of all test cases. int total_test_case_count() const; // Gets the number of all test cases that contain at least one test // that should run. int test_case_to_run_count() const; // Gets the number of successful tests. int successful_test_count() const; // Gets the number of failed tests. int failed_test_count() const; // Gets the number of disabled tests that will be reported in the XML report. int reportable_disabled_test_count() const; // Gets the number of disabled tests. int disabled_test_count() const; // Gets the number of tests to be printed in the XML report. int reportable_test_count() const; // Gets the number of all tests. int total_test_count() const; // Gets the number of tests that should run. int test_to_run_count() const; // Gets the time of the test program start, in ms from the start of the // UNIX epoch. TimeInMillis start_timestamp() const { return start_timestamp_; } // Gets the elapsed time, in milliseconds. TimeInMillis elapsed_time() const { return elapsed_time_; } // Returns true iff the unit test passed (i.e. all test cases passed). bool Passed() const { return !Failed(); } // Returns true iff the unit test failed (i.e. some test case failed // or something outside of all tests failed). bool Failed() const { return failed_test_case_count() > 0 || ad_hoc_test_result()->Failed(); } // Gets the i-th test case among all the test cases. i can range from 0 to // total_test_case_count() - 1. If i is not in that range, returns NULL. const TestCase* GetTestCase(int i) const { const int index = GetElementOr(test_case_indices_, i, -1); return index < 0 ? NULL : test_cases_[i]; } // Gets the i-th test case among all the test cases. i can range from 0 to // total_test_case_count() - 1. If i is not in that range, returns NULL. TestCase* GetMutableTestCase(int i) { const int index = GetElementOr(test_case_indices_, i, -1); return index < 0 ? NULL : test_cases_[index]; } // Provides access to the event listener list. TestEventListeners* listeners() { return &listeners_; } // Returns the TestResult for the test that's currently running, or // the TestResult for the ad hoc test if no test is running. TestResult* current_test_result(); // Returns the TestResult for the ad hoc test. const TestResult* ad_hoc_test_result() const { return &ad_hoc_test_result_; } // Sets the OS stack trace getter. // // Does nothing if the input and the current OS stack trace getter // are the same; otherwise, deletes the old getter and makes the // input the current getter. void set_os_stack_trace_getter(OsStackTraceGetterInterface* getter); // Returns the current OS stack trace getter if it is not NULL; // otherwise, creates an OsStackTraceGetter, makes it the current // getter, and returns it. OsStackTraceGetterInterface* os_stack_trace_getter(); // Returns the current OS stack trace as an std::string. // // The maximum number of stack frames to be included is specified by // the gtest_stack_trace_depth flag. The skip_count parameter // specifies the number of top frames to be skipped, which doesn't // count against the number of frames to be included. // // For example, if Foo() calls Bar(), which in turn calls // CurrentOsStackTraceExceptTop(1), Foo() will be included in the // trace but Bar() and CurrentOsStackTraceExceptTop() won't. std::string CurrentOsStackTraceExceptTop(int skip_count) GTEST_NO_INLINE_; // Finds and returns a TestCase with the given name. If one doesn't // exist, creates one and returns it. // // Arguments: // // test_case_name: name of the test case // type_param: the name of the test's type parameter, or NULL if // this is not a typed or a type-parameterized test. // set_up_tc: pointer to the function that sets up the test case // tear_down_tc: pointer to the function that tears down the test case TestCase* GetTestCase(const char* test_case_name, const char* type_param, Test::SetUpTestCaseFunc set_up_tc, Test::TearDownTestCaseFunc tear_down_tc); // Adds a TestInfo to the unit test. // // Arguments: // // set_up_tc: pointer to the function that sets up the test case // tear_down_tc: pointer to the function that tears down the test case // test_info: the TestInfo object void AddTestInfo(Test::SetUpTestCaseFunc set_up_tc, Test::TearDownTestCaseFunc tear_down_tc, TestInfo* test_info) { // In order to support thread-safe death tests, we need to // remember the original working directory when the test program // was first invoked. We cannot do this in RUN_ALL_TESTS(), as // the user may have changed the current directory before calling // RUN_ALL_TESTS(). Therefore we capture the current directory in // AddTestInfo(), which is called to register a TEST or TEST_F // before main() is reached. if (original_working_dir_.IsEmpty()) { original_working_dir_.Set(FilePath::GetCurrentDir()); GTEST_CHECK_(!original_working_dir_.IsEmpty()) << "Failed to get the current working directory."; } GetTestCase(test_info->test_case_name(), test_info->type_param(), set_up_tc, tear_down_tc)->AddTestInfo(test_info); } #if GTEST_HAS_PARAM_TEST // Returns ParameterizedTestCaseRegistry object used to keep track of // value-parameterized tests and instantiate and register them. internal::ParameterizedTestCaseRegistry& parameterized_test_registry() { return parameterized_test_registry_; } #endif // GTEST_HAS_PARAM_TEST // Sets the TestCase object for the test that's currently running. void set_current_test_case(TestCase* a_current_test_case) { current_test_case_ = a_current_test_case; } // Sets the TestInfo object for the test that's currently running. If // current_test_info is NULL, the assertion results will be stored in // ad_hoc_test_result_. void set_current_test_info(TestInfo* a_current_test_info) { current_test_info_ = a_current_test_info; } // Registers all parameterized tests defined using TEST_P and // INSTANTIATE_TEST_CASE_P, creating regular tests for each test/parameter // combination. This method can be called more then once; it has guards // protecting from registering the tests more then once. If // value-parameterized tests are disabled, RegisterParameterizedTests is // present but does nothing. void RegisterParameterizedTests(); // Runs all tests in this UnitTest object, prints the result, and // returns true if all tests are successful. If any exception is // thrown during a test, this test is considered to be failed, but // the rest of the tests will still be run. bool RunAllTests(); // Clears the results of all tests, except the ad hoc tests. void ClearNonAdHocTestResult() { ForEach(test_cases_, TestCase::ClearTestCaseResult); } // Clears the results of ad-hoc test assertions. void ClearAdHocTestResult() { ad_hoc_test_result_.Clear(); } // Adds a TestProperty to the current TestResult object when invoked in a // context of a test or a test case, or to the global property set. If the // result already contains a property with the same key, the value will be // updated. void RecordProperty(const TestProperty& test_property); enum ReactionToSharding { HONOR_SHARDING_PROTOCOL, IGNORE_SHARDING_PROTOCOL }; // Matches the full name of each test against the user-specified // filter to decide whether the test should run, then records the // result in each TestCase and TestInfo object. // If shard_tests == HONOR_SHARDING_PROTOCOL, further filters tests // based on sharding variables in the environment. // Returns the number of tests that should run. int FilterTests(ReactionToSharding shard_tests); // Prints the names of the tests matching the user-specified filter flag. void ListTestsMatchingFilter(); const TestCase* current_test_case() const { return current_test_case_; } TestInfo* current_test_info() { return current_test_info_; } const TestInfo* current_test_info() const { return current_test_info_; } // Returns the vector of environments that need to be set-up/torn-down // before/after the tests are run. std::vector<Environment*>& environments() { return environments_; } // Getters for the per-thread Google Test trace stack. std::vector<TraceInfo>& gtest_trace_stack() { return *(gtest_trace_stack_.pointer()); } const std::vector<TraceInfo>& gtest_trace_stack() const { return gtest_trace_stack_.get(); } #if GTEST_HAS_DEATH_TEST void InitDeathTestSubprocessControlInfo() { internal_run_death_test_flag_.reset(ParseInternalRunDeathTestFlag()); } // Returns a pointer to the parsed --gtest_internal_run_death_test // flag, or NULL if that flag was not specified. // This information is useful only in a death test child process. // Must not be called before a call to InitGoogleTest. const InternalRunDeathTestFlag* internal_run_death_test_flag() const { return internal_run_death_test_flag_.get(); } // Returns a pointer to the current death test factory. internal::DeathTestFactory* death_test_factory() { return death_test_factory_.get(); } void SuppressTestEventsIfInSubprocess(); friend class ReplaceDeathTestFactory; #endif // GTEST_HAS_DEATH_TEST // Initializes the event listener performing XML output as specified by // UnitTestOptions. Must not be called before InitGoogleTest. void ConfigureXmlOutput(); #if GTEST_CAN_STREAM_RESULTS_ // Initializes the event listener for streaming test results to a socket. // Must not be called before InitGoogleTest. void ConfigureStreamingOutput(); #endif // Performs initialization dependent upon flag values obtained in // ParseGoogleTestFlagsOnly. Is called from InitGoogleTest after the call to // ParseGoogleTestFlagsOnly. In case a user neglects to call InitGoogleTest // this function is also called from RunAllTests. Since this function can be // called more than once, it has to be idempotent. void PostFlagParsingInit(); // Gets the random seed used at the start of the current test iteration. int random_seed() const { return random_seed_; } // Gets the random number generator. internal::Random* random() { return &random_; } // Shuffles all test cases, and the tests within each test case, // making sure that death tests are still run first. void ShuffleTests(); // Restores the test cases and tests to their order before the first shuffle. void UnshuffleTests(); // Returns the value of GTEST_FLAG(catch_exceptions) at the moment // UnitTest::Run() starts. bool catch_exceptions() const { return catch_exceptions_; } private: friend class ::testing::UnitTest; // Used by UnitTest::Run() to capture the state of // GTEST_FLAG(catch_exceptions) at the moment it starts. void set_catch_exceptions(bool value) { catch_exceptions_ = value; } // The UnitTest object that owns this implementation object. UnitTest* const parent_; // The working directory when the first TEST() or TEST_F() was // executed. internal::FilePath original_working_dir_; // The default test part result reporters. DefaultGlobalTestPartResultReporter default_global_test_part_result_reporter_; DefaultPerThreadTestPartResultReporter default_per_thread_test_part_result_reporter_; // Points to (but doesn't own) the global test part result reporter. TestPartResultReporterInterface* global_test_part_result_repoter_; // Protects read and write access to global_test_part_result_reporter_. internal::Mutex global_test_part_result_reporter_mutex_; // Points to (but doesn't own) the per-thread test part result reporter. internal::ThreadLocal<TestPartResultReporterInterface*> per_thread_test_part_result_reporter_; // The vector of environments that need to be set-up/torn-down // before/after the tests are run. std::vector<Environment*> environments_; // The vector of TestCases in their original order. It owns the // elements in the vector. std::vector<TestCase*> test_cases_; // Provides a level of indirection for the test case list to allow // easy shuffling and restoring the test case order. The i-th // element of this vector is the index of the i-th test case in the // shuffled order. std::vector<int> test_case_indices_; #if GTEST_HAS_PARAM_TEST // ParameterizedTestRegistry object used to register value-parameterized // tests. internal::ParameterizedTestCaseRegistry parameterized_test_registry_; // Indicates whether RegisterParameterizedTests() has been called already. bool parameterized_tests_registered_; #endif // GTEST_HAS_PARAM_TEST // Index of the last death test case registered. Initially -1. int last_death_test_case_; // This points to the TestCase for the currently running test. It // changes as Google Test goes through one test case after another. // When no test is running, this is set to NULL and Google Test // stores assertion results in ad_hoc_test_result_. Initially NULL. TestCase* current_test_case_; // This points to the TestInfo for the currently running test. It // changes as Google Test goes through one test after another. When // no test is running, this is set to NULL and Google Test stores // assertion results in ad_hoc_test_result_. Initially NULL. TestInfo* current_test_info_; // Normally, a user only writes assertions inside a TEST or TEST_F, // or inside a function called by a TEST or TEST_F. Since Google // Test keeps track of which test is current running, it can // associate such an assertion with the test it belongs to. // // If an assertion is encountered when no TEST or TEST_F is running, // Google Test attributes the assertion result to an imaginary "ad hoc" // test, and records the result in ad_hoc_test_result_. TestResult ad_hoc_test_result_; // The list of event listeners that can be used to track events inside // Google Test. TestEventListeners listeners_; // The OS stack trace getter. Will be deleted when the UnitTest // object is destructed. By default, an OsStackTraceGetter is used, // but the user can set this field to use a custom getter if that is // desired. OsStackTraceGetterInterface* os_stack_trace_getter_; // True iff PostFlagParsingInit() has been called. bool post_flag_parse_init_performed_; // The random number seed used at the beginning of the test run. int random_seed_; // Our random number generator. internal::Random random_; // The time of the test program start, in ms from the start of the // UNIX epoch. TimeInMillis start_timestamp_; // How long the test took to run, in milliseconds. TimeInMillis elapsed_time_; #if GTEST_HAS_DEATH_TEST // The decomposed components of the gtest_internal_run_death_test flag, // parsed when RUN_ALL_TESTS is called. internal::scoped_ptr<InternalRunDeathTestFlag> internal_run_death_test_flag_; internal::scoped_ptr<internal::DeathTestFactory> death_test_factory_; #endif // GTEST_HAS_DEATH_TEST // A per-thread stack of traces created by the SCOPED_TRACE() macro. internal::ThreadLocal<std::vector<TraceInfo> > gtest_trace_stack_; // The value of GTEST_FLAG(catch_exceptions) at the moment RunAllTests() // starts. bool catch_exceptions_; GTEST_DISALLOW_COPY_AND_ASSIGN_(UnitTestImpl); }; // class UnitTestImpl // Convenience function for accessing the global UnitTest // implementation object. inline UnitTestImpl* GetUnitTestImpl() { return UnitTest::GetInstance()->impl(); } #if GTEST_USES_SIMPLE_RE // Internal helper functions for implementing the simple regular // expression matcher. GTEST_API_ bool IsInSet(char ch, const char* str); GTEST_API_ bool IsAsciiDigit(char ch); GTEST_API_ bool IsAsciiPunct(char ch); GTEST_API_ bool IsRepeat(char ch); GTEST_API_ bool IsAsciiWhiteSpace(char ch); GTEST_API_ bool IsAsciiWordChar(char ch); GTEST_API_ bool IsValidEscape(char ch); GTEST_API_ bool AtomMatchesChar(bool escaped, char pattern, char ch); GTEST_API_ std::string FormatRegexSyntaxError(const char* regex, int index); GTEST_API_ bool ValidateRegex(const char* regex); GTEST_API_ bool MatchRegexAtHead(const char* regex, const char* str); GTEST_API_ bool MatchRepetitionAndRegexAtHead( bool escaped, char ch, char repeat, const char* regex, const char* str); GTEST_API_ bool MatchRegexAnywhere(const char* regex, const char* str); #endif // GTEST_USES_SIMPLE_RE // Parses the command line for Google Test flags, without initializing // other parts of Google Test. GTEST_API_ void ParseGoogleTestFlagsOnly(int* argc, char** argv); GTEST_API_ void ParseGoogleTestFlagsOnly(int* argc, wchar_t** argv); #if GTEST_HAS_DEATH_TEST // Returns the message describing the last system error, regardless of the // platform. GTEST_API_ std::string GetLastErrnoDescription(); # if GTEST_OS_WINDOWS // Provides leak-safe Windows kernel handle ownership. class AutoHandle { public: AutoHandle() : handle_(INVALID_HANDLE_VALUE) {} explicit AutoHandle(HANDLE handle) : handle_(handle) {} ~AutoHandle() { Reset(); } HANDLE Get() const { return handle_; } void Reset() { Reset(INVALID_HANDLE_VALUE); } void Reset(HANDLE handle) { if (handle != handle_) { if (handle_ != INVALID_HANDLE_VALUE) ::CloseHandle(handle_); handle_ = handle; } } private: HANDLE handle_; GTEST_DISALLOW_COPY_AND_ASSIGN_(AutoHandle); }; # endif // GTEST_OS_WINDOWS // Attempts to parse a string into a positive integer pointed to by the // number parameter. Returns true if that is possible. // GTEST_HAS_DEATH_TEST implies that we have ::std::string, so we can use // it here. template <typename Integer> bool ParseNaturalNumber(const ::std::string& str, Integer* number) { // Fail fast if the given string does not begin with a digit; // this bypasses strtoXXX's "optional leading whitespace and plus // or minus sign" semantics, which are undesirable here. if (str.empty() || !IsDigit(str[0])) { return false; } errno = 0; char* end; // BiggestConvertible is the largest integer type that system-provided // string-to-number conversion routines can return. # if GTEST_OS_WINDOWS && !defined(__GNUC__) // MSVC and C++ Builder define __int64 instead of the standard long long. typedef unsigned __int64 BiggestConvertible; const BiggestConvertible parsed = _strtoui64(str.c_str(), &end, 10); # else typedef unsigned long long BiggestConvertible; // NOLINT const BiggestConvertible parsed = strtoull(str.c_str(), &end, 10); # endif // GTEST_OS_WINDOWS && !defined(__GNUC__) const bool parse_success = *end == '\0' && errno == 0; // TODO(vladl@google.com): Convert this to compile time assertion when it is // available. GTEST_CHECK_(sizeof(Integer) <= sizeof(parsed)); const Integer result = static_cast<Integer>(parsed); if (parse_success && static_cast<BiggestConvertible>(result) == parsed) { *number = result; return true; } return false; } #endif // GTEST_HAS_DEATH_TEST // TestResult contains some private methods that should be hidden from // Google Test user but are required for testing. This class allow our tests // to access them. // // This class is supplied only for the purpose of testing Google Test's own // constructs. Do not use it in user tests, either directly or indirectly. class TestResultAccessor { public: static void RecordProperty(TestResult* test_result, const std::string& xml_element, const TestProperty& property) { test_result->RecordProperty(xml_element, property); } static void ClearTestPartResults(TestResult* test_result) { test_result->ClearTestPartResults(); } static const std::vector<testing::TestPartResult>& test_part_results( const TestResult& test_result) { return test_result.test_part_results(); } }; #if GTEST_CAN_STREAM_RESULTS_ // Streams test results to the given port on the given host machine. class StreamingListener : public EmptyTestEventListener { public: // Abstract base class for writing strings to a socket. class AbstractSocketWriter { public: virtual ~AbstractSocketWriter() {} // Sends a string to the socket. virtual void Send(const string& message) = 0; // Closes the socket. virtual void CloseConnection() {} // Sends a string and a newline to the socket. void SendLn(const string& message) { Send(message + "\n"); } }; // Concrete class for actually writing strings to a socket. class SocketWriter : public AbstractSocketWriter { public: SocketWriter(const string& host, const string& port) : sockfd_(-1), host_name_(host), port_num_(port) { MakeConnection(); } virtual ~SocketWriter() { if (sockfd_ != -1) CloseConnection(); } // Sends a string to the socket. virtual void Send(const string& message) { GTEST_CHECK_(sockfd_ != -1) << "Send() can be called only when there is a connection."; const int len = static_cast<int>(message.length()); if (write(sockfd_, message.c_str(), len) != len) { GTEST_LOG_(WARNING) << "stream_result_to: failed to stream to " << host_name_ << ":" << port_num_; } } private: // Creates a client socket and connects to the server. void MakeConnection(); // Closes the socket. void CloseConnection() { GTEST_CHECK_(sockfd_ != -1) << "CloseConnection() can be called only when there is a connection."; close(sockfd_); sockfd_ = -1; } int sockfd_; // socket file descriptor const string host_name_; const string port_num_; GTEST_DISALLOW_COPY_AND_ASSIGN_(SocketWriter); }; // class SocketWriter // Escapes '=', '&', '%', and '\n' characters in str as "%xx". static string UrlEncode(const char* str); StreamingListener(const string& host, const string& port) : socket_writer_(new SocketWriter(host, port)) { Start(); } explicit StreamingListener(AbstractSocketWriter* socket_writer) : socket_writer_(socket_writer) { Start(); } void OnTestProgramStart(const UnitTest& /* unit_test */) { SendLn("event=TestProgramStart"); } void OnTestProgramEnd(const UnitTest& unit_test) { // Note that Google Test current only report elapsed time for each // test iteration, not for the entire test program. SendLn("event=TestProgramEnd&passed=" + FormatBool(unit_test.Passed())); // Notify the streaming server to stop. socket_writer_->CloseConnection(); } void OnTestIterationStart(const UnitTest& /* unit_test */, int iteration) { SendLn("event=TestIterationStart&iteration=" + StreamableToString(iteration)); } void OnTestIterationEnd(const UnitTest& unit_test, int /* iteration */) { SendLn("event=TestIterationEnd&passed=" + FormatBool(unit_test.Passed()) + "&elapsed_time=" + StreamableToString(unit_test.elapsed_time()) + "ms"); } void OnTestCaseStart(const TestCase& test_case) { SendLn(std::string("event=TestCaseStart&name=") + test_case.name()); } void OnTestCaseEnd(const TestCase& test_case) { SendLn("event=TestCaseEnd&passed=" + FormatBool(test_case.Passed()) + "&elapsed_time=" + StreamableToString(test_case.elapsed_time()) + "ms"); } void OnTestStart(const TestInfo& test_info) { SendLn(std::string("event=TestStart&name=") + test_info.name()); } void OnTestEnd(const TestInfo& test_info) { SendLn("event=TestEnd&passed=" + FormatBool((test_info.result())->Passed()) + "&elapsed_time=" + StreamableToString((test_info.result())->elapsed_time()) + "ms"); } void OnTestPartResult(const TestPartResult& test_part_result) { const char* file_name = test_part_result.file_name(); if (file_name == NULL) file_name = ""; SendLn("event=TestPartResult&file=" + UrlEncode(file_name) + "&line=" + StreamableToString(test_part_result.line_number()) + "&message=" + UrlEncode(test_part_result.message())); } private: // Sends the given message and a newline to the socket. void SendLn(const string& message) { socket_writer_->SendLn(message); } // Called at the start of streaming to notify the receiver what // protocol we are using. void Start() { SendLn("gtest_streaming_protocol_version=1.0"); } string FormatBool(bool value) { return value ? "1" : "0"; } const scoped_ptr<AbstractSocketWriter> socket_writer_; GTEST_DISALLOW_COPY_AND_ASSIGN_(StreamingListener); }; // class StreamingListener #endif // GTEST_CAN_STREAM_RESULTS_ } // namespace internal } // namespace testing #endif // GTEST_SRC_GTEST_INTERNAL_INL_H_ #undef GTEST_IMPLEMENTATION_ #if GTEST_OS_WINDOWS # define vsnprintf _vsnprintf #endif // GTEST_OS_WINDOWS namespace testing { using internal::CountIf; using internal::ForEach; using internal::GetElementOr; using internal::Shuffle; // Constants. // A test whose test case name or test name matches this filter is // disabled and not run. static const char kDisableTestFilter[] = "DISABLED_*:*/DISABLED_*"; // A test case whose name matches this filter is considered a death // test case and will be run before test cases whose name doesn't // match this filter. static const char kDeathTestCaseFilter[] = "*DeathTest:*DeathTest/*"; // A test filter that matches everything. static const char kUniversalFilter[] = "*"; // The default output file for XML output. static const char kDefaultOutputFile[] = "test_detail.xml"; // The environment variable name for the test shard index. static const char kTestShardIndex[] = "GTEST_SHARD_INDEX"; // The environment variable name for the total number of test shards. static const char kTestTotalShards[] = "GTEST_TOTAL_SHARDS"; // The environment variable name for the test shard status file. static const char kTestShardStatusFile[] = "GTEST_SHARD_STATUS_FILE"; namespace internal { // The text used in failure messages to indicate the start of the // stack trace. const char kStackTraceMarker[] = "\nStack trace:\n"; // g_help_flag is true iff the --help flag or an equivalent form is // specified on the command line. bool g_help_flag = false; } // namespace internal static const char* GetDefaultFilter() { return kUniversalFilter; } GTEST_DEFINE_bool_( also_run_disabled_tests, internal::BoolFromGTestEnv("also_run_disabled_tests", false), "Run disabled tests too, in addition to the tests normally being run."); GTEST_DEFINE_bool_( break_on_failure, internal::BoolFromGTestEnv("break_on_failure", false), "True iff a failed assertion should be a debugger break-point."); GTEST_DEFINE_bool_( catch_exceptions, internal::BoolFromGTestEnv("catch_exceptions", true), "True iff " GTEST_NAME_ " should catch exceptions and treat them as test failures."); GTEST_DEFINE_string_( color, internal::StringFromGTestEnv("color", "auto"), "Whether to use colors in the output. Valid values: yes, no, " "and auto. 'auto' means to use colors if the output is " "being sent to a terminal and the TERM environment variable " "is set to a terminal type that supports colors."); GTEST_DEFINE_string_( filter, internal::StringFromGTestEnv("filter", GetDefaultFilter()), "A colon-separated list of glob (not regex) patterns " "for filtering the tests to run, optionally followed by a " "'-' and a : separated list of negative patterns (tests to " "exclude). A test is run if it matches one of the positive " "patterns and does not match any of the negative patterns."); GTEST_DEFINE_string_( param_filter, internal::StringFromGTestEnv("param_filter", GetDefaultFilter()), "Same syntax and semantics as for param, but these patterns " "have to match the test's parameters."); GTEST_DEFINE_bool_(list_tests, false, "List all tests without running them."); GTEST_DEFINE_string_( output, internal::StringFromGTestEnv("output", ""), "A format (currently must be \"xml\"), optionally followed " "by a colon and an output file name or directory. A directory " "is indicated by a trailing pathname separator. " "Examples: \"xml:filename.xml\", \"xml::directoryname/\". " "If a directory is specified, output files will be created " "within that directory, with file-names based on the test " "executable's name and, if necessary, made unique by adding " "digits."); GTEST_DEFINE_bool_( print_time, internal::BoolFromGTestEnv("print_time", true), "True iff " GTEST_NAME_ " should display elapsed time in text output."); GTEST_DEFINE_int32_( random_seed, internal::Int32FromGTestEnv("random_seed", 0), "Random number seed to use when shuffling test orders. Must be in range " "[1, 99999], or 0 to use a seed based on the current time."); GTEST_DEFINE_int32_( repeat, internal::Int32FromGTestEnv("repeat", 1), "How many times to repeat each test. Specify a negative number " "for repeating forever. Useful for shaking out flaky tests."); GTEST_DEFINE_bool_( show_internal_stack_frames, false, "True iff " GTEST_NAME_ " should include internal stack frames when " "printing test failure stack traces."); GTEST_DEFINE_bool_( shuffle, internal::BoolFromGTestEnv("shuffle", false), "True iff " GTEST_NAME_ " should randomize tests' order on every run."); GTEST_DEFINE_int32_( stack_trace_depth, internal::Int32FromGTestEnv("stack_trace_depth", kMaxStackTraceDepth), "The maximum number of stack frames to print when an " "assertion fails. The valid range is 0 through 100, inclusive."); GTEST_DEFINE_string_( stream_result_to, internal::StringFromGTestEnv("stream_result_to", ""), "This flag specifies the host name and the port number on which to stream " "test results. Example: \"localhost:555\". The flag is effective only on " "Linux."); GTEST_DEFINE_bool_( throw_on_failure, internal::BoolFromGTestEnv("throw_on_failure", false), "When this flag is specified, a failed assertion will throw an exception " "if exceptions are enabled or exit the program with a non-zero code " "otherwise."); namespace internal { // Generates a random number from [0, range), using a Linear // Congruential Generator (LCG). Crashes if 'range' is 0 or greater // than kMaxRange. UInt32 Random::Generate(UInt32 range) { // These constants are the same as are used in glibc's rand(3). state_ = (1103515245U*state_ + 12345U) % kMaxRange; GTEST_CHECK_(range > 0) << "Cannot generate a number in the range [0, 0)."; GTEST_CHECK_(range <= kMaxRange) << "Generation of a number in [0, " << range << ") was requested, " << "but this can only generate numbers in [0, " << kMaxRange << ")."; // Converting via modulus introduces a bit of downward bias, but // it's simple, and a linear congruential generator isn't too good // to begin with. return state_ % range; } // GTestIsInitialized() returns true iff the user has initialized // Google Test. Useful for catching the user mistake of not initializing // Google Test before calling RUN_ALL_TESTS(). // // A user must call testing::InitGoogleTest() to initialize Google // Test. g_init_gtest_count is set to the number of times // InitGoogleTest() has been called. We don't protect this variable // under a mutex as it is only accessed in the main thread. GTEST_API_ int g_init_gtest_count = 0; static bool GTestIsInitialized() { return g_init_gtest_count != 0; } // Iterates over a vector of TestCases, keeping a running sum of the // results of calling a given int-returning method on each. // Returns the sum. static int SumOverTestCaseList(const std::vector<TestCase*>& case_list, int (TestCase::*method)() const) { int sum = 0; for (size_t i = 0; i < case_list.size(); i++) { sum += (case_list[i]->*method)(); } return sum; } // Returns true iff the test case passed. static bool TestCasePassed(const TestCase* test_case) { return test_case->should_run() && test_case->Passed(); } // Returns true iff the test case failed. static bool TestCaseFailed(const TestCase* test_case) { return test_case->should_run() && test_case->Failed(); } // Returns true iff test_case contains at least one test that should // run. static bool ShouldRunTestCase(const TestCase* test_case) { return test_case->should_run(); } // AssertHelper constructor. AssertHelper::AssertHelper(TestPartResult::Type type, const char* file, int line, const char* message) : data_(new AssertHelperData(type, file, line, message)) { } AssertHelper::~AssertHelper() { delete data_; } // Message assignment, for assertion streaming support. void AssertHelper::operator=(const Message& message) const { UnitTest::GetInstance()-> AddTestPartResult(data_->type, data_->file, data_->line, AppendUserMessage(data_->message, message), UnitTest::GetInstance()->impl() ->CurrentOsStackTraceExceptTop(1) // Skips the stack frame for this function itself. ); // NOLINT } // Mutex for linked pointers. GTEST_API_ GTEST_DEFINE_STATIC_MUTEX_(g_linked_ptr_mutex); // Application pathname gotten in InitGoogleTest. std::string g_executable_path; // Returns the current application's name, removing directory path if that // is present. FilePath GetCurrentExecutableName() { FilePath result; #if GTEST_OS_WINDOWS result.Set(FilePath(g_executable_path).RemoveExtension("exe")); #else result.Set(FilePath(g_executable_path)); #endif // GTEST_OS_WINDOWS return result.RemoveDirectoryName(); } // Functions for processing the gtest_output flag. // Returns the output format, or "" for normal printed output. std::string UnitTestOptions::GetOutputFormat() { const char* const gtest_output_flag = GTEST_FLAG(output).c_str(); if (gtest_output_flag == NULL) return std::string(""); const char* const colon = strchr(gtest_output_flag, ':'); return (colon == NULL) ? std::string(gtest_output_flag) : std::string(gtest_output_flag, colon - gtest_output_flag); } // Returns the name of the requested output file, or the default if none // was explicitly specified. std::string UnitTestOptions::GetAbsolutePathToOutputFile() { const char* const gtest_output_flag = GTEST_FLAG(output).c_str(); if (gtest_output_flag == NULL) return ""; const char* const colon = strchr(gtest_output_flag, ':'); if (colon == NULL) return internal::FilePath::ConcatPaths( internal::FilePath( UnitTest::GetInstance()->original_working_dir()), internal::FilePath(kDefaultOutputFile)).string(); internal::FilePath output_name(colon + 1); if (!output_name.IsAbsolutePath()) // TODO(wan@google.com): on Windows \some\path is not an absolute // path (as its meaning depends on the current drive), yet the // following logic for turning it into an absolute path is wrong. // Fix it. output_name = internal::FilePath::ConcatPaths( internal::FilePath(UnitTest::GetInstance()->original_working_dir()), internal::FilePath(colon + 1)); if (!output_name.IsDirectory()) return output_name.string(); internal::FilePath result(internal::FilePath::GenerateUniqueFileName( output_name, internal::GetCurrentExecutableName(), GetOutputFormat().c_str())); return result.string(); } // Returns true iff the wildcard pattern matches the string. The // first ':' or '\0' character in pattern marks the end of it. // // This recursive algorithm isn't very efficient, but is clear and // works well enough for matching test names, which are short. bool UnitTestOptions::PatternMatchesString(const char *pattern, const char *str) { switch (*pattern) { case '\0': case ':': // Either ':' or '\0' marks the end of the pattern. return *str == '\0'; case '?': // Matches any single character. return *str != '\0' && PatternMatchesString(pattern + 1, str + 1); case '*': // Matches any string (possibly empty) of characters. return (*str != '\0' && PatternMatchesString(pattern, str + 1)) || PatternMatchesString(pattern + 1, str); default: // Non-special character. Matches itself. return *pattern == *str && PatternMatchesString(pattern + 1, str + 1); } } bool UnitTestOptions::MatchesFilter( const std::string& name, const char* filter) { const char *cur_pattern = filter; for (;;) { if (PatternMatchesString(cur_pattern, name.c_str())) { return true; } // Finds the next pattern in the filter. cur_pattern = strchr(cur_pattern, ':'); // Returns if no more pattern can be found. if (cur_pattern == NULL) { return false; } // Skips the pattern separater (the ':' character). cur_pattern++; } } // Returns true iff the user-specified filter matches the test case // name and the test name. bool UnitTestOptions::FilterMatchesTest(const std::string &test_case_name, const std::string &test_name) { const std::string& full_name = test_case_name + "." + test_name.c_str(); // Split --gtest_filter at '-', if there is one, to separate into // positive filter and negative filter portions const char* const p = GTEST_FLAG(filter).c_str(); const char* const dash = strchr(p, '-'); std::string positive; std::string negative; if (dash == NULL) { positive = GTEST_FLAG(filter).c_str(); // Whole string is a positive filter negative = ""; } else { positive = std::string(p, dash); // Everything up to the dash negative = std::string(dash + 1); // Everything after the dash if (positive.empty()) { // Treat '-test1' as the same as '*-test1' positive = kUniversalFilter; } } // A filter is a colon-separated list of patterns. It matches a // test if any pattern in it matches the test. return (MatchesFilter(full_name, positive.c_str()) && !MatchesFilter(full_name, negative.c_str())); } #if GTEST_HAS_SEH // Returns EXCEPTION_EXECUTE_HANDLER if Google Test should handle the // given SEH exception, or EXCEPTION_CONTINUE_SEARCH otherwise. // This function is useful as an __except condition. int UnitTestOptions::GTestShouldProcessSEH(DWORD exception_code) { // Google Test should handle a SEH exception if: // 1. the user wants it to, AND // 2. this is not a breakpoint exception, AND // 3. this is not a C++ exception (VC++ implements them via SEH, // apparently). // // SEH exception code for C++ exceptions. // (see http://support.microsoft.com/kb/185294 for more information). const DWORD kCxxExceptionCode = 0xe06d7363; bool should_handle = true; if (!GTEST_FLAG(catch_exceptions)) should_handle = false; else if (exception_code == EXCEPTION_BREAKPOINT) should_handle = false; else if (exception_code == kCxxExceptionCode) should_handle = false; return should_handle ? EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH; } #endif // GTEST_HAS_SEH } // namespace internal // The c'tor sets this object as the test part result reporter used by // Google Test. The 'result' parameter specifies where to report the // results. Intercepts only failures from the current thread. ScopedFakeTestPartResultReporter::ScopedFakeTestPartResultReporter( TestPartResultArray* result) : intercept_mode_(INTERCEPT_ONLY_CURRENT_THREAD), result_(result) { Init(); } // The c'tor sets this object as the test part result reporter used by // Google Test. The 'result' parameter specifies where to report the // results. ScopedFakeTestPartResultReporter::ScopedFakeTestPartResultReporter( InterceptMode intercept_mode, TestPartResultArray* result) : intercept_mode_(intercept_mode), result_(result) { Init(); } void ScopedFakeTestPartResultReporter::Init() { internal::UnitTestImpl* const impl = internal::GetUnitTestImpl(); if (intercept_mode_ == INTERCEPT_ALL_THREADS) { old_reporter_ = impl->GetGlobalTestPartResultReporter(); impl->SetGlobalTestPartResultReporter(this); } else { old_reporter_ = impl->GetTestPartResultReporterForCurrentThread(); impl->SetTestPartResultReporterForCurrentThread(this); } } // The d'tor restores the test part result reporter used by Google Test // before. ScopedFakeTestPartResultReporter::~ScopedFakeTestPartResultReporter() { internal::UnitTestImpl* const impl = internal::GetUnitTestImpl(); if (intercept_mode_ == INTERCEPT_ALL_THREADS) { impl->SetGlobalTestPartResultReporter(old_reporter_); } else { impl->SetTestPartResultReporterForCurrentThread(old_reporter_); } } // Increments the test part result count and remembers the result. // This method is from the TestPartResultReporterInterface interface. void ScopedFakeTestPartResultReporter::ReportTestPartResult( const TestPartResult& result) { result_->Append(result); } namespace internal { // Returns the type ID of ::testing::Test. We should always call this // instead of GetTypeId< ::testing::Test>() to get the type ID of // testing::Test. This is to work around a suspected linker bug when // using Google Test as a framework on Mac OS X. The bug causes // GetTypeId< ::testing::Test>() to return different values depending // on whether the call is from the Google Test framework itself or // from user test code. GetTestTypeId() is guaranteed to always // return the same value, as it always calls GetTypeId<>() from the // gtest.cc, which is within the Google Test framework. TypeId GetTestTypeId() { return GetTypeId<Test>(); } // The value of GetTestTypeId() as seen from within the Google Test // library. This is solely for testing GetTestTypeId(). extern const TypeId kTestTypeIdInGoogleTest = GetTestTypeId(); // This predicate-formatter checks that 'results' contains a test part // failure of the given type and that the failure message contains the // given substring. static AssertionResult HasOneFailure(const char* /* results_expr */, const char* /* type_expr */, const char* /* substr_expr */, const TestPartResultArray& results, TestPartResult::Type type, const string& substr) { const std::string expected(type == TestPartResult::kFatalFailure ? "1 fatal failure" : "1 non-fatal failure"); Message msg; if (results.size() != 1) { msg << "Expected: " << expected << "\n" << " Actual: " << results.size() << " failures"; for (int i = 0; i < results.size(); i++) { msg << "\n" << results.GetTestPartResult(i); } return AssertionFailure() << msg; } const TestPartResult& r = results.GetTestPartResult(0); if (r.type() != type) { return AssertionFailure() << "Expected: " << expected << "\n" << " Actual:\n" << r; } if (strstr(r.message(), substr.c_str()) == NULL) { return AssertionFailure() << "Expected: " << expected << " containing \"" << substr << "\"\n" << " Actual:\n" << r; } return AssertionSuccess(); } // The constructor of SingleFailureChecker remembers where to look up // test part results, what type of failure we expect, and what // substring the failure message should contain. SingleFailureChecker:: SingleFailureChecker( const TestPartResultArray* results, TestPartResult::Type type, const string& substr) : results_(results), type_(type), substr_(substr) {} // The destructor of SingleFailureChecker verifies that the given // TestPartResultArray contains exactly one failure that has the given // type and contains the given substring. If that's not the case, a // non-fatal failure will be generated. SingleFailureChecker::~SingleFailureChecker() { EXPECT_PRED_FORMAT3(HasOneFailure, *results_, type_, substr_); } DefaultGlobalTestPartResultReporter::DefaultGlobalTestPartResultReporter( UnitTestImpl* unit_test) : unit_test_(unit_test) {} void DefaultGlobalTestPartResultReporter::ReportTestPartResult( const TestPartResult& result) { unit_test_->current_test_result()->AddTestPartResult(result); unit_test_->listeners()->repeater()->OnTestPartResult(result); } DefaultPerThreadTestPartResultReporter::DefaultPerThreadTestPartResultReporter( UnitTestImpl* unit_test) : unit_test_(unit_test) {} void DefaultPerThreadTestPartResultReporter::ReportTestPartResult( const TestPartResult& result) { unit_test_->GetGlobalTestPartResultReporter()->ReportTestPartResult(result); } // Returns the global test part result reporter. TestPartResultReporterInterface* UnitTestImpl::GetGlobalTestPartResultReporter() { internal::MutexLock lock(&global_test_part_result_reporter_mutex_); return global_test_part_result_repoter_; } // Sets the global test part result reporter. void UnitTestImpl::SetGlobalTestPartResultReporter( TestPartResultReporterInterface* reporter) { internal::MutexLock lock(&global_test_part_result_reporter_mutex_); global_test_part_result_repoter_ = reporter; } // Returns the test part result reporter for the current thread. TestPartResultReporterInterface* UnitTestImpl::GetTestPartResultReporterForCurrentThread() { return per_thread_test_part_result_reporter_.get(); } // Sets the test part result reporter for the current thread. void UnitTestImpl::SetTestPartResultReporterForCurrentThread( TestPartResultReporterInterface* reporter) { per_thread_test_part_result_reporter_.set(reporter); } // Gets the number of successful test cases. int UnitTestImpl::successful_test_case_count() const { return CountIf(test_cases_, TestCasePassed); } // Gets the number of failed test cases. int UnitTestImpl::failed_test_case_count() const { return CountIf(test_cases_, TestCaseFailed); } // Gets the number of all test cases. int UnitTestImpl::total_test_case_count() const { return static_cast<int>(test_cases_.size()); } // Gets the number of all test cases that contain at least one test // that should run. int UnitTestImpl::test_case_to_run_count() const { return CountIf(test_cases_, ShouldRunTestCase); } // Gets the number of successful tests. int UnitTestImpl::successful_test_count() const { return SumOverTestCaseList(test_cases_, &TestCase::successful_test_count); } // Gets the number of failed tests. int UnitTestImpl::failed_test_count() const { return SumOverTestCaseList(test_cases_, &TestCase::failed_test_count); } // Gets the number of disabled tests that will be reported in the XML report. int UnitTestImpl::reportable_disabled_test_count() const { return SumOverTestCaseList(test_cases_, &TestCase::reportable_disabled_test_count); } // Gets the number of disabled tests. int UnitTestImpl::disabled_test_count() const { return SumOverTestCaseList(test_cases_, &TestCase::disabled_test_count); } // Gets the number of tests to be printed in the XML report. int UnitTestImpl::reportable_test_count() const { return SumOverTestCaseList(test_cases_, &TestCase::reportable_test_count); } // Gets the number of all tests. int UnitTestImpl::total_test_count() const { return SumOverTestCaseList(test_cases_, &TestCase::total_test_count); } // Gets the number of tests that should run. int UnitTestImpl::test_to_run_count() const { return SumOverTestCaseList(test_cases_, &TestCase::test_to_run_count); } // Returns the current OS stack trace as an std::string. // // The maximum number of stack frames to be included is specified by // the gtest_stack_trace_depth flag. The skip_count parameter // specifies the number of top frames to be skipped, which doesn't // count against the number of frames to be included. // // For example, if Foo() calls Bar(), which in turn calls // CurrentOsStackTraceExceptTop(1), Foo() will be included in the // trace but Bar() and CurrentOsStackTraceExceptTop() won't. std::string UnitTestImpl::CurrentOsStackTraceExceptTop(int skip_count) { (void)skip_count; return ""; } // Returns the current time in milliseconds. TimeInMillis GetTimeInMillis() { #if GTEST_OS_WINDOWS_MOBILE || defined(__BORLANDC__) // Difference between 1970-01-01 and 1601-01-01 in milliseconds. // http://analogous.blogspot.com/2005/04/epoch.html const TimeInMillis kJavaEpochToWinFileTimeDelta = static_cast<TimeInMillis>(116444736UL) * 100000UL; const DWORD kTenthMicrosInMilliSecond = 10000; SYSTEMTIME now_systime; FILETIME now_filetime; ULARGE_INTEGER now_int64; // TODO(kenton@google.com): Shouldn't this just use // GetSystemTimeAsFileTime()? GetSystemTime(&now_systime); if (SystemTimeToFileTime(&now_systime, &now_filetime)) { now_int64.LowPart = now_filetime.dwLowDateTime; now_int64.HighPart = now_filetime.dwHighDateTime; now_int64.QuadPart = (now_int64.QuadPart / kTenthMicrosInMilliSecond) - kJavaEpochToWinFileTimeDelta; return now_int64.QuadPart; } return 0; #elif GTEST_OS_WINDOWS && !GTEST_HAS_GETTIMEOFDAY_ __timeb64 now; # ifdef _MSC_VER // MSVC 8 deprecates _ftime64(), so we want to suppress warning 4996 // (deprecated function) there. // TODO(kenton@google.com): Use GetTickCount()? Or use // SystemTimeToFileTime() # pragma warning(push) // Saves the current warning state. # pragma warning(disable:4996) // Temporarily disables warning 4996. _ftime64(&now); # pragma warning(pop) // Restores the warning state. # else _ftime64(&now); # endif // _MSC_VER return static_cast<TimeInMillis>(now.time) * 1000 + now.millitm; #elif GTEST_HAS_GETTIMEOFDAY_ struct timeval now; gettimeofday(&now, NULL); return static_cast<TimeInMillis>(now.tv_sec) * 1000 + now.tv_usec / 1000; #else # error "Don't know how to get the current time on your system." #endif } // Utilities // class String. #if GTEST_OS_WINDOWS_MOBILE // Creates a UTF-16 wide string from the given ANSI string, allocating // memory using new. The caller is responsible for deleting the return // value using delete[]. Returns the wide string, or NULL if the // input is NULL. LPCWSTR String::AnsiToUtf16(const char* ansi) { if (!ansi) return NULL; const int length = strlen(ansi); const int unicode_length = MultiByteToWideChar(CP_ACP, 0, ansi, length, NULL, 0); WCHAR* unicode = new WCHAR[unicode_length + 1]; MultiByteToWideChar(CP_ACP, 0, ansi, length, unicode, unicode_length); unicode[unicode_length] = 0; return unicode; } // Creates an ANSI string from the given wide string, allocating // memory using new. The caller is responsible for deleting the return // value using delete[]. Returns the ANSI string, or NULL if the // input is NULL. const char* String::Utf16ToAnsi(LPCWSTR utf16_str) { if (!utf16_str) return NULL; const int ansi_length = WideCharToMultiByte(CP_ACP, 0, utf16_str, -1, NULL, 0, NULL, NULL); char* ansi = new char[ansi_length + 1]; WideCharToMultiByte(CP_ACP, 0, utf16_str, -1, ansi, ansi_length, NULL, NULL); ansi[ansi_length] = 0; return ansi; } #endif // GTEST_OS_WINDOWS_MOBILE // Compares two C strings. Returns true iff they have the same content. // // Unlike strcmp(), this function can handle NULL argument(s). A NULL // C string is considered different to any non-NULL C string, // including the empty string. bool String::CStringEquals(const char * lhs, const char * rhs) { if ( lhs == NULL ) return rhs == NULL; if ( rhs == NULL ) return false; return strcmp(lhs, rhs) == 0; } #if GTEST_HAS_STD_WSTRING || GTEST_HAS_GLOBAL_WSTRING // Converts an array of wide chars to a narrow string using the UTF-8 // encoding, and streams the result to the given Message object. static void StreamWideCharsToMessage(const wchar_t* wstr, size_t length, Message* msg) { for (size_t i = 0; i != length; ) { // NOLINT if (wstr[i] != L'\0') { *msg << WideStringToUtf8(wstr + i, static_cast<int>(length - i)); while (i != length && wstr[i] != L'\0') i++; } else { *msg << '\0'; i++; } } } #endif // GTEST_HAS_STD_WSTRING || GTEST_HAS_GLOBAL_WSTRING } // namespace internal // Constructs an empty Message. // We allocate the stringstream separately because otherwise each use of // ASSERT/EXPECT in a procedure adds over 200 bytes to the procedure's // stack frame leading to huge stack frames in some cases; gcc does not reuse // the stack space. Message::Message() : ss_(new ::std::stringstream) { // By default, we want there to be enough precision when printing // a double to a Message. *ss_ << std::setprecision(std::numeric_limits<double>::digits10 + 2); } // These two overloads allow streaming a wide C string to a Message // using the UTF-8 encoding. Message& Message::operator <<(const wchar_t* wide_c_str) { return *this << internal::String::ShowWideCString(wide_c_str); } Message& Message::operator <<(wchar_t* wide_c_str) { return *this << internal::String::ShowWideCString(wide_c_str); } #if GTEST_HAS_STD_WSTRING // Converts the given wide string to a narrow string using the UTF-8 // encoding, and streams the result to this Message object. Message& Message::operator <<(const ::std::wstring& wstr) { internal::StreamWideCharsToMessage(wstr.c_str(), wstr.length(), this); return *this; } #endif // GTEST_HAS_STD_WSTRING #if GTEST_HAS_GLOBAL_WSTRING // Converts the given wide string to a narrow string using the UTF-8 // encoding, and streams the result to this Message object. Message& Message::operator <<(const ::wstring& wstr) { internal::StreamWideCharsToMessage(wstr.c_str(), wstr.length(), this); return *this; } #endif // GTEST_HAS_GLOBAL_WSTRING // Gets the text streamed to this object so far as an std::string. // Each '\0' character in the buffer is replaced with "\\0". std::string Message::GetString() const { return internal::StringStreamToString(ss_.get()); } // AssertionResult constructors. // Used in EXPECT_TRUE/FALSE(assertion_result). AssertionResult::AssertionResult(const AssertionResult& other) : success_(other.success_), message_(other.message_.get() != NULL ? new ::std::string(*other.message_) : static_cast< ::std::string*>(NULL)) { } // Returns the assertion's negation. Used with EXPECT/ASSERT_FALSE. AssertionResult AssertionResult::operator!() const { AssertionResult negation(!success_); if (message_.get() != NULL) negation << *message_; return negation; } // Makes a successful assertion result. AssertionResult AssertionSuccess() { return AssertionResult(true); } // Makes a failed assertion result. AssertionResult AssertionFailure() { return AssertionResult(false); } // Makes a failed assertion result with the given failure message. // Deprecated; use AssertionFailure() << message. AssertionResult AssertionFailure(const Message& message) { return AssertionFailure() << message; } namespace internal { // Constructs and returns the message for an equality assertion // (e.g. ASSERT_EQ, EXPECT_STREQ, etc) failure. // // The first four parameters are the expressions used in the assertion // and their values, as strings. For example, for ASSERT_EQ(foo, bar) // where foo is 5 and bar is 6, we have: // // expected_expression: "foo" // actual_expression: "bar" // expected_value: "5" // actual_value: "6" // // The ignoring_case parameter is true iff the assertion is a // *_STRCASEEQ*. When it's true, the string " (ignoring case)" will // be inserted into the message. AssertionResult EqFailure(const char* expected_expression, const char* actual_expression, const std::string& expected_value, const std::string& actual_value, bool ignoring_case) { Message msg; msg << "Value of: " << actual_expression; if (actual_value != actual_expression) { msg << "\n Actual: " << actual_value; } msg << "\nExpected: " << expected_expression; if (ignoring_case) { msg << " (ignoring case)"; } if (expected_value != expected_expression) { msg << "\nWhich is: " << expected_value; } return AssertionFailure() << msg; } // Constructs a failure message for Boolean assertions such as EXPECT_TRUE. std::string GetBoolAssertionFailureMessage( const AssertionResult& assertion_result, const char* expression_text, const char* actual_predicate_value, const char* expected_predicate_value) { const char* actual_message = assertion_result.message(); Message msg; msg << "Value of: " << expression_text << "\n Actual: " << actual_predicate_value; if (actual_message[0] != '\0') msg << " (" << actual_message << ")"; msg << "\nExpected: " << expected_predicate_value; return msg.GetString(); } // Helper function for implementing ASSERT_NEAR. AssertionResult DoubleNearPredFormat(const char* expr1, const char* expr2, const char* abs_error_expr, double val1, double val2, double abs_error) { const double diff = fabs(val1 - val2); if (diff <= abs_error) return AssertionSuccess(); // TODO(wan): do not print the value of an expression if it's // already a literal. return AssertionFailure() << "The difference between " << expr1 << " and " << expr2 << " is " << diff << ", which exceeds " << abs_error_expr << ", where\n" << expr1 << " evaluates to " << val1 << ",\n" << expr2 << " evaluates to " << val2 << ", and\n" << abs_error_expr << " evaluates to " << abs_error << "."; } // Helper template for implementing FloatLE() and DoubleLE(). template <typename RawType> AssertionResult FloatingPointLE(const char* expr1, const char* expr2, RawType val1, RawType val2) { // Returns success if val1 is less than val2, if (val1 < val2) { return AssertionSuccess(); } // or if val1 is almost equal to val2. const FloatingPoint<RawType> lhs(val1), rhs(val2); if (lhs.AlmostEquals(rhs)) { return AssertionSuccess(); } // Note that the above two checks will both fail if either val1 or // val2 is NaN, as the IEEE floating-point standard requires that // any predicate involving a NaN must return false. ::std::stringstream val1_ss; val1_ss << std::setprecision(std::numeric_limits<RawType>::digits10 + 2) << val1; ::std::stringstream val2_ss; val2_ss << std::setprecision(std::numeric_limits<RawType>::digits10 + 2) << val2; return AssertionFailure() << "Expected: (" << expr1 << ") <= (" << expr2 << ")\n" << " Actual: " << StringStreamToString(&val1_ss) << " vs " << StringStreamToString(&val2_ss); } } // namespace internal // Asserts that val1 is less than, or almost equal to, val2. Fails // otherwise. In particular, it fails if either val1 or val2 is NaN. AssertionResult FloatLE(const char* expr1, const char* expr2, float val1, float val2) { return internal::FloatingPointLE<float>(expr1, expr2, val1, val2); } // Asserts that val1 is less than, or almost equal to, val2. Fails // otherwise. In particular, it fails if either val1 or val2 is NaN. AssertionResult DoubleLE(const char* expr1, const char* expr2, double val1, double val2) { return internal::FloatingPointLE<double>(expr1, expr2, val1, val2); } namespace internal { // The helper function for {ASSERT|EXPECT}_EQ with int or enum // arguments. AssertionResult CmpHelperEQ(const char* expected_expression, const char* actual_expression, BiggestInt expected, BiggestInt actual) { if (expected == actual) { return AssertionSuccess(); } return EqFailure(expected_expression, actual_expression, FormatForComparisonFailureMessage(expected, actual), FormatForComparisonFailureMessage(actual, expected), false); } // A macro for implementing the helper functions needed to implement // ASSERT_?? and EXPECT_?? with integer or enum arguments. It is here // just to avoid copy-and-paste of similar code. #define GTEST_IMPL_CMP_HELPER_(op_name, op)\ AssertionResult CmpHelper##op_name(const char* expr1, const char* expr2, \ BiggestInt val1, BiggestInt val2) {\ if (val1 op val2) {\ return AssertionSuccess();\ } else {\ return AssertionFailure() \ << "Expected: (" << expr1 << ") " #op " (" << expr2\ << "), actual: " << FormatForComparisonFailureMessage(val1, val2)\ << " vs " << FormatForComparisonFailureMessage(val2, val1);\ }\ } // Implements the helper function for {ASSERT|EXPECT}_NE with int or // enum arguments. GTEST_IMPL_CMP_HELPER_(NE, !=) // Implements the helper function for {ASSERT|EXPECT}_LE with int or // enum arguments. GTEST_IMPL_CMP_HELPER_(LE, <=) // Implements the helper function for {ASSERT|EXPECT}_LT with int or // enum arguments. GTEST_IMPL_CMP_HELPER_(LT, < ) // Implements the helper function for {ASSERT|EXPECT}_GE with int or // enum arguments. GTEST_IMPL_CMP_HELPER_(GE, >=) // Implements the helper function for {ASSERT|EXPECT}_GT with int or // enum arguments. GTEST_IMPL_CMP_HELPER_(GT, > ) #undef GTEST_IMPL_CMP_HELPER_ // The helper function for {ASSERT|EXPECT}_STREQ. AssertionResult CmpHelperSTREQ(const char* expected_expression, const char* actual_expression, const char* expected, const char* actual) { if (String::CStringEquals(expected, actual)) { return AssertionSuccess(); } return EqFailure(expected_expression, actual_expression, PrintToString(expected), PrintToString(actual), false); } // The helper function for {ASSERT|EXPECT}_STRCASEEQ. AssertionResult CmpHelperSTRCASEEQ(const char* expected_expression, const char* actual_expression, const char* expected, const char* actual) { if (String::CaseInsensitiveCStringEquals(expected, actual)) { return AssertionSuccess(); } return EqFailure(expected_expression, actual_expression, PrintToString(expected), PrintToString(actual), true); } // The helper function for {ASSERT|EXPECT}_STRNE. AssertionResult CmpHelperSTRNE(const char* s1_expression, const char* s2_expression, const char* s1, const char* s2) { if (!String::CStringEquals(s1, s2)) { return AssertionSuccess(); } else { return AssertionFailure() << "Expected: (" << s1_expression << ") != (" << s2_expression << "), actual: \"" << s1 << "\" vs \"" << s2 << "\""; } } // The helper function for {ASSERT|EXPECT}_STRCASENE. AssertionResult CmpHelperSTRCASENE(const char* s1_expression, const char* s2_expression, const char* s1, const char* s2) { if (!String::CaseInsensitiveCStringEquals(s1, s2)) { return AssertionSuccess(); } else { return AssertionFailure() << "Expected: (" << s1_expression << ") != (" << s2_expression << ") (ignoring case), actual: \"" << s1 << "\" vs \"" << s2 << "\""; } } } // namespace internal namespace { // Helper functions for implementing IsSubString() and IsNotSubstring(). // This group of overloaded functions return true iff needle is a // substring of haystack. NULL is considered a substring of itself // only. bool IsSubstringPred(const char* needle, const char* haystack) { if (needle == NULL || haystack == NULL) return needle == haystack; return strstr(haystack, needle) != NULL; } bool IsSubstringPred(const wchar_t* needle, const wchar_t* haystack) { if (needle == NULL || haystack == NULL) return needle == haystack; return wcsstr(haystack, needle) != NULL; } // StringType here can be either ::std::string or ::std::wstring. template <typename StringType> bool IsSubstringPred(const StringType& needle, const StringType& haystack) { return haystack.find(needle) != StringType::npos; } // This function implements either IsSubstring() or IsNotSubstring(), // depending on the value of the expected_to_be_substring parameter. // StringType here can be const char*, const wchar_t*, ::std::string, // or ::std::wstring. template <typename StringType> AssertionResult IsSubstringImpl( bool expected_to_be_substring, const char* needle_expr, const char* haystack_expr, const StringType& needle, const StringType& haystack) { if (IsSubstringPred(needle, haystack) == expected_to_be_substring) return AssertionSuccess(); const bool is_wide_string = sizeof(needle[0]) > 1; const char* const begin_string_quote = is_wide_string ? "L\"" : "\""; return AssertionFailure() << "Value of: " << needle_expr << "\n" << " Actual: " << begin_string_quote << needle << "\"\n" << "Expected: " << (expected_to_be_substring ? "" : "not ") << "a substring of " << haystack_expr << "\n" << "Which is: " << begin_string_quote << haystack << "\""; } } // namespace // IsSubstring() and IsNotSubstring() check whether needle is a // substring of haystack (NULL is considered a substring of itself // only), and return an appropriate error message when they fail. AssertionResult IsSubstring( const char* needle_expr, const char* haystack_expr, const char* needle, const char* haystack) { return IsSubstringImpl(true, needle_expr, haystack_expr, needle, haystack); } AssertionResult IsSubstring( const char* needle_expr, const char* haystack_expr, const wchar_t* needle, const wchar_t* haystack) { return IsSubstringImpl(true, needle_expr, haystack_expr, needle, haystack); } AssertionResult IsNotSubstring( const char* needle_expr, const char* haystack_expr, const char* needle, const char* haystack) { return IsSubstringImpl(false, needle_expr, haystack_expr, needle, haystack); } AssertionResult IsNotSubstring( const char* needle_expr, const char* haystack_expr, const wchar_t* needle, const wchar_t* haystack) { return IsSubstringImpl(false, needle_expr, haystack_expr, needle, haystack); } AssertionResult IsSubstring( const char* needle_expr, const char* haystack_expr, const ::std::string& needle, const ::std::string& haystack) { return IsSubstringImpl(true, needle_expr, haystack_expr, needle, haystack); } AssertionResult IsNotSubstring( const char* needle_expr, const char* haystack_expr, const ::std::string& needle, const ::std::string& haystack) { return IsSubstringImpl(false, needle_expr, haystack_expr, needle, haystack); } #if GTEST_HAS_STD_WSTRING AssertionResult IsSubstring( const char* needle_expr, const char* haystack_expr, const ::std::wstring& needle, const ::std::wstring& haystack) { return IsSubstringImpl(true, needle_expr, haystack_expr, needle, haystack); } AssertionResult IsNotSubstring( const char* needle_expr, const char* haystack_expr, const ::std::wstring& needle, const ::std::wstring& haystack) { return IsSubstringImpl(false, needle_expr, haystack_expr, needle, haystack); } #endif // GTEST_HAS_STD_WSTRING namespace internal { #if GTEST_OS_WINDOWS namespace { // Helper function for IsHRESULT{SuccessFailure} predicates AssertionResult HRESULTFailureHelper(const char* expr, const char* expected, long hr) { // NOLINT # if GTEST_OS_WINDOWS_MOBILE // Windows CE doesn't support FormatMessage. const char error_text[] = ""; # else // Looks up the human-readable system message for the HRESULT code // and since we're not passing any params to FormatMessage, we don't // want inserts expanded. const DWORD kFlags = FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS; const DWORD kBufSize = 4096; // Gets the system's human readable message string for this HRESULT. char error_text[kBufSize] = { '\0' }; DWORD message_length = ::FormatMessageA(kFlags, 0, // no source, we're asking system hr, // the error 0, // no line width restrictions error_text, // output buffer kBufSize, // buf size NULL); // no arguments for inserts // Trims tailing white space (FormatMessage leaves a trailing CR-LF) for (; message_length && IsSpace(error_text[message_length - 1]); --message_length) { error_text[message_length - 1] = '\0'; } # endif // GTEST_OS_WINDOWS_MOBILE const std::string error_hex("0x" + String::FormatHexInt(hr)); return ::testing::AssertionFailure() << "Expected: " << expr << " " << expected << ".\n" << " Actual: " << error_hex << " " << error_text << "\n"; } } // namespace AssertionResult IsHRESULTSuccess(const char* expr, long hr) { // NOLINT if (SUCCEEDED(hr)) { return AssertionSuccess(); } return HRESULTFailureHelper(expr, "succeeds", hr); } AssertionResult IsHRESULTFailure(const char* expr, long hr) { // NOLINT if (FAILED(hr)) { return AssertionSuccess(); } return HRESULTFailureHelper(expr, "fails", hr); } #endif // GTEST_OS_WINDOWS // Utility functions for encoding Unicode text (wide strings) in // UTF-8. // A Unicode code-point can have upto 21 bits, and is encoded in UTF-8 // like this: // // Code-point length Encoding // 0 - 7 bits 0xxxxxxx // 8 - 11 bits 110xxxxx 10xxxxxx // 12 - 16 bits 1110xxxx 10xxxxxx 10xxxxxx // 17 - 21 bits 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx // The maximum code-point a one-byte UTF-8 sequence can represent. const UInt32 kMaxCodePoint1 = (static_cast<UInt32>(1) << 7) - 1; // The maximum code-point a two-byte UTF-8 sequence can represent. const UInt32 kMaxCodePoint2 = (static_cast<UInt32>(1) << (5 + 6)) - 1; // The maximum code-point a three-byte UTF-8 sequence can represent. const UInt32 kMaxCodePoint3 = (static_cast<UInt32>(1) << (4 + 2*6)) - 1; // The maximum code-point a four-byte UTF-8 sequence can represent. const UInt32 kMaxCodePoint4 = (static_cast<UInt32>(1) << (3 + 3*6)) - 1; // Chops off the n lowest bits from a bit pattern. Returns the n // lowest bits. As a side effect, the original bit pattern will be // shifted to the right by n bits. inline UInt32 ChopLowBits(UInt32* bits, int n) { const UInt32 low_bits = *bits & ((static_cast<UInt32>(1) << n) - 1); *bits >>= n; return low_bits; } // Converts a Unicode code point to a narrow string in UTF-8 encoding. // code_point parameter is of type UInt32 because wchar_t may not be // wide enough to contain a code point. // If the code_point is not a valid Unicode code point // (i.e. outside of Unicode range U+0 to U+10FFFF) it will be converted // to "(Invalid Unicode 0xXXXXXXXX)". std::string CodePointToUtf8(UInt32 code_point) { if (code_point > kMaxCodePoint4) { return "(Invalid Unicode 0x" + String::FormatHexInt(code_point) + ")"; } char str[5]; // Big enough for the largest valid code point. if (code_point <= kMaxCodePoint1) { str[1] = '\0'; str[0] = static_cast<char>(code_point); // 0xxxxxxx } else if (code_point <= kMaxCodePoint2) { str[2] = '\0'; str[1] = static_cast<char>(0x80 | ChopLowBits(&code_point, 6)); // 10xxxxxx str[0] = static_cast<char>(0xC0 | code_point); // 110xxxxx } else if (code_point <= kMaxCodePoint3) { str[3] = '\0'; str[2] = static_cast<char>(0x80 | ChopLowBits(&code_point, 6)); // 10xxxxxx str[1] = static_cast<char>(0x80 | ChopLowBits(&code_point, 6)); // 10xxxxxx str[0] = static_cast<char>(0xE0 | code_point); // 1110xxxx } else { // code_point <= kMaxCodePoint4 str[4] = '\0'; str[3] = static_cast<char>(0x80 | ChopLowBits(&code_point, 6)); // 10xxxxxx str[2] = static_cast<char>(0x80 | ChopLowBits(&code_point, 6)); // 10xxxxxx str[1] = static_cast<char>(0x80 | ChopLowBits(&code_point, 6)); // 10xxxxxx str[0] = static_cast<char>(0xF0 | code_point); // 11110xxx } return str; } // The following two functions only make sense if the the system // uses UTF-16 for wide string encoding. All supported systems // with 16 bit wchar_t (Windows, Cygwin, Symbian OS) do use UTF-16. // Determines if the arguments constitute UTF-16 surrogate pair // and thus should be combined into a single Unicode code point // using CreateCodePointFromUtf16SurrogatePair. inline bool IsUtf16SurrogatePair(wchar_t first, wchar_t second) { return sizeof(wchar_t) == 2 && (first & 0xFC00) == 0xD800 && (second & 0xFC00) == 0xDC00; } // Creates a Unicode code point from UTF16 surrogate pair. inline UInt32 CreateCodePointFromUtf16SurrogatePair(wchar_t first, wchar_t second) { const UInt32 mask = (1 << 10) - 1; return (sizeof(wchar_t) == 2) ? (((first & mask) << 10) | (second & mask)) + 0x10000 : // This function should not be called when the condition is // false, but we provide a sensible default in case it is. static_cast<UInt32>(first); } // Converts a wide string to a narrow string in UTF-8 encoding. // The wide string is assumed to have the following encoding: // UTF-16 if sizeof(wchar_t) == 2 (on Windows, Cygwin, Symbian OS) // UTF-32 if sizeof(wchar_t) == 4 (on Linux) // Parameter str points to a null-terminated wide string. // Parameter num_chars may additionally limit the number // of wchar_t characters processed. -1 is used when the entire string // should be processed. // If the string contains code points that are not valid Unicode code points // (i.e. outside of Unicode range U+0 to U+10FFFF) they will be output // as '(Invalid Unicode 0xXXXXXXXX)'. If the string is in UTF16 encoding // and contains invalid UTF-16 surrogate pairs, values in those pairs // will be encoded as individual Unicode characters from Basic Normal Plane. std::string WideStringToUtf8(const wchar_t* str, int num_chars) { if (num_chars == -1) num_chars = static_cast<int>(wcslen(str)); ::std::stringstream stream; for (int i = 0; i < num_chars; ++i) { UInt32 unicode_code_point; if (str[i] == L'\0') { break; } else if (i + 1 < num_chars && IsUtf16SurrogatePair(str[i], str[i + 1])) { unicode_code_point = CreateCodePointFromUtf16SurrogatePair(str[i], str[i + 1]); i++; } else { unicode_code_point = static_cast<UInt32>(str[i]); } stream << CodePointToUtf8(unicode_code_point); } return StringStreamToString(&stream); } // Converts a wide C string to an std::string using the UTF-8 encoding. // NULL will be converted to "(null)". std::string String::ShowWideCString(const wchar_t * wide_c_str) { if (wide_c_str == NULL) return "(null)"; return internal::WideStringToUtf8(wide_c_str, -1); } // Compares two wide C strings. Returns true iff they have the same // content. // // Unlike wcscmp(), this function can handle NULL argument(s). A NULL // C string is considered different to any non-NULL C string, // including the empty string. bool String::WideCStringEquals(const wchar_t * lhs, const wchar_t * rhs) { if (lhs == NULL) return rhs == NULL; if (rhs == NULL) return false; return wcscmp(lhs, rhs) == 0; } // Helper function for *_STREQ on wide strings. AssertionResult CmpHelperSTREQ(const char* expected_expression, const char* actual_expression, const wchar_t* expected, const wchar_t* actual) { if (String::WideCStringEquals(expected, actual)) { return AssertionSuccess(); } return EqFailure(expected_expression, actual_expression, PrintToString(expected), PrintToString(actual), false); } // Helper function for *_STRNE on wide strings. AssertionResult CmpHelperSTRNE(const char* s1_expression, const char* s2_expression, const wchar_t* s1, const wchar_t* s2) { if (!String::WideCStringEquals(s1, s2)) { return AssertionSuccess(); } return AssertionFailure() << "Expected: (" << s1_expression << ") != (" << s2_expression << "), actual: " << PrintToString(s1) << " vs " << PrintToString(s2); } // Compares two C strings, ignoring case. Returns true iff they have // the same content. // // Unlike strcasecmp(), this function can handle NULL argument(s). A // NULL C string is considered different to any non-NULL C string, // including the empty string. bool String::CaseInsensitiveCStringEquals(const char * lhs, const char * rhs) { if (lhs == NULL) return rhs == NULL; if (rhs == NULL) return false; return posix::StrCaseCmp(lhs, rhs) == 0; } // Compares two wide C strings, ignoring case. Returns true iff they // have the same content. // // Unlike wcscasecmp(), this function can handle NULL argument(s). // A NULL C string is considered different to any non-NULL wide C string, // including the empty string. // NB: The implementations on different platforms slightly differ. // On windows, this method uses _wcsicmp which compares according to LC_CTYPE // environment variable. On GNU platform this method uses wcscasecmp // which compares according to LC_CTYPE category of the current locale. // On MacOS X, it uses towlower, which also uses LC_CTYPE category of the // current locale. bool String::CaseInsensitiveWideCStringEquals(const wchar_t* lhs, const wchar_t* rhs) { if (lhs == NULL) return rhs == NULL; if (rhs == NULL) return false; #if GTEST_OS_WINDOWS return _wcsicmp(lhs, rhs) == 0; #elif GTEST_OS_LINUX && !GTEST_OS_LINUX_ANDROID return wcscasecmp(lhs, rhs) == 0; #else // Android, Mac OS X and Cygwin don't define wcscasecmp. // Other unknown OSes may not define it either. wint_t left, right; do { left = towlower(*lhs++); right = towlower(*rhs++); } while (left && left == right); return left == right; #endif // OS selector } // Returns true iff str ends with the given suffix, ignoring case. // Any string is considered to end with an empty suffix. bool String::EndsWithCaseInsensitive( const std::string& str, const std::string& suffix) { const size_t str_len = str.length(); const size_t suffix_len = suffix.length(); return (str_len >= suffix_len) && CaseInsensitiveCStringEquals(str.c_str() + str_len - suffix_len, suffix.c_str()); } // Formats an int value as "%02d". std::string String::FormatIntWidth2(int value) { std::stringstream ss; ss << std::setfill('0') << std::setw(2) << value; return ss.str(); } // Formats an int value as "%X". std::string String::FormatHexInt(int value) { std::stringstream ss; ss << std::hex << std::uppercase << value; return ss.str(); } // Formats a byte as "%02X". std::string String::FormatByte(unsigned char value) { std::stringstream ss; ss << std::setfill('0') << std::setw(2) << std::hex << std::uppercase << static_cast<unsigned int>(value); return ss.str(); } // Converts the buffer in a stringstream to an std::string, converting NUL // bytes to "\\0" along the way. std::string StringStreamToString(::std::stringstream* ss) { const ::std::string& str = ss->str(); const char* const start = str.c_str(); const char* const end = start + str.length(); std::string result; result.reserve(2 * (end - start)); for (const char* ch = start; ch != end; ++ch) { if (*ch == '\0') { result += "\\0"; // Replaces NUL with "\\0"; } else { result += *ch; } } return result; } // Appends the user-supplied message to the Google-Test-generated message. std::string AppendUserMessage(const std::string& gtest_msg, const Message& user_msg) { // Appends the user message if it's non-empty. const std::string user_msg_string = user_msg.GetString(); if (user_msg_string.empty()) { return gtest_msg; } return gtest_msg + "\n" + user_msg_string; } } // namespace internal // class TestResult // Creates an empty TestResult. TestResult::TestResult() : death_test_count_(0), elapsed_time_(0) { } // D'tor. TestResult::~TestResult() { } // Returns the i-th test part result among all the results. i can // range from 0 to total_part_count() - 1. If i is not in that range, // aborts the program. const TestPartResult& TestResult::GetTestPartResult(int i) const { if (i < 0 || i >= total_part_count()) internal::posix::Abort(); return test_part_results_.at(i); } // Returns the i-th test property. i can range from 0 to // test_property_count() - 1. If i is not in that range, aborts the // program. const TestProperty& TestResult::GetTestProperty(int i) const { if (i < 0 || i >= test_property_count()) internal::posix::Abort(); return test_properties_.at(i); } // Clears the test part results. void TestResult::ClearTestPartResults() { test_part_results_.clear(); } // Adds a test part result to the list. void TestResult::AddTestPartResult(const TestPartResult& test_part_result) { test_part_results_.push_back(test_part_result); } // Adds a test property to the list. If a property with the same key as the // supplied property is already represented, the value of this test_property // replaces the old value for that key. void TestResult::RecordProperty(const std::string& xml_element, const TestProperty& test_property) { if (!ValidateTestProperty(xml_element, test_property)) { return; } internal::MutexLock lock(&test_properites_mutex_); const std::vector<TestProperty>::iterator property_with_matching_key = std::find_if(test_properties_.begin(), test_properties_.end(), internal::TestPropertyKeyIs(test_property.key())); if (property_with_matching_key == test_properties_.end()) { test_properties_.push_back(test_property); return; } property_with_matching_key->SetValue(test_property.value()); } // The list of reserved attributes used in the <testsuites> element of XML // output. static const char* const kReservedTestSuitesAttributes[] = { "disabled", "errors", "failures", "name", "random_seed", "tests", "time", "timestamp" }; // The list of reserved attributes used in the <testsuite> element of XML // output. static const char* const kReservedTestSuiteAttributes[] = { "disabled", "errors", "failures", "name", "tests", "time" }; // The list of reserved attributes used in the <testcase> element of XML output. static const char* const kReservedTestCaseAttributes[] = { "classname", "name", "status", "time", "type_param", "value_param" }; template <int kSize> std::vector<std::string> ArrayAsVector(const char* const (&array)[kSize]) { return std::vector<std::string>(array, array + kSize); } static std::vector<std::string> GetReservedAttributesForElement( const std::string& xml_element) { if (xml_element == "testsuites") { return ArrayAsVector(kReservedTestSuitesAttributes); } else if (xml_element == "testsuite") { return ArrayAsVector(kReservedTestSuiteAttributes); } else if (xml_element == "testcase") { return ArrayAsVector(kReservedTestCaseAttributes); } else { GTEST_CHECK_(false) << "Unrecognized xml_element provided: " << xml_element; } // This code is unreachable but some compilers may not realizes that. return std::vector<std::string>(); } static std::string FormatWordList(const std::vector<std::string>& words) { Message word_list; for (size_t i = 0; i < words.size(); ++i) { if (i > 0 && words.size() > 2) { word_list << ", "; } if (i == words.size() - 1) { word_list << "and "; } word_list << "'" << words[i] << "'"; } return word_list.GetString(); } static bool ValidateTestPropertyName(const std::string& property_name, const std::vector<std::string>& reserved_names) { if (std::find(reserved_names.begin(), reserved_names.end(), property_name) != reserved_names.end()) { ADD_FAILURE() << "Reserved key used in RecordProperty(): " << property_name << " (" << FormatWordList(reserved_names) << " are reserved by " << GTEST_NAME_ << ")"; return false; } return true; } // Adds a failure if the key is a reserved attribute of the element named // xml_element. Returns true if the property is valid. bool TestResult::ValidateTestProperty(const std::string& xml_element, const TestProperty& test_property) { return ValidateTestPropertyName(test_property.key(), GetReservedAttributesForElement(xml_element)); } // Clears the object. void TestResult::Clear() { test_part_results_.clear(); test_properties_.clear(); death_test_count_ = 0; elapsed_time_ = 0; } // Returns true iff the test failed. bool TestResult::Failed() const { for (int i = 0; i < total_part_count(); ++i) { if (GetTestPartResult(i).failed()) return true; } return false; } // Returns true iff the test part fatally failed. static bool TestPartFatallyFailed(const TestPartResult& result) { return result.fatally_failed(); } // Returns true iff the test fatally failed. bool TestResult::HasFatalFailure() const { return CountIf(test_part_results_, TestPartFatallyFailed) > 0; } // Returns true iff the test part non-fatally failed. static bool TestPartNonfatallyFailed(const TestPartResult& result) { return result.nonfatally_failed(); } // Returns true iff the test has a non-fatal failure. bool TestResult::HasNonfatalFailure() const { return CountIf(test_part_results_, TestPartNonfatallyFailed) > 0; } // Gets the number of all test parts. This is the sum of the number // of successful test parts and the number of failed test parts. int TestResult::total_part_count() const { return static_cast<int>(test_part_results_.size()); } // Returns the number of the test properties. int TestResult::test_property_count() const { return static_cast<int>(test_properties_.size()); } // class Test // Creates a Test object. // The c'tor saves the values of all Google Test flags. Test::Test() : gtest_flag_saver_(new internal::GTestFlagSaver) { } // The d'tor restores the values of all Google Test flags. Test::~Test() { delete gtest_flag_saver_; } // Sets up the test fixture. // // A sub-class may override this. void Test::SetUp() { } // Tears down the test fixture. // // A sub-class may override this. void Test::TearDown() { } // Allows user supplied key value pairs to be recorded for later output. void Test::RecordProperty(const std::string& key, const std::string& value) { UnitTest::GetInstance()->RecordProperty(key, value); } // Allows user supplied key value pairs to be recorded for later output. void Test::RecordProperty(const std::string& key, int value) { Message value_message; value_message << value; RecordProperty(key, value_message.GetString().c_str()); } namespace internal { void ReportFailureInUnknownLocation(TestPartResult::Type result_type, const std::string& message) { // This function is a friend of UnitTest and as such has access to // AddTestPartResult. UnitTest::GetInstance()->AddTestPartResult( result_type, NULL, // No info about the source file where the exception occurred. -1, // We have no info on which line caused the exception. message, ""); // No stack trace, either. } } // namespace internal // Google Test requires all tests in the same test case to use the same test // fixture class. This function checks if the current test has the // same fixture class as the first test in the current test case. If // yes, it returns true; otherwise it generates a Google Test failure and // returns false. bool Test::HasSameFixtureClass() { internal::UnitTestImpl* const impl = internal::GetUnitTestImpl(); const TestCase* const test_case = impl->current_test_case(); // Info about the first test in the current test case. const TestInfo* const first_test_info = test_case->test_info_list()[0]; const internal::TypeId first_fixture_id = first_test_info->fixture_class_id_; const char* const first_test_name = first_test_info->name(); // Info about the current test. const TestInfo* const this_test_info = impl->current_test_info(); const internal::TypeId this_fixture_id = this_test_info->fixture_class_id_; const char* const this_test_name = this_test_info->name(); if (this_fixture_id != first_fixture_id) { // Is the first test defined using TEST? const bool first_is_TEST = first_fixture_id == internal::GetTestTypeId(); // Is this test defined using TEST? const bool this_is_TEST = this_fixture_id == internal::GetTestTypeId(); if (first_is_TEST || this_is_TEST) { // The user mixed TEST and TEST_F in this test case - we'll tell // him/her how to fix it. // Gets the name of the TEST and the name of the TEST_F. Note // that first_is_TEST and this_is_TEST cannot both be true, as // the fixture IDs are different for the two tests. const char* const TEST_name = first_is_TEST ? first_test_name : this_test_name; const char* const TEST_F_name = first_is_TEST ? this_test_name : first_test_name; ADD_FAILURE() << "All tests in the same test case must use the same test fixture\n" << "class, so mixing TEST_F and TEST in the same test case is\n" << "illegal. In test case " << this_test_info->test_case_name() << ",\n" << "test " << TEST_F_name << " is defined using TEST_F but\n" << "test " << TEST_name << " is defined using TEST. You probably\n" << "want to change the TEST to TEST_F or move it to another test\n" << "case."; } else { // The user defined two fixture classes with the same name in // two namespaces - we'll tell him/her how to fix it. ADD_FAILURE() << "All tests in the same test case must use the same test fixture\n" << "class. However, in test case " << this_test_info->test_case_name() << ",\n" << "you defined test " << first_test_name << " and test " << this_test_name << "\n" << "using two different test fixture classes. This can happen if\n" << "the two classes are from different namespaces or translation\n" << "units and have the same name. You should probably rename one\n" << "of the classes to put the tests into different test cases."; } return false; } return true; } #if GTEST_HAS_SEH // Adds an "exception thrown" fatal failure to the current test. This // function returns its result via an output parameter pointer because VC++ // prohibits creation of objects with destructors on stack in functions // using __try (see error C2712). static std::string* FormatSehExceptionMessage(DWORD exception_code, const char* location) { Message message; message << "SEH exception with code 0x" << std::setbase(16) << exception_code << std::setbase(10) << " thrown in " << location << "."; return new std::string(message.GetString()); } #endif // GTEST_HAS_SEH namespace internal { #if GTEST_HAS_EXCEPTIONS // Adds an "exception thrown" fatal failure to the current test. static std::string FormatCxxExceptionMessage(const char* description, const char* location) { Message message; if (description != NULL) { message << "C++ exception with description \"" << description << "\""; } else { message << "Unknown C++ exception"; } message << " thrown in " << location << "."; return message.GetString(); } static std::string PrintTestPartResultToString( const TestPartResult& test_part_result); GoogleTestFailureException::GoogleTestFailureException( const TestPartResult& failure) : ::std::runtime_error(PrintTestPartResultToString(failure).c_str()) {} #endif // GTEST_HAS_EXCEPTIONS // We put these helper functions in the internal namespace as IBM's xlC // compiler rejects the code if they were declared static. // Runs the given method and handles SEH exceptions it throws, when // SEH is supported; returns the 0-value for type Result in case of an // SEH exception. (Microsoft compilers cannot handle SEH and C++ // exceptions in the same function. Therefore, we provide a separate // wrapper function for handling SEH exceptions.) template <class T, typename Result> Result HandleSehExceptionsInMethodIfSupported( T* object, Result (T::*method)(), const char* location) { #if GTEST_HAS_SEH __try { return (object->*method)(); } __except (internal::UnitTestOptions::GTestShouldProcessSEH( // NOLINT GetExceptionCode())) { // We create the exception message on the heap because VC++ prohibits // creation of objects with destructors on stack in functions using __try // (see error C2712). std::string* exception_message = FormatSehExceptionMessage( GetExceptionCode(), location); internal::ReportFailureInUnknownLocation(TestPartResult::kFatalFailure, *exception_message); delete exception_message; return static_cast<Result>(0); } #else (void)location; return (object->*method)(); #endif // GTEST_HAS_SEH } // Runs the given method and catches and reports C++ and/or SEH-style // exceptions, if they are supported; returns the 0-value for type // Result in case of an SEH exception. template <class T, typename Result> Result HandleExceptionsInMethodIfSupported( T* object, Result (T::*method)(), const char* location) { // NOTE: The user code can affect the way in which Google Test handles // exceptions by setting GTEST_FLAG(catch_exceptions), but only before // RUN_ALL_TESTS() starts. It is technically possible to check the flag // after the exception is caught and either report or re-throw the // exception based on the flag's value: // // try { // // Perform the test method. // } catch (...) { // if (GTEST_FLAG(catch_exceptions)) // // Report the exception as failure. // else // throw; // Re-throws the original exception. // } // // However, the purpose of this flag is to allow the program to drop into // the debugger when the exception is thrown. On most platforms, once the // control enters the catch block, the exception origin information is // lost and the debugger will stop the program at the point of the // re-throw in this function -- instead of at the point of the original // throw statement in the code under test. For this reason, we perform // the check early, sacrificing the ability to affect Google Test's // exception handling in the method where the exception is thrown. if (internal::GetUnitTestImpl()->catch_exceptions()) { #if GTEST_HAS_EXCEPTIONS try { return HandleSehExceptionsInMethodIfSupported(object, method, location); } catch (const internal::GoogleTestFailureException&) { // NOLINT // This exception type can only be thrown by a failed Google // Test assertion with the intention of letting another testing // framework catch it. Therefore we just re-throw it. throw; } catch (const std::exception& e) { // NOLINT internal::ReportFailureInUnknownLocation( TestPartResult::kFatalFailure, FormatCxxExceptionMessage(e.what(), location)); } catch (...) { // NOLINT internal::ReportFailureInUnknownLocation( TestPartResult::kFatalFailure, FormatCxxExceptionMessage(NULL, location)); } return static_cast<Result>(0); #else return HandleSehExceptionsInMethodIfSupported(object, method, location); #endif // GTEST_HAS_EXCEPTIONS } else { return (object->*method)(); } } } // namespace internal // Runs the test and updates the test result. void Test::Run() { if (!HasSameFixtureClass()) return; internal::UnitTestImpl* const impl = internal::GetUnitTestImpl(); impl->os_stack_trace_getter()->UponLeavingGTest(); internal::HandleExceptionsInMethodIfSupported(this, &Test::SetUp, "SetUp()"); // We will run the test only if SetUp() was successful. if (!HasFatalFailure()) { impl->os_stack_trace_getter()->UponLeavingGTest(); internal::HandleExceptionsInMethodIfSupported( this, &Test::TestBody, "the test body"); } // However, we want to clean up as much as possible. Hence we will // always call TearDown(), even if SetUp() or the test body has // failed. impl->os_stack_trace_getter()->UponLeavingGTest(); internal::HandleExceptionsInMethodIfSupported( this, &Test::TearDown, "TearDown()"); } // Returns true iff the current test has a fatal failure. bool Test::HasFatalFailure() { return internal::GetUnitTestImpl()->current_test_result()->HasFatalFailure(); } // Returns true iff the current test has a non-fatal failure. bool Test::HasNonfatalFailure() { return internal::GetUnitTestImpl()->current_test_result()-> HasNonfatalFailure(); } // class TestInfo // Constructs a TestInfo object. It assumes ownership of the test factory // object. TestInfo::TestInfo(const std::string& a_test_case_name, const std::string& a_name, const char* a_type_param, const char* a_value_param, internal::TypeId fixture_class_id, internal::TestFactoryBase* factory) : test_case_name_(a_test_case_name), name_(a_name), type_param_(a_type_param ? new std::string(a_type_param) : NULL), value_param_(a_value_param ? new std::string(a_value_param) : NULL), fixture_class_id_(fixture_class_id), should_run_(false), is_disabled_(false), matches_filter_(false), factory_(factory), result_() {} // Destructs a TestInfo object. TestInfo::~TestInfo() { delete factory_; } namespace internal { // Creates a new TestInfo object and registers it with Google Test; // returns the created object. // // Arguments: // // test_case_name: name of the test case // name: name of the test // type_param: the name of the test's type parameter, or NULL if // this is not a typed or a type-parameterized test. // value_param: text representation of the test's value parameter, // or NULL if this is not a value-parameterized test. // fixture_class_id: ID of the test fixture class // set_up_tc: pointer to the function that sets up the test case // tear_down_tc: pointer to the function that tears down the test case // factory: pointer to the factory that creates a test object. // The newly created TestInfo instance will assume // ownership of the factory object. TestInfo* MakeAndRegisterTestInfo( const char* test_case_name, const char* name, const char* type_param, const char* value_param, TypeId fixture_class_id, SetUpTestCaseFunc set_up_tc, TearDownTestCaseFunc tear_down_tc, TestFactoryBase* factory) { TestInfo* const test_info = new TestInfo(test_case_name, name, type_param, value_param, fixture_class_id, factory); GetUnitTestImpl()->AddTestInfo(set_up_tc, tear_down_tc, test_info); return test_info; } #if GTEST_HAS_PARAM_TEST void ReportInvalidTestCaseType(const char* test_case_name, const char* file, int line) { Message errors; errors << "Attempted redefinition of test case " << test_case_name << ".\n" << "All tests in the same test case must use the same test fixture\n" << "class. However, in test case " << test_case_name << ", you tried\n" << "to define a test using a fixture class different from the one\n" << "used earlier. This can happen if the two fixture classes are\n" << "from different namespaces and have the same name. You should\n" << "probably rename one of the classes to put the tests into different\n" << "test cases."; fprintf(stderr, "%s %s", FormatFileLocation(file, line).c_str(), errors.GetString().c_str()); } #endif // GTEST_HAS_PARAM_TEST } // namespace internal namespace { // A predicate that checks the test name of a TestInfo against a known // value. // // This is used for implementation of the TestCase class only. We put // it in the anonymous namespace to prevent polluting the outer // namespace. // // TestNameIs is copyable. class TestNameIs { public: // Constructor. // // TestNameIs has NO default constructor. explicit TestNameIs(const char* name) : name_(name) {} // Returns true iff the test name of test_info matches name_. bool operator()(const TestInfo * test_info) const { return test_info && test_info->name() == name_; } private: std::string name_; }; } // namespace namespace internal { // This method expands all parameterized tests registered with macros TEST_P // and INSTANTIATE_TEST_CASE_P into regular tests and registers those. // This will be done just once during the program runtime. void UnitTestImpl::RegisterParameterizedTests() { #if GTEST_HAS_PARAM_TEST if (!parameterized_tests_registered_) { parameterized_test_registry_.RegisterTests(); parameterized_tests_registered_ = true; } #endif } } // namespace internal // Creates the test object, runs it, records its result, and then // deletes it. void TestInfo::Run() { if (!should_run_) return; // Tells UnitTest where to store test result. internal::UnitTestImpl* const impl = internal::GetUnitTestImpl(); impl->set_current_test_info(this); TestEventListener* repeater = UnitTest::GetInstance()->listeners().repeater(); // Notifies the unit test event listeners that a test is about to start. repeater->OnTestStart(*this); const TimeInMillis start = internal::GetTimeInMillis(); impl->os_stack_trace_getter()->UponLeavingGTest(); // Creates the test object. Test* const test = internal::HandleExceptionsInMethodIfSupported( factory_, &internal::TestFactoryBase::CreateTest, "the test fixture's constructor"); // Runs the test only if the test object was created and its // constructor didn't generate a fatal failure. if ((test != NULL) && !Test::HasFatalFailure()) { // This doesn't throw as all user code that can throw are wrapped into // exception handling code. test->Run(); } // Deletes the test object. impl->os_stack_trace_getter()->UponLeavingGTest(); internal::HandleExceptionsInMethodIfSupported( test, &Test::DeleteSelf_, "the test fixture's destructor"); result_.set_elapsed_time(internal::GetTimeInMillis() - start); // Notifies the unit test event listener that a test has just finished. repeater->OnTestEnd(*this); // Tells UnitTest to stop associating assertion results to this // test. impl->set_current_test_info(NULL); } // class TestCase // Gets the number of successful tests in this test case. int TestCase::successful_test_count() const { return CountIf(test_info_list_, TestPassed); } // Gets the number of failed tests in this test case. int TestCase::failed_test_count() const { return CountIf(test_info_list_, TestFailed); } // Gets the number of disabled tests that will be reported in the XML report. int TestCase::reportable_disabled_test_count() const { return CountIf(test_info_list_, TestReportableDisabled); } // Gets the number of disabled tests in this test case. int TestCase::disabled_test_count() const { return CountIf(test_info_list_, TestDisabled); } // Gets the number of tests to be printed in the XML report. int TestCase::reportable_test_count() const { return CountIf(test_info_list_, TestReportable); } // Get the number of tests in this test case that should run. int TestCase::test_to_run_count() const { return CountIf(test_info_list_, ShouldRunTest); } // Gets the number of all tests. int TestCase::total_test_count() const { return static_cast<int>(test_info_list_.size()); } // Creates a TestCase with the given name. // // Arguments: // // name: name of the test case // a_type_param: the name of the test case's type parameter, or NULL if // this is not a typed or a type-parameterized test case. // set_up_tc: pointer to the function that sets up the test case // tear_down_tc: pointer to the function that tears down the test case TestCase::TestCase(const char* a_name, const char* a_type_param, Test::SetUpTestCaseFunc set_up_tc, Test::TearDownTestCaseFunc tear_down_tc) : name_(a_name), type_param_(a_type_param ? new std::string(a_type_param) : NULL), set_up_tc_(set_up_tc), tear_down_tc_(tear_down_tc), should_run_(false), elapsed_time_(0) { } // Destructor of TestCase. TestCase::~TestCase() { // Deletes every Test in the collection. ForEach(test_info_list_, internal::Delete<TestInfo>); } // Returns the i-th test among all the tests. i can range from 0 to // total_test_count() - 1. If i is not in that range, returns NULL. const TestInfo* TestCase::GetTestInfo(int i) const { const int index = GetElementOr(test_indices_, i, -1); return index < 0 ? NULL : test_info_list_[index]; } // Returns the i-th test among all the tests. i can range from 0 to // total_test_count() - 1. If i is not in that range, returns NULL. TestInfo* TestCase::GetMutableTestInfo(int i) { const int index = GetElementOr(test_indices_, i, -1); return index < 0 ? NULL : test_info_list_[index]; } // Adds a test to this test case. Will delete the test upon // destruction of the TestCase object. void TestCase::AddTestInfo(TestInfo * test_info) { test_info_list_.push_back(test_info); test_indices_.push_back(static_cast<int>(test_indices_.size())); } // Runs every test in this TestCase. void TestCase::Run() { if (!should_run_) return; internal::UnitTestImpl* const impl = internal::GetUnitTestImpl(); impl->set_current_test_case(this); TestEventListener* repeater = UnitTest::GetInstance()->listeners().repeater(); repeater->OnTestCaseStart(*this); impl->os_stack_trace_getter()->UponLeavingGTest(); internal::HandleExceptionsInMethodIfSupported( this, &TestCase::RunSetUpTestCase, "SetUpTestCase()"); const internal::TimeInMillis start = internal::GetTimeInMillis(); for (int i = 0; i < total_test_count(); i++) { GetMutableTestInfo(i)->Run(); } elapsed_time_ = internal::GetTimeInMillis() - start; impl->os_stack_trace_getter()->UponLeavingGTest(); internal::HandleExceptionsInMethodIfSupported( this, &TestCase::RunTearDownTestCase, "TearDownTestCase()"); repeater->OnTestCaseEnd(*this); impl->set_current_test_case(NULL); } // Clears the results of all tests in this test case. void TestCase::ClearResult() { ad_hoc_test_result_.Clear(); ForEach(test_info_list_, TestInfo::ClearTestResult); } // Shuffles the tests in this test case. void TestCase::ShuffleTests(internal::Random* random) { Shuffle(random, &test_indices_); } // Restores the test order to before the first shuffle. void TestCase::UnshuffleTests() { for (size_t i = 0; i < test_indices_.size(); i++) { test_indices_[i] = static_cast<int>(i); } } // Formats a countable noun. Depending on its quantity, either the // singular form or the plural form is used. e.g. // // FormatCountableNoun(1, "formula", "formuli") returns "1 formula". // FormatCountableNoun(5, "book", "books") returns "5 books". static std::string FormatCountableNoun(int count, const char * singular_form, const char * plural_form) { return internal::StreamableToString(count) + " " + (count == 1 ? singular_form : plural_form); } // Formats the count of tests. static std::string FormatTestCount(int test_count) { return FormatCountableNoun(test_count, "test", "tests"); } // Formats the count of test cases. static std::string FormatTestCaseCount(int test_case_count) { return FormatCountableNoun(test_case_count, "test case", "test cases"); } // Converts a TestPartResult::Type enum to human-friendly string // representation. Both kNonFatalFailure and kFatalFailure are translated // to "Failure", as the user usually doesn't care about the difference // between the two when viewing the test result. static const char * TestPartResultTypeToString(TestPartResult::Type type) { switch (type) { case TestPartResult::kSuccess: return "Success"; case TestPartResult::kNonFatalFailure: case TestPartResult::kFatalFailure: #ifdef _MSC_VER return "error: "; #else return "Failure\n"; #endif default: return "Unknown result type"; } } namespace internal { // Prints a TestPartResult to an std::string. static std::string PrintTestPartResultToString( const TestPartResult& test_part_result) { return (Message() << internal::FormatFileLocation(test_part_result.file_name(), test_part_result.line_number()) << " " << TestPartResultTypeToString(test_part_result.type()) << test_part_result.message()).GetString(); } // Prints a TestPartResult. static void PrintTestPartResult(const TestPartResult& test_part_result) { const std::string& result = PrintTestPartResultToString(test_part_result); printf("%s\n", result.c_str()); fflush(stdout); // If the test program runs in Visual Studio or a debugger, the // following statements add the test part result message to the Output // window such that the user can double-click on it to jump to the // corresponding source code location; otherwise they do nothing. #if GTEST_OS_WINDOWS && !GTEST_OS_WINDOWS_MOBILE // We don't call OutputDebugString*() on Windows Mobile, as printing // to stdout is done by OutputDebugString() there already - we don't // want the same message printed twice. ::OutputDebugStringA(result.c_str()); ::OutputDebugStringA("\n"); #endif } // class PrettyUnitTestResultPrinter enum GTestColor { COLOR_DEFAULT, COLOR_RED, COLOR_GREEN, COLOR_YELLOW }; #if GTEST_OS_WINDOWS && !GTEST_OS_WINDOWS_MOBILE // Returns the character attribute for the given color. WORD GetColorAttribute(GTestColor color) { switch (color) { case COLOR_RED: return FOREGROUND_RED; case COLOR_GREEN: return FOREGROUND_GREEN; case COLOR_YELLOW: return FOREGROUND_RED | FOREGROUND_GREEN; default: return 0; } } #else // Returns the ANSI color code for the given color. COLOR_DEFAULT is // an invalid input. static const char* GetAnsiColorCode(GTestColor color) { switch (color) { case COLOR_RED: return "1"; case COLOR_GREEN: return "2"; case COLOR_YELLOW: return "3"; default: return NULL; }; } #endif // GTEST_OS_WINDOWS && !GTEST_OS_WINDOWS_MOBILE // Returns true iff Google Test should use colors in the output. bool ShouldUseColor(bool stdout_is_tty) { const char* const gtest_color = GTEST_FLAG(color).c_str(); if (String::CaseInsensitiveCStringEquals(gtest_color, "auto")) { #if GTEST_OS_WINDOWS // On Windows the TERM variable is usually not set, but the // console there does support colors. return stdout_is_tty; #else // On non-Windows platforms, we rely on the TERM variable. const char* const term = posix::GetEnv("TERM"); const bool term_supports_color = String::CStringEquals(term, "xterm") || String::CStringEquals(term, "xterm-color") || String::CStringEquals(term, "xterm-256color") || String::CStringEquals(term, "screen") || String::CStringEquals(term, "screen-256color") || String::CStringEquals(term, "linux") || String::CStringEquals(term, "cygwin"); return stdout_is_tty && term_supports_color; #endif // GTEST_OS_WINDOWS } return String::CaseInsensitiveCStringEquals(gtest_color, "yes") || String::CaseInsensitiveCStringEquals(gtest_color, "true") || String::CaseInsensitiveCStringEquals(gtest_color, "t") || String::CStringEquals(gtest_color, "1"); // We take "yes", "true", "t", and "1" as meaning "yes". If the // value is neither one of these nor "auto", we treat it as "no" to // be conservative. } // Helpers for printing colored strings to stdout. Note that on Windows, we // cannot simply emit special characters and have the terminal change colors. // This routine must actually emit the characters rather than return a string // that would be colored when printed, as can be done on Linux. static void ColoredPrintf(GTestColor color, const char* fmt, ...) { va_list args; va_start(args, fmt); #if GTEST_OS_WINDOWS_MOBILE || GTEST_OS_SYMBIAN || GTEST_OS_ZOS || GTEST_OS_IOS const bool use_color = false; #else static const bool in_color_mode = ShouldUseColor(posix::IsATTY(posix::FileNo(stdout)) != 0); const bool use_color = in_color_mode && (color != COLOR_DEFAULT); #endif // GTEST_OS_WINDOWS_MOBILE || GTEST_OS_SYMBIAN || GTEST_OS_ZOS // The '!= 0' comparison is necessary to satisfy MSVC 7.1. if (!use_color) { vprintf(fmt, args); va_end(args); return; } #if GTEST_OS_WINDOWS && !GTEST_OS_WINDOWS_MOBILE const HANDLE stdout_handle = GetStdHandle(STD_OUTPUT_HANDLE); // Gets the current text color. CONSOLE_SCREEN_BUFFER_INFO buffer_info; GetConsoleScreenBufferInfo(stdout_handle, &buffer_info); const WORD old_color_attrs = buffer_info.wAttributes; // We need to flush the stream buffers into the console before each // SetConsoleTextAttribute call lest it affect the text that is already // printed but has not yet reached the console. fflush(stdout); SetConsoleTextAttribute(stdout_handle, GetColorAttribute(color) | FOREGROUND_INTENSITY); vprintf(fmt, args); fflush(stdout); // Restores the text color. SetConsoleTextAttribute(stdout_handle, old_color_attrs); #else printf("\033[0;3%sm", GetAnsiColorCode(color)); vprintf(fmt, args); printf("\033[m"); // Resets the terminal to default. #endif // GTEST_OS_WINDOWS && !GTEST_OS_WINDOWS_MOBILE va_end(args); } // Text printed in Google Test's text output and --gunit_list_tests // output to label the type parameter and value parameter for a test. static const char kTypeParamLabel[] = "TypeParam"; static const char kValueParamLabel[] = "GetParam()"; static void PrintFullTestCommentIfPresent(const TestInfo& test_info) { const char* const type_param = test_info.type_param(); const char* const value_param = test_info.value_param(); if (type_param != NULL || value_param != NULL) { printf(", where "); if (type_param != NULL) { printf("%s = %s", kTypeParamLabel, type_param); if (value_param != NULL) printf(" and "); } if (value_param != NULL) { printf("%s = %s", kValueParamLabel, value_param); } } } // This class implements the TestEventListener interface. // // Class PrettyUnitTestResultPrinter is copyable. class PrettyUnitTestResultPrinter : public TestEventListener { public: PrettyUnitTestResultPrinter() {} static void PrintTestName(const char * test_case, const char * test) { printf("%s.%s", test_case, test); } // The following methods override what's in the TestEventListener class. virtual void OnTestProgramStart(const UnitTest& /*unit_test*/) {} virtual void OnTestIterationStart(const UnitTest& unit_test, int iteration); virtual void OnEnvironmentsSetUpStart(const UnitTest& unit_test); virtual void OnEnvironmentsSetUpEnd(const UnitTest& /*unit_test*/) {} virtual void OnTestCaseStart(const TestCase& test_case); virtual void OnTestStart(const TestInfo& test_info); virtual void OnTestPartResult(const TestPartResult& result); virtual void OnTestEnd(const TestInfo& test_info); virtual void OnTestCaseEnd(const TestCase& test_case); virtual void OnEnvironmentsTearDownStart(const UnitTest& unit_test); virtual void OnEnvironmentsTearDownEnd(const UnitTest& /*unit_test*/) {} virtual void OnTestIterationEnd(const UnitTest& unit_test, int iteration); virtual void OnTestProgramEnd(const UnitTest& /*unit_test*/) {} private: static void PrintFailedTests(const UnitTest& unit_test); }; // Fired before each iteration of tests starts. void PrettyUnitTestResultPrinter::OnTestIterationStart( const UnitTest& unit_test, int iteration) { if (GTEST_FLAG(repeat) != 1) printf("\nRepeating all tests (iteration %d) . . .\n\n", iteration + 1); const char* const filter = GTEST_FLAG(filter).c_str(); // Prints the filter if it's not *. This reminds the user that some // tests may be skipped. if (!String::CStringEquals(filter, kUniversalFilter)) { ColoredPrintf(COLOR_YELLOW, "Note: %s filter = %s\n", GTEST_NAME_, filter); } const char* const param_filter = GTEST_FLAG(param_filter).c_str(); // Ditto. if (!String::CStringEquals(param_filter, kUniversalFilter)) { ColoredPrintf(COLOR_YELLOW, "Note: %s parameter filter = %s\n", GTEST_NAME_, param_filter); } if (internal::ShouldShard(kTestTotalShards, kTestShardIndex, false)) { const Int32 shard_index = Int32FromEnvOrDie(kTestShardIndex, -1); ColoredPrintf(COLOR_YELLOW, "Note: This is test shard %d of %s.\n", static_cast<int>(shard_index) + 1, internal::posix::GetEnv(kTestTotalShards)); } if (GTEST_FLAG(shuffle)) { ColoredPrintf(COLOR_YELLOW, "Note: Randomizing tests' orders with a seed of %d .\n", unit_test.random_seed()); } ColoredPrintf(COLOR_GREEN, "[==========] "); printf("Running %s from %s.\n", FormatTestCount(unit_test.test_to_run_count()).c_str(), FormatTestCaseCount(unit_test.test_case_to_run_count()).c_str()); fflush(stdout); } void PrettyUnitTestResultPrinter::OnEnvironmentsSetUpStart( const UnitTest& /*unit_test*/) { ColoredPrintf(COLOR_GREEN, "[----------] "); printf("Global test environment set-up.\n"); fflush(stdout); } void PrettyUnitTestResultPrinter::OnTestCaseStart(const TestCase& test_case) { const std::string counts = FormatCountableNoun(test_case.test_to_run_count(), "test", "tests"); ColoredPrintf(COLOR_GREEN, "[----------] "); printf("%s from %s", counts.c_str(), test_case.name()); if (test_case.type_param() == NULL) { printf("\n"); } else { printf(", where %s = %s\n", kTypeParamLabel, test_case.type_param()); } fflush(stdout); } void PrettyUnitTestResultPrinter::OnTestStart(const TestInfo& test_info) { ColoredPrintf(COLOR_GREEN, "[ RUN ] "); PrintTestName(test_info.test_case_name(), test_info.name()); printf("\n"); fflush(stdout); } // Called after an assertion failure. void PrettyUnitTestResultPrinter::OnTestPartResult( const TestPartResult& result) { // If the test part succeeded, we don't need to do anything. if (result.type() == TestPartResult::kSuccess) return; // Print failure message from the assertion (e.g. expected this and got that). PrintTestPartResult(result); fflush(stdout); } void PrettyUnitTestResultPrinter::OnTestEnd(const TestInfo& test_info) { if (test_info.result()->Passed()) { ColoredPrintf(COLOR_GREEN, "[ OK ] "); } else { ColoredPrintf(COLOR_RED, "[ FAILED ] "); } PrintTestName(test_info.test_case_name(), test_info.name()); if (test_info.result()->Failed()) PrintFullTestCommentIfPresent(test_info); if (GTEST_FLAG(print_time)) { printf(" (%s ms)\n", internal::StreamableToString( test_info.result()->elapsed_time()).c_str()); } else { printf("\n"); } fflush(stdout); } void PrettyUnitTestResultPrinter::OnTestCaseEnd(const TestCase& test_case) { if (!GTEST_FLAG(print_time)) return; const std::string counts = FormatCountableNoun(test_case.test_to_run_count(), "test", "tests"); ColoredPrintf(COLOR_GREEN, "[----------] "); printf("%s from %s (%s ms total)\n\n", counts.c_str(), test_case.name(), internal::StreamableToString(test_case.elapsed_time()).c_str()); fflush(stdout); } void PrettyUnitTestResultPrinter::OnEnvironmentsTearDownStart( const UnitTest& /*unit_test*/) { ColoredPrintf(COLOR_GREEN, "[----------] "); printf("Global test environment tear-down\n"); fflush(stdout); } // Internal helper for printing the list of failed tests. void PrettyUnitTestResultPrinter::PrintFailedTests(const UnitTest& unit_test) { const int failed_test_count = unit_test.failed_test_count(); if (failed_test_count == 0) { return; } for (int i = 0; i < unit_test.total_test_case_count(); ++i) { const TestCase& test_case = *unit_test.GetTestCase(i); if (!test_case.should_run() || (test_case.failed_test_count() == 0)) { continue; } for (int j = 0; j < test_case.total_test_count(); ++j) { const TestInfo& test_info = *test_case.GetTestInfo(j); if (!test_info.should_run() || test_info.result()->Passed()) { continue; } ColoredPrintf(COLOR_RED, "[ FAILED ] "); printf("%s.%s", test_case.name(), test_info.name()); PrintFullTestCommentIfPresent(test_info); printf("\n"); } } } void PrettyUnitTestResultPrinter::OnTestIterationEnd(const UnitTest& unit_test, int /*iteration*/) { ColoredPrintf(COLOR_GREEN, "[==========] "); printf("%s from %s ran.", FormatTestCount(unit_test.test_to_run_count()).c_str(), FormatTestCaseCount(unit_test.test_case_to_run_count()).c_str()); if (GTEST_FLAG(print_time)) { printf(" (%s ms total)", internal::StreamableToString(unit_test.elapsed_time()).c_str()); } printf("\n"); ColoredPrintf(COLOR_GREEN, "[ PASSED ] "); printf("%s.\n", FormatTestCount(unit_test.successful_test_count()).c_str()); int num_failures = unit_test.failed_test_count(); if (!unit_test.Passed()) { const int failed_test_count = unit_test.failed_test_count(); ColoredPrintf(COLOR_RED, "[ FAILED ] "); printf("%s, listed below:\n", FormatTestCount(failed_test_count).c_str()); PrintFailedTests(unit_test); printf("\n%2d FAILED %s\n", num_failures, num_failures == 1 ? "TEST" : "TESTS"); } int num_disabled = unit_test.reportable_disabled_test_count(); if (num_disabled && !GTEST_FLAG(also_run_disabled_tests)) { if (!num_failures) { printf("\n"); // Add a spacer if no FAILURE banner is displayed. } ColoredPrintf(COLOR_YELLOW, " YOU HAVE %d DISABLED %s\n\n", num_disabled, num_disabled == 1 ? "TEST" : "TESTS"); } // Ensure that Google Test output is printed before, e.g., heapchecker output. fflush(stdout); } // End PrettyUnitTestResultPrinter // class TestEventRepeater // // This class forwards events to other event listeners. class TestEventRepeater : public TestEventListener { public: TestEventRepeater() : forwarding_enabled_(true) {} virtual ~TestEventRepeater(); void Append(TestEventListener *listener); TestEventListener* Release(TestEventListener* listener); // Controls whether events will be forwarded to listeners_. Set to false // in death test child processes. bool forwarding_enabled() const { return forwarding_enabled_; } void set_forwarding_enabled(bool enable) { forwarding_enabled_ = enable; } virtual void OnTestProgramStart(const UnitTest& unit_test); virtual void OnTestIterationStart(const UnitTest& unit_test, int iteration); virtual void OnEnvironmentsSetUpStart(const UnitTest& unit_test); virtual void OnEnvironmentsSetUpEnd(const UnitTest& unit_test); virtual void OnTestCaseStart(const TestCase& test_case); virtual void OnTestStart(const TestInfo& test_info); virtual void OnTestPartResult(const TestPartResult& result); virtual void OnTestEnd(const TestInfo& test_info); virtual void OnTestCaseEnd(const TestCase& test_case); virtual void OnEnvironmentsTearDownStart(const UnitTest& unit_test); virtual void OnEnvironmentsTearDownEnd(const UnitTest& unit_test); virtual void OnTestIterationEnd(const UnitTest& unit_test, int iteration); virtual void OnTestProgramEnd(const UnitTest& unit_test); private: // Controls whether events will be forwarded to listeners_. Set to false // in death test child processes. bool forwarding_enabled_; // The list of listeners that receive events. std::vector<TestEventListener*> listeners_; GTEST_DISALLOW_COPY_AND_ASSIGN_(TestEventRepeater); }; TestEventRepeater::~TestEventRepeater() { ForEach(listeners_, Delete<TestEventListener>); } void TestEventRepeater::Append(TestEventListener *listener) { listeners_.push_back(listener); } // TODO(vladl@google.com): Factor the search functionality into Vector::Find. TestEventListener* TestEventRepeater::Release(TestEventListener *listener) { for (size_t i = 0; i < listeners_.size(); ++i) { if (listeners_[i] == listener) { listeners_.erase(listeners_.begin() + i); return listener; } } return NULL; } // Since most methods are very similar, use macros to reduce boilerplate. // This defines a member that forwards the call to all listeners. #define GTEST_REPEATER_METHOD_(Name, Type) \ void TestEventRepeater::Name(const Type& parameter) { \ if (forwarding_enabled_) { \ for (size_t i = 0; i < listeners_.size(); i++) { \ listeners_[i]->Name(parameter); \ } \ } \ } // This defines a member that forwards the call to all listeners in reverse // order. #define GTEST_REVERSE_REPEATER_METHOD_(Name, Type) \ void TestEventRepeater::Name(const Type& parameter) { \ if (forwarding_enabled_) { \ for (int i = static_cast<int>(listeners_.size()) - 1; i >= 0; i--) { \ listeners_[i]->Name(parameter); \ } \ } \ } GTEST_REPEATER_METHOD_(OnTestProgramStart, UnitTest) GTEST_REPEATER_METHOD_(OnEnvironmentsSetUpStart, UnitTest) GTEST_REPEATER_METHOD_(OnTestCaseStart, TestCase) GTEST_REPEATER_METHOD_(OnTestStart, TestInfo) GTEST_REPEATER_METHOD_(OnTestPartResult, TestPartResult) GTEST_REPEATER_METHOD_(OnEnvironmentsTearDownStart, UnitTest) GTEST_REVERSE_REPEATER_METHOD_(OnEnvironmentsSetUpEnd, UnitTest) GTEST_REVERSE_REPEATER_METHOD_(OnEnvironmentsTearDownEnd, UnitTest) GTEST_REVERSE_REPEATER_METHOD_(OnTestEnd, TestInfo) GTEST_REVERSE_REPEATER_METHOD_(OnTestCaseEnd, TestCase) GTEST_REVERSE_REPEATER_METHOD_(OnTestProgramEnd, UnitTest) #undef GTEST_REPEATER_METHOD_ #undef GTEST_REVERSE_REPEATER_METHOD_ void TestEventRepeater::OnTestIterationStart(const UnitTest& unit_test, int iteration) { if (forwarding_enabled_) { for (size_t i = 0; i < listeners_.size(); i++) { listeners_[i]->OnTestIterationStart(unit_test, iteration); } } } void TestEventRepeater::OnTestIterationEnd(const UnitTest& unit_test, int iteration) { if (forwarding_enabled_) { for (int i = static_cast<int>(listeners_.size()) - 1; i >= 0; i--) { listeners_[i]->OnTestIterationEnd(unit_test, iteration); } } } // End TestEventRepeater // This class generates an XML output file. class XmlUnitTestResultPrinter : public EmptyTestEventListener { public: explicit XmlUnitTestResultPrinter(const char* output_file); virtual void OnTestIterationEnd(const UnitTest& unit_test, int iteration); private: // Is c a whitespace character that is normalized to a space character // when it appears in an XML attribute value? static bool IsNormalizableWhitespace(char c) { return c == 0x9 || c == 0xA || c == 0xD; } // May c appear in a well-formed XML document? static bool IsValidXmlCharacter(char c) { return IsNormalizableWhitespace(c) || c >= 0x20; } // Returns an XML-escaped copy of the input string str. If // is_attribute is true, the text is meant to appear as an attribute // value, and normalizable whitespace is preserved by replacing it // with character references. static std::string EscapeXml(const std::string& str, bool is_attribute); // Returns the given string with all characters invalid in XML removed. static std::string RemoveInvalidXmlCharacters(const std::string& str); // Convenience wrapper around EscapeXml when str is an attribute value. static std::string EscapeXmlAttribute(const std::string& str) { return EscapeXml(str, true); } // Convenience wrapper around EscapeXml when str is not an attribute value. static std::string EscapeXmlText(const char* str) { return EscapeXml(str, false); } // Verifies that the given attribute belongs to the given element and // streams the attribute as XML. static void OutputXmlAttribute(std::ostream* stream, const std::string& element_name, const std::string& name, const std::string& value); // Streams an XML CDATA section, escaping invalid CDATA sequences as needed. static void OutputXmlCDataSection(::std::ostream* stream, const char* data); // Streams an XML representation of a TestInfo object. static void OutputXmlTestInfo(::std::ostream* stream, const char* test_case_name, const TestInfo& test_info); // Prints an XML representation of a TestCase object static void PrintXmlTestCase(::std::ostream* stream, const TestCase& test_case); // Prints an XML summary of unit_test to output stream out. static void PrintXmlUnitTest(::std::ostream* stream, const UnitTest& unit_test); // Produces a string representing the test properties in a result as space // delimited XML attributes based on the property key="value" pairs. // When the std::string is not empty, it includes a space at the beginning, // to delimit this attribute from prior attributes. static std::string TestPropertiesAsXmlAttributes(const TestResult& result); // The output file. const std::string output_file_; GTEST_DISALLOW_COPY_AND_ASSIGN_(XmlUnitTestResultPrinter); }; // Creates a new XmlUnitTestResultPrinter. XmlUnitTestResultPrinter::XmlUnitTestResultPrinter(const char* output_file) : output_file_(output_file) { if (output_file_.c_str() == NULL || output_file_.empty()) { fprintf(stderr, "XML output file may not be null\n"); fflush(stderr); exit(EXIT_FAILURE); } } // Called after the unit test ends. void XmlUnitTestResultPrinter::OnTestIterationEnd(const UnitTest& unit_test, int /*iteration*/) { FILE* xmlout = NULL; FilePath output_file(output_file_); FilePath output_dir(output_file.RemoveFileName()); if (output_dir.CreateDirectoriesRecursively()) { xmlout = posix::FOpen(output_file_.c_str(), "w"); } if (xmlout == NULL) { // TODO(wan): report the reason of the failure. // // We don't do it for now as: // // 1. There is no urgent need for it. // 2. It's a bit involved to make the errno variable thread-safe on // all three operating systems (Linux, Windows, and Mac OS). // 3. To interpret the meaning of errno in a thread-safe way, // we need the strerror_r() function, which is not available on // Windows. fprintf(stderr, "Unable to open file \"%s\"\n", output_file_.c_str()); fflush(stderr); exit(EXIT_FAILURE); } std::stringstream stream; PrintXmlUnitTest(&stream, unit_test); fprintf(xmlout, "%s", StringStreamToString(&stream).c_str()); fclose(xmlout); } // Returns an XML-escaped copy of the input string str. If is_attribute // is true, the text is meant to appear as an attribute value, and // normalizable whitespace is preserved by replacing it with character // references. // // Invalid XML characters in str, if any, are stripped from the output. // It is expected that most, if not all, of the text processed by this // module will consist of ordinary English text. // If this module is ever modified to produce version 1.1 XML output, // most invalid characters can be retained using character references. // TODO(wan): It might be nice to have a minimally invasive, human-readable // escaping scheme for invalid characters, rather than dropping them. std::string XmlUnitTestResultPrinter::EscapeXml( const std::string& str, bool is_attribute) { Message m; for (size_t i = 0; i < str.size(); ++i) { const char ch = str[i]; switch (ch) { case '<': m << "&lt;"; break; case '>': m << "&gt;"; break; case '&': m << "&amp;"; break; case '\'': if (is_attribute) m << "&apos;"; else m << '\''; break; case '"': if (is_attribute) m << "&quot;"; else m << '"'; break; default: if (IsValidXmlCharacter(ch)) { if (is_attribute && IsNormalizableWhitespace(ch)) m << "&#x" << String::FormatByte(static_cast<unsigned char>(ch)) << ";"; else m << ch; } break; } } return m.GetString(); } // Returns the given string with all characters invalid in XML removed. // Currently invalid characters are dropped from the string. An // alternative is to replace them with certain characters such as . or ?. std::string XmlUnitTestResultPrinter::RemoveInvalidXmlCharacters( const std::string& str) { std::string output; output.reserve(str.size()); for (std::string::const_iterator it = str.begin(); it != str.end(); ++it) if (IsValidXmlCharacter(*it)) output.push_back(*it); return output; } // The following routines generate an XML representation of a UnitTest // object. // // This is how Google Test concepts map to the DTD: // // <testsuites name="AllTests"> <-- corresponds to a UnitTest object // <testsuite name="testcase-name"> <-- corresponds to a TestCase object // <testcase name="test-name"> <-- corresponds to a TestInfo object // <failure message="...">...</failure> // <failure message="...">...</failure> // <failure message="...">...</failure> // <-- individual assertion failures // </testcase> // </testsuite> // </testsuites> // Formats the given time in milliseconds as seconds. std::string FormatTimeInMillisAsSeconds(TimeInMillis ms) { ::std::stringstream ss; ss << ms/1000.0; return ss.str(); } // Converts the given epoch time in milliseconds to a date string in the ISO // 8601 format, without the timezone information. std::string FormatEpochTimeInMillisAsIso8601(TimeInMillis ms) { // Using non-reentrant version as localtime_r is not portable. time_t seconds = static_cast<time_t>(ms / 1000); #ifdef _MSC_VER # pragma warning(push) // Saves the current warning state. # pragma warning(disable:4996) // Temporarily disables warning 4996 // (function or variable may be unsafe). const struct tm* const time_struct = localtime(&seconds); // NOLINT # pragma warning(pop) // Restores the warning state again. #else const struct tm* const time_struct = localtime(&seconds); // NOLINT #endif if (time_struct == NULL) return ""; // Invalid ms value // YYYY-MM-DDThh:mm:ss return StreamableToString(time_struct->tm_year + 1900) + "-" + String::FormatIntWidth2(time_struct->tm_mon + 1) + "-" + String::FormatIntWidth2(time_struct->tm_mday) + "T" + String::FormatIntWidth2(time_struct->tm_hour) + ":" + String::FormatIntWidth2(time_struct->tm_min) + ":" + String::FormatIntWidth2(time_struct->tm_sec); } // Streams an XML CDATA section, escaping invalid CDATA sequences as needed. void XmlUnitTestResultPrinter::OutputXmlCDataSection(::std::ostream* stream, const char* data) { const char* segment = data; *stream << "<![CDATA["; for (;;) { const char* const next_segment = strstr(segment, "]]>"); if (next_segment != NULL) { stream->write( segment, static_cast<std::streamsize>(next_segment - segment)); *stream << "]]>]]&gt;<![CDATA["; segment = next_segment + strlen("]]>"); } else { *stream << segment; break; } } *stream << "]]>"; } void XmlUnitTestResultPrinter::OutputXmlAttribute( std::ostream* stream, const std::string& element_name, const std::string& name, const std::string& value) { const std::vector<std::string>& allowed_names = GetReservedAttributesForElement(element_name); GTEST_CHECK_(std::find(allowed_names.begin(), allowed_names.end(), name) != allowed_names.end()) << "Attribute " << name << " is not allowed for element <" << element_name << ">."; *stream << " " << name << "=\"" << EscapeXmlAttribute(value) << "\""; } // Prints an XML representation of a TestInfo object. // TODO(wan): There is also value in printing properties with the plain printer. void XmlUnitTestResultPrinter::OutputXmlTestInfo(::std::ostream* stream, const char* test_case_name, const TestInfo& test_info) { const TestResult& result = *test_info.result(); const std::string kTestcase = "testcase"; *stream << " <testcase"; OutputXmlAttribute(stream, kTestcase, "name", test_info.name()); if (test_info.value_param() != NULL) { OutputXmlAttribute(stream, kTestcase, "value_param", test_info.value_param()); } if (test_info.type_param() != NULL) { OutputXmlAttribute(stream, kTestcase, "type_param", test_info.type_param()); } OutputXmlAttribute(stream, kTestcase, "status", test_info.should_run() ? "run" : "notrun"); OutputXmlAttribute(stream, kTestcase, "time", FormatTimeInMillisAsSeconds(result.elapsed_time())); OutputXmlAttribute(stream, kTestcase, "classname", test_case_name); *stream << TestPropertiesAsXmlAttributes(result); int failures = 0; for (int i = 0; i < result.total_part_count(); ++i) { const TestPartResult& part = result.GetTestPartResult(i); if (part.failed()) { if (++failures == 1) { *stream << ">\n"; } const string location = internal::FormatCompilerIndependentFileLocation( part.file_name(), part.line_number()); const string summary = location + "\n" + part.summary(); *stream << " <failure message=\"" << EscapeXmlAttribute(summary.c_str()) << "\" type=\"\">"; const string detail = location + "\n" + part.message(); OutputXmlCDataSection(stream, RemoveInvalidXmlCharacters(detail).c_str()); *stream << "</failure>\n"; } } if (failures == 0) *stream << " />\n"; else *stream << " </testcase>\n"; } // Prints an XML representation of a TestCase object void XmlUnitTestResultPrinter::PrintXmlTestCase(std::ostream* stream, const TestCase& test_case) { const std::string kTestsuite = "testsuite"; *stream << " <" << kTestsuite; OutputXmlAttribute(stream, kTestsuite, "name", test_case.name()); OutputXmlAttribute(stream, kTestsuite, "tests", StreamableToString(test_case.reportable_test_count())); OutputXmlAttribute(stream, kTestsuite, "failures", StreamableToString(test_case.failed_test_count())); OutputXmlAttribute( stream, kTestsuite, "disabled", StreamableToString(test_case.reportable_disabled_test_count())); OutputXmlAttribute(stream, kTestsuite, "errors", "0"); OutputXmlAttribute(stream, kTestsuite, "time", FormatTimeInMillisAsSeconds(test_case.elapsed_time())); *stream << TestPropertiesAsXmlAttributes(test_case.ad_hoc_test_result()) << ">\n"; for (int i = 0; i < test_case.total_test_count(); ++i) { if (test_case.GetTestInfo(i)->is_reportable()) OutputXmlTestInfo(stream, test_case.name(), *test_case.GetTestInfo(i)); } *stream << " </" << kTestsuite << ">\n"; } // Prints an XML summary of unit_test to output stream out. void XmlUnitTestResultPrinter::PrintXmlUnitTest(std::ostream* stream, const UnitTest& unit_test) { const std::string kTestsuites = "testsuites"; *stream << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"; *stream << "<" << kTestsuites; OutputXmlAttribute(stream, kTestsuites, "tests", StreamableToString(unit_test.reportable_test_count())); OutputXmlAttribute(stream, kTestsuites, "failures", StreamableToString(unit_test.failed_test_count())); OutputXmlAttribute( stream, kTestsuites, "disabled", StreamableToString(unit_test.reportable_disabled_test_count())); OutputXmlAttribute(stream, kTestsuites, "errors", "0"); OutputXmlAttribute( stream, kTestsuites, "timestamp", FormatEpochTimeInMillisAsIso8601(unit_test.start_timestamp())); OutputXmlAttribute(stream, kTestsuites, "time", FormatTimeInMillisAsSeconds(unit_test.elapsed_time())); if (GTEST_FLAG(shuffle)) { OutputXmlAttribute(stream, kTestsuites, "random_seed", StreamableToString(unit_test.random_seed())); } *stream << TestPropertiesAsXmlAttributes(unit_test.ad_hoc_test_result()); OutputXmlAttribute(stream, kTestsuites, "name", "AllTests"); *stream << ">\n"; for (int i = 0; i < unit_test.total_test_case_count(); ++i) { if (unit_test.GetTestCase(i)->reportable_test_count() > 0) PrintXmlTestCase(stream, *unit_test.GetTestCase(i)); } *stream << "</" << kTestsuites << ">\n"; } // Produces a string representing the test properties in a result as space // delimited XML attributes based on the property key="value" pairs. std::string XmlUnitTestResultPrinter::TestPropertiesAsXmlAttributes( const TestResult& result) { Message attributes; for (int i = 0; i < result.test_property_count(); ++i) { const TestProperty& property = result.GetTestProperty(i); attributes << " " << property.key() << "=" << "\"" << EscapeXmlAttribute(property.value()) << "\""; } return attributes.GetString(); } // End XmlUnitTestResultPrinter #if GTEST_CAN_STREAM_RESULTS_ // Checks if str contains '=', '&', '%' or '\n' characters. If yes, // replaces them by "%xx" where xx is their hexadecimal value. For // example, replaces "=" with "%3D". This algorithm is O(strlen(str)) // in both time and space -- important as the input str may contain an // arbitrarily long test failure message and stack trace. string StreamingListener::UrlEncode(const char* str) { string result; result.reserve(strlen(str) + 1); for (char ch = *str; ch != '\0'; ch = *++str) { switch (ch) { case '%': case '=': case '&': case '\n': result.append("%" + String::FormatByte(static_cast<unsigned char>(ch))); break; default: result.push_back(ch); break; } } return result; } void StreamingListener::SocketWriter::MakeConnection() { GTEST_CHECK_(sockfd_ == -1) << "MakeConnection() can't be called when there is already a connection."; addrinfo hints; memset(&hints, 0, sizeof(hints)); hints.ai_family = AF_UNSPEC; // To allow both IPv4 and IPv6 addresses. hints.ai_socktype = SOCK_STREAM; addrinfo* servinfo = NULL; // Use the getaddrinfo() to get a linked list of IP addresses for // the given host name. const int error_num = getaddrinfo( host_name_.c_str(), port_num_.c_str(), &hints, &servinfo); if (error_num != 0) { GTEST_LOG_(WARNING) << "stream_result_to: getaddrinfo() failed: " << gai_strerror(error_num); } // Loop through all the results and connect to the first we can. for (addrinfo* cur_addr = servinfo; sockfd_ == -1 && cur_addr != NULL; cur_addr = cur_addr->ai_next) { sockfd_ = socket( cur_addr->ai_family, cur_addr->ai_socktype, cur_addr->ai_protocol); if (sockfd_ != -1) { // Connect the client socket to the server socket. if (connect(sockfd_, cur_addr->ai_addr, cur_addr->ai_addrlen) == -1) { close(sockfd_); sockfd_ = -1; } } } freeaddrinfo(servinfo); // all done with this structure if (sockfd_ == -1) { GTEST_LOG_(WARNING) << "stream_result_to: failed to connect to " << host_name_ << ":" << port_num_; } } // End of class Streaming Listener #endif // GTEST_CAN_STREAM_RESULTS__ // Class ScopedTrace // Pushes the given source file location and message onto a per-thread // trace stack maintained by Google Test. ScopedTrace::ScopedTrace(const char* file, int line, const Message& message) GTEST_LOCK_EXCLUDED_(&UnitTest::mutex_) { TraceInfo trace; trace.file = file; trace.line = line; trace.message = message.GetString(); UnitTest::GetInstance()->PushGTestTrace(trace); } // Pops the info pushed by the c'tor. ScopedTrace::~ScopedTrace() GTEST_LOCK_EXCLUDED_(&UnitTest::mutex_) { UnitTest::GetInstance()->PopGTestTrace(); } // class OsStackTraceGetter // Returns the current OS stack trace as an std::string. Parameters: // // max_depth - the maximum number of stack frames to be included // in the trace. // skip_count - the number of top frames to be skipped; doesn't count // against max_depth. // string OsStackTraceGetter::CurrentStackTrace(int /* max_depth */, int /* skip_count */) GTEST_LOCK_EXCLUDED_(mutex_) { return ""; } void OsStackTraceGetter::UponLeavingGTest() GTEST_LOCK_EXCLUDED_(mutex_) { } const char* const OsStackTraceGetter::kElidedFramesMarker = "... " GTEST_NAME_ " internal frames ..."; // A helper class that creates the premature-exit file in its // constructor and deletes the file in its destructor. class ScopedPrematureExitFile { public: explicit ScopedPrematureExitFile(const char* premature_exit_filepath) : premature_exit_filepath_(premature_exit_filepath) { // If a path to the premature-exit file is specified... if (premature_exit_filepath != NULL && *premature_exit_filepath != '\0') { // create the file with a single "0" character in it. I/O // errors are ignored as there's nothing better we can do and we // don't want to fail the test because of this. FILE* pfile = posix::FOpen(premature_exit_filepath, "w"); fwrite("0", 1, 1, pfile); fclose(pfile); } } ~ScopedPrematureExitFile() { if (premature_exit_filepath_ != NULL && *premature_exit_filepath_ != '\0') { remove(premature_exit_filepath_); } } private: const char* const premature_exit_filepath_; GTEST_DISALLOW_COPY_AND_ASSIGN_(ScopedPrematureExitFile); }; } // namespace internal // class TestEventListeners TestEventListeners::TestEventListeners() : repeater_(new internal::TestEventRepeater()), default_result_printer_(NULL), default_xml_generator_(NULL) { } TestEventListeners::~TestEventListeners() { delete repeater_; } // Returns the standard listener responsible for the default console // output. Can be removed from the listeners list to shut down default // console output. Note that removing this object from the listener list // with Release transfers its ownership to the user. void TestEventListeners::Append(TestEventListener* listener) { repeater_->Append(listener); } // Removes the given event listener from the list and returns it. It then // becomes the caller's responsibility to delete the listener. Returns // NULL if the listener is not found in the list. TestEventListener* TestEventListeners::Release(TestEventListener* listener) { if (listener == default_result_printer_) default_result_printer_ = NULL; else if (listener == default_xml_generator_) default_xml_generator_ = NULL; return repeater_->Release(listener); } // Returns repeater that broadcasts the TestEventListener events to all // subscribers. TestEventListener* TestEventListeners::repeater() { return repeater_; } // Sets the default_result_printer attribute to the provided listener. // The listener is also added to the listener list and previous // default_result_printer is removed from it and deleted. The listener can // also be NULL in which case it will not be added to the list. Does // nothing if the previous and the current listener objects are the same. void TestEventListeners::SetDefaultResultPrinter(TestEventListener* listener) { if (default_result_printer_ != listener) { // It is an error to pass this method a listener that is already in the // list. delete Release(default_result_printer_); default_result_printer_ = listener; if (listener != NULL) Append(listener); } } // Sets the default_xml_generator attribute to the provided listener. The // listener is also added to the listener list and previous // default_xml_generator is removed from it and deleted. The listener can // also be NULL in which case it will not be added to the list. Does // nothing if the previous and the current listener objects are the same. void TestEventListeners::SetDefaultXmlGenerator(TestEventListener* listener) { if (default_xml_generator_ != listener) { // It is an error to pass this method a listener that is already in the // list. delete Release(default_xml_generator_); default_xml_generator_ = listener; if (listener != NULL) Append(listener); } } // Controls whether events will be forwarded by the repeater to the // listeners in the list. bool TestEventListeners::EventForwardingEnabled() const { return repeater_->forwarding_enabled(); } void TestEventListeners::SuppressEventForwarding() { repeater_->set_forwarding_enabled(false); } // class UnitTest // Gets the singleton UnitTest object. The first time this method is // called, a UnitTest object is constructed and returned. Consecutive // calls will return the same object. // // We don't protect this under mutex_ as a user is not supposed to // call this before main() starts, from which point on the return // value will never change. UnitTest * UnitTest::GetInstance() { // When compiled with MSVC 7.1 in optimized mode, destroying the // UnitTest object upon exiting the program messes up the exit code, // causing successful tests to appear failed. We have to use a // different implementation in this case to bypass the compiler bug. // This implementation makes the compiler happy, at the cost of // leaking the UnitTest object. // CodeGear C++Builder insists on a public destructor for the // default implementation. Use this implementation to keep good OO // design with private destructor. #if (defined(_MSC_VER) && _MSC_VER == 1310 && !defined(_DEBUG)) || defined(__BORLANDC__) static UnitTest* const instance = new UnitTest; return instance; #else static UnitTest instance; return &instance; #endif // (defined(_MSC_VER) && _MSC_VER == 1310 && !defined(_DEBUG)) || defined(__BORLANDC__) } // Gets the number of successful test cases. int UnitTest::successful_test_case_count() const { return impl()->successful_test_case_count(); } // Gets the number of failed test cases. int UnitTest::failed_test_case_count() const { return impl()->failed_test_case_count(); } // Gets the number of all test cases. int UnitTest::total_test_case_count() const { return impl()->total_test_case_count(); } // Gets the number of all test cases that contain at least one test // that should run. int UnitTest::test_case_to_run_count() const { return impl()->test_case_to_run_count(); } // Gets the number of successful tests. int UnitTest::successful_test_count() const { return impl()->successful_test_count(); } // Gets the number of failed tests. int UnitTest::failed_test_count() const { return impl()->failed_test_count(); } // Gets the number of disabled tests that will be reported in the XML report. int UnitTest::reportable_disabled_test_count() const { return impl()->reportable_disabled_test_count(); } // Gets the number of disabled tests. int UnitTest::disabled_test_count() const { return impl()->disabled_test_count(); } // Gets the number of tests to be printed in the XML report. int UnitTest::reportable_test_count() const { return impl()->reportable_test_count(); } // Gets the number of all tests. int UnitTest::total_test_count() const { return impl()->total_test_count(); } // Gets the number of tests that should run. int UnitTest::test_to_run_count() const { return impl()->test_to_run_count(); } // Gets the time of the test program start, in ms from the start of the // UNIX epoch. internal::TimeInMillis UnitTest::start_timestamp() const { return impl()->start_timestamp(); } // Gets the elapsed time, in milliseconds. internal::TimeInMillis UnitTest::elapsed_time() const { return impl()->elapsed_time(); } // Returns true iff the unit test passed (i.e. all test cases passed). bool UnitTest::Passed() const { return impl()->Passed(); } // Returns true iff the unit test failed (i.e. some test case failed // or something outside of all tests failed). bool UnitTest::Failed() const { return impl()->Failed(); } // Gets the i-th test case among all the test cases. i can range from 0 to // total_test_case_count() - 1. If i is not in that range, returns NULL. const TestCase* UnitTest::GetTestCase(int i) const { return impl()->GetTestCase(i); } // Returns the TestResult containing information on test failures and // properties logged outside of individual test cases. const TestResult& UnitTest::ad_hoc_test_result() const { return *impl()->ad_hoc_test_result(); } // Gets the i-th test case among all the test cases. i can range from 0 to // total_test_case_count() - 1. If i is not in that range, returns NULL. TestCase* UnitTest::GetMutableTestCase(int i) { return impl()->GetMutableTestCase(i); } // Returns the list of event listeners that can be used to track events // inside Google Test. TestEventListeners& UnitTest::listeners() { return *impl()->listeners(); } // Registers and returns a global test environment. When a test // program is run, all global test environments will be set-up in the // order they were registered. After all tests in the program have // finished, all global test environments will be torn-down in the // *reverse* order they were registered. // // The UnitTest object takes ownership of the given environment. // // We don't protect this under mutex_, as we only support calling it // from the main thread. Environment* UnitTest::AddEnvironment(Environment* env) { if (env == NULL) { return NULL; } impl_->environments().push_back(env); return env; } // Adds a TestPartResult to the current TestResult object. All Google Test // assertion macros (e.g. ASSERT_TRUE, EXPECT_EQ, etc) eventually call // this to report their results. The user code should use the // assertion macros instead of calling this directly. void UnitTest::AddTestPartResult( TestPartResult::Type result_type, const char* file_name, int line_number, const std::string& message, const std::string& os_stack_trace) GTEST_LOCK_EXCLUDED_(mutex_) { Message msg; msg << message; internal::MutexLock lock(&mutex_); if (impl_->gtest_trace_stack().size() > 0) { msg << "\n" << GTEST_NAME_ << " trace:"; for (int i = static_cast<int>(impl_->gtest_trace_stack().size()); i > 0; --i) { const internal::TraceInfo& trace = impl_->gtest_trace_stack()[i - 1]; msg << "\n" << internal::FormatFileLocation(trace.file, trace.line) << " " << trace.message; } } if (os_stack_trace.c_str() != NULL && !os_stack_trace.empty()) { msg << internal::kStackTraceMarker << os_stack_trace; } const TestPartResult result = TestPartResult(result_type, file_name, line_number, msg.GetString().c_str()); impl_->GetTestPartResultReporterForCurrentThread()-> ReportTestPartResult(result); if (result_type != TestPartResult::kSuccess) { // gtest_break_on_failure takes precedence over // gtest_throw_on_failure. This allows a user to set the latter // in the code (perhaps in order to use Google Test assertions // with another testing framework) and specify the former on the // command line for debugging. if (GTEST_FLAG(break_on_failure)) { #if GTEST_OS_WINDOWS // Using DebugBreak on Windows allows gtest to still break into a debugger // when a failure happens and both the --gtest_break_on_failure and // the --gtest_catch_exceptions flags are specified. DebugBreak(); #else // Dereference NULL through a volatile pointer to prevent the compiler // from removing. We use this rather than abort() or __builtin_trap() for // portability: Symbian doesn't implement abort() well, and some debuggers // don't correctly trap abort(). *static_cast<volatile int*>(NULL) = 1; #endif // GTEST_OS_WINDOWS } else if (GTEST_FLAG(throw_on_failure)) { #if GTEST_HAS_EXCEPTIONS throw internal::GoogleTestFailureException(result); #else // We cannot call abort() as it generates a pop-up in debug mode // that cannot be suppressed in VC 7.1 or below. exit(1); #endif } } } // Adds a TestProperty to the current TestResult object when invoked from // inside a test, to current TestCase's ad_hoc_test_result_ when invoked // from SetUpTestCase or TearDownTestCase, or to the global property set // when invoked elsewhere. If the result already contains a property with // the same key, the value will be updated. void UnitTest::RecordProperty(const std::string& key, const std::string& value) { impl_->RecordProperty(TestProperty(key, value)); } // Runs all tests in this UnitTest object and prints the result. // Returns 0 if successful, or 1 otherwise. // // We don't protect this under mutex_, as we only support calling it // from the main thread. int UnitTest::Run() { const bool in_death_test_child_process = internal::GTEST_FLAG(internal_run_death_test).length() > 0; // Google Test implements this protocol for catching that a test // program exits before returning control to Google Test: // // 1. Upon start, Google Test creates a file whose absolute path // is specified by the environment variable // TEST_PREMATURE_EXIT_FILE. // 2. When Google Test has finished its work, it deletes the file. // // This allows a test runner to set TEST_PREMATURE_EXIT_FILE before // running a Google-Test-based test program and check the existence // of the file at the end of the test execution to see if it has // exited prematurely. // If we are in the child process of a death test, don't // create/delete the premature exit file, as doing so is unnecessary // and will confuse the parent process. Otherwise, create/delete // the file upon entering/leaving this function. If the program // somehow exits before this function has a chance to return, the // premature-exit file will be left undeleted, causing a test runner // that understands the premature-exit-file protocol to report the // test as having failed. const internal::ScopedPrematureExitFile premature_exit_file( in_death_test_child_process ? NULL : internal::posix::GetEnv("TEST_PREMATURE_EXIT_FILE")); // Captures the value of GTEST_FLAG(catch_exceptions). This value will be // used for the duration of the program. impl()->set_catch_exceptions(GTEST_FLAG(catch_exceptions)); #if GTEST_HAS_SEH // Either the user wants Google Test to catch exceptions thrown by the // tests or this is executing in the context of death test child // process. In either case the user does not want to see pop-up dialogs // about crashes - they are expected. if (impl()->catch_exceptions() || in_death_test_child_process) { # if !GTEST_OS_WINDOWS_MOBILE // SetErrorMode doesn't exist on CE. SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOALIGNMENTFAULTEXCEPT | SEM_NOGPFAULTERRORBOX | SEM_NOOPENFILEERRORBOX); # endif // !GTEST_OS_WINDOWS_MOBILE # if (defined(_MSC_VER) || GTEST_OS_WINDOWS_MINGW) && !GTEST_OS_WINDOWS_MOBILE // Death test children can be terminated with _abort(). On Windows, // _abort() can show a dialog with a warning message. This forces the // abort message to go to stderr instead. _set_error_mode(_OUT_TO_STDERR); # endif # if _MSC_VER >= 1400 && !GTEST_OS_WINDOWS_MOBILE // In the debug version, Visual Studio pops up a separate dialog // offering a choice to debug the aborted program. We need to suppress // this dialog or it will pop up for every EXPECT/ASSERT_DEATH statement // executed. Google Test will notify the user of any unexpected // failure via stderr. // // VC++ doesn't define _set_abort_behavior() prior to the version 8.0. // Users of prior VC versions shall suffer the agony and pain of // clicking through the countless debug dialogs. // TODO(vladl@google.com): find a way to suppress the abort dialog() in the // debug mode when compiled with VC 7.1 or lower. if (!GTEST_FLAG(break_on_failure)) _set_abort_behavior( 0x0, // Clear the following flags: _WRITE_ABORT_MSG | _CALL_REPORTFAULT); // pop-up window, core dump. # endif } #endif // GTEST_HAS_SEH return internal::HandleExceptionsInMethodIfSupported( impl(), &internal::UnitTestImpl::RunAllTests, "auxiliary test code (environments or event listeners)") ? 0 : 1; } // Returns the working directory when the first TEST() or TEST_F() was // executed. const char* UnitTest::original_working_dir() const { return impl_->original_working_dir_.c_str(); } // Returns the TestCase object for the test that's currently running, // or NULL if no test is running. const TestCase* UnitTest::current_test_case() const GTEST_LOCK_EXCLUDED_(mutex_) { internal::MutexLock lock(&mutex_); return impl_->current_test_case(); } // Returns the TestInfo object for the test that's currently running, // or NULL if no test is running. const TestInfo* UnitTest::current_test_info() const GTEST_LOCK_EXCLUDED_(mutex_) { internal::MutexLock lock(&mutex_); return impl_->current_test_info(); } // Returns the random seed used at the start of the current test run. int UnitTest::random_seed() const { return impl_->random_seed(); } #if GTEST_HAS_PARAM_TEST // Returns ParameterizedTestCaseRegistry object used to keep track of // value-parameterized tests and instantiate and register them. internal::ParameterizedTestCaseRegistry& UnitTest::parameterized_test_registry() GTEST_LOCK_EXCLUDED_(mutex_) { return impl_->parameterized_test_registry(); } #endif // GTEST_HAS_PARAM_TEST // Creates an empty UnitTest. UnitTest::UnitTest() { impl_ = new internal::UnitTestImpl(this); } // Destructor of UnitTest. UnitTest::~UnitTest() { delete impl_; } // Pushes a trace defined by SCOPED_TRACE() on to the per-thread // Google Test trace stack. void UnitTest::PushGTestTrace(const internal::TraceInfo& trace) GTEST_LOCK_EXCLUDED_(mutex_) { internal::MutexLock lock(&mutex_); impl_->gtest_trace_stack().push_back(trace); } // Pops a trace from the per-thread Google Test trace stack. void UnitTest::PopGTestTrace() GTEST_LOCK_EXCLUDED_(mutex_) { internal::MutexLock lock(&mutex_); impl_->gtest_trace_stack().pop_back(); } namespace internal { UnitTestImpl::UnitTestImpl(UnitTest* parent) : parent_(parent), #ifdef _MSC_VER # pragma warning(push) // Saves the current warning state. # pragma warning(disable:4355) // Temporarily disables warning 4355 // (using this in initializer). default_global_test_part_result_reporter_(this), default_per_thread_test_part_result_reporter_(this), # pragma warning(pop) // Restores the warning state again. #else default_global_test_part_result_reporter_(this), default_per_thread_test_part_result_reporter_(this), #endif // _MSC_VER global_test_part_result_repoter_( &default_global_test_part_result_reporter_), per_thread_test_part_result_reporter_( &default_per_thread_test_part_result_reporter_), #if GTEST_HAS_PARAM_TEST parameterized_test_registry_(), parameterized_tests_registered_(false), #endif // GTEST_HAS_PARAM_TEST last_death_test_case_(-1), current_test_case_(NULL), current_test_info_(NULL), ad_hoc_test_result_(), os_stack_trace_getter_(NULL), post_flag_parse_init_performed_(false), random_seed_(0), // Will be overridden by the flag before first use. random_(0), // Will be reseeded before first use. start_timestamp_(0), elapsed_time_(0), #if GTEST_HAS_DEATH_TEST death_test_factory_(new DefaultDeathTestFactory), #endif // Will be overridden by the flag before first use. catch_exceptions_(false) { listeners()->SetDefaultResultPrinter(new PrettyUnitTestResultPrinter); } UnitTestImpl::~UnitTestImpl() { // Deletes every TestCase. ForEach(test_cases_, internal::Delete<TestCase>); // Deletes every Environment. ForEach(environments_, internal::Delete<Environment>); delete os_stack_trace_getter_; } // Adds a TestProperty to the current TestResult object when invoked in a // context of a test, to current test case's ad_hoc_test_result when invoke // from SetUpTestCase/TearDownTestCase, or to the global property set // otherwise. If the result already contains a property with the same key, // the value will be updated. void UnitTestImpl::RecordProperty(const TestProperty& test_property) { std::string xml_element; TestResult* test_result; // TestResult appropriate for property recording. if (current_test_info_ != NULL) { xml_element = "testcase"; test_result = &(current_test_info_->result_); } else if (current_test_case_ != NULL) { xml_element = "testsuite"; test_result = &(current_test_case_->ad_hoc_test_result_); } else { xml_element = "testsuites"; test_result = &ad_hoc_test_result_; } test_result->RecordProperty(xml_element, test_property); } #if GTEST_HAS_DEATH_TEST // Disables event forwarding if the control is currently in a death test // subprocess. Must not be called before InitGoogleTest. void UnitTestImpl::SuppressTestEventsIfInSubprocess() { if (internal_run_death_test_flag_.get() != NULL) listeners()->SuppressEventForwarding(); } #endif // GTEST_HAS_DEATH_TEST // Initializes event listeners performing XML output as specified by // UnitTestOptions. Must not be called before InitGoogleTest. void UnitTestImpl::ConfigureXmlOutput() { const std::string& output_format = UnitTestOptions::GetOutputFormat(); if (output_format == "xml") { listeners()->SetDefaultXmlGenerator(new XmlUnitTestResultPrinter( UnitTestOptions::GetAbsolutePathToOutputFile().c_str())); } else if (output_format != "") { printf("WARNING: unrecognized output format \"%s\" ignored.\n", output_format.c_str()); fflush(stdout); } } #if GTEST_CAN_STREAM_RESULTS_ // Initializes event listeners for streaming test results in string form. // Must not be called before InitGoogleTest. void UnitTestImpl::ConfigureStreamingOutput() { const std::string& target = GTEST_FLAG(stream_result_to); if (!target.empty()) { const size_t pos = target.find(':'); if (pos != std::string::npos) { listeners()->Append(new StreamingListener(target.substr(0, pos), target.substr(pos+1))); } else { printf("WARNING: unrecognized streaming target \"%s\" ignored.\n", target.c_str()); fflush(stdout); } } } #endif // GTEST_CAN_STREAM_RESULTS_ // Performs initialization dependent upon flag values obtained in // ParseGoogleTestFlagsOnly. Is called from InitGoogleTest after the call to // ParseGoogleTestFlagsOnly. In case a user neglects to call InitGoogleTest // this function is also called from RunAllTests. Since this function can be // called more than once, it has to be idempotent. void UnitTestImpl::PostFlagParsingInit() { // Ensures that this function does not execute more than once. if (!post_flag_parse_init_performed_) { post_flag_parse_init_performed_ = true; #if GTEST_HAS_DEATH_TEST InitDeathTestSubprocessControlInfo(); SuppressTestEventsIfInSubprocess(); #endif // GTEST_HAS_DEATH_TEST // Registers parameterized tests. This makes parameterized tests // available to the UnitTest reflection API without running // RUN_ALL_TESTS. RegisterParameterizedTests(); // Configures listeners for XML output. This makes it possible for users // to shut down the default XML output before invoking RUN_ALL_TESTS. ConfigureXmlOutput(); #if GTEST_CAN_STREAM_RESULTS_ // Configures listeners for streaming test results to the specified server. ConfigureStreamingOutput(); #endif // GTEST_CAN_STREAM_RESULTS_ } } // A predicate that checks the name of a TestCase against a known // value. // // This is used for implementation of the UnitTest class only. We put // it in the anonymous namespace to prevent polluting the outer // namespace. // // TestCaseNameIs is copyable. class TestCaseNameIs { public: // Constructor. explicit TestCaseNameIs(const std::string& name) : name_(name) {} // Returns true iff the name of test_case matches name_. bool operator()(const TestCase* test_case) const { return test_case != NULL && strcmp(test_case->name(), name_.c_str()) == 0; } private: std::string name_; }; // Finds and returns a TestCase with the given name. If one doesn't // exist, creates one and returns it. It's the CALLER'S // RESPONSIBILITY to ensure that this function is only called WHEN THE // TESTS ARE NOT SHUFFLED. // // Arguments: // // test_case_name: name of the test case // type_param: the name of the test case's type parameter, or NULL if // this is not a typed or a type-parameterized test case. // set_up_tc: pointer to the function that sets up the test case // tear_down_tc: pointer to the function that tears down the test case TestCase* UnitTestImpl::GetTestCase(const char* test_case_name, const char* type_param, Test::SetUpTestCaseFunc set_up_tc, Test::TearDownTestCaseFunc tear_down_tc) { // Can we find a TestCase with the given name? const std::vector<TestCase*>::const_iterator test_case = std::find_if(test_cases_.begin(), test_cases_.end(), TestCaseNameIs(test_case_name)); if (test_case != test_cases_.end()) return *test_case; // No. Let's create one. TestCase* const new_test_case = new TestCase(test_case_name, type_param, set_up_tc, tear_down_tc); // Is this a death test case? if (internal::UnitTestOptions::MatchesFilter(test_case_name, kDeathTestCaseFilter)) { // Yes. Inserts the test case after the last death test case // defined so far. This only works when the test cases haven't // been shuffled. Otherwise we may end up running a death test // after a non-death test. ++last_death_test_case_; test_cases_.insert(test_cases_.begin() + last_death_test_case_, new_test_case); } else { // No. Appends to the end of the list. test_cases_.push_back(new_test_case); } test_case_indices_.push_back(static_cast<int>(test_case_indices_.size())); return new_test_case; } // Helpers for setting up / tearing down the given environment. They // are for use in the ForEach() function. static void SetUpEnvironment(Environment* env) { env->SetUp(); } static void TearDownEnvironment(Environment* env) { env->TearDown(); } // Runs all tests in this UnitTest object, prints the result, and // returns true if all tests are successful. If any exception is // thrown during a test, the test is considered to be failed, but the // rest of the tests will still be run. // // When parameterized tests are enabled, it expands and registers // parameterized tests first in RegisterParameterizedTests(). // All other functions called from RunAllTests() may safely assume that // parameterized tests are ready to be counted and run. bool UnitTestImpl::RunAllTests() { // Makes sure InitGoogleTest() was called. if (!GTestIsInitialized()) { printf("%s", "\nThis test program did NOT call ::testing::InitGoogleTest " "before calling RUN_ALL_TESTS(). Please fix it.\n"); return false; } // Do not run any test if the --help flag was specified. if (g_help_flag) return true; // Repeats the call to the post-flag parsing initialization in case the // user didn't call InitGoogleTest. PostFlagParsingInit(); // Even if sharding is not on, test runners may want to use the // GTEST_SHARD_STATUS_FILE to query whether the test supports the sharding // protocol. internal::WriteToShardStatusFileIfNeeded(); // True iff we are in a subprocess for running a thread-safe-style // death test. bool in_subprocess_for_death_test = false; #if GTEST_HAS_DEATH_TEST in_subprocess_for_death_test = (internal_run_death_test_flag_.get() != NULL); #endif // GTEST_HAS_DEATH_TEST const bool should_shard = ShouldShard(kTestTotalShards, kTestShardIndex, in_subprocess_for_death_test); // Compares the full test names with the filter to decide which // tests to run. const bool has_tests_to_run = FilterTests(should_shard ? HONOR_SHARDING_PROTOCOL : IGNORE_SHARDING_PROTOCOL) > 0; // Lists the tests and exits if the --gtest_list_tests flag was specified. if (GTEST_FLAG(list_tests)) { // This must be called *after* FilterTests() has been called. ListTestsMatchingFilter(); return true; } random_seed_ = GTEST_FLAG(shuffle) ? GetRandomSeedFromFlag(GTEST_FLAG(random_seed)) : 0; // True iff at least one test has failed. bool failed = false; TestEventListener* repeater = listeners()->repeater(); start_timestamp_ = GetTimeInMillis(); repeater->OnTestProgramStart(*parent_); // How many times to repeat the tests? We don't want to repeat them // when we are inside the subprocess of a death test. const int repeat = in_subprocess_for_death_test ? 1 : GTEST_FLAG(repeat); // Repeats forever if the repeat count is negative. const bool forever = repeat < 0; for (int i = 0; forever || i != repeat; i++) { // We want to preserve failures generated by ad-hoc test // assertions executed before RUN_ALL_TESTS(). ClearNonAdHocTestResult(); const TimeInMillis start = GetTimeInMillis(); // Shuffles test cases and tests if requested. if (has_tests_to_run && GTEST_FLAG(shuffle)) { random()->Reseed(random_seed_); // This should be done before calling OnTestIterationStart(), // such that a test event listener can see the actual test order // in the event. ShuffleTests(); } // Tells the unit test event listeners that the tests are about to start. repeater->OnTestIterationStart(*parent_, i); // Runs each test case if there is at least one test to run. if (has_tests_to_run) { // Sets up all environments beforehand. repeater->OnEnvironmentsSetUpStart(*parent_); ForEach(environments_, SetUpEnvironment); repeater->OnEnvironmentsSetUpEnd(*parent_); // Runs the tests only if there was no fatal failure during global // set-up. if (!Test::HasFatalFailure()) { for (int test_index = 0; test_index < total_test_case_count(); test_index++) { GetMutableTestCase(test_index)->Run(); } } // Tears down all environments in reverse order afterwards. repeater->OnEnvironmentsTearDownStart(*parent_); std::for_each(environments_.rbegin(), environments_.rend(), TearDownEnvironment); repeater->OnEnvironmentsTearDownEnd(*parent_); } elapsed_time_ = GetTimeInMillis() - start; // Tells the unit test event listener that the tests have just finished. repeater->OnTestIterationEnd(*parent_, i); // Gets the result and clears it. if (!Passed()) { failed = true; } // Restores the original test order after the iteration. This // allows the user to quickly repro a failure that happens in the // N-th iteration without repeating the first (N - 1) iterations. // This is not enclosed in "if (GTEST_FLAG(shuffle)) { ... }", in // case the user somehow changes the value of the flag somewhere // (it's always safe to unshuffle the tests). UnshuffleTests(); if (GTEST_FLAG(shuffle)) { // Picks a new random seed for each iteration. random_seed_ = GetNextRandomSeed(random_seed_); } } repeater->OnTestProgramEnd(*parent_); return !failed; } // Reads the GTEST_SHARD_STATUS_FILE environment variable, and creates the file // if the variable is present. If a file already exists at this location, this // function will write over it. If the variable is present, but the file cannot // be created, prints an error and exits. void WriteToShardStatusFileIfNeeded() { const char* const test_shard_file = posix::GetEnv(kTestShardStatusFile); if (test_shard_file != NULL) { FILE* const file = posix::FOpen(test_shard_file, "w"); if (file == NULL) { ColoredPrintf(COLOR_RED, "Could not write to the test shard status file \"%s\" " "specified by the %s environment variable.\n", test_shard_file, kTestShardStatusFile); fflush(stdout); exit(EXIT_FAILURE); } fclose(file); } } // Checks whether sharding is enabled by examining the relevant // environment variable values. If the variables are present, // but inconsistent (i.e., shard_index >= total_shards), prints // an error and exits. If in_subprocess_for_death_test, sharding is // disabled because it must only be applied to the original test // process. Otherwise, we could filter out death tests we intended to execute. bool ShouldShard(const char* total_shards_env, const char* shard_index_env, bool in_subprocess_for_death_test) { if (in_subprocess_for_death_test) { return false; } const Int32 total_shards = Int32FromEnvOrDie(total_shards_env, -1); const Int32 shard_index = Int32FromEnvOrDie(shard_index_env, -1); if (total_shards == -1 && shard_index == -1) { return false; } else if (total_shards == -1 && shard_index != -1) { const Message msg = Message() << "Invalid environment variables: you have " << kTestShardIndex << " = " << shard_index << ", but have left " << kTestTotalShards << " unset.\n"; ColoredPrintf(COLOR_RED, msg.GetString().c_str()); fflush(stdout); exit(EXIT_FAILURE); } else if (total_shards != -1 && shard_index == -1) { const Message msg = Message() << "Invalid environment variables: you have " << kTestTotalShards << " = " << total_shards << ", but have left " << kTestShardIndex << " unset.\n"; ColoredPrintf(COLOR_RED, msg.GetString().c_str()); fflush(stdout); exit(EXIT_FAILURE); } else if (shard_index < 0 || shard_index >= total_shards) { const Message msg = Message() << "Invalid environment variables: we require 0 <= " << kTestShardIndex << " < " << kTestTotalShards << ", but you have " << kTestShardIndex << "=" << shard_index << ", " << kTestTotalShards << "=" << total_shards << ".\n"; ColoredPrintf(COLOR_RED, msg.GetString().c_str()); fflush(stdout); exit(EXIT_FAILURE); } return total_shards > 1; } // Parses the environment variable var as an Int32. If it is unset, // returns default_val. If it is not an Int32, prints an error // and aborts. Int32 Int32FromEnvOrDie(const char* var, Int32 default_val) { const char* str_val = posix::GetEnv(var); if (str_val == NULL) { return default_val; } Int32 result; if (!ParseInt32(Message() << "The value of environment variable " << var, str_val, &result)) { exit(EXIT_FAILURE); } return result; } // Given the total number of shards, the shard index, and the test id, // returns true iff the test should be run on this shard. The test id is // some arbitrary but unique non-negative integer assigned to each test // method. Assumes that 0 <= shard_index < total_shards. bool ShouldRunTestOnShard(int total_shards, int shard_index, int test_id) { return (test_id % total_shards) == shard_index; } // Compares the name of each test with the user-specified filter to // decide whether the test should be run, then records the result in // each TestCase and TestInfo object. // If shard_tests == true, further filters tests based on sharding // variables in the environment - see // http://code.google.com/p/googletest/wiki/GoogleTestAdvancedGuide. // Returns the number of tests that should run. int UnitTestImpl::FilterTests(ReactionToSharding shard_tests) { const Int32 total_shards = shard_tests == HONOR_SHARDING_PROTOCOL ? Int32FromEnvOrDie(kTestTotalShards, -1) : -1; const Int32 shard_index = shard_tests == HONOR_SHARDING_PROTOCOL ? Int32FromEnvOrDie(kTestShardIndex, -1) : -1; // num_runnable_tests are the number of tests that will // run across all shards (i.e., match filter and are not disabled). // num_selected_tests are the number of tests to be run on // this shard. int num_runnable_tests = 0; int num_selected_tests = 0; for (size_t i = 0; i < test_cases_.size(); i++) { TestCase* const test_case = test_cases_[i]; const std::string &test_case_name = test_case->name(); test_case->set_should_run(false); for (size_t j = 0; j < test_case->test_info_list().size(); j++) { TestInfo* const test_info = test_case->test_info_list()[j]; const std::string test_name(test_info->name()); // A test is disabled if test case name or test name matches // kDisableTestFilter. const bool is_disabled = internal::UnitTestOptions::MatchesFilter(test_case_name, kDisableTestFilter) || internal::UnitTestOptions::MatchesFilter(test_name, kDisableTestFilter); test_info->is_disabled_ = is_disabled; const std::string value_param(test_info->value_param() == NULL ? "" : test_info->value_param()); const bool matches_filter = internal::UnitTestOptions::FilterMatchesTest(test_case_name, test_name) && internal::UnitTestOptions::MatchesFilter(value_param, GTEST_FLAG(param_filter).c_str()); test_info->matches_filter_ = matches_filter; const bool is_runnable = (GTEST_FLAG(also_run_disabled_tests) || !is_disabled) && matches_filter; const bool is_selected = is_runnable && (shard_tests == IGNORE_SHARDING_PROTOCOL || ShouldRunTestOnShard(total_shards, shard_index, num_runnable_tests)); num_runnable_tests += is_runnable; num_selected_tests += is_selected; test_info->should_run_ = is_selected; test_case->set_should_run(test_case->should_run() || is_selected); } } return num_selected_tests; } // Prints the given C-string on a single line by replacing all '\n' // characters with string "\\n". If the output takes more than // max_length characters, only prints the first max_length characters // and "...". static void PrintOnOneLine(const char* str, int max_length) { if (str != NULL) { for (int i = 0; *str != '\0'; ++str) { if (i >= max_length) { printf("..."); break; } if (*str == '\n') { printf("\\n"); i += 2; } else { printf("%c", *str); ++i; } } } } // Prints the names of the tests matching the user-specified filter flag. void UnitTestImpl::ListTestsMatchingFilter() { // Print at most this many characters for each type/value parameter. const int kMaxParamLength = 250; for (size_t i = 0; i < test_cases_.size(); i++) { const TestCase* const test_case = test_cases_[i]; bool printed_test_case_name = false; for (size_t j = 0; j < test_case->test_info_list().size(); j++) { const TestInfo* const test_info = test_case->test_info_list()[j]; if (test_info->matches_filter_) { if (!printed_test_case_name) { printed_test_case_name = true; printf("%s.", test_case->name()); if (test_case->type_param() != NULL) { printf(" # %s = ", kTypeParamLabel); // We print the type parameter on a single line to make // the output easy to parse by a program. PrintOnOneLine(test_case->type_param(), kMaxParamLength); } printf("\n"); } printf(" %s", test_info->name()); if (test_info->value_param() != NULL) { printf(" # %s = ", kValueParamLabel); // We print the value parameter on a single line to make the // output easy to parse by a program. PrintOnOneLine(test_info->value_param(), kMaxParamLength); } printf("\n"); } } } fflush(stdout); } // Sets the OS stack trace getter. // // Does nothing if the input and the current OS stack trace getter are // the same; otherwise, deletes the old getter and makes the input the // current getter. void UnitTestImpl::set_os_stack_trace_getter( OsStackTraceGetterInterface* getter) { if (os_stack_trace_getter_ != getter) { delete os_stack_trace_getter_; os_stack_trace_getter_ = getter; } } // Returns the current OS stack trace getter if it is not NULL; // otherwise, creates an OsStackTraceGetter, makes it the current // getter, and returns it. OsStackTraceGetterInterface* UnitTestImpl::os_stack_trace_getter() { if (os_stack_trace_getter_ == NULL) { os_stack_trace_getter_ = new OsStackTraceGetter; } return os_stack_trace_getter_; } // Returns the TestResult for the test that's currently running, or // the TestResult for the ad hoc test if no test is running. TestResult* UnitTestImpl::current_test_result() { return current_test_info_ ? &(current_test_info_->result_) : &ad_hoc_test_result_; } // Shuffles all test cases, and the tests within each test case, // making sure that death tests are still run first. void UnitTestImpl::ShuffleTests() { // Shuffles the death test cases. ShuffleRange(random(), 0, last_death_test_case_ + 1, &test_case_indices_); // Shuffles the non-death test cases. ShuffleRange(random(), last_death_test_case_ + 1, static_cast<int>(test_cases_.size()), &test_case_indices_); // Shuffles the tests inside each test case. for (size_t i = 0; i < test_cases_.size(); i++) { test_cases_[i]->ShuffleTests(random()); } } // Restores the test cases and tests to their order before the first shuffle. void UnitTestImpl::UnshuffleTests() { for (size_t i = 0; i < test_cases_.size(); i++) { // Unshuffles the tests in each test case. test_cases_[i]->UnshuffleTests(); // Resets the index of each test case. test_case_indices_[i] = static_cast<int>(i); } } // Returns the current OS stack trace as an std::string. // // The maximum number of stack frames to be included is specified by // the gtest_stack_trace_depth flag. The skip_count parameter // specifies the number of top frames to be skipped, which doesn't // count against the number of frames to be included. // // For example, if Foo() calls Bar(), which in turn calls // GetCurrentOsStackTraceExceptTop(..., 1), Foo() will be included in // the trace but Bar() and GetCurrentOsStackTraceExceptTop() won't. std::string GetCurrentOsStackTraceExceptTop(UnitTest* /*unit_test*/, int skip_count) { // We pass skip_count + 1 to skip this wrapper function in addition // to what the user really wants to skip. return GetUnitTestImpl()->CurrentOsStackTraceExceptTop(skip_count + 1); } // Used by the GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_ macro to // suppress unreachable code warnings. namespace { class ClassUniqueToAlwaysTrue {}; } bool IsTrue(bool condition) { return condition; } bool AlwaysTrue() { #if GTEST_HAS_EXCEPTIONS // This condition is always false so AlwaysTrue() never actually throws, // but it makes the compiler think that it may throw. if (IsTrue(false)) throw ClassUniqueToAlwaysTrue(); #endif // GTEST_HAS_EXCEPTIONS return true; } // If *pstr starts with the given prefix, modifies *pstr to be right // past the prefix and returns true; otherwise leaves *pstr unchanged // and returns false. None of pstr, *pstr, and prefix can be NULL. bool SkipPrefix(const char* prefix, const char** pstr) { const size_t prefix_len = strlen(prefix); if (strncmp(*pstr, prefix, prefix_len) == 0) { *pstr += prefix_len; return true; } return false; } // Parses a string as a command line flag. The string should have // the format "--flag=value". When def_optional is true, the "=value" // part can be omitted. // // Returns the value of the flag, or NULL if the parsing failed. static const char* ParseFlagValue(const char* str, const char* flag, bool def_optional) { // str and flag must not be NULL. if (str == NULL || flag == NULL) return NULL; // The flag must start with "--" followed by GTEST_FLAG_PREFIX_. const std::string flag_str = std::string("--") + GTEST_FLAG_PREFIX_ + flag; const size_t flag_len = flag_str.length(); if (strncmp(str, flag_str.c_str(), flag_len) != 0) return NULL; // Skips the flag name. const char* flag_end = str + flag_len; // When def_optional is true, it's OK to not have a "=value" part. if (def_optional && (flag_end[0] == '\0')) { return flag_end; } // If def_optional is true and there are more characters after the // flag name, or if def_optional is false, there must be a '=' after // the flag name. if (flag_end[0] != '=') return NULL; // Returns the string after "=". return flag_end + 1; } // Parses a string for a bool flag, in the form of either // "--flag=value" or "--flag". // // In the former case, the value is taken as true as long as it does // not start with '0', 'f', or 'F'. // // In the latter case, the value is taken as true. // // On success, stores the value of the flag in *value, and returns // true. On failure, returns false without changing *value. static bool ParseBoolFlag(const char* str, const char* flag, bool* value) { // Gets the value of the flag as a string. const char* const value_str = ParseFlagValue(str, flag, true); // Aborts if the parsing failed. if (value_str == NULL) return false; // Converts the string value to a bool. *value = !(*value_str == '0' || *value_str == 'f' || *value_str == 'F'); return true; } // Parses a string for an Int32 flag, in the form of // "--flag=value". // // On success, stores the value of the flag in *value, and returns // true. On failure, returns false without changing *value. bool ParseInt32Flag(const char* str, const char* flag, Int32* value) { // Gets the value of the flag as a string. const char* const value_str = ParseFlagValue(str, flag, false); // Aborts if the parsing failed. if (value_str == NULL) return false; // Sets *value to the value of the flag. return ParseInt32(Message() << "The value of flag --" << flag, value_str, value); } // Parses a string for a string flag, in the form of // "--flag=value". // // On success, stores the value of the flag in *value, and returns // true. On failure, returns false without changing *value. static bool ParseStringFlag(const char* str, const char* flag, std::string* value) { // Gets the value of the flag as a string. const char* const value_str = ParseFlagValue(str, flag, false); // Aborts if the parsing failed. if (value_str == NULL) return false; // Sets *value to the value of the flag. *value = value_str; return true; } // Determines whether a string has a prefix that Google Test uses for its // flags, i.e., starts with GTEST_FLAG_PREFIX_ or GTEST_FLAG_PREFIX_DASH_. // If Google Test detects that a command line flag has its prefix but is not // recognized, it will print its help message. Flags starting with // GTEST_INTERNAL_PREFIX_ followed by "internal_" are considered Google Test // internal flags and do not trigger the help message. static bool HasGoogleTestFlagPrefix(const char* str) { return (SkipPrefix("--", &str) || SkipPrefix("-", &str) || SkipPrefix("/", &str)) && !SkipPrefix(GTEST_FLAG_PREFIX_ "internal_", &str) && (SkipPrefix(GTEST_FLAG_PREFIX_, &str) || SkipPrefix(GTEST_FLAG_PREFIX_DASH_, &str)); } // Prints a string containing code-encoded text. The following escape // sequences can be used in the string to control the text color: // // @@ prints a single '@' character. // @R changes the color to red. // @G changes the color to green. // @Y changes the color to yellow. // @D changes to the default terminal text color. // // TODO(wan@google.com): Write tests for this once we add stdout // capturing to Google Test. static void PrintColorEncoded(const char* str) { GTestColor color = COLOR_DEFAULT; // The current color. // Conceptually, we split the string into segments divided by escape // sequences. Then we print one segment at a time. At the end of // each iteration, the str pointer advances to the beginning of the // next segment. for (;;) { const char* p = strchr(str, '@'); if (p == NULL) { ColoredPrintf(color, "%s", str); return; } ColoredPrintf(color, "%s", std::string(str, p).c_str()); const char ch = p[1]; str = p + 2; if (ch == '@') { ColoredPrintf(color, "@"); } else if (ch == 'D') { color = COLOR_DEFAULT; } else if (ch == 'R') { color = COLOR_RED; } else if (ch == 'G') { color = COLOR_GREEN; } else if (ch == 'Y') { color = COLOR_YELLOW; } else { --str; } } } static const char kColorEncodedHelpMessage[] = "This program contains tests written using " GTEST_NAME_ ". You can use the\n" "following command line flags to control its behavior:\n" "\n" "Test Selection:\n" " @G--" GTEST_FLAG_PREFIX_ "list_tests@D\n" " List the names of all tests instead of running them. The name of\n" " TEST(Foo, Bar) is \"Foo.Bar\".\n" " @G--" GTEST_FLAG_PREFIX_ "filter=@YPOSTIVE_PATTERNS" "[@G-@YNEGATIVE_PATTERNS]@D\n" " Run only the tests whose name matches one of the positive patterns but\n" " none of the negative patterns. '?' matches any single character; '*'\n" " matches any substring; ':' separates two patterns.\n" " @G--" GTEST_FLAG_PREFIX_ "param_filter=@YPOSITIVE_PATTERNS" "[@G-@YNEGATIVE_PATTERNS]@D\n" " Like @G--" GTEST_FLAG_PREFIX_ "filter@D, but applies to the test's parameter. If a\n" " test is not parameterized, its parameter is considered to be the\n" " empty string.\n" " @G--" GTEST_FLAG_PREFIX_ "also_run_disabled_tests@D\n" " Run all disabled tests too.\n" "\n" "Test Execution:\n" " @G--" GTEST_FLAG_PREFIX_ "repeat=@Y[COUNT]@D\n" " Run the tests repeatedly; use a negative count to repeat forever.\n" " @G--" GTEST_FLAG_PREFIX_ "shuffle@D\n" " Randomize tests' orders on every iteration.\n" " @G--" GTEST_FLAG_PREFIX_ "random_seed=@Y[NUMBER]@D\n" " Random number seed to use for shuffling test orders (between 1 and\n" " 99999, or 0 to use a seed based on the current time).\n" "\n" "Test Output:\n" " @G--" GTEST_FLAG_PREFIX_ "color=@Y(@Gyes@Y|@Gno@Y|@Gauto@Y)@D\n" " Enable/disable colored output. The default is @Gauto@D.\n" " -@G-" GTEST_FLAG_PREFIX_ "print_time=0@D\n" " Don't print the elapsed time of each test.\n" " @G--" GTEST_FLAG_PREFIX_ "output=xml@Y[@G:@YDIRECTORY_PATH@G" GTEST_PATH_SEP_ "@Y|@G:@YFILE_PATH]@D\n" " Generate an XML report in the given directory or with the given file\n" " name. @YFILE_PATH@D defaults to @Gtest_details.xml@D.\n" #if GTEST_CAN_STREAM_RESULTS_ " @G--" GTEST_FLAG_PREFIX_ "stream_result_to=@YHOST@G:@YPORT@D\n" " Stream test results to the given server.\n" #endif // GTEST_CAN_STREAM_RESULTS_ "\n" "Assertion Behavior:\n" #if GTEST_HAS_DEATH_TEST && !GTEST_OS_WINDOWS " @G--" GTEST_FLAG_PREFIX_ "death_test_style=@Y(@Gfast@Y|@Gthreadsafe@Y)@D\n" " Set the default death test style.\n" #endif // GTEST_HAS_DEATH_TEST && !GTEST_OS_WINDOWS " @G--" GTEST_FLAG_PREFIX_ "break_on_failure@D\n" " Turn assertion failures into debugger break-points.\n" " @G--" GTEST_FLAG_PREFIX_ "throw_on_failure@D\n" " Turn assertion failures into C++ exceptions.\n" " @G--" GTEST_FLAG_PREFIX_ "catch_exceptions=0@D\n" " Do not report exceptions as test failures. Instead, allow them\n" " to crash the program or throw a pop-up (on Windows).\n" "\n" "Except for @G--" GTEST_FLAG_PREFIX_ "list_tests@D, you can alternatively set " "the corresponding\n" "environment variable of a flag (all letters in upper-case). For example, to\n" "disable colored text output, you can either specify @G--" GTEST_FLAG_PREFIX_ "color=no@D or set\n" "the @G" GTEST_FLAG_PREFIX_UPPER_ "COLOR@D environment variable to @Gno@D.\n" "\n" "For more information, please read the " GTEST_NAME_ " documentation at\n" "@G" GTEST_PROJECT_URL_ "@D. If you find a bug in " GTEST_NAME_ "\n" "(not one in your own code or tests), please report it to\n" "@G<" GTEST_DEV_EMAIL_ ">@D.\n"; // Parses the command line for Google Test flags, without initializing // other parts of Google Test. The type parameter CharType can be // instantiated to either char or wchar_t. template <typename CharType> void ParseGoogleTestFlagsOnlyImpl(int* argc, CharType** argv) { for (int i = 1; i < *argc; i++) { const std::string arg_string = StreamableToString(argv[i]); const char* const arg = arg_string.c_str(); using internal::ParseBoolFlag; using internal::ParseInt32Flag; using internal::ParseStringFlag; // Do we see a Google Test flag? if (ParseBoolFlag(arg, kAlsoRunDisabledTestsFlag, &GTEST_FLAG(also_run_disabled_tests)) || ParseBoolFlag(arg, kBreakOnFailureFlag, &GTEST_FLAG(break_on_failure)) || ParseBoolFlag(arg, kCatchExceptionsFlag, &GTEST_FLAG(catch_exceptions)) || ParseStringFlag(arg, kColorFlag, &GTEST_FLAG(color)) || ParseStringFlag(arg, kDeathTestStyleFlag, &GTEST_FLAG(death_test_style)) || ParseBoolFlag(arg, kDeathTestUseFork, &GTEST_FLAG(death_test_use_fork)) || ParseStringFlag(arg, kFilterFlag, &GTEST_FLAG(filter)) || ParseStringFlag(arg, kParamFilterFlag, &GTEST_FLAG(param_filter)) || ParseStringFlag(arg, kInternalRunDeathTestFlag, &GTEST_FLAG(internal_run_death_test)) || ParseBoolFlag(arg, kListTestsFlag, &GTEST_FLAG(list_tests)) || ParseStringFlag(arg, kOutputFlag, &GTEST_FLAG(output)) || ParseBoolFlag(arg, kPrintTimeFlag, &GTEST_FLAG(print_time)) || ParseInt32Flag(arg, kRandomSeedFlag, &GTEST_FLAG(random_seed)) || ParseInt32Flag(arg, kRepeatFlag, &GTEST_FLAG(repeat)) || ParseBoolFlag(arg, kShuffleFlag, &GTEST_FLAG(shuffle)) || ParseInt32Flag(arg, kStackTraceDepthFlag, &GTEST_FLAG(stack_trace_depth)) || ParseStringFlag(arg, kStreamResultToFlag, &GTEST_FLAG(stream_result_to)) || ParseBoolFlag(arg, kThrowOnFailureFlag, &GTEST_FLAG(throw_on_failure)) ) { // Yes. Shift the remainder of the argv list left by one. Note // that argv has (*argc + 1) elements, the last one always being // NULL. The following loop moves the trailing NULL element as // well. for (int j = i; j != *argc; j++) { argv[j] = argv[j + 1]; } // Decrements the argument count. (*argc)--; // We also need to decrement the iterator as we just removed // an element. i--; } else if (arg_string == "--help" || arg_string == "-h" || arg_string == "-?" || arg_string == "/?" || HasGoogleTestFlagPrefix(arg)) { // Both help flag and unrecognized Google Test flags (excluding // internal ones) trigger help display. g_help_flag = true; } } if (g_help_flag) { // We print the help here instead of in RUN_ALL_TESTS(), as the // latter may not be called at all if the user is using Google // Test with another testing framework. PrintColorEncoded(kColorEncodedHelpMessage); } } // Parses the command line for Google Test flags, without initializing // other parts of Google Test. void ParseGoogleTestFlagsOnly(int* argc, char** argv) { ParseGoogleTestFlagsOnlyImpl(argc, argv); } void ParseGoogleTestFlagsOnly(int* argc, wchar_t** argv) { ParseGoogleTestFlagsOnlyImpl(argc, argv); } // The internal implementation of InitGoogleTest(). // // The type parameter CharType can be instantiated to either char or // wchar_t. template <typename CharType> void InitGoogleTestImpl(int* argc, CharType** argv) { g_init_gtest_count++; // We don't want to run the initialization code twice. if (g_init_gtest_count != 1) return; if (*argc <= 0) return; internal::g_executable_path = internal::StreamableToString(argv[0]); #if GTEST_HAS_DEATH_TEST g_argvs.clear(); for (int i = 0; i != *argc; i++) { g_argvs.push_back(StreamableToString(argv[i])); } #endif // GTEST_HAS_DEATH_TEST ParseGoogleTestFlagsOnly(argc, argv); GetUnitTestImpl()->PostFlagParsingInit(); } } // namespace internal // Initializes Google Test. This must be called before calling // RUN_ALL_TESTS(). In particular, it parses a command line for the // flags that Google Test recognizes. Whenever a Google Test flag is // seen, it is removed from argv, and *argc is decremented. // // No value is returned. Instead, the Google Test flag variables are // updated. // // Calling the function for the second time has no user-visible effect. void InitGoogleTest(int* argc, char** argv) { internal::InitGoogleTestImpl(argc, argv); } // This overloaded version can be used in Windows programs compiled in // UNICODE mode. void InitGoogleTest(int* argc, wchar_t** argv) { internal::InitGoogleTestImpl(argc, argv); } } // namespace testing // Copyright 2005, Google Inc. // 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. // * Neither the name of Google Inc. nor the names of its // contributors may be used to endorse or promote products derived from // this software without specific prior written permission. // // 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 // OWNER 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. // // Author: wan@google.com (Zhanyong Wan), vladl@google.com (Vlad Losev) // // This file implements death tests. #if GTEST_HAS_DEATH_TEST # if GTEST_OS_MAC # include <crt_externs.h> # endif // GTEST_OS_MAC # include <errno.h> # include <fcntl.h> # include <limits.h> # if GTEST_OS_LINUX # include <signal.h> # endif // GTEST_OS_LINUX # include <stdarg.h> # if GTEST_OS_WINDOWS # include <windows.h> # else # include <sys/mman.h> # include <sys/wait.h> # endif // GTEST_OS_WINDOWS # if GTEST_OS_QNX # include <spawn.h> # endif // GTEST_OS_QNX #endif // GTEST_HAS_DEATH_TEST // Indicates that this translation unit is part of Google Test's // implementation. It must come before gtest-internal-inl.h is // included, or there will be a compiler error. This trick is to // prevent a user from accidentally including gtest-internal-inl.h in // his code. #define GTEST_IMPLEMENTATION_ 1 #undef GTEST_IMPLEMENTATION_ namespace testing { // Constants. // The default death test style. static const char kDefaultDeathTestStyle[] = "fast"; GTEST_DEFINE_string_( death_test_style, internal::StringFromGTestEnv("death_test_style", kDefaultDeathTestStyle), "Indicates how to run a death test in a forked child process: " "\"threadsafe\" (child process re-executes the test binary " "from the beginning, running only the specific death test) or " "\"fast\" (child process runs the death test immediately " "after forking)."); GTEST_DEFINE_bool_( death_test_use_fork, internal::BoolFromGTestEnv("death_test_use_fork", false), "Instructs to use fork()/_exit() instead of clone() in death tests. " "Ignored and always uses fork() on POSIX systems where clone() is not " "implemented. Useful when running under valgrind or similar tools if " "those do not support clone(). Valgrind 3.3.1 will just fail if " "it sees an unsupported combination of clone() flags. " "It is not recommended to use this flag w/o valgrind though it will " "work in 99% of the cases. Once valgrind is fixed, this flag will " "most likely be removed."); namespace internal { GTEST_DEFINE_string_( internal_run_death_test, "", "Indicates the file, line number, temporal index of " "the single death test to run, and a file descriptor to " "which a success code may be sent, all separated by " "the '|' characters. This flag is specified if and only if the current " "process is a sub-process launched for running a thread-safe " "death test. FOR INTERNAL USE ONLY."); } // namespace internal #if GTEST_HAS_DEATH_TEST namespace internal { // Valid only for fast death tests. Indicates the code is running in the // child process of a fast style death test. # if !GTEST_OS_WINDOWS static bool g_in_fast_death_test_child = false; # endif // Returns a Boolean value indicating whether the caller is currently // executing in the context of the death test child process. Tools such as // Valgrind heap checkers may need this to modify their behavior in death // tests. IMPORTANT: This is an internal utility. Using it may break the // implementation of death tests. User code MUST NOT use it. bool InDeathTestChild() { # if GTEST_OS_WINDOWS // On Windows, death tests are thread-safe regardless of the value of the // death_test_style flag. return !GTEST_FLAG(internal_run_death_test).empty(); # else if (GTEST_FLAG(death_test_style) == "threadsafe") return !GTEST_FLAG(internal_run_death_test).empty(); else return g_in_fast_death_test_child; #endif } } // namespace internal // ExitedWithCode constructor. ExitedWithCode::ExitedWithCode(int exit_code) : exit_code_(exit_code) { } // ExitedWithCode function-call operator. bool ExitedWithCode::operator()(int exit_status) const { # if GTEST_OS_WINDOWS return exit_status == exit_code_; # else return WIFEXITED(exit_status) && WEXITSTATUS(exit_status) == exit_code_; # endif // GTEST_OS_WINDOWS } # if !GTEST_OS_WINDOWS // KilledBySignal constructor. KilledBySignal::KilledBySignal(int signum) : signum_(signum) { } // KilledBySignal function-call operator. bool KilledBySignal::operator()(int exit_status) const { return WIFSIGNALED(exit_status) && WTERMSIG(exit_status) == signum_; } # endif // !GTEST_OS_WINDOWS namespace internal { // Utilities needed for death tests. // Generates a textual description of a given exit code, in the format // specified by wait(2). static std::string ExitSummary(int exit_code) { Message m; # if GTEST_OS_WINDOWS m << "Exited with exit status " << exit_code; # else if (WIFEXITED(exit_code)) { m << "Exited with exit status " << WEXITSTATUS(exit_code); } else if (WIFSIGNALED(exit_code)) { m << "Terminated by signal " << WTERMSIG(exit_code); } # ifdef WCOREDUMP if (WCOREDUMP(exit_code)) { m << " (core dumped)"; } # endif # endif // GTEST_OS_WINDOWS return m.GetString(); } // Returns true if exit_status describes a process that was terminated // by a signal, or exited normally with a nonzero exit code. bool ExitedUnsuccessfully(int exit_status) { return !ExitedWithCode(0)(exit_status); } # if !GTEST_OS_WINDOWS // Generates a textual failure message when a death test finds more than // one thread running, or cannot determine the number of threads, prior // to executing the given statement. It is the responsibility of the // caller not to pass a thread_count of 1. static std::string DeathTestThreadWarning(size_t thread_count) { Message msg; msg << "Death tests use fork(), which is unsafe particularly" << " in a threaded context. For this test, " << GTEST_NAME_ << " "; if (thread_count == 0) msg << "couldn't detect the number of threads."; else msg << "detected " << thread_count << " threads."; return msg.GetString(); } # endif // !GTEST_OS_WINDOWS // Flag characters for reporting a death test that did not die. static const char kDeathTestLived = 'L'; static const char kDeathTestReturned = 'R'; static const char kDeathTestThrew = 'T'; static const char kDeathTestInternalError = 'I'; // An enumeration describing all of the possible ways that a death test can // conclude. DIED means that the process died while executing the test // code; LIVED means that process lived beyond the end of the test code; // RETURNED means that the test statement attempted to execute a return // statement, which is not allowed; THREW means that the test statement // returned control by throwing an exception. IN_PROGRESS means the test // has not yet concluded. // TODO(vladl@google.com): Unify names and possibly values for // AbortReason, DeathTestOutcome, and flag characters above. enum DeathTestOutcome { IN_PROGRESS, DIED, LIVED, RETURNED, THREW }; // Routine for aborting the program which is safe to call from an // exec-style death test child process, in which case the error // message is propagated back to the parent process. Otherwise, the // message is simply printed to stderr. In either case, the program // then exits with status 1. static void DeathTestAbort(const std::string& message) { // On a POSIX system, this function may be called from a threadsafe-style // death test child process, which operates on a very small stack. Use // the heap for any additional non-minuscule memory requirements. const InternalRunDeathTestFlag* const flag = GetUnitTestImpl()->internal_run_death_test_flag(); if (flag != NULL) { FILE* parent = posix::FDOpen(flag->write_fd(), "w"); fputc(kDeathTestInternalError, parent); fprintf(parent, "%s", message.c_str()); fflush(parent); _exit(1); } else { fprintf(stderr, "%s", message.c_str()); fflush(stderr); posix::Abort(); } } // A replacement for CHECK that calls DeathTestAbort if the assertion // fails. # define GTEST_DEATH_TEST_CHECK_(expression) \ do { \ if (!::testing::internal::IsTrue(expression)) { \ DeathTestAbort( \ ::std::string("CHECK failed: File ") + __FILE__ + ", line " \ + ::testing::internal::StreamableToString(__LINE__) + ": " \ + #expression); \ } \ } while (::testing::internal::AlwaysFalse()) // This macro is similar to GTEST_DEATH_TEST_CHECK_, but it is meant for // evaluating any system call that fulfills two conditions: it must return // -1 on failure, and set errno to EINTR when it is interrupted and // should be tried again. The macro expands to a loop that repeatedly // evaluates the expression as long as it evaluates to -1 and sets // errno to EINTR. If the expression evaluates to -1 but errno is // something other than EINTR, DeathTestAbort is called. # define GTEST_DEATH_TEST_CHECK_SYSCALL_(expression) \ do { \ int gtest_retval; \ do { \ gtest_retval = (expression); \ } while (gtest_retval == -1 && errno == EINTR); \ if (gtest_retval == -1) { \ DeathTestAbort( \ ::std::string("CHECK failed: File ") + __FILE__ + ", line " \ + ::testing::internal::StreamableToString(__LINE__) + ": " \ + #expression + " != -1"); \ } \ } while (::testing::internal::AlwaysFalse()) // Returns the message describing the last system error in errno. std::string GetLastErrnoDescription() { return errno == 0 ? "" : posix::StrError(errno); } // This is called from a death test parent process to read a failure // message from the death test child process and log it with the FATAL // severity. On Windows, the message is read from a pipe handle. On other // platforms, it is read from a file descriptor. static void FailFromInternalError(int fd) { Message error; char buffer[256]; int num_read; do { while ((num_read = posix::Read(fd, buffer, 255)) > 0) { buffer[num_read] = '\0'; error << buffer; } } while (num_read == -1 && errno == EINTR); if (num_read == 0) { GTEST_LOG_(FATAL) << error.GetString(); } else { const int last_error = errno; GTEST_LOG_(FATAL) << "Error while reading death test internal: " << GetLastErrnoDescription() << " [" << last_error << "]"; } } // Death test constructor. Increments the running death test count // for the current test. DeathTest::DeathTest() { TestInfo* const info = GetUnitTestImpl()->current_test_info(); if (info == NULL) { DeathTestAbort("Cannot run a death test outside of a TEST or " "TEST_F construct"); } } // Creates and returns a death test by dispatching to the current // death test factory. bool DeathTest::Create(const char* statement, const RE* regex, const char* file, int line, DeathTest** test) { return GetUnitTestImpl()->death_test_factory()->Create( statement, regex, file, line, test); } const char* DeathTest::LastMessage() { return last_death_test_message_.c_str(); } void DeathTest::set_last_death_test_message(const std::string& message) { last_death_test_message_ = message; } std::string DeathTest::last_death_test_message_; // Provides cross platform implementation for some death functionality. class DeathTestImpl : public DeathTest { protected: DeathTestImpl(const char* a_statement, const RE* a_regex) : statement_(a_statement), regex_(a_regex), spawned_(false), status_(-1), outcome_(IN_PROGRESS), read_fd_(-1), write_fd_(-1) {} // read_fd_ is expected to be closed and cleared by a derived class. ~DeathTestImpl() { GTEST_DEATH_TEST_CHECK_(read_fd_ == -1); } void Abort(AbortReason reason); virtual bool Passed(bool status_ok); const char* statement() const { return statement_; } const RE* regex() const { return regex_; } bool spawned() const { return spawned_; } void set_spawned(bool is_spawned) { spawned_ = is_spawned; } int status() const { return status_; } void set_status(int a_status) { status_ = a_status; } DeathTestOutcome outcome() const { return outcome_; } void set_outcome(DeathTestOutcome an_outcome) { outcome_ = an_outcome; } int read_fd() const { return read_fd_; } void set_read_fd(int fd) { read_fd_ = fd; } int write_fd() const { return write_fd_; } void set_write_fd(int fd) { write_fd_ = fd; } // Called in the parent process only. Reads the result code of the death // test child process via a pipe, interprets it to set the outcome_ // member, and closes read_fd_. Outputs diagnostics and terminates in // case of unexpected codes. void ReadAndInterpretStatusByte(); private: // The textual content of the code this object is testing. This class // doesn't own this string and should not attempt to delete it. const char* const statement_; // The regular expression which test output must match. DeathTestImpl // doesn't own this object and should not attempt to delete it. const RE* const regex_; // True if the death test child process has been successfully spawned. bool spawned_; // The exit status of the child process. int status_; // How the death test concluded. DeathTestOutcome outcome_; // Descriptor to the read end of the pipe to the child process. It is // always -1 in the child process. The child keeps its write end of the // pipe in write_fd_. int read_fd_; // Descriptor to the child's write end of the pipe to the parent process. // It is always -1 in the parent process. The parent keeps its end of the // pipe in read_fd_. int write_fd_; }; // Called in the parent process only. Reads the result code of the death // test child process via a pipe, interprets it to set the outcome_ // member, and closes read_fd_. Outputs diagnostics and terminates in // case of unexpected codes. void DeathTestImpl::ReadAndInterpretStatusByte() { char flag; int bytes_read; // The read() here blocks until data is available (signifying the // failure of the death test) or until the pipe is closed (signifying // its success), so it's okay to call this in the parent before // the child process has exited. do { bytes_read = posix::Read(read_fd(), &flag, 1); } while (bytes_read == -1 && errno == EINTR); if (bytes_read == 0) { set_outcome(DIED); } else if (bytes_read == 1) { switch (flag) { case kDeathTestReturned: set_outcome(RETURNED); break; case kDeathTestThrew: set_outcome(THREW); break; case kDeathTestLived: set_outcome(LIVED); break; case kDeathTestInternalError: FailFromInternalError(read_fd()); // Does not return. break; default: GTEST_LOG_(FATAL) << "Death test child process reported " << "unexpected status byte (" << static_cast<unsigned int>(flag) << ")"; } } else { GTEST_LOG_(FATAL) << "Read from death test child process failed: " << GetLastErrnoDescription(); } GTEST_DEATH_TEST_CHECK_SYSCALL_(posix::Close(read_fd())); set_read_fd(-1); } // Signals that the death test code which should have exited, didn't. // Should be called only in a death test child process. // Writes a status byte to the child's status file descriptor, then // calls _exit(1). void DeathTestImpl::Abort(AbortReason reason) { // The parent process considers the death test to be a failure if // it finds any data in our pipe. So, here we write a single flag byte // to the pipe, then exit. const char status_ch = reason == TEST_DID_NOT_DIE ? kDeathTestLived : reason == TEST_THREW_EXCEPTION ? kDeathTestThrew : kDeathTestReturned; GTEST_DEATH_TEST_CHECK_SYSCALL_(posix::Write(write_fd(), &status_ch, 1)); // We are leaking the descriptor here because on some platforms (i.e., // when built as Windows DLL), destructors of global objects will still // run after calling _exit(). On such systems, write_fd_ will be // indirectly closed from the destructor of UnitTestImpl, causing double // close if it is also closed here. On debug configurations, double close // may assert. As there are no in-process buffers to flush here, we are // relying on the OS to close the descriptor after the process terminates // when the destructors are not run. _exit(1); // Exits w/o any normal exit hooks (we were supposed to crash) } // Returns an indented copy of stderr output for a death test. // This makes distinguishing death test output lines from regular log lines // much easier. static ::std::string FormatDeathTestOutput(const ::std::string& output) { ::std::string ret; for (size_t at = 0; ; ) { const size_t line_end = output.find('\n', at); ret += "[ DEATH ] "; if (line_end == ::std::string::npos) { ret += output.substr(at); break; } ret += output.substr(at, line_end + 1 - at); at = line_end + 1; } return ret; } // Assesses the success or failure of a death test, using both private // members which have previously been set, and one argument: // // Private data members: // outcome: An enumeration describing how the death test // concluded: DIED, LIVED, THREW, or RETURNED. The death test // fails in the latter three cases. // status: The exit status of the child process. On *nix, it is in the // in the format specified by wait(2). On Windows, this is the // value supplied to the ExitProcess() API or a numeric code // of the exception that terminated the program. // regex: A regular expression object to be applied to // the test's captured standard error output; the death test // fails if it does not match. // // Argument: // status_ok: true if exit_status is acceptable in the context of // this particular death test, which fails if it is false // // Returns true iff all of the above conditions are met. Otherwise, the // first failing condition, in the order given above, is the one that is // reported. Also sets the last death test message string. bool DeathTestImpl::Passed(bool status_ok) { if (!spawned()) return false; const std::string error_message = GetCapturedStderr(); bool success = false; Message buffer; buffer << "Death test: " << statement() << "\n"; switch (outcome()) { case LIVED: buffer << " Result: failed to die.\n" << " Error msg:\n" << FormatDeathTestOutput(error_message); break; case THREW: buffer << " Result: threw an exception.\n" << " Error msg:\n" << FormatDeathTestOutput(error_message); break; case RETURNED: buffer << " Result: illegal return in test statement.\n" << " Error msg:\n" << FormatDeathTestOutput(error_message); break; case DIED: if (status_ok) { const bool matched = RE::PartialMatch(error_message.c_str(), *regex()); if (matched) { success = true; } else { buffer << " Result: died but not with expected error.\n" << " Expected: " << regex()->pattern() << "\n" << "Actual msg:\n" << FormatDeathTestOutput(error_message); } } else { buffer << " Result: died but not with expected exit code:\n" << " " << ExitSummary(status()) << "\n" << "Actual msg:\n" << FormatDeathTestOutput(error_message); } break; case IN_PROGRESS: default: GTEST_LOG_(FATAL) << "DeathTest::Passed somehow called before conclusion of test"; } DeathTest::set_last_death_test_message(buffer.GetString()); return success; } # if GTEST_OS_WINDOWS // WindowsDeathTest implements death tests on Windows. Due to the // specifics of starting new processes on Windows, death tests there are // always threadsafe, and Google Test considers the // --gtest_death_test_style=fast setting to be equivalent to // --gtest_death_test_style=threadsafe there. // // A few implementation notes: Like the Linux version, the Windows // implementation uses pipes for child-to-parent communication. But due to // the specifics of pipes on Windows, some extra steps are required: // // 1. The parent creates a communication pipe and stores handles to both // ends of it. // 2. The parent starts the child and provides it with the information // necessary to acquire the handle to the write end of the pipe. // 3. The child acquires the write end of the pipe and signals the parent // using a Windows event. // 4. Now the parent can release the write end of the pipe on its side. If // this is done before step 3, the object's reference count goes down to // 0 and it is destroyed, preventing the child from acquiring it. The // parent now has to release it, or read operations on the read end of // the pipe will not return when the child terminates. // 5. The parent reads child's output through the pipe (outcome code and // any possible error messages) from the pipe, and its stderr and then // determines whether to fail the test. // // Note: to distinguish Win32 API calls from the local method and function // calls, the former are explicitly resolved in the global namespace. // class WindowsDeathTest : public DeathTestImpl { public: WindowsDeathTest(const char* a_statement, const RE* a_regex, const char* file, int line) : DeathTestImpl(a_statement, a_regex), file_(file), line_(line) {} // All of these virtual functions are inherited from DeathTest. virtual int Wait(); virtual TestRole AssumeRole(); private: // The name of the file in which the death test is located. const char* const file_; // The line number on which the death test is located. const int line_; // Handle to the write end of the pipe to the child process. AutoHandle write_handle_; // Child process handle. AutoHandle child_handle_; // Event the child process uses to signal the parent that it has // acquired the handle to the write end of the pipe. After seeing this // event the parent can release its own handles to make sure its // ReadFile() calls return when the child terminates. AutoHandle event_handle_; }; // Waits for the child in a death test to exit, returning its exit // status, or 0 if no child process exists. As a side effect, sets the // outcome data member. int WindowsDeathTest::Wait() { if (!spawned()) return 0; // Wait until the child either signals that it has acquired the write end // of the pipe or it dies. const HANDLE wait_handles[2] = { child_handle_.Get(), event_handle_.Get() }; switch (::WaitForMultipleObjects(2, wait_handles, FALSE, // Waits for any of the handles. INFINITE)) { case WAIT_OBJECT_0: case WAIT_OBJECT_0 + 1: break; default: GTEST_DEATH_TEST_CHECK_(false); // Should not get here. } // The child has acquired the write end of the pipe or exited. // We release the handle on our side and continue. write_handle_.Reset(); event_handle_.Reset(); ReadAndInterpretStatusByte(); // Waits for the child process to exit if it haven't already. This // returns immediately if the child has already exited, regardless of // whether previous calls to WaitForMultipleObjects synchronized on this // handle or not. GTEST_DEATH_TEST_CHECK_( WAIT_OBJECT_0 == ::WaitForSingleObject(child_handle_.Get(), INFINITE)); DWORD status_code; GTEST_DEATH_TEST_CHECK_( ::GetExitCodeProcess(child_handle_.Get(), &status_code) != FALSE); child_handle_.Reset(); set_status(static_cast<int>(status_code)); return status(); } // The AssumeRole process for a Windows death test. It creates a child // process with the same executable as the current process to run the // death test. The child process is given the --gtest_filter and // --gtest_internal_run_death_test flags such that it knows to run the // current death test only. DeathTest::TestRole WindowsDeathTest::AssumeRole() { const UnitTestImpl* const impl = GetUnitTestImpl(); const InternalRunDeathTestFlag* const flag = impl->internal_run_death_test_flag(); const TestInfo* const info = impl->current_test_info(); const int death_test_index = info->result()->death_test_count(); if (flag != NULL) { // ParseInternalRunDeathTestFlag() has performed all the necessary // processing. set_write_fd(flag->write_fd()); return EXECUTE_TEST; } // WindowsDeathTest uses an anonymous pipe to communicate results of // a death test. SECURITY_ATTRIBUTES handles_are_inheritable = { sizeof(SECURITY_ATTRIBUTES), NULL, TRUE }; HANDLE read_handle, write_handle; GTEST_DEATH_TEST_CHECK_( ::CreatePipe(&read_handle, &write_handle, &handles_are_inheritable, 0) // Default buffer size. != FALSE); set_read_fd(::_open_osfhandle(reinterpret_cast<intptr_t>(read_handle), O_RDONLY)); write_handle_.Reset(write_handle); event_handle_.Reset(::CreateEvent( &handles_are_inheritable, TRUE, // The event will automatically reset to non-signaled state. FALSE, // The initial state is non-signalled. NULL)); // The even is unnamed. GTEST_DEATH_TEST_CHECK_(event_handle_.Get() != NULL); const std::string filter_flag = std::string("--") + GTEST_FLAG_PREFIX_ + kFilterFlag + "=" + info->test_case_name() + "." + info->name(); const std::string internal_flag = std::string("--") + GTEST_FLAG_PREFIX_ + kInternalRunDeathTestFlag + "=" + file_ + "|" + StreamableToString(line_) + "|" + StreamableToString(death_test_index) + "|" + StreamableToString(static_cast<unsigned int>(::GetCurrentProcessId())) + // size_t has the same width as pointers on both 32-bit and 64-bit // Windows platforms. // See http://msdn.microsoft.com/en-us/library/tcxf1dw6.aspx. "|" + StreamableToString(reinterpret_cast<size_t>(write_handle)) + "|" + StreamableToString(reinterpret_cast<size_t>(event_handle_.Get())); char executable_path[_MAX_PATH + 1]; // NOLINT GTEST_DEATH_TEST_CHECK_( _MAX_PATH + 1 != ::GetModuleFileNameA(NULL, executable_path, _MAX_PATH)); std::string command_line = std::string(::GetCommandLineA()) + " " + filter_flag + " \"" + internal_flag + "\""; DeathTest::set_last_death_test_message(""); CaptureStderr(); // Flush the log buffers since the log streams are shared with the child. FlushInfoLog(); // The child process will share the standard handles with the parent. STARTUPINFOA startup_info; memset(&startup_info, 0, sizeof(STARTUPINFO)); startup_info.dwFlags = STARTF_USESTDHANDLES; startup_info.hStdInput = ::GetStdHandle(STD_INPUT_HANDLE); startup_info.hStdOutput = ::GetStdHandle(STD_OUTPUT_HANDLE); startup_info.hStdError = ::GetStdHandle(STD_ERROR_HANDLE); PROCESS_INFORMATION process_info; GTEST_DEATH_TEST_CHECK_(::CreateProcessA( executable_path, const_cast<char*>(command_line.c_str()), NULL, // Retuned process handle is not inheritable. NULL, // Retuned thread handle is not inheritable. TRUE, // Child inherits all inheritable handles (for write_handle_). 0x0, // Default creation flags. NULL, // Inherit the parent's environment. UnitTest::GetInstance()->original_working_dir(), &startup_info, &process_info) != FALSE); child_handle_.Reset(process_info.hProcess); ::CloseHandle(process_info.hThread); set_spawned(true); return OVERSEE_TEST; } # else // We are not on Windows. // ForkingDeathTest provides implementations for most of the abstract // methods of the DeathTest interface. Only the AssumeRole method is // left undefined. class ForkingDeathTest : public DeathTestImpl { public: ForkingDeathTest(const char* statement, const RE* regex); // All of these virtual functions are inherited from DeathTest. virtual int Wait(); protected: void set_child_pid(pid_t child_pid) { child_pid_ = child_pid; } private: // PID of child process during death test; 0 in the child process itself. pid_t child_pid_; }; // Constructs a ForkingDeathTest. ForkingDeathTest::ForkingDeathTest(const char* a_statement, const RE* a_regex) : DeathTestImpl(a_statement, a_regex), child_pid_(-1) {} // Waits for the child in a death test to exit, returning its exit // status, or 0 if no child process exists. As a side effect, sets the // outcome data member. int ForkingDeathTest::Wait() { if (!spawned()) return 0; ReadAndInterpretStatusByte(); int status_value; GTEST_DEATH_TEST_CHECK_SYSCALL_(waitpid(child_pid_, &status_value, 0)); set_status(status_value); return status_value; } // A concrete death test class that forks, then immediately runs the test // in the child process. class NoExecDeathTest : public ForkingDeathTest { public: NoExecDeathTest(const char* a_statement, const RE* a_regex) : ForkingDeathTest(a_statement, a_regex) { } virtual TestRole AssumeRole(); }; // The AssumeRole process for a fork-and-run death test. It implements a // straightforward fork, with a simple pipe to transmit the status byte. DeathTest::TestRole NoExecDeathTest::AssumeRole() { const size_t thread_count = GetThreadCount(); if (thread_count != 1) { GTEST_LOG_(WARNING) << DeathTestThreadWarning(thread_count); } int pipe_fd[2]; GTEST_DEATH_TEST_CHECK_(pipe(pipe_fd) != -1); DeathTest::set_last_death_test_message(""); CaptureStderr(); // When we fork the process below, the log file buffers are copied, but the // file descriptors are shared. We flush all log files here so that closing // the file descriptors in the child process doesn't throw off the // synchronization between descriptors and buffers in the parent process. // This is as close to the fork as possible to avoid a race condition in case // there are multiple threads running before the death test, and another // thread writes to the log file. FlushInfoLog(); const pid_t child_pid = fork(); GTEST_DEATH_TEST_CHECK_(child_pid != -1); set_child_pid(child_pid); if (child_pid == 0) { GTEST_DEATH_TEST_CHECK_SYSCALL_(close(pipe_fd[0])); set_write_fd(pipe_fd[1]); // Redirects all logging to stderr in the child process to prevent // concurrent writes to the log files. We capture stderr in the parent // process and append the child process' output to a log. LogToStderr(); // Event forwarding to the listeners of event listener API mush be shut // down in death test subprocesses. GetUnitTestImpl()->listeners()->SuppressEventForwarding(); g_in_fast_death_test_child = true; return EXECUTE_TEST; } else { GTEST_DEATH_TEST_CHECK_SYSCALL_(close(pipe_fd[1])); set_read_fd(pipe_fd[0]); set_spawned(true); return OVERSEE_TEST; } } // A concrete death test class that forks and re-executes the main // program from the beginning, with command-line flags set that cause // only this specific death test to be run. class ExecDeathTest : public ForkingDeathTest { public: ExecDeathTest(const char* a_statement, const RE* a_regex, const char* file, int line) : ForkingDeathTest(a_statement, a_regex), file_(file), line_(line) { } virtual TestRole AssumeRole(); private: static ::std::vector<testing::internal::string> GetArgvsForDeathTestChildProcess() { ::std::vector<testing::internal::string> args = GetInjectableArgvs(); return args; } // The name of the file in which the death test is located. const char* const file_; // The line number on which the death test is located. const int line_; }; // Utility class for accumulating command-line arguments. class Arguments { public: Arguments() { args_.push_back(NULL); } ~Arguments() { for (std::vector<char*>::iterator i = args_.begin(); i != args_.end(); ++i) { free(*i); } } void AddArgument(const char* argument) { args_.insert(args_.end() - 1, posix::StrDup(argument)); } template <typename Str> void AddArguments(const ::std::vector<Str>& arguments) { for (typename ::std::vector<Str>::const_iterator i = arguments.begin(); i != arguments.end(); ++i) { args_.insert(args_.end() - 1, posix::StrDup(i->c_str())); } } char* const* Argv() { return &args_[0]; } private: std::vector<char*> args_; }; // A struct that encompasses the arguments to the child process of a // threadsafe-style death test process. struct ExecDeathTestArgs { char* const* argv; // Command-line arguments for the child's call to exec int close_fd; // File descriptor to close; the read end of a pipe }; # if GTEST_OS_MAC inline char** GetEnviron() { // When Google Test is built as a framework on MacOS X, the environ variable // is unavailable. Apple's documentation (man environ) recommends using // _NSGetEnviron() instead. return *_NSGetEnviron(); } # else // Some POSIX platforms expect you to declare environ. extern "C" makes // it reside in the global namespace. extern "C" char** environ; inline char** GetEnviron() { return environ; } # endif // GTEST_OS_MAC # if !GTEST_OS_QNX // The main function for a threadsafe-style death test child process. // This function is called in a clone()-ed process and thus must avoid // any potentially unsafe operations like malloc or libc functions. static int ExecDeathTestChildMain(void* child_arg) { ExecDeathTestArgs* const args = static_cast<ExecDeathTestArgs*>(child_arg); GTEST_DEATH_TEST_CHECK_SYSCALL_(close(args->close_fd)); // We need to execute the test program in the same environment where // it was originally invoked. Therefore we change to the original // working directory first. const char* const original_dir = UnitTest::GetInstance()->original_working_dir(); // We can safely call chdir() as it's a direct system call. if (chdir(original_dir) != 0) { DeathTestAbort(std::string("chdir(\"") + original_dir + "\") failed: " + GetLastErrnoDescription()); return EXIT_FAILURE; } // We can safely call execve() as it's a direct system call. We // cannot use execvp() as it's a libc function and thus potentially // unsafe. Since execve() doesn't search the PATH, the user must // invoke the test program via a valid path that contains at least // one path separator. execve(args->argv[0], args->argv, GetEnviron()); DeathTestAbort(std::string("execve(") + args->argv[0] + ", ...) in " + original_dir + " failed: " + GetLastErrnoDescription()); return EXIT_FAILURE; } # endif // !GTEST_OS_QNX // Two utility routines that together determine the direction the stack // grows. // This could be accomplished more elegantly by a single recursive // function, but we want to guard against the unlikely possibility of // a smart compiler optimizing the recursion away. // // GTEST_NO_INLINE_ is required to prevent GCC 4.6 from inlining // StackLowerThanAddress into StackGrowsDown, which then doesn't give // correct answer. void StackLowerThanAddress(const void* ptr, bool* result) GTEST_NO_INLINE_; void StackLowerThanAddress(const void* ptr, bool* result) { int dummy; *result = (&dummy < ptr); } #if GTEST_HAS_CLONE static bool StackGrowsDown() { int dummy; bool result; StackLowerThanAddress(&dummy, &result); return result; } #endif // Spawns a child process with the same executable as the current process in // a thread-safe manner and instructs it to run the death test. The // implementation uses fork(2) + exec. On systems where clone(2) is // available, it is used instead, being slightly more thread-safe. On QNX, // fork supports only single-threaded environments, so this function uses // spawn(2) there instead. The function dies with an error message if // anything goes wrong. static pid_t ExecDeathTestSpawnChild(char* const* argv, int close_fd) { ExecDeathTestArgs args = { argv, close_fd }; pid_t child_pid = -1; # if GTEST_OS_QNX // Obtains the current directory and sets it to be closed in the child // process. const int cwd_fd = open(".", O_RDONLY); GTEST_DEATH_TEST_CHECK_(cwd_fd != -1); GTEST_DEATH_TEST_CHECK_SYSCALL_(fcntl(cwd_fd, F_SETFD, FD_CLOEXEC)); // We need to execute the test program in the same environment where // it was originally invoked. Therefore we change to the original // working directory first. const char* const original_dir = UnitTest::GetInstance()->original_working_dir(); // We can safely call chdir() as it's a direct system call. if (chdir(original_dir) != 0) { DeathTestAbort(std::string("chdir(\"") + original_dir + "\") failed: " + GetLastErrnoDescription()); return EXIT_FAILURE; } int fd_flags; // Set close_fd to be closed after spawn. GTEST_DEATH_TEST_CHECK_SYSCALL_(fd_flags = fcntl(close_fd, F_GETFD)); GTEST_DEATH_TEST_CHECK_SYSCALL_(fcntl(close_fd, F_SETFD, fd_flags | FD_CLOEXEC)); struct inheritance inherit = {0}; // spawn is a system call. child_pid = spawn(args.argv[0], 0, NULL, &inherit, args.argv, GetEnviron()); // Restores the current working directory. GTEST_DEATH_TEST_CHECK_(fchdir(cwd_fd) != -1); GTEST_DEATH_TEST_CHECK_SYSCALL_(close(cwd_fd)); # else // GTEST_OS_QNX # if GTEST_OS_LINUX // When a SIGPROF signal is received while fork() or clone() are executing, // the process may hang. To avoid this, we ignore SIGPROF here and re-enable // it after the call to fork()/clone() is complete. struct sigaction saved_sigprof_action; struct sigaction ignore_sigprof_action; memset(&ignore_sigprof_action, 0, sizeof(ignore_sigprof_action)); sigemptyset(&ignore_sigprof_action.sa_mask); ignore_sigprof_action.sa_handler = SIG_IGN; GTEST_DEATH_TEST_CHECK_SYSCALL_(sigaction( SIGPROF, &ignore_sigprof_action, &saved_sigprof_action)); # endif // GTEST_OS_LINUX # if GTEST_HAS_CLONE const bool use_fork = GTEST_FLAG(death_test_use_fork); if (!use_fork) { static const bool stack_grows_down = StackGrowsDown(); const size_t stack_size = getpagesize(); // MMAP_ANONYMOUS is not defined on Mac, so we use MAP_ANON instead. void* const stack = mmap(NULL, stack_size, PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE, -1, 0); GTEST_DEATH_TEST_CHECK_(stack != MAP_FAILED); // Maximum stack alignment in bytes: For a downward-growing stack, this // amount is subtracted from size of the stack space to get an address // that is within the stack space and is aligned on all systems we care // about. As far as I know there is no ABI with stack alignment greater // than 64. We assume stack and stack_size already have alignment of // kMaxStackAlignment. const size_t kMaxStackAlignment = 64; void* const stack_top = static_cast<char*>(stack) + (stack_grows_down ? stack_size - kMaxStackAlignment : 0); GTEST_DEATH_TEST_CHECK_(stack_size > kMaxStackAlignment && reinterpret_cast<intptr_t>(stack_top) % kMaxStackAlignment == 0); child_pid = clone(&ExecDeathTestChildMain, stack_top, SIGCHLD, &args); GTEST_DEATH_TEST_CHECK_(munmap(stack, stack_size) != -1); } # else const bool use_fork = true; # endif // GTEST_HAS_CLONE if (use_fork && (child_pid = fork()) == 0) { ExecDeathTestChildMain(&args); _exit(0); } # endif // GTEST_OS_QNX # if GTEST_OS_LINUX GTEST_DEATH_TEST_CHECK_SYSCALL_( sigaction(SIGPROF, &saved_sigprof_action, NULL)); # endif // GTEST_OS_LINUX GTEST_DEATH_TEST_CHECK_(child_pid != -1); return child_pid; } // The AssumeRole process for a fork-and-exec death test. It re-executes the // main program from the beginning, setting the --gtest_filter // and --gtest_internal_run_death_test flags to cause only the current // death test to be re-run. DeathTest::TestRole ExecDeathTest::AssumeRole() { const UnitTestImpl* const impl = GetUnitTestImpl(); const InternalRunDeathTestFlag* const flag = impl->internal_run_death_test_flag(); const TestInfo* const info = impl->current_test_info(); const int death_test_index = info->result()->death_test_count(); if (flag != NULL) { set_write_fd(flag->write_fd()); return EXECUTE_TEST; } int pipe_fd[2]; GTEST_DEATH_TEST_CHECK_(pipe(pipe_fd) != -1); // Clear the close-on-exec flag on the write end of the pipe, lest // it be closed when the child process does an exec: GTEST_DEATH_TEST_CHECK_(fcntl(pipe_fd[1], F_SETFD, 0) != -1); const std::string filter_flag = std::string("--") + GTEST_FLAG_PREFIX_ + kFilterFlag + "=" + info->test_case_name() + "." + info->name(); const std::string internal_flag = std::string("--") + GTEST_FLAG_PREFIX_ + kInternalRunDeathTestFlag + "=" + file_ + "|" + StreamableToString(line_) + "|" + StreamableToString(death_test_index) + "|" + StreamableToString(pipe_fd[1]); Arguments args; args.AddArguments(GetArgvsForDeathTestChildProcess()); args.AddArgument(filter_flag.c_str()); args.AddArgument(internal_flag.c_str()); DeathTest::set_last_death_test_message(""); CaptureStderr(); // See the comment in NoExecDeathTest::AssumeRole for why the next line // is necessary. FlushInfoLog(); const pid_t child_pid = ExecDeathTestSpawnChild(args.Argv(), pipe_fd[0]); GTEST_DEATH_TEST_CHECK_SYSCALL_(close(pipe_fd[1])); set_child_pid(child_pid); set_read_fd(pipe_fd[0]); set_spawned(true); return OVERSEE_TEST; } # endif // !GTEST_OS_WINDOWS // Creates a concrete DeathTest-derived class that depends on the // --gtest_death_test_style flag, and sets the pointer pointed to // by the "test" argument to its address. If the test should be // skipped, sets that pointer to NULL. Returns true, unless the // flag is set to an invalid value. bool DefaultDeathTestFactory::Create(const char* statement, const RE* regex, const char* file, int line, DeathTest** test) { UnitTestImpl* const impl = GetUnitTestImpl(); const InternalRunDeathTestFlag* const flag = impl->internal_run_death_test_flag(); const int death_test_index = impl->current_test_info() ->increment_death_test_count(); if (flag != NULL) { if (death_test_index > flag->index()) { DeathTest::set_last_death_test_message( "Death test count (" + StreamableToString(death_test_index) + ") somehow exceeded expected maximum (" + StreamableToString(flag->index()) + ")"); return false; } if (!(flag->file() == file && flag->line() == line && flag->index() == death_test_index)) { *test = NULL; return true; } } # if GTEST_OS_WINDOWS if (GTEST_FLAG(death_test_style) == "threadsafe" || GTEST_FLAG(death_test_style) == "fast") { *test = new WindowsDeathTest(statement, regex, file, line); } # else if (GTEST_FLAG(death_test_style) == "threadsafe") { *test = new ExecDeathTest(statement, regex, file, line); } else if (GTEST_FLAG(death_test_style) == "fast") { *test = new NoExecDeathTest(statement, regex); } # endif // GTEST_OS_WINDOWS else { // NOLINT - this is more readable than unbalanced brackets inside #if. DeathTest::set_last_death_test_message( "Unknown death test style \"" + GTEST_FLAG(death_test_style) + "\" encountered"); return false; } return true; } // Splits a given string on a given delimiter, populating a given // vector with the fields. GTEST_HAS_DEATH_TEST implies that we have // ::std::string, so we can use it here. static void SplitString(const ::std::string& str, char delimiter, ::std::vector< ::std::string>* dest) { ::std::vector< ::std::string> parsed; ::std::string::size_type pos = 0; while (::testing::internal::AlwaysTrue()) { const ::std::string::size_type colon = str.find(delimiter, pos); if (colon == ::std::string::npos) { parsed.push_back(str.substr(pos)); break; } else { parsed.push_back(str.substr(pos, colon - pos)); pos = colon + 1; } } dest->swap(parsed); } # if GTEST_OS_WINDOWS // Recreates the pipe and event handles from the provided parameters, // signals the event, and returns a file descriptor wrapped around the pipe // handle. This function is called in the child process only. int GetStatusFileDescriptor(unsigned int parent_process_id, size_t write_handle_as_size_t, size_t event_handle_as_size_t) { AutoHandle parent_process_handle(::OpenProcess(PROCESS_DUP_HANDLE, FALSE, // Non-inheritable. parent_process_id)); if (parent_process_handle.Get() == INVALID_HANDLE_VALUE) { DeathTestAbort("Unable to open parent process " + StreamableToString(parent_process_id)); } // TODO(vladl@google.com): Replace the following check with a // compile-time assertion when available. GTEST_CHECK_(sizeof(HANDLE) <= sizeof(size_t)); const HANDLE write_handle = reinterpret_cast<HANDLE>(write_handle_as_size_t); HANDLE dup_write_handle; // The newly initialized handle is accessible only in in the parent // process. To obtain one accessible within the child, we need to use // DuplicateHandle. if (!::DuplicateHandle(parent_process_handle.Get(), write_handle, ::GetCurrentProcess(), &dup_write_handle, 0x0, // Requested privileges ignored since // DUPLICATE_SAME_ACCESS is used. FALSE, // Request non-inheritable handler. DUPLICATE_SAME_ACCESS)) { DeathTestAbort("Unable to duplicate the pipe handle " + StreamableToString(write_handle_as_size_t) + " from the parent process " + StreamableToString(parent_process_id)); } const HANDLE event_handle = reinterpret_cast<HANDLE>(event_handle_as_size_t); HANDLE dup_event_handle; if (!::DuplicateHandle(parent_process_handle.Get(), event_handle, ::GetCurrentProcess(), &dup_event_handle, 0x0, FALSE, DUPLICATE_SAME_ACCESS)) { DeathTestAbort("Unable to duplicate the event handle " + StreamableToString(event_handle_as_size_t) + " from the parent process " + StreamableToString(parent_process_id)); } const int write_fd = ::_open_osfhandle(reinterpret_cast<intptr_t>(dup_write_handle), O_APPEND); if (write_fd == -1) { DeathTestAbort("Unable to convert pipe handle " + StreamableToString(write_handle_as_size_t) + " to a file descriptor"); } // Signals the parent that the write end of the pipe has been acquired // so the parent can release its own write end. ::SetEvent(dup_event_handle); return write_fd; } # endif // GTEST_OS_WINDOWS // Returns a newly created InternalRunDeathTestFlag object with fields // initialized from the GTEST_FLAG(internal_run_death_test) flag if // the flag is specified; otherwise returns NULL. InternalRunDeathTestFlag* ParseInternalRunDeathTestFlag() { if (GTEST_FLAG(internal_run_death_test) == "") return NULL; // GTEST_HAS_DEATH_TEST implies that we have ::std::string, so we // can use it here. int line = -1; int index = -1; ::std::vector< ::std::string> fields; SplitString(GTEST_FLAG(internal_run_death_test).c_str(), '|', &fields); int write_fd = -1; # if GTEST_OS_WINDOWS unsigned int parent_process_id = 0; size_t write_handle_as_size_t = 0; size_t event_handle_as_size_t = 0; if (fields.size() != 6 || !ParseNaturalNumber(fields[1], &line) || !ParseNaturalNumber(fields[2], &index) || !ParseNaturalNumber(fields[3], &parent_process_id) || !ParseNaturalNumber(fields[4], &write_handle_as_size_t) || !ParseNaturalNumber(fields[5], &event_handle_as_size_t)) { DeathTestAbort("Bad --gtest_internal_run_death_test flag: " + GTEST_FLAG(internal_run_death_test)); } write_fd = GetStatusFileDescriptor(parent_process_id, write_handle_as_size_t, event_handle_as_size_t); # else if (fields.size() != 4 || !ParseNaturalNumber(fields[1], &line) || !ParseNaturalNumber(fields[2], &index) || !ParseNaturalNumber(fields[3], &write_fd)) { DeathTestAbort("Bad --gtest_internal_run_death_test flag: " + GTEST_FLAG(internal_run_death_test)); } # endif // GTEST_OS_WINDOWS return new InternalRunDeathTestFlag(fields[0], line, index, write_fd); } } // namespace internal #endif // GTEST_HAS_DEATH_TEST } // namespace testing // Copyright 2008, Google Inc. // 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. // * Neither the name of Google Inc. nor the names of its // contributors may be used to endorse or promote products derived from // this software without specific prior written permission. // // 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 // OWNER 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. // // Authors: keith.ray@gmail.com (Keith Ray) #include <stdlib.h> #if GTEST_OS_WINDOWS_MOBILE # include <windows.h> #elif GTEST_OS_WINDOWS # include <direct.h> # include <io.h> #elif GTEST_OS_SYMBIAN // Symbian OpenC has PATH_MAX in sys/syslimits.h # include <sys/syslimits.h> #else # include <limits.h> # include <climits> // Some Linux distributions define PATH_MAX here. #endif // GTEST_OS_WINDOWS_MOBILE #if GTEST_OS_WINDOWS # define GTEST_PATH_MAX_ _MAX_PATH #elif defined(PATH_MAX) # define GTEST_PATH_MAX_ PATH_MAX #elif defined(_XOPEN_PATH_MAX) # define GTEST_PATH_MAX_ _XOPEN_PATH_MAX #else # define GTEST_PATH_MAX_ _POSIX_PATH_MAX #endif // GTEST_OS_WINDOWS namespace testing { namespace internal { #if GTEST_OS_WINDOWS // On Windows, '\\' is the standard path separator, but many tools and the // Windows API also accept '/' as an alternate path separator. Unless otherwise // noted, a file path can contain either kind of path separators, or a mixture // of them. const char kPathSeparator = '\\'; const char kAlternatePathSeparator = '/'; //const char kPathSeparatorString[] = "\\"; const char kAlternatePathSeparatorString[] = "/"; # if GTEST_OS_WINDOWS_MOBILE // Windows CE doesn't have a current directory. You should not use // the current directory in tests on Windows CE, but this at least // provides a reasonable fallback. const char kCurrentDirectoryString[] = "\\"; // Windows CE doesn't define INVALID_FILE_ATTRIBUTES const DWORD kInvalidFileAttributes = 0xffffffff; # else const char kCurrentDirectoryString[] = ".\\"; # endif // GTEST_OS_WINDOWS_MOBILE #else const char kPathSeparator = '/'; //const char kPathSeparatorString[] = "/"; const char kCurrentDirectoryString[] = "./"; #endif // GTEST_OS_WINDOWS // Returns whether the given character is a valid path separator. static bool IsPathSeparator(char c) { #if GTEST_HAS_ALT_PATH_SEP_ return (c == kPathSeparator) || (c == kAlternatePathSeparator); #else return c == kPathSeparator; #endif } // Returns the current working directory, or "" if unsuccessful. FilePath FilePath::GetCurrentDir() { #if GTEST_OS_WINDOWS_MOBILE // Windows CE doesn't have a current directory, so we just return // something reasonable. return FilePath(kCurrentDirectoryString); #elif GTEST_OS_WINDOWS char cwd[GTEST_PATH_MAX_ + 1] = { '\0' }; return FilePath(_getcwd(cwd, sizeof(cwd)) == NULL ? "" : cwd); #else char cwd[GTEST_PATH_MAX_ + 1] = { '\0' }; return FilePath(getcwd(cwd, sizeof(cwd)) == NULL ? "" : cwd); #endif // GTEST_OS_WINDOWS_MOBILE } // Returns a copy of the FilePath with the case-insensitive extension removed. // Example: FilePath("dir/file.exe").RemoveExtension("EXE") returns // FilePath("dir/file"). If a case-insensitive extension is not // found, returns a copy of the original FilePath. FilePath FilePath::RemoveExtension(const char* extension) const { const std::string dot_extension = std::string(".") + extension; if (String::EndsWithCaseInsensitive(pathname_, dot_extension)) { return FilePath(pathname_.substr( 0, pathname_.length() - dot_extension.length())); } return *this; } // Returns a pointer to the last occurence of a valid path separator in // the FilePath. On Windows, for example, both '/' and '\' are valid path // separators. Returns NULL if no path separator was found. const char* FilePath::FindLastPathSeparator() const { const char* const last_sep = strrchr(c_str(), kPathSeparator); #if GTEST_HAS_ALT_PATH_SEP_ const char* const last_alt_sep = strrchr(c_str(), kAlternatePathSeparator); // Comparing two pointers of which only one is NULL is undefined. if (last_alt_sep != NULL && (last_sep == NULL || last_alt_sep > last_sep)) { return last_alt_sep; } #endif return last_sep; } // Returns a copy of the FilePath with the directory part removed. // Example: FilePath("path/to/file").RemoveDirectoryName() returns // FilePath("file"). If there is no directory part ("just_a_file"), it returns // the FilePath unmodified. If there is no file part ("just_a_dir/") it // returns an empty FilePath (""). // On Windows platform, '\' is the path separator, otherwise it is '/'. FilePath FilePath::RemoveDirectoryName() const { const char* const last_sep = FindLastPathSeparator(); return last_sep ? FilePath(last_sep + 1) : *this; } // RemoveFileName returns the directory path with the filename removed. // Example: FilePath("path/to/file").RemoveFileName() returns "path/to/". // If the FilePath is "a_file" or "/a_file", RemoveFileName returns // FilePath("./") or, on Windows, FilePath(".\\"). If the filepath does // not have a file, like "just/a/dir/", it returns the FilePath unmodified. // On Windows platform, '\' is the path separator, otherwise it is '/'. FilePath FilePath::RemoveFileName() const { const char* const last_sep = FindLastPathSeparator(); std::string dir; if (last_sep) { dir = std::string(c_str(), last_sep + 1 - c_str()); } else { dir = kCurrentDirectoryString; } return FilePath(dir); } // Helper functions for naming files in a directory for xml output. // Given directory = "dir", base_name = "test", number = 0, // extension = "xml", returns "dir/test.xml". If number is greater // than zero (e.g., 12), returns "dir/test_12.xml". // On Windows platform, uses \ as the separator rather than /. FilePath FilePath::MakeFileName(const FilePath& directory, const FilePath& base_name, int number, const char* extension) { std::string file; if (number == 0) { file = base_name.string() + "." + extension; } else { file = base_name.string() + "_" + StreamableToString(number) + "." + extension; } return ConcatPaths(directory, FilePath(file)); } // Given directory = "dir", relative_path = "test.xml", returns "dir/test.xml". // On Windows, uses \ as the separator rather than /. FilePath FilePath::ConcatPaths(const FilePath& directory, const FilePath& relative_path) { if (directory.IsEmpty()) return relative_path; const FilePath dir(directory.RemoveTrailingPathSeparator()); return FilePath(dir.string() + kPathSeparator + relative_path.string()); } // Returns true if pathname describes something findable in the file-system, // either a file, directory, or whatever. bool FilePath::FileOrDirectoryExists() const { #if GTEST_OS_WINDOWS_MOBILE LPCWSTR unicode = String::AnsiToUtf16(pathname_.c_str()); const DWORD attributes = GetFileAttributes(unicode); delete [] unicode; return attributes != kInvalidFileAttributes; #else posix::StatStruct file_stat; return posix::Stat(pathname_.c_str(), &file_stat) == 0; #endif // GTEST_OS_WINDOWS_MOBILE } // Returns true if pathname describes a directory in the file-system // that exists. bool FilePath::DirectoryExists() const { bool result = false; #if GTEST_OS_WINDOWS // Don't strip off trailing separator if path is a root directory on // Windows (like "C:\\"). const FilePath& path(IsRootDirectory() ? *this : RemoveTrailingPathSeparator()); #else const FilePath& path(*this); #endif #if GTEST_OS_WINDOWS_MOBILE LPCWSTR unicode = String::AnsiToUtf16(path.c_str()); const DWORD attributes = GetFileAttributes(unicode); delete [] unicode; if ((attributes != kInvalidFileAttributes) && (attributes & FILE_ATTRIBUTE_DIRECTORY)) { result = true; } #else posix::StatStruct file_stat; result = posix::Stat(path.c_str(), &file_stat) == 0 && posix::IsDir(file_stat); #endif // GTEST_OS_WINDOWS_MOBILE return result; } // Returns true if pathname describes a root directory. (Windows has one // root directory per disk drive.) bool FilePath::IsRootDirectory() const { #if GTEST_OS_WINDOWS // TODO(wan@google.com): on Windows a network share like // \\server\share can be a root directory, although it cannot be the // current directory. Handle this properly. return pathname_.length() == 3 && IsAbsolutePath(); #else return pathname_.length() == 1 && IsPathSeparator(pathname_.c_str()[0]); #endif } // Returns true if pathname describes an absolute path. bool FilePath::IsAbsolutePath() const { const char* const name = pathname_.c_str(); #if GTEST_OS_WINDOWS return pathname_.length() >= 3 && ((name[0] >= 'a' && name[0] <= 'z') || (name[0] >= 'A' && name[0] <= 'Z')) && name[1] == ':' && IsPathSeparator(name[2]); #else return IsPathSeparator(name[0]); #endif } // Returns a pathname for a file that does not currently exist. The pathname // will be directory/base_name.extension or // directory/base_name_<number>.extension if directory/base_name.extension // already exists. The number will be incremented until a pathname is found // that does not already exist. // Examples: 'dir/foo_test.xml' or 'dir/foo_test_1.xml'. // There could be a race condition if two or more processes are calling this // function at the same time -- they could both pick the same filename. FilePath FilePath::GenerateUniqueFileName(const FilePath& directory, const FilePath& base_name, const char* extension) { FilePath full_pathname; int number = 0; do { full_pathname.Set(MakeFileName(directory, base_name, number++, extension)); } while (full_pathname.FileOrDirectoryExists()); return full_pathname; } // Returns true if FilePath ends with a path separator, which indicates that // it is intended to represent a directory. Returns false otherwise. // This does NOT check that a directory (or file) actually exists. bool FilePath::IsDirectory() const { return !pathname_.empty() && IsPathSeparator(pathname_.c_str()[pathname_.length() - 1]); } // Create directories so that path exists. Returns true if successful or if // the directories already exist; returns false if unable to create directories // for any reason. bool FilePath::CreateDirectoriesRecursively() const { if (!this->IsDirectory()) { return false; } if (pathname_.length() == 0 || this->DirectoryExists()) { return true; } const FilePath parent(this->RemoveTrailingPathSeparator().RemoveFileName()); return parent.CreateDirectoriesRecursively() && this->CreateFolder(); } // Create the directory so that path exists. Returns true if successful or // if the directory already exists; returns false if unable to create the // directory for any reason, including if the parent directory does not // exist. Not named "CreateDirectory" because that's a macro on Windows. bool FilePath::CreateFolder() const { #if GTEST_OS_WINDOWS_MOBILE FilePath removed_sep(this->RemoveTrailingPathSeparator()); LPCWSTR unicode = String::AnsiToUtf16(removed_sep.c_str()); int result = CreateDirectory(unicode, NULL) ? 0 : -1; delete [] unicode; #elif GTEST_OS_WINDOWS int result = _mkdir(pathname_.c_str()); #else int result = mkdir(pathname_.c_str(), 0777); #endif // GTEST_OS_WINDOWS_MOBILE if (result == -1) { return this->DirectoryExists(); // An error is OK if the directory exists. } return true; // No error. } // If input name has a trailing separator character, remove it and return the // name, otherwise return the name string unmodified. // On Windows platform, uses \ as the separator, other platforms use /. FilePath FilePath::RemoveTrailingPathSeparator() const { return IsDirectory() ? FilePath(pathname_.substr(0, pathname_.length() - 1)) : *this; } // Removes any redundant separators that might be in the pathname. // For example, "bar///foo" becomes "bar/foo". Does not eliminate other // redundancies that might be in a pathname involving "." or "..". // TODO(wan@google.com): handle Windows network shares (e.g. \\server\share). void FilePath::Normalize() { if (pathname_.c_str() == NULL) { pathname_ = ""; return; } const char* src = pathname_.c_str(); char* const dest = new char[pathname_.length() + 1]; char* dest_ptr = dest; memset(dest_ptr, 0, pathname_.length() + 1); while (*src != '\0') { *dest_ptr = *src; if (!IsPathSeparator(*src)) { src++; } else { #if GTEST_HAS_ALT_PATH_SEP_ if (*dest_ptr == kAlternatePathSeparator) { *dest_ptr = kPathSeparator; } #endif while (IsPathSeparator(*src)) src++; } dest_ptr++; } *dest_ptr = '\0'; pathname_ = dest; delete[] dest; } } // namespace internal } // namespace testing // Copyright 2008, Google Inc. // 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. // * Neither the name of Google Inc. nor the names of its // contributors may be used to endorse or promote products derived from // this software without specific prior written permission. // // 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 // OWNER 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. // // Author: wan@google.com (Zhanyong Wan) #include <limits.h> #include <stdlib.h> #include <stdio.h> #include <string.h> #if GTEST_OS_WINDOWS_MOBILE # include <windows.h> // For TerminateProcess() #elif GTEST_OS_WINDOWS # include <io.h> # include <sys/stat.h> #else # include <unistd.h> #endif // GTEST_OS_WINDOWS_MOBILE #if GTEST_OS_MAC # include <mach/mach_init.h> # include <mach/task.h> # include <mach/vm_map.h> #endif // GTEST_OS_MAC #if GTEST_OS_QNX # include <devctl.h> # include <sys/procfs.h> #endif // GTEST_OS_QNX // Indicates that this translation unit is part of Google Test's // implementation. It must come before gtest-internal-inl.h is // included, or there will be a compiler error. This trick is to // prevent a user from accidentally including gtest-internal-inl.h in // his code. #define GTEST_IMPLEMENTATION_ 1 #undef GTEST_IMPLEMENTATION_ namespace testing { namespace internal { #if defined(_MSC_VER) || defined(__BORLANDC__) // MSVC and C++Builder do not provide a definition of STDERR_FILENO. const int kStdOutFileno = 1; const int kStdErrFileno = 2; #else const int kStdOutFileno = STDOUT_FILENO; const int kStdErrFileno = STDERR_FILENO; #endif // _MSC_VER #if GTEST_OS_MAC // Returns the number of threads running in the process, or 0 to indicate that // we cannot detect it. size_t GetThreadCount() { const task_t task = mach_task_self(); mach_msg_type_number_t thread_count; thread_act_array_t thread_list; const kern_return_t status = task_threads(task, &thread_list, &thread_count); if (status == KERN_SUCCESS) { // task_threads allocates resources in thread_list and we need to free them // to avoid leaks. vm_deallocate(task, reinterpret_cast<vm_address_t>(thread_list), sizeof(thread_t) * thread_count); return static_cast<size_t>(thread_count); } else { return 0; } } #elif GTEST_OS_QNX // Returns the number of threads running in the process, or 0 to indicate that // we cannot detect it. size_t GetThreadCount() { const int fd = open("/proc/self/as", O_RDONLY); if (fd < 0) { return 0; } procfs_info process_info; const int status = devctl(fd, DCMD_PROC_INFO, &process_info, sizeof(process_info), NULL); close(fd); if (status == EOK) { return static_cast<size_t>(process_info.num_threads); } else { return 0; } } #else size_t GetThreadCount() { // There's no portable way to detect the number of threads, so we just // return 0 to indicate that we cannot detect it. return 0; } #endif // GTEST_OS_MAC #if GTEST_USES_POSIX_RE // Implements RE. Currently only needed for death tests. RE::~RE() { if (is_valid_) { // regfree'ing an invalid regex might crash because the content // of the regex is undefined. Since the regex's are essentially // the same, one cannot be valid (or invalid) without the other // being so too. regfree(&partial_regex_); regfree(&full_regex_); } free(const_cast<char*>(pattern_)); } // Returns true iff regular expression re matches the entire str. bool RE::FullMatch(const char* str, const RE& re) { if (!re.is_valid_) return false; regmatch_t match; return regexec(&re.full_regex_, str, 1, &match, 0) == 0; } // Returns true iff regular expression re matches a substring of str // (including str itself). bool RE::PartialMatch(const char* str, const RE& re) { if (!re.is_valid_) return false; regmatch_t match; return regexec(&re.partial_regex_, str, 1, &match, 0) == 0; } // Initializes an RE from its string representation. void RE::Init(const char* regex) { pattern_ = posix::StrDup(regex); // Reserves enough bytes to hold the regular expression used for a // full match. const size_t full_regex_len = strlen(regex) + 10; char* const full_pattern = new char[full_regex_len]; snprintf(full_pattern, full_regex_len, "^(%s)$", regex); is_valid_ = regcomp(&full_regex_, full_pattern, REG_EXTENDED) == 0; // We want to call regcomp(&partial_regex_, ...) even if the // previous expression returns false. Otherwise partial_regex_ may // not be properly initialized can may cause trouble when it's // freed. // // Some implementation of POSIX regex (e.g. on at least some // versions of Cygwin) doesn't accept the empty string as a valid // regex. We change it to an equivalent form "()" to be safe. if (is_valid_) { const char* const partial_regex = (*regex == '\0') ? "()" : regex; is_valid_ = regcomp(&partial_regex_, partial_regex, REG_EXTENDED) == 0; } EXPECT_TRUE(is_valid_) << "Regular expression \"" << regex << "\" is not a valid POSIX Extended regular expression."; delete[] full_pattern; } #elif GTEST_USES_SIMPLE_RE // Returns true iff ch appears anywhere in str (excluding the // terminating '\0' character). bool IsInSet(char ch, const char* str) { return ch != '\0' && strchr(str, ch) != NULL; } // Returns true iff ch belongs to the given classification. Unlike // similar functions in <ctype.h>, these aren't affected by the // current locale. bool IsAsciiDigit(char ch) { return '0' <= ch && ch <= '9'; } bool IsAsciiPunct(char ch) { return IsInSet(ch, "^-!\"#$%&'()*+,./:;<=>?@[\\]_`{|}~"); } bool IsRepeat(char ch) { return IsInSet(ch, "?*+"); } bool IsAsciiWhiteSpace(char ch) { return IsInSet(ch, " \f\n\r\t\v"); } bool IsAsciiWordChar(char ch) { return ('a' <= ch && ch <= 'z') || ('A' <= ch && ch <= 'Z') || ('0' <= ch && ch <= '9') || ch == '_'; } // Returns true iff "\\c" is a supported escape sequence. bool IsValidEscape(char c) { return (IsAsciiPunct(c) || IsInSet(c, "dDfnrsStvwW")); } // Returns true iff the given atom (specified by escaped and pattern) // matches ch. The result is undefined if the atom is invalid. bool AtomMatchesChar(bool escaped, char pattern_char, char ch) { if (escaped) { // "\\p" where p is pattern_char. switch (pattern_char) { case 'd': return IsAsciiDigit(ch); case 'D': return !IsAsciiDigit(ch); case 'f': return ch == '\f'; case 'n': return ch == '\n'; case 'r': return ch == '\r'; case 's': return IsAsciiWhiteSpace(ch); case 'S': return !IsAsciiWhiteSpace(ch); case 't': return ch == '\t'; case 'v': return ch == '\v'; case 'w': return IsAsciiWordChar(ch); case 'W': return !IsAsciiWordChar(ch); } return IsAsciiPunct(pattern_char) && pattern_char == ch; } return (pattern_char == '.' && ch != '\n') || pattern_char == ch; } // Helper function used by ValidateRegex() to format error messages. std::string FormatRegexSyntaxError(const char* regex, int index) { return (Message() << "Syntax error at index " << index << " in simple regular expression \"" << regex << "\": ").GetString(); } // Generates non-fatal failures and returns false if regex is invalid; // otherwise returns true. bool ValidateRegex(const char* regex) { if (regex == NULL) { // TODO(wan@google.com): fix the source file location in the // assertion failures to match where the regex is used in user // code. ADD_FAILURE() << "NULL is not a valid simple regular expression."; return false; } bool is_valid = true; // True iff ?, *, or + can follow the previous atom. bool prev_repeatable = false; for (int i = 0; regex[i]; i++) { if (regex[i] == '\\') { // An escape sequence i++; if (regex[i] == '\0') { ADD_FAILURE() << FormatRegexSyntaxError(regex, i - 1) << "'\\' cannot appear at the end."; return false; } if (!IsValidEscape(regex[i])) { ADD_FAILURE() << FormatRegexSyntaxError(regex, i - 1) << "invalid escape sequence \"\\" << regex[i] << "\"."; is_valid = false; } prev_repeatable = true; } else { // Not an escape sequence. const char ch = regex[i]; if (ch == '^' && i > 0) { ADD_FAILURE() << FormatRegexSyntaxError(regex, i) << "'^' can only appear at the beginning."; is_valid = false; } else if (ch == '$' && regex[i + 1] != '\0') { ADD_FAILURE() << FormatRegexSyntaxError(regex, i) << "'$' can only appear at the end."; is_valid = false; } else if (IsInSet(ch, "()[]{}|")) { ADD_FAILURE() << FormatRegexSyntaxError(regex, i) << "'" << ch << "' is unsupported."; is_valid = false; } else if (IsRepeat(ch) && !prev_repeatable) { ADD_FAILURE() << FormatRegexSyntaxError(regex, i) << "'" << ch << "' can only follow a repeatable token."; is_valid = false; } prev_repeatable = !IsInSet(ch, "^$?*+"); } } return is_valid; } // Matches a repeated regex atom followed by a valid simple regular // expression. The regex atom is defined as c if escaped is false, // or \c otherwise. repeat is the repetition meta character (?, *, // or +). The behavior is undefined if str contains too many // characters to be indexable by size_t, in which case the test will // probably time out anyway. We are fine with this limitation as // std::string has it too. bool MatchRepetitionAndRegexAtHead( bool escaped, char c, char repeat, const char* regex, const char* str) { const size_t min_count = (repeat == '+') ? 1 : 0; const size_t max_count = (repeat == '?') ? 1 : static_cast<size_t>(-1) - 1; // We cannot call numeric_limits::max() as it conflicts with the // max() macro on Windows. for (size_t i = 0; i <= max_count; ++i) { // We know that the atom matches each of the first i characters in str. if (i >= min_count && MatchRegexAtHead(regex, str + i)) { // We have enough matches at the head, and the tail matches too. // Since we only care about *whether* the pattern matches str // (as opposed to *how* it matches), there is no need to find a // greedy match. return true; } if (str[i] == '\0' || !AtomMatchesChar(escaped, c, str[i])) return false; } return false; } // Returns true iff regex matches a prefix of str. regex must be a // valid simple regular expression and not start with "^", or the // result is undefined. bool MatchRegexAtHead(const char* regex, const char* str) { if (*regex == '\0') // An empty regex matches a prefix of anything. return true; // "$" only matches the end of a string. Note that regex being // valid guarantees that there's nothing after "$" in it. if (*regex == '$') return *str == '\0'; // Is the first thing in regex an escape sequence? const bool escaped = *regex == '\\'; if (escaped) ++regex; if (IsRepeat(regex[1])) { // MatchRepetitionAndRegexAtHead() calls MatchRegexAtHead(), so // here's an indirect recursion. It terminates as the regex gets // shorter in each recursion. return MatchRepetitionAndRegexAtHead( escaped, regex[0], regex[1], regex + 2, str); } else { // regex isn't empty, isn't "$", and doesn't start with a // repetition. We match the first atom of regex with the first // character of str and recurse. return (*str != '\0') && AtomMatchesChar(escaped, *regex, *str) && MatchRegexAtHead(regex + 1, str + 1); } } // Returns true iff regex matches any substring of str. regex must be // a valid simple regular expression, or the result is undefined. // // The algorithm is recursive, but the recursion depth doesn't exceed // the regex length, so we won't need to worry about running out of // stack space normally. In rare cases the time complexity can be // exponential with respect to the regex length + the string length, // but usually it's must faster (often close to linear). bool MatchRegexAnywhere(const char* regex, const char* str) { if (regex == NULL || str == NULL) return false; if (*regex == '^') return MatchRegexAtHead(regex + 1, str); // A successful match can be anywhere in str. do { if (MatchRegexAtHead(regex, str)) return true; } while (*str++ != '\0'); return false; } // Implements the RE class. RE::~RE() { free(const_cast<char*>(pattern_)); free(const_cast<char*>(full_pattern_)); } // Returns true iff regular expression re matches the entire str. bool RE::FullMatch(const char* str, const RE& re) { return re.is_valid_ && MatchRegexAnywhere(re.full_pattern_, str); } // Returns true iff regular expression re matches a substring of str // (including str itself). bool RE::PartialMatch(const char* str, const RE& re) { return re.is_valid_ && MatchRegexAnywhere(re.pattern_, str); } // Initializes an RE from its string representation. void RE::Init(const char* regex) { pattern_ = full_pattern_ = NULL; if (regex != NULL) { pattern_ = posix::StrDup(regex); } is_valid_ = ValidateRegex(regex); if (!is_valid_) { // No need to calculate the full pattern when the regex is invalid. return; } const size_t len = strlen(regex); // Reserves enough bytes to hold the regular expression used for a // full match: we need space to prepend a '^', append a '$', and // terminate the string with '\0'. char* buffer = static_cast<char*>(malloc(len + 3)); full_pattern_ = buffer; if (*regex != '^') *buffer++ = '^'; // Makes sure full_pattern_ starts with '^'. // We don't use snprintf or strncpy, as they trigger a warning when // compiled with VC++ 8.0. memcpy(buffer, regex, len); buffer += len; if (len == 0 || regex[len - 1] != '$') *buffer++ = '$'; // Makes sure full_pattern_ ends with '$'. *buffer = '\0'; } #endif // GTEST_USES_POSIX_RE const char kUnknownFile[] = "unknown file"; // Formats a source file path and a line number as they would appear // in an error message from the compiler used to compile this code. GTEST_API_ ::std::string FormatFileLocation(const char* file, int line) { const std::string file_name(file == NULL ? kUnknownFile : file); if (line < 0) { return file_name + ":"; } #ifdef _MSC_VER return file_name + "(" + StreamableToString(line) + "):"; #else return file_name + ":" + StreamableToString(line) + ":"; #endif // _MSC_VER } // Formats a file location for compiler-independent XML output. // Although this function is not platform dependent, we put it next to // FormatFileLocation in order to contrast the two functions. // Note that FormatCompilerIndependentFileLocation() does NOT append colon // to the file location it produces, unlike FormatFileLocation(). GTEST_API_ ::std::string FormatCompilerIndependentFileLocation( const char* file, int line) { const std::string file_name(file == NULL ? kUnknownFile : file); if (line < 0) return file_name; else return file_name + ":" + StreamableToString(line); } GTestLog::GTestLog(GTestLogSeverity severity, const char* file, int line) : severity_(severity) { const char* const marker = severity == GTEST_INFO ? "[ INFO ]" : severity == GTEST_WARNING ? "[WARNING]" : severity == GTEST_ERROR ? "[ ERROR ]" : "[ FATAL ]"; GetStream() << ::std::endl << marker << " " << FormatFileLocation(file, line).c_str() << ": "; } // Flushes the buffers and, if severity is GTEST_FATAL, aborts the program. GTestLog::~GTestLog() { GetStream() << ::std::endl; if (severity_ == GTEST_FATAL) { fflush(stderr); posix::Abort(); } } // Disable Microsoft deprecation warnings for POSIX functions called from // this class (creat, dup, dup2, and close) #ifdef _MSC_VER # pragma warning(push) # pragma warning(disable: 4996) #endif // _MSC_VER #if GTEST_HAS_STREAM_REDIRECTION // Object that captures an output stream (stdout/stderr). class CapturedStream { public: // The ctor redirects the stream to a temporary file. explicit CapturedStream(int fd) : fd_(fd), uncaptured_fd_(dup(fd)) { # if GTEST_OS_WINDOWS char temp_dir_path[MAX_PATH + 1] = { '\0' }; // NOLINT char temp_file_path[MAX_PATH + 1] = { '\0' }; // NOLINT ::GetTempPathA(sizeof(temp_dir_path), temp_dir_path); const UINT success = ::GetTempFileNameA(temp_dir_path, "gtest_redir", 0, // Generate unique file name. temp_file_path); GTEST_CHECK_(success != 0) << "Unable to create a temporary file in " << temp_dir_path; const int captured_fd = creat(temp_file_path, _S_IREAD | _S_IWRITE); GTEST_CHECK_(captured_fd != -1) << "Unable to open temporary file " << temp_file_path; filename_ = temp_file_path; # else // There's no guarantee that a test has write access to the current // directory, so we create the temporary file in the /tmp directory // instead. We use /tmp on most systems, and /sdcard on Android. // That's because Android doesn't have /tmp. # if GTEST_OS_LINUX_ANDROID // Note: Android applications are expected to call the framework's // Context.getExternalStorageDirectory() method through JNI to get // the location of the world-writable SD Card directory. However, // this requires a Context handle, which cannot be retrieved // globally from native code. Doing so also precludes running the // code as part of a regular standalone executable, which doesn't // run in a Dalvik process (e.g. when running it through 'adb shell'). // // The location /sdcard is directly accessible from native code // and is the only location (unofficially) supported by the Android // team. It's generally a symlink to the real SD Card mount point // which can be /mnt/sdcard, /mnt/sdcard0, /system/media/sdcard, or // other OEM-customized locations. Never rely on these, and always // use /sdcard. char name_template[] = "/sdcard/gtest_captured_stream.XXXXXX"; # else char name_template[] = "/tmp/captured_stream.XXXXXX"; # endif // GTEST_OS_LINUX_ANDROID const int captured_fd = mkstemp(name_template); filename_ = name_template; # endif // GTEST_OS_WINDOWS fflush(NULL); dup2(captured_fd, fd_); close(captured_fd); } ~CapturedStream() { remove(filename_.c_str()); } std::string GetCapturedString() { if (uncaptured_fd_ != -1) { // Restores the original stream. fflush(NULL); dup2(uncaptured_fd_, fd_); close(uncaptured_fd_); uncaptured_fd_ = -1; } FILE* const file = posix::FOpen(filename_.c_str(), "r"); const std::string content = ReadEntireFile(file); posix::FClose(file); return content; } private: // Reads the entire content of a file as an std::string. static std::string ReadEntireFile(FILE* file); // Returns the size (in bytes) of a file. static size_t GetFileSize(FILE* file); const int fd_; // A stream to capture. int uncaptured_fd_; // Name of the temporary file holding the stderr output. ::std::string filename_; GTEST_DISALLOW_COPY_AND_ASSIGN_(CapturedStream); }; // Returns the size (in bytes) of a file. size_t CapturedStream::GetFileSize(FILE* file) { fseek(file, 0, SEEK_END); return static_cast<size_t>(ftell(file)); } // Reads the entire content of a file as a string. std::string CapturedStream::ReadEntireFile(FILE* file) { const size_t file_size = GetFileSize(file); char* const buffer = new char[file_size]; size_t bytes_last_read = 0; // # of bytes read in the last fread() size_t bytes_read = 0; // # of bytes read so far fseek(file, 0, SEEK_SET); // Keeps reading the file until we cannot read further or the // pre-determined file size is reached. do { bytes_last_read = fread(buffer+bytes_read, 1, file_size-bytes_read, file); bytes_read += bytes_last_read; } while (bytes_last_read > 0 && bytes_read < file_size); const std::string content(buffer, bytes_read); delete[] buffer; return content; } # ifdef _MSC_VER # pragma warning(pop) # endif // _MSC_VER static CapturedStream* g_captured_stderr = NULL; static CapturedStream* g_captured_stdout = NULL; // Starts capturing an output stream (stdout/stderr). static void CaptureStream(int fd, const char* stream_name, CapturedStream** stream) { if (*stream != NULL) { GTEST_LOG_(FATAL) << "Only one " << stream_name << " capturer can exist at a time."; } *stream = new CapturedStream(fd); } // Stops capturing the output stream and returns the captured string. static std::string GetCapturedStream(CapturedStream** captured_stream) { const std::string content = (*captured_stream)->GetCapturedString(); delete *captured_stream; *captured_stream = NULL; return content; } // Starts capturing stdout. void CaptureStdout() { CaptureStream(kStdOutFileno, "stdout", &g_captured_stdout); } // Starts capturing stderr. void CaptureStderr() { CaptureStream(kStdErrFileno, "stderr", &g_captured_stderr); } // Stops capturing stdout and returns the captured string. std::string GetCapturedStdout() { return GetCapturedStream(&g_captured_stdout); } // Stops capturing stderr and returns the captured string. std::string GetCapturedStderr() { return GetCapturedStream(&g_captured_stderr); } #endif // GTEST_HAS_STREAM_REDIRECTION #if GTEST_HAS_DEATH_TEST // A copy of all command line arguments. Set by InitGoogleTest(). ::std::vector<testing::internal::string> g_argvs; static const ::std::vector<testing::internal::string>* g_injected_test_argvs = NULL; // Owned. void SetInjectableArgvs(const ::std::vector<testing::internal::string>* argvs) { if (g_injected_test_argvs != argvs) delete g_injected_test_argvs; g_injected_test_argvs = argvs; } const ::std::vector<testing::internal::string>& GetInjectableArgvs() { if (g_injected_test_argvs != NULL) { return *g_injected_test_argvs; } return g_argvs; } #endif // GTEST_HAS_DEATH_TEST #if GTEST_OS_WINDOWS_MOBILE namespace posix { void Abort() { DebugBreak(); TerminateProcess(GetCurrentProcess(), 1); } } // namespace posix #endif // GTEST_OS_WINDOWS_MOBILE // Returns the name of the environment variable corresponding to the // given flag. For example, FlagToEnvVar("foo") will return // "GTEST_FOO" in the open-source version. static std::string FlagToEnvVar(const char* flag) { const std::string full_flag = (Message() << GTEST_FLAG_PREFIX_ << flag).GetString(); Message env_var; for (size_t i = 0; i != full_flag.length(); i++) { env_var << ToUpper(full_flag.c_str()[i]); } return env_var.GetString(); } // Parses 'str' for a 32-bit signed integer. If successful, writes // the result to *value and returns true; otherwise leaves *value // unchanged and returns false. bool ParseInt32(const Message& src_text, const char* str, Int32* value) { // Parses the environment variable as a decimal integer. char* end = NULL; const long long_value = strtol(str, &end, 10); // NOLINT // Has strtol() consumed all characters in the string? if (*end != '\0') { // No - an invalid character was encountered. Message msg; msg << "WARNING: " << src_text << " is expected to be a 32-bit integer, but actually" << " has value \"" << str << "\".\n"; printf("%s", msg.GetString().c_str()); fflush(stdout); return false; } // Is the parsed value in the range of an Int32? const Int32 result = static_cast<Int32>(long_value); if (long_value == LONG_MAX || long_value == LONG_MIN || // The parsed value overflows as a long. (strtol() returns // LONG_MAX or LONG_MIN when the input overflows.) result != long_value // The parsed value overflows as an Int32. ) { Message msg; msg << "WARNING: " << src_text << " is expected to be a 32-bit integer, but actually" << " has value " << str << ", which overflows.\n"; printf("%s", msg.GetString().c_str()); fflush(stdout); return false; } *value = result; return true; } // Reads and returns the Boolean environment variable corresponding to // the given flag; if it's not set, returns default_value. // // The value is considered true iff it's not "0". bool BoolFromGTestEnv(const char* flag, bool default_value) { const std::string env_var = FlagToEnvVar(flag); const char* const string_value = posix::GetEnv(env_var.c_str()); return string_value == NULL ? default_value : strcmp(string_value, "0") != 0; } // Reads and returns a 32-bit integer stored in the environment // variable corresponding to the given flag; if it isn't set or // doesn't represent a valid 32-bit integer, returns default_value. Int32 Int32FromGTestEnv(const char* flag, Int32 default_value) { const std::string env_var = FlagToEnvVar(flag); const char* const string_value = posix::GetEnv(env_var.c_str()); if (string_value == NULL) { // The environment variable is not set. return default_value; } Int32 result = default_value; if (!ParseInt32(Message() << "Environment variable " << env_var, string_value, &result)) { printf("The default value %s is used.\n", (Message() << default_value).GetString().c_str()); fflush(stdout); return default_value; } return result; } // Reads and returns the string environment variable corresponding to // the given flag; if it's not set, returns default_value. const char* StringFromGTestEnv(const char* flag, const char* default_value) { const std::string env_var = FlagToEnvVar(flag); const char* const value = posix::GetEnv(env_var.c_str()); return value == NULL ? default_value : value; } } // namespace internal } // namespace testing // Copyright 2007, Google Inc. // 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. // * Neither the name of Google Inc. nor the names of its // contributors may be used to endorse or promote products derived from // this software without specific prior written permission. // // 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 // OWNER 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. // // Author: wan@google.com (Zhanyong Wan) // Google Test - The Google C++ Testing Framework // // This file implements a universal value printer that can print a // value of any type T: // // void ::testing::internal::UniversalPrinter<T>::Print(value, ostream_ptr); // // It uses the << operator when possible, and prints the bytes in the // object otherwise. A user can override its behavior for a class // type Foo by defining either operator<<(::std::ostream&, const Foo&) // or void PrintTo(const Foo&, ::std::ostream*) in the namespace that // defines Foo. #include <ctype.h> #include <stdio.h> #include <ostream> // NOLINT #include <string> namespace testing { namespace { using ::std::ostream; // Prints a segment of bytes in the given object. void PrintByteSegmentInObjectTo(const unsigned char* obj_bytes, size_t start, size_t count, ostream* os) { char text[5] = ""; for (size_t i = 0; i != count; i++) { const size_t j = start + i; if (i != 0) { // Organizes the bytes into groups of 2 for easy parsing by // human. if ((j % 2) == 0) *os << ' '; else *os << '-'; } GTEST_SNPRINTF_(text, sizeof(text), "%02X", obj_bytes[j]); *os << text; } } // Prints the bytes in the given value to the given ostream. void PrintBytesInObjectToImpl(const unsigned char* obj_bytes, size_t count, ostream* os) { // Tells the user how big the object is. *os << count << "-byte object <"; const size_t kThreshold = 132; const size_t kChunkSize = 64; // If the object size is bigger than kThreshold, we'll have to omit // some details by printing only the first and the last kChunkSize // bytes. // TODO(wan): let the user control the threshold using a flag. if (count < kThreshold) { PrintByteSegmentInObjectTo(obj_bytes, 0, count, os); } else { PrintByteSegmentInObjectTo(obj_bytes, 0, kChunkSize, os); *os << " ... "; // Rounds up to 2-byte boundary. const size_t resume_pos = (count - kChunkSize + 1)/2*2; PrintByteSegmentInObjectTo(obj_bytes, resume_pos, count - resume_pos, os); } *os << ">"; } } // namespace namespace internal2 { // Delegates to PrintBytesInObjectToImpl() to print the bytes in the // given object. The delegation simplifies the implementation, which // uses the << operator and thus is easier done outside of the // ::testing::internal namespace, which contains a << operator that // sometimes conflicts with the one in STL. void PrintBytesInObjectTo(const unsigned char* obj_bytes, size_t count, ostream* os) { PrintBytesInObjectToImpl(obj_bytes, count, os); } } // namespace internal2 namespace internal { // Depending on the value of a char (or wchar_t), we print it in one // of three formats: // - as is if it's a printable ASCII (e.g. 'a', '2', ' '), // - as a hexidecimal escape sequence (e.g. '\x7F'), or // - as a special escape sequence (e.g. '\r', '\n'). enum CharFormat { kAsIs, kHexEscape, kSpecialEscape }; // Returns true if c is a printable ASCII character. We test the // value of c directly instead of calling isprint(), which is buggy on // Windows Mobile. inline bool IsPrintableAscii(wchar_t c) { return 0x20 <= c && c <= 0x7E; } // Prints a wide or narrow char c as a character literal without the // quotes, escaping it when necessary; returns how c was formatted. // The template argument UnsignedChar is the unsigned version of Char, // which is the type of c. template <typename UnsignedChar, typename Char> static CharFormat PrintAsCharLiteralTo(Char c, ostream* os) { switch (static_cast<wchar_t>(c)) { case L'\0': *os << "\\0"; break; case L'\'': *os << "\\'"; break; case L'\\': *os << "\\\\"; break; case L'\a': *os << "\\a"; break; case L'\b': *os << "\\b"; break; case L'\f': *os << "\\f"; break; case L'\n': *os << "\\n"; break; case L'\r': *os << "\\r"; break; case L'\t': *os << "\\t"; break; case L'\v': *os << "\\v"; break; default: if (IsPrintableAscii(c)) { *os << static_cast<char>(c); return kAsIs; } else { *os << "\\x" + String::FormatHexInt(static_cast<UnsignedChar>(c)); return kHexEscape; } } return kSpecialEscape; } // Prints a wchar_t c as if it's part of a string literal, escaping it when // necessary; returns how c was formatted. static CharFormat PrintAsStringLiteralTo(wchar_t c, ostream* os) { switch (c) { case L'\'': *os << "'"; return kAsIs; case L'"': *os << "\\\""; return kSpecialEscape; default: return PrintAsCharLiteralTo<wchar_t>(c, os); } } // Prints a char c as if it's part of a string literal, escaping it when // necessary; returns how c was formatted. static CharFormat PrintAsStringLiteralTo(char c, ostream* os) { return PrintAsStringLiteralTo( static_cast<wchar_t>(static_cast<unsigned char>(c)), os); } // Prints a wide or narrow character c and its code. '\0' is printed // as "'\\0'", other unprintable characters are also properly escaped // using the standard C++ escape sequence. The template argument // UnsignedChar is the unsigned version of Char, which is the type of c. template <typename UnsignedChar, typename Char> void PrintCharAndCodeTo(Char c, ostream* os) { // First, print c as a literal in the most readable form we can find. *os << ((sizeof(c) > 1) ? "L'" : "'"); const CharFormat format = PrintAsCharLiteralTo<UnsignedChar>(c, os); *os << "'"; // To aid user debugging, we also print c's code in decimal, unless // it's 0 (in which case c was printed as '\\0', making the code // obvious). if (c == 0) return; *os << " (" << static_cast<int>(c); // For more convenience, we print c's code again in hexidecimal, // unless c was already printed in the form '\x##' or the code is in // [1, 9]. if (format == kHexEscape || (1 <= c && c <= 9)) { // Do nothing. } else { *os << ", 0x" << String::FormatHexInt(static_cast<UnsignedChar>(c)); } *os << ")"; } void PrintTo(unsigned char c, ::std::ostream* os) { PrintCharAndCodeTo<unsigned char>(c, os); } void PrintTo(signed char c, ::std::ostream* os) { PrintCharAndCodeTo<unsigned char>(c, os); } // Prints a wchar_t as a symbol if it is printable or as its internal // code otherwise and also as its code. L'\0' is printed as "L'\\0'". void PrintTo(wchar_t wc, ostream* os) { PrintCharAndCodeTo<wchar_t>(wc, os); } // Prints the given array of characters to the ostream. CharType must be either // char or wchar_t. // The array starts at begin, the length is len, it may include '\0' characters // and may not be NUL-terminated. template <typename CharType> static void PrintCharsAsStringTo( const CharType* begin, size_t len, ostream* os) { const char* const kQuoteBegin = sizeof(CharType) == 1 ? "\"" : "L\""; *os << kQuoteBegin; bool is_previous_hex = false; for (size_t index = 0; index < len; ++index) { const CharType cur = begin[index]; if (is_previous_hex && IsXDigit(cur)) { // Previous character is of '\x..' form and this character can be // interpreted as another hexadecimal digit in its number. Break string to // disambiguate. *os << "\" " << kQuoteBegin; } is_previous_hex = PrintAsStringLiteralTo(cur, os) == kHexEscape; } *os << "\""; } // Prints a (const) char/wchar_t array of 'len' elements, starting at address // 'begin'. CharType must be either char or wchar_t. template <typename CharType> static void UniversalPrintCharArray( const CharType* begin, size_t len, ostream* os) { // The code // const char kFoo[] = "foo"; // generates an array of 4, not 3, elements, with the last one being '\0'. // // Therefore when printing a char array, we don't print the last element if // it's '\0', such that the output matches the string literal as it's // written in the source code. if (len > 0 && begin[len - 1] == '\0') { PrintCharsAsStringTo(begin, len - 1, os); return; } // If, however, the last element in the array is not '\0', e.g. // const char kFoo[] = { 'f', 'o', 'o' }; // we must print the entire array. We also print a message to indicate // that the array is not NUL-terminated. PrintCharsAsStringTo(begin, len, os); *os << " (no terminating NUL)"; } // Prints a (const) char array of 'len' elements, starting at address 'begin'. void UniversalPrintArray(const char* begin, size_t len, ostream* os) { UniversalPrintCharArray(begin, len, os); } // Prints a (const) wchar_t array of 'len' elements, starting at address // 'begin'. void UniversalPrintArray(const wchar_t* begin, size_t len, ostream* os) { UniversalPrintCharArray(begin, len, os); } // Prints the given C string to the ostream. void PrintTo(const char* s, ostream* os) { if (s == NULL) { *os << "NULL"; } else { *os << ImplicitCast_<const void*>(s) << " pointing to "; PrintCharsAsStringTo(s, strlen(s), os); } } // MSVC compiler can be configured to define whar_t as a typedef // of unsigned short. Defining an overload for const wchar_t* in that case // would cause pointers to unsigned shorts be printed as wide strings, // possibly accessing more memory than intended and causing invalid // memory accesses. MSVC defines _NATIVE_WCHAR_T_DEFINED symbol when // wchar_t is implemented as a native type. #if !defined(_MSC_VER) || defined(_NATIVE_WCHAR_T_DEFINED) // Prints the given wide C string to the ostream. void PrintTo(const wchar_t* s, ostream* os) { if (s == NULL) { *os << "NULL"; } else { *os << ImplicitCast_<const void*>(s) << " pointing to "; PrintCharsAsStringTo(s, wcslen(s), os); } } #endif // wchar_t is native // Prints a ::string object. #if GTEST_HAS_GLOBAL_STRING void PrintStringTo(const ::string& s, ostream* os) { PrintCharsAsStringTo(s.data(), s.size(), os); } #endif // GTEST_HAS_GLOBAL_STRING void PrintStringTo(const ::std::string& s, ostream* os) { PrintCharsAsStringTo(s.data(), s.size(), os); } // Prints a ::wstring object. #if GTEST_HAS_GLOBAL_WSTRING void PrintWideStringTo(const ::wstring& s, ostream* os) { PrintCharsAsStringTo(s.data(), s.size(), os); } #endif // GTEST_HAS_GLOBAL_WSTRING #if GTEST_HAS_STD_WSTRING void PrintWideStringTo(const ::std::wstring& s, ostream* os) { PrintCharsAsStringTo(s.data(), s.size(), os); } #endif // GTEST_HAS_STD_WSTRING } // namespace internal } // namespace testing // Copyright 2008, Google Inc. // 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. // * Neither the name of Google Inc. nor the names of its // contributors may be used to endorse or promote products derived from // this software without specific prior written permission. // // 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 // OWNER 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. // // Author: mheule@google.com (Markus Heule) // // The Google C++ Testing Framework (Google Test) // Indicates that this translation unit is part of Google Test's // implementation. It must come before gtest-internal-inl.h is // included, or there will be a compiler error. This trick is to // prevent a user from accidentally including gtest-internal-inl.h in // his code. #define GTEST_IMPLEMENTATION_ 1 #undef GTEST_IMPLEMENTATION_ namespace testing { using internal::GetUnitTestImpl; // Gets the summary of the failure message by omitting the stack trace // in it. std::string TestPartResult::ExtractSummary(const char* message) { const char* const stack_trace = strstr(message, internal::kStackTraceMarker); return stack_trace == NULL ? message : std::string(message, stack_trace); } // Prints a TestPartResult object. std::ostream& operator<<(std::ostream& os, const TestPartResult& result) { return os << result.file_name() << ":" << result.line_number() << ": " << (result.type() == TestPartResult::kSuccess ? "Success" : result.type() == TestPartResult::kFatalFailure ? "Fatal failure" : "Non-fatal failure") << ":\n" << result.message() << std::endl; } // Appends a TestPartResult to the array. void TestPartResultArray::Append(const TestPartResult& result) { array_.push_back(result); } // Returns the TestPartResult at the given index (0-based). const TestPartResult& TestPartResultArray::GetTestPartResult(int index) const { if (index < 0 || index >= size()) { printf("\nInvalid index (%d) into TestPartResultArray.\n", index); internal::posix::Abort(); } return array_[index]; } // Returns the number of TestPartResult objects in the array. int TestPartResultArray::size() const { return static_cast<int>(array_.size()); } namespace internal { HasNewFatalFailureHelper::HasNewFatalFailureHelper() : has_new_fatal_failure_(false), original_reporter_(GetUnitTestImpl()-> GetTestPartResultReporterForCurrentThread()) { GetUnitTestImpl()->SetTestPartResultReporterForCurrentThread(this); } HasNewFatalFailureHelper::~HasNewFatalFailureHelper() { GetUnitTestImpl()->SetTestPartResultReporterForCurrentThread( original_reporter_); } void HasNewFatalFailureHelper::ReportTestPartResult( const TestPartResult& result) { if (result.fatally_failed()) has_new_fatal_failure_ = true; original_reporter_->ReportTestPartResult(result); } } // namespace internal } // namespace testing // Copyright 2008 Google Inc. // 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. // * Neither the name of Google Inc. nor the names of its // contributors may be used to endorse or promote products derived from // this software without specific prior written permission. // // 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 // OWNER 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. // // Author: wan@google.com (Zhanyong Wan) namespace testing { namespace internal { #if GTEST_HAS_TYPED_TEST_P // Skips to the first non-space char in str. Returns an empty string if str // contains only whitespace characters. static const char* SkipSpaces(const char* str) { while (IsSpace(*str)) str++; return str; } // Verifies that registered_tests match the test names in // defined_test_names_; returns registered_tests if successful, or // aborts the program otherwise. const char* TypedTestCasePState::VerifyRegisteredTestNames( const char* file, int line, const char* registered_tests) { typedef ::std::set<const char*>::const_iterator DefinedTestIter; registered_ = true; // Skip initial whitespace in registered_tests since some // preprocessors prefix stringizied literals with whitespace. registered_tests = SkipSpaces(registered_tests); Message errors; ::std::set<std::string> tests; for (const char* names = registered_tests; names != NULL; names = SkipComma(names)) { const std::string name = GetPrefixUntilComma(names); if (tests.count(name) != 0) { errors << "Test " << name << " is listed more than once.\n"; continue; } bool found = false; for (DefinedTestIter it = defined_test_names_.begin(); it != defined_test_names_.end(); ++it) { if (name == *it) { found = true; break; } } if (found) { tests.insert(name); } else { errors << "No test named " << name << " can be found in this test case.\n"; } } for (DefinedTestIter it = defined_test_names_.begin(); it != defined_test_names_.end(); ++it) { if (tests.count(*it) == 0) { errors << "You forgot to list test " << *it << ".\n"; } } const std::string& errors_str = errors.GetString(); if (errors_str != "") { fprintf(stderr, "%s %s", FormatFileLocation(file, line).c_str(), errors_str.c_str()); fflush(stderr); posix::Abort(); } return registered_tests; } #endif // GTEST_HAS_TYPED_TEST_P } // namespace internal } // namespace testing
[ "thatindiangeek@gmail.com" ]
thatindiangeek@gmail.com
63322e31491e07c713d8bce2480c9d689781b086
62f44c8fb9079a57a0304ef09191dc4714b5373f
/Array/1431.cpp
d26c7f347f3a820fb2a167c8a94f0421bbd9e8e6
[]
no_license
amoghj8/Leetcode-Solutions
9ec97b5942bbcb8349dbb6b9128bffd5758c68e9
57aa1a50d5938176c85a87d97bd381651306e100
refs/heads/master
2023-01-03T00:22:24.332576
2020-10-14T16:19:38
2020-10-14T16:19:38
283,253,640
0
1
null
2020-10-03T11:54:44
2020-07-28T15:30:44
C++
UTF-8
C++
false
false
546
cpp
// 1431. Kids With the Greatest Number of Candies class Solution { public: vector<bool> kidsWithCandies(vector<int>& candies, int extraCandies) { vector<bool> result; int greatestNumber = INT_MIN; for(auto candy:candies) { if(candy>greatestNumber) { greatestNumber = candy; } } for(int i=0;i<candies.size();i++) { (candies[i]+extraCandies>=greatestNumber) ? result.push_back(true) : result.push_back(false); } return result; } };
[ "amoghj8@gmail.com" ]
amoghj8@gmail.com
7b3c52f2a59537d0c96327307e1c84bd5511dfe7
7b697987f7f922330155393a9ba0a808ea63dafe
/include/Hadouken/BitTorrent/TorrentStatus.hpp
d8010bbfb2a790ccce649f9c4e8f451be552f2f1
[ "MIT" ]
permissive
rabbitsmith/hadouken
b3f7f9e35d2e12da08251cfb25c3cc0056c2511b
0823c0187ca61ca38a1faf922f90853b3eb65975
refs/heads/develop
2021-01-17T20:07:21.713862
2015-08-23T12:10:56
2015-08-23T12:10:56
36,056,846
0
0
null
2015-05-22T06:48:57
2015-05-22T06:48:57
null
UTF-8
C++
false
false
4,050
hpp
#ifndef HADOUKEN_BITTORRENT_TORRENTSTATUS_HPP #define HADOUKEN_BITTORRENT_TORRENTSTATUS_HPP #include <Hadouken/Config.hpp> #include <libtorrent/torrent_handle.hpp> #include <Poco/Timespan.h> #include <Poco/Timestamp.h> namespace libtorrent { struct torrent_status; } namespace Hadouken { namespace BitTorrent { struct TorrentHandle; struct TorrentStatus { enum State { QueuedForChecking, CheckingFiles, DownloadingMetadata, Downloading, Finished, Seeding, Allocating, CheckingResumeData }; TorrentStatus(const libtorrent::torrent_status& status); HDKN_EXPORT int getActiveTime() const; HDKN_EXPORT time_t getAddedTime() const; HDKN_EXPORT uint64_t getAllTimeDownload() const; HDKN_EXPORT uint64_t getAllTimeUpload() const; HDKN_EXPORT Poco::Timespan getAnnounceInterval() const; HDKN_EXPORT int getBlockSize() const; HDKN_EXPORT Poco::Timestamp getCompletedTime() const; HDKN_EXPORT int getConnectionsLimit() const; HDKN_EXPORT int getConnectCandidates() const; HDKN_EXPORT std::string getCurrentTracker() const; HDKN_EXPORT float getDistributedCopies() const; HDKN_EXPORT int getDownloadPayloadRate() const; HDKN_EXPORT int getDownloadRate() const; HDKN_EXPORT int getDownBandwidthQueue() const; HDKN_EXPORT std::string getError() const; HDKN_EXPORT Poco::Timestamp getFinishedTime() const; HDKN_EXPORT TorrentHandle getHandle() const; HDKN_EXPORT bool hasIncoming() const; HDKN_EXPORT bool hasMetadata() const; HDKN_EXPORT std::string getInfoHash() const; HDKN_EXPORT bool getIpFilterApplies() const; HDKN_EXPORT Poco::Timespan getLastScrape() const; HDKN_EXPORT Poco::Timestamp getLastSeenComplete() const; HDKN_EXPORT int getListPeers() const; HDKN_EXPORT int getListSeeds() const; HDKN_EXPORT std::string getName() const; HDKN_EXPORT bool getNeedSaveResume() const; HDKN_EXPORT Poco::Timespan getNextAnnounce() const; HDKN_EXPORT int getNumComplete() const; HDKN_EXPORT int getNumConnections() const; HDKN_EXPORT int getNumIncomplete() const; HDKN_EXPORT int getNumPeers() const; HDKN_EXPORT int getNumPieces() const; HDKN_EXPORT int getNumSeeds() const; HDKN_EXPORT int getNumUploads() const; // TODO Bitfield getPieces const; HDKN_EXPORT int getPriority() const; HDKN_EXPORT float getProgress() const; HDKN_EXPORT int getQueuePosition() const; HDKN_EXPORT std::string getSavePath() const; HDKN_EXPORT Poco::Timespan getSeedingTime() const; // TODO seed mode HDKN_EXPORT int getSeedRank() const; // TODO share mode HDKN_EXPORT int getSparseRegions() const; HDKN_EXPORT State getState() const; HDKN_EXPORT uint64_t getTotalDownload() const; HDKN_EXPORT uint64_t getTotalUpload() const; HDKN_EXPORT int getUploadRate() const; HDKN_EXPORT bool isAutoManaged() const; HDKN_EXPORT bool isFinished() const; HDKN_EXPORT bool isMovingStorage() const; HDKN_EXPORT bool isPaused() const; HDKN_EXPORT bool isSeeding() const; HDKN_EXPORT bool isSequentialDownload() const; private: const libtorrent::torrent_status status_; }; } } #endif
[ "viktor@viktorelofsson.se" ]
viktor@viktorelofsson.se
695390a12f8060e2d2805edb9f8c8c99a6566f1f
f715e9f872235dfab9c89149cd5c661a889a1bbc
/Containers/include/HashSet.h
ca1523f9f750c8a17bc4009edc82dde264e3affd
[]
no_license
Aldarrion/HsContainers
02f7572cce8253223127e6100c77839e3f328d60
42f2da857719980821798cbba07c2b144c8d4ad0
refs/heads/master
2020-12-26T22:43:54.086195
2020-02-01T20:24:52
2020-02-01T20:24:52
237,673,082
0
0
null
null
null
null
UTF-8
C++
false
false
306
h
#include <stdint.h> namespace hs { template<class TKey> class HashSet { public: using Hash_t = int32_t; void insert(const TKey& key) { // TODO } bool contains(const TKey& key) { // TODO return false; } private: struct Entry { TKey key_; int32_t distance_; }; }; } // namespace hs
[ "smejkal.pa@gmail.com" ]
smejkal.pa@gmail.com
2b8bbf01fdcfb39e586fd5559a9920824cac3468
e5b70789fd7f3409743af34cc7d6f8b04bfde8f0
/Class/FriendMethod2Class/position.cpp
788f1d9c0360fc9f3323e9d5c134208a156f298d
[]
no_license
gustavojoteror/C-fromBeginner2Expert
1577f8224a9c5c339fd119d2e197613a5f24788d
1d539cc4354c654e871806d9f0ccd2031c32fa64
refs/heads/master
2020-06-27T00:40:58.022159
2019-07-31T07:19:43
2019-07-31T07:19:43
199,801,507
0
0
null
null
null
null
UTF-8
C++
false
false
570
cpp
#include "position.h" #include <iostream> // IOstream stands for Input Output stream using namespace std; Position::Position(int x, int y) { this->x=x; this->y=y; //this means: this instance e.g. var.x= x } Position::~Position() { } void Position::getPosition() const // const is added so this method can be used for const instances { cout<< "The x : " << x << endl; cout<< "The y : " << y << endl; } void Position::setPosition(int x, int y) // this method on the other had can't be used for const instances { this->x=x; this->y=y; }
[ "gjoterorodrigu@gjoterorodrigu-OptiPlex-7040" ]
gjoterorodrigu@gjoterorodrigu-OptiPlex-7040
723333b198b3b97a90cc599622d890e9a0b4d796
8cf32b4cbca07bd39341e1d0a29428e420b492a6
/unittests/ram_tests.cpp
19cbb1ee5379982df89b92ef93d049211c152f10
[ "MIT" ]
permissive
cubetrain/CubeTrain
e1cd516d5dbca77082258948d3c7fc70ebd50fdc
b930a3e88e941225c2c54219267f743c790e388f
refs/heads/master
2020-04-11T23:00:50.245442
2018-12-17T16:07:16
2018-12-17T16:07:16
156,970,178
0
0
null
null
null
null
UTF-8
C++
false
false
12,302
cpp
/** * @file api_tests.cpp * @copyright defined in seat/LICENSE.txt */ #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wsign-compare" #include <boost/test/unit_test.hpp> #pragma GCC diagnostic pop #include <cubetrain/testing/tester.hpp> #include <cubetrain/chain/exceptions.hpp> #include <cubetrain/chain/resource_limits.hpp> #include <fc/exception/exception.hpp> #include <fc/variant_object.hpp> #include "cubetrain_system_tester.hpp" #include <test_ram_limit/test_ram_limit.abi.hpp> #include <test_ram_limit/test_ram_limit.wast.hpp> #define DISABLE_SEATLIB_SERIALIZE #include <test_api/test_api_common.hpp> /* * register test suite `ram_tests` */ BOOST_AUTO_TEST_SUITE(ram_tests) /************************************************************************************* * ram_tests test case *************************************************************************************/ BOOST_FIXTURE_TEST_CASE(ram_tests, cubetrain_system::cubetrain_system_tester) { try { auto init_request_bytes = 80000; const auto increment_contract_bytes = 10000; const auto table_allocation_bytes = 12000; BOOST_REQUIRE_MESSAGE(table_allocation_bytes > increment_contract_bytes, "increment_contract_bytes must be less than table_allocation_bytes for this test setup to work"); buyrambytes(config::system_account_name, config::system_account_name, 70000); produce_blocks(10); create_account_with_resources(N(testram11111),config::system_account_name, init_request_bytes + 40); create_account_with_resources(N(testram22222),config::system_account_name, init_request_bytes + 1190); produce_blocks(10); BOOST_REQUIRE_EQUAL( success(), stake( "cubetrain.st", "testram11111", core_from_string("10.0000"), core_from_string("5.0000") ) ); produce_blocks(10); for (auto i = 0; i < 10; ++i) { try { set_code( N(testram11111), test_ram_limit_wast ); break; } catch (const ram_usage_exceeded&) { init_request_bytes += increment_contract_bytes; buyrambytes(config::system_account_name, N(testram11111), increment_contract_bytes); buyrambytes(config::system_account_name, N(testram22222), increment_contract_bytes); } } produce_blocks(10); for (auto i = 0; i < 10; ++i) { try { set_abi( N(testram11111), test_ram_limit_abi ); break; } catch (const ram_usage_exceeded&) { init_request_bytes += increment_contract_bytes; buyrambytes(config::system_account_name, N(testram11111), increment_contract_bytes); buyrambytes(config::system_account_name, N(testram22222), increment_contract_bytes); } } produce_blocks(10); set_code( N(testram22222), test_ram_limit_wast ); set_abi( N(testram22222), test_ram_limit_abi ); produce_blocks(10); auto total = get_total_stake( N(testram11111) ); const auto init_bytes = total["ram_bytes"].as_uint64(); auto rlm = control->get_resource_limits_manager(); auto initial_ram_usage = rlm.get_account_ram_usage(N(testram11111)); // calculate how many more bytes we need to have table_allocation_bytes for database stores auto more_ram = table_allocation_bytes + init_bytes - init_request_bytes; BOOST_REQUIRE_MESSAGE(more_ram >= 0, "Underlying understanding changed, need to reduce size of init_request_bytes"); wdump((init_bytes)(initial_ram_usage)(init_request_bytes)(more_ram) ); buyrambytes(config::system_account_name, N(testram11111), more_ram); buyrambytes(config::system_account_name, N(testram22222), more_ram); TESTER* tester = this; // allocate just under the allocated bytes tester->push_action( N(testram11111), N(setentry), N(testram11111), mvo() ("payer", "testram11111") ("from", 1) ("to", 10) ("size", 1780 /*1910*/)); produce_blocks(1); auto ram_usage = rlm.get_account_ram_usage(N(testram11111)); total = get_total_stake( N(testram11111) ); const auto ram_bytes = total["ram_bytes"].as_uint64(); wdump((ram_bytes)(ram_usage)(initial_ram_usage)(init_bytes)(ram_usage - initial_ram_usage)(init_bytes - ram_usage) ); wlog("ram_tests 1 %%%%%%"); // allocate just beyond the allocated bytes BOOST_REQUIRE_EXCEPTION( tester->push_action( N(testram11111), N(setentry), N(testram11111), mvo() ("payer", "testram11111") ("from", 1) ("to", 10) ("size", 1790 /*1920*/)), ram_usage_exceeded, fc_exception_message_starts_with("account testram11111 has insufficient ram")); wlog("ram_tests 2 %%%%%%"); produce_blocks(1); BOOST_REQUIRE_EQUAL(ram_usage, rlm.get_account_ram_usage(N(testram11111))); // update the entries with smaller allocations so that we can verify space is freed and new allocations can be made tester->push_action( N(testram11111), N(setentry), N(testram11111), mvo() ("payer", "testram11111") ("from", 1) ("to", 10) ("size", 1680/*1810*/)); produce_blocks(1); BOOST_REQUIRE_EQUAL(ram_usage - 1000, rlm.get_account_ram_usage(N(testram11111))); // verify the added entry is beyond the allocation bytes limit BOOST_REQUIRE_EXCEPTION( tester->push_action( N(testram11111), N(setentry), N(testram11111), mvo() ("payer", "testram11111") ("from", 1) ("to", 11) ("size", 1680/*1810*/)), ram_usage_exceeded, fc_exception_message_starts_with("account testram11111 has insufficient ram")); produce_blocks(1); BOOST_REQUIRE_EQUAL(ram_usage - 1000, rlm.get_account_ram_usage(N(testram11111))); // verify the new entry's bytes minus the freed up bytes for existing entries still exceeds the allocation bytes limit BOOST_REQUIRE_EXCEPTION( tester->push_action( N(testram11111), N(setentry), N(testram11111), mvo() ("payer", "testram11111") ("from", 1) ("to", 11) ("size", 1760)), ram_usage_exceeded, fc_exception_message_starts_with("account testram11111 has insufficient ram")); produce_blocks(1); BOOST_REQUIRE_EQUAL(ram_usage - 1000, rlm.get_account_ram_usage(N(testram11111))); // verify the new entry's bytes minus the freed up bytes for existing entries are under the allocation bytes limit tester->push_action( N(testram11111), N(setentry), N(testram11111), mvo() ("payer", "testram11111") ("from", 1) ("to", 11) ("size", 1600/*1720*/)); produce_blocks(1); tester->push_action( N(testram11111), N(rmentry), N(testram11111), mvo() ("from", 3) ("to", 3)); produce_blocks(1); // verify that the new entry will exceed the allocation bytes limit BOOST_REQUIRE_EXCEPTION( tester->push_action( N(testram11111), N(setentry), N(testram11111), mvo() ("payer", "testram11111") ("from", 12) ("to", 12) ("size", 1780)), ram_usage_exceeded, fc_exception_message_starts_with("account testram11111 has insufficient ram")); produce_blocks(1); // verify that the new entry is under the allocation bytes limit tester->push_action( N(testram11111), N(setentry), N(testram11111), mvo() ("payer", "testram11111") ("from", 12) ("to", 12) ("size", 1620/*1720*/)); produce_blocks(1); // verify that anoth new entry will exceed the allocation bytes limit, to setup testing of new payer BOOST_REQUIRE_EXCEPTION( tester->push_action( N(testram11111), N(setentry), N(testram11111), mvo() ("payer", "testram11111") ("from", 13) ("to", 13) ("size", 1660)), ram_usage_exceeded, fc_exception_message_starts_with("account testram11111 has insufficient ram")); produce_blocks(1); // verify that the new entry is under the allocation bytes limit tester->push_action( N(testram11111), N(setentry), {N(testram11111),N(testram22222)}, mvo() ("payer", "testram22222") ("from", 12) ("to", 12) ("size", 1720)); produce_blocks(1); // verify that another new entry that is too big will exceed the allocation bytes limit, to setup testing of new payer BOOST_REQUIRE_EXCEPTION( tester->push_action( N(testram11111), N(setentry), N(testram11111), mvo() ("payer", "testram11111") ("from", 13) ("to", 13) ("size", 1900)), ram_usage_exceeded, fc_exception_message_starts_with("account testram11111 has insufficient ram")); produce_blocks(1); wlog("ram_tests 18 %%%%%%"); // verify that the new entry is under the allocation bytes limit, because entry 12 is now charged to testram22222 tester->push_action( N(testram11111), N(setentry), N(testram11111), mvo() ("payer", "testram11111") ("from", 13) ("to", 13) ("size", 1720)); produce_blocks(1); // verify that new entries for testram22222 exceed the allocation bytes limit BOOST_REQUIRE_EXCEPTION( tester->push_action( N(testram11111), N(setentry), {N(testram11111),N(testram22222)}, mvo() ("payer", "testram22222") ("from", 12) ("to", 21) ("size", 1930)), ram_usage_exceeded, fc_exception_message_starts_with("account testram22222 has insufficient ram")); produce_blocks(1); // verify that new entries for testram22222 are under the allocation bytes limit tester->push_action( N(testram11111), N(setentry), {N(testram11111),N(testram22222)}, mvo() ("payer", "testram22222") ("from", 12) ("to", 21) ("size", 1910)); produce_blocks(1); // verify that new entry for testram22222 exceed the allocation bytes limit BOOST_REQUIRE_EXCEPTION( tester->push_action( N(testram11111), N(setentry), {N(testram11111),N(testram22222)}, mvo() ("payer", "testram22222") ("from", 22) ("to", 22) ("size", 1910)), ram_usage_exceeded, fc_exception_message_starts_with("account testram22222 has insufficient ram")); produce_blocks(1); tester->push_action( N(testram11111), N(rmentry), N(testram11111), mvo() ("from", 20) ("to", 20)); produce_blocks(1); // verify that new entry for testram22222 are under the allocation bytes limit tester->push_action( N(testram11111), N(setentry), {N(testram11111),N(testram22222)}, mvo() ("payer", "testram22222") ("from", 22) ("to", 22) ("size", 1910)); produce_blocks(1); } FC_LOG_AND_RETHROW() } BOOST_AUTO_TEST_SUITE_END()
[ "1848@shanchain.com" ]
1848@shanchain.com
3439b1e4d51f94a1d94668c0eacc836c8ef6efc5
f00a4c7ad3fa9d2394131002ca1d024c30681e71
/Library/Library/x64/Debug/uic/ui_AddMessage.h
ab702bccb6ed9710f2aa8f11b2e358964ecd0c8a
[]
no_license
belowthetree/LibrarySystem
4b9a54644ec8b6a5615feaaf7058278207991789
f8f4ace2bcee83fe504a736dc43e18679b1e37f1
refs/heads/master
2020-07-30T08:10:17.372314
2019-10-28T04:27:10
2019-10-28T04:27:10
210,144,506
3
1
null
null
null
null
UTF-8
C++
false
false
2,821
h
/******************************************************************************** ** Form generated from reading UI file 'AddMessage.ui' ** ** Created by: Qt User Interface Compiler version 5.9.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ #ifndef UI_ADDMESSAGE_H #define UI_ADDMESSAGE_H #include <QtCore/QVariant> #include <QtWidgets/QAction> #include <QtWidgets/QApplication> #include <QtWidgets/QButtonGroup> #include <QtWidgets/QGroupBox> #include <QtWidgets/QHeaderView> #include <QtWidgets/QLabel> #include <QtWidgets/QPushButton> #include <QtWidgets/QTextEdit> #include <QtWidgets/QWidget> QT_BEGIN_NAMESPACE class Ui_AddMessage { public: QLabel *label_3; QTextEdit *textEdit_3; QGroupBox *groupBox; QPushButton *pushButton; QPushButton *pushButton_3; void setupUi(QWidget *AddMessage) { if (AddMessage->objectName().isEmpty()) AddMessage->setObjectName(QStringLiteral("AddMessage")); AddMessage->resize(989, 700); label_3 = new QLabel(AddMessage); label_3->setObjectName(QStringLiteral("label_3")); label_3->setGeometry(QRect(420, 50, 101, 31)); textEdit_3 = new QTextEdit(AddMessage); textEdit_3->setObjectName(QStringLiteral("textEdit_3")); textEdit_3->setGeometry(QRect(290, 120, 411, 271)); groupBox = new QGroupBox(AddMessage); groupBox->setObjectName(QStringLiteral("groupBox")); groupBox->setGeometry(QRect(300, 460, 381, 71)); pushButton = new QPushButton(groupBox); pushButton->setObjectName(QStringLiteral("pushButton")); pushButton->setGeometry(QRect(30, 20, 112, 34)); pushButton_3 = new QPushButton(groupBox); pushButton_3->setObjectName(QStringLiteral("pushButton_3")); pushButton_3->setGeometry(QRect(240, 20, 112, 34)); retranslateUi(AddMessage); QMetaObject::connectSlotsByName(AddMessage); } // setupUi void retranslateUi(QWidget *AddMessage) { AddMessage->setWindowTitle(QApplication::translate("AddMessage", "AddMessage", Q_NULLPTR)); label_3->setText(QApplication::translate("AddMessage", "<html><head/><body><p><span style=\" font-size:11pt;\">\347\225\231\350\250\200\345\206\205\345\256\271</span></p></body></html>", Q_NULLPTR)); groupBox->setTitle(QString()); pushButton->setText(QApplication::translate("AddMessage", "\346\267\273\345\212\240", Q_NULLPTR)); pushButton_3->setText(QApplication::translate("AddMessage", "\345\217\226\346\266\210", Q_NULLPTR)); } // retranslateUi }; namespace Ui { class AddMessage: public Ui_AddMessage {}; } // namespace Ui QT_END_NAMESPACE #endif // UI_ADDMESSAGE_H
[ "1427007602@qq.com" ]
1427007602@qq.com
a4dfb1998e866b13b5952a3a381584d9e745e36e
3cd7874518b68eb8093cef6969576e907f138981
/Project8_PidController/src/PID.h
4f5fa009ca089cb673bedb4124341cac8e2b7f72
[ "MIT" ]
permissive
pjt9188/Udacity_SDC_Projects
7333ea81de81fa3cece94108234c43b3e7781c39
7ef0d7b34526650a191df779868821c17058c758
refs/heads/master
2023-06-04T11:39:51.703509
2021-06-30T15:04:05
2021-06-30T15:04:05
286,644,758
0
0
null
null
null
null
UTF-8
C++
false
false
872
h
#ifndef PID_H #define PID_H #include <vector> class PID { public: /** * Constructor */ PID(); /** * Destructor. */ virtual ~PID(); /** * Initialize PID. * @param (Kp, Ki, Kd) The initial PID coefficients */ void Init(double Kp, double Ki, double Kd); /** * Update the PID error variables given cross track error. * @param cte The current cross track error */ void UpdateError(double cte); /** * Calculate the total PID error. * @output The total PID error */ double TotalError(); /** * Calculate the total PID error. * @output The total PID error */ double Output(); private: /** * PID Errors */ double p_error_; double i_error_; double d_error_; double total_error_; /** * PID Coefficients */ double Kp_; double Ki_; double Kd_; }; #endif // PID_H
[ "pjt9188@naver.com" ]
pjt9188@naver.com
e4d3128699d58e91ce7c79d6195a7ec59b15acfb
da1500e0d3040497614d5327d2461a22e934b4d8
/starboard/shared/stub/media_get_audio_configuration.cc
3dd16cee147f7d2965c04c9ad112cbfa13a2f337
[ "Apache-2.0", "BSD-3-Clause" ]
permissive
youtube/cobalt
34085fc93972ebe05b988b15410e99845efd1968
acefdaaadd3ef46f10f63d1acae2259e4024d383
refs/heads/main
2023-09-01T13:09:47.225174
2023-09-01T08:54:54
2023-09-01T08:54:54
50,049,789
169
80
BSD-3-Clause
2023-09-14T21:50:50
2016-01-20T18:11:34
null
UTF-8
C++
false
false
775
cc
// Copyright 2017 The Cobalt Authors. 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. #include "starboard/media.h" bool SbMediaGetAudioConfiguration( int output_index, SbMediaAudioConfiguration* out_configuration) { return false; }
[ "brianting@google.com" ]
brianting@google.com
942f4827824ab43a05233d0e6de4cb4480bd23a2
718c6e7cbe8c6905c6287ab2f200603d3f0bf287
/vmapextension/Utility.h
bf90179b5148f8d2fde67fa42aed714518d6d6fb
[]
no_license
Bia10/WOW-Bot
bf4c1a5ec6508459097533c308a1784bd0c2cfce
538162199e75b568989062842ae1f563e0ae2974
refs/heads/master
2021-01-17T17:10:27.163225
2010-02-17T21:15:49
2010-02-17T21:15:49
95,457,088
1
0
null
2017-06-26T14:45:10
2017-06-26T14:45:09
null
UTF-8
C++
false
false
640
h
#include <iostream> #include <string> #include <map> #include <vector> #include <stdio.h> void printlastcall(); void printstacktrace(); using namespace std; void error(std::string msg,...); void debug(std::string msg,...); void info(std::string msg,...); void notice(std::string msg,...); void good(std::string msg,...); void bad(std::string msg,...); std::string strfmt(std::string fmt,...); char * geterror(); string join(vector<string> ar,int start); void delchr(char c, string &s); std::vector<std::string> split(std::string s,std::string d); std::string getfiledata(char * filename); char * signalname(int s); double getcurrenttime();
[ "tiziano@tizbac.dyndns.org" ]
tiziano@tizbac.dyndns.org
33cc3964e6710d7bc3d5acf56e70218d49e2036f
dd6b6da760c32ac6830c52aa2f4d5cce17e4d408
/magma-2.5.0/src/cgeqrf_mgpu.cpp
459f0e928e6582033a5847ea7f45c22a950092d8
[]
no_license
uumami/hit_and_run
81584b4f68cf25a2a1140baa3ee88f9e1844b672
dfda812a52bbd65e02753b9abcb9f54aeb4e8184
refs/heads/master
2023-03-13T16:48:37.975390
2023-02-28T05:04:58
2023-02-28T05:04:58
139,909,134
1
0
null
null
null
null
UTF-8
C++
false
false
13,526
cpp
/* -- MAGMA (version 2.5.0) -- Univ. of Tennessee, Knoxville Univ. of California, Berkeley Univ. of Colorado, Denver @date January 2019 @generated from src/zgeqrf_mgpu.cpp, normal z -> c, Wed Jan 2 14:18:49 2019 */ #include "magma_internal.h" /***************************************************************************//** Purpose ------- CGEQRF computes a QR factorization of a complex M-by-N matrix A: A = Q * R. This is a GPU interface of the routine. Arguments --------- @param[in] ngpu INTEGER Number of GPUs to use. ngpu > 0. @param[in] m INTEGER The number of rows of the matrix A. M >= 0. @param[in] n INTEGER The number of columns of the matrix A. N >= 0. @param[in,out] dlA COMPLEX array of pointers on the GPU, dimension (ngpu). On entry, the M-by-N matrix A distributed over GPUs (d_lA[d] points to the local matrix on d-th GPU). It uses 1D block column cyclic format with the block size of nb, and each local matrix is stored by column. On exit, the elements on and above the diagonal of the array contain the min(M,N)-by-N upper trapezoidal matrix R (R is upper triangular if m >= n); the elements below the diagonal, with the array TAU, represent the orthogonal matrix Q as a product of min(m,n) elementary reflectors (see Further Details). @param[in] ldda INTEGER The leading dimension of the array dA. LDDA >= max(1,M). To benefit from coalescent memory accesses LDDA must be divisible by 16. @param[out] tau COMPLEX array, dimension (min(M,N)) The scalar factors of the elementary reflectors (see Further Details). @param[out] info INTEGER - = 0: successful exit - < 0: if INFO = -i, the i-th argument had an illegal value or another error occured, such as memory allocation failed. Further Details --------------- The matrix Q is represented as a product of elementary reflectors Q = H(1) H(2) . . . H(k), where k = min(m,n). Each H(i) has the form H(i) = I - tau * v * v' where tau is a complex scalar, and v is a complex vector with v(1:i-1) = 0 and v(i) = 1; v(i+1:m) is stored on exit in A(i+1:m,i), and tau in TAU(i). @ingroup magma_geqrf *******************************************************************************/ extern "C" magma_int_t magma_cgeqrf2_mgpu( magma_int_t ngpu, magma_int_t m, magma_int_t n, magmaFloatComplex_ptr dlA[], magma_int_t ldda, magmaFloatComplex *tau, magma_int_t *info ) { #define dlA(dev, i, j) (dlA[dev] + (i) + (j)*(ldda)) #define hpanel(i) (hpanel + (i)) // set to NULL to make cleanup easy: free(NULL) does nothing. magmaFloatComplex *dwork[MagmaMaxGPUs]={NULL}, *dpanel[MagmaMaxGPUs]={NULL}; magmaFloatComplex *hwork=NULL, *hpanel=NULL; magma_queue_t queues[MagmaMaxGPUs][2]={{NULL}}; magma_event_t panel_event[MagmaMaxGPUs]={NULL}; magma_int_t i, j, min_mn, dev, ldhpanel, lddwork, rows; magma_int_t ib, nb; magma_int_t lhwork, lwork; magma_int_t panel_dev, i_local, i_nb_local, n_local[MagmaMaxGPUs], la_dev, dpanel_offset; *info = 0; if (m < 0) { *info = -1; } else if (n < 0) { *info = -2; } else if (ldda < max(1,m)) { *info = -4; } if (*info != 0) { magma_xerbla( __func__, -(*info) ); return *info; } min_mn = min(m,n); if (min_mn == 0) return *info; magma_device_t orig_dev; magma_getdevice( &orig_dev ); nb = magma_get_cgeqrf_nb( m, n ); /* dwork is (n*nb) --- for T (nb*nb) and clarfb work ((n-nb)*nb) --- * + dpanel (ldda*nb), on each GPU. * I think clarfb work could be smaller, max(n_local[:]). * Oddly, T and clarfb work get stacked on top of each other, both with lddwork=n. * on GPU that owns panel, set dpanel = dlA(dev,i,i_local). * on other GPUs, set dpanel = dwork[dev] + dpanel_offset. */ lddwork = n; dpanel_offset = lddwork*nb; for( dev=0; dev < ngpu; dev++ ) { magma_setdevice( dev ); if ( MAGMA_SUCCESS != magma_cmalloc( &(dwork[dev]), (lddwork + ldda)*nb )) { *info = MAGMA_ERR_DEVICE_ALLOC; goto CLEANUP; } } /* hwork is MAX( workspace for cgeqrf (n*nb), two copies of T (2*nb*nb) ) * + hpanel (m*nb). * for last block, need 2*n*nb total. */ ldhpanel = m; lhwork = max( n*nb, 2*nb*nb ); lwork = max( lhwork + ldhpanel*nb, 2*n*nb ); if ( MAGMA_SUCCESS != magma_cmalloc_pinned( &hwork, lwork )) { *info = MAGMA_ERR_HOST_ALLOC; goto CLEANUP; } hpanel = hwork + lhwork; /* Set the number of local n for each GPU */ for( dev=0; dev < ngpu; dev++ ) { n_local[dev] = ((n/nb)/ngpu)*nb; if (dev < (n/nb) % ngpu) n_local[dev] += nb; else if (dev == (n/nb) % ngpu) n_local[dev] += n % nb; } for( dev=0; dev < ngpu; dev++ ) { magma_setdevice( dev ); magma_queue_create( dev, &queues[dev][0] ); magma_queue_create( dev, &queues[dev][1] ); magma_event_create( &panel_event[dev] ); } if ( nb < min_mn ) { /* Use blocked code initially */ // Note: as written, ib cannot be < nb. for( i = 0; i < min_mn-nb; i += nb ) { /* Set the GPU number that holds the current panel */ panel_dev = (i/nb) % ngpu; /* Set the local index where the current panel is (j == i) */ i_local = i/(nb*ngpu)*nb; ib = min(min_mn-i, nb); rows = m-i; /* Send current panel to the CPU, after panel_event indicates it has been updated */ magma_setdevice( panel_dev ); magma_queue_wait_event( queues[panel_dev][1], panel_event[panel_dev] ); magma_cgetmatrix_async( rows, ib, dlA(panel_dev, i, i_local), ldda, hpanel(i), ldhpanel, queues[panel_dev][1] ); magma_queue_sync( queues[panel_dev][1] ); // Factor panel lapackf77_cgeqrf( &rows, &ib, hpanel(i), &ldhpanel, tau+i, hwork, &lhwork, info ); if ( *info != 0 ) { fprintf( stderr, "error %lld\n", (long long) *info ); } // Form the triangular factor of the block reflector // H = H(i) H(i+1) . . . H(i+ib-1) lapackf77_clarft( MagmaForwardStr, MagmaColumnwiseStr, &rows, &ib, hpanel(i), &ldhpanel, tau+i, hwork, &ib ); magma_cpanel_to_q( MagmaUpper, ib, hpanel(i), ldhpanel, hwork + ib*ib ); // Send the current panel back to the GPUs for( dev=0; dev < ngpu; dev++ ) { magma_setdevice( dev ); if (dev == panel_dev) dpanel[dev] = dlA(dev, i, i_local); else dpanel[dev] = dwork[dev] + dpanel_offset; magma_csetmatrix_async( rows, ib, hpanel(i), ldhpanel, dpanel[dev], ldda, queues[dev][0] ); } for( dev=0; dev < ngpu; dev++ ) { magma_setdevice( dev ); magma_queue_sync( queues[dev][0] ); } // TODO: if magma_cpanel_to_q copied whole block, wouldn't need to restore // -- just send the copy to the GPUs. // TODO: also, could zero out the lower triangle and use Azzam's larfb w/ gemm. /* Restore the panel */ magma_cq_to_panel( MagmaUpper, ib, hpanel(i), ldhpanel, hwork + ib*ib ); if (i + ib < n) { /* Send the T matrix to the GPU. */ for( dev=0; dev < ngpu; dev++ ) { magma_setdevice( dev ); magma_csetmatrix_async( ib, ib, hwork, ib, dwork[dev], lddwork, queues[dev][0] ); } la_dev = (panel_dev+1) % ngpu; for( dev=0; dev < ngpu; dev++ ) { magma_setdevice( dev ); if (dev == la_dev && i+nb < min_mn-nb) { // If not last panel, // for look-ahead panel, apply H' to A(i:m,i+ib:i+2*ib) i_nb_local = (i+nb)/(nb*ngpu)*nb; magma_clarfb_gpu( MagmaLeft, MagmaConjTrans, MagmaForward, MagmaColumnwise, rows, ib, ib, dpanel[dev], ldda, // V dwork[dev], lddwork, // T dlA(dev, i, i_nb_local), ldda, // C dwork[dev]+ib, lddwork, // work queues[dev][0] ); magma_event_record( panel_event[dev], queues[dev][0] ); // for trailing matrix, apply H' to A(i:m,i+2*ib:n) magma_clarfb_gpu( MagmaLeft, MagmaConjTrans, MagmaForward, MagmaColumnwise, rows, n_local[dev]-(i_nb_local+ib), ib, dpanel[dev], ldda, // V dwork[dev], lddwork, // T dlA(dev, i, i_nb_local+ib), ldda, // C dwork[dev]+ib, lddwork, // work queues[dev][0] ); } else { // for trailing matrix, apply H' to A(i:m,i+ib:n) i_nb_local = i_local; if (dev <= panel_dev) { i_nb_local += ib; } magma_clarfb_gpu( MagmaLeft, MagmaConjTrans, MagmaForward, MagmaColumnwise, rows, n_local[dev]-i_nb_local, ib, dpanel[dev], ldda, // V dwork[dev], lddwork, // T dlA(dev, i, i_nb_local), ldda, // C dwork[dev]+ib, lddwork, // work queues[dev][0] ); } } // Restore top of panel (after larfb is done) magma_setdevice( panel_dev ); magma_csetmatrix_async( ib, ib, hpanel(i), ldhpanel, dlA(panel_dev, i, i_local), ldda, queues[panel_dev][0] ); } } } else { i = 0; } /* Use unblocked code to factor the last or only block row. */ if (i < min_mn) { rows = m-i; for( j=i; j < n; j += nb ) { panel_dev = (j/nb) % ngpu; i_local = j/(nb*ngpu)*nb; ib = min( n-j, nb ); magma_setdevice( panel_dev ); magma_cgetmatrix( rows, ib, dlA(panel_dev, i, i_local), ldda, hwork + (j-i)*rows, rows, queues[panel_dev][0] ); } // needs lwork >= 2*n*nb: // needs (m-i)*(n-i) for last block row, bounded by nb*n. // needs (n-i)*nb for cgeqrf work, bounded by n*nb. ib = n-i; // total columns in block row lhwork = lwork - ib*rows; lapackf77_cgeqrf( &rows, &ib, hwork, &rows, tau+i, hwork + ib*rows, &lhwork, info ); if ( *info != 0 ) { fprintf( stderr, "error %lld\n", (long long) *info ); } for( j=i; j < n; j += nb ) { panel_dev = (j/nb) % ngpu; i_local = j/(nb*ngpu)*nb; ib = min( n-j, nb ); magma_setdevice( panel_dev ); magma_csetmatrix( rows, ib, hwork + (j-i)*rows, rows, dlA(panel_dev, i, i_local), ldda, queues[panel_dev][0] ); } } CLEANUP: // free(NULL) does nothing. for( dev=0; dev < ngpu; dev++ ) { magma_setdevice( dev ); magma_queue_destroy( queues[dev][0] ); magma_queue_destroy( queues[dev][1] ); magma_event_destroy( panel_event[dev] ); magma_free( dwork[dev] ); } magma_free_pinned( hwork ); magma_setdevice( orig_dev ); return *info; } /* magma_cgeqrf2_mgpu */
[ "vazcorm@gmail.com" ]
vazcorm@gmail.com
42059a3d715540812883d38a5d19b44d7a292465
5fb40740c24d4f301422da450b953de040dadb8d
/LCAA.cpp
c0a47068e6157733876c8480cb7b1a46ff792487
[]
no_license
Hibari233/OI-Codes
33110db22bfb9ce56c06a26512dbfe704852db75
6b026f98d007afeff480ab6b0d022b75572c19b9
refs/heads/master
2023-08-20T13:40:53.368218
2021-10-31T12:28:09
2021-10-31T12:28:09
263,259,957
2
0
null
null
null
null
UTF-8
C++
false
false
993
cpp
#pragma GCC optimize ("O3") #include<iostream> #include<cstdio> #include<algorithm> using namespace std; const int N=500050,M=N*2; int n,m,s,x,y; int head[N],ver[M],Next[M],tot,par[N][25],depth[N]; void add(int x,int y){ ver[++tot]=y,Next[tot]=head[x],head[x]=tot; } void dfs(int x,int fa){ depth[x]=depth[fa]+1; par[x][0]=fa; for(int i=head[x];i;i=Next[i]){ int y=ver[i]; if(y==fa) continue; dfs(y,x); } } void getf(){ for(int up=1;(1<<up)<=n;up++){ for(int i=1;i<=n;i++){ par[i][up]=par[par[i][up-1]][up-1]; } } } int lca(int x,int y){ if(depth[x]<depth[y]) swap(x,y); for(int i=20;i>=0;i--) if(depth[par[x][i]]>=depth[y]) x=par[x][i]; if(x==y) return x; for(int i=20;i>=0;i--) if(par[x][i]!=par[y][i]) x=par[x][i],y=par[y][i]; return par[x][0]; } int main(){ scanf("%d%d%d",&n,&m,&s); for(int i=1;i<n;i++){ scanf("%d%d",&x,&y); add(x,y);add(y,x); } dfs(s,0); getf(); for(int i=1;i<=m;i++){ scanf("%d%d",&x,&y); printf("%d\n",lca(x,y)); } return 0; }
[ "59260343@qq.com" ]
59260343@qq.com
4784016c43f2233f61b0f65732fe40f0f0caae5b
aec41e793d61159771ec01295a511eb5d021f458
/leetcode/105-construct-binary-tree-from-preorder-and-inorder-traversal.cpp
270975c4b8dd1910396da1aab88de37d7b9fc64e
[]
no_license
FootprintGL/algo
ef043d89549685d72400275f7f4ce769028c48c8
1109c20921a6c573212ac9170c2aafeb5ca1da0f
refs/heads/master
2023-04-09T02:59:00.510380
2021-04-16T12:59:03
2021-04-16T12:59:03
272,113,789
0
0
null
null
null
null
UTF-8
C++
false
false
1,220
cpp
/** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x), left(NULL), right(NULL) {} * }; */ class Solution { public: unordered_map<int, int> tbl; /* * 前序遍历第一个节点为根节点 * 根节点把中序遍历结果分割成左右子树 * 递归构建左右子树 */ TreeNode *dfs(vector<int> &inorder, int l1, int r1, vector<int> &preorder, int l2, int r2) { //cout << l1 << " " << r1 << " " << l2 << " " << r2 << endl; if (l1 > r1) return NULL; int index = tbl[preorder[l2]]; TreeNode *root = new TreeNode(preorder[l2]); root->left = dfs(inorder, l1, index - 1, preorder, l2 + 1, index + l2 - l1); root->right = dfs(inorder, index + 1, r1, preorder, index + l2 - l1 + 1, r2); return root; } TreeNode* buildTree(vector<int>& preorder, vector<int>& inorder) { /* 哈希表加快根节点位置坐标查询 */ for (int i = 0; i < inorder.size(); i++) tbl[inorder[i]] = i; return dfs(inorder, 0, inorder.size() - 1, preorder, 0, preorder.size() - 1); } };
[ "glbian@hotmail.com" ]
glbian@hotmail.com
857ac7a9f257c1ebb776509a06445cfd791f9075
7eb397bcd67cf0de1b61d4635e07d58f7715c095
/src/core/TheveninDischargeStrategy.h
7d7e093161d3f9776874bde4a51da9924158df60
[]
no_license
qdrk/cheali-charger
248fdced8fe83cad1e87f20a30b64fbe8ab5fd37
386dbb34b61a2b8bfc1f1eae1419c2359cb942ba
refs/heads/master
2021-05-27T12:10:29.800531
2013-10-27T12:25:23
2013-10-27T12:25:23
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,259
h
/* cheali-charger - open source firmware for a variety of LiPo chargers Copyright (C) 2013 Paweł Stawicki. All right reserved. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ #ifndef THEVENINDISCHARGESTRATEGY_H_ #define THEVENINDISCHARGESTRATEGY_H_ #include "SimpleDischargeStrategy.h" #include "TheveninMethod.h" namespace TheveninDischargeStrategy { extern const Strategy::VTable vtable; void powerOn(); Strategy::statusType doStrategy(); void powerOff(); void setVI(AnalogInputs::ValueType v, AnalogInputs::ValueType i); void setMinI(AnalogInputs::ValueType i); }; #endif /* THEVENINDISCHARGESTRATEGY_H_ */
[ "stawel+chealiCharger@gmail.com" ]
stawel+chealiCharger@gmail.com
4be3fe748ea1c42b8806be2bba57d41a48033536
f3c35916431adf6471169221dd239aa9a2e5e67d
/algorithmic-design-and-techniques/algorithmic-warmup/fibonacci_sum_last_digit.cpp
dcfeae1750ebb58c405005aa8e9baf3b24254b9a
[ "MIT" ]
permissive
aitorlb/algorithms-and-data-structures-micromasters
6f81f4cfeb6e1ec53ba85b5c94c903ad79371441
a84be036f3c0712421a5510eb942709cb4d6d8db
refs/heads/master
2020-04-17T23:37:24.253937
2019-02-12T21:19:58
2019-02-12T21:19:58
167,042,884
2
0
null
null
null
null
UTF-8
C++
false
false
1,203
cpp
#include <iostream> #include <vector> int fibonacci_sum_naive(long long n) { if (n <= 1) return n; long long previous = 0; long long current = 1; long long sum = 1; for (long long i = 0; i < n - 1; ++i) { long long tmp_previous = previous; previous = current; current = tmp_previous + current; sum += current; } return sum % 10; } /* Last Digit of the Sum of Fibonacci Numbers Given the following relationship between sequences exist: 0 1 1 2 3 5 8 13 21 34 // fibs 1 2 4 7 12 20 33 // sums We need to compute the last digit of F(n+2) and substract 1 */ int fibonacci_sum_fast(long long n) { std::vector<int> p{0, 1, 1 % 10}; // Pisano period for (int i = 2; true; ++i) { int current = (p[i] + p[i - 1]) % 10; if (p[i] == 0 && current == 1) { p.pop_back(); break; } p.push_back(current); } int fib = p[(n + 2) % p.size()]; // F(n+2) % 10 // Handle decrementing 0 by adding 9 and returning last digit. return (fib + 9) % 10; } int main() { long long n = 0; std::cin >> n; std::cout << fibonacci_sum_fast(n); }
[ "aitorlopezbeltran@gmail.com" ]
aitorlopezbeltran@gmail.com
9c19143db089f8c954264ceb911cd1b4d936760c
f1c9c0694d17b2b28c97860f10ddbc62d0ec593e
/src/devices/CurrentSensor.cpp
ef2adf348bbfe74ce414fa82995dc5da148c2e77
[ "MIT" ]
permissive
jiangzhenwei/nano-sat-controller
3829320fc992e9cd3345a7886b9377c637b30e85
b264d78d0443dbc0c4212f6ef38b9bc6702aaee4
refs/heads/master
2020-03-27T18:04:15.796848
2018-02-27T10:56:30
2018-02-27T10:56:30
null
0
0
null
null
null
null
UTF-8
C++
false
false
17,146
cpp
/*=========================================================================== Nano satellite controller // Copyright: Copyright (c) 2017, Alberto Cenzato All rights reserved. // Licence: BSD // Based on: Adafruit INA219 breakout board library by K. Townsend (Adafruit Industries) https://github.com/adafruit/Adafruit_INA219 Redistribution and use in source and binary forms are permitted provided that the above copyright notice and this paragraph are duplicated in all such forms and that any documentation, advertising materials, and other materials related to such distribution and use acknowledge that the software was developed by the <organization>. The name of the <organization> may not be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. //============================================================================ */ #include "devices/CurrentSensor.hpp" #include <thread> #include "utils/Settings.hpp" #include "self_test/SelfTest.hpp" #include "utils/Logger.hpp" #pragma region registers #define INA219_READ 0x01 //CONFIG REGISTER (R/W) #define INA219_REG_CONFIG 0x00 #define INA219_CONFIG_RESET 0x8000 // Reset #define INA219_CONFIG_BVOLTAGERANGE_MASK 0x2000 // Bus Voltage Range Mask #define INA219_CONFIG_BVOLTAGERANGE_16V 0x0000 // 0-16V Range #define INA219_CONFIG_BVOLTAGERANGE_32V 0x2000 // 0-32V #define INA219_CONFIG_GAIN_MASK 0x1800 // Gain Mask #define INA219_CONFIG_GAIN_1_40MV 0x0000 // Gain 1, 40mV Range #define INA219_CONFIG_GAIN_2_80MV 0x0800 // Gain 2, 80mV Range #define INA219_CONFIG_GAIN_4_160MV 0x1000 // Gain 4, 160mV Range #define INA219_CONFIG_GAIN_8_320MV 0x1800 // Gain 8, 320mV #define INA219_CONFIG_BADCRES_MASK 0x0780 // Bus ADC Resolution Mask #define INA219_CONFIG_BADCRES_9BIT 0x0080 // 9-bit bus res = 0..511 #define INA219_CONFIG_BADCRES_10BIT 0x0100 // 10-bit bus res = 0..1023 #define INA219_CONFIG_BADCRES_11BIT 0x0200 // 11-bit bus res = 0..2047 #define INA219_CONFIG_BADCRES_12BIT 0x0400 // 12-bit bus res = 0.. #define INA219_CONFIG_SADCRES_MASK 0x0078 // Shunt ADC Resolution and Averaging Mask #define INA219_CONFIG_SADCRES_9BIT_1S_84US 0x0000 // 1 x 9-bit shunt sample #define INA219_CONFIG_SADCRES_10BIT_1S_148US 0x0008 // 1 x 10-bit shunt sample #define INA219_CONFIG_SADCRES_11BIT_1S_276US 0x0010 // 1 x 11-bit shunt sample #define INA219_CONFIG_SADCRES_12BIT_1S_532US 0x0018 // 1 x 12-bit shunt sample #define INA219_CONFIG_SADCRES_12BIT_2S_1060US 0x0048 // 2 x 12-bit shunt samples averaged together #define INA219_CONFIG_SADCRES_12BIT_4S_2130US 0x0050 // 4 x 12-bit shunt samples averaged together #define INA219_CONFIG_SADCRES_12BIT_8S_4260US 0x0058 // 8 x 12-bit shunt samples averaged together #define INA219_CONFIG_SADCRES_12BIT_16S_8510US 0x0060 // 16 x 12-bit shunt samples averaged together #define INA219_CONFIG_SADCRES_12BIT_32S_17MS 0x0068 // 32 x 12-bit shunt samples averaged together #define INA219_CONFIG_SADCRES_12BIT_64S_34MS 0x0070 // 64 x 12-bit shunt samples averaged together #define INA219_CONFIG_SADCRES_12BIT_128S_69MS 0x0078 // 128 x 12-bit shunt samples averaged #define INA219_CONFIG_MODE_MASK 0x0007 // Operating Mode Mask #define INA219_CONFIG_MODE_POWERDOWN 0x0000 #define INA219_CONFIG_MODE_SVOLT_TRIGGERED 0x0001 #define INA219_CONFIG_MODE_BVOLT_TRIGGERED 0x0002 #define INA219_CONFIG_MODE_SANDBVOLT_TRIGGERED 0x0003 #define INA219_CONFIG_MODE_ADCOFF 0x0004 #define INA219_CONFIG_MODE_SVOLT_CONTINUOUS 0x0005 #define INA219_CONFIG_MODE_BVOLT_CONTINUOUS 0x0006 #define INA219_CONFIG_MODE_SANDBVOLT_CONTINUOUS 0x0007 // SHUNT VOLTAGE REGISTER (R) #define INA219_REG_SHUNTVOLTAGE 0x01 // BUS VOLTAGE REGISTER (R) #define INA219_REG_BUSVOLTAGE 0x02 // POWER REGISTER (R) #define INA219_REG_POWER 0x03 // CURRENT REGISTER (R) #define INA219_REG_CURRENT 0x04 // CALIBRATION REGISTER (R/W) #define INA219_REG_CALIBRATION 0x05 #pragma endregion registers using this_thread::sleep_for; namespace sat { namespace device { const string CurrentSensor::DEFAULT_DEV_ID = "Adafruit_INA219"; const chrono::seconds CurrentSensor::DEVICE_RESET_TIME = chrono::seconds(1); // ---------- Constructors ---------- #pragma region constructors std::unique_ptr<CurrentSensor> CurrentSensor::create(const utils::CurrentSensorSettings& settings) { return std::make_unique<CurrentSensor>(settings); } CurrentSensor::CurrentSensor() : DeviceI2C(DEFAULT_DEV_ID, DEFAULT_I2C_ADDR), ina219_calValue(0), ina219_currentDivider_mA(0), ina219_powerDivider_mW(0) { } CurrentSensor::CurrentSensor(const utils::CurrentSensorSettings& settings) : DeviceI2C(settings.deviceID, settings.address), ina219_calValue(0), ina219_currentDivider_mA(0), ina219_powerDivider_mW(0) { //addTestAndAction(&CurrentSensor::testValues, &CurrentSensor::noAction); testsAndActions.emplace_back(std::bind(&CurrentSensor::testValues, this), std::bind(&CurrentSensor::noAction, this)); setCalibration_32V_2A(); } #pragma endregion constructors // ---------- public member functions ------------------ #pragma region pub_functions float CurrentSensor::readCurrent() const { if (!available) return std::numeric_limits<float>::quiet_NaN(); uint16_t value; // Sometimes a sharp load will reset the INA219, which will // reset the cal register, meaning CURRENT and POWER will // not be available ... avoid this by always setting a cal // value even if it's an unfortunate extra step write16_const(INA219_REG_CALIBRATION, ina219_calValue); // Now we can safely read the CURRENT register! read16(INA219_REG_CURRENT, value); float valueDec = int16_t(value); valueDec /= float(ina219_currentDivider_mA); return valueDec; } vector<double> CurrentSensor::read() const { return { double(readCurrent()) }; } void CurrentSensor::setCalibration_32V_2A() { // By default we use a pretty huge range for the input voltage, // which probably isn't the most appropriate choice for system // that don't use a lot of power. But all of the calculations // are shown below if you want to change the settings. You will // also need to change any relevant register settings, such as // setting the VBUS_MAX to 16V instead of 32V, etc. // VBUS_MAX = 32V (Assumes 32V, can also be set to 16V) // VSHUNT_MAX = 0.32 (Assumes Gain 8, 320mV, can also be 0.16, 0.08, 0.04) // RSHUNT = 0.1 (Resistor value in ohms) // 1. Determine max possible current // MaxPossible_I = VSHUNT_MAX / RSHUNT // MaxPossible_I = 3.2A // 2. Determine max expected current // MaxExpected_I = 2.0A // 3. Calculate possible range of LSBs (Min = 15-bit, Max = 12-bit) // MinimumLSB = MaxExpected_I/32767 // MinimumLSB = 0.000061 (61uA per bit) // MaximumLSB = MaxExpected_I/4096 // MaximumLSB = 0,000488 (488uA per bit) // 4. Choose an LSB between the min and max values // (Preferrably a roundish number close to MinLSB) // CurrentLSB = 0.0001 (100uA per bit) // 5. Compute the calibration register // Cal = trunc (0.04096 / (Current_LSB * RSHUNT)) // Cal = 4096 (0x1000) ina219_calValue = 4096; // 6. Calculate the power LSB // PowerLSB = 20 * CurrentLSB // PowerLSB = 0.002 (2mW per bit) // 7. Compute the maximum current and shunt voltage values before overflow // // Max_Current = Current_LSB * 32767 // Max_Current = 3.2767A before overflow // // If Max_Current > Max_Possible_I then // Max_Current_Before_Overflow = MaxPossible_I // Else // Max_Current_Before_Overflow = Max_Current // End If // // Max_ShuntVoltage = Max_Current_Before_Overflow * RSHUNT // Max_ShuntVoltage = 0.32V // // If Max_ShuntVoltage >= VSHUNT_MAX // Max_ShuntVoltage_Before_Overflow = VSHUNT_MAX // Else // Max_ShuntVoltage_Before_Overflow = Max_ShuntVoltage // End If // 8. Compute the Maximum Power // MaximumPower = Max_Current_Before_Overflow * VBUS_MAX // MaximumPower = 3.2 * 32V // MaximumPower = 102.4W // Set multipliers to convert raw current/power values ina219_currentDivider_mA = 10; // Current LSB = 100uA per bit (1000/100 = 10) ina219_powerDivider_mW = 2; // Power LSB = 1mW per bit (2/1) // Set Calibration register to 'Cal' calculated above write16(INA219_REG_CALIBRATION, ina219_calValue); // Set Config register to take into account the settings above const uint16_t config = INA219_CONFIG_BVOLTAGERANGE_32V | INA219_CONFIG_GAIN_8_320MV | INA219_CONFIG_BADCRES_12BIT | INA219_CONFIG_SADCRES_12BIT_1S_532US | INA219_CONFIG_MODE_SANDBVOLT_CONTINUOUS; write16(INA219_REG_CONFIG, config); } void CurrentSensor::setCalibration_32V_1A() { // By default we use a pretty huge range for the input voltage, // which probably isn't the most appropriate choice for system // that don't use a lot of power. But all of the calculations // are shown below if you want to change the settings. You will // also need to change any relevant register settings, such as // setting the VBUS_MAX to 16V instead of 32V, etc. // VBUS_MAX = 32V (Assumes 32V, can also be set to 16V) // VSHUNT_MAX = 0.32 (Assumes Gain 8, 320mV, can also be 0.16, 0.08, 0.04) // RSHUNT = 0.1 (Resistor value in ohms) // 1. Determine max possible current // MaxPossible_I = VSHUNT_MAX / RSHUNT // MaxPossible_I = 3.2A // 2. Determine max expected current // MaxExpected_I = 1.0A // 3. Calculate possible range of LSBs (Min = 15-bit, Max = 12-bit) // MinimumLSB = MaxExpected_I/32767 // MinimumLSB = 0.0000305 (30.5�A per bit) // MaximumLSB = MaxExpected_I/4096 // MaximumLSB = 0.000244 (244�A per bit) // 4. Choose an LSB between the min and max values // (Preferrably a roundish number close to MinLSB) // CurrentLSB = 0.0000400 (40�A per bit) // 5. Compute the calibration register // Cal = trunc (0.04096 / (Current_LSB * RSHUNT)) // Cal = 10240 (0x2800) ina219_calValue = 10240; // 6. Calculate the power LSB // PowerLSB = 20 * CurrentLSB // PowerLSB = 0.0008 (800�W per bit) // 7. Compute the maximum current and shunt voltage values before overflow // // Max_Current = Current_LSB * 32767 // Max_Current = 1.31068A before overflow // // If Max_Current > Max_Possible_I then // Max_Current_Before_Overflow = MaxPossible_I // Else // Max_Current_Before_Overflow = Max_Current // End If // // ... In this case, we're good though since Max_Current is less than MaxPossible_I // // Max_ShuntVoltage = Max_Current_Before_Overflow * RSHUNT // Max_ShuntVoltage = 0.131068V // // If Max_ShuntVoltage >= VSHUNT_MAX // Max_ShuntVoltage_Before_Overflow = VSHUNT_MAX // Else // Max_ShuntVoltage_Before_Overflow = Max_ShuntVoltage // End If // 8. Compute the Maximum Power // MaximumPower = Max_Current_Before_Overflow * VBUS_MAX // MaximumPower = 1.31068 * 32V // MaximumPower = 41.94176W // Set multipliers to convert raw current/power values ina219_currentDivider_mA = 25; // Current LSB = 40uA per bit (1000/40 = 25) ina219_powerDivider_mW = 1; // Power LSB = 800�W per bit // Set Calibration register to 'Cal' calculated above write16(INA219_REG_CALIBRATION, ina219_calValue); // Set Config register to take into account the settings above const uint16_t config = INA219_CONFIG_BVOLTAGERANGE_32V | INA219_CONFIG_GAIN_8_320MV | INA219_CONFIG_BADCRES_12BIT | INA219_CONFIG_SADCRES_12BIT_1S_532US | INA219_CONFIG_MODE_SANDBVOLT_CONTINUOUS; write16(INA219_REG_CONFIG, config); } void CurrentSensor::setCalibration_16V_400mA() { // Calibration which uses the highest precision for // current measurement (0.1mA), at the expense of // only supporting 16V at 400mA max. // VBUS_MAX = 16V // VSHUNT_MAX = 0.04 (Assumes Gain 1, 40mV) // RSHUNT = 0.1 (Resistor value in ohms) // 1. Determine max possible current // MaxPossible_I = VSHUNT_MAX / RSHUNT // MaxPossible_I = 0.4A // 2. Determine max expected current // MaxExpected_I = 0.4A // 3. Calculate possible range of LSBs (Min = 15-bit, Max = 12-bit) // MinimumLSB = MaxExpected_I/32767 // MinimumLSB = 0.0000122 (12uA per bit) // MaximumLSB = MaxExpected_I/4096 // MaximumLSB = 0.0000977 (98uA per bit) // 4. Choose an LSB between the min and max values // (Preferrably a roundish number close to MinLSB) // CurrentLSB = 0.00005 (50uA per bit) // 5. Compute the calibration register // Cal = trunc (0.04096 / (Current_LSB * RSHUNT)) // Cal = 8192 (0x2000) ina219_calValue = 8192; // 6. Calculate the power LSB // PowerLSB = 20 * CurrentLSB // PowerLSB = 0.001 (1mW per bit) // 7. Compute the maximum current and shunt voltage values before overflow // // Max_Current = Current_LSB * 32767 // Max_Current = 1.63835A before overflow // // If Max_Current > Max_Possible_I then // Max_Current_Before_Overflow = MaxPossible_I // Else // Max_Current_Before_Overflow = Max_Current // End If // // Max_Current_Before_Overflow = MaxPossible_I // Max_Current_Before_Overflow = 0.4 // // Max_ShuntVoltage = Max_Current_Before_Overflow * RSHUNT // Max_ShuntVoltage = 0.04V // // If Max_ShuntVoltage >= VSHUNT_MAX // Max_ShuntVoltage_Before_Overflow = VSHUNT_MAX // Else // Max_ShuntVoltage_Before_Overflow = Max_ShuntVoltage // End If // // Max_ShuntVoltage_Before_Overflow = VSHUNT_MAX // Max_ShuntVoltage_Before_Overflow = 0.04V // 8. Compute the Maximum Power // MaximumPower = Max_Current_Before_Overflow * VBUS_MAX // MaximumPower = 0.4 * 16V // MaximumPower = 6.4W // Set multipliers to convert raw current/power values ina219_currentDivider_mA = 20; // Current LSB = 50uA per bit (1000/50 = 20) ina219_powerDivider_mW = 1; // Power LSB = 1mW per bit // Set Calibration register to 'Cal' calculated above write16(INA219_REG_CALIBRATION, ina219_calValue); // Set Config register to take into account the settings above const uint16_t config = INA219_CONFIG_BVOLTAGERANGE_16V | INA219_CONFIG_GAIN_1_40MV | INA219_CONFIG_BADCRES_12BIT | INA219_CONFIG_SADCRES_12BIT_1S_532US | INA219_CONFIG_MODE_SANDBVOLT_CONTINUOUS; write16(INA219_REG_CONFIG, config); } float CurrentSensor::getShuntVoltage_mV() const { uint16_t value_raw; read16(INA219_REG_SHUNTVOLTAGE, value_raw); return int16_t(value_raw) * 0.01f; } float CurrentSensor::getBusVoltage_V() const { uint16_t value_raw; read16(INA219_REG_BUSVOLTAGE, value_raw); // Shift to the right 3 to drop CNVR and OVF and multiply by LSB const auto value = int16_t((value_raw >> 3) * 4); return value * 0.001f; } #pragma endregion pub_functions // ---------- Inherited functions ---------- #pragma region inherited_functions bool CurrentSensor::read16(uint8_t regAddress, uint16_t& value) const { bus.setAddress(address); if (bus.send(regAddress) == -1) { Log::err << deviceID + ": " + bus.getErrorMessage(); return false; } sleep_for(chrono::microseconds(600)); uint8_t readBuff[2]; if (bus.receive(readBuff, 2) == -1) { Log::err << deviceID + ": " + bus.getErrorMessage(); return false; } value = static_cast<uint16_t>(readBuff[0] << 8 | readBuff[1]); return true; } TestResult CurrentSensor::testConnection() { auto test = ConnectionSelfTest::create(deviceID); uint16_t value, savedState; if (!read16(INA219_REG_CONFIG, savedState)) { // save value stored in INA219_REG_CONFIG register test->errorLevel = ErrorLevel::warning; test->additionalInfo += " | Read error!"; return TestResult(test); } if (!write16(INA219_REG_CONFIG, INA219_CONFIG_RESET)) { // setting RESET bit to 1 test->errorLevel = ErrorLevel::warning; test->additionalInfo += " | Read error!"; return TestResult(test); } sleep_for(DEVICE_RESET_TIME); // wait 1s for device reset if (!read16(INA219_REG_CONFIG, value)) { // read default value of INA219_REG_CONFIG register test->errorLevel = ErrorLevel::warning; test->additionalInfo += " | Read error!"; return TestResult(test); } if (value != 0x399F) test->errorLevel = ErrorLevel::warning; if (!write16(INA219_REG_CONFIG, savedState)) { // restore saved register value test->errorLevel = ErrorLevel::warning; test->additionalInfo += " | Read error!"; return TestResult(test); } return TestResult(test); } TestResult CurrentSensor::testValues() const { auto test = OutOfRangeSelfTest::create(deviceID); const auto current = readCurrent(); if (current < -2000 || current > 2000) { test->errorLevel = ErrorLevel::warning; } test->additionalInfo += " | current value (mA): " + to_string(current); return TestResult(test); } #pragma endregion inherited_functions } // end device } // end sat
[ "albertocenzato@alice.it" ]
albertocenzato@alice.it
1aa7c3da4ffa148817d20ba92438582674f6f1a6
912ec9f6e968b22f2ac77ec6084645386b70bea1
/trunk/maya7.0/exporter/singleton.h
2f242bcf48739159486ada9ec065c4f8d64931fd
[]
no_license
cpzhang/zen
9156413d93f7dc9c5b48b9bd1e5cdb5a5b1657da
6d6e06278aa37eb279e05c9097fd964bf476c939
refs/heads/master
2016-09-05T15:24:06.565446
2013-03-19T12:29:28
2013-03-19T12:29:28
7,439,357
0
1
null
null
null
null
UTF-8
C++
false
false
422
h
#pragma once #define assert(x) template <typename T> class Singleton { protected: static T* ms_Singleton; public: Singleton(){ assert( !ms_Singleton ); ms_Singleton = static_cast< T* >( this ); } ~Singleton(){ assert( ms_Singleton ); ms_Singleton = 0; } static T& getSingleton(){ assert( ms_Singleton ); return ( *ms_Singleton ); } static T* getSingletonPtr(){ return ms_Singleton; } };
[ "297191409@qq.com" ]
297191409@qq.com
51348d32cc2c469e81119d44bcbe08cd84a246fd
fbf03e58097e6c53b485a3cf85d6946b839a08e0
/General/standard.h
e4f7c6099382d891a5cdca11dd8c6a164fef29ab
[]
no_license
CandyOre/myDSAprac
193a55e0371407a7128ce8b61974a91c7fdb7114
013d469c1e9d9f989abb9c15c0606cd9e21ef651
refs/heads/main
2023-04-16T21:23:05.098299
2021-05-07T06:24:32
2021-05-07T06:24:32
348,968,579
3
0
null
2021-05-07T06:24:32
2021-03-18T06:42:56
C++
UTF-8
C++
false
false
106
h
#ifndef _GENERAL_H #define _GENERAL_H #include "../General/general.h" #endif namespace mySTL { }
[ "834657460@qq.com" ]
834657460@qq.com
170e1283a62d8482b37b276f4421f0cd7c4e3a5e
cf3302a478551167d14c577be171fe0c1b4a3507
/src/cpp/activemq/activemq-cpp-3.2.5/src/main/activemq/wireformat/openwire/marshal/v3/RemoveInfoMarshaller.cpp
c76d18a9f1c5a9db60475a0f4ef6e38166497368
[ "Apache-2.0" ]
permissive
WilliamDrewAeroNomos/muthur
7babb320ed3bfb6ed7905a1a943e3d35aa03aedc
0c66c78af245ef3b06b92172e0df62eb54b3fb84
refs/heads/master
2016-09-05T11:15:50.083267
2015-07-01T15:49:56
2015-07-01T15:49:56
38,366,076
0
0
null
null
null
null
UTF-8
C++
false
false
5,710
cpp
/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You 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. */ #include <activemq/wireformat/openwire/marshal/v3/RemoveInfoMarshaller.h> #include <activemq/commands/RemoveInfo.h> #include <activemq/exceptions/ActiveMQException.h> #include <decaf/lang/Pointer.h> // // NOTE!: This file is autogenerated - do not modify! // if you need to make a change, please see the Java Classes in the // activemq-core module // using namespace std; using namespace activemq; using namespace activemq::exceptions; using namespace activemq::commands; using namespace activemq::wireformat; using namespace activemq::wireformat::openwire; using namespace activemq::wireformat::openwire::marshal; using namespace activemq::wireformat::openwire::utils; using namespace activemq::wireformat::openwire::marshal::v3; using namespace decaf; using namespace decaf::io; using namespace decaf::lang; /////////////////////////////////////////////////////////////////////////////// DataStructure* RemoveInfoMarshaller::createObject() const { return new RemoveInfo(); } /////////////////////////////////////////////////////////////////////////////// unsigned char RemoveInfoMarshaller::getDataStructureType() const { return RemoveInfo::ID_REMOVEINFO; } /////////////////////////////////////////////////////////////////////////////// void RemoveInfoMarshaller::tightUnmarshal( OpenWireFormat* wireFormat, DataStructure* dataStructure, DataInputStream* dataIn, BooleanStream* bs ) throw( decaf::io::IOException ) { try { BaseCommandMarshaller::tightUnmarshal( wireFormat, dataStructure, dataIn, bs ); RemoveInfo* info = dynamic_cast<RemoveInfo*>( dataStructure ); info->setObjectId( Pointer<DataStructure>( dynamic_cast< DataStructure* >( tightUnmarshalCachedObject( wireFormat, dataIn, bs ) ) ) ); } AMQ_CATCH_RETHROW( decaf::io::IOException ) AMQ_CATCH_EXCEPTION_CONVERT( exceptions::ActiveMQException, decaf::io::IOException ) AMQ_CATCHALL_THROW( decaf::io::IOException ) } /////////////////////////////////////////////////////////////////////////////// int RemoveInfoMarshaller::tightMarshal1( OpenWireFormat* wireFormat, DataStructure* dataStructure, BooleanStream* bs ) throw( decaf::io::IOException ) { try { RemoveInfo* info = dynamic_cast<RemoveInfo*>( dataStructure ); int rc = BaseCommandMarshaller::tightMarshal1( wireFormat, dataStructure, bs ); rc += tightMarshalCachedObject1( wireFormat, info->getObjectId().get(), bs ); return rc + 0; } AMQ_CATCH_RETHROW( decaf::io::IOException ) AMQ_CATCH_EXCEPTION_CONVERT( exceptions::ActiveMQException, decaf::io::IOException ) AMQ_CATCHALL_THROW( decaf::io::IOException ) } /////////////////////////////////////////////////////////////////////////////// void RemoveInfoMarshaller::tightMarshal2( OpenWireFormat* wireFormat, DataStructure* dataStructure, DataOutputStream* dataOut, BooleanStream* bs ) throw( decaf::io::IOException ) { try { BaseCommandMarshaller::tightMarshal2( wireFormat, dataStructure, dataOut, bs ); RemoveInfo* info = dynamic_cast<RemoveInfo*>( dataStructure ); tightMarshalCachedObject2( wireFormat, info->getObjectId().get(), dataOut, bs ); } AMQ_CATCH_RETHROW( decaf::io::IOException ) AMQ_CATCH_EXCEPTION_CONVERT( exceptions::ActiveMQException, decaf::io::IOException ) AMQ_CATCHALL_THROW( decaf::io::IOException ) } /////////////////////////////////////////////////////////////////////////////// void RemoveInfoMarshaller::looseUnmarshal( OpenWireFormat* wireFormat, DataStructure* dataStructure, DataInputStream* dataIn ) throw( decaf::io::IOException ) { try { BaseCommandMarshaller::looseUnmarshal( wireFormat, dataStructure, dataIn ); RemoveInfo* info = dynamic_cast<RemoveInfo*>( dataStructure ); info->setObjectId( Pointer<DataStructure>( dynamic_cast< DataStructure* >( looseUnmarshalCachedObject( wireFormat, dataIn ) ) ) ); } AMQ_CATCH_RETHROW( decaf::io::IOException ) AMQ_CATCH_EXCEPTION_CONVERT( exceptions::ActiveMQException, decaf::io::IOException ) AMQ_CATCHALL_THROW( decaf::io::IOException ) } /////////////////////////////////////////////////////////////////////////////// void RemoveInfoMarshaller::looseMarshal( OpenWireFormat* wireFormat, DataStructure* dataStructure, DataOutputStream* dataOut ) throw( decaf::io::IOException ) { try { RemoveInfo* info = dynamic_cast<RemoveInfo*>( dataStructure ); BaseCommandMarshaller::looseMarshal( wireFormat, dataStructure, dataOut ); looseMarshalCachedObject( wireFormat, info->getObjectId().get(), dataOut ); } AMQ_CATCH_RETHROW( decaf::io::IOException ) AMQ_CATCH_EXCEPTION_CONVERT( exceptions::ActiveMQException, decaf::io::IOException ) AMQ_CATCHALL_THROW( decaf::io::IOException ) }
[ "wdrew@aeronomos.com" ]
wdrew@aeronomos.com
8cbceb585e08f76853f894b8873cbfde15efd591
77b238a489ab12482a3990b83fc9fb2a46c338cd
/chrome/browser/web_applications/isolated_web_apps/isolated_web_app_update_apply_waiter.h
035793ac546fbf62baede139112ed2a960e92ac6
[ "BSD-3-Clause" ]
permissive
orthogonal829/chromium
1738b905b89be167bee71e45d7af87727813727c
1a885846dfa47874c99cfc78d875fd8213415bb1
refs/heads/main
2023-08-17T06:04:22.206251
2023-08-04T05:20:36
2023-08-04T05:20:36
271,580,635
0
0
BSD-3-Clause
2021-01-25T05:31:23
2020-06-11T15:23:24
null
UTF-8
C++
false
false
2,074
h
// Copyright 2023 The Chromium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef CHROME_BROWSER_WEB_APPLICATIONS_ISOLATED_WEB_APPS_ISOLATED_WEB_APP_UPDATE_APPLY_WAITER_H_ #define CHROME_BROWSER_WEB_APPLICATIONS_ISOLATED_WEB_APPS_ISOLATED_WEB_APP_UPDATE_APPLY_WAITER_H_ #include "base/functional/callback_forward.h" #include "base/memory/raw_ref.h" #include "chrome/browser/web_applications/isolated_web_apps/isolated_web_app_url_info.h" class Profile; class ScopedKeepAlive; class ScopedProfileKeepAlive; namespace web_app { class WebAppUiManager; // This class waits for the right time to apply a pending and prepared update // for an IWA. It will keep profile and browser alive while waiting. // // For now, it will simply wait for all windows of the IWA to be closed. In // the future, it might wait for more complex conditions, such as the user // clicking a button to apply the update. class IsolatedWebAppUpdateApplyWaiter { public: using Callback = base::OnceCallback<void(std::unique_ptr<ScopedKeepAlive>, std::unique_ptr<ScopedProfileKeepAlive>)>; IsolatedWebAppUpdateApplyWaiter(IsolatedWebAppUrlInfo url_info, WebAppUiManager& ui_manager); ~IsolatedWebAppUpdateApplyWaiter(); IsolatedWebAppUpdateApplyWaiter(const IsolatedWebAppUpdateApplyWaiter&) = delete; IsolatedWebAppUpdateApplyWaiter& operator=( const IsolatedWebAppUpdateApplyWaiter&) = delete; void Wait(Profile* profile, Callback callback); base::Value AsDebugValue() const; private: void Signal(); IsolatedWebAppUrlInfo url_info_; base::raw_ref<WebAppUiManager> ui_manager_; Callback callback_; std::unique_ptr<ScopedKeepAlive> keep_alive_; std::unique_ptr<ScopedProfileKeepAlive> profile_keep_alive_; base::WeakPtrFactory<IsolatedWebAppUpdateApplyWaiter> weak_factory_{this}; }; } // namespace web_app #endif // CHROME_BROWSER_WEB_APPLICATIONS_ISOLATED_WEB_APPS_ISOLATED_WEB_APP_UPDATE_APPLY_WAITER_H_
[ "chromium-scoped@luci-project-accounts.iam.gserviceaccount.com" ]
chromium-scoped@luci-project-accounts.iam.gserviceaccount.com
2f649a41d896fc0e614d9f33a0d2d8ae53bede2d
d2249116413e870d8bf6cd133ae135bc52021208
/Programming Windows with MFC 2e src/Chap13/EZPrint/EZPrint.h
2083d727061a08c9d5a88daad1af454581179130
[]
no_license
Unknow-man/mfc-4
ecbdd79cc1836767ab4b4ca72734bc4fe9f5a0b5
b58abf9eb4c6d90ef01b9f1203b174471293dfba
refs/heads/master
2023-02-17T18:22:09.276673
2021-01-20T07:46:14
2021-01-20T07:46:14
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,367
h
// EZPrint.h : main header file for the EZPRINT application // #if !defined(AFX_EZPRINT_H__3A83FDE5_A3E6_11D2_8E53_006008A82731__INCLUDED_) #define AFX_EZPRINT_H__3A83FDE5_A3E6_11D2_8E53_006008A82731__INCLUDED_ #if _MSC_VER > 1000 #pragma once #endif // _MSC_VER > 1000 #ifndef __AFXWIN_H__ #error include 'stdafx.h' before including this file for PCH #endif #include "resource.h" // main symbols ///////////////////////////////////////////////////////////////////////////// // CEZPrintApp: // See EZPrint.cpp for the implementation of this class // class CEZPrintApp : public CWinApp { public: CEZPrintApp(); // Overrides // ClassWizard generated virtual function overrides //{{AFX_VIRTUAL(CEZPrintApp) public: virtual BOOL InitInstance(); //}}AFX_VIRTUAL // Implementation //{{AFX_MSG(CEZPrintApp) afx_msg void OnAppAbout(); // NOTE - the ClassWizard will add and remove member functions here. // DO NOT EDIT what you see in these blocks of generated code ! //}}AFX_MSG DECLARE_MESSAGE_MAP() }; ///////////////////////////////////////////////////////////////////////////// //{{AFX_INSERT_LOCATION}} // Microsoft Visual C++ will insert additional declarations immediately before the previous line. #endif // !defined(AFX_EZPRINT_H__3A83FDE5_A3E6_11D2_8E53_006008A82731__INCLUDED_)
[ "chenchao0632@163.com" ]
chenchao0632@163.com
e8f90907424cd9f88fcf8e4256690f60b56f2754
36cf45fd00dde28737bf37ff8a4d7d26e0f5558a
/repos/plywood/src/apps/WebCooker/Main.cpp
e362cdd4245f3b2fdf7463ba94a113029daca360
[ "MIT" ]
permissive
dertom95/plywood
2590c87010be85ed867587242125d3aaceceb98e
e058e8fb6c0fbbfdf83fe99bf2a3a3a3bbfd63c4
refs/heads/master
2022-09-20T20:24:17.168030
2020-06-03T21:37:10
2020-06-03T21:38:50
269,182,185
0
0
MIT
2020-06-03T19:58:55
2020-06-03T19:58:54
null
UTF-8
C++
false
false
8,294
cpp
/*------------------------------------ ///\ Plywood C++ Framework \\\/ https://plywood.arc80.com/ ------------------------------------*/ #include <ply-reflect/Base.h> #include <ply-runtime/Base.h> #include <pylon/Parse.h> #include <pylon/Write.h> #include <pylon-reflect/Import.h> #include <pylon-reflect/Export.h> #include <ply-runtime/process/Subprocess.h> #include <ply-runtime/io/text/LiquidTags.h> #include <web-sass/Sass.h> #include <ply-cook/CookJob.h> #include <ply-web-cook-docs/SemaEntity.h> #include <ply-web-cook-docs/WebCookerIndex.h> #include <ply-web-cook-docs/CookResult_ExtractPageMeta.h> #include <ply-runtime/algorithm/Find.h> #include <web-documentation/Contents.h> #include <ply-runtime/algorithm/Sort.h> namespace ply { namespace docs { extern cook::CookJobType CookJobType_CopyStatic; extern cook::CookJobType CookJobType_ExtractAPI; extern cook::CookJobType CookJobType_ExtractPageMeta; extern cook::CookJobType CookJobType_Page; extern cook::CookJobType CookJobType_StyleSheetID; void initCookJobTypes(); } // namespace docs } // namespace ply using namespace ply; Array<Reference<cook::CookJob>> copyStaticFiles(cook::CookContext* ctx, StringView srcRoot) { Array<Reference<cook::CookJob>> copyJobs; for (WalkTriple& triple : FileSystem::native()->walk(srcRoot)) { for (const WalkTriple::FileInfo& file : triple.files) { String relativeDir = NativePath::makeRelative(srcRoot, triple.dirPath); copyJobs.append(ctx->cook( {&ply::docs::CookJobType_CopyStatic, NativePath::join(relativeDir, file.name)})); } } return copyJobs; } Array<String> getSourceFileKeys(StringView srcRoot) { Array<String> srcKeys; for (WalkTriple& triple : FileSystem::native()->walk(srcRoot)) { for (const WalkTriple::FileInfo& file : triple.files) { if (file.name.endsWith(".cpp") || file.name.endsWith(".h")) { // FIXME: Eliminate exclusions for (StringView exclude : { "Sort.h", "Functor.h", "DirectoryWatcher_Mac.h", "DirectoryWatcher_Win32.h", "Heap.cpp", "HiddenArgFunctor.h", "LambdaView.h", "Pool.h", }) { if (file.name == exclude) goto skipIt; } { String relativeDir = NativePath::makeRelative(PLY_WORKSPACE_FOLDER, triple.dirPath); srcKeys.append(NativePath::join(relativeDir, file.name)); } skipIt:; } } for (StringView exclude : {"Shell_iOS", "opengl-support"}) { s32 i = findItem(triple.dirNames.view(), exclude); if (i >= 0) { triple.dirNames.erase(i); } } } return srcKeys; } Reference<cook::CookJob> extractPageMetasFromFolder(cook::CookContext* ctx, StringView relPath) { PLY_ASSERT(relPath.startsWith("/")); Reference<cook::CookJob> pageMetaJob = ctx->depTracker->getOrCreateCookJob( {&docs::CookJobType_ExtractPageMeta, PosixPath::join(relPath, "index")}); Array<Reference<cook::CookJob>> childJobs; String absPath = NativePath::join(PLY_WORKSPACE_FOLDER, "repos/plywood/docs", relPath.subStr(1)); // By default, sort child pages by filename // The order can be overridden for each page using the <% childOrder %> tag Array<DirectoryEntry> allEntries; for (const DirectoryEntry& entry : FileSystem::native()->listDir(absPath)) { allEntries.append(entry); } sort(allEntries.view(), [](const DirectoryEntry& a, const DirectoryEntry& b) { return a.name < b.name; }); // Add child entries for (const DirectoryEntry& entry : allEntries) { if (entry.isDir) { childJobs.append(extractPageMetasFromFolder(ctx, PosixPath::join(relPath, entry.name))); } else if (entry.name.endsWith(".md") && entry.name != "index.md") { StringView baseName = entry.name.shortenedBy(3); childJobs.append(ctx->cook( {&docs::CookJobType_ExtractPageMeta, PosixPath::join(relPath, baseName)})); } } ctx->ensureCooked(pageMetaJob, TypedPtr::bind(&childJobs)); return pageMetaJob; } void visitPageMetas(const cook::CookJob* pageMetaJob, const LambdaView<void(const docs::CookResult_ExtractPageMeta*)>& visitor) { const docs::CookResult_ExtractPageMeta* pageMetaResult = pageMetaJob->castResult<docs::CookResult_ExtractPageMeta>(); PLY_ASSERT(pageMetaResult); visitor(pageMetaResult); for (const cook::CookJob* childJob : pageMetaResult->childPages) { visitPageMetas(childJob, visitor); } } web::Contents convertContents(const cook::CookJob* pageMetaJob) { web::Contents dstNode; const docs::CookResult_ExtractPageMeta* pageMetaResult = pageMetaJob->castResult<docs::CookResult_ExtractPageMeta>(); PLY_ASSERT(pageMetaResult); // Set title dstNode.title = pageMetaResult->title; dstNode.linkDestination = pageMetaResult->getLinkDestination(); for (const cook::CookJob* childMetaJob : pageMetaResult->childPages) { dstNode.children.append(convertContents(childMetaJob)); } return dstNode; } int main() { ply::docs::initCookJobTypes(); cook::DependencyTracker db; docs::WebCookerIndex* wci = new docs::WebCookerIndex; wci->globalScope = new docs::SemaEntity; db.userData = OwnTypedPtr::bind(wci); // String dbPath = NativePath::join(PLY_WORKSPACE_FOLDER, "data/docsite-cache/depTracker.db"); cook::CookContext ctx; ctx.depTracker = &db; ctx.beginCook(); // Copy static files Array<Reference<cook::CookJob>> copyJobs = copyStaticFiles( &ctx, NativePath::join(PLY_WORKSPACE_FOLDER, "repos/plywood/src/web/theme")); // Extract API documentation from the source code Array<Reference<cook::CookJob>> rootRefs; Array<String> srcKeys = getSourceFileKeys( NativePath::join(PLY_WORKSPACE_FOLDER, "repos/plywood/src/runtime/ply-runtime/io")); srcKeys.extend( getSourceFileKeys(NativePath::join(PLY_WORKSPACE_FOLDER, "repos/plywood/src/runtime/ply-runtime/container")) .view()); srcKeys.extend( getSourceFileKeys( NativePath::join(PLY_WORKSPACE_FOLDER, "repos/plywood/src/runtime/ply-runtime/string")) .view()); srcKeys.extend( getSourceFileKeys(NativePath::join(PLY_WORKSPACE_FOLDER, "repos/plywood/src/runtime/ply-runtime/filesystem")) .view()); for (StringView srcKey : srcKeys) { rootRefs.append(ctx.cook({&ply::docs::CookJobType_ExtractAPI, srcKey})); } // Extract page metas Reference<cook::CookJob> contentsRoot = extractPageMetasFromFolder(&ctx, "/"); // Cook all pages visitPageMetas(contentsRoot, [&](const docs::CookResult_ExtractPageMeta* pageMetaResult) { rootRefs.append(ctx.cook({&ply::docs::CookJobType_Page, pageMetaResult->job->id.desc})); }); ctx.cookDeferred(); // Save contents (FIXME: Skip this step if dependencies haven't changed) Array<web::Contents> contents; { web::Contents converted = convertContents(contentsRoot); web::Contents& home = contents.append(); home.title = "Home"; home.linkDestination = "/"; contents.moveExtend(converted.children.view()); } { auto aRoot = pylon::exportObj(TypedPtr::bind(&contents)); MemOutStream mout; pylon::write(&mout, aRoot); FileSystem::native()->makeDirsAndSaveTextIfDifferent( NativePath::join(PLY_WORKSPACE_FOLDER, "data/docsite/contents.pylon"), mout.moveToString(), TextFormat::unixUTF8()); } // Cook stylesheet rootRefs.append(ctx.cook({&ply::docs::CookJobType_StyleSheetID, {}})); db.setRootReferences(std::move(rootRefs)); contentsRoot.clear(); copyJobs.clear(); ctx.endCook(); return 0; }
[ "filter-github@preshing.com" ]
filter-github@preshing.com
94dbf08e8ee4cd74524c1b8623ff40f543036a4b
95626140b639c93a5bc7d86c5ed7cead4d27372a
/algorithm And Data Structure/Graph/BFS/ONEZERO - Ones and zeros(spoj).cpp
1bdd99a50b680e982428a3e90d9b5fe6086829c2
[]
no_license
asad-shuvo/ACM
059bed7f91261af385d1be189e544fe240da2ff2
2dea0ef7378d831097efdf4cae25fbc6f34b8064
refs/heads/master
2022-06-08T13:03:04.294916
2022-05-13T12:22:50
2022-05-13T12:22:50
211,629,208
0
0
null
null
null
null
UTF-8
C++
false
false
2,708
cpp
#include <bits/stdc++.h> using namespace std; int fx4[] = {1 , -1 , 0 , 0}; int fy4[] = {0 , 0 , 1 , -1}; int Kfx[]= {-2,-2,2,2,1,1,-1,-1}; ///knight move x - exis int Kfy[]= {1,-1,1,-1,2,-2,2,-2}; ///knight move y- exis int fx8[]= {1,1,1,0,0,-1,-1,-1}; int fy8[]= {0,1,-1,1,-1,0,1,-1}; #define ll long long int #define pii pair<int,int> #define llu unsigned long long #define inf 1<<28 #define gama 0.57721566490 #define PI acos(-1.0) #define INF 0x7fffffff #define MOD 1000000007 #define EPS 1e-7 /* bool status[mx]; void sieve(){ long long int i,j; for(i=2;i<=mx;i++) { status[i]=0; } for( i=2;i<=sqrt(mx);i++){ if(status[i]==0) { for(j=i*i;j<=mx;j+=i){ status[j]=1; } } } }*/ ll BM( ll a , ll b , ll m ) { if ( b == 0 ) return 1 ; ll x = BM(a,b/2,m); x = (( x % m) * (x % m))%m; if( b % 2 ) x = (( x % m) * (a %m)) % m ; return x ; } #define dd double #define sc scanf #define pr printf #define VI vector<int> #define VS vector<string> #define VC vector<char> #define VLL vector<long long int> #define FILE freopen("input.txt","rt",stdin); freopen("output.txt","w",stdout); #define p_b push_back #define mem(x,y) memset(x,y,sizeof(x)) #define F(i,a,b) for(i=a;i<=b;i++) #define sc1(a) scanf("%d",&a) #define scL1(a) scanf("%lld",&a) #define scL2(a,b) scanf("%lld%lld",&a,&b) #define sc2(a,b) scanf("%d%d",&a,&b) #define sc3(a,b,c) scanf("%d%d%d",&a,&b,&c) #define scL3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c) #define fori(N) for(int i = 0; i<(N); i++) #define forj(N) for(int j = 0; j<(N); j++) #define fork(N) for(int k = 0; k<(N); k++) #define forl(N) for(int l = 0; l<(N); l++) #define ford(N) for(int d = 0; d<(N); d++) #define fori1(N) for(int i = 1; i<=(N); i++) #define forj1(N) for(int j = 1; j<=(N); j++) #define fork1(N) for(int k = 1; k<=(N); k++) #define ford1(N) for(int d = 1; d<=(N); d++) #define sqr(x) (x)*(x) #define TEST int test,te=0 #define segment_tree int l=(n*2),r=(n*2)+1,mid=(l+r)/2 #define Mx 100005 #define mx 10005 #define __FastIO ios_base::sync_with_stdio(false); cin.tie(0) int n; string bfs() { queue<string>q; q.push("1"); while(!q.empty()){ string tmp=q.front(); q.pop(); int value=0; for(int i=0;i<tmp.size();i++) { value=((value*10)+(tmp[i]-'0'))%n; } if(value==0)return tmp; q.push(tmp+'0'); q.push(tmp+'1'); } } int main() { int test; sc1(test); while(test--){ sc1(n); cout<<bfs()<<endl; } }
[ "asad.shuvo.cse@gmail.com" ]
asad.shuvo.cse@gmail.com
e052a551d47e097bd53e37f0e4768ff3c7d181f9
2c73a693c2b3c162eae2ab94f649d8c4494878ba
/components/multimedia/amr_decode/amr_nb/dec/src/ec_gains.c
f5d4a9d0c856646e30798cb80dd44b61fc8436d6
[ "MIT" ]
permissive
openLuat/LuatOS
185e1e140aed908434168133571ddcafe98f4e12
4b29d5121ab4f7133630331e8502c526c7856897
refs/heads/master
2023-08-23T04:57:23.263539
2023-08-23T04:46:46
2023-08-23T04:46:46
230,403,844
378
93
MIT
2021-12-17T02:19:30
2019-12-27T08:29:19
C
UTF-8
C++
false
false
20,455
c
/* ------------------------------------------------------------------ * Copyright (C) 1998-2009 PacketVideo * * 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. * ------------------------------------------------------------------- */ /**************************************************************************************** Portions of this file are derived from the following 3GPP standard: 3GPP TS 26.073 ANSI-C code for the Adaptive Multi-Rate (AMR) speech codec Available from http://www.3gpp.org (C) 2004, 3GPP Organizational Partners (ARIB, ATIS, CCSA, ETSI, TTA, TTC) Permission to distribute, modify and use this file under the standard license terms listed above has been obtained from the copyright holder. ****************************************************************************************/ /* ------------------------------------------------------------------------------ Filename: ec_gains.cpp ------------------------------------------------------------------------------ MODULE DESCRIPTION These modules execute the code book gains for error concealment. This module contains the init, reset, exit, and "main" functions in this process. ------------------------------------------------------------------------------ */ /*---------------------------------------------------------------------------- ; INCLUDES ----------------------------------------------------------------------------*/ #include "ec_gains.h" #include "typedef.h" #include "cnst.h" #include "gmed_n.h" #include "gc_pred.h" #include "basic_op.h" /*--------------------------------------------------------------------------*/ #ifdef __cplusplus extern "C" { #endif /*---------------------------------------------------------------------------- ; MACROS ; Define module specific macros here ----------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------- ; DEFINES ; Include all pre-processor statements here. Include conditional ; compile variables also. ----------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------- ; LOCAL FUNCTION DEFINITIONS ; Function Prototype declaration ----------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------- ; LOCAL VARIABLE DEFINITIONS ; Variable declaration - defined here and used outside this module ----------------------------------------------------------------------------*/ /*--------------------------------------------------------------------------*/ #ifdef __cplusplus } #endif /* ------------------------------------------------------------------------------ FUNCTION NAME: ec_gain_code_reset ------------------------------------------------------------------------------ INPUT AND OUTPUT DEFINITIONS Inputs: state = pointer to a pointer to a structure containing code state data of stucture type ec_gain_codeState Outputs: None. Returns: None Global Variables Used: None. Local Variables Needed: None. ------------------------------------------------------------------------------ FUNCTION DESCRIPTION This function resets the state data for the ec_gain module. ------------------------------------------------------------------------------ REQUIREMENTS None ------------------------------------------------------------------------------ REFERENCES None ------------------------------------------------------------------------------ PSEUDO-CODE int ec_gain_code_reset (ec_gain_codeState *state) { Word16 i; if (state == (ec_gain_codeState *) NULL){ // fprintf(stderr, "ec_gain_code_reset: invalid parameter\n"); return -1; } for ( i = 0; i < 5; i++) state->gbuf[i] = 1; state->past_gain_code = 0; state->prev_gc = 1; return 0; } ------------------------------------------------------------------------------ CAUTION [optional] [State any special notes, constraints or cautions for users of this function] ------------------------------------------------------------------------------ */ Word16 ec_gain_code_reset(ec_gain_codeState *state) { Word16 i; if (state == (ec_gain_codeState *) NULL) { /* fprintf(stderr, "ec_gain_code_reset: invalid parameter\n"); */ return -1; } for (i = 0; i < 5; i++) state->gbuf[i] = 1; state->past_gain_code = 0; state->prev_gc = 1; return 0; } /* ------------------------------------------------------------------------------ FUNCTION NAME: ec_gain_code ------------------------------------------------------------------------------ INPUT AND OUTPUT DEFINITIONS Inputs: st = pointer to a pointer to a structure containing code state data of stucture type ec_gain_codeState pred_state = pointer to MA predictor state of type gc_predState state = state of the state machine of type Word16 gain_code = pointer to decoded innovation gain of type Word16 pOverflow = pointer to overflow indicator of type Flag Outputs: st = pointer to a pointer to a structure containing code state data of stucture type ec_gain_codeState pred_state = pointer to MA predictor state of type gc_predState pOverflow = 1 if there is an overflow else it is zero. Returns: None. Global Variables Used: None. Local Variables Needed: None. ------------------------------------------------------------------------------ FUNCTION DESCRIPTION This function does error concealment using the codebook. Call this function only in BFI (instead of normal gain decoding function). ------------------------------------------------------------------------------ REQUIREMENTS None. ------------------------------------------------------------------------------ REFERENCES ec_gain.c, UMTS GSM AMR speech codec, R99 - Version 3.2.0, March 2, 2001 ------------------------------------------------------------------------------ PSEUDO-CODE static const Word16 cdown[7] = { 32767, 32112, 32112, 32112, 32112, 32112, 22937 }; Word16 tmp; Word16 qua_ener_MR122; Word16 qua_ener; // calculate median of last five gain values tmp = gmed_n (st->gbuf,5); // new gain = minimum(median, past_gain) * cdown[state] if (sub (tmp, st->past_gain_code) > 0) { tmp = st->past_gain_code; } tmp = mult (tmp, cdown[state]); *gain_code = tmp; // update table of past quantized energies with average of // current values gc_pred_average_limited(pred_state, &qua_ener_MR122, &qua_ener); gc_pred_update(pred_state, qua_ener_MR122, qua_ener); } ------------------------------------------------------------------------------ CAUTION [optional] [State any special notes, constraints or cautions for users of this function] ------------------------------------------------------------------------------ */ void ec_gain_code( ec_gain_codeState *st, /* i/o : State struct */ gc_predState *pred_state, /* i/o : MA predictor state */ Word16 state, /* i : state of the state machine */ Word16 *gain_code, /* o : decoded innovation gain */ Flag *pOverflow ) { static const Word16 cdown[7] = { 32767, 32112, 32112, 32112, 32112, 32112, 22937 }; Word16 tmp; Word16 qua_ener_MR122; Word16 qua_ener; /* calculate median of last five gain values */ tmp = gmed_n(st->gbuf, 5); /* new gain = minimum(median, past_gain) * cdown[state] */ if (sub(tmp, st->past_gain_code, pOverflow) > 0) { tmp = st->past_gain_code; } tmp = mult(tmp, cdown[state], pOverflow); *gain_code = tmp; /* update table of past quantized energies with average of * current values */ gc_pred_average_limited(pred_state, &qua_ener_MR122, &qua_ener, pOverflow); gc_pred_update(pred_state, qua_ener_MR122, qua_ener); } /****************************************************************************/ /* ------------------------------------------------------------------------------ FUNCTION NAME: ec_gain_code_update ------------------------------------------------------------------------------ INPUT AND OUTPUT DEFINITIONS Inputs: st = pointer to a pointer to a structure containing code state data of stucture type ec_gain_codeState bfi = a flag that indicates if the frame is bad of type Word16 prev_bf = a flag that indicates if the previous frame was bad of type Word16 gain_code = pointer to decoded innovation gain of type Word16 pOverflow = pointer to overflow indicator of type Flag Outputs: st = pointer to a pointer to a structure containing code state data of stucture type ec_gain_codeState gain_code = pointer to decoded innovation gain of type Word16 pOverflow = 1 if there is an overflow else it is zero. Returns: None. Global Variables Used: None. Local Variables Needed: None. ------------------------------------------------------------------------------ FUNCTION DESCRIPTION Purpose : update the codebook gain concealment state; limit gain_code if the previous frame was bad Call this function always after decoding (or concealing) the gain ------------------------------------------------------------------------------ REQUIREMENTS None. ------------------------------------------------------------------------------ REFERENCES ec_gain.c, UMTS GSM AMR speech codec, R99 - Version 3.2.0, March 2, 2001 ------------------------------------------------------------------------------ PSEUDO-CODE Word16 i; // limit gain_code by previous good gain if previous frame was bad if (bfi == 0) { if (prev_bf != 0) { if (sub (*gain_code, st->prev_gc) > 0) { *gain_code = st->prev_gc; } } st->prev_gc = *gain_code; } // update EC states: previous gain, gain buffer st->past_gain_code = *gain_code; for (i = 1; i < 5; i++) { st->gbuf[i - 1] = st->gbuf[i]; } st->gbuf[4] = *gain_code; return; } ------------------------------------------------------------------------------ CAUTION [optional] [State any special notes, constraints or cautions for users of this function] ------------------------------------------------------------------------------ */ void ec_gain_code_update( ec_gain_codeState *st, /* i/o : State struct */ Word16 bfi, /* i : flag: frame is bad */ Word16 prev_bf, /* i : flag: previous frame was bad */ Word16 *gain_code, /* i/o : decoded innovation gain */ Flag *pOverflow ) { Word16 i; /* limit gain_code by previous good gain if previous frame was bad */ if (bfi == 0) { if (prev_bf != 0) { if (sub(*gain_code, st->prev_gc, pOverflow) > 0) { *gain_code = st->prev_gc; } } st->prev_gc = *gain_code; } /* update EC states: previous gain, gain buffer */ st->past_gain_code = *gain_code; for (i = 1; i < 5; i++) { st->gbuf[i - 1] = st->gbuf[i]; } st->gbuf[4] = *gain_code; return; } /****************************************************************************/ /* ------------------------------------------------------------------------------ FUNCTION NAME: ec_gain_pitch ------------------------------------------------------------------------------ INPUT AND OUTPUT DEFINITIONS Inputs: st = pointer to a pointer to a structure containing code state data of stucture type ec_gain_pitchState state = state of the state machine of type Word16 pOverflow = pointer to overflow indicator of type Flag Outputs: state = pointer to a pointer to a structure containing code state data of stucture type ec_gain_pitchState gain_pitch = pointer to pitch gain (Q14) of type Word16 pOverflow = 1 if there is an overflow else it is zero. Returns: None. Global Variables Used: None. Local Variables Needed: None. ------------------------------------------------------------------------------ FUNCTION DESCRIPTION This function conceals the error using code gain implementation in this function. ------------------------------------------------------------------------------ REQUIREMENTS None. ------------------------------------------------------------------------------ REFERENCES ec_gain.c, UMTS GSM AMR speech codec, R99 - Version 3.2.0, March 2, 2001 ------------------------------------------------------------------------------ PSEUDO-CODE static const Word16 pdown[7] = { 32767, 32112, 32112, 26214, 9830, 6553, 6553 }; Word16 tmp; // calculate median of last five gains tmp = gmed_n (st->pbuf, 5); // new gain = minimum(median, past_gain) * pdown[state] if (sub (tmp, st->past_gain_pit) > 0) { tmp = st->past_gain_pit; } *gain_pitch = mult (tmp, pdown[state]); ------------------------------------------------------------------------------ CAUTION [optional] [State any special notes, constraints or cautions for users of this function] ------------------------------------------------------------------------------ */ void ec_gain_pitch( ec_gain_pitchState *st, /* i/o : state variables */ Word16 state, /* i : state of the state machine */ Word16 *gain_pitch, /* o : pitch gain (Q14) */ Flag *pOverflow ) { static const Word16 pdown[7] = { 32767, 32112, 32112, 26214, 9830, 6553, 6553 }; Word16 tmp; /* calculate median of last five gains */ tmp = gmed_n(st->pbuf, 5); /* new gain = minimum(median, past_gain) * pdown[state] */ if (sub(tmp, st->past_gain_pit, pOverflow) > 0) { tmp = st->past_gain_pit; } *gain_pitch = mult(tmp, pdown[state], pOverflow); } /****************************************************************************/ /* ------------------------------------------------------------------------------ FUNCTION NAME: ec_gain_pitch_reset ------------------------------------------------------------------------------ INPUT AND OUTPUT DEFINITIONS Inputs: state = state of the state machine of type Word16 pOverflow = pointer to overflow indicator of type Flag Outputs: state = pointer to a pointer to a structure containing code state data of stucture type ec_gain_pitchState pOverflow = 1 if there is an overflow else it is zero. Returns: None. Global Variables Used: None. Local Variables Needed: None. ------------------------------------------------------------------------------ FUNCTION DESCRIPTION Function: ec_gain_pitch_reset Purpose: Resets state memory ------------------------------------------------------------------------------ REQUIREMENTS None. ------------------------------------------------------------------------------ REFERENCES ec_gain.c, UMTS GSM AMR speech codec, R99 - Version 3.2.0, March 2, 2001 ------------------------------------------------------------------------------ PSEUDO-CODE int ec_gain_pitch_reset (ec_gain_pitchState *state) { Word16 i; if (state == (ec_gain_pitchState *) NULL){ // fprintf(stderr, "ec_gain_pitch_reset: invalid parameter\n"); return -1; } for(i = 0; i < 5; i++) state->pbuf[i] = 1640; state->past_gain_pit = 0; state->prev_gp = 16384; return 0; } ------------------------------------------------------------------------------ CAUTION [optional] [State any special notes, constraints or cautions for users of this function] ------------------------------------------------------------------------------ */ Word16 ec_gain_pitch_reset(ec_gain_pitchState *state) { Word16 i; if (state == (ec_gain_pitchState *) NULL) { /* fprintf(stderr, "ec_gain_pitch_reset: invalid parameter\n"); */ return -1; } for (i = 0; i < 5; i++) state->pbuf[i] = 1640; state->past_gain_pit = 0; state->prev_gp = 16384; return 0; } /****************************************************************************/ /* ------------------------------------------------------------------------------ FUNCTION NAME: ec_gain_pitch_update ------------------------------------------------------------------------------ INPUT AND OUTPUT DEFINITIONS Inputs: st = pointer to a pointer to a structure containing code state data of stucture type ec_gain_pitchState bfi = flag indicating the frame is bad of type Word16 prev_bf = flag indicating the previous frame was bad of type Word16 gain_pitch = pointer to pitch gain of type Word16 pOverflow = pointer to overflow indicator of type Flag Outputs: state = pointer to a pointer to a structure containing code state data of stucture type ec_gain_pitchState gain_pitch = pointer to pitch gain of type Word16 pOverflow = 1 if there is an overflow else it is zero. Returns: None. Global Variables Used: None. Local Variables Needed: None. ------------------------------------------------------------------------------ FUNCTION DESCRIPTION Purpose : update the pitch gain concealment state; limit gain_pitch if the previous frame was bad Call this function always after decoding (or concealing) the gain ------------------------------------------------------------------------------ REQUIREMENTS None. ------------------------------------------------------------------------------ REFERENCES ec_gain.c, UMTS GSM AMR speech codec, R99 - Version 3.2.0, March 2, 2001 ------------------------------------------------------------------------------ PSEUDO-CODE Word16 i; if (bfi == 0) { if (prev_bf != 0) { if (sub (*gain_pitch, st->prev_gp) > 0) { *gain_pitch = st->prev_gp; } } st->prev_gp = *gain_pitch; } st->past_gain_pit = *gain_pitch; if (sub (st->past_gain_pit, 16384) > 0) // if (st->past_gain_pit > 1.0) { st->past_gain_pit = 16384; } for (i = 1; i < 5; i++) { st->pbuf[i - 1] = st->pbuf[i]; } st->pbuf[4] = st->past_gain_pit; ------------------------------------------------------------------------------ CAUTION [optional] [State any special notes, constraints or cautions for users of this function] ------------------------------------------------------------------------------ */ void ec_gain_pitch_update( ec_gain_pitchState *st, /* i/o : state variables */ Word16 bfi, /* i : flag: frame is bad */ Word16 prev_bf, /* i : flag: previous frame was bad */ Word16 *gain_pitch, /* i/o : pitch gain */ Flag *pOverflow ) { Word16 i; if (bfi == 0) { if (prev_bf != 0) { if (sub(*gain_pitch, st->prev_gp, pOverflow) > 0) { *gain_pitch = st->prev_gp; } } st->prev_gp = *gain_pitch; } st->past_gain_pit = *gain_pitch; if (sub(st->past_gain_pit, 16384, pOverflow) > 0) /* if (st->past_gain_pit > 1.0) */ { st->past_gain_pit = 16384; } for (i = 1; i < 5; i++) { st->pbuf[i - 1] = st->pbuf[i]; } st->pbuf[4] = st->past_gain_pit; }
[ "alienwalker@sina.com" ]
alienwalker@sina.com
dee8fa0d81dc1771be1b05c1c6ec20e18011680f
1f63dde39fcc5f8be29f2acb947c41f1b6f1683e
/Boss2D/addon/webrtc-jumpingyang001_for_boss/modules/video_coding/codecs/vp9/include/vp9.h
89aa4bb580e402195b532e688259e5a1fca1f280
[ "BSD-3-Clause", "LicenseRef-scancode-google-patent-license-webm", "LicenseRef-scancode-google-patent-license-webrtc", "LicenseRef-scancode-unknown-license-reference", "MIT" ]
permissive
koobonil/Boss2D
09ca948823e0df5a5a53b64a10033c4f3665483a
e5eb355b57228a701495f2660f137bd05628c202
refs/heads/master
2022-10-20T09:02:51.341143
2019-07-18T02:13:44
2019-07-18T02:13:44
105,999,368
7
2
MIT
2022-10-04T23:31:12
2017-10-06T11:57:07
C++
UTF-8
C++
false
false
1,727
h
/* * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. * * Use of this source code is governed by a BSD-style license * that can be found in the LICENSE file in the root of the source * tree. An additional intellectual property rights grant can be found * in the file PATENTS. All contributing project authors may * be found in the AUTHORS file in the root of the source tree. * */ #ifndef MODULES_VIDEO_CODING_CODECS_VP9_INCLUDE_VP9_H_ #define MODULES_VIDEO_CODING_CODECS_VP9_INCLUDE_VP9_H_ #include <memory> #include <vector> #include BOSS_WEBRTC_U_api__video_codecs__sdp_video_format_h //original-code:"api/video_codecs/sdp_video_format.h" #include BOSS_WEBRTC_U_media__base__codec_h //original-code:"media/base/codec.h" #include BOSS_WEBRTC_U_modules__video_coding__include__video_codec_interface_h //original-code:"modules/video_coding/include/video_codec_interface.h" namespace webrtc { // Returns a vector with all supported internal VP9 profiles that we can // negotiate in SDP, in order of preference. std::vector<SdpVideoFormat> SupportedVP9Codecs(); class VP9Encoder : public VideoEncoder { public: // Deprecated. Returns default implementation using VP9 Profile 0. // TODO(emircan): Remove once this is no longer used. static std::unique_ptr<VP9Encoder> Create(); // Parses VP9 Profile from |codec| and returns the appropriate implementation. static std::unique_ptr<VP9Encoder> Create(const cricket::VideoCodec& codec); ~VP9Encoder() override {} }; class VP9Decoder : public VideoDecoder { public: static std::unique_ptr<VP9Decoder> Create(); ~VP9Decoder() override {} }; } // namespace webrtc #endif // MODULES_VIDEO_CODING_CODECS_VP9_INCLUDE_VP9_H_
[ "slacealic@nate.com" ]
slacealic@nate.com
5ff9eb7d6d2fbec0cab54d0523a9068612a7ee55
41bc115ac2ebc2debeb1814e952c46c99164ee41
/csrc/draw.cpp
ea83ba408f75e72f28567f325845f6db1591f470
[ "BSD-3-Clause", "MIT" ]
permissive
nebuta/HaskellCV
656be555bb170faaa44d4dba17b999bab9566ec3
2cfe00527422c70cc63f0a78af8810668be383ae
refs/heads/master
2020-12-24T17:26:10.342563
2013-06-29T21:33:03
2013-06-29T21:33:03
null
0
0
null
null
null
null
UTF-8
C++
false
false
871
cpp
// // draw.cpp // HaskellCV // // Created by Hiroyuki Kai on 10/5/12. // Copyright (c) 2012 Hiroyuki Kai. All rights reserved. // #include "draw.h" #include "opencv2/opencv.hpp" #include "opencv2/highgui/highgui.hpp" #include <map> extern "C" { #include "mainlib.h" using namespace cv; using namespace std; void m_circle(Mat* mat, int y, int x, int radius, int b, int g, int r, int thickness){ circle(*mat, Point(x,y), radius, Scalar(b,g,r),thickness,CV_AA); } void m_rectangle(Mat* mat, int y1, int x1, int y2, int x2, int b, int g, int r, int thickness){ rectangle(*mat, Point(x1,y1), Point(x2,y2), Scalar(b,g,r),thickness,CV_AA); } void m_line(Mat* mat, int y1, int x1, int y2, int x2, int b, int g, int r, int thickness){ line(*mat, Point(x1,y1), Point(x2,y2), Scalar(b,g,r),thickness,CV_AA); } }
[ "fullerenec84@gmail.com" ]
fullerenec84@gmail.com
fd5cbde9df61dc027450d65c1edb0fa2089f9e64
ce7453e65bc63cfffa334a39a368891eab082f29
/mediatek/platform/mt6589/hardware/mtkcam/core/featureio/pipe/aaa/isp_tuning/paramctrl/paramctrl_user.cpp
63512bb5cfed59704fdb0dfe7d6ea34123d1c8a6
[]
no_license
AdryV/kernel_w200_kk_4.4.2_3.4.67_mt6589
7a65d4c3ca0f4b59e4ad6d7d8a81c28862812f1c
f2b1be8f087cd8216ec1c9439b688df30c1c67d4
refs/heads/master
2021-01-13T00:45:17.398354
2016-12-04T17:41:24
2016-12-04T17:41:24
48,487,823
7
10
null
null
null
null
UTF-8
C++
false
false
8,570
cpp
/* Copyright Statement: * * This software/firmware and related documentation ("MediaTek Software") are * protected under relevant copyright laws. The information contained herein * is confidential and proprietary to MediaTek Inc. and/or its licensors. * Without the prior written permission of MediaTek inc. and/or its licensors, * any reproduction, modification, use or disclosure of MediaTek Software, * and information contained herein, in whole or in part, shall be strictly prohibited. */ /* MediaTek Inc. (C) 2010. All rights reserved. * * BY OPENING THIS FILE, RECEIVER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES * THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE") * RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO RECEIVER ON * AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT. * NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE * SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR * SUPPLIED WITH THE MEDIATEK SOFTWARE, AND RECEIVER AGREES TO LOOK ONLY TO SUCH * THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. RECEIVER EXPRESSLY ACKNOWLEDGES * THAT IT IS RECEIVER'S SOLE RESPONSIBILITY TO OBTAIN FROM ANY THIRD PARTY ALL PROPER LICENSES * CONTAINED IN MEDIATEK SOFTWARE. MEDIATEK SHALL ALSO NOT BE RESPONSIBLE FOR ANY MEDIATEK * SOFTWARE RELEASES MADE TO RECEIVER'S SPECIFICATION OR TO CONFORM TO A PARTICULAR * STANDARD OR OPEN FORUM. RECEIVER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND * CUMULATIVE LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE, * AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE, * OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY RECEIVER TO * MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. * * The following software/firmware and/or related documentation ("MediaTek Software") * have been modified by MediaTek Inc. All revisions are subject to any receiver's * applicable license agreements with MediaTek Inc. */ /******************************************************************************************** * LEGAL DISCLAIMER * * (Header of MediaTek Software/Firmware Release or Documentation) * * BY OPENING OR USING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES * THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE") RECEIVED * FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON AN "AS-IS" BASIS * ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES, EXPRESS OR IMPLIED, * INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR * A PARTICULAR PURPOSE OR NONINFRINGEMENT. NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY * WHATSOEVER WITH RESPECT TO THE SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, * INCORPORATED IN, OR SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK * ONLY TO SUCH THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO * NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S SPECIFICATION * OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM. * * BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE LIABILITY WITH * RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE, AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE, OR REFUND ANY SOFTWARE LICENSE * FEES OR SERVICE CHARGE PAID BY BUYER TO MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. * * THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE WITH THE LAWS * OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF LAWS PRINCIPLES. ************************************************************************************************/ #define LOG_TAG "paramctrl_user" #ifndef ENABLE_MY_LOG #define ENABLE_MY_LOG (1) #endif #include <aaa_types.h> #include <aaa_log.h> #include <mtkcam/hal/aaa_hal_base.h> #include <camera_custom_nvram.h> #include <isp_tuning.h> #include <camera_feature.h> #include <awb_param.h> #include <ae_param.h> #include <af_param.h> #include <flash_param.h> #include <isp_tuning_cam_info.h> #include <isp_tuning_idx.h> #include <isp_tuning_custom.h> #include <lsc_mgr.h> #include <dbg_isp_param.h> #include "paramctrl_if.h" #include "paramctrl.h" using namespace android; using namespace NSIspTuning; //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ MERROR_ENUM Paramctrl:: setIspUserIdx_Edge(EIndex_Isp_Edge_T const eIndex) { Mutex::Autolock lock(m_Lock); MY_LOG_IF(m_bDebugEnable, "[+setIspUserIdx_Edge] (old, new)=(%d, %d)", m_IspUsrSelectLevel.eIdx_Edge, eIndex); if ( checkParamChange(m_IspUsrSelectLevel.eIdx_Edge, eIndex) ) m_IspUsrSelectLevel.eIdx_Edge = eIndex; return MERR_OK; } //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ MERROR_ENUM Paramctrl:: setIspUserIdx_Hue(EIndex_Isp_Hue_T const eIndex) { Mutex::Autolock lock(m_Lock); MY_LOG_IF(m_bDebugEnable, "[+setIspUserIdx_Hue] (old, new)=(%d, %d)", m_IspUsrSelectLevel.eIdx_Hue, eIndex); if ( checkParamChange(m_IspUsrSelectLevel.eIdx_Hue, eIndex) ) m_IspUsrSelectLevel.eIdx_Hue = eIndex; return MERR_OK; } //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ MERROR_ENUM Paramctrl:: setIspUserIdx_Sat(EIndex_Isp_Saturation_T const eIndex) { Mutex::Autolock lock(m_Lock); MY_LOG_IF(m_bDebugEnable, "[+setIspUserIdx_Sat] (old, new)=(%d, %d)", m_IspUsrSelectLevel.eIdx_Sat, eIndex); if ( checkParamChange(m_IspUsrSelectLevel.eIdx_Sat, eIndex) ) m_IspUsrSelectLevel.eIdx_Sat = eIndex; return MERR_OK; } //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ MERROR_ENUM Paramctrl:: setIspUserIdx_Bright(EIndex_Isp_Brightness_T const eIndex) { Mutex::Autolock lock(m_Lock); MY_LOG_IF(m_bDebugEnable, "[+setIspUserIdx_Bright] (old, new)=(%d, %d)", m_IspUsrSelectLevel.eIdx_Bright, eIndex); if ( checkParamChange(m_IspUsrSelectLevel.eIdx_Bright, eIndex) ) m_IspUsrSelectLevel.eIdx_Bright = eIndex; return MERR_OK; } //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ MERROR_ENUM Paramctrl:: setIspUserIdx_Contrast(EIndex_Isp_Contrast_T const eIndex) { Mutex::Autolock lock(m_Lock); MY_LOG_IF(m_bDebugEnable, "[+setIspUserIdx_Contrast] (old, new)=(%d, %d)", m_IspUsrSelectLevel.eIdx_Contrast, eIndex); if ( checkParamChange(m_IspUsrSelectLevel.eIdx_Contrast, eIndex) ) m_IspUsrSelectLevel.eIdx_Contrast = eIndex; return MERR_OK; } //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ #if 0 MBOOL Paramctrl:: prepareHw_PerFrame_IspUserIndex() { MBOOL fgRet = MFALSE; // (0) Invoked only when Normal Operation Mode. if ( EOperMode_Normal != getOperMode() ) { fgRet = MTRUE; goto lbExit; } // Sharpness { // (a) Customize the nvram index based on the user setting. MUINT8 const u8Idx_EE = m_pIspTuningCustom-> map_user_setting_to_nvram_index<ISP_NVRAM_EE_T>( m_IspNvramMgr.getIdx_EE(), // The current nvram index. getIspUsrSelectLevel() // Get the user setting. ); // (b) Overwrite the params member. fgRet = m_IspNvramMgr.setIdx_EE(u8Idx_EE); if ( ! fgRet ) { MY_ERR( "[ERROR][prepareHw_PerFrame_IspUserIndex]" "setIdx_EE: bad idx(%d)", u8Idx_EE ); goto lbExit; } } MY_LOG( "[prepareHw_PerFrame_IspUserIndex](ee)=(%d)", m_IspNvramMgr.getIdx_EE() ); fgRet = MTRUE; lbExit: return fgRet; } #endif
[ "vetaxa.manchyk@gmail.com" ]
vetaxa.manchyk@gmail.com
763074db9c73671221d12e84ae0be905b02878e6
568788609344083b10e46332e2200fbbb16b55b0
/CodeForces/CF612B.cc
f24b33158a36ae024668b2182697564e4d579d7c
[]
no_license
BuglessCoder/algorithm-1
bd2011cfc31ace4690a9743663ae1fa26528a6fb
7fa2fd5ea284507416d6975dfc1fc4f3d4770f4f
refs/heads/master
2021-01-21T07:04:16.767337
2016-07-02T12:32:18
2016-07-02T12:32:18
null
0
0
null
null
null
null
UTF-8
C++
false
false
686
cc
#include <algorithm> #include <iostream> #include <iomanip> #include <cstring> #include <climits> #include <complex> #include <fstream> #include <cassert> #include <cstdio> #include <bitset> #include <vector> #include <deque> #include <queue> #include <stack> #include <ctime> #include <set> #include <map> #include <cmath> using namespace std; typedef long long LL; const int maxn = 2222222; int n; int f[maxn]; int main() { // freopen("in", "r", stdin); while(~scanf("%d", &n)) { int x; for(int i = 1; i <= n; i++) { scanf("%d", &x); f[x] = i; } LL ans = 0; for(int i = 2; i <= n; i++) { ans += abs(f[i] - f[i-1]); } printf("%I64d\n", ans); } return 0; }
[ "m13853352137@mail.bistu.edu.cn" ]
m13853352137@mail.bistu.edu.cn
4f95c7dea00ac597fdf9683cf89d336ead0cf53c
a3b7dcb909b363c4748c6a176863e97434b7cd09
/Assignments/Assignment3.cpp
7132a6273761f2a2dbe326d98500ce14fd275fe4
[]
no_license
pat-nel87/CppClasswork
e6f94690fdfd9315d92c54b5faf35bfc514612b9
c8d4e57279a4d3aec4293c38b980c87b4b0ffec8
refs/heads/main
2023-04-10T10:40:58.950848
2021-04-29T00:20:56
2021-04-29T00:20:56
334,282,032
0
0
null
null
null
null
UTF-8
C++
false
false
1,544
cpp
// STUDENT: PATRICK NELSON // ASSIGNMENT #: 3 // DUE: 3/02/21 #include <iostream> #include <iomanip> #include <string> #include <windows.h> //included to modify default background & text colors using namespace std; void dataCollect(); void pollResult(string names[], string win, double vtot[]); int main() { dataCollect(); return 0; } void dataCollect() { string last_name[5]; double votes[5]; double max = votes[0]; string winner; for (int i=0; i < 5; i++) { system("Color B5"); cout << "Enter Candidate " << i + 1 << "'s last name " << " "; getline(cin, last_name[i]); } for (int j=0; j < 5; j++) { system("Color 16"); cout << "Enter Candidate " << j + 1 << "'s total votes" << " "; cin >> votes[j]; if (max < votes[j]) //finds the winner while collecting votes, more effecient? { max = votes[j]; winner = last_name[j]; } } pollResult(last_name, winner, votes); } void pollResult(string names[], string win, double vtot[]) { double total; double percent; for(int h=0; h < 5; h++) { total = total + vtot[h]; } system("Color E4"); cout << "CANDIDATE " << "Votes Received " << "Percent of Total Votes" << "\n"; for (int k=0; k < 5; k++) { percent = (vtot[k] / total); percent = percent * 100; cout << names[k] << " " << vtot[k] << " " << percent << "%" << " \n"; } cout << "\n" << "Total Votes: " << total << endl; cout << "\n" << "The Winner of the election is: " << win << endl; }
[ "noreply@github.com" ]
noreply@github.com
8521e2782d8de115a0a96e2b4e8a9fabf25b53fb
fac201e6ba719956d1799705607cabb825cbe0c8
/LTE/LAAShadowFading.h
71be2cb33ba31da8a470291991a48ca9d36cce66
[]
no_license
MichaelZhangBUPT/LAA-Simulation
c1a3a784249b88f4e40a961f3ef3e4c254ec786e
41426a1ac69e3bacd0cecc1e146f9e5f8da648fb
refs/heads/master
2016-09-12T23:43:19.897186
2016-04-13T01:38:12
2016-04-13T01:38:12
56,025,089
0
0
null
null
null
null
UTF-8
C++
false
false
320
h
#pragma once #include "LAAFading.h" #include "RandomManager.h" #include "DB.h" namespace LTESim { class LAAShadowFading : public LAAFading { public: LAAShadowFading(); ~LAAShadowFading(); public: void Update(); double GetFading( int apid, int ueid, int TxAntenna, int RxAntenna, double distance )const; }; }
[ "799804777@qq.com" ]
799804777@qq.com
264942c9ec39f9e9ab677621aabef12d36c4da8c
cbd3ac62b75ac3dceb6ffb219eaa3fe9d2ef0c00
/src/base/trace_event/trace_category.h
de4ecdf056d31142a623452ddc7945488151d3fc
[ "BSD-3-Clause" ]
permissive
crazypeace/naiveproxy
d403fa282bcf65cac3eacb519667d6767080d05d
0a8242dca02b760272d4a0eb8f8a712f9d1093c4
refs/heads/master
2023-03-09T21:23:30.415305
2022-10-06T17:23:40
2022-10-06T17:23:40
null
0
0
null
null
null
null
UTF-8
C++
false
false
3,865
h
// Copyright 2016 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef BASE_TRACE_EVENT_TRACE_CATEGORY_H_ #define BASE_TRACE_EVENT_TRACE_CATEGORY_H_ #include <stdint.h> #include "base/check.h" namespace base { namespace trace_event { // Captures the state of an invidivual trace category. Nothing except tracing // internals (e.g., TraceLog) is supposed to have non-const Category pointers. struct TraceCategory { // The TRACE_EVENT macros should only use this value as a bool. // These enum values are effectively a public API and third_party projects // depend on their value. Hence, never remove or recycle existing bits, unless // you are sure that all the third-party projects that depend on this have // been updated. enum StateFlags : uint8_t { ENABLED_FOR_RECORDING = 1 << 0, // Not used anymore. DEPRECATED_ENABLED_FOR_MONITORING = 1 << 1, DEPRECATED_ENABLED_FOR_EVENT_CALLBACK = 1 << 2, ENABLED_FOR_ETW_EXPORT = 1 << 3, ENABLED_FOR_FILTERING = 1 << 4 }; static const TraceCategory* FromStatePtr(const uint8_t* state_ptr) { static_assert( offsetof(TraceCategory, state_) == 0, "|state_| must be the first field of the TraceCategory class."); return reinterpret_cast<const TraceCategory*>(state_ptr); } bool is_valid() const { return name_ != nullptr; } void set_name(const char* name) { name_ = name; } const char* name() const { DCHECK(is_valid()); return name_; } // TODO(primiano): This is an intermediate solution to deal with the fact that // today TRACE_EVENT* macros cache the state ptr. They should just cache the // full TraceCategory ptr, which is immutable, and use these helper function // here. This will get rid of the need of this awkward ptr getter completely. constexpr const uint8_t* state_ptr() const { return const_cast<const uint8_t*>(&state_); } uint8_t state() const { return *const_cast<volatile const uint8_t*>(&state_); } bool is_enabled() const { return state() != 0; } void set_state(uint8_t state) { *const_cast<volatile uint8_t*>(&state_) = state; } void clear_state_flag(StateFlags flag) { set_state(state() & (~flag)); } void set_state_flag(StateFlags flag) { set_state(state() | flag); } uint32_t enabled_filters() const { return *const_cast<volatile const uint32_t*>(&enabled_filters_); } bool is_filter_enabled(size_t index) const { DCHECK(index < sizeof(enabled_filters_) * 8); return (enabled_filters() & (1 << index)) != 0; } void set_enabled_filters(uint32_t enabled_filters) { *const_cast<volatile uint32_t*>(&enabled_filters_) = enabled_filters; } void reset_for_testing() { set_state(0); set_enabled_filters(0); } // These fields should not be accessed directly, not even by tracing code. // The only reason why these are not private is because it makes it impossible // to have a global array of TraceCategory in category_registry.cc without // creating initializers. See discussion on goo.gl/qhZN94 and // crbug.com/{660967,660828}. // The enabled state. TRACE_EVENT* macros will capture events if any of the // flags here are set. Since TRACE_EVENTx macros are used in a lot of // fast-paths, accesses to this field are non-barriered and racy by design. // This field is mutated when starting/stopping tracing and we don't care // about missing some events. uint8_t state_; // When ENABLED_FOR_FILTERING is set, this contains a bitmap to the // corresponding filter (see event_filters.h). uint32_t enabled_filters_; // TraceCategory group names are long lived static strings. const char* name_; }; } // namespace trace_event } // namespace base #endif // BASE_TRACE_EVENT_TRACE_CATEGORY_H_
[ "kizdiv@gmail.com" ]
kizdiv@gmail.com
6e083aaffad241bb9d5600bf5daf5088ac13b594
32fa66d6bd15fe4ff770f621f09818297de0ce07
/ContinuingEmployee.h
9e7b317ffda8fe43db47ae1bb0a8b3a60a4d02b9
[]
no_license
AliHassamCarleton/CuNics-Payroll-System-UMLs
382734e57c0b4d3ba3900b150f17a765e8c208f6
9236026ed2f8e9e8c47cc36cde00762263032eac
refs/heads/master
2021-03-27T18:28:49.217350
2017-12-04T13:48:04
2017-12-04T13:48:04
null
0
0
null
null
null
null
UTF-8
C++
false
false
209
h
#ifndef CONTINUINGEMPLOYEE_H #define CONTINUINGEMPLOYEE_H #include "defs.h" class ContinuingEmployee: public Employee{ public: ContinuingEmployee(); protected: float salary; }; #endif
[ "noreply@github.com" ]
noreply@github.com
16403a3ed8d69bc9b751f09dce2e7cfb8b47dfdb
6f2b6e9d77fc4dd5e1dae8ba6e5a66eb7c7ae849
/sstd_boost/sstd/boost/coroutine2/detail/disable_overload.hpp
b363fce8c013e8f0691af326456ecdbef88dc217
[ "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
849
hpp
 // Copyright Oliver Kowalke 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) #ifndef BOOST_COROUTINES2_DETAIL_DISABLE_OVERLOAD_H #define BOOST_COROUTINES2_DETAIL_DISABLE_OVERLOAD_H #include <type_traits> #include <sstd/boost/config.hpp> #include <sstd/boost/context/detail/disable_overload.hpp> #include <sstd/boost/coroutine2/detail/config.hpp> #ifdef BOOST_HAS_ABI_HEADERS # include BOOST_ABI_PREFIX #endif namespace boost { namespace coroutines2 { namespace detail { template< typename X, typename Y > using disable_overload = boost::context::detail::disable_overload< X, Y >; }}} #ifdef BOOST_HAS_ABI_HEADERS #include BOOST_ABI_SUFFIX #endif #endif // BOOST_COROUTINES2_DETAIL_DISABLE_OVERLOAD_H
[ "zhaixueqiang@hotmail.com" ]
zhaixueqiang@hotmail.com
dc57cf222e504fb296e001829f48cc48a4e6553b
a69c072954de44143bcd7310c15fb2ffa4a54c00
/Constructor destructor.cpp
14f88423301a24f28bd5a7bed4c43ed124c7a4b8
[]
no_license
bajwa96/Cplusplus
89dc10443ed8ced3d8231d7ba08a48578b4c52de
4945f91649af61f2127a4c644c8609bbbc223534
refs/heads/master
2021-01-21T10:26:31.483966
2017-02-28T13:13:16
2017-02-28T13:13:16
83,433,903
0
0
null
null
null
null
UTF-8
C++
false
false
1,001
cpp
#include <iostream> using namespace std ; /*Write Program to demonstrate use of constructors and destructors for performing dynamic operations //write code here int main() { data d1("obfuscation"); data d2("obstruction"); d1.show(); d2.show(); d1.compare(d2); return 0; } Expected output: Data 1= Obfuscation Data 2= Obstruction Both Objects have different text Release memory allocated to Obfuscation Release memory allocated to Obstructio*/ #include <string.h> class data{ int l; char name[100]; public: data(char a[100]){ int i; l=strlen(a); for(i=0;i<strlen(a);i++){ name[i]=a[i]; } name[i]='\0'; } void show(){ cout<<name<<endl; } void compare(data d){ if(l>d.l){ cout<<"Obj 1 is large\n"; } else if(l==d.l)cout<<"These are same\n"; else cout<<"Obj 2 is large\n"; } }; int main() { data d1("obfuscation"); data d2("obstruction"); d1.show(); d2.show(); d1.compare(d2); return 0; }
[ "noreply@github.com" ]
noreply@github.com
7a954d0f7db449a2f32f191f281535314c7e602d
78bf122075be16df0573953ebd822ad6454a6360
/hittable.h
efa497d5496c66ce8decec6b13f32ccfad8d9449
[]
no_license
BryanMCarroll/Ray_Tracer
fb67b411e6fd024b2174c80268f7e545f8ad730a
e5bf363c257037fdbb8ac8bfc242e07d4b47c45f
refs/heads/main
2023-02-19T09:37:12.867811
2021-01-26T00:44:38
2021-01-26T00:44:38
332,925,939
0
0
null
null
null
null
UTF-8
C++
false
false
719
h
#pragma once #include <memory> #include "material.h" #include "ray.h" struct hitRecord { public: // members point3 point; // hit point vec3 normal; // perpendicular from the surface hit point std::shared_ptr< material > matPtr; double t; // hit time bool frontFace; // methods inline void setFaceNormal( const ray& r, const vec3& outwardNormal ) { // if it's neg, the ray is striking from outside ( front ) frontFace = dot( r.direction(), outwardNormal ) < 0; normal = frontFace ? outwardNormal : -outwardNormal; } }; class hittable { public: // methods virtual bool hit( const ray& r, double tMin, double tMax, hitRecord& rec ) const = 0; };
[ "bmcarroll1986@gmail.com" ]
bmcarroll1986@gmail.com
c9b3805ee510295b2b1570ba85cf7b5b2bb8c721
7d2018678bd6ae35825e1a2d3e5c9d2bffaa503c
/examples/example_android/app/prebuilt/armeabi-v7a/include/ALLIVaultCoreP/ALLISharingGroupSyncNMP.h
a272ab57b94ca71433d8cd7d9ef45f366587c6d8
[]
no_license
allidev/android-demo
05b052118c7dab4845418633de55fab16ac83ceb
2a780badfb0fb95668864ede98f6482c4f006799
refs/heads/master
2020-06-14T03:56:53.858811
2017-07-16T02:19:03
2017-07-16T02:19:03
75,522,567
1
2
null
null
null
null
UTF-8
C++
false
false
2,825
h
#pragma once #include "ALLISharingGroupSyncP.h" #include "alli_event.h" namespace boost { namespace signals2 { class connection; } } namespace ALLIVaultCore { namespace FrontEnd { class ALLIExistingUserP; } namespace Helpers { class alli_semaphore; class ALLIStatusP; class ALLINewMachineStateP; class ALLISharingGroupSyncNMP : public ALLISharingGroupSyncP { public: typedef ALLIVaultCore::FrontEnd::mach_new_status_updated_event::slot_type MachNewStatusUpdatedSlotType; ALLISharingGroupSyncNMP(ALLIVaultCore::FrontEnd::ALLIExistingUserP &eu); ~ALLISharingGroupSyncNMP(); void initNMState(); void setNMState(ALLIVaultCore::Helpers::ALLINewMachineStateP *src); void setSharingCurSemap(ALLIVaultCore::Helpers::alli_semaphore *src); void setSharingALLIGroupList(std::vector<ALLIVaultCore::Helpers::ALLIGroupP> *src); void processSharingSyncNM(const std::string &hostUserName, const std::string &groupName, ALLIVaultCore::Helpers::ALLIStatusP &alli_status, int counter); boost::signals2::connection connectMachNewStatusUpdated(const MachNewStatusUpdatedSlotType &slot); private: //ALLIVaultCore::FrontEnd::ALLIExistingUserP &existUser; ALLIVaultCore::Helpers::ALLINewMachineStateP *nmState; // this semaphore is used to sync for new machine and sharing groups // when the user is a guest user. ALLIVaultCore::Helpers::alli_semaphore *sharingCurSemap; ALLIVaultCore::FrontEnd::mach_new_status_updated_event machNewStatusUpdated; void OnMachNewStatusUpdated(ALLIVaultCore::FrontEnd::new_machine_event_args &e); void setSharingUserNameSync(const std::string &hostUserName, const std::string &groupName); void batchActionsForSharingSync(const std::string &hostUserName, const std::string &groupName, ALLIVaultCore::Helpers::ALLIStatusP &alli_status, int counter); void setSharingHostUserNameSync(const std::string &guestUserName, const std::string &groupName); void setSharingGuestUserNameSync(const std::string &hostUserName, const std::string &hostFullName, const std::string &groupName); void setSharingGuestUserNameSync(const std::string &hostUserName, const std::string &groupName); void attachToNativeEventHandlerForCloneTransferUpdate(); void copyFilesFromServerToSharingPlainFolderImpl(void *obj) override; void copyFilesFromServerToSharingPlainFolderExImpl(const boost::filesystem::path &sharingPlainFolderURL) override; void monitorSharingSyncPlainRepoImpl(const std::string &hostUserName) override; void monitorSharingSyncEncryptedRepoImpl(const std::string &hostUserName) override; void monitorSharingSyncPlainFolderAtURLImpl(const boost::filesystem::path &sharingPlainFolder, const std::string &hostUserName) override; void copyFilesFromServerToSharingPlainFolderImpl_1(void *obj) override; }; } }
[ "xuesong@allienterprises.com" ]
xuesong@allienterprises.com
fc1fd3a01a19031807ec85bb0205bdea62994b05
f7e8786b1e62222bd1cedcb58383a0576c36a2a2
/src/mojo/environment/scoped_chromium_init.h
4908cb4bbd91ba419665776a1c70d1b1e056fd9f
[ "BSD-3-Clause" ]
permissive
amplab/ray-core
656915553742302915a363e42b7497037985a91e
89a278ec589d98bcbc7e57e0b80d055667cca62f
refs/heads/master
2023-07-07T20:45:40.883095
2016-08-06T23:52:23
2016-08-06T23:52:23
61,343,320
4
5
null
2016-08-06T23:52:24
2016-06-17T03:35:34
C++
UTF-8
C++
false
false
1,281
h
// Copyright 2016 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef MOJO_ENVIRONMENT_SCOPED_CHROMIUM_INIT_H_ #define MOJO_ENVIRONMENT_SCOPED_CHROMIUM_INIT_H_ #include "base/at_exit.h" #include "base/macros.h" namespace mojo { // Using code from //base typically requires that a number of things be // initialized/present. In particular the global |base::CommandLine| singleton // should be initialized and an |AtExitManager| should be present. // // This class is a simple helper that does these things (and tears down the // |AtExitManager| on destruction). Typically, it should be used in |MojoMain()| // as follows: // // MojoResult MojoMain(MojoHandle application_request) { // mojo::ScopedBaseInit init; // ... // } // // TODO(vtl): Maybe this should be called |ScopedBaseInit|, but for now I'm // being consistent with everything else that refers to things that use //base // as "chromium". class ScopedChromiumInit { public: ScopedChromiumInit(); ~ScopedChromiumInit(); private: base::AtExitManager at_exit_manager_; DISALLOW_COPY_AND_ASSIGN(ScopedChromiumInit); }; } // namespace mojo #endif // MOJO_ENVIRONMENT_SCOPED_CHROMIUM_INIT_H_
[ "pcmoritz@gmail.com" ]
pcmoritz@gmail.com
719ff4436627cbef9d6be557762e05d6415c33bd
d147f9c98bae97ed79cef2597977f61c83724c39
/STLWorkspace/Exam/DXExam1/DirectX_Assignment/08. DirectX_Texture/WinMain.cpp
45c0d963dd1cf0d00f509d8f1a6d5569917123e9
[]
no_license
daaie/SkillTreeLab
28ec4bea1057d4c44a5f15bcfb1e0178358f85e1
43482b9a4732836ad7b0f2df5c29c6b1debfa913
refs/heads/master
2020-03-17T05:06:08.824446
2018-07-17T04:49:47
2018-07-17T04:49:47
133,302,446
0
0
null
null
null
null
UHC
C++
false
false
314
cpp
#include <Windows.h> // 윈도우 생성하기 위해 필요. #include "Engine.h" int WINAPI WinMain( HINSTANCE hinstnace, HINSTANCE previnstance, LPSTR lpCmdLine, int nCmdLine) { Engine engine(hinstnace); // 초기화. if (engine.Init() == false) return 0; // 엔진 실행. return engine.Run(); }
[ "pda4423@gmail.com" ]
pda4423@gmail.com
fc54d4b1bce2d659916b5a2e5049f96cd69a440a
c776476e9d06b3779d744641e758ac3a2c15cddc
/examples/litmus/c/run-scripts/tmp_1/R+wsipl+polp-ctrl-popa001.c.cbmc.cpp
bb41de4c833d0750ba8b265ed20c493c8f79e720
[]
no_license
ashutosh0gupta/llvm_bmc
aaac7961c723ba6f7ffd77a39559e0e52432eade
0287c4fb180244e6b3c599a9902507f05c8a7234
refs/heads/master
2023-08-02T17:14:06.178723
2023-07-31T10:46:53
2023-07-31T10:46:53
143,100,825
3
4
null
2023-05-25T05:50:55
2018-08-01T03:47:00
C++
UTF-8
C++
false
false
36,217
cpp
// 0:vars:3 // 3:atom_0_X3_3:1 // 4:atom_1_X6_0:1 // 5:thr0:1 // 6:thr1:1 #define ADDRSIZE 7 #define NPROC 3 #define NCONTEXT 1 #define ASSUME(stmt) __CPROVER_assume(stmt) #define ASSERT(stmt) __CPROVER_assert(stmt, "error") #define max(a,b) (a>b?a:b) char __get_rng(); char get_rng( char from, char to ) { char ret = __get_rng(); ASSUME(ret >= from && ret <= to); return ret; } char get_rng_th( char from, char to ) { char ret = __get_rng(); ASSUME(ret >= from && ret <= to); return ret; } int main(int argc, char **argv) { // declare arrays for intial value version in contexts int meminit_[ADDRSIZE*NCONTEXT]; #define meminit(x,k) meminit_[(x)*NCONTEXT+k] int coinit_[ADDRSIZE*NCONTEXT]; #define coinit(x,k) coinit_[(x)*NCONTEXT+k] int deltainit_[ADDRSIZE*NCONTEXT]; #define deltainit(x,k) deltainit_[(x)*NCONTEXT+k] // declare arrays for running value version in contexts int mem_[ADDRSIZE*NCONTEXT]; #define mem(x,k) mem_[(x)*NCONTEXT+k] int co_[ADDRSIZE*NCONTEXT]; #define co(x,k) co_[(x)*NCONTEXT+k] int delta_[ADDRSIZE*NCONTEXT]; #define delta(x,k) delta_[(x)*NCONTEXT+k] // declare arrays for local buffer and observed writes int buff_[NPROC*ADDRSIZE]; #define buff(x,k) buff_[(x)*ADDRSIZE+k] int pw_[NPROC*ADDRSIZE]; #define pw(x,k) pw_[(x)*ADDRSIZE+k] // declare arrays for context stamps char cr_[NPROC*ADDRSIZE]; #define cr(x,k) cr_[(x)*ADDRSIZE+k] char iw_[NPROC*ADDRSIZE]; #define iw(x,k) iw_[(x)*ADDRSIZE+k] char cw_[NPROC*ADDRSIZE]; #define cw(x,k) cw_[(x)*ADDRSIZE+k] char cx_[NPROC*ADDRSIZE]; #define cx(x,k) cx_[(x)*ADDRSIZE+k] char is_[NPROC*ADDRSIZE]; #define is(x,k) is_[(x)*ADDRSIZE+k] char cs_[NPROC*ADDRSIZE]; #define cs(x,k) cs_[(x)*ADDRSIZE+k] char crmax_[NPROC*ADDRSIZE]; #define crmax(x,k) crmax_[(x)*ADDRSIZE+k] char sforbid_[ADDRSIZE*NCONTEXT]; #define sforbid(x,k) sforbid_[(x)*NCONTEXT+k] // declare arrays for synchronizations int cl[NPROC]; int cdy[NPROC]; int cds[NPROC]; int cdl[NPROC]; int cisb[NPROC]; int caddr[NPROC]; int cctrl[NPROC]; int cstart[NPROC]; int creturn[NPROC]; // declare arrays for contexts activity int active[NCONTEXT]; int ctx_used[NCONTEXT]; __LOCALS__ buff(0,0) = 0; pw(0,0) = 0; cr(0,0) = 0; iw(0,0) = 0; cw(0,0) = 0; cx(0,0) = 0; is(0,0) = 0; cs(0,0) = 0; crmax(0,0) = 0; buff(0,1) = 0; pw(0,1) = 0; cr(0,1) = 0; iw(0,1) = 0; cw(0,1) = 0; cx(0,1) = 0; is(0,1) = 0; cs(0,1) = 0; crmax(0,1) = 0; buff(0,2) = 0; pw(0,2) = 0; cr(0,2) = 0; iw(0,2) = 0; cw(0,2) = 0; cx(0,2) = 0; is(0,2) = 0; cs(0,2) = 0; crmax(0,2) = 0; buff(0,3) = 0; pw(0,3) = 0; cr(0,3) = 0; iw(0,3) = 0; cw(0,3) = 0; cx(0,3) = 0; is(0,3) = 0; cs(0,3) = 0; crmax(0,3) = 0; buff(0,4) = 0; pw(0,4) = 0; cr(0,4) = 0; iw(0,4) = 0; cw(0,4) = 0; cx(0,4) = 0; is(0,4) = 0; cs(0,4) = 0; crmax(0,4) = 0; buff(0,5) = 0; pw(0,5) = 0; cr(0,5) = 0; iw(0,5) = 0; cw(0,5) = 0; cx(0,5) = 0; is(0,5) = 0; cs(0,5) = 0; crmax(0,5) = 0; buff(0,6) = 0; pw(0,6) = 0; cr(0,6) = 0; iw(0,6) = 0; cw(0,6) = 0; cx(0,6) = 0; is(0,6) = 0; cs(0,6) = 0; crmax(0,6) = 0; cl[0] = 0; cdy[0] = 0; cds[0] = 0; cdl[0] = 0; cisb[0] = 0; caddr[0] = 0; cctrl[0] = 0; cstart[0] = get_rng(0,NCONTEXT-1); creturn[0] = get_rng(0,NCONTEXT-1); buff(1,0) = 0; pw(1,0) = 0; cr(1,0) = 0; iw(1,0) = 0; cw(1,0) = 0; cx(1,0) = 0; is(1,0) = 0; cs(1,0) = 0; crmax(1,0) = 0; buff(1,1) = 0; pw(1,1) = 0; cr(1,1) = 0; iw(1,1) = 0; cw(1,1) = 0; cx(1,1) = 0; is(1,1) = 0; cs(1,1) = 0; crmax(1,1) = 0; buff(1,2) = 0; pw(1,2) = 0; cr(1,2) = 0; iw(1,2) = 0; cw(1,2) = 0; cx(1,2) = 0; is(1,2) = 0; cs(1,2) = 0; crmax(1,2) = 0; buff(1,3) = 0; pw(1,3) = 0; cr(1,3) = 0; iw(1,3) = 0; cw(1,3) = 0; cx(1,3) = 0; is(1,3) = 0; cs(1,3) = 0; crmax(1,3) = 0; buff(1,4) = 0; pw(1,4) = 0; cr(1,4) = 0; iw(1,4) = 0; cw(1,4) = 0; cx(1,4) = 0; is(1,4) = 0; cs(1,4) = 0; crmax(1,4) = 0; buff(1,5) = 0; pw(1,5) = 0; cr(1,5) = 0; iw(1,5) = 0; cw(1,5) = 0; cx(1,5) = 0; is(1,5) = 0; cs(1,5) = 0; crmax(1,5) = 0; buff(1,6) = 0; pw(1,6) = 0; cr(1,6) = 0; iw(1,6) = 0; cw(1,6) = 0; cx(1,6) = 0; is(1,6) = 0; cs(1,6) = 0; crmax(1,6) = 0; cl[1] = 0; cdy[1] = 0; cds[1] = 0; cdl[1] = 0; cisb[1] = 0; caddr[1] = 0; cctrl[1] = 0; cstart[1] = get_rng(0,NCONTEXT-1); creturn[1] = get_rng(0,NCONTEXT-1); buff(2,0) = 0; pw(2,0) = 0; cr(2,0) = 0; iw(2,0) = 0; cw(2,0) = 0; cx(2,0) = 0; is(2,0) = 0; cs(2,0) = 0; crmax(2,0) = 0; buff(2,1) = 0; pw(2,1) = 0; cr(2,1) = 0; iw(2,1) = 0; cw(2,1) = 0; cx(2,1) = 0; is(2,1) = 0; cs(2,1) = 0; crmax(2,1) = 0; buff(2,2) = 0; pw(2,2) = 0; cr(2,2) = 0; iw(2,2) = 0; cw(2,2) = 0; cx(2,2) = 0; is(2,2) = 0; cs(2,2) = 0; crmax(2,2) = 0; buff(2,3) = 0; pw(2,3) = 0; cr(2,3) = 0; iw(2,3) = 0; cw(2,3) = 0; cx(2,3) = 0; is(2,3) = 0; cs(2,3) = 0; crmax(2,3) = 0; buff(2,4) = 0; pw(2,4) = 0; cr(2,4) = 0; iw(2,4) = 0; cw(2,4) = 0; cx(2,4) = 0; is(2,4) = 0; cs(2,4) = 0; crmax(2,4) = 0; buff(2,5) = 0; pw(2,5) = 0; cr(2,5) = 0; iw(2,5) = 0; cw(2,5) = 0; cx(2,5) = 0; is(2,5) = 0; cs(2,5) = 0; crmax(2,5) = 0; buff(2,6) = 0; pw(2,6) = 0; cr(2,6) = 0; iw(2,6) = 0; cw(2,6) = 0; cx(2,6) = 0; is(2,6) = 0; cs(2,6) = 0; crmax(2,6) = 0; cl[2] = 0; cdy[2] = 0; cds[2] = 0; cdl[2] = 0; cisb[2] = 0; caddr[2] = 0; cctrl[2] = 0; cstart[2] = get_rng(0,NCONTEXT-1); creturn[2] = get_rng(0,NCONTEXT-1); // Dumping initializations mem(0+0,0) = 0; mem(0+1,0) = 0; mem(0+2,0) = 0; mem(3+0,0) = 0; mem(4+0,0) = 0; mem(5+0,0) = 0; mem(6+0,0) = 0; // Dumping context matching equalities co(0,0) = 0; delta(0,0) = -1; co(1,0) = 0; delta(1,0) = -1; co(2,0) = 0; delta(2,0) = -1; co(3,0) = 0; delta(3,0) = -1; co(4,0) = 0; delta(4,0) = -1; co(5,0) = 0; delta(5,0) = -1; co(6,0) = 0; delta(6,0) = -1; // Dumping thread 1 int ret_thread_1 = 0; cdy[1] = get_rng(0,NCONTEXT-1); ASSUME(cdy[1] >= cstart[1]); T1BLOCK0: // call void @llvm.dbg.value(metadata i8* %arg, metadata !35, metadata !DIExpression()), !dbg !53 // br label %label_1, !dbg !54 goto T1BLOCK1; T1BLOCK1: // call void @llvm.dbg.label(metadata !52), !dbg !55 // call void @llvm.dbg.value(metadata i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 0), metadata !36, metadata !DIExpression()), !dbg !56 // call void @llvm.dbg.value(metadata i64 1, metadata !39, metadata !DIExpression()), !dbg !56 // store atomic i64 1, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 0) monotonic, align 8, !dbg !57 // ST: Guess iw(1,0) = get_rng(0,NCONTEXT-1);// 1 ASSIGN STIW old_cw = cw(1,0); cw(1,0) = get_rng(0,NCONTEXT-1);// 1 ASSIGN STCOM // Check ASSUME(active[iw(1,0)] == 1); ASSUME(active[cw(1,0)] == 1); ASSUME(sforbid(0,cw(1,0))== 0); ASSUME(iw(1,0) >= 0); ASSUME(iw(1,0) >= 0); ASSUME(cw(1,0) >= iw(1,0)); ASSUME(cw(1,0) >= old_cw); ASSUME(cw(1,0) >= cr(1,0)); ASSUME(cw(1,0) >= cl[1]); ASSUME(cw(1,0) >= cisb[1]); ASSUME(cw(1,0) >= cdy[1]); ASSUME(cw(1,0) >= cdl[1]); ASSUME(cw(1,0) >= cds[1]); ASSUME(cw(1,0) >= cctrl[1]); ASSUME(cw(1,0) >= caddr[1]); // Update caddr[1] = max(caddr[1],0); buff(1,0) = 1; mem(0,cw(1,0)) = 1; co(0,cw(1,0))+=1; delta(0,cw(1,0)) = -1; ASSUME(creturn[1] >= cw(1,0)); // call void @llvm.dbg.value(metadata i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 0), metadata !40, metadata !DIExpression()), !dbg !58 // call void @llvm.dbg.value(metadata i64 2, metadata !42, metadata !DIExpression()), !dbg !58 // store atomic i64 2, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 0) release, align 8, !dbg !59 // ST: Guess // : Release iw(1,0) = get_rng(0,NCONTEXT-1);// 1 ASSIGN STIW old_cw = cw(1,0); cw(1,0) = get_rng(0,NCONTEXT-1);// 1 ASSIGN STCOM // Check ASSUME(active[iw(1,0)] == 1); ASSUME(active[cw(1,0)] == 1); ASSUME(sforbid(0,cw(1,0))== 0); ASSUME(iw(1,0) >= 0); ASSUME(iw(1,0) >= 0); ASSUME(cw(1,0) >= iw(1,0)); ASSUME(cw(1,0) >= old_cw); ASSUME(cw(1,0) >= cr(1,0)); ASSUME(cw(1,0) >= cl[1]); ASSUME(cw(1,0) >= cisb[1]); ASSUME(cw(1,0) >= cdy[1]); ASSUME(cw(1,0) >= cdl[1]); ASSUME(cw(1,0) >= cds[1]); ASSUME(cw(1,0) >= cctrl[1]); ASSUME(cw(1,0) >= caddr[1]); ASSUME(cw(1,0) >= cr(1,0+0)); ASSUME(cw(1,0) >= cr(1,0+1)); ASSUME(cw(1,0) >= cr(1,0+2)); ASSUME(cw(1,0) >= cr(1,3+0)); ASSUME(cw(1,0) >= cr(1,4+0)); ASSUME(cw(1,0) >= cr(1,5+0)); ASSUME(cw(1,0) >= cr(1,6+0)); ASSUME(cw(1,0) >= cw(1,0+0)); ASSUME(cw(1,0) >= cw(1,0+1)); ASSUME(cw(1,0) >= cw(1,0+2)); ASSUME(cw(1,0) >= cw(1,3+0)); ASSUME(cw(1,0) >= cw(1,4+0)); ASSUME(cw(1,0) >= cw(1,5+0)); ASSUME(cw(1,0) >= cw(1,6+0)); // Update caddr[1] = max(caddr[1],0); buff(1,0) = 2; mem(0,cw(1,0)) = 2; co(0,cw(1,0))+=1; delta(0,cw(1,0)) = -1; is(1,0) = iw(1,0); cs(1,0) = cw(1,0); ASSUME(creturn[1] >= cw(1,0)); // call void @llvm.dbg.value(metadata i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 0), metadata !45, metadata !DIExpression()), !dbg !60 // %0 = load atomic i64, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 0) monotonic, align 8, !dbg !61 // LD: Guess old_cr = cr(1,0); cr(1,0) = get_rng(0,NCONTEXT-1);// 1 ASSIGN LDCOM // Check ASSUME(active[cr(1,0)] == 1); ASSUME(cr(1,0) >= iw(1,0)); ASSUME(cr(1,0) >= 0); ASSUME(cr(1,0) >= cdy[1]); ASSUME(cr(1,0) >= cisb[1]); ASSUME(cr(1,0) >= cdl[1]); ASSUME(cr(1,0) >= cl[1]); // Update creg_r0 = cr(1,0); crmax(1,0) = max(crmax(1,0),cr(1,0)); caddr[1] = max(caddr[1],0); if(cr(1,0) < cw(1,0)) { r0 = buff(1,0); } else { if(pw(1,0) != co(0,cr(1,0))) { ASSUME(cr(1,0) >= old_cr); } pw(1,0) = co(0,cr(1,0)); r0 = mem(0,cr(1,0)); } ASSUME(creturn[1] >= cr(1,0)); // call void @llvm.dbg.value(metadata i64 %0, metadata !47, metadata !DIExpression()), !dbg !60 // %conv = trunc i64 %0 to i32, !dbg !62 // call void @llvm.dbg.value(metadata i32 %conv, metadata !43, metadata !DIExpression()), !dbg !53 // %cmp = icmp eq i32 %conv, 3, !dbg !63 // %conv3 = zext i1 %cmp to i32, !dbg !63 // call void @llvm.dbg.value(metadata i32 %conv3, metadata !48, metadata !DIExpression()), !dbg !53 // call void @llvm.dbg.value(metadata i64* @atom_0_X3_3, metadata !49, metadata !DIExpression()), !dbg !64 // %1 = zext i32 %conv3 to i64 // call void @llvm.dbg.value(metadata i64 %1, metadata !51, metadata !DIExpression()), !dbg !64 // store atomic i64 %1, i64* @atom_0_X3_3 seq_cst, align 8, !dbg !65 // ST: Guess iw(1,3) = get_rng(0,NCONTEXT-1);// 1 ASSIGN STIW old_cw = cw(1,3); cw(1,3) = get_rng(0,NCONTEXT-1);// 1 ASSIGN STCOM // Check ASSUME(active[iw(1,3)] == 1); ASSUME(active[cw(1,3)] == 1); ASSUME(sforbid(3,cw(1,3))== 0); ASSUME(iw(1,3) >= max(creg_r0,0)); ASSUME(iw(1,3) >= 0); ASSUME(cw(1,3) >= iw(1,3)); ASSUME(cw(1,3) >= old_cw); ASSUME(cw(1,3) >= cr(1,3)); ASSUME(cw(1,3) >= cl[1]); ASSUME(cw(1,3) >= cisb[1]); ASSUME(cw(1,3) >= cdy[1]); ASSUME(cw(1,3) >= cdl[1]); ASSUME(cw(1,3) >= cds[1]); ASSUME(cw(1,3) >= cctrl[1]); ASSUME(cw(1,3) >= caddr[1]); // Update caddr[1] = max(caddr[1],0); buff(1,3) = (r0==3); mem(3,cw(1,3)) = (r0==3); co(3,cw(1,3))+=1; delta(3,cw(1,3)) = -1; ASSUME(creturn[1] >= cw(1,3)); // ret i8* null, !dbg !66 ret_thread_1 = (- 1); // Dumping thread 2 int ret_thread_2 = 0; cdy[2] = get_rng(0,NCONTEXT-1); ASSUME(cdy[2] >= cstart[2]); T2BLOCK0: // call void @llvm.dbg.value(metadata i8* %arg, metadata !69, metadata !DIExpression()), !dbg !91 // br label %label_2, !dbg !60 goto T2BLOCK1; T2BLOCK1: // call void @llvm.dbg.label(metadata !89), !dbg !93 // call void @llvm.dbg.value(metadata i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 0), metadata !70, metadata !DIExpression()), !dbg !94 // call void @llvm.dbg.value(metadata i64 3, metadata !72, metadata !DIExpression()), !dbg !94 // store atomic i64 3, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 0) release, align 8, !dbg !63 // ST: Guess // : Release iw(2,0) = get_rng(0,NCONTEXT-1);// 2 ASSIGN STIW old_cw = cw(2,0); cw(2,0) = get_rng(0,NCONTEXT-1);// 2 ASSIGN STCOM // Check ASSUME(active[iw(2,0)] == 2); ASSUME(active[cw(2,0)] == 2); ASSUME(sforbid(0,cw(2,0))== 0); ASSUME(iw(2,0) >= 0); ASSUME(iw(2,0) >= 0); ASSUME(cw(2,0) >= iw(2,0)); ASSUME(cw(2,0) >= old_cw); ASSUME(cw(2,0) >= cr(2,0)); ASSUME(cw(2,0) >= cl[2]); ASSUME(cw(2,0) >= cisb[2]); ASSUME(cw(2,0) >= cdy[2]); ASSUME(cw(2,0) >= cdl[2]); ASSUME(cw(2,0) >= cds[2]); ASSUME(cw(2,0) >= cctrl[2]); ASSUME(cw(2,0) >= caddr[2]); ASSUME(cw(2,0) >= cr(2,0+0)); ASSUME(cw(2,0) >= cr(2,0+1)); ASSUME(cw(2,0) >= cr(2,0+2)); ASSUME(cw(2,0) >= cr(2,3+0)); ASSUME(cw(2,0) >= cr(2,4+0)); ASSUME(cw(2,0) >= cr(2,5+0)); ASSUME(cw(2,0) >= cr(2,6+0)); ASSUME(cw(2,0) >= cw(2,0+0)); ASSUME(cw(2,0) >= cw(2,0+1)); ASSUME(cw(2,0) >= cw(2,0+2)); ASSUME(cw(2,0) >= cw(2,3+0)); ASSUME(cw(2,0) >= cw(2,4+0)); ASSUME(cw(2,0) >= cw(2,5+0)); ASSUME(cw(2,0) >= cw(2,6+0)); // Update caddr[2] = max(caddr[2],0); buff(2,0) = 3; mem(0,cw(2,0)) = 3; co(0,cw(2,0))+=1; delta(0,cw(2,0)) = -1; is(2,0) = iw(2,0); cs(2,0) = cw(2,0); ASSUME(creturn[2] >= cw(2,0)); // call void @llvm.dbg.value(metadata i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 1), metadata !74, metadata !DIExpression()), !dbg !96 // %0 = load atomic i64, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 1) monotonic, align 8, !dbg !65 // LD: Guess old_cr = cr(2,0+1*1); cr(2,0+1*1) = get_rng(0,NCONTEXT-1);// 2 ASSIGN LDCOM // Check ASSUME(active[cr(2,0+1*1)] == 2); ASSUME(cr(2,0+1*1) >= iw(2,0+1*1)); ASSUME(cr(2,0+1*1) >= 0); ASSUME(cr(2,0+1*1) >= cdy[2]); ASSUME(cr(2,0+1*1) >= cisb[2]); ASSUME(cr(2,0+1*1) >= cdl[2]); ASSUME(cr(2,0+1*1) >= cl[2]); // Update creg_r1 = cr(2,0+1*1); crmax(2,0+1*1) = max(crmax(2,0+1*1),cr(2,0+1*1)); caddr[2] = max(caddr[2],0); if(cr(2,0+1*1) < cw(2,0+1*1)) { r1 = buff(2,0+1*1); } else { if(pw(2,0+1*1) != co(0+1*1,cr(2,0+1*1))) { ASSUME(cr(2,0+1*1) >= old_cr); } pw(2,0+1*1) = co(0+1*1,cr(2,0+1*1)); r1 = mem(0+1*1,cr(2,0+1*1)); } ASSUME(creturn[2] >= cr(2,0+1*1)); // call void @llvm.dbg.value(metadata i64 %0, metadata !76, metadata !DIExpression()), !dbg !96 // %conv = trunc i64 %0 to i32, !dbg !66 // call void @llvm.dbg.value(metadata i32 %conv, metadata !73, metadata !DIExpression()), !dbg !91 // %tobool = icmp ne i32 %conv, 0, !dbg !67 // br i1 %tobool, label %if.then, label %if.else, !dbg !69 old_cctrl = cctrl[2]; cctrl[2] = get_rng(0,NCONTEXT-1); ASSUME(cctrl[2] >= old_cctrl); ASSUME(cctrl[2] >= creg_r1); ASSUME(cctrl[2] >= 0); if((r1!=0)) { goto T2BLOCK2; } else { goto T2BLOCK3; } T2BLOCK2: // br label %lbl_LC00, !dbg !70 goto T2BLOCK4; T2BLOCK3: // br label %lbl_LC00, !dbg !71 goto T2BLOCK4; T2BLOCK4: // call void @llvm.dbg.label(metadata !90), !dbg !104 // call void @llvm.dbg.value(metadata i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 2), metadata !78, metadata !DIExpression()), !dbg !105 // %1 = load atomic i64, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 2) monotonic, align 8, !dbg !74 // LD: Guess old_cr = cr(2,0+2*1); cr(2,0+2*1) = get_rng(0,NCONTEXT-1);// 2 ASSIGN LDCOM // Check ASSUME(active[cr(2,0+2*1)] == 2); ASSUME(cr(2,0+2*1) >= iw(2,0+2*1)); ASSUME(cr(2,0+2*1) >= 0); ASSUME(cr(2,0+2*1) >= cdy[2]); ASSUME(cr(2,0+2*1) >= cisb[2]); ASSUME(cr(2,0+2*1) >= cdl[2]); ASSUME(cr(2,0+2*1) >= cl[2]); // Update creg_r2 = cr(2,0+2*1); crmax(2,0+2*1) = max(crmax(2,0+2*1),cr(2,0+2*1)); caddr[2] = max(caddr[2],0); if(cr(2,0+2*1) < cw(2,0+2*1)) { r2 = buff(2,0+2*1); } else { if(pw(2,0+2*1) != co(0+2*1,cr(2,0+2*1))) { ASSUME(cr(2,0+2*1) >= old_cr); } pw(2,0+2*1) = co(0+2*1,cr(2,0+2*1)); r2 = mem(0+2*1,cr(2,0+2*1)); } ASSUME(creturn[2] >= cr(2,0+2*1)); // call void @llvm.dbg.value(metadata i64 %1, metadata !80, metadata !DIExpression()), !dbg !105 // %conv4 = trunc i64 %1 to i32, !dbg !75 // call void @llvm.dbg.value(metadata i32 %conv4, metadata !77, metadata !DIExpression()), !dbg !91 // call void @llvm.dbg.value(metadata i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 0), metadata !82, metadata !DIExpression()), !dbg !108 // %2 = load atomic i64, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 0) acquire, align 8, !dbg !77 // LD: Guess // : Acquire old_cr = cr(2,0); cr(2,0) = get_rng(0,NCONTEXT-1);// 2 ASSIGN LDCOM // Check ASSUME(active[cr(2,0)] == 2); ASSUME(cr(2,0) >= iw(2,0)); ASSUME(cr(2,0) >= 0); ASSUME(cr(2,0) >= cdy[2]); ASSUME(cr(2,0) >= cisb[2]); ASSUME(cr(2,0) >= cdl[2]); ASSUME(cr(2,0) >= cl[2]); ASSUME(cr(2,0) >= cx(2,0)); ASSUME(cr(2,0) >= cs(2,0+0)); ASSUME(cr(2,0) >= cs(2,0+1)); ASSUME(cr(2,0) >= cs(2,0+2)); ASSUME(cr(2,0) >= cs(2,3+0)); ASSUME(cr(2,0) >= cs(2,4+0)); ASSUME(cr(2,0) >= cs(2,5+0)); ASSUME(cr(2,0) >= cs(2,6+0)); // Update creg_r3 = cr(2,0); crmax(2,0) = max(crmax(2,0),cr(2,0)); caddr[2] = max(caddr[2],0); if(cr(2,0) < cw(2,0)) { r3 = buff(2,0); } else { if(pw(2,0) != co(0,cr(2,0))) { ASSUME(cr(2,0) >= old_cr); } pw(2,0) = co(0,cr(2,0)); r3 = mem(0,cr(2,0)); } cl[2] = max(cl[2],cr(2,0)); ASSUME(creturn[2] >= cr(2,0)); // call void @llvm.dbg.value(metadata i64 %2, metadata !84, metadata !DIExpression()), !dbg !108 // %conv8 = trunc i64 %2 to i32, !dbg !78 // call void @llvm.dbg.value(metadata i32 %conv8, metadata !81, metadata !DIExpression()), !dbg !91 // %cmp = icmp eq i32 %conv8, 0, !dbg !79 // %conv9 = zext i1 %cmp to i32, !dbg !79 // call void @llvm.dbg.value(metadata i32 %conv9, metadata !85, metadata !DIExpression()), !dbg !91 // call void @llvm.dbg.value(metadata i64* @atom_1_X6_0, metadata !86, metadata !DIExpression()), !dbg !112 // %3 = zext i32 %conv9 to i64 // call void @llvm.dbg.value(metadata i64 %3, metadata !88, metadata !DIExpression()), !dbg !112 // store atomic i64 %3, i64* @atom_1_X6_0 seq_cst, align 8, !dbg !81 // ST: Guess iw(2,4) = get_rng(0,NCONTEXT-1);// 2 ASSIGN STIW old_cw = cw(2,4); cw(2,4) = get_rng(0,NCONTEXT-1);// 2 ASSIGN STCOM // Check ASSUME(active[iw(2,4)] == 2); ASSUME(active[cw(2,4)] == 2); ASSUME(sforbid(4,cw(2,4))== 0); ASSUME(iw(2,4) >= max(creg_r3,0)); ASSUME(iw(2,4) >= 0); ASSUME(cw(2,4) >= iw(2,4)); ASSUME(cw(2,4) >= old_cw); ASSUME(cw(2,4) >= cr(2,4)); ASSUME(cw(2,4) >= cl[2]); ASSUME(cw(2,4) >= cisb[2]); ASSUME(cw(2,4) >= cdy[2]); ASSUME(cw(2,4) >= cdl[2]); ASSUME(cw(2,4) >= cds[2]); ASSUME(cw(2,4) >= cctrl[2]); ASSUME(cw(2,4) >= caddr[2]); // Update caddr[2] = max(caddr[2],0); buff(2,4) = (r3==0); mem(4,cw(2,4)) = (r3==0); co(4,cw(2,4))+=1; delta(4,cw(2,4)) = -1; ASSUME(creturn[2] >= cw(2,4)); // ret i8* null, !dbg !82 ret_thread_2 = (- 1); // Dumping thread 0 int ret_thread_0 = 0; cdy[0] = get_rng(0,NCONTEXT-1); ASSUME(cdy[0] >= cstart[0]); T0BLOCK0: // %thr0 = alloca i64, align 8 // %thr1 = alloca i64, align 8 // call void @llvm.dbg.value(metadata i32 %argc, metadata !122, metadata !DIExpression()), !dbg !159 // call void @llvm.dbg.value(metadata i8** %argv, metadata !123, metadata !DIExpression()), !dbg !159 // %0 = bitcast i64* %thr0 to i8*, !dbg !78 // call void @llvm.lifetime.start.p0i8(i64 8, i8* %0) #7, !dbg !78 // call void @llvm.dbg.declare(metadata i64* %thr0, metadata !124, metadata !DIExpression()), !dbg !161 // %1 = bitcast i64* %thr1 to i8*, !dbg !80 // call void @llvm.lifetime.start.p0i8(i64 8, i8* %1) #7, !dbg !80 // call void @llvm.dbg.declare(metadata i64* %thr1, metadata !128, metadata !DIExpression()), !dbg !163 // call void @llvm.dbg.value(metadata i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 2), metadata !129, metadata !DIExpression()), !dbg !164 // call void @llvm.dbg.value(metadata i64 0, metadata !131, metadata !DIExpression()), !dbg !164 // store atomic i64 0, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 2) monotonic, align 8, !dbg !83 // ST: Guess iw(0,0+2*1) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STIW old_cw = cw(0,0+2*1); cw(0,0+2*1) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STCOM // Check ASSUME(active[iw(0,0+2*1)] == 0); ASSUME(active[cw(0,0+2*1)] == 0); ASSUME(sforbid(0+2*1,cw(0,0+2*1))== 0); ASSUME(iw(0,0+2*1) >= 0); ASSUME(iw(0,0+2*1) >= 0); ASSUME(cw(0,0+2*1) >= iw(0,0+2*1)); ASSUME(cw(0,0+2*1) >= old_cw); ASSUME(cw(0,0+2*1) >= cr(0,0+2*1)); ASSUME(cw(0,0+2*1) >= cl[0]); ASSUME(cw(0,0+2*1) >= cisb[0]); ASSUME(cw(0,0+2*1) >= cdy[0]); ASSUME(cw(0,0+2*1) >= cdl[0]); ASSUME(cw(0,0+2*1) >= cds[0]); ASSUME(cw(0,0+2*1) >= cctrl[0]); ASSUME(cw(0,0+2*1) >= caddr[0]); // Update caddr[0] = max(caddr[0],0); buff(0,0+2*1) = 0; mem(0+2*1,cw(0,0+2*1)) = 0; co(0+2*1,cw(0,0+2*1))+=1; delta(0+2*1,cw(0,0+2*1)) = -1; ASSUME(creturn[0] >= cw(0,0+2*1)); // call void @llvm.dbg.value(metadata i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 1), metadata !132, metadata !DIExpression()), !dbg !166 // call void @llvm.dbg.value(metadata i64 0, metadata !134, metadata !DIExpression()), !dbg !166 // store atomic i64 0, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 1) monotonic, align 8, !dbg !85 // ST: Guess iw(0,0+1*1) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STIW old_cw = cw(0,0+1*1); cw(0,0+1*1) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STCOM // Check ASSUME(active[iw(0,0+1*1)] == 0); ASSUME(active[cw(0,0+1*1)] == 0); ASSUME(sforbid(0+1*1,cw(0,0+1*1))== 0); ASSUME(iw(0,0+1*1) >= 0); ASSUME(iw(0,0+1*1) >= 0); ASSUME(cw(0,0+1*1) >= iw(0,0+1*1)); ASSUME(cw(0,0+1*1) >= old_cw); ASSUME(cw(0,0+1*1) >= cr(0,0+1*1)); ASSUME(cw(0,0+1*1) >= cl[0]); ASSUME(cw(0,0+1*1) >= cisb[0]); ASSUME(cw(0,0+1*1) >= cdy[0]); ASSUME(cw(0,0+1*1) >= cdl[0]); ASSUME(cw(0,0+1*1) >= cds[0]); ASSUME(cw(0,0+1*1) >= cctrl[0]); ASSUME(cw(0,0+1*1) >= caddr[0]); // Update caddr[0] = max(caddr[0],0); buff(0,0+1*1) = 0; mem(0+1*1,cw(0,0+1*1)) = 0; co(0+1*1,cw(0,0+1*1))+=1; delta(0+1*1,cw(0,0+1*1)) = -1; ASSUME(creturn[0] >= cw(0,0+1*1)); // call void @llvm.dbg.value(metadata i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 0), metadata !135, metadata !DIExpression()), !dbg !168 // call void @llvm.dbg.value(metadata i64 0, metadata !137, metadata !DIExpression()), !dbg !168 // store atomic i64 0, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 0) monotonic, align 8, !dbg !87 // ST: Guess iw(0,0) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STIW old_cw = cw(0,0); cw(0,0) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STCOM // Check ASSUME(active[iw(0,0)] == 0); ASSUME(active[cw(0,0)] == 0); ASSUME(sforbid(0,cw(0,0))== 0); ASSUME(iw(0,0) >= 0); ASSUME(iw(0,0) >= 0); ASSUME(cw(0,0) >= iw(0,0)); ASSUME(cw(0,0) >= old_cw); ASSUME(cw(0,0) >= cr(0,0)); ASSUME(cw(0,0) >= cl[0]); ASSUME(cw(0,0) >= cisb[0]); ASSUME(cw(0,0) >= cdy[0]); ASSUME(cw(0,0) >= cdl[0]); ASSUME(cw(0,0) >= cds[0]); ASSUME(cw(0,0) >= cctrl[0]); ASSUME(cw(0,0) >= caddr[0]); // Update caddr[0] = max(caddr[0],0); buff(0,0) = 0; mem(0,cw(0,0)) = 0; co(0,cw(0,0))+=1; delta(0,cw(0,0)) = -1; ASSUME(creturn[0] >= cw(0,0)); // call void @llvm.dbg.value(metadata i64* @atom_0_X3_3, metadata !138, metadata !DIExpression()), !dbg !170 // call void @llvm.dbg.value(metadata i64 0, metadata !140, metadata !DIExpression()), !dbg !170 // store atomic i64 0, i64* @atom_0_X3_3 monotonic, align 8, !dbg !89 // ST: Guess iw(0,3) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STIW old_cw = cw(0,3); cw(0,3) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STCOM // Check ASSUME(active[iw(0,3)] == 0); ASSUME(active[cw(0,3)] == 0); ASSUME(sforbid(3,cw(0,3))== 0); ASSUME(iw(0,3) >= 0); ASSUME(iw(0,3) >= 0); ASSUME(cw(0,3) >= iw(0,3)); ASSUME(cw(0,3) >= old_cw); ASSUME(cw(0,3) >= cr(0,3)); ASSUME(cw(0,3) >= cl[0]); ASSUME(cw(0,3) >= cisb[0]); ASSUME(cw(0,3) >= cdy[0]); ASSUME(cw(0,3) >= cdl[0]); ASSUME(cw(0,3) >= cds[0]); ASSUME(cw(0,3) >= cctrl[0]); ASSUME(cw(0,3) >= caddr[0]); // Update caddr[0] = max(caddr[0],0); buff(0,3) = 0; mem(3,cw(0,3)) = 0; co(3,cw(0,3))+=1; delta(3,cw(0,3)) = -1; ASSUME(creturn[0] >= cw(0,3)); // call void @llvm.dbg.value(metadata i64* @atom_1_X6_0, metadata !141, metadata !DIExpression()), !dbg !172 // call void @llvm.dbg.value(metadata i64 0, metadata !143, metadata !DIExpression()), !dbg !172 // store atomic i64 0, i64* @atom_1_X6_0 monotonic, align 8, !dbg !91 // ST: Guess iw(0,4) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STIW old_cw = cw(0,4); cw(0,4) = get_rng(0,NCONTEXT-1);// 0 ASSIGN STCOM // Check ASSUME(active[iw(0,4)] == 0); ASSUME(active[cw(0,4)] == 0); ASSUME(sforbid(4,cw(0,4))== 0); ASSUME(iw(0,4) >= 0); ASSUME(iw(0,4) >= 0); ASSUME(cw(0,4) >= iw(0,4)); ASSUME(cw(0,4) >= old_cw); ASSUME(cw(0,4) >= cr(0,4)); ASSUME(cw(0,4) >= cl[0]); ASSUME(cw(0,4) >= cisb[0]); ASSUME(cw(0,4) >= cdy[0]); ASSUME(cw(0,4) >= cdl[0]); ASSUME(cw(0,4) >= cds[0]); ASSUME(cw(0,4) >= cctrl[0]); ASSUME(cw(0,4) >= caddr[0]); // Update caddr[0] = max(caddr[0],0); buff(0,4) = 0; mem(4,cw(0,4)) = 0; co(4,cw(0,4))+=1; delta(4,cw(0,4)) = -1; ASSUME(creturn[0] >= cw(0,4)); // %call = call i32 @pthread_create(i64* noundef %thr0, %union.pthread_attr_t* noundef null, i8* (i8*)* noundef @t0, i8* noundef null) #7, !dbg !92 // dumbsy: Guess old_cdy = cdy[0]; cdy[0] = get_rng(0,NCONTEXT-1); // Check ASSUME(cdy[0] >= old_cdy); ASSUME(cdy[0] >= cisb[0]); ASSUME(cdy[0] >= cdl[0]); ASSUME(cdy[0] >= cds[0]); ASSUME(cdy[0] >= cctrl[0]); ASSUME(cdy[0] >= cw(0,0+0)); ASSUME(cdy[0] >= cw(0,0+1)); ASSUME(cdy[0] >= cw(0,0+2)); ASSUME(cdy[0] >= cw(0,3+0)); ASSUME(cdy[0] >= cw(0,4+0)); ASSUME(cdy[0] >= cw(0,5+0)); ASSUME(cdy[0] >= cw(0,6+0)); ASSUME(cdy[0] >= cr(0,0+0)); ASSUME(cdy[0] >= cr(0,0+1)); ASSUME(cdy[0] >= cr(0,0+2)); ASSUME(cdy[0] >= cr(0,3+0)); ASSUME(cdy[0] >= cr(0,4+0)); ASSUME(cdy[0] >= cr(0,5+0)); ASSUME(cdy[0] >= cr(0,6+0)); ASSUME(creturn[0] >= cdy[0]); ASSUME(cstart[1] >= cdy[0]); // %call9 = call i32 @pthread_create(i64* noundef %thr1, %union.pthread_attr_t* noundef null, i8* (i8*)* noundef @t1, i8* noundef null) #7, !dbg !93 // dumbsy: Guess old_cdy = cdy[0]; cdy[0] = get_rng(0,NCONTEXT-1); // Check ASSUME(cdy[0] >= old_cdy); ASSUME(cdy[0] >= cisb[0]); ASSUME(cdy[0] >= cdl[0]); ASSUME(cdy[0] >= cds[0]); ASSUME(cdy[0] >= cctrl[0]); ASSUME(cdy[0] >= cw(0,0+0)); ASSUME(cdy[0] >= cw(0,0+1)); ASSUME(cdy[0] >= cw(0,0+2)); ASSUME(cdy[0] >= cw(0,3+0)); ASSUME(cdy[0] >= cw(0,4+0)); ASSUME(cdy[0] >= cw(0,5+0)); ASSUME(cdy[0] >= cw(0,6+0)); ASSUME(cdy[0] >= cr(0,0+0)); ASSUME(cdy[0] >= cr(0,0+1)); ASSUME(cdy[0] >= cr(0,0+2)); ASSUME(cdy[0] >= cr(0,3+0)); ASSUME(cdy[0] >= cr(0,4+0)); ASSUME(cdy[0] >= cr(0,5+0)); ASSUME(cdy[0] >= cr(0,6+0)); ASSUME(creturn[0] >= cdy[0]); ASSUME(cstart[2] >= cdy[0]); // %2 = load i64, i64* %thr0, align 8, !dbg !94, !tbaa !95 // LD: Guess old_cr = cr(0,5); cr(0,5) = get_rng(0,NCONTEXT-1);// 0 ASSIGN LDCOM // Check ASSUME(active[cr(0,5)] == 0); ASSUME(cr(0,5) >= iw(0,5)); ASSUME(cr(0,5) >= 0); ASSUME(cr(0,5) >= cdy[0]); ASSUME(cr(0,5) >= cisb[0]); ASSUME(cr(0,5) >= cdl[0]); ASSUME(cr(0,5) >= cl[0]); // Update creg_r5 = cr(0,5); crmax(0,5) = max(crmax(0,5),cr(0,5)); caddr[0] = max(caddr[0],0); if(cr(0,5) < cw(0,5)) { r5 = buff(0,5); } else { if(pw(0,5) != co(5,cr(0,5))) { ASSUME(cr(0,5) >= old_cr); } pw(0,5) = co(5,cr(0,5)); r5 = mem(5,cr(0,5)); } ASSUME(creturn[0] >= cr(0,5)); // %call10 = call i32 @pthread_join(i64 noundef %2, i8** noundef null), !dbg !99 // dumbsy: Guess old_cdy = cdy[0]; cdy[0] = get_rng(0,NCONTEXT-1); // Check ASSUME(cdy[0] >= old_cdy); ASSUME(cdy[0] >= cisb[0]); ASSUME(cdy[0] >= cdl[0]); ASSUME(cdy[0] >= cds[0]); ASSUME(cdy[0] >= cctrl[0]); ASSUME(cdy[0] >= cw(0,0+0)); ASSUME(cdy[0] >= cw(0,0+1)); ASSUME(cdy[0] >= cw(0,0+2)); ASSUME(cdy[0] >= cw(0,3+0)); ASSUME(cdy[0] >= cw(0,4+0)); ASSUME(cdy[0] >= cw(0,5+0)); ASSUME(cdy[0] >= cw(0,6+0)); ASSUME(cdy[0] >= cr(0,0+0)); ASSUME(cdy[0] >= cr(0,0+1)); ASSUME(cdy[0] >= cr(0,0+2)); ASSUME(cdy[0] >= cr(0,3+0)); ASSUME(cdy[0] >= cr(0,4+0)); ASSUME(cdy[0] >= cr(0,5+0)); ASSUME(cdy[0] >= cr(0,6+0)); ASSUME(creturn[0] >= cdy[0]); ASSUME(cdy[0] >= creturn[1]); // %3 = load i64, i64* %thr1, align 8, !dbg !100, !tbaa !95 // LD: Guess old_cr = cr(0,6); cr(0,6) = get_rng(0,NCONTEXT-1);// 0 ASSIGN LDCOM // Check ASSUME(active[cr(0,6)] == 0); ASSUME(cr(0,6) >= iw(0,6)); ASSUME(cr(0,6) >= 0); ASSUME(cr(0,6) >= cdy[0]); ASSUME(cr(0,6) >= cisb[0]); ASSUME(cr(0,6) >= cdl[0]); ASSUME(cr(0,6) >= cl[0]); // Update creg_r6 = cr(0,6); crmax(0,6) = max(crmax(0,6),cr(0,6)); caddr[0] = max(caddr[0],0); if(cr(0,6) < cw(0,6)) { r6 = buff(0,6); } else { if(pw(0,6) != co(6,cr(0,6))) { ASSUME(cr(0,6) >= old_cr); } pw(0,6) = co(6,cr(0,6)); r6 = mem(6,cr(0,6)); } ASSUME(creturn[0] >= cr(0,6)); // %call11 = call i32 @pthread_join(i64 noundef %3, i8** noundef null), !dbg !101 // dumbsy: Guess old_cdy = cdy[0]; cdy[0] = get_rng(0,NCONTEXT-1); // Check ASSUME(cdy[0] >= old_cdy); ASSUME(cdy[0] >= cisb[0]); ASSUME(cdy[0] >= cdl[0]); ASSUME(cdy[0] >= cds[0]); ASSUME(cdy[0] >= cctrl[0]); ASSUME(cdy[0] >= cw(0,0+0)); ASSUME(cdy[0] >= cw(0,0+1)); ASSUME(cdy[0] >= cw(0,0+2)); ASSUME(cdy[0] >= cw(0,3+0)); ASSUME(cdy[0] >= cw(0,4+0)); ASSUME(cdy[0] >= cw(0,5+0)); ASSUME(cdy[0] >= cw(0,6+0)); ASSUME(cdy[0] >= cr(0,0+0)); ASSUME(cdy[0] >= cr(0,0+1)); ASSUME(cdy[0] >= cr(0,0+2)); ASSUME(cdy[0] >= cr(0,3+0)); ASSUME(cdy[0] >= cr(0,4+0)); ASSUME(cdy[0] >= cr(0,5+0)); ASSUME(cdy[0] >= cr(0,6+0)); ASSUME(creturn[0] >= cdy[0]); ASSUME(cdy[0] >= creturn[2]); // call void @llvm.dbg.value(metadata i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 0), metadata !145, metadata !DIExpression()), !dbg !184 // %4 = load atomic i64, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @vars, i64 0, i64 0) seq_cst, align 8, !dbg !103 // LD: Guess old_cr = cr(0,0); cr(0,0) = get_rng(0,NCONTEXT-1);// 0 ASSIGN LDCOM // Check ASSUME(active[cr(0,0)] == 0); ASSUME(cr(0,0) >= iw(0,0)); ASSUME(cr(0,0) >= 0); ASSUME(cr(0,0) >= cdy[0]); ASSUME(cr(0,0) >= cisb[0]); ASSUME(cr(0,0) >= cdl[0]); ASSUME(cr(0,0) >= cl[0]); // Update creg_r7 = cr(0,0); crmax(0,0) = max(crmax(0,0),cr(0,0)); caddr[0] = max(caddr[0],0); if(cr(0,0) < cw(0,0)) { r7 = buff(0,0); } else { if(pw(0,0) != co(0,cr(0,0))) { ASSUME(cr(0,0) >= old_cr); } pw(0,0) = co(0,cr(0,0)); r7 = mem(0,cr(0,0)); } ASSUME(creturn[0] >= cr(0,0)); // call void @llvm.dbg.value(metadata i64 %4, metadata !147, metadata !DIExpression()), !dbg !184 // %conv = trunc i64 %4 to i32, !dbg !104 // call void @llvm.dbg.value(metadata i32 %conv, metadata !144, metadata !DIExpression()), !dbg !159 // %cmp = icmp eq i32 %conv, 3, !dbg !105 // %conv12 = zext i1 %cmp to i32, !dbg !105 // call void @llvm.dbg.value(metadata i32 %conv12, metadata !148, metadata !DIExpression()), !dbg !159 // call void @llvm.dbg.value(metadata i64* @atom_0_X3_3, metadata !150, metadata !DIExpression()), !dbg !188 // %5 = load atomic i64, i64* @atom_0_X3_3 seq_cst, align 8, !dbg !107 // LD: Guess old_cr = cr(0,3); cr(0,3) = get_rng(0,NCONTEXT-1);// 0 ASSIGN LDCOM // Check ASSUME(active[cr(0,3)] == 0); ASSUME(cr(0,3) >= iw(0,3)); ASSUME(cr(0,3) >= 0); ASSUME(cr(0,3) >= cdy[0]); ASSUME(cr(0,3) >= cisb[0]); ASSUME(cr(0,3) >= cdl[0]); ASSUME(cr(0,3) >= cl[0]); // Update creg_r8 = cr(0,3); crmax(0,3) = max(crmax(0,3),cr(0,3)); caddr[0] = max(caddr[0],0); if(cr(0,3) < cw(0,3)) { r8 = buff(0,3); } else { if(pw(0,3) != co(3,cr(0,3))) { ASSUME(cr(0,3) >= old_cr); } pw(0,3) = co(3,cr(0,3)); r8 = mem(3,cr(0,3)); } ASSUME(creturn[0] >= cr(0,3)); // call void @llvm.dbg.value(metadata i64 %5, metadata !152, metadata !DIExpression()), !dbg !188 // %conv16 = trunc i64 %5 to i32, !dbg !108 // call void @llvm.dbg.value(metadata i32 %conv16, metadata !149, metadata !DIExpression()), !dbg !159 // call void @llvm.dbg.value(metadata i64* @atom_1_X6_0, metadata !154, metadata !DIExpression()), !dbg !191 // %6 = load atomic i64, i64* @atom_1_X6_0 seq_cst, align 8, !dbg !110 // LD: Guess old_cr = cr(0,4); cr(0,4) = get_rng(0,NCONTEXT-1);// 0 ASSIGN LDCOM // Check ASSUME(active[cr(0,4)] == 0); ASSUME(cr(0,4) >= iw(0,4)); ASSUME(cr(0,4) >= 0); ASSUME(cr(0,4) >= cdy[0]); ASSUME(cr(0,4) >= cisb[0]); ASSUME(cr(0,4) >= cdl[0]); ASSUME(cr(0,4) >= cl[0]); // Update creg_r9 = cr(0,4); crmax(0,4) = max(crmax(0,4),cr(0,4)); caddr[0] = max(caddr[0],0); if(cr(0,4) < cw(0,4)) { r9 = buff(0,4); } else { if(pw(0,4) != co(4,cr(0,4))) { ASSUME(cr(0,4) >= old_cr); } pw(0,4) = co(4,cr(0,4)); r9 = mem(4,cr(0,4)); } ASSUME(creturn[0] >= cr(0,4)); // call void @llvm.dbg.value(metadata i64 %6, metadata !156, metadata !DIExpression()), !dbg !191 // %conv20 = trunc i64 %6 to i32, !dbg !111 // call void @llvm.dbg.value(metadata i32 %conv20, metadata !153, metadata !DIExpression()), !dbg !159 // %and = and i32 %conv16, %conv20, !dbg !112 creg_r10 = max(creg_r8,creg_r9); ASSUME(active[creg_r10] == 0); r10 = r8 & r9; // call void @llvm.dbg.value(metadata i32 %and, metadata !157, metadata !DIExpression()), !dbg !159 // %and21 = and i32 %conv12, %and, !dbg !113 creg_r11 = max(max(creg_r7,0),creg_r10); ASSUME(active[creg_r11] == 0); r11 = (r7==3) & r10; // call void @llvm.dbg.value(metadata i32 %and21, metadata !158, metadata !DIExpression()), !dbg !159 // %cmp22 = icmp eq i32 %and21, 1, !dbg !114 // br i1 %cmp22, label %if.then, label %if.end, !dbg !116 old_cctrl = cctrl[0]; cctrl[0] = get_rng(0,NCONTEXT-1); ASSUME(cctrl[0] >= old_cctrl); ASSUME(cctrl[0] >= creg_r11); ASSUME(cctrl[0] >= 0); if((r11==1)) { goto T0BLOCK1; } else { goto T0BLOCK2; } T0BLOCK1: // call void @__assert_fail(i8* noundef getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8* noundef getelementptr inbounds ([110 x i8], [110 x i8]* @.str.1, i64 0, i64 0), i32 noundef 63, i8* noundef getelementptr inbounds ([23 x i8], [23 x i8]* @__PRETTY_FUNCTION__.main, i64 0, i64 0)) #8, !dbg !117 // unreachable, !dbg !117 r12 = 1; T0BLOCK2: // %7 = bitcast i64* %thr1 to i8*, !dbg !120 // call void @llvm.lifetime.end.p0i8(i64 8, i8* %7) #7, !dbg !120 // %8 = bitcast i64* %thr0 to i8*, !dbg !120 // call void @llvm.lifetime.end.p0i8(i64 8, i8* %8) #7, !dbg !120 // ret i32 0, !dbg !121 ret_thread_0 = 0; ASSERT(r12== 0); }
[ "tuan-phong.ngo@it.uu.se" ]
tuan-phong.ngo@it.uu.se
4dd786f5d11b9ce2a3361f32da0b4565c7665c26
67e833a8a5562198971a0a6985528e7ee0e50839
/E131DMX/E131DMX.ino
6e4ddc9b23154696435b4365e5fcd1590c388d6d
[]
no_license
netmindz/arduino
df9aaa06f17809ceabd3963bf91450499ebbdd79
cd38e9ad891cc1fd425c579b49174e67f939052e
refs/heads/master
2023-05-11T19:52:40.209031
2023-04-21T20:00:32
2023-04-21T20:00:32
34,161,384
17
5
null
2022-04-03T22:45:30
2015-04-18T10:14:20
C++
UTF-8
C++
false
false
2,254
ino
#include <ESP8266WiFi.h> #include <ESPAsyncE131.h> #include <ESPDMX.h> #define UNIVERSE 1 // First DMX Universe to listen for #define UNIVERSE_COUNT 1 // Total number of Universes to listen for, starting at UNIVERSE #define CHANNELS 512 ESPAsyncE131 e131(UNIVERSE_COUNT); #include "wifi.h" const char ssid[] = SECRET_SSID; const char passphrase[] = SECRET_PSK; DMXESPSerial dmx; void setup() { Serial.begin(115200); // Make sure you're in station mode WiFi.mode(WIFI_STA); Serial.println(""); Serial.print(F("Connecting to ")); Serial.print(ssid); if (passphrase != NULL) WiFi.begin(ssid, passphrase); else WiFi.begin(ssid); Serial.print("Waiting on wifi "); while (WiFi.status() != WL_CONNECTED) { delay(500); Serial.print("w"); } Serial.println("\nDone"); Serial.print("IP address: "); Serial.println(WiFi.localIP()); delay(2000); // Choose one to begin listening for E1.31 data //if (e131.begin(E131_UNICAST)) { if (e131.begin(E131_MULTICAST, UNIVERSE, UNIVERSE_COUNT)) { // Listen via Multicast Serial.println(F("Listening for data...")); } else { Serial.println(F("*** e131.begin failed ***")); } dmx.init(CHANNELS); pinMode(LED_BUILTIN, OUTPUT); // Initialize the LED_BUILTIN pin as an output } int led = 0; void loop() { if (!e131.isEmpty()) { led = !led; digitalWrite(LED_BUILTIN, led); e131_packet_t packet; e131.pull(&packet); // Pull packet from ring buffer // EVERY_N_SECONDS( 2 ) { Serial.printf("Universe %u / %u Channels | Packet#: %u / Errors: %u / CH1: %u\n", htons(packet.universe), // The Universe for this packet htons(packet.property_value_count) - 1, // Start code is ignored, we're interested in dimmer data e131.stats.num_packets, // Packet counter e131.stats.packet_errors, // Packet error counter packet.property_values[1]); // Dimmer data for Channel 1 //} /* Parse a packet and update pixels */ for (int i = 1; i <= CHANNELS; i++) { int v = packet.property_values[i]; dmx.write(i, v); } dmx.update(); } }
[ "will@netmindz.net" ]
will@netmindz.net
70b9401687dfb9baf085d84c5593ea73f36a3913
a2fc06cf458f896d2217592ac92098863e755a9c
/src/program/online_learning/projector.cpp
79c89e5d821c96e79f5323879d347420181db793
[]
no_license
MrBrood/Stanford-Junior-self-driving-car
ba3f2a07a9366d3566def59fd25f90bad55748d2
d999e94bb287933666dac82129cad6702923a8e1
refs/heads/master
2023-07-18T04:56:02.055754
2020-08-21T01:31:46
2020-08-21T01:31:46
null
0
0
null
null
null
null
UTF-8
C++
false
false
3,065
cpp
#include "projector.h" using namespace std; using namespace Eigen; NameMapping2 Projector::generateNameMapping(const NameMapping& orig) const { ROS_ASSERT(orig.size() == projectors_.size()); NameMapping2 dmap; for(size_t i = 0; i < orig.size(); ++i) { for(size_t j = 0; j < projectors_[i].size(); ++j) { ostringstream oss; oss << orig.toName(i) << ":hashed_with_seed:" << seeds_[i][j]; dmap.addName(oss.str()); } } return dmap; } string Projector::status() const { ostringstream oss; for(size_t i = 0; i < projectors_.size(); ++i) { oss << "************************************************************" << endl; oss << "Projectors for dspace " << i << endl; for(size_t j = 0; j < projectors_[i].size(); ++j) { oss << projectors_[i][j].transpose() << endl; oss << endl; } } return oss.str(); } int Projector::getNumProjections() const { int num = 0; for(size_t i = 0; i < projectors_.size(); ++i) num += projectors_[i].size(); return num; } uint32_t Projector::getSeed() const { return seed_; } Projector::Projector(uint32_t seed, int projectors_per_dspace, const Object& obj) : seed_(seed) { std::tr1::mt19937 seed_generator(seed); projectors_.resize(obj.descriptors_.size()); seeds_.resize(projectors_.size()); for(size_t i = 0; i < obj.descriptors_.size(); ++i) { ROS_ASSERT(obj.descriptors_[i].vector); projectors_[i].resize(projectors_per_dspace); seeds_[i].resize(projectors_per_dspace); for(size_t j = 0; j < projectors_[i].size(); ++j) { seeds_[i][j] = seed_generator(); projectors_[i][j] = getProjector(seeds_[i][j], obj.descriptors_[i].vector->rows()); //cout << "New projector: " << projectors_[i][j].transpose() << endl; } } } VectorXf Projector::project(const Object& obj) const { VectorXf descriptors(getNumProjections()); int idx = 0; for(size_t i = 0; i < obj.descriptors_.size(); ++i) { ROS_ASSERT(obj.descriptors_[i].vector); for(size_t j = 0; j < projectors_[i].size(); ++j, ++idx) { // cout << obj.descriptors_[i].vector->rows() << " vs " << projectors_[i][j].rows() << endl; descriptors(idx) = obj.descriptors_[i].vector->cast<double>().dot(projectors_[i][j]); } } return descriptors; } double Projector::sampleFromGaussian(std::tr1::mt19937& mersenne_twister, double stdev) { double sum = 0; for(size_t i=0; i<12; ++i) { sum += 2. * stdev * (double)mersenne_twister() / (double)mersenne_twister.max() - stdev; } return sum / 2.; } VectorXd Projector::getProjector(uint32_t seed, int num_dim) { VectorXd projector = VectorXd::Zero(num_dim); // -- Each entry in the projector is drawn from the standard normal. // http://books.google.com/books?id=6Ewlh_lNo4sC&lpg=PP9&ots=JrJ9sqV0a5&dq=random%20projection&lr=&pg=PA2#v=twopage&q=&f=false std::tr1::mt19937 mersenne_twister(seed); for(int i = 0; i < projector.rows(); ++i) projector(i) = sampleFromGaussian(mersenne_twister, 1); projector.normalize(); return projector; }
[ "6959037@qq.com" ]
6959037@qq.com
893ebbb37d961f1d246259453cb1ba9b45f5ec89
1852beacad3561871d2a3df30a5f1114f1483389
/src/spacenav_ur.cpp
91e5f5b985b0d389c29c6caaf7fdab7dbd8c9d88
[ "BSD-3-Clause" ]
permissive
borongyuan/spacenav_ur
a46eb8dda4db22438b1bfa3e439a0e14e6b855b1
bba5c67689757f9e0b3ac4f3604d03ee4a68b661
refs/heads/master
2021-01-01T06:13:56.716162
2018-09-09T17:37:23
2018-09-09T17:37:23
143,623,912
1
0
null
null
null
null
UTF-8
C++
false
false
3,558
cpp
#include <ros/ros.h> #include <sensor_msgs/JointState.h> #include <trajectory_msgs/JointTrajectory.h> #include <kdl_conversions/kdl_msg.h> #include <kdl_parser/kdl_parser.hpp> #include <kdl/chainiksolvervel_wdls.hpp> class InverseDifferentialKinematics { public: InverseDifferentialKinematics(const ros::NodeHandle& nh, const KDL::Chain& chain): nh_(nh), iksolver(chain, 0.1, 30) { iksolver.setLambda(0.1); if (chain.getNrOfJoints() == 6) { Eigen::VectorXd weight_js(6); weight_js << 1, 1, 1, 0.2, 0.2, 0.2; iksolver.setWeightJS(weight_js.asDiagonal()); } joint_names = {"shoulder_pan_joint", "shoulder_lift_joint", "elbow_joint", "wrist_1_joint", "wrist_2_joint", "wrist_3_joint"}; if (joint_names.size() != chain.getNrOfJoints()) throw std::runtime_error("joint_names vector and kdl_chain have unequal lengths"); joint_pos.resize(chain.getNrOfJoints()); joint_vel.resize(chain.getNrOfJoints()); tj_msg.joint_names = joint_names; joint_sub = nh_.subscribe("joint_states", 10, &InverseDifferentialKinematics::jointCallback,this); twist_sub = nh_.subscribe("twist", 10, &InverseDifferentialKinematics::twistCallback,this); vel_pub = nh_.advertise<trajectory_msgs::JointTrajectory>("joint_speed", 1); } private: ros::NodeHandle nh_; ros::Subscriber joint_sub; ros::Subscriber twist_sub; ros::Publisher vel_pub; KDL::ChainIkSolverVel_wdls iksolver; std::vector<std::string> joint_names; KDL::JntArray joint_pos, joint_vel; KDL::Twist cart_vel; std::map<std::string, double> joint_state_map; trajectory_msgs::JointTrajectoryPoint tj_point; trajectory_msgs::JointTrajectory tj_msg; void jointCallback(const sensor_msgs::JointState::ConstPtr& joint); void twistCallback(const geometry_msgs::Twist::ConstPtr& twist); }; void InverseDifferentialKinematics::jointCallback(const sensor_msgs::JointState::ConstPtr& joint) { for (size_t i = 0; i < joint->name.size(); i++) joint_state_map[joint->name[i]] = joint->position[i]; for (size_t i = 0; i < joint_pos.rows(); i++) joint_pos(i) = joint_state_map[joint_names[i]]; } void InverseDifferentialKinematics::twistCallback(const geometry_msgs::Twist::ConstPtr& twist) { tf::twistMsgToKDL(*twist, cart_vel); if (iksolver.CartToJnt(joint_pos, cart_vel, joint_vel) == iksolver.E_SVD_FAILED) throw std::runtime_error("svd solution failed, error code: " + std::to_string(iksolver.getSVDResult())); tj_point.velocities = {joint_vel(0), joint_vel(1), joint_vel(2), joint_vel(3), joint_vel(4), joint_vel(5)}; tj_msg.points = {tj_point}; vel_pub.publish(tj_msg); } int main(int argc, char *argv[]) { ros::init(argc, argv, "spacenav_ur"); ros::NodeHandle nh("~"); try { KDL::Tree ur_tree; std::string robot_desc_string; nh.param("/robot_description", robot_desc_string, std::string()); if (!kdl_parser::treeFromString(robot_desc_string, ur_tree)) throw std::runtime_error("Failed to construct KDL tree from parameter server"); KDL::Chain ur_chain; if (!ur_tree.getChain("world", "ee_link", ur_chain)) throw std::runtime_error("Failed to get KDL chain from KDL tree"); InverseDifferentialKinematics ur_world_to_ee(nh, ur_chain); ros::spin(); } catch (const std::exception& e) { ROS_ERROR("%s", e.what()); } return 0; }
[ "yuanborong@hotmail.com" ]
yuanborong@hotmail.com
76ef1fc98fcd9fd3dcbdb34dbaf0a0ad55de3622
323788cf746237167c70f38117d3fbd26e92c041
/sandbox/thang/src/sgmm2bin/sgmm2-rescore-lattice.cc
4222906b2955ff3bd93e3797cf21dc7d84f9f558
[ "Apache-2.0", "LicenseRef-scancode-public-domain" ]
permissive
zweiein/kaldi
3cfc5d1fc66c1ca32c74f71171d4af2e2512f15c
708448c693272af0d68c8e178c7b4ff836125acf
refs/heads/master
2020-12-26T00:45:36.907011
2015-10-23T21:17:02
2015-10-23T21:17:02
46,313,562
0
1
null
2015-11-17T00:57:57
2015-11-17T00:57:57
null
UTF-8
C++
false
false
5,437
cc
// sgmm2bin/sgmm2-rescore-lattice.cc // Copyright 2009-2012 Saarland University (Author: Arnab Ghoshal) // Johns Hopkins University (Author: Daniel Povey) // Cisco Systems (Author: Neha Agrawal) // 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 // // THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY // KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED // WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, // MERCHANTABLITY OR NON-INFRINGEMENT. // See the Apache 2 License for the specific language governing permissions and // limitations under the License. #include "base/kaldi-common.h" #include "util/common-utils.h" #include "util/stl-utils.h" #include "sgmm2/am-sgmm.h" #include "hmm/transition-model.h" #include "fstext/fstext-lib.h" #include "lat/kaldi-lattice.h" #include "lat/lattice-functions.h" #include "decoder/decodable-am-sgmm2.h" int main(int argc, char *argv[]) { try { using namespace kaldi; typedef kaldi::int32 int32; typedef kaldi::int64 int64; using fst::SymbolTable; using fst::VectorFst; using fst::StdArc; const char *usage = "Replace the acoustic scores on a lattice using a new model.\n" "Usage: sgmm2-rescore-lattice [options] <model-in> <lattice-rspecifier> " "<feature-rspecifier> <lattice-wspecifier>\n" " e.g.: sgmm2-rescore-lattice 1.mdl ark:1.lats scp:trn.scp ark:2.lats\n"; kaldi::BaseFloat old_acoustic_scale = 0.0; BaseFloat log_prune = 5.0; std::string gselect_rspecifier, spkvecs_rspecifier, utt2spk_rspecifier; kaldi::ParseOptions po(usage); po.Register("old-acoustic-scale", &old_acoustic_scale, "Add the current acoustic scores with some scale."); po.Register("log-prune", &log_prune, "Pruning beam used to reduce number of exp() evaluations."); po.Register("spk-vecs", &spkvecs_rspecifier, "Speaker vectors (rspecifier)"); po.Register("utt2spk", &utt2spk_rspecifier, "rspecifier for utterance to speaker map"); po.Register("gselect", &gselect_rspecifier, "Precomputed Gaussian indices (rspecifier)"); po.Read(argc, argv); if (po.NumArgs() != 4) { po.PrintUsage(); exit(1); } if (gselect_rspecifier == "") KALDI_ERR << "--gselect-rspecifier option is required."; std::string model_filename = po.GetArg(1), lats_rspecifier = po.GetArg(2), feature_rspecifier = po.GetArg(3), lats_wspecifier = po.GetArg(4); AmSgmm2 am_sgmm; TransitionModel trans_model; { bool binary; Input ki(model_filename, &binary); trans_model.Read(ki.Stream(), binary); am_sgmm.Read(ki.Stream(), binary); } RandomAccessInt32VectorVectorReader gselect_reader(gselect_rspecifier); RandomAccessBaseFloatVectorReaderMapped spkvecs_reader(spkvecs_rspecifier, utt2spk_rspecifier); RandomAccessBaseFloatMatrixReader feature_reader(feature_rspecifier); // Read as compact lattice SequentialCompactLatticeReader compact_lattice_reader(lats_rspecifier); // Write as compact lattice. CompactLatticeWriter compact_lattice_writer(lats_wspecifier); int32 num_done = 0, num_err = 0; for (; !compact_lattice_reader.Done(); compact_lattice_reader.Next()) { std::string utt = compact_lattice_reader.Key(); if (!feature_reader.HasKey(utt)) { KALDI_WARN << "No feature found for utterance " << utt; num_err++; continue; } CompactLattice clat = compact_lattice_reader.Value(); compact_lattice_reader.FreeCurrent(); if (old_acoustic_scale != 1.0) fst::ScaleLattice(fst::AcousticLatticeScale(old_acoustic_scale), &clat); const Matrix<BaseFloat> &feats = feature_reader.Value(utt); // Get speaker vectors Sgmm2PerSpkDerivedVars spk_vars; if (spkvecs_reader.IsOpen()) { if (spkvecs_reader.HasKey(utt)) { spk_vars.SetSpeakerVector(spkvecs_reader.Value(utt)); am_sgmm.ComputePerSpkDerivedVars(&spk_vars); } else { KALDI_WARN << "Cannot find speaker vector for " << utt; num_err++; continue; } } // else spk_vars is "empty" if (!gselect_reader.HasKey(utt) || gselect_reader.Value(utt).size() != feats.NumRows()) { KALDI_WARN << "No Gaussian-selection info available for utterance " << utt << " (or wrong size)"; num_err++; continue; } const std::vector<std::vector<int32> > &gselect = gselect_reader.Value(utt); DecodableAmSgmm2 sgmm2_decodable(am_sgmm, trans_model, feats, gselect, log_prune, &spk_vars); if (kaldi::RescoreCompactLattice(&sgmm2_decodable, &clat)) { compact_lattice_writer.Write(utt, clat); num_done++; } else num_err++; } KALDI_LOG << "Done " << num_done << " lattices, errors on " << num_err; return (num_done != 0 ? 0 : 1); } catch(const std::exception &e) { std::cerr << e.what(); return -1; } }
[ "danielpovey@5e6a8d80-dfce-4ca6-a32a-6e07a63d50c8" ]
danielpovey@5e6a8d80-dfce-4ca6-a32a-6e07a63d50c8
8b26653e04e3ebad49b9559414fe816d41b898e0
f6ad1c5e9736c548ee8d41a7aca36b28888db74a
/cf/1097/G.cpp
8881cb9576cd62a11259d3a17932a6edf731903d
[]
no_license
cnyali-czy/code
7fabf17711e1579969442888efe3af6fedf55469
a86661dce437276979e8c83d8c97fb72579459dd
refs/heads/master
2021-07-22T18:59:15.270296
2021-07-14T08:01:13
2021-07-14T08:01:13
122,709,732
0
3
null
null
null
null
UTF-8
C++
false
false
2,022
cpp
/* Problem: G.cpp Time: 2021-01-27 21:32 Author: CraZYali E-Mail: yms-chenziyang@outlook.com */ #define REP(i, s, e) for (register int i(s), end_##i(e); i <= end_##i; i++) #define DEP(i, s, e) for (register int i(s), end_##i(e); i >= end_##i; i--) #define DEBUG fprintf(stderr, "Passing [%s] in Line %d\n", __FUNCTION__, __LINE__) #define chkmax(a, b) (a < (b) ? a = (b) : a) #define chkmin(a, b) (a > (b) ? a = (b) : a) #include <vector> #include <iostream> #include <cstdio> #define i64 long long using namespace std; const int maxn = 1e5 + 10, maxk = 200 + 5, MOD = 1e9 + 7; template <typename T> inline T read() { T ans = 0, flag = 1; char c = getchar(); while (!isdigit(c)) { if (c == '-') flag = -1; c = getchar(); } while (isdigit(c)) { ans = ans * 10 + (c - 48); c = getchar(); } return ans * flag; } #define file(FILE_NAME) freopen(FILE_NAME".in", "r", stdin), freopen(FILE_NAME".out", "w", stdout) int n, k, f[maxn][maxk], ans[maxk]; int fac[maxk], str[maxk][maxk]; void init() { fac[0] = 1; REP(i, 1, k) fac[i] = 1ll * i * fac[i - 1] % MOD; str[0][0] = 1; REP(i, 1, k) REP(j, 1, i) str[i][j] = (str[i - 1][j - 1] + 1ll * j * str[i - 1][j]) % MOD; } vector <int> G[maxn]; int siz[maxn]; void dfs(int u, int fa = 0) { siz[u] = 1; f[u][0] = 2; for (int v : G[u]) if (v ^ fa) { dfs(v, u); static int tmp[maxk]; REP(i, 0, min(siz[u], k)) REP(j, 0, min(k - i, siz[v])) tmp[i + j] = (tmp[i + j] + 1ll * f[u][i] * f[v][j]) % MOD; REP(i, 0, k) f[u][i] = tmp[i], tmp[i] = 0, (ans[i] -= f[v][i]) %= MOD; siz[u] += siz[v]; } REP(i, 0, k) (ans[i] += f[u][i]) %= MOD; DEP(i, k, 1) (f[u][i] += f[u][i - 1]) %= MOD; f[u][1]--; } int main() { #ifdef CraZYali file("G"); #endif n = read<int>();k = read<int>(); init(); REP(i, 2, n) { int x = read<int>(), y = read<int>(); G[x].emplace_back(y);G[y].emplace_back(x); } dfs(1); i64 Ans = 0; REP(i, 0, k) (Ans += 1ll * fac[i] * str[k][i] % MOD * ans[i]) %= MOD; cout << (Ans + MOD) % MOD << endl; return 0; }
[ "yms-chenziyang@outlook.com" ]
yms-chenziyang@outlook.com
2018b152d322ebe3f9d2c143e5061134b9b5ab51
56b43407194d038d7842279c7f4e8b5f2ebdd9e9
/json_translator.cpp
0da760f3af048ad5fac9d59b1adbb3c6e1074773
[ "MIT" ]
permissive
jcavalieri8619/XML2JSON
c7b776f50a7cde1f7c994979409318dff1b5647a
286e7629a20129aaf7064ae25e51a3f2f374f342
refs/heads/master
2020-05-29T14:41:36.247395
2016-05-29T23:56:31
2016-05-29T23:56:31
59,871,741
1
0
null
null
null
null
UTF-8
C++
false
false
14,105
cpp
/* * File: json_translator.cpp * Author: John Cavalieri * * Created on November 7, 2013, 10:41 PM */ #include "json_translator.hpp" #include <utility> #include <vector> #include <sstream> using namespace std; //index to state tuples #define ENTITY 0 #define DEPTH 1 #define NAME 2 #define INDENTLEVEL 3 // index to node Queue #define CURRENT 0 #define NEXT 1 static const std::string delimiters[] = { "{", "}", "[", "]", "," }; XMLTree_JSON::XMLTree_JSON( const std::string fileName ): indentSize( 0 ), fileOutput( fileName.data( ) ), THIS_Translator( this ) { if ( !fileOutput ) throw "Error Opening output file"; } XMLTree_JSON::~XMLTree_JSON( ) { delete THIS_Translator; } bool XMLTree_JSON::isClosing( const Tree_node* whatNode, bool prior )const { return isClosingArray( whatNode, prior ) || isClosingObject( whatNode, prior ); } STATUS XMLTree_JSON::initializeTranslator( Tree_node * tree, XMLTree_JSON* * object ) { static XMLTree_JSON* self = new XMLTree_JSON; static bool initialized = false; //first call to initializeTranslator will construct XMLTree_JSON //object in the heap and pass back a pointer to it through //the *object parameter if ( ! initialized ){ initialized = true; *object = self; return OK; //if initialized and called in the appropriate manner //then populate queue- passing to XMLtree traverse //will always be called in appropriate manner. } else if ( tree && !object ){ self->pushNode( tree ); return OK; //if not called in the appropriate manner then ERROR } else return ERROR; } STATUS XMLTree_JSON::translator( ) { //if XML tree is empty then translator is finished if ( NodeQueueEmpty( ) ) return OK; bool rootProcessed = false; stringstream lineContainer( ios_base::out | ios_base::ate ); while ( !NodeQueueEmpty( ) ){ //these variables need to be reinitialized //on every loop of translation process string nodeName; size_t nodeDepth = 0; size_t currIndent = 0; vector<pair<string, string> > nodalKeyVals; if ( isClosing( getQueuedNode( CURRENT ) ) ){ //loops begins by checking if the current node //closes the most nested entity (object or array); //if so then it is closed. If current //node closes multiple entities then each will be //closed before the node is further processed. generateOutput( lineContainer, Closing, vector<pair<string, string> >( ) ); popState( ); continue; } else if ( isOpeningArray( ) && ( state_extractName( getCurrentState( ) ) != getQueuedNode( CURRENT )->getElementName( ) ) ){ //determines in current node opens an array; //if so the appropriate output is generated. //the current node is not popped off front of queue //yet though because the node still has to be processed. //This is why gatherNodalData is not called within this //block gatherStateData( nodeDepth, nodeName, currIndent ); pushState( ARRAY, nodeDepth, nodeName, currIndent ); generateOutput( lineContainer, ArrayOpening, vector<pair<string, string> >( ) ); continue; } else if ( isOpeningObject( ) ){ gatherStateData( nodeDepth, nodeName, currIndent ); pushState( OBJECT, nodeDepth, nodeName, currIndent ); gatherNodalData( nodalKeyVals ); generateOutput( lineContainer, ( rootProcessed ? Opening : ( rootProcessed = true, RootOpening ) ), nodalKeyVals ); popFrontNode( ); continue; } else{ //must be a key value pair == complete element gatherNodalData( nodalKeyVals ); generateOutput( lineContainer, KeyVal, nodalKeyVals ); popFrontNode( ); continue; } } //unwind state stack by closing each remaining entity while ( !StateStackEmpty( ) ){ generateOutput( lineContainer, Closing, vector<pair<string, string> >( ) ); popState( ); } return OK; } std::size_t XMLTree_JSON::StateStackSize( )const { return StateStack.size( ); } bool XMLTree_JSON::StateStackEmpty( )const { return StateStack.empty( ); } std::size_t XMLTree_JSON::NodeQueueSize( )const { return NodeQueue.size( ); } bool XMLTree_JSON::NodeQueueEmpty( )const { return NodeQueue.empty( ); } void XMLTree_JSON::pushNode( const Tree_node * node ) { NodeQueue.push_back( node ); } void XMLTree_JSON::popFrontNode( ) { NodeQueue.pop_front( ); } void XMLTree_JSON::gatherStateData( std::size_t& depth, std::string& name, std::size_t & indentLevel )const { depth = getQueuedNode( CURRENT )->getElementDepth( ); name = getQueuedNode( CURRENT )->getElementName( ); indentLevel = getIndentSize( ); } bool XMLTree_JSON::isOpeningObject( )const { return countObjectChildren( ) > 0; } bool XMLTree_JSON::isOpeningArray( )const { size_t depth_ = getQueuedNode( CURRENT )->getElementDepth( ); string name_ = getQueuedNode( CURRENT )->getElementName( ); for ( const auto & nodeItr : NodeQueue ){ if ( nodeItr != getQueuedNode( CURRENT ) ){ if ( nodeItr->getElementDepth( ) < depth_ ) return false; if ( ( nodeItr->getElementDepth( ) == depth_ ) && ( nodeItr->getElementName( ) == name_ ) ) return true; } } return false; } std::tuple<ValueEntity, std::size_t, std::string, std::size_t> XMLTree_JSON::getCurrentState( )const { return StateStack.back( ); } std::tuple<ValueEntity, std::size_t, std::string, std::size_t> XMLTree_JSON::getPriorState( )const { auto rItr = StateStack.rbegin( ); return *( ++rItr ); } ValueEntity XMLTree_JSON::state_extractEntity( std::tuple<ValueEntity, std::size_t, std::string, std::size_t> state )const { return get<ENTITY>( state ); } std::size_t XMLTree_JSON::state_extractDepth( std::tuple<ValueEntity, std::size_t, std::string, std::size_t> state )const { return get<DEPTH>( state ); } std::size_t XMLTree_JSON::state_extractIndentLevel( std::tuple<ValueEntity, std::size_t, std::string, std::size_t> state )const { return get<INDENTLEVEL>( state ); } std::string XMLTree_JSON::state_extractName( std::tuple<ValueEntity, std::size_t, std::string, std::size_t> state )const { return get<NAME>( state ); } void XMLTree_JSON::pushState( ValueEntity value, std::size_t depth, std::string name, std::size_t indentLevel ) { StateStack.push_back( make_tuple( value, depth, name, indentLevel ) ); } void XMLTree_JSON::popState( ) { StateStack.pop_back( ); } bool XMLTree_JSON::isKeyValuePair( )const { return countObjectChildren( ) == 0; } bool XMLTree_JSON::isClosingArray( const Tree_node * whatNode, bool prior )const { if ( !StateStackEmpty( ) ){ if ( state_extractEntity( prior ? getPriorState( ) : getCurrentState( ) ) == ARRAY ){ if ( whatNode->getElementDepth( ) < ( state_extractDepth( prior ? getPriorState( ) : getCurrentState( ) ) ) ){ return true; } else if ( ( state_extractDepth( ( prior ? getPriorState( ) : getCurrentState( ) ) ) == whatNode->getElementDepth( ) ) ){ if ( state_extractName( ( prior ? getPriorState( ) : getCurrentState( ) ) ) != whatNode->getElementName( ) ){ return true; } } } } return false; } bool XMLTree_JSON::isClosingObject( const Tree_node * whatNode, bool prior )const { if ( !StateStackEmpty( ) ){ if ( state_extractEntity( ( prior ? getPriorState( ) : getCurrentState( ) ) ) == OBJECT ){ if ( ( whatNode->getElementDepth( ) ) <= state_extractDepth( ( prior ? getPriorState( ) : getCurrentState( ) ) ) ) return true; } } return false; } bool XMLTree_JSON::isClosingCommaNeeded( )const { if ( NodeQueueEmpty( ) ) return false; //if isClosing( CurrNode, priorState) --> current delimiter NO COMMA else return !isClosing( getQueuedNode( CURRENT ), true ); } bool XMLTree_JSON::isCommaNeeded( )const { //if isClosing(next) then last nodal pair of current node-->NO COMMA if ( NodeQueueSize( ) == 1 ) return false; return !isClosing( getQueuedNode( NEXT ) ); } void XMLTree_JSON::insertDelimiter( std::stringstream& formJSONLine, delimiterType delimiter )const { formJSONLine << delimiters[delimiter]; } void XMLTree_JSON::insertComma( std::stringstream & formJSONLine )const { formJSONLine << delimiters[COMMA]; } const static string QUOTE( "\"" ); void XMLTree_JSON::insertKeyValuePair( std::stringstream& formJSONLine, std::string key, std::string val )const { formJSONLine << QUOTE + key + QUOTE << " : "; if ( ( val.size( ) == 0 ) || ( val.find( QUOTE ) != string::npos ) ) formJSONLine << val; else formJSONLine << QUOTE + val + QUOTE; } std::size_t XMLTree_JSON::getCurrentNodeDepth( )const { return getQueuedNode( CURRENT )->getElementDepth( ); } std::size_t XMLTree_JSON::getIndentSize( )const { return indentSize; } void XMLTree_JSON::setIndentSize( std::size_t size ) { indentSize = size; } STATUS XMLTree_JSON::writeJSONLine( std::stringstream & JSONLine ) { string currString = JSONLine.str( ); size_t length = currString.length( ); //setfill used to prepend indent onto output string //where indent size is equal to size of the string plus //the indent size --> this ensures setfill will kick //in because the min width will always be greater than //string length fileOutput << setfill( ' ' ) << setw( length + getIndentSize( ) ) << right << currString << endl; if ( ! fileOutput ) return ERROR; //resets string stream for next output JSONLine.clear( ); JSONLine.str( string( "" ) ); return OK; } const Tree_node * XMLTree_JSON::getQueuedNode( std::size_t whatNodeIndex )const { return NodeQueue[whatNodeIndex]; } std::size_t XMLTree_JSON::countObjectChildren( )const { return getQueuedNode( CURRENT )->getNumAttributes( ) + getQueuedNode( CURRENT )->getNumChildren( ) ; } //indent changes size by 2 to emphasize hierarchy void XMLTree_JSON::incrementIndent( ) { indentSize += 2; } //after gathering nodal data, build line looping through //nodal pairs vector. build line will build line using //key and value parameters and type. If opening type //then no need to check for comma. If closing type //then key and value will be empty strings. If opening //then value will be empty. After building call insert indent //so that line size can be used to determine indent void XMLTree_JSON::generateOutput( std::stringstream& formJSONLine, lineType type, const std::vector<std::pair<std::string, std::string> > & nodalPairs ) { const Tree_node * CurrNode = getQueuedNode( CURRENT ); switch ( type ) { case Opening: { //print "name : " if state top is not ARRAY //if ARRAY then just print opening delimiter //after printing each "{ " opening delimiter //increment indentSize member. if ( StateStackSize( ) > 2 && state_extractEntity( getPriorState( ) ) == ARRAY ){ insertDelimiter( formJSONLine, OpenObject ); writeJSONLine( formJSONLine ); } else{ insertKeyValuePair( formJSONLine, CurrNode->getElementName( ) ); writeJSONLine( formJSONLine ); insertDelimiter( formJSONLine, OpenObject ); writeJSONLine( formJSONLine ); } incrementIndent( ); //prints any content and attributes associated with the node for ( auto keyValItr = nodalPairs.begin( ); keyValItr != nodalPairs.end( ); ++keyValItr ){ insertKeyValuePair( formJSONLine, keyValItr->first, keyValItr->second ); if ( ( keyValItr + 1 == nodalPairs.end( ) ) ){ if ( ! isCommaNeeded( ) ){ writeJSONLine( formJSONLine ); break; } } insertComma( formJSONLine ); writeJSONLine( formJSONLine ); } break; } case KeyVal: { insertKeyValuePair( formJSONLine, nodalPairs.front( ).first, nodalPairs.front( ).second ); if ( isCommaNeeded( ) ) insertComma( formJSONLine ); writeJSONLine( formJSONLine ); break; } case Closing: //each closing "} " delimiter is printed at //state_extractIndent(getCurrState()) then //indentSize is set equal extracted indent //to determine if comma needed, check if //next node is NOT closing - if true add comma //else no comma needed setIndentSize( state_extractIndentLevel( getCurrentState( ) ) ); insertDelimiter( formJSONLine, ( state_extractEntity( getCurrentState( ) ) == ARRAY ? CloseArray : CloseObject ) ); //top state is about to be popped so comma needed //if the current node is going to close the next //highest state on state stack if ( isClosingCommaNeeded( ) ) insertComma( formJSONLine ); writeJSONLine( formJSONLine ); break; case ArrayOpening: //print opening "name : " and "[ " insertKeyValuePair( formJSONLine, CurrNode->getElementName( ) ); writeJSONLine( formJSONLine ); insertDelimiter( formJSONLine, OpenArray ); writeJSONLine( formJSONLine ); incrementIndent( ); break; case RootOpening: // only print "{ " at indentSize insertDelimiter( formJSONLine, OpenObject ); writeJSONLine( formJSONLine ); incrementIndent( ); break; default: throw "generate output default case tripped" ; } } void XMLTree_JSON::gatherNodalData( std::vector<std::pair<std::string, std::string> >& nodalPairs ) { const Tree_node * currNode = getQueuedNode( CURRENT ); string content; content = currNode->getElementContent( ) ; if ( countObjectChildren( ) == 0 ){ nodalPairs.push_back( make_pair( currNode->getElementName( ), content ) ); } else{ if ( content.size( ) > 0 ) nodalPairs.push_back( make_pair( "content", content ) ); for ( const auto & Attributes : *( currNode->getPtrAttributes( ) ) ){ nodalPairs.push_back( make_pair( Attributes.first, Attributes.second ) ); } } }
[ "jcavalieri8619@gmail.com" ]
jcavalieri8619@gmail.com
126c0493f5e61ca35c31476e33a37d29c2417140
8578ae5be776b49559fa95ce30f6b45b6a82b73a
/src/test/blockencodings_tests.cpp
3f7def9ad880ffe8122d38790797b53a819d57ac
[ "MIT" ]
permissive
devcoin/core
3f9f177bd9d5d2cc54ff95a981cfe88671206ae2
f67e8b058b4316dd491615dc3f8799a45f396f4a
refs/heads/master
2023-05-25T03:42:03.998451
2023-05-24T07:59:22
2023-05-24T08:02:14
21,529,485
16
13
MIT
2022-01-07T17:04:18
2014-07-05T22:42:13
C
UTF-8
C++
false
false
14,228
cpp
// Copyright (c) 2011-2020 The Bitcoin Core and Devcoin Core developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #include <blockencodings.h> #include <chainparams.h> #include <consensus/merkle.h> #include <pow.h> #include <streams.h> #include <test/util/setup_common.h> #include <boost/test/unit_test.hpp> std::vector<std::pair<uint256, CTransactionRef>> extra_txn; BOOST_FIXTURE_TEST_SUITE(blockencodings_tests, RegTestingSetup) static CBlock BuildBlockTestCase() { CBlock block; CMutableTransaction tx; tx.vin.resize(1); tx.vin[0].scriptSig.resize(10); tx.vout.resize(1); tx.vout[0].nValue = 42; block.vtx.resize(3); block.vtx[0] = MakeTransactionRef(tx); block.nVersion = 42; block.hashPrevBlock = InsecureRand256(); block.nBits = 0x207fffff; tx.vin[0].prevout.hash = InsecureRand256(); tx.vin[0].prevout.n = 0; block.vtx[1] = MakeTransactionRef(tx); tx.vin.resize(10); for (size_t i = 0; i < tx.vin.size(); i++) { tx.vin[i].prevout.hash = InsecureRand256(); tx.vin[i].prevout.n = 0; } block.vtx[2] = MakeTransactionRef(tx); bool mutated; block.hashMerkleRoot = BlockMerkleRoot(block, &mutated); assert(!mutated); while (!CheckProofOfWork(block.GetHash(), block.nBits, Params().GetConsensus())) ++block.nNonce; return block; } // Number of shared use_counts we expect for a tx we haven't touched // (block + mempool + our copy from the GetSharedTx call) constexpr long SHARED_TX_OFFSET{3}; BOOST_AUTO_TEST_CASE(SimpleRoundTripTest) { CTxMemPool pool; TestMemPoolEntryHelper entry; CBlock block(BuildBlockTestCase()); LOCK2(cs_main, pool.cs); pool.addUnchecked(entry.FromTx(block.vtx[2])); BOOST_CHECK_EQUAL(pool.mapTx.find(block.vtx[2]->GetHash())->GetSharedTx().use_count(), SHARED_TX_OFFSET + 0); // Do a simple ShortTxIDs RT { CBlockHeaderAndShortTxIDs shortIDs(block, true); CDataStream stream(SER_NETWORK, PROTOCOL_VERSION); stream << shortIDs; CBlockHeaderAndShortTxIDs shortIDs2; stream >> shortIDs2; PartiallyDownloadedBlock partialBlock(&pool); BOOST_CHECK(partialBlock.InitData(shortIDs2, extra_txn) == READ_STATUS_OK); BOOST_CHECK( partialBlock.IsTxAvailable(0)); BOOST_CHECK(!partialBlock.IsTxAvailable(1)); BOOST_CHECK( partialBlock.IsTxAvailable(2)); BOOST_CHECK_EQUAL(pool.mapTx.find(block.vtx[2]->GetHash())->GetSharedTx().use_count(), SHARED_TX_OFFSET + 1); size_t poolSize = pool.size(); pool.removeRecursive(*block.vtx[2], MemPoolRemovalReason::REPLACED); BOOST_CHECK_EQUAL(pool.size(), poolSize - 1); CBlock block2; { PartiallyDownloadedBlock tmp = partialBlock; BOOST_CHECK(partialBlock.FillBlock(block2, {}) == READ_STATUS_INVALID); // No transactions partialBlock = tmp; } // Wrong transaction { PartiallyDownloadedBlock tmp = partialBlock; partialBlock.FillBlock(block2, {block.vtx[2]}); // Current implementation doesn't check txn here, but don't require that partialBlock = tmp; } bool mutated; BOOST_CHECK(block.hashMerkleRoot != BlockMerkleRoot(block2, &mutated)); CBlock block3; BOOST_CHECK(partialBlock.FillBlock(block3, {block.vtx[1]}) == READ_STATUS_OK); BOOST_CHECK_EQUAL(block.GetHash().ToString(), block3.GetHash().ToString()); BOOST_CHECK_EQUAL(block.hashMerkleRoot.ToString(), BlockMerkleRoot(block3, &mutated).ToString()); BOOST_CHECK(!mutated); } } class TestHeaderAndShortIDs { // Utility to encode custom CBlockHeaderAndShortTxIDs public: CBlockHeader header; uint64_t nonce; std::vector<uint64_t> shorttxids; std::vector<PrefilledTransaction> prefilledtxn; explicit TestHeaderAndShortIDs(const CBlockHeaderAndShortTxIDs& orig) { CDataStream stream(SER_NETWORK, PROTOCOL_VERSION); stream << orig; stream >> *this; } explicit TestHeaderAndShortIDs(const CBlock& block) : TestHeaderAndShortIDs(CBlockHeaderAndShortTxIDs(block, true)) {} uint64_t GetShortID(const uint256& txhash) const { CDataStream stream(SER_NETWORK, PROTOCOL_VERSION); stream << *this; CBlockHeaderAndShortTxIDs base; stream >> base; return base.GetShortID(txhash); } SERIALIZE_METHODS(TestHeaderAndShortIDs, obj) { READWRITE(obj.header, obj.nonce, Using<VectorFormatter<CustomUintFormatter<CBlockHeaderAndShortTxIDs::SHORTTXIDS_LENGTH>>>(obj.shorttxids), obj.prefilledtxn); } }; BOOST_AUTO_TEST_CASE(NonCoinbasePreforwardRTTest) { CTxMemPool pool; TestMemPoolEntryHelper entry; CBlock block(BuildBlockTestCase()); LOCK2(cs_main, pool.cs); pool.addUnchecked(entry.FromTx(block.vtx[2])); BOOST_CHECK_EQUAL(pool.mapTx.find(block.vtx[2]->GetHash())->GetSharedTx().use_count(), SHARED_TX_OFFSET + 0); uint256 txhash; // Test with pre-forwarding tx 1, but not coinbase { TestHeaderAndShortIDs shortIDs(block); shortIDs.prefilledtxn.resize(1); shortIDs.prefilledtxn[0] = {1, block.vtx[1]}; shortIDs.shorttxids.resize(2); shortIDs.shorttxids[0] = shortIDs.GetShortID(block.vtx[0]->GetHash()); shortIDs.shorttxids[1] = shortIDs.GetShortID(block.vtx[2]->GetHash()); CDataStream stream(SER_NETWORK, PROTOCOL_VERSION); stream << shortIDs; CBlockHeaderAndShortTxIDs shortIDs2; stream >> shortIDs2; PartiallyDownloadedBlock partialBlock(&pool); BOOST_CHECK(partialBlock.InitData(shortIDs2, extra_txn) == READ_STATUS_OK); BOOST_CHECK(!partialBlock.IsTxAvailable(0)); BOOST_CHECK( partialBlock.IsTxAvailable(1)); BOOST_CHECK( partialBlock.IsTxAvailable(2)); BOOST_CHECK_EQUAL(pool.mapTx.find(block.vtx[2]->GetHash())->GetSharedTx().use_count(), SHARED_TX_OFFSET + 1); // +1 because of partialBlock CBlock block2; { PartiallyDownloadedBlock tmp = partialBlock; BOOST_CHECK(partialBlock.FillBlock(block2, {}) == READ_STATUS_INVALID); // No transactions partialBlock = tmp; } // Wrong transaction { PartiallyDownloadedBlock tmp = partialBlock; partialBlock.FillBlock(block2, {block.vtx[1]}); // Current implementation doesn't check txn here, but don't require that partialBlock = tmp; } BOOST_CHECK_EQUAL(pool.mapTx.find(block.vtx[2]->GetHash())->GetSharedTx().use_count(), SHARED_TX_OFFSET + 2); // +2 because of partialBlock and block2 bool mutated; BOOST_CHECK(block.hashMerkleRoot != BlockMerkleRoot(block2, &mutated)); CBlock block3; PartiallyDownloadedBlock partialBlockCopy = partialBlock; BOOST_CHECK(partialBlock.FillBlock(block3, {block.vtx[0]}) == READ_STATUS_OK); BOOST_CHECK_EQUAL(block.GetHash().ToString(), block3.GetHash().ToString()); BOOST_CHECK_EQUAL(block.hashMerkleRoot.ToString(), BlockMerkleRoot(block3, &mutated).ToString()); BOOST_CHECK(!mutated); BOOST_CHECK_EQUAL(pool.mapTx.find(block.vtx[2]->GetHash())->GetSharedTx().use_count(), SHARED_TX_OFFSET + 3); // +2 because of partialBlock and block2 and block3 txhash = block.vtx[2]->GetHash(); block.vtx.clear(); block2.vtx.clear(); block3.vtx.clear(); BOOST_CHECK_EQUAL(pool.mapTx.find(txhash)->GetSharedTx().use_count(), SHARED_TX_OFFSET + 1 - 1); // + 1 because of partialBlock; -1 because of block. } BOOST_CHECK_EQUAL(pool.mapTx.find(txhash)->GetSharedTx().use_count(), SHARED_TX_OFFSET - 1); // -1 because of block } BOOST_AUTO_TEST_CASE(SufficientPreforwardRTTest) { CTxMemPool pool; TestMemPoolEntryHelper entry; CBlock block(BuildBlockTestCase()); LOCK2(cs_main, pool.cs); pool.addUnchecked(entry.FromTx(block.vtx[1])); BOOST_CHECK_EQUAL(pool.mapTx.find(block.vtx[1]->GetHash())->GetSharedTx().use_count(), SHARED_TX_OFFSET + 0); uint256 txhash; // Test with pre-forwarding coinbase + tx 2 with tx 1 in mempool { TestHeaderAndShortIDs shortIDs(block); shortIDs.prefilledtxn.resize(2); shortIDs.prefilledtxn[0] = {0, block.vtx[0]}; shortIDs.prefilledtxn[1] = {1, block.vtx[2]}; // id == 1 as it is 1 after index 1 shortIDs.shorttxids.resize(1); shortIDs.shorttxids[0] = shortIDs.GetShortID(block.vtx[1]->GetHash()); CDataStream stream(SER_NETWORK, PROTOCOL_VERSION); stream << shortIDs; CBlockHeaderAndShortTxIDs shortIDs2; stream >> shortIDs2; PartiallyDownloadedBlock partialBlock(&pool); BOOST_CHECK(partialBlock.InitData(shortIDs2, extra_txn) == READ_STATUS_OK); BOOST_CHECK( partialBlock.IsTxAvailable(0)); BOOST_CHECK( partialBlock.IsTxAvailable(1)); BOOST_CHECK( partialBlock.IsTxAvailable(2)); BOOST_CHECK_EQUAL(pool.mapTx.find(block.vtx[1]->GetHash())->GetSharedTx().use_count(), SHARED_TX_OFFSET + 1); CBlock block2; PartiallyDownloadedBlock partialBlockCopy = partialBlock; BOOST_CHECK(partialBlock.FillBlock(block2, {}) == READ_STATUS_OK); BOOST_CHECK_EQUAL(block.GetHash().ToString(), block2.GetHash().ToString()); bool mutated; BOOST_CHECK_EQUAL(block.hashMerkleRoot.ToString(), BlockMerkleRoot(block2, &mutated).ToString()); BOOST_CHECK(!mutated); txhash = block.vtx[1]->GetHash(); block.vtx.clear(); block2.vtx.clear(); BOOST_CHECK_EQUAL(pool.mapTx.find(txhash)->GetSharedTx().use_count(), SHARED_TX_OFFSET + 1 - 1); // + 1 because of partialBlock; -1 because of block. } BOOST_CHECK_EQUAL(pool.mapTx.find(txhash)->GetSharedTx().use_count(), SHARED_TX_OFFSET - 1); // -1 because of block } BOOST_AUTO_TEST_CASE(EmptyBlockRoundTripTest) { CTxMemPool pool; CMutableTransaction coinbase; coinbase.vin.resize(1); coinbase.vin[0].scriptSig.resize(10); coinbase.vout.resize(1); coinbase.vout[0].nValue = 42; CBlock block; block.vtx.resize(1); block.vtx[0] = MakeTransactionRef(std::move(coinbase)); block.nVersion = 42; block.hashPrevBlock = InsecureRand256(); block.nBits = 0x207fffff; bool mutated; block.hashMerkleRoot = BlockMerkleRoot(block, &mutated); assert(!mutated); while (!CheckProofOfWork(block.GetHash(), block.nBits, Params().GetConsensus())) ++block.nNonce; // Test simple header round-trip with only coinbase { CBlockHeaderAndShortTxIDs shortIDs(block, false); CDataStream stream(SER_NETWORK, PROTOCOL_VERSION); stream << shortIDs; CBlockHeaderAndShortTxIDs shortIDs2; stream >> shortIDs2; PartiallyDownloadedBlock partialBlock(&pool); BOOST_CHECK(partialBlock.InitData(shortIDs2, extra_txn) == READ_STATUS_OK); BOOST_CHECK(partialBlock.IsTxAvailable(0)); CBlock block2; std::vector<CTransactionRef> vtx_missing; BOOST_CHECK(partialBlock.FillBlock(block2, vtx_missing) == READ_STATUS_OK); BOOST_CHECK_EQUAL(block.GetHash().ToString(), block2.GetHash().ToString()); BOOST_CHECK_EQUAL(block.hashMerkleRoot.ToString(), BlockMerkleRoot(block2, &mutated).ToString()); BOOST_CHECK(!mutated); } } BOOST_AUTO_TEST_CASE(TransactionsRequestSerializationTest) { BlockTransactionsRequest req1; req1.blockhash = InsecureRand256(); req1.indexes.resize(4); req1.indexes[0] = 0; req1.indexes[1] = 1; req1.indexes[2] = 3; req1.indexes[3] = 4; CDataStream stream(SER_NETWORK, PROTOCOL_VERSION); stream << req1; BlockTransactionsRequest req2; stream >> req2; BOOST_CHECK_EQUAL(req1.blockhash.ToString(), req2.blockhash.ToString()); BOOST_CHECK_EQUAL(req1.indexes.size(), req2.indexes.size()); BOOST_CHECK_EQUAL(req1.indexes[0], req2.indexes[0]); BOOST_CHECK_EQUAL(req1.indexes[1], req2.indexes[1]); BOOST_CHECK_EQUAL(req1.indexes[2], req2.indexes[2]); BOOST_CHECK_EQUAL(req1.indexes[3], req2.indexes[3]); } BOOST_AUTO_TEST_CASE(TransactionsRequestDeserializationMaxTest) { // Check that the highest legal index is decoded correctly BlockTransactionsRequest req0; req0.blockhash = InsecureRand256(); req0.indexes.resize(1); req0.indexes[0] = 0xffff; CDataStream stream(SER_NETWORK, PROTOCOL_VERSION); stream << req0; BlockTransactionsRequest req1; stream >> req1; BOOST_CHECK_EQUAL(req0.indexes.size(), req1.indexes.size()); BOOST_CHECK_EQUAL(req0.indexes[0], req1.indexes[0]); } BOOST_AUTO_TEST_CASE(TransactionsRequestDeserializationOverflowTest) { // Any set of index deltas that starts with N values that sum to (0x10000 - N) // causes the edge-case overflow that was originally not checked for. Such // a request cannot be created by serializing a real BlockTransactionsRequest // due to the overflow, so here we'll serialize from raw deltas. BlockTransactionsRequest req0; req0.blockhash = InsecureRand256(); req0.indexes.resize(3); req0.indexes[0] = 0x7000; req0.indexes[1] = 0x10000 - 0x7000 - 2; req0.indexes[2] = 0; CDataStream stream(SER_NETWORK, PROTOCOL_VERSION); stream << req0.blockhash; WriteCompactSize(stream, req0.indexes.size()); WriteCompactSize(stream, req0.indexes[0]); WriteCompactSize(stream, req0.indexes[1]); WriteCompactSize(stream, req0.indexes[2]); BlockTransactionsRequest req1; try { stream >> req1; // before patch: deserialize above succeeds and this check fails, demonstrating the overflow BOOST_CHECK(req1.indexes[1] < req1.indexes[2]); // this shouldn't be reachable before or after patch BOOST_CHECK(0); } catch(std::ios_base::failure &) { // deserialize should fail BOOST_CHECK(true); // Needed to suppress "Test case [...] did not check any assertions" } } BOOST_AUTO_TEST_SUITE_END()
[ "fernando@develcuy.com" ]
fernando@develcuy.com
cde9137bdfb115433f83aeec844849db31620670
dc09d77b199a55f4d22c49d7878882e0144ccd7f
/test/motor_and_pump_test/motor_and_pump_test.ino
5ea10536f08ccddb248d22b4367b37fe7ae03b88
[]
no_license
jaedwards4422/aqualus
48b6f2b220b130a19ef23a175d291be3a27ee06f
262cf905a0ca45e48e3f3c0e6fc48b2e5d014f09
refs/heads/main
2023-08-12T13:45:19.333631
2021-10-06T21:03:00
2021-10-06T21:03:00
400,286,307
0
0
null
null
null
null
UTF-8
C++
false
false
1,261
ino
const int OUT1 = 2; //pins for motor const int OUT2 = 3; const int ENA = 5; //PWM, ENA pin const int OUT3 = 8; //pins for pump const int OUT4 = 9; const int ENB = 10; //PWM, ENB pin void setup() { //Set up for motors pinMode(OUT1,OUTPUT); // when high, reverse pinMode(OUT2,OUTPUT); //when high, forward pinMode(ENA, OUTPUT); //PWM controls speed of motor //Set up for pump pinMode(OUT3,OUTPUT); // when high, reverse pinMode(OUT4,OUTPUT); //when high, forward pinMode(ENB, OUTPUT); //PWM controls speed of pump } void loop() { // test if motor runs. first backwards, pause 1s, then forwards. digitalWrite(OUT1,HIGH); digitalWrite(OUT2,LOW); analogWrite(ENA,255); delay(1000); digitalWrite(OUT1,LOW); digitalWrite(OUT2,LOW); analogWrite(ENA,0); delay(1000); digitalWrite(OUT1,LOW); digitalWrite(OUT2,HIGH); analogWrite(ENA,255); delay(1000); digitalWrite(OUT1,LOW); digitalWrite(OUT2,LOW); analogWrite(ENA,0); delay(1000); // test if pump runs. might need to change which pin is high and which is low digitalWrite(OUT3,LOW); digitalWrite(OUT4,HIGH); analogWrite(ENB,255); delay(3000); digitalWrite(OUT3,LOW); //pause 1sec digitalWrite(OUT4,LOW); analogWrite(ENB,0); delay(1000); }
[ "stevenneuhaus@vagelos-ve703-15464.apn.wlan.private.upenn.edu" ]
stevenneuhaus@vagelos-ve703-15464.apn.wlan.private.upenn.edu
01c0245b30fa3b35c311ad5541e3e091e2f32d69
26df6604faf41197c9ced34c3df13839be6e74d4
/src/org/apache/poi/ss/formula/ptg/OperationPtg.cpp
9078fae0c88b09364ba3625500852ae946e4acef
[ "Apache-2.0" ]
permissive
pebble2015/cpoi
58b4b1e38a7769b13ccfb2973270d15d490de07f
6dcc0c5e13e3e722b4ef9fd0baffbf62bf71ead6
refs/heads/master
2021-07-09T09:02:41.986901
2017-10-08T12:12:56
2017-10-08T12:12:56
105,988,119
0
0
null
null
null
null
UTF-8
C++
false
false
1,108
cpp
// Generated from /POI/java/org/apache/poi/ss/formula/ptg/OperationPtg.java #include <org/apache/poi/ss/formula/ptg/OperationPtg.hpp> #include <org/apache/poi/ss/formula/ptg/Ptg.hpp> poi::ss::formula::ptg::OperationPtg::OperationPtg(const ::default_init_tag&) : super(*static_cast< ::default_init_tag* >(0)) { clinit(); } poi::ss::formula::ptg::OperationPtg::OperationPtg() : OperationPtg(*static_cast< ::default_init_tag* >(0)) { ctor(); } constexpr int32_t poi::ss::formula::ptg::OperationPtg::TYPE_UNARY; constexpr int32_t poi::ss::formula::ptg::OperationPtg::TYPE_BINARY; constexpr int32_t poi::ss::formula::ptg::OperationPtg::TYPE_FUNCTION; int8_t poi::ss::formula::ptg::OperationPtg::getDefaultOperandClass() { return Ptg::CLASS_VALUE; } extern java::lang::Class *class_(const char16_t *c, int n); java::lang::Class* poi::ss::formula::ptg::OperationPtg::class_() { static ::java::lang::Class* c = ::class_(u"org.apache.poi.ss.formula.ptg.OperationPtg", 42); return c; } java::lang::Class* poi::ss::formula::ptg::OperationPtg::getClass0() { return class_(); }
[ "zhang.chen.yu@outlook.com" ]
zhang.chen.yu@outlook.com
3c5c442707b593f57c3f619002957b084ab3a089
ec4711e5444c280fc4fcd6505d5c0acca0627d55
/console/colors.cpp
b4469983d9265cf5abcc4a67038455a6d0177d4e
[ "MIT" ]
permissive
ancientlore/hermit
18f605d1cc8f145c6d936268c9139c92f6182590
0b6b5b3e364fe9a7080517a7f3ddb8cdb03f5b14
refs/heads/master
2020-05-16T21:02:57.517459
2012-01-26T00:17:12
2012-01-26T00:17:12
3,269,934
2
0
null
null
null
null
UTF-8
C++
false
false
15,097
cpp
// Color tables code // Copyright (C) 1996 Michael D. Lore All Rights Reserved #include "console/colors.h" #include "registry.h" #define FG_WHITE (FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE) #define FG_YELLOW (FOREGROUND_RED | FOREGROUND_GREEN) #define FG_VIOLET (FOREGROUND_RED | FOREGROUND_BLUE) #define FG_CYAN (FOREGROUND_BLUE | FOREGROUND_GREEN) #define FG_RED (FOREGROUND_RED) #define FG_GREEN (FOREGROUND_GREEN) #define FG_BLUE (FOREGROUND_BLUE) #define FG_HIGH (FOREGROUND_INTENSITY) #define BG_WHITE (BACKGROUND_RED | BACKGROUND_GREEN | BACKGROUND_BLUE) #define BG_YELLOW (BACKGROUND_RED | BACKGROUND_GREEN) #define BG_VIOLET (BACKGROUND_RED | BACKGROUND_BLUE) #define BG_CYAN (BACKGROUND_BLUE | BACKGROUND_GREEN) #define BG_RED (BACKGROUND_RED) #define BG_GREEN (BACKGROUND_GREEN) #define BG_BLUE (BACKGROUND_BLUE) #define BG_HIGH (BACKGROUND_INTENSITY) // Number of different color tables const int COLOR_TABLES = 4; /**********************************************************************/ static WORD defaultColorTable[ceNumEntries] = { // StatusBar FG_WHITE | FG_HIGH | BG_VIOLET, // ceStatusText FG_YELLOW | FG_HIGH | BG_VIOLET, // ceStatusTail // ScrollDir file listing FG_CYAN | FG_HIGH, // ceFileTag FG_YELLOW | FG_HIGH, // ceFileAttributes FG_WHITE | FG_HIGH, // ceFileSize FG_YELLOW | FG_HIGH, // ceFileDate FG_WHITE | FG_HIGH, // ceFileName FG_CYAN | FG_HIGH, // ceFileNameExt // ScrollDir file listing - under cursor! FG_CYAN | FG_HIGH | BG_BLUE, // ceFileTagCursor FG_YELLOW | FG_HIGH | BG_BLUE, // ceFileAttributesCursor FG_WHITE | FG_HIGH | BG_BLUE, // ceFileSizeCursor FG_YELLOW | FG_HIGH | BG_BLUE, // ceFileDateCursor FG_WHITE | FG_HIGH | BG_BLUE, // ceFileNameCursor FG_CYAN | FG_HIGH | BG_BLUE, // ceFileNameExtCursor // TitleBar FG_YELLOW | FG_HIGH | BG_VIOLET, // ceTitleText FG_WHITE | FG_HIGH | BG_VIOLET, // ceTitleTail // Popup Windows FG_WHITE | FG_HIGH | BG_BLUE, // cePopupBackground FG_WHITE | FG_HIGH | BG_BLUE | BG_HIGH, // cePopupBorder // Fields in Popup windows FG_CYAN | FG_HIGH | BG_BLUE, // ceField FG_YELLOW | FG_HIGH | BG_BLUE, // ceFieldKey FG_CYAN | FG_HIGH, // ceSelectedField FG_YELLOW | FG_HIGH, // ceSelectedKey // Edit Window FG_WHITE | FG_HIGH | BG_CYAN, // ceEditWindow // CommandDir file listing FG_BLUE | BG_CYAN, // ceCmdHeading FG_YELLOW | FG_HIGH | BG_CYAN, // ceCmdKey FG_WHITE | FG_HIGH | BG_CYAN, // ceCmdText // CommandDir file listing - under cursor! FG_BLUE | FG_HIGH, // ceCmdHeadingCursor FG_YELLOW | FG_HIGH, // ceCmdKeyCursor FG_WHITE | FG_HIGH, // ceCmdTextCursor // License Screen colors FG_WHITE, // ceLicenseNormal FG_YELLOW | FG_HIGH, // ceLicenseHighlight FG_WHITE | BG_RED, // ceLicenseNormalSel FG_YELLOW | FG_HIGH | BG_RED, // ceLicenseHighlightSel // Help Screen colors FG_WHITE, // ceHelpNormal FG_YELLOW | FG_HIGH, // ceHelpHighlight FG_WHITE | BG_BLUE, // ceHelpNormalSel FG_YELLOW | FG_HIGH | BG_BLUE, // ceHelpHighlightSel // Command text on user screen FG_YELLOW | FG_HIGH, // ceCommandText - background always black // because it's merged in later! // Verb Scroller FG_YELLOW | FG_HIGH | BG_CYAN, // ceVerb FG_YELLOW | FG_HIGH, // ceVerbCursor // Assigned Commands Scroller FG_YELLOW | FG_HIGH | BG_CYAN, // ceAssignKey FG_WHITE | FG_HIGH | BG_CYAN, // ceAssignCommand FG_YELLOW | FG_HIGH, // ceAssignKeyCursor FG_WHITE | FG_HIGH, // ceAssignCommandCursor // Info Window FG_WHITE | FG_HIGH | BG_BLUE, // ceInfoNormal FG_YELLOW | FG_HIGH | BG_BLUE, // ceInfoHighlight FG_WHITE | FG_HIGH | BG_CYAN // ceInfoNormalSel }; /**********************************************************************/ static WORD colorfulColorTable[ceNumEntries] = { // StatusBar FG_WHITE | FG_HIGH | BG_CYAN, // ceStatusText FG_YELLOW | FG_HIGH | BG_CYAN, // ceStatusTail // ScrollDir file listing FG_CYAN | FG_HIGH | BG_BLUE, // ceFileTag FG_YELLOW | FG_HIGH | BG_BLUE, // ceFileAttributes FG_WHITE | FG_HIGH | BG_BLUE, // ceFileSize FG_YELLOW | FG_HIGH | BG_BLUE, // ceFileDate FG_WHITE | FG_HIGH | BG_BLUE, // ceFileName FG_CYAN | FG_HIGH | BG_BLUE, // ceFileNameExt // ScrollDir file listing - under cursor! FG_CYAN | BG_WHITE, // ceFileTagCursor FG_BLUE | BG_WHITE, // ceFileAttributesCursor BG_WHITE, // ceFileSizeCursor FG_BLUE | BG_WHITE, // ceFileDateCursor BG_WHITE, // ceFileNameCursor FG_CYAN | BG_WHITE, // ceFileNameExtCursor // TitleBar FG_YELLOW | FG_HIGH | BG_CYAN, // ceTitleText FG_WHITE | FG_HIGH | BG_CYAN, // ceTitleTail // Popup Windows FG_YELLOW | FG_HIGH | BG_CYAN, // cePopupBackground FG_BLUE | BG_WHITE | BG_HIGH, // cePopupBorder // Fields in Popup windows FG_YELLOW | FG_HIGH | BG_CYAN, // ceField FG_WHITE | FG_HIGH | BG_CYAN, // ceFieldKey FG_BLUE | BG_WHITE, // ceSelectedField BG_WHITE, // ceSelectedKey // Edit Window FG_WHITE, // ceEditWindow // CommandDir file listing FG_CYAN | FG_HIGH | BG_BLUE, // ceCmdHeading FG_YELLOW | FG_HIGH | BG_BLUE, // ceCmdKey FG_WHITE | FG_HIGH | BG_BLUE, // ceCmdText // CommandDir file listing - under cursor! FG_BLUE | FG_HIGH | BG_WHITE, // ceCmdHeadingCursor BG_WHITE, // ceCmdKeyCursor FG_BLUE | BG_WHITE, // ceCmdTextCursor // License Screen colors FG_WHITE | FG_HIGH | BG_GREEN, // ceLicenseNormal FG_YELLOW | FG_HIGH | BG_GREEN, // ceLicenseHighlight BG_WHITE | BG_HIGH, // ceLicenseNormalSel FG_GREEN | BG_WHITE | BG_HIGH, // ceLicenseHighlightSel // Help Screen colors FG_WHITE, // ceHelpNormal FG_YELLOW | FG_HIGH, // ceHelpHighlight FG_WHITE | BG_BLUE, // ceHelpNormalSel FG_YELLOW | FG_HIGH | BG_BLUE, // ceHelpHighlightSel // Command text on user screen FG_GREEN | FG_HIGH, // ceCommandText - background always black // because it's merged in later! // Verb Scroller FG_YELLOW | FG_HIGH | BG_BLUE, // ceVerb BG_WHITE, // ceVerbCursor // Assigned Commands Scroller FG_YELLOW | FG_HIGH | BG_BLUE, // ceAssignKey FG_WHITE | FG_HIGH | BG_BLUE, // ceAssignCommand FG_BLUE | BG_WHITE, // ceAssignKeyCursor BG_WHITE, // ceAssignCommandCursor // Info Window FG_WHITE | FG_HIGH | BG_BLUE, // ceInfoNormal FG_YELLOW | FG_HIGH | BG_BLUE, // ceInfoHighlight FG_WHITE | FG_HIGH | BG_CYAN // ceInfoNormalSel }; /**********************************************************************/ static WORD greyColorTable[ceNumEntries] = { // StatusBar FG_WHITE | FG_HIGH | BG_HIGH, // ceStatusText BG_WHITE, // ceStatusTail // ScrollDir file listing FG_WHITE | FG_HIGH, // ceFileTag FG_WHITE, // ceFileAttributes FG_WHITE | FG_HIGH, // ceFileSize FG_WHITE, // ceFileDate FG_WHITE | FG_HIGH, // ceFileName FG_WHITE, // ceFileNameExt // ScrollDir file listing - under cursor! BG_WHITE, // ceFileTagCursor BG_WHITE, // ceFileAttributesCursor BG_WHITE, // ceFileSizeCursor BG_WHITE, // ceFileDateCursor BG_WHITE, // ceFileNameCursor BG_WHITE, // ceFileNameExtCursor // TitleBar FG_WHITE| FG_HIGH | BG_HIGH, // ceTitleText BG_WHITE, // ceTitleTail // Popup Windows FG_WHITE | FG_HIGH | BG_HIGH, // cePopupBackground BG_WHITE | BG_HIGH, // cePopupBorder // Fields in Popup windows FG_WHITE | FG_HIGH | BG_HIGH, // ceField BG_WHITE, // ceFieldKey BG_WHITE, // ceSelectedField BG_WHITE, // ceSelectedKey // Edit Window FG_WHITE | FG_HIGH, // ceEditWindow // CommandDir file listing FG_WHITE | FG_HIGH, // ceCmdHeading FG_WHITE, // ceCmdKey FG_WHITE | FG_HIGH, // ceCmdText // CommandDir file listing - under cursor! BG_WHITE, // ceCmdHeadingCursor BG_WHITE, // ceCmdKeyCursor BG_WHITE, // ceCmdTextCursor // License Screen colors FG_WHITE | BG_HIGH, // ceLicenseNormal FG_WHITE | FG_HIGH | BG_HIGH, // ceLicenseHighlight BG_WHITE, // ceLicenseNormalSel BG_WHITE, // ceLicenseHighlightSel // Help Screen colors FG_WHITE | BG_HIGH, // ceHelpNormal FG_WHITE | FG_HIGH | BG_HIGH, // ceHelpHighlight BG_WHITE, // ceHelpNormalSel BG_WHITE, // ceHelpHighlightSel // Command text on user screen FG_WHITE | FG_HIGH, // ceCommandText - background always black // because it's merged in later! // Verb Scroller FG_WHITE | FG_HIGH, // ceVerb BG_WHITE, // ceVerbCursor // Assigned Commands Scroller FG_WHITE, // ceAssignKey FG_WHITE | FG_HIGH, // ceAssignCommand BG_WHITE, // ceAssignKeyCursor BG_WHITE, // ceAssignCommandCursor // Info Window FG_WHITE, // ceInfoNormal FG_WHITE | FG_HIGH, // ceInfoHighlight BG_HIGH // ceInfoNormalSel }; /**********************************************************************/ static WORD forestColorTable[ceNumEntries] = { // StatusBar BG_WHITE | BG_HIGH, // ceStatusText FG_RED | BG_WHITE | BG_HIGH, // ceStatusTail // ScrollDir file listing FG_GREEN | FG_HIGH | BG_GREEN, // ceFileTag FG_YELLOW | FG_HIGH | BG_GREEN, // ceFileAttributes FG_WHITE | FG_HIGH | BG_GREEN, // ceFileSize FG_YELLOW | FG_HIGH | BG_GREEN, // ceFileDate FG_WHITE | FG_HIGH | BG_GREEN, // ceFileName FG_GREEN | FG_HIGH | BG_GREEN, // ceFileNameExt // ScrollDir file listing - under cursor! FG_GREEN | FG_HIGH | BG_YELLOW, // ceFileTagCursor FG_YELLOW | FG_HIGH | BG_YELLOW, // ceFileAttributesCursor FG_WHITE | FG_HIGH | BG_YELLOW, // ceFileSizeCursor FG_YELLOW | FG_HIGH | BG_YELLOW, // ceFileDateCursor FG_WHITE | FG_HIGH | BG_YELLOW, // ceFileNameCursor FG_GREEN | FG_HIGH | BG_YELLOW, // ceFileNameExtCursor // TitleBar BG_WHITE | BG_HIGH, // ceTitleText FG_RED | BG_WHITE | BG_HIGH, // ceTitleTail // Popup Windows FG_WHITE | FG_HIGH | BG_RED, // cePopupBackground FG_WHITE | FG_HIGH, // cePopupBorder // Fields in Popup windows FG_WHITE | FG_HIGH | BG_RED, // ceField FG_YELLOW | FG_HIGH | BG_RED, // ceFieldKey FG_WHITE | FG_HIGH, // ceSelectedField FG_YELLOW | FG_HIGH, // ceSelectedKey // Edit Window FG_YELLOW | FG_HIGH, // ceEditWindow // CommandDir file listing FG_GREEN | FG_HIGH, // ceCmdHeading FG_YELLOW | FG_HIGH, // ceCmdKey FG_WHITE | FG_HIGH, // ceCmdText // CommandDir file listing - under cursor! FG_GREEN | FG_HIGH | BG_GREEN, // ceCmdHeadingCursor FG_YELLOW | FG_HIGH | BG_GREEN, // ceCmdKeyCursor FG_WHITE | FG_HIGH | BG_GREEN, // ceCmdTextCursor // License Screen colors FG_WHITE | FG_HIGH | BG_GREEN, // ceLicenseNormal FG_YELLOW | FG_HIGH | BG_GREEN, // ceLicenseHighlight BG_WHITE | BG_HIGH, // ceLicenseNormalSel FG_GREEN | BG_WHITE | BG_HIGH, // ceLicenseHighlightSel // Help Screen colors FG_WHITE | FG_HIGH | BG_GREEN, // ceHelpNormal FG_YELLOW | FG_HIGH | BG_GREEN, // ceHelpHighlight BG_WHITE | BG_HIGH, // ceHelpNormalSel FG_GREEN | BG_WHITE | BG_HIGH, // ceHelpHighlightSel // Command text on user screen FG_GREEN | FG_HIGH, // ceCommandText - background always black // because it's merged in later! // Verb Scroller FG_YELLOW | FG_HIGH, // ceVerb FG_YELLOW | FG_HIGH | BG_GREEN, // ceVerbCursor // Assigned Commands Scroller FG_YELLOW | FG_HIGH, // ceAssignKey FG_WHITE | FG_HIGH, // ceAssignCommand FG_YELLOW | FG_HIGH | BG_GREEN, // ceAssignKeyCursor FG_WHITE | FG_HIGH | BG_GREEN, // ceAssignCommandCursor // Info Window FG_WHITE | FG_HIGH, // ceInfoNormal FG_GREEN | FG_HIGH, // ceInfoHighlight FG_WHITE | FG_HIGH | BG_YELLOW // ceInfoNormalSel }; static WORD *colorTable = NULL; // causes it to be read from registry static int curTable = 0; static void assignColorTable (int table) { if (table == 0) colorTable = defaultColorTable; else if (table == 1) colorTable = colorfulColorTable; else if (table == 2) colorTable = greyColorTable; else if (table == 3) colorTable = forestColorTable; else return; curTable = table; } int getColorTable () { return curTable; } void selectColorTable (int table) { table = table % COLOR_TABLES; assignColorTable (table); // Save the choice in the registry if (table >= 0 && table < COLOR_TABLES) { try { RegistryKey k (HKEY_CURRENT_USER, HKCU_SUBKEY_HERMIT "\\Color", KEY_READ | KEY_WRITE); k.setValue ("Scheme", (DWORD) table); } catch (const std::exception&) { // oh well, it's only the colors } } } WORD getColor (ColorEntry entry) { if (colorTable == NULL) { // get the choice from the registry try { RegistryKey k (HKEY_CURRENT_USER, HKCU_SUBKEY_HERMIT "\\Color", KEY_READ); DWORD type; char *value = k.queryValue ("Scheme", type); if (type == REG_DWORD && value != 0) assignColorTable (*((DWORD *)value)); delete [] value; } catch (const std::exception&) { // oh well, it's only the colors } if (colorTable == NULL) colorTable = defaultColorTable; } if (entry >= ceFirstEntry && entry < ceNumEntries) return colorTable[entry]; else return FG_WHITE; } // End
[ "michael.lore@gmail.com" ]
michael.lore@gmail.com
85e61056264a84dc76d659de8638540738f5612d
055f01de3773d4b38c6c2f384445dbb3d9573b80
/SDAlgorithm/interface/StoredJet.h
6ec70e1d7370971d339c89e2d7c5b117d7059eca
[]
no_license
jmduarte/ShowerDeconstruction
4dd9a2ff7eb83581567428948714d93a4f59589b
fb9070eef6fb698077cb84d5248ec57afa2bff0f
refs/heads/master
2021-03-27T11:01:30.700371
2015-05-18T11:07:29
2015-05-18T11:07:29
72,777,403
0
1
null
null
null
null
UTF-8
C++
false
false
895
h
#ifndef STOREDJET_H #define STOREDJET_H #include <vector> #include "ShowerDeconstruction/SDAlgorithm/interface/Storage.h" #include <fastjet/PseudoJet.hh> namespace Deconstruction { class StoredJet { public: StoredJet(); StoredJet(const StoredJet &s); StoredJet(const Storage &store); StoredJet(const Storage *store); StoredJet(const Storage &store, std::vector<int> list); virtual ~StoredJet(); int getIdx(int i) const; std::vector<int> getList() const; const fastjet::PseudoJet &operator[](int i) const; const fastjet::PseudoJet &at(int i) const; int size() const; fastjet::PseudoJet sum() const; void push_back(int i); operator std::vector<fastjet::PseudoJet>() const; const Storage &store() const; private: const Storage *m_store; std::vector<int> m_list; }; } #endif
[ "gregor.kasieczka@cern.ch" ]
gregor.kasieczka@cern.ch
f9a73e214446714a12aa5eefe524b1a0685fa8fa
4d8f7b7fe6e4b8f8bc772339bd187960d3e01e2b
/tutorials/week11/starter/services_masterclass/src/sample.cpp
623c4591088843cb2bcae5f7078b9e1149edc0e5
[]
no_license
ajalsingh/PFMS-A2020
1dd2c18691ac48867d07d062114b49b029c7004b
e52a5e1677b6d0c5b309dbeec8e125c0ac19d857
refs/heads/master
2023-05-29T04:08:48.327745
2021-06-08T08:04:16
2021-06-08T08:04:16
275,065,349
0
2
null
null
null
null
UTF-8
C++
false
false
5,108
cpp
#include "sample.h" /** * This sample code is provided to illustrate * - Subscribing to standard topics (Odometry and Laser) * - Subscribing to images (which require a image transport interpreter) * - Publishing images * * The code is not intended to provide a */ PfmsSample::PfmsSample(ros::NodeHandle nh) : nh_(nh), it_(nh), imageProcessing_() { //Subscribing to odometry sub1_ = nh_.subscribe("/robot_0/odom", 1000, &PfmsSample::odomCallback,this); //Subscribing to image // unlike other topics this requires a image transport rather than simply a node handle image_transport::ImageTransport it(nh); sub2_ = it.subscribe("map_image/full", 1, &PfmsSample::imageCallback,this); //Publish a velocity ... to control the robot cmd_vel_pub_ = nh_.advertise<geometry_msgs::Twist>("/robot_0/cmd_vel",1); //Allowing an incoming service on /face_goal, this invokes the faceGoal function service_ = nh_.advertiseService("face_goal", &PfmsSample::faceGoal,this); //The below get's configurations from parameters server nh_.getParam("/local_map/map_resolution", resolution_); //Below is how to get parameters from command line, on command line they need to be _param:=value //For example _example:=0.1 //Below will either get the configuration from command line or assign a default value 0.1 ros::NodeHandle pn("~"); double example; pn.param<double>("example", example, 0.1); } PfmsSample::~PfmsSample() { // cv::destroyWindow("view"); } bool PfmsSample::faceGoal(a4_setup::RequestGoal::Request &req, a4_setup::RequestGoal::Response &res) { //When an incoming call arrives, we can respond to it here ROS_INFO_STREAM("request: [x,y]=[" << req.pose.x << "," << req.pose.y); //! @todo Ex04 : Adjust the code so it returns a `true` in the acknowledgment of the service call if the point //! can be reached in a straight line from current robot pose, only traversing free space. //! Below code will be useful //! Lock image buffer, take one message from deque and unlock it // cv::Mat image; // imageDataBuffer_.mtx.lock(); // if(imageDataBuffer_.imageDeq.size()>0){ // image = imageDataBuffer_.imageDeq.front(); // imageDataBuffer_.timeStampDeq.front();//We don't need time here, we could also obtain it // imageDataBuffer_.imageDeq.pop_front(); // imageDataBuffer_.timeStampDeq.pop_front(); // } // imageDataBuffer_.mtx.unlock(); res.ack = true;//At the moment we are simply assigning a value so we can return from function ROS_INFO_STREAM(__func__ << " sending back response");//The example has __func__ , which get's the function name, so it assists debugging return true; //We HAVE to retrun true to indicate the service call sucseeded } void PfmsSample::odomCallback(const nav_msgs::OdometryConstPtr& msg) { //Let's get the pose out from odometry message //rosmsg show nav_msgs/Odometry geometry_msgs::Pose pose=msg->pose.pose; //We will be using a structire to store odometry with a Deq for time and poses //In case we want to search through them, if your only using last reading then you //might not need a deque (this is an example different to topics_masterclass) poseDataBuffer_.mtx.lock(); poseDataBuffer_.poseDeq.push_back(pose); poseDataBuffer_.timeStampDeq.push_back(msg->header.stamp); if(poseDataBuffer_.poseDeq.size()>2){ poseDataBuffer_.poseDeq.pop_front(); poseDataBuffer_.timeStampDeq.pop_front(); } poseDataBuffer_.mtx.unlock(); } void PfmsSample::imageCallback(const sensor_msgs::ImageConstPtr& msg) { //! Below code pushes the image and time to a deque, to share across threads try { if (enc::isColor(msg->encoding)) cvPtr_ = cv_bridge::toCvCopy(msg, enc::BGR8); else cvPtr_ = cv_bridge::toCvCopy(msg, enc::MONO8); } catch (cv_bridge::Exception& e) { ROS_ERROR("cv_bridge exception: %s", e.what()); return; } imageDataBuffer_.mtx.lock(); imageDataBuffer_.imageDeq.push_back(cvPtr_->image); imageDataBuffer_.timeStampDeq.push_back(msg->header.stamp); if(imageDataBuffer_.imageDeq.size()>2){ imageDataBuffer_.imageDeq.pop_front(); imageDataBuffer_.timeStampDeq.pop_front(); } imageDataBuffer_.mtx.unlock(); } void PfmsSample::seperateThread() { /** * The below loop runs until ros is shutdown */ //! What does this rate limiter do? ros::Rate rate_limiter(1.0); while (ros::ok()) { //! @todo One of the assignments requires control of the robot so it turns to face the point requested (and does not move forward). //! Yor node should also allow for any new requests to overwrite the current actioned goal. //! What data do we need? geometry_msgs::Twist cmdvel; cmdvel.linear.x = 0.1; //Linear Velocity - V cmdvel.angular.z = 0; //Angular Velocity - Omega ROS_INFO_STREAM("sending...[" << cmdvel.linear.x << "," << cmdvel.angular.z << "]"); cmd_vel_pub_.publish(cmdvel); rate_limiter.sleep(); } }
[ "ajal.singh@multifin.com.au" ]
ajal.singh@multifin.com.au
1b54de2f8094caa2fe187397e8a700a3b623e3ee
f410536bd2d15500c3eb3e61a9de0593a4add1e1
/NumberGuesser/NumberGuesser.cpp
0f29ae9473bd0d967b7fb07f52d2bad2750a72b0
[]
no_license
DemingYan/cs110b
29969713812cbb07328bddf4c297f9818c178779
6e39dfae3e0ba94fa938f15eb86886d9ed946046
refs/heads/master
2020-12-03T00:18:00.463334
2014-12-17T06:17:57
2014-12-17T06:17:57
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,203
cpp
/* Author: Kevin Morris <kevr@nixcode.us> * File: NumberGuesser.h * This module is responsible for the guesser data structure * involved in this assignment */ #include "NumberGuesser.h" #include <cstdlib> using namespace std; // Range class definitions Range::Range(int min, int max) : _min(min) , _mid((min + max) / 2.0) , _max(max) { // min/max constructor } Range Range::cutLow() const { return Range(_min, _mid); } Range Range::cutHigh() const { return Range(_mid, _max); } // End Range class // NumberGuesser Node class definitions NumberGuesser::Node::Node(int newValue) : value(newValue) , left(NULL) , right(NULL) { /* default constructor */ } NumberGuesser::Node::~Node() { if(left) delete left; if(right) delete right; } // End NumberGuesser Node class definitions // NumberGuesser class definitions NumberGuesser::NumberGuesser(int min, int max) : root(NULL) , current(NULL) { populate(min, max); /* Initialize all the things */ } NumberGuesser::~NumberGuesser() { if(root) delete root; } void NumberGuesser::insert(int newValue) { insert(root, newValue); } /* private insert bouncer */ void NumberGuesser::insert(Node *& node, int newValue) { if(!node) node = new Node(newValue); else if(newValue < node->value) insert(node->left, newValue); else if(newValue > node->value) insert(node->right, newValue); } int NumberGuesser::reset() { current = root; return current ? current->value : -1; } int NumberGuesser::higher() { current = current->right; return current ? current->value : -1; } int NumberGuesser::lower() { current = current->left; return current ? current->value : -1; } void NumberGuesser::populate(int min, int max) { populate(Range(min, max)); current = root; } #ifdef EBUG #include <iostream> #endif void NumberGuesser::populate(const Range& range) { insert(range.mid()); if(range.mid() == range.min()) return; else if(range.mid() + 1 == range.max()) { insert(range.max()); return; } populate(range.cutLow()); populate(range.cutHigh()); }
[ "kevr@nixcode.us" ]
kevr@nixcode.us
51c71a36bbe3bfe117843bfefc86f24fe3874baa
95e013baf017ff22a5fcdb90c49273fa3a6de1b9
/src/base58.h
533ef4651345f720bbe629ca66ddfdb2c76566dd
[ "MIT" ]
permissive
moleculas/narCo-in
ac4b82c0139472a637b303442a9ccca11fe72f2d
4607d4ad2c85330d2e769f90dab1e86ebddd5cfc
refs/heads/master
2021-01-24T20:42:08.913799
2015-11-26T21:42:25
2015-11-26T21:42:25
46,628,648
0
0
null
null
null
null
UTF-8
C++
false
false
13,230
h
// Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2012 The Bitcoin Developers // Copyright (c) 2011-2012 NarCo-in Developers // Distributed under the MIT/X11 software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. // // Why base-58 instead of standard base-64 encoding? // - Don't want 0OIl characters that look the same in some fonts and // could be used to create visually identical looking account numbers. // - A string with non-alphanumeric characters is not as easily accepted as an account number. // - E-mail usually won't line-break if there's no punctuation to break at. // - Doubleclicking selects the whole number as one word if it's all alphanumeric. // #ifndef BITCOIN_BASE58_H #define BITCOIN_BASE58_H #include <string> #include <vector> #include "bignum.h" #include "key.h" #include "script.h" static const char* pszBase58 = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"; // Encode a byte sequence as a base58-encoded string inline std::string EncodeBase58(const unsigned char* pbegin, const unsigned char* pend) { CAutoBN_CTX pctx; CBigNum bn58 = 58; CBigNum bn0 = 0; // Convert big endian data to little endian // Extra zero at the end make sure bignum will interpret as a positive number std::vector<unsigned char> vchTmp(pend-pbegin+1, 0); reverse_copy(pbegin, pend, vchTmp.begin()); // Convert little endian data to bignum CBigNum bn; bn.setvch(vchTmp); // Convert bignum to std::string std::string str; // Expected size increase from base58 conversion is approximately 137% // use 138% to be safe str.reserve((pend - pbegin) * 138 / 100 + 1); CBigNum dv; CBigNum rem; while (bn > bn0) { if (!BN_div(&dv, &rem, &bn, &bn58, pctx)) throw bignum_error("EncodeBase58 : BN_div failed"); bn = dv; unsigned int c = rem.getulong(); str += pszBase58[c]; } // Leading zeroes encoded as base58 zeros for (const unsigned char* p = pbegin; p < pend && *p == 0; p++) str += pszBase58[0]; // Convert little endian std::string to big endian reverse(str.begin(), str.end()); return str; } // Encode a byte vector as a base58-encoded string inline std::string EncodeBase58(const std::vector<unsigned char>& vch) { return EncodeBase58(&vch[0], &vch[0] + vch.size()); } // Decode a base58-encoded string psz into byte vector vchRet // returns true if decoding is successful inline bool DecodeBase58(const char* psz, std::vector<unsigned char>& vchRet) { CAutoBN_CTX pctx; vchRet.clear(); CBigNum bn58 = 58; CBigNum bn = 0; CBigNum bnChar; while (isspace(*psz)) psz++; // Convert big endian string to bignum for (const char* p = psz; *p; p++) { const char* p1 = strchr(pszBase58, *p); if (p1 == NULL) { while (isspace(*p)) p++; if (*p != '\0') return false; break; } bnChar.setulong(p1 - pszBase58); if (!BN_mul(&bn, &bn, &bn58, pctx)) throw bignum_error("DecodeBase58 : BN_mul failed"); bn += bnChar; } // Get bignum as little endian data std::vector<unsigned char> vchTmp = bn.getvch(); // Trim off sign byte if present if (vchTmp.size() >= 2 && vchTmp.end()[-1] == 0 && vchTmp.end()[-2] >= 0x80) vchTmp.erase(vchTmp.end()-1); // Restore leading zeros int nLeadingZeros = 0; for (const char* p = psz; *p == pszBase58[0]; p++) nLeadingZeros++; vchRet.assign(nLeadingZeros + vchTmp.size(), 0); // Convert little endian data to big endian reverse_copy(vchTmp.begin(), vchTmp.end(), vchRet.end() - vchTmp.size()); return true; } // Decode a base58-encoded string str into byte vector vchRet // returns true if decoding is successful inline bool DecodeBase58(const std::string& str, std::vector<unsigned char>& vchRet) { return DecodeBase58(str.c_str(), vchRet); } // Encode a byte vector to a base58-encoded string, including checksum inline std::string EncodeBase58Check(const std::vector<unsigned char>& vchIn) { // add 4-byte hash check to the end std::vector<unsigned char> vch(vchIn); uint256 hash = Hash(vch.begin(), vch.end()); vch.insert(vch.end(), (unsigned char*)&hash, (unsigned char*)&hash + 4); return EncodeBase58(vch); } // Decode a base58-encoded string psz that includes a checksum, into byte vector vchRet // returns true if decoding is successful inline bool DecodeBase58Check(const char* psz, std::vector<unsigned char>& vchRet) { if (!DecodeBase58(psz, vchRet)) return false; if (vchRet.size() < 4) { vchRet.clear(); return false; } uint256 hash = Hash(vchRet.begin(), vchRet.end()-4); if (memcmp(&hash, &vchRet.end()[-4], 4) != 0) { vchRet.clear(); return false; } vchRet.resize(vchRet.size()-4); return true; } // Decode a base58-encoded string str that includes a checksum, into byte vector vchRet // returns true if decoding is successful inline bool DecodeBase58Check(const std::string& str, std::vector<unsigned char>& vchRet) { return DecodeBase58Check(str.c_str(), vchRet); } /** Base class for all base58-encoded data */ class CBase58Data { protected: // the version byte unsigned char nVersion; // the actually encoded data std::vector<unsigned char> vchData; CBase58Data() { nVersion = 0; vchData.clear(); } ~CBase58Data() { // zero the memory, as it may contain sensitive data if (!vchData.empty()) memset(&vchData[0], 0, vchData.size()); } void SetData(int nVersionIn, const void* pdata, size_t nSize) { nVersion = nVersionIn; vchData.resize(nSize); if (!vchData.empty()) memcpy(&vchData[0], pdata, nSize); } void SetData(int nVersionIn, const unsigned char *pbegin, const unsigned char *pend) { SetData(nVersionIn, (void*)pbegin, pend - pbegin); } public: bool SetString(const char* psz) { std::vector<unsigned char> vchTemp; DecodeBase58Check(psz, vchTemp); if (vchTemp.empty()) { vchData.clear(); nVersion = 0; return false; } nVersion = vchTemp[0]; vchData.resize(vchTemp.size() - 1); if (!vchData.empty()) memcpy(&vchData[0], &vchTemp[1], vchData.size()); memset(&vchTemp[0], 0, vchTemp.size()); return true; } bool SetString(const std::string& str) { return SetString(str.c_str()); } std::string ToString() const { std::vector<unsigned char> vch(1, nVersion); vch.insert(vch.end(), vchData.begin(), vchData.end()); return EncodeBase58Check(vch); } int CompareTo(const CBase58Data& b58) const { if (nVersion < b58.nVersion) return -1; if (nVersion > b58.nVersion) return 1; if (vchData < b58.vchData) return -1; if (vchData > b58.vchData) return 1; return 0; } bool operator==(const CBase58Data& b58) const { return CompareTo(b58) == 0; } bool operator<=(const CBase58Data& b58) const { return CompareTo(b58) <= 0; } bool operator>=(const CBase58Data& b58) const { return CompareTo(b58) >= 0; } bool operator< (const CBase58Data& b58) const { return CompareTo(b58) < 0; } bool operator> (const CBase58Data& b58) const { return CompareTo(b58) > 0; } }; /** base58-encoded Bitcoin addresses. * Public-key-hash-addresses have version 0 (or 111 testnet). * The data vector contains RIPEMD160(SHA256(pubkey)), where pubkey is the serialized public key. * Script-hash-addresses have version 5 (or 196 testnet). * The data vector contains RIPEMD160(SHA256(cscript)), where cscript is the serialized redemption script. */ class CBitcoinAddress; class CBitcoinAddressVisitor : public boost::static_visitor<bool> { private: CBitcoinAddress *addr; public: CBitcoinAddressVisitor(CBitcoinAddress *addrIn) : addr(addrIn) { } bool operator()(const CKeyID &id) const; bool operator()(const CScriptID &id) const; bool operator()(const CNoDestination &no) const; }; class CBitcoinAddress : public CBase58Data { public: enum { PUBKEY_ADDRESS = 48, // NarCo-in addresses start with L SCRIPT_ADDRESS = 5, PUBKEY_ADDRESS_TEST = 111, SCRIPT_ADDRESS_TEST = 196, }; bool Set(const CKeyID &id) { SetData(fTestNet ? PUBKEY_ADDRESS_TEST : PUBKEY_ADDRESS, &id, 20); return true; } bool Set(const CScriptID &id) { SetData(fTestNet ? SCRIPT_ADDRESS_TEST : SCRIPT_ADDRESS, &id, 20); return true; } bool Set(const CTxDestination &dest) { return boost::apply_visitor(CBitcoinAddressVisitor(this), dest); } bool IsValid() const { unsigned int nExpectedSize = 20; bool fExpectTestNet = false; switch(nVersion) { case PUBKEY_ADDRESS: nExpectedSize = 20; // Hash of public key fExpectTestNet = false; break; case SCRIPT_ADDRESS: nExpectedSize = 20; // Hash of CScript fExpectTestNet = false; break; case PUBKEY_ADDRESS_TEST: nExpectedSize = 20; fExpectTestNet = true; break; case SCRIPT_ADDRESS_TEST: nExpectedSize = 20; fExpectTestNet = true; break; default: return false; } return fExpectTestNet == fTestNet && vchData.size() == nExpectedSize; } CBitcoinAddress() { } CBitcoinAddress(const CTxDestination &dest) { Set(dest); } CBitcoinAddress(const std::string& strAddress) { SetString(strAddress); } CBitcoinAddress(const char* pszAddress) { SetString(pszAddress); } CTxDestination Get() const { if (!IsValid()) return CNoDestination(); switch (nVersion) { case PUBKEY_ADDRESS: case PUBKEY_ADDRESS_TEST: { uint160 id; memcpy(&id, &vchData[0], 20); return CKeyID(id); } case SCRIPT_ADDRESS: case SCRIPT_ADDRESS_TEST: { uint160 id; memcpy(&id, &vchData[0], 20); return CScriptID(id); } } return CNoDestination(); } bool GetKeyID(CKeyID &keyID) const { if (!IsValid()) return false; switch (nVersion) { case PUBKEY_ADDRESS: case PUBKEY_ADDRESS_TEST: { uint160 id; memcpy(&id, &vchData[0], 20); keyID = CKeyID(id); return true; } default: return false; } } bool IsScript() const { if (!IsValid()) return false; switch (nVersion) { case SCRIPT_ADDRESS: case SCRIPT_ADDRESS_TEST: { return true; } default: return false; } } }; bool inline CBitcoinAddressVisitor::operator()(const CKeyID &id) const { return addr->Set(id); } bool inline CBitcoinAddressVisitor::operator()(const CScriptID &id) const { return addr->Set(id); } bool inline CBitcoinAddressVisitor::operator()(const CNoDestination &id) const { return false; } /** A base58-encoded secret key */ class CBitcoinSecret : public CBase58Data { public: enum { PRIVKEY_ADDRESS = CBitcoinAddress::PUBKEY_ADDRESS + 128, PRIVKEY_ADDRESS_TEST = CBitcoinAddress::PUBKEY_ADDRESS_TEST + 128, }; void SetSecret(const CSecret& vchSecret, bool fCompressed) { assert(vchSecret.size() == 32); SetData(fTestNet ? PRIVKEY_ADDRESS_TEST : PRIVKEY_ADDRESS, &vchSecret[0], vchSecret.size()); if (fCompressed) vchData.push_back(1); } CSecret GetSecret(bool &fCompressedOut) { CSecret vchSecret; vchSecret.resize(32); memcpy(&vchSecret[0], &vchData[0], 32); fCompressedOut = vchData.size() == 33; return vchSecret; } bool IsValid() const { bool fExpectTestNet = false; switch(nVersion) { case PRIVKEY_ADDRESS: break; case PRIVKEY_ADDRESS_TEST: fExpectTestNet = true; break; default: return false; } return fExpectTestNet == fTestNet && (vchData.size() == 32 || (vchData.size() == 33 && vchData[32] == 1)); } bool SetString(const char* pszSecret) { return CBase58Data::SetString(pszSecret) && IsValid(); } bool SetString(const std::string& strSecret) { return SetString(strSecret.c_str()); } CBitcoinSecret(const CSecret& vchSecret, bool fCompressed) { SetSecret(vchSecret, fCompressed); } CBitcoinSecret() { } }; #endif
[ "isaiasherrero@gmail.com" ]
isaiasherrero@gmail.com
2dc8323d4293547d2fa25336263fc0162e8072a7
7bc26aa43584a978506e31b170c5ffc6d470cfd6
/LANChat/aboutsetwidget.cpp
cd4eba291d38a62810dfe595858cbfc43020183c
[]
no_license
mAndisan/turbo-guide
dac56227f64626908c5300e24e7476867c7e5451
cbd3f1293d190a0f516fc6e6033212c8b7f8465f
refs/heads/master
2021-08-24T06:05:45.294464
2017-12-08T10:02:01
2017-12-08T10:02:01
112,831,739
1
0
null
null
null
null
UTF-8
C++
false
false
571
cpp
#include "aboutsetwidget.h" aboutSetWidget::aboutSetWidget(QWidget *parent) : QWidget(parent) { ui.setupUi(this); //setStyleSheet("background-color:white;"); ui.label_gitLink->setOpenExternalLinks(true); //ui.label_gitLink->setText("<a href = https://github.com/mAndisan/turbo-guide>https://github.com/mAndisan/turbo-guide</a>"); ui.label_gitLink->setText(QString::fromLocal8Bit("<style> a {text-decoration:none} </style> <a href = https://github.com/mAndisan/turbo-guide>https://github.com/mAndisan/turbo-guide</a>")); } aboutSetWidget::~aboutSetWidget() { }
[ "xuxuan@zhinengguo.com" ]
xuxuan@zhinengguo.com
4c856f3ff35c500aaad97ac7e2d294dc24ad8b49
04899c4620f640922cfddc6f12c3393043c4ff60
/AnKi/Gr/Utils/StackGpuAllocator.h
afcb439f357255e9867f6ee777d014afe4ec4647
[ "BSD-2-Clause", "BSD-3-Clause" ]
permissive
galek/anki-3d-engine-1
51c3d56b8aeaf6773216749d95e0326aa75978de
48f9806364d35a12a53508b248e26c597188b542
refs/heads/master
2021-11-25T06:47:32.120582
2021-10-24T19:33:05
2021-10-24T19:33:21
59,970,766
0
0
null
2016-05-30T00:57:00
2016-05-30T00:57:00
null
UTF-8
C++
false
false
2,240
h
// Copyright (C) 2009-2021, Panagiotis Christopoulos Charitos and contributors. // All rights reserved. // Code licensed under the BSD License. // http://www.anki3d.org/LICENSE #pragma once #include <AnKi/Gr/Common.h> namespace anki { // Forward class StackGpuAllocatorChunk; /// @addtogroup graphics /// @{ /// The user defined output of an allocation. class StackGpuAllocatorMemory { }; /// The user defined methods to allocate memory. class StackGpuAllocatorInterface { public: virtual ~StackGpuAllocatorInterface() { } /// Allocate memory. Should be thread safe. virtual ANKI_USE_RESULT Error allocate(PtrSize size, StackGpuAllocatorMemory*& mem) = 0; /// Free memory. Should be thread safe. virtual void free(StackGpuAllocatorMemory* mem) = 0; /// If the current chunk of the linear allocator is of size N then the next chunk will be of size N*scale+bias. virtual void getChunkGrowInfo(F32& scale, PtrSize& bias, PtrSize& initialSize) = 0; virtual U32 getMaxAlignment() = 0; }; /// The output of an allocation. class StackGpuAllocatorHandle { friend class StackGpuAllocator; public: StackGpuAllocatorMemory* m_memory = nullptr; PtrSize m_offset = 0; explicit operator Bool() const { return m_memory != nullptr; } }; /// Linear based allocator. class StackGpuAllocator { public: StackGpuAllocator() = default; StackGpuAllocator(const StackGpuAllocator&) = delete; // Non-copyable ~StackGpuAllocator(); StackGpuAllocator& operator=(const StackGpuAllocator&) = delete; // Non-copyable void init(GenericMemoryPoolAllocator<U8> alloc, StackGpuAllocatorInterface* iface); /// Allocate memory. ANKI_USE_RESULT Error allocate(PtrSize size, StackGpuAllocatorHandle& handle); /// Reset all the memory chunks. Not thread safe. void reset(); StackGpuAllocatorInterface* getInterface() const { ANKI_ASSERT(m_iface); return m_iface; } private: using Chunk = StackGpuAllocatorChunk; GenericMemoryPoolAllocator<U8> m_alloc; StackGpuAllocatorInterface* m_iface = nullptr; Chunk* m_chunkListHead = nullptr; Atomic<Chunk*> m_crntChunk = {nullptr}; Mutex m_lock; F32 m_scale = 0.0; PtrSize m_bias = 0; PtrSize m_initialSize = 0; U32 m_alignment = 0; }; /// @} } // end namespace anki
[ "godlike@ancient-ritual.com" ]
godlike@ancient-ritual.com
640c1ea0d987cfe4795fa7e0df79aaae09a3c89d
e9dd938342eb5b9027b7eb5c89678e44623899c6
/hackerrank/C++/CompileTest.cc
bdc721c8d1e7d8dfa7f5c6dae06bc44ebeb51a42
[]
no_license
Mike-Stupich/technical-interview-training
4209b5730bfd4acafd1a67f3788e708d4136cb41
d86d18c8553ac4b60dbd9a38d3df16542b091ba5
refs/heads/master
2020-04-16T13:14:59.240343
2019-07-19T22:32:37
2019-07-19T22:32:37
165,617,756
0
0
null
null
null
null
UTF-8
C++
false
false
101
cc
#include <iostream> using namespace std; int main(){ cout << "HelloWorld" <<endl; return 0; }
[ "mike.stupich@gmail.com" ]
mike.stupich@gmail.com
e433bb38d059ae8b3ea18e60e057533f053e2d9b
ea9604cc5eada05fdfba5b0bc54a4eb10527eff0
/header/BinaryTreeNode.hpp
855fad31c2cbda725630f3c32e9c09960758dec3
[]
no_license
h9uest/InterviewCpp
5e9c467d363980baf7410d2bc454aded2a7a7fae
312f63744a8ecdce47ffb200123802d815472f61
refs/heads/master
2021-01-10T11:02:05.996284
2016-01-24T00:35:24
2016-01-24T00:35:24
50,264,800
0
0
null
null
null
null
UTF-8
C++
false
false
649
hpp
#ifndef _BinaryTreeNode_HPP_ #define _BinaryTreeNode_HPP_ template<typename T> struct BinaryTreeNode { BinaryTreeNode<T> *Left; BinaryTreeNode<T> *Right; T Value; BinaryTreeNode(); BinaryTreeNode(T value); BinaryTreeNode(T value, BinaryTreeNode<T> *left, BinaryTreeNode<T> *right); }; template<typename T> BinaryTreeNode<T>::BinaryTreeNode() { } template<typename T> BinaryTreeNode<T>::BinaryTreeNode(T value) { Value = value; Left = nullptr; Right = nullptr; } template<typename T> BinaryTreeNode<T>::BinaryTreeNode(T value, BinaryTreeNode<T> *left, BinaryTreeNode<T> *right) { Value = value; Left = left; Right = right; } #endif
[ "h9uest@gmail.com" ]
h9uest@gmail.com
4dcc73c13a8cedd356c36e09d89378ef55a9d666
4108ce3f198fc3f78ac65e5cd9bb4763a73eff14
/TYRANT/CMakeFiles/TYRANT.dir/MinSizeRel/cmake_pch.hxx
938552e2a514042edf867ba3d83fa2f556b330ec
[]
no_license
JTLee-GameWizard/TYRANT
704229b1ac6ff39024b067e2d065f75f6b0d6925
9a540bb30171f17678ea3101007e88f1b484602c
refs/heads/master
2023-08-17T07:32:50.814159
2021-09-21T05:35:26
2021-09-21T05:35:26
336,840,725
0
0
null
null
null
null
UTF-8
C++
false
false
149
hxx
/* generated by CMake */ #pragma system_header #ifdef __cplusplus #include "E:/Dev/TYRANT_ENGINE/TYRANT/include/TYRANT/pch.h" #endif // __cplusplus
[ "wujoshuagamedev@gmail.com" ]
wujoshuagamedev@gmail.com
de26623be1f211a9dfa680626de81de1f68083fd
da8c4077151f06a210e161c54b8bc3b97097ff61
/알고리즘/Backjoon/for문/2741_N찍기.cpp
6a9ef099355817757fe903e190dae7615a64ff4a
[]
no_license
welshimeat/Self_Study
79a02f4320dc68c1aa30974ce716b36dc1019278
d21decf5530d729f02be19c5355337a1da18cde6
refs/heads/master
2021-04-24T03:05:24.964874
2021-03-12T16:29:00
2021-03-12T16:29:00
250,065,414
0
0
null
null
null
null
UTF-8
C++
false
false
129
cpp
#include <stdio.h> int main(){ int num; scanf("%d", &num); for(int i=1; i<=num; i++) printf("%d\n", i); return 0; }
[ "kimsw1726@naver.com" ]
kimsw1726@naver.com
2613ea551f18fab3d6b3568995ae0286720777d4
a234566aa09841f5c9bec644a12372ba8b08fbe0
/06/include/log.h
bf2026da473dd9c59e7700689d5e5b6bd787f1be
[]
no_license
pfaco/ees_cpp
efc70f3224435b284dec95e8f9ff1c610a62678f
e60d3b999ff370ce446333052e3af7b35fa3fed4
refs/heads/master
2023-03-06T10:11:20.465566
2021-02-11T22:10:25
2021-02-11T22:10:25
312,292,291
4
0
null
null
null
null
UTF-8
C++
false
false
648
h
#pragma once #include <fmt/format.h> namespace ees { template<typename ...Args> void log(std::string_view fmt_str, Args ...args) { fmt::print(fmt_str, args...); } template<typename ...Args> void info(std::string_view fmt_str, Args ...args) { log(fmt::format("info: {}", fmt::format(fmt_str, args...))); } template<typename ...Args> void warn(std::string_view fmt_str, Args ...args) { log(fmt::format("warn: {}", fmt::format(fmt_str, args...))); } template<typename ...Args> void error(std::string_view fmt_str, Args ...args) { log(fmt::format("error: {}", fmt::format(fmt_str, args...))); } }
[ "paulo.faco@eletraenergy.com" ]
paulo.faco@eletraenergy.com
1c5e282cf7d29ec3ff7d9ef6627a2e1fa947579b
07e6fc323f657d1fbfc24f861a278ab57338b80a
/cpp/sketches_SDL/Molecular/test_RARFFarr.cpp
dd947cb04181b2c0cc0a1844617ac8db4afa60aa
[ "MIT" ]
permissive
ProkopHapala/SimpleSimulationEngine
99cf2532501698ee8a03b2e40d1e4bedd9a12609
47543f24f106419697e82771289172d7773c7810
refs/heads/master
2022-09-05T01:02:42.820199
2022-08-28T10:22:41
2022-08-28T10:22:41
40,007,027
35
4
null
null
null
null
UTF-8
C++
false
false
13,680
cpp
#include <stdlib.h> #include <stdio.h> #include <string.h> #include <vector> #include <math.h> #include <SDL2/SDL.h> #include <SDL2/SDL_opengl.h> #include "Draw.h" #include "Draw3D.h" #include "Solids.h" #include "fastmath.h" #include "Vec3.h" #include "Mat3.h" #include "VecN.h" /* #include "Multipoles.h" #include "PotentialFlow.h" #include "grids3D.h" #include "MultipoleGrid.h" */ #include "AppSDL2OGL_3D.h" #include "testUtils.h" #include "SDL_utils.h" #include "Plot2D.h" #include "Draw3D_Molecular.h" //#include "MMFF.h" //#include "RARFF.h" //#include "RARFF2.h" #include "RARFFarr.h" #include "QEq.h" #define R2SAFE 1.0e-8f // ============= This is From LIB ReactiveFF.cpp // /home/prokop/git/ProbeParticleModel_OclPy3/cpp/ReactiveFF.cpp // ============= Global Variables std::vector<RigidAtomType*> atomTypes; RARFF2arr ff; QEq qeq; // ============= Functions template< typename FF> int pickBond( FF ff, Vec3d& ray0, const Vec3d& hRay, double R ){ double tmin = 1e+300; int imin = -1; for(int ia=0; ia<ff.natom; ia++){ if(ff.ignoreAtoms)if(ff.ignoreAtoms[ia])continue; int nb = ff.types[ia]->nbond; for(int j=0; j<nb; j++){ int i = ia*N_BOND_MAX + j; Vec3d pbond = ff.bondPos(i,1.0); double ti = raySphere( ray0, hRay, R, pbond ); //printf( "atom %i t %g %g hRay(%g,%g,%g) ps(%g,%g,%g) \n", i, ti, tmin, hRay.x,hRay.y,hRay.z, ps[i].x, ps[i].y, ps[i].z ); //printf( "atom %i t %g %g %g ray0(%g,%g,%g) ps(%g,%g,%g) \n", i, ti, R, tmin, ray0.x,ray0.y,ray0.z, ps[i].x, ps[i].y, ps[i].z ); if(ti<tmin){ imin=i; tmin=ti; } } } return imin; } /* int insertAtomType( int nbond, int ihyb, double rbond0, double aMorse, double bMorse, double c6, double R2vdW, double Epz ){ RigidAtomType* atyp = new RigidAtomType(); atomTypes.push_back( atyp ); //RigidAtomType& atyp = atomTypes.back(); atyp->nbond = nbond; // number bonds atyp->rbond0 = rbond0; atyp->aMorse = aMorse; atyp->bMorse = bMorse; atyp->Epz = Epz; atyp->c6 = c6; atyp->R2vdW = R2vdW; printf("insertAtomType %i %i %g %g %g %g %g ", nbond, ihyb, rbond0, aMorse, bMorse, c6, R2vdW ); switch(ihyb){ case 0: atyp->bh0s = (Vec3d*)sp1_hs; printf("sp1\n"); break; case 1: atyp->bh0s = (Vec3d*)sp2_hs; printf("sp2\n"); break; case 2: atyp->bh0s = (Vec3d*)sp3_hs; printf("sp3\n"); break; }; return atomTypes.size()-1; } template<typename Func> void numDeriv( Vec3d p, double d, Vec3d& f, Func func){ double d_=d*0.5; Vec3d p0=p; p.x=p0.x+d_; f.x = func(p); p.x-=d; f.x-=func(p); p.x+=d_; p.y=p0.y+d_; f.y = func(p); p.y-=d; f.y-=func(p); p.y+=d_; p.z=p0.z+d_; f.z = func(p); p.z-=d; f.z-=func(p); p.z+=d_; f.mul(1/d); } */ class TestAppRARFF: public AppSDL2OGL_3D { public: //RigidAtom atom1; // type1,type2, typH2O; RigidAtomType typeList [4]; //RigidAtomType* typeList_[3]; RigidAtomType* curType=0; CapType capTypes[2]; Quat4i capsBrush; bool bBlockAddAtom=false; int ipicked = -1; Vec3d ray0; Vec3d mouse_p0; int ogl_sph=0; const char* workFileName="data/work.rff"; Plot2D plot1; bool bRun = true; int perFrame = 100; int fontTex; virtual void draw (); virtual void drawHUD(); //virtual void mouseHandling( ); virtual void eventHandling ( const SDL_Event& event ); virtual void keyStateHandling( const Uint8 *keys ); TestAppRARFF( int& id, int WIDTH_, int HEIGHT_ ); }; TestAppRARFF::TestAppRARFF( int& id, int WIDTH_, int HEIGHT_ ) : AppSDL2OGL_3D( id, WIDTH_, HEIGHT_ ) { fontTex = makeTextureHard( "common_resources/dejvu_sans_mono_RGBA_pix.bmp" ); {RigidAtomType& typ=typeList[0]; // C-sp2 //typeList_[0]=&typ; typ.id = 0; typ.nbond = 3; // number bonds typ.rbond0 = 1.2/2; typ.aMorse = 1.0; typ.bMorse = -0.7; typ.bh0s = (Vec3d*)sp2_hs; typ.print(); //exit(0); } {RigidAtomType& typ=typeList[1]; // C-sp3 //typeList_[1]=&typ; typ.id = 1; typ.nbond = 4; // number bonds typ.rbond0 = 1.5/2; typ.aMorse = 1.0; typ.bMorse = -0.7; typ.bh0s = (Vec3d*)sp3_hs; typ.print(); } {RigidAtomType& typ=typeList[2]; // H2O //typeList_[2]=&typ; //typ.name = "O"; strcpy(typ.name, "O"); typ.id = 2; typ.nbond = 4; typ.rbond0 = 2.9/2; typ.aMorse = 1.0; typ.bMorse = -0.7; typ.bh0s = (Vec3d*)sp3_hs; typ.print(); } {RigidAtomType& typ=typeList[3]; // H2O //typeList_[2]=&typ; //typ.name = "O"; strcpy(typ.name, "O"); typ.id = 3; typ.nbond = 3; typ.rbond0 = 2.9/2; typ.aMorse = 1.0; typ.bMorse = -0.7; typ.bh0s = (Vec3d*)sp2_hs; typ.print(); } //curType = &typeList[3]; //curType = &typeList[0]; curType = &typeList[1]; {CapType& typ=capTypes[1]; // C-sp3 typ.id = 1; typ.rbond0 = 1.0; strcpy(typ.name, "H"); } //capsBrush.set(1,1,-1,-1); //capsBrush.set(1,1,1,1); capsBrush.set(-1,-1,-1,-1); //capsBrush.set(0,0,0,0); ff.capTypeList = capTypes; ff.typeList = typeList; ff.bRepelCaps = false; // ignore caps .... good e.g. for water ff.bDonorAcceptorCap = true; /* srand(0); //srand(2); int nat = 12; ff.realloc(nat); for(int i=0; i<nat; i++){ if(randf()>0.5){ ff.types[i]=&type1; }else{ ff.types[i]=&type2; } ff.apos [i].fromRandomBox((Vec3d){-5.0,-5.0,-1.0},(Vec3d){5.0,5.0,1.0}); ff.qrots[i].setRandomRotation(); } ff.cleanAux(); RigidAtomType pairType; pairType.combine(type1,type1); printf(" >>> pairType: <<<<\n"); pairType.print(); ff.projectBonds(); ff.pairEF( 0, 1, 3,3, pairType ); //exit(0); */ //int nat=1; int nat=10; ff.realloc( nat, 100 ); for(int i=0; i<nat; i++){ //if(randf()>0.5){ ff.types[i]=&type1; }else{ ff.types[i]=&type2; } ff.types[i]=curType; ff.apos [i].fromRandomBox((Vec3d){-5.0,-5.0,-1.0},(Vec3d){5.0,5.0,1.0}); ff.qrots[i].setRandomRotation(); ((Quat4i*)ff.bondCaps)[i]=capsBrush; } ff.apos [0]=Vec3dZero; ff.qrots[0]=Quat4dIdentity; ff.cleanAux(); //ff.resize(15); //ff.tryResize( ); /* ogl_sph = glGenLists(1); glNewList(ogl_sph, GL_COMPILE); //Draw3D::drawSphere_oct( 3, 1.0, (Vec3d){0.0,0.0,0.0} ); Draw3D::drawSphere_oct( 3, 0.2, (Vec3d){0.0,0.0,0.0} ); glEndList(); */ Draw3D::makeSphereOgl( ogl_sph, 3, 0.25 ); } void TestAppRARFF::draw(){ //printf( " ==== frame %i \n", frameCount ); glClearColor( 1.0f, 1.0f, 1.0f, 1.0f ); glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); glEnable(GL_DEPTH_TEST); glDisable( GL_LIGHTING ); //if( ff.tryResize( 5, 100, 10) ); // ---------- Simulate //bRun = false; perFrame = 10; if(bRun){ for(int i=0; i<perFrame; i++){ ff.cleanAtomForce(); ff.projectBonds(); ff.interEF(); if(ipicked>=0){ Vec3d f = getForceSpringRay( ff.apos[ipicked], (Vec3d)cam.rot.c, ray0, -1.0 ); ff.aforce[ipicked].add( f ); } //for(int i=0; i<ff.natom; i++){ ff.aforce[i].add( getForceHamakerPlane( ff.apos[i], {0.0,0.0,1.0}, -3.0, 0.3, 2.0 ) );} //ff.applyForceHarmonic1D( Vec3dZ, 0.0, -30.1); ff.applyForceHarmonic1D( Vec3dZ, 0.0, -1.0); //ff.applyForceHamacker(true, -5.0, 10.0, 2.0 ); ff.evalTorques(); ff.moveMDdamp(0.05, 0.9); } }else{ if(ipicked>=0){ Vec3d dpos = ray0 - ff.apos[ipicked]; dpos.makeOrthoU( (Vec3d)cam.rot.c ); ff.apos[ipicked].add(dpos); } } if( frameCount>10 ){ //bRun=0; //exit(0); } ray0 = (Vec3d)(cam.rot.a*mouse_begin_x + cam.rot.b*mouse_begin_y); Draw3D::drawPointCross( ray0, 0.1 ); if(ipicked>=0) Draw3D::drawLine( ff.apos[ipicked], ray0); // ---------- Draw glColor3f(0.0,0.0,0.0); double fsc = 0.1; double tsc = 0.1; //printf( "ff.natom %i \n", ff.natom ); for(int ia=0; ia<ff.natom; ia++){ if(ff.ignoreAtoms[ia])continue; glColor3f(0.3,0.3,0.3); Draw3D::drawShape( ogl_sph, ff.apos[ia], Mat3dIdentity ); for(int j=0; j<ff.types[ia]->nbond; j++){ int i=ia*N_BOND_MAX+j; Vec3d pb = ff.bondPos( i ); //printf( "bondCaps[%i] %i\n", i, ff.bondCaps[i] ); if( ff.bondCaps[i]>=0 ){ glColor3f(1.0,0.0,0.0); } else{ glColor3f(0.0,0.0,0.0); } Draw3D::drawLine( ff.apos[ia] , pb ); glColor3f(0.0,1.0,0.0); Draw3D::drawVecInPos( ff.fbonds[i]*fsc, pb ); //glColor3f(0.0,0.0,0.0); Draw3D::drawVecInPos( ff.hbonds[i], ff.apos[i] ); //glColor3f(0.0,1.0,0.0); Draw3D::drawVecInPos( ff.fbonds[io]*fsc, ff.apos[i]+ff.hbonds[io] ); } }; Draw3D::drawAxis( 1.0); }; void TestAppRARFF::drawHUD(){ glTranslatef( 100.0,100.0,0.0 ); glScalef ( 10.0,10.00,1.0 ); plot1.view(); } void TestAppRARFF::keyStateHandling( const Uint8 *keys ){ if( keys[ SDL_SCANCODE_R ] ){ if(ipicked>=0){ //Mat3d rot; Quat4d qrot; qrot.f=(Vec3d)cam.rot.c*0.01; qrot.normalizeW(); ff.qrots[ipicked].qmul(qrot); ff.projectAtomBons(ipicked); } } AppSDL2OGL_3D::keyStateHandling( keys ); }; void TestAppRARFF::eventHandling ( const SDL_Event& event ){ //printf( "NonInert_seats::eventHandling() \n" ); Quat4i* caps = &capsBrush; if(ipicked>=0) caps=((Quat4i*)ff.bondCaps)+ipicked; switch( event.type ){ case SDL_KEYDOWN : switch( event.key.keysym.sym ){ case SDLK_p: first_person = !first_person; break; case SDLK_o: perspective = !perspective; break; case SDLK_KP_0: caps->array[0]*=-1; break; case SDLK_KP_1: caps->array[1]*=-1; break; case SDLK_KP_2: caps->array[2]*=-1; break; case SDLK_KP_3: caps->array[3]*=-1; break; case SDLK_KP_MULTIPLY: caps->mul(-1); printf("capsBrush(%i,%i,%i,%i)\n", caps->x,caps->y,caps->z,caps->w ); break; case SDLK_l: ff.load(workFileName); bRun=false; break; case SDLK_k: ff.save(workFileName); break; case SDLK_x: ff.saveXYZ("data/RARFF_out.xyz"); break; case SDLK_SPACE: bRun = !bRun; break; //case SDLK_r: world.fireProjectile( warrior1 ); break; } break; case SDL_MOUSEBUTTONDOWN: switch( event.button.button ){ case SDL_BUTTON_LEFT:{ int ip = pickParticle( ray0, (Vec3d)cam.rot.c, 0.5, ff.natom, ff.apos, ff.ignoreAtoms ); bBlockAddAtom=false; if( ip>=0){ if(ipicked==ip){ ipicked=-1; bBlockAddAtom=true; printf("inv\n"); } else { ipicked=ip; printf("set\n"); } }else{ ipicked=-1; } mouse_p0 = (Vec3d)( cam.rot.a*mouse_begin_x + cam.rot.b*mouse_begin_y ); printf( "LMB DOWN picked %i/%i bblock %i \n", ipicked,ip, bBlockAddAtom ); }break; case SDL_BUTTON_RIGHT:{ ipicked = pickParticle( ray0, (Vec3d)cam.rot.c, 0.5, ff.natom, ff.apos, ff.ignoreAtoms ); printf( "remove atom %i \n", ipicked ); ff.ignoreAtoms[ ipicked ] = true; }break; } break; case SDL_MOUSEBUTTONUP: switch( event.button.button ){ case SDL_BUTTON_LEFT: printf( "LMB UP picked %i bblock %i \n", ipicked, bBlockAddAtom ); if( (ipicked==-1)&&(!bBlockAddAtom) ){ Vec3d mouse_p = (Vec3d)( cam.rot.a*mouse_begin_x + cam.rot.b*mouse_begin_y ); Vec3d dir = mouse_p-mouse_p0; if(dir.norm2()<1e-6){ dir=(Vec3d)cam.rot.b; }; int ib = pickBond( ff, mouse_p0, (Vec3d)cam.rot.c, 0.5 ); if(ib>=0){ printf( "add atom to bond %i of atom %i \n", ib%N_BOND_MAX, ib/N_BOND_MAX ); Vec3d p0 = ff.bondPos(ib, 2.0 ); //ff.inserAtom( {nbBrush,4,4}, mouse_p0, dir, (Vec3d)cam.rot.b ); //ff.inserAtom( &type1, (const int[]){0,0,0,0}, p0, dir, (Vec3d)cam.rot.b ); int ia = ff.inserAtom( curType, (int*)&capsBrush, p0, ff.hbonds[ib]*-1, dir ); ff.projectAtomBons(ia); bRun = 0; } //ipicked = -1; } break; case SDL_BUTTON_RIGHT: ipicked = -1; break; } break; }; AppSDL2OGL::eventHandling( event ); } // ===================== MAIN TestAppRARFF* thisApp; int main(int argc, char *argv[]){ SDL_Init(SDL_INIT_VIDEO); SDL_GL_SetAttribute(SDL_GL_SHARE_WITH_CURRENT_CONTEXT, 1); //SDL_SetRelativeMouseMode( SDL_TRUE ); int junk; thisApp = new TestAppRARFF( junk , 800, 600 ); thisApp->loop( 1000000 ); return 0; }
[ "ProkopHapala@gmail.com" ]
ProkopHapala@gmail.com
5a02094fe73d809801f17db247eb9d21aa508609
89192ddb742eade527ec73bc61358a059a8bc466
/evita/spellchecker/hunspell_engine.cc
123151297dc0bd6262539773f34f0928371ddd02
[]
no_license
blockspacer/evita
d419c110e3efec5537468fce11b46eb892876592
881173c8dc37b180b92755a775d753aaa63b244c
refs/heads/master
2020-09-14T20:37:56.121935
2018-03-31T12:58:29
2018-03-31T12:58:29
null
0
0
null
null
null
null
UTF-8
C++
false
false
4,464
cc
// Copyright (c) 1996-2014 Project Vogue. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include <windows.h> #include <string> #include <utility> #include "evita/spellchecker/hunspell_engine.h" #include "base/logging.h" #include "base/strings/utf_string_conversions.h" #include "base/synchronization/lock.h" #include "common/win/scoped_handle.h" #include "third_party/hunspell/src/hunspell/hunspell.hxx" namespace spellchecker { namespace { // Maximum length of words we actually check. // 64 is the observed limits for OSX system checker. const size_t kMaxCheckedLen = 64; // Maximum length of words we provide suggestions for. // 24 is the observed limits for OSX system checker. const size_t kMaxSuggestLen = 24; static_assert(kMaxCheckedLen <= size_t(MAXWORDLEN), "MaxCheckedLen too long"); static_assert(kMaxSuggestLen <= kMaxCheckedLen, "MaxSuggestLen too long"); // Max number of dictionary suggestions. const int kMaxSuggestions = 5; } // namespace ////////////////////////////////////////////////////////////////////// // // HunspellEngine::Dictionary // class HunspellEngine::Dictionary final { public: Dictionary(); ~Dictionary(); bool is_valid() const { return is_valid_; } const uint8_t* data() const { return data_.data(); } size_t size() const { return data_.size(); } private: static base::string16 GetFileName(); bool is_valid_; std::vector<uint8_t> data_; DISALLOW_COPY_AND_ASSIGN(Dictionary); }; HunspellEngine::Dictionary::Dictionary() : is_valid_(false) { auto const file_name = GetFileName(); common::win::scoped_handle file( ::CreateFileW(file_name.c_str(), GENERIC_READ, FILE_SHARE_READ, nullptr, OPEN_EXISTING, FILE_FLAG_SEQUENTIAL_SCAN, nullptr)); if (!file) { PLOG(ERROR) << "CreateFile " << file_name << " failed"; return; } BY_HANDLE_FILE_INFORMATION info; if (!::GetFileInformationByHandle(file.get(), &info)) { PLOG(ERROR) << "GetFileInformationByHandle failed"; return; } DCHECK(!info.nFileSizeHigh); data_.resize(info.nFileSizeLow); DWORD read; if (!::ReadFile(file.get(), &data_[0], static_cast<DWORD>(data_.size()), &read, nullptr)) { PLOG(ERROR) << "ReadFile failed"; return; } is_valid_ = true; } HunspellEngine::Dictionary::~Dictionary() {} base::string16 HunspellEngine::Dictionary::GetFileName() { base::string16 file_name(MAX_PATH, '?'); auto length_with_zero = ::ExpandEnvironmentStrings( L"%LOCALAPPDATA%/Google/Chrome/User Data/en-US-7-1.bdic", &file_name[0], static_cast<DWORD>(file_name.size())); file_name.resize(length_with_zero - 1); return file_name; } ////////////////////////////////////////////////////////////////////// // // HunspellEngine // HunspellEngine::HunspellEngine() : lock_(new base::Lock()) {} HunspellEngine::~HunspellEngine() {} // spellchecker::SpellingEngine bool HunspellEngine::CheckSpelling(const base::string16& word_to_check) { DCHECK(!word_to_check.empty()); if (!EnsureInitialized()) return true; std::string utf8_word_to_check(base::UTF16ToUTF8(word_to_check)); if (utf8_word_to_check.size() > kMaxCheckedLen) return true; return hunspell_->spell(utf8_word_to_check.c_str()) != 0; } bool HunspellEngine::EnsureInitialized() { if (hunspell_) return true; base::AutoLock lock_scope(*lock_); if (dictionary_) return dictionary_->is_valid(); dictionary_.reset(new Dictionary()); if (!dictionary_->is_valid()) return false; hunspell_.reset(new Hunspell(dictionary_->data(), dictionary_->size())); return true; } std::vector<base::string16> HunspellEngine::GetSpellingSuggestions( const base::string16& wrong_word) { DCHECK(!wrong_word.empty()); if (!EnsureInitialized()) return std::vector<base::string16>(); std::string utf8_wrong_word(base::UTF16ToUTF8(wrong_word)); char** utf8_suggestions = nullptr; auto const num_suggestions = hunspell_->suggest(&utf8_suggestions, utf8_wrong_word.c_str()); std::vector<base::string16> suggestions; for (auto i = 0; i < num_suggestions; ++i) { auto const utf8_suggestion = utf8_suggestions[i]; if (i < kMaxSuggestions) suggestions.push_back(base::UTF8ToUTF16(utf8_suggestion)); ::free(utf8_suggestion); } if (utf8_suggestions) ::free(utf8_suggestions); return std::move(suggestions); } } // namespace spellchecker
[ "eval1749@gmail.com" ]
eval1749@gmail.com
0bdf47724391deb5c2126cbf1c175771fb4eb4fa
f318d716af6fe0c333d7facf1253a361a56ea820
/data/messages_handler.cpp
1d80c236eca539d6c5ab36558d88e6475acd2d6d
[]
no_license
alesanu/dronolab-stm32
00f9de68efea05b0ad5ab7783e962744285de862
d90015a7acee6d64c1d526719370ce5979c13984
refs/heads/master
2021-01-17T17:55:42.859386
2014-09-14T05:05:39
2014-09-14T05:05:39
null
0
0
null
null
null
null
UTF-8
C++
false
false
10,716
cpp
#include "messages_handler.h" #include <data/datastore.h> #include <driver/ffprotocol/ffp_sender.h> #include <singleton.h> namespace Messages { /** Macro to generate generic MessageHandler class implementation ** Here an example of the code generated DRONOLAB_DECLARE_MESSAGE_HANDLER_IMPLEMENTATION(RcChannel); RcChannelHandler::RcChannelHandler { Singleton::get()->RcChannelMessageEntry.handler = this; } **/ #define DRONOLAB_DECLARE_MESSAGE_HANDLER_IMPLEMENTATION(_Name) \ _Name##Handler::_Name##Handler() \ { Singleton::get()->_Name##MessageEntry.handler = this; } \ DRONOLAB_DECLARE_MESSAGE_HANDLER_IMPLEMENTATION(RcChannel); void RcChannelHandler::serialize(FFPSender& sender, Snapshot& snapshot) { sender << Singleton::get()->RcChannelMessageEntry; sender << snapshot.get(DataStore::RC_THROTTLE); sender << snapshot.get(DataStore::RC_ROLL); sender << snapshot.get(DataStore::RC_PITCH); sender << snapshot.get(DataStore::RC_YAW); sender << snapshot.get(DataStore::RC_MANUAL); sender << snapshot.get(DataStore::RC_KILL); sender << endtrame; } DRONOLAB_DECLARE_MESSAGE_HANDLER_IMPLEMENTATION(UCommands); void UCommandsHandler::serialize(FFPSender& sender, Snapshot& snapshot) { sender << Singleton::get()->UCommandsMessageEntry; sender << snapshot.get(DataStore::CMD_U1); sender << snapshot.get(DataStore::CMD_U2); sender << snapshot.get(DataStore::CMD_U3); sender << snapshot.get(DataStore::CMD_U4); sender << snapshot.get(DataStore::CMD_ROLL); sender << snapshot.get(DataStore::CMD_PITCH); sender << endtrame; } DRONOLAB_DECLARE_MESSAGE_HANDLER_IMPLEMENTATION(IMUData); void IMUDataHandler::serialize(FFPSender& sender, Snapshot& snapshot) { sender << Singleton::get()->IMUDataMessageEntry; sender << snapshot.get(DataStore::ROLL); sender << snapshot.get(DataStore::PITCH); sender << snapshot.get(DataStore::YAW); sender << snapshot.get(DataStore::DOT_ROLL); sender << snapshot.get(DataStore::DOT_PITCH); sender << snapshot.get(DataStore::DOT_YAW); sender << snapshot.get(DataStore::ACCEL_X); sender << snapshot.get(DataStore::ACCEL_Y); sender << snapshot.get(DataStore::ACCEL_Z); sender << endtrame; } //Should NOT BE CALLED BY THIS !!!!!! DRONOLAB_DECLARE_MESSAGE_HANDLER_IMPLEMENTATION(EstimatedInsPosition); void EstimatedInsPositionHandler::serialize(FFPSender& sender, Snapshot& snapshot) { sender << Singleton::get()->EstimatedInsPositionMessageEntry; sender << snapshot.get(DataStore::INS_ESTIMATED_X); sender << snapshot.get(DataStore::INS_ESTIMATED_Y); sender << snapshot.get(DataStore::INS_ESTIMATED_Z); sender << snapshot.get(DataStore::INS_ESTIMATED_VX); sender << snapshot.get(DataStore::INS_ESTIMATED_VY); sender << snapshot.get(DataStore::INS_ESTIMATED_VZ); sender << endtrame; //@todo Remove this after debug .... Singleton::get()->console << " HELL NO SENDING POSITION OF INS NOT IN THE PROCESS HELL !!!! \n\r"; } DRONOLAB_DECLARE_MESSAGE_HANDLER_IMPLEMENTATION(MotorSpeed); void MotorSpeedHandler::serialize(FFPSender& sender, Snapshot& snapshot) { sender << Singleton::get()->MotorSpeedMessageEntry; sender << snapshot.get(DataStore::M1); sender << snapshot.get(DataStore::M2); sender << snapshot.get(DataStore::M3); sender << snapshot.get(DataStore::M4); sender << endtrame; } DRONOLAB_DECLARE_MESSAGE_HANDLER_IMPLEMENTATION(Watchdog); void WatchdogHandler::serialize(FFPSender& sender, Snapshot& snapshot) { sender << Singleton::get()->WatchdogMessageEntry << (char) (snapshot.get_watchdogs()) << endtrame; } DRONOLAB_DECLARE_MESSAGE_HANDLER_IMPLEMENTATION(BatteryStatus); void BatteryStatusHandler::serialize(FFPSender& sender, Snapshot& snapshot) { // @todo } DRONOLAB_DECLARE_MESSAGE_HANDLER_IMPLEMENTATION(EchoPose); void EchoPoseHandler::serialize(FFPSender& sender, Snapshot& snapshot) { sender << Singleton::get()->EchoPoseMessageEntry; sender << snapshot.get(DataStore::PC_CURRENT_X); sender << snapshot.get(DataStore::PC_CURRENT_Y); sender << snapshot.get(DataStore::PC_CURRENT_Z); sender << snapshot.get(DataStore::PC_CURRENT_YAW); sender << snapshot.get(DataStore::PC_TARGET_X); sender << snapshot.get(DataStore::PC_TARGET_Y); sender << snapshot.get(DataStore::PC_TARGET_Z); sender << snapshot.get(DataStore::PC_TARGET_YAW); sender << snapshot.get(DataStore::PC_MOTOR_ON); sender << snapshot.get(DataStore::PC_GRAB_ON); sender << snapshot.get(DataStore::PC_RELEASE_ON); sender << snapshot.get(DataStore::GAIN_K1); sender << snapshot.get(DataStore::GAIN_K2); sender << snapshot.get(DataStore::GAIN_LAMBDA); sender << snapshot.get(DataStore::GAIN_K1_P); sender << snapshot.get(DataStore::GAIN_K2_P); sender << snapshot.get(DataStore::GAIN_LAMBDA_P); sender << endtrame; } DRONOLAB_DECLARE_MESSAGE_HANDLER_IMPLEMENTATION(EchoInsCorrection); void EchoInsCorrectionHandler::serialize(FFPSender& sender, Snapshot& snapshot) { sender << Singleton::get()->EchoInsCorrectionMessageEntry; sender << snapshot.get(DataStore::INS_CORRECTION_X); sender << snapshot.get(DataStore::INS_CORRECTION_Y); sender << snapshot.get(DataStore::INS_CORRECTION_Z); sender << snapshot.get(DataStore::INS_CORRECTION_VX); sender << snapshot.get(DataStore::INS_CORRECTION_VY); sender << snapshot.get(DataStore::INS_CORRECTION_VZ); sender << endtrame; } DRONOLAB_DECLARE_MESSAGE_HANDLER_IMPLEMENTATION(DebugFloat); void DebugFloatHandler::serialize(FFPSender& sender, Snapshot& snapshot) { sender << Singleton::get()->DebugFloatMessageEntry; sender << snapshot.get(DataStore::DEBUG_0); sender << snapshot.get(DataStore::DEBUG_1); sender << snapshot.get(DataStore::DEBUG_2); sender << snapshot.get(DataStore::DEBUG_3); sender << snapshot.get(DataStore::DEBUG_4); sender << endtrame; } DRONOLAB_DECLARE_MESSAGE_HANDLER_IMPLEMENTATION(DatastoreTimestamp); void DatastoreTimestampHandler::serialize(FFPSender& sender, Snapshot& snapshot) { sender << Singleton::get()->DatastoreTimestampMessageEntry; sender << snapshot.time; sender << endtrame; } DRONOLAB_DECLARE_MESSAGE_HANDLER_IMPLEMENTATION(RcTaskMonitoring); void RcTaskMonitoringHandler::serialize(FFPSender& sender, Snapshot& snapshot) { sender << Singleton::get()->RcTaskMonitoringMessageEntry; sender << snapshot.get(DataStore::RC_AVRG_EXEC_US); sender << snapshot.get(DataStore::RC_AVRG_OFFSET_US); sender << snapshot.get(DataStore::RC_AVRG_PERIOD_US); sender << endtrame; } DRONOLAB_DECLARE_MESSAGE_HANDLER_IMPLEMENTATION(ImuTaskMonitoring); void ImuTaskMonitoringHandler::serialize(FFPSender& sender, Snapshot& snapshot) { sender << Singleton::get()->ImuTaskMonitoringMessageEntry; sender << snapshot.get(DataStore::IMU_AVRG_EXEC_US); sender << snapshot.get(DataStore::IMU_AVRG_OFFSET_US); sender << snapshot.get(DataStore::IMU_AVRG_PERIOD_US); sender << snapshot.get(DataStore::IMU_AVRG_ANG_RECEP_US); sender << snapshot.get(DataStore::IMU_AVRG_ACC_RECEP_US); sender << snapshot.get(DataStore::IMU_SUM_RECEIVING_US); sender << endtrame; } DRONOLAB_DECLARE_MESSAGE_HANDLER_IMPLEMENTATION(CtrlAttTaskMonitoring); void CtrlAttTaskMonitoringHandler::serialize(FFPSender& sender, Snapshot& snapshot) { sender << Singleton::get()->CtrlAttTaskMonitoringMessageEntry; sender << snapshot.get(DataStore::CTRL_ATT_AVRG_EXEC_US); sender << snapshot.get(DataStore::CTRL_ATT_AVRG_OFFSET_US); sender << snapshot.get(DataStore::CTRL_ATT_AVRG_PERIOD_US); sender << endtrame; } DRONOLAB_DECLARE_MESSAGE_HANDLER_IMPLEMENTATION(CtrlPosTaskMonitoring); void CtrlPosTaskMonitoringHandler::serialize(FFPSender& sender, Snapshot& snapshot) { sender << Singleton::get()->CtrlPosTaskMonitoringMessageEntry; sender << snapshot.get(DataStore::CTRL_POS_AVRG_EXEC_US); sender << snapshot.get(DataStore::CTRL_POS_AVRG_EXEC_US); sender << snapshot.get(DataStore::CTRL_POS_AVRG_EXEC_US); sender << endtrame; } DRONOLAB_DECLARE_MESSAGE_HANDLER_IMPLEMENTATION(ObcTaskMonitoring); void ObcTaskMonitoringHandler::serialize(FFPSender& sender, Snapshot& snapshot) { sender << Singleton::get()->ObcTaskMonitoringMessageEntry; sender << snapshot.get(DataStore::OBC_AVRG_EXEC_US); sender << snapshot.get(DataStore::OBC_AVRG_OFFSET_US); sender << snapshot.get(DataStore::OBC_AVRG_PERIOD_US); sender << snapshot.get(DataStore::OBC_SUM_RECEIVING_US); sender << snapshot.get(DataStore::OBC_AVRG_SENDING_US); sender << endtrame; } /* DRONOLAB_DECLARE_MESSAGE_HANDLER_IMPLEMENTATION(TelemetryTaskMonitoring); void TelemetryTaskMonitoringHandler::serialize(FFPSender& sender, Snapshot& snapshot) { sender << Singleton::get()->TelemetryTaskMonitoringMessageEntry; sender << snapshot.get(DataStore::TEL_AVRG_EXEC_US); sender << snapshot.get(DataStore::TEL_AVRG_OFFSET_US); sender << snapshot.get(DataStore::TEL_AVRG_PERIOD_US); sender << endtrame; } */ DRONOLAB_DECLARE_MESSAGE_HANDLER_IMPLEMENTATION(InsTaskMonitoring); void InsTaskMonitoringHandler::serialize(FFPSender& sender, Snapshot& snapshot) { sender << Singleton::get()->InsTaskMonitoringMessageEntry; sender << snapshot.get(DataStore::INS_AVRG_EXEC_US); sender << snapshot.get(DataStore::INS_AVRG_EXEC_US); sender << snapshot.get(DataStore::INS_AVRG_EXEC_US); sender << endtrame; } DRONOLAB_DECLARE_MESSAGE_HANDLER_IMPLEMENTATION(FirmwareVersion); void FirmwareVersionHandler::serialize(FFPSender& sender, Snapshot& snapshot) { sender << Singleton::get()->FirmwareVersionMessageEntry; sender << snapshot.get(DataStore::FIRMWARE_VERSION); sender << endtrame; } //@todo : Finish Parameters module !!! /* DRONOLAB_DECLARE_MESSAGE_HANDLER_IMPLEMENTATION(SendDefaultParameters); void SendDefaultParametersHandler::serialize(FFPSender& sender, Snapshot& snapshot) { sender << Singleton::get()->SendDefaultParametersMessageEntry; for (int i = 0; i < Singleton::get()->parameters.LAST_ENUM_PARAM; i++) sender << Singleton::get()->parameters.default_.params[i]; sender << endtrame; } DRONOLAB_DECLARE_MESSAGE_HANDLER_IMPLEMENTATION(SendLiveParameters); void SendLiveParametersHandler::serialize(FFPSender& sender, Snapshot& snapshot) { sender << Singleton::get()->SendLiveParametersMessageEntry; for (int i = 0; i < Singleton::get()->parameters.LAST_ENUM_PARAM; i++) sender << Singleton::get()->parameters.live.params[i]; sender << endtrame; } DRONOLAB_DECLARE_MESSAGE_HANDLER_IMPLEMENTATION(SendFlashParameters); void SendFlashParametersHandler::serialize(FFPSender& sender, Snapshot& snapshot) { sender << Singleton::get()->SendFlashParametersMessageEntry; for(int i=0; i<Singleton::get()->parameters.LAST_ENUM_PARAM; i++) sender << Singleton::get()->parameters.flash_param_->params[i]; sender << endtrame; } */ #undef DRONOLAB_DECLARE_MESSAGE_HANDLER_IMPLEMENTATION } // namespace Message
[ "liambeguin@gmail.com" ]
liambeguin@gmail.com
96ff24d1b54a275de3e022727bcbbbe8034c434f
bb123142f4a4e2a74adfa246c39c93c549f1bd5d
/cpp/AwayExtensionsAnimateCC/include/RessourcePalette.h
40b08ebf6f85d72b543fa7f9e4a63182ea72cf88
[]
no_license
awaytools/AwayExtensions-FlashPro
a6c98fe276956850ff3b0edb6ef76a5edd6a32ca
3fcb0b895ad4165b53553d9419775b633f74b4b7
refs/heads/master
2020-04-06T07:01:07.957536
2017-10-01T22:05:08
2017-10-01T22:05:08
24,890,956
9
1
null
2014-10-30T19:50:12
2014-10-07T13:17:43
C++
UTF-8
C++
false
false
4,659
h
/************************************************************************* * ADOBE CONFIDENTIAL * ___________________ * * Copyright [2013] Adobe Systems Incorporated * All Rights Reserved. * * NOTICE: All information contained herein is, and remains * the property of Adobe Systems Incorporated and its suppliers, * if any. The intellectual and technical concepts contained * herein are proprietary to Adobe Systems Incorporated and its * suppliers and are protected by all applicable intellectual * property laws, including trade secret and copyright laws. * Dissemination of this information or reproduction of this material * is strictly forbidden unless prior written permission is obtained * from Adobe Systems Incorporated. **************************************************************************/ /** * @file Publisher.h * * @brief This file contains declarations for a Publisher plugin. */ #ifndef RESSOURCE_PALLETTE_H_ #define RESSOURCE_PALLETTE_H_ #include <vector> #include "Version.h" #include "FCMTypes.h" #include "FCMPluginInterface.h" #include "Exporter/Service/IResourcePalette.h" #include "Exporter/Service/ITimelineBuilder.h" #include "Exporter/Service/ITimelineBuilderFactory.h" #include "Publisher/IPublisher.h" #include "FillStyle/ISolidFillStyle.h" #include "FillStyle/IGradientFillStyle.h" #include "FillStyle/IBitmapFillStyle.h" #include "FrameElement/IClassicText.h" #include "FrameElement/ITextStyle.h" #include "Exporter/Service/IFrameCommandGenerator.h" #include "AWDTimelineWriter.h" #include "awd_project.h" /* -------------------------------------------------- Forward Decl */ #ifdef _DEBUG #include <stdlib.h> #include <crtdbg.h> #ifndef DBG_NEW #define DBG_NEW new ( _NORMAL_BLOCK , __FILE__ , __LINE__ ) #define new DBG_NEW #endif #endif // _DEBUG using namespace FCM; using namespace Publisher; using namespace Exporter::Service; namespace AwayJS { class CPublisher; class ResourcePalette; class TimelineBuilder; class TimelineBuilderFactory; class ITimelineWriter; } namespace DOM { namespace Service { namespace Shape { FORWARD_DECLARE_INTERFACE(IPath); } }; }; namespace AwayJS { class ResourcePalette : public IResourcePalette, public FCMObjectBase { public: BEGIN_INTERFACE_MAP(ResourcePalette, AWAYJS_PLUGIN_VERSION) INTERFACE_ENTRY(IResourcePalette) END_INTERFACE_MAP void* test_shape; virtual FCM::Result _FCMCALL AddSymbol( FCM::U_Int32 resourceId, FCM::StringRep16 pName, Exporter::Service::PITimelineBuilder pTimelineBuilder); virtual FCM::Result _FCMCALL AddShape( FCM::U_Int32 resourceId, DOM::FrameElement::PIShape pShape); virtual FCM::Result _FCMCALL AddSound( FCM::U_Int32 resourceId, DOM::LibraryItem::PIMediaItem pLibItem); virtual FCM::Result _FCMCALL AddBitmap( FCM::U_Int32 resourceId, DOM::LibraryItem::PIMediaItem pLibItem); virtual FCM::Result _FCMCALL AddClassicText( FCM::U_Int32 resourceId, DOM::FrameElement::PIClassicText pClassicText); virtual FCM::Result _FCMCALL HasResource( FCM::U_Int32 resourceId, FCM::Boolean& hasResource); ResourcePalette(); ~ResourcePalette(); void Init(AnimateToAWDEncoder* awd_encoder); void Clear(); FCM::Result HasResource( const std::string& name, FCM::Boolean& hasResource); private: FCM::Result ExportStrokeStyle(FCM::PIFCMUnknown pStrokeStyle); FCM::Result ExportSolidStrokeStyle(DOM::StrokeStyle::ISolidStrokeStyle* pSolidStrokeStyle); FCM::Result CreateImageFileName(DOM::ILibraryItem* pLibItem, std::string& name); FCM::Result CreateSoundFileName(DOM::ILibraryItem* pLibItem, std::string& name); FCM::Result GetFontInfo(DOM::FrameElement::ITextStyle* pTextStyleItem, std::string& name,FCM::U_Int16 fontSize); FCM::Result HasFancyStrokes(DOM::FrameElement::PIShape pShape, FCM::Boolean& hasFancy); FCM::Result ConvertStrokeToFill( DOM::FrameElement::PIShape pShape, DOM::FrameElement::PIShape& pNewShape); private: AnimateToAWDEncoder* awd_converter; std::vector<FCM::U_Int32> m_resourceList; FCM::U_Int32 m_imageFileNameLabel; FCM::U_Int32 m_soundFileNameLabel; std::vector<std::string> m_resourceNames; }; }; #endif // PUBLISHER_H_
[ "80prozent@differentdesign.de" ]
80prozent@differentdesign.de
9b9edc6ea0ee860819f5093c79d3f2e1bbca3695
38b9daafe39f937b39eefc30501939fd47f7e668
/tutorials/2WayCouplingOceanWave3D/EvalResults180628-Eta/73.8/alpha.water
35d79c3577abe115d6f4d8f652241d08f2b5cbc4
[]
no_license
rubynuaa/2-way-coupling
3a292840d9f56255f38c5e31c6b30fcb52d9e1cf
a820b57dd2cac1170b937f8411bc861392d8fbaa
refs/heads/master
2020-04-08T18:49:53.047796
2018-08-29T14:22:18
2018-08-29T14:22:18
null
0
0
null
null
null
null
UTF-8
C++
false
false
160,674
water
/*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | | \\ / O peration | Version: 3.0.1 | | \\ / A nd | Web: www.OpenFOAM.org | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ FoamFile { version 2.0; format ascii; class volScalarField; location "73.8"; object alpha.water; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // dimensions [0 0 0 0 0 0 0]; internalField nonuniform List<scalar> 21420 ( 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00002 1.00002 1.00002 1.00002 1.00002 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00002 1.00002 1.00002 1.00002 1.00002 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00002 1.00002 1.00002 1.00002 1.00002 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00002 1.00002 1.00002 1.00002 1.00002 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00003 1.00003 1.00003 1.00003 1.00003 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00003 1.00003 1.00003 1.00003 1.00003 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00002 1.00002 1.00002 1.00002 1.00002 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00005 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00002 1.00002 1.00002 1.00002 1.00002 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00002 1.00002 1.00002 1.00002 1.00002 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00002 1.00002 1.00002 1.00002 1.00002 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00004 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00003 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00002 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0.999999 0.999999 0.999999 0.999999 0.999998 0.999998 0.999998 0.999998 0.999998 0.999998 0.999998 0.999999 0.999999 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0.999999 0.999999 0.999999 0.999998 0.999997 0.999997 0.999996 0.999996 0.999998 0.999997 0.999997 0.999997 0.999998 0.999999 0.999999 0.999999 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0.999999 0.999998 0.999996 0.999993 0.999989 0.999983 0.999975 0.999964 0.999951 0.999939 0.999925 0.999917 0.999914 0.999911 0.99992 0.999952 0.999978 0.999988 0.999985 0.999984 0.999985 0.999988 0.999992 0.999993 0.999994 0.999995 0.999996 0.999997 0.999998 0.999999 0.999999 0.999999 1 1 1 1 1 1 1 1 1 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1 1 1 1 1 1 1 1 1 1 1 1 1 0.999999 0.999999 0.999999 0.999998 0.999998 0.999998 0.999998 0.999997 0.999997 0.999997 0.999998 0.999998 0.999998 0.999999 0.999999 0.999999 0.999998 0.999998 0.999998 0.999998 0.999998 0.999998 0.999998 0.999998 0.999998 0.999999 0.999999 0.999999 0.999999 0.999999 1 1 1 1 1 1 1 1 1 1 1 1 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0.999999 0.999999 0.999999 0.999999 0.999999 0.999999 0.999999 0.999999 1 0.999999 0.999999 0.999999 1 1 0.999999 0.999999 0.999999 0.999999 0.999999 0.999999 0.999999 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0.999999 0.999999 0.999999 0.999999 0.999998 0.999998 0.999998 0.999998 0.999998 0.999998 0.999998 0.999998 0.999998 0.999998 0.999998 0.999999 0.999999 0.999999 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0.999999 0.999835 0.999066 0.998325 0.997289 0.99658 0.995902 0.995747 0.996853 0.998753 0.999878 0.999931 0.999933 0.999936 0.999942 0.99996 0.999981 0.999981 0.999987 0.999994 0.999996 0.999998 0.999999 0.999999 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0.999999 0.999998 0.999992 0.999974 0.999927 0.999813 0.999556 0.999023 0.99798 0.996034 0.992658 0.987197 0.979139 0.968322 0.954776 0.939343 0.923904 0.910233 0.900483 0.895699 0.896684 0.902029 0.911441 0.924558 0.940919 0.95865 0.974956 0.988203 0.996964 0.999784 0.999816 0.999853 0.999896 0.999936 0.999965 0.999973 0.999979 0.999987 0.999994 0.999996 0.999998 0.999999 0.999999 1 1 1 1 1 1 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1 1 1 1 1 1 1 0.999999 0.999996 0.999987 0.999967 0.999921 0.999824 0.999638 0.999299 0.998763 0.997904 0.996709 0.995024 0.99299 0.990649 0.98814 0.985904 0.984085 0.982857 0.982528 0.98304 0.984261 0.985546 0.987272 0.989542 0.992096 0.994739 0.997137 0.998992 0.999912 0.999934 0.999927 0.999925 0.999929 0.99994 0.999956 0.999973 0.999982 0.999984 0.999987 0.999992 0.999996 0.999997 0.999998 0.999999 1 1 1 1 1 1 1 1 1 1 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1 1 1 1 1 1 1 1 1 1 1 1 1 0.999999 0.999998 0.999994 0.999986 0.999974 0.999963 0.999956 0.999945 0.99991 0.999729 0.999244 0.998985 0.999146 0.99948 0.999692 0.999814 0.999878 0.999907 0.999933 0.999993 0.999999 0.999998 0.999995 0.99999 0.999984 0.999977 0.999969 0.999966 0.999964 0.999966 0.999969 0.999972 0.999979 0.999987 0.99999 0.999991 0.999994 0.999996 0.999998 0.999998 0.999999 0.999999 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0.999999 0.999999 0.999998 0.999998 0.999998 0.999997 0.999996 0.999996 0.999995 0.999994 0.999993 0.999991 0.999989 0.999987 0.999984 0.999978 0.999972 0.999964 0.999949 0.99994 0.999953 0.999962 0.999974 0.999971 0.999957 0.999944 0.999936 0.999938 0.99995 0.999966 0.999977 0.999981 0.999989 0.999994 0.999996 0.999998 0.999999 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0.309114 0.265622 0.234017 0.213907 0.205167 0.20766 0.22217 0.24841 0.286419 0.336973 0.399715 0.475515 0.565738 0.667643 0.786529 0.913405 0.965965 0.976027 0.986444 0.998012 0.999673 0.999714 0.999819 0.999923 0.999948 0.999977 0.999989 0.999994 0.999998 0.999999 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0.999998 0.999993 0.999973 0.999904 0.99969 0.999068 0.99735 0.992692 0.981129 0.95631 0.909987 0.83459 0.737597 0.645298 0.562157 0.490119 0.429815 0.381753 0.34618 0.323264 0.312181 0.3114 0.319688 0.335586 0.360101 0.395277 0.443184 0.502949 0.571167 0.644739 0.72238 0.79944 0.859521 0.908708 0.949082 0.978876 0.996228 0.999478 0.999631 0.99979 0.999901 0.999937 0.999964 0.999985 0.999992 0.999996 0.999998 0.999999 1 1 1 1 1 1 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1.00001 1 1 1 1 1 1 1 0.999997 0.999988 0.999962 0.999891 0.999708 0.999264 0.998251 0.996002 0.991152 0.981441 0.964299 0.937438 0.89974 0.852921 0.800699 0.750941 0.70932 0.676616 0.651845 0.634445 0.624431 0.620745 0.622148 0.628401 0.639837 0.655319 0.674366 0.697252 0.723311 0.752861 0.784847 0.816107 0.846916 0.879224 0.912481 0.943927 0.970682 0.990004 0.999051 0.999643 0.999739 0.999845 0.999927 0.999955 0.999972 0.999986 0.999993 0.999996 0.999998 0.999999 1 1 1 1 1 1 1 1 1 1 1 1.00001 1.00001 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0.999998 0.999992 0.999976 0.999938 0.999847 0.999655 0.999264 0.998503 0.997064 0.994573 0.990333 0.983877 0.97443 0.960914 0.941875 0.915136 0.887035 0.866581 0.850818 0.834687 0.816957 0.800402 0.788298 0.782431 0.783586 0.790322 0.799886 0.812937 0.828175 0.844909 0.861597 0.879426 0.900009 0.92081 0.940723 0.95917 0.976547 0.99021 0.998338 0.999747 0.9998 0.999825 0.999889 0.999948 0.999971 0.999979 0.999989 0.999995 0.999997 0.999999 0.999999 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0.999999 0.999998 0.999996 0.999992 0.999984 0.999967 0.999931 0.999868 0.999757 0.999568 0.999267 0.99881 0.998162 0.997344 0.996407 0.995406 0.994392 0.993397 0.992395 0.991254 0.989811 0.987737 0.984637 0.979914 0.972335 0.960247 0.942922 0.925572 0.910064 0.896702 0.889334 0.891798 0.901471 0.913867 0.922609 0.935323 0.949709 0.968146 0.985683 0.998656 0.999588 0.999683 0.999829 0.999912 0.99995 0.999977 0.999989 0.999995 0.999998 0.999999 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2.19092e-05 7.59124e-06 2.44139e-06 1.46876e-06 5.57414e-07 2.46443e-07 9.05709e-12 6.86694e-14 3.26721e-14 2.22923e-16 9.88569e-15 6.66665e-14 4.79898e-08 2.06017e-05 0.000874714 0.0149886 0.118883 0.28509 0.47055 0.6711 0.882422 0.954995 0.98314 0.998997 0.999382 0.999731 0.999881 0.999937 0.999981 0.999991 0.999997 0.999999 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0.999998 0.999988 0.999949 0.999794 0.999204 0.996983 0.988394 0.959406 0.881571 0.72775 0.561133 0.406096 0.275173 0.181394 0.128292 0.0899412 0.0620502 0.0423081 0.0289191 0.020356 0.0150329 0.0121147 0.0108218 0.0105661 0.0112474 0.0124716 0.0143494 0.0175304 0.0228711 0.0314491 0.0449767 0.0658975 0.100241 0.158513 0.249095 0.3532 0.467451 0.590169 0.717149 0.827425 0.903827 0.961398 0.993764 0.999103 0.999519 0.999804 0.999896 0.999953 0.999982 0.999992 0.999997 0.999999 1 1 1 1 1 1 1 1 1.00001 1.00001 1.00001 1.00001 1.00001 1 1 1 1 1 1 1 1 1 0.999996 0.999984 0.999941 0.999805 0.999396 0.998211 0.994732 0.984063 0.954619 0.886726 0.763238 0.622804 0.492162 0.378413 0.28612 0.216845 0.169907 0.137784 0.113646 0.0957227 0.0825769 0.0731802 0.0670134 0.0633526 0.0618775 0.0634424 0.0674341 0.0731977 0.0810278 0.0913754 0.105151 0.124357 0.150346 0.185543 0.233174 0.293491 0.367787 0.455231 0.554464 0.661706 0.765539 0.845815 0.90886 0.960183 0.991654 0.999266 0.99957 0.999801 0.999907 0.99995 0.999978 0.99999 0.999996 0.999998 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0.999999 0.999994 0.999979 0.999935 0.999802 0.999457 0.998619 0.996554 0.991585 0.979933 0.95506 0.908446 0.831746 0.730779 0.632771 0.542457 0.459839 0.385853 0.326113 0.282097 0.245828 0.214992 0.190244 0.171902 0.158924 0.150721 0.148068 0.149662 0.154948 0.165165 0.180893 0.202295 0.229018 0.259134 0.295442 0.338829 0.388634 0.444274 0.507652 0.581862 0.662962 0.748372 0.825052 0.887208 0.93894 0.976415 0.996776 0.999484 0.999594 0.999781 0.999921 0.999955 0.999973 0.99999 0.999996 0.999998 0.999999 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0.999999 0.999999 0.999997 0.999993 0.999983 0.999961 0.999912 0.999798 0.999528 0.998845 0.997063 0.992422 0.98095 0.955987 0.908483 0.82884 0.730332 0.639369 0.557975 0.485629 0.420929 0.362239 0.30842 0.258357 0.211493 0.169169 0.131961 0.0979944 0.0689495 0.0477338 0.0349939 0.0255647 0.0203808 0.0227945 0.0276355 0.0355389 0.0513269 0.081294 0.133662 0.205459 0.299265 0.417198 0.552 0.710323 0.871367 0.93797 0.978868 0.998804 0.99936 0.999718 0.999876 0.999941 0.999982 0.999992 0.999998 0.999999 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 4.26862e-08 2.12317e-08 2.02931e-08 8.63e-09 2.02027e-09 2.57204e-10 5.36766e-14 2.37818e-14 6.16095e-17 9.96615e-19 1.04784e-19 7.80925e-15 4.44955e-16 3.75464e-17 6.1975e-16 3.47895e-14 7.06634e-14 2.53542e-06 0.000121758 0.00312593 0.0412564 0.230604 0.491141 0.780863 0.938897 0.986809 0.998741 0.999363 0.999811 0.999907 0.999968 0.99999 0.999997 0.999999 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0.999999 0.999997 0.999985 0.999927 0.999665 0.99849 0.992673 0.964272 0.858424 0.639865 0.413503 0.222224 0.117521 0.0563929 0.019305 0.00271829 0.000392646 0.000225874 0.000128227 7.19446e-05 6.7295e-05 0.000139873 0.000185832 0.000215361 0.000239218 0.00026446 0.000288346 0.000312324 0.000351167 0.000401044 0.000486163 0.000627697 0.000850005 0.0012033 0.00174832 0.0026742 0.00441932 0.00781994 0.0141144 0.0259249 0.0490753 0.0958998 0.190382 0.336031 0.508465 0.694085 0.846049 0.938408 0.989914 0.998759 0.999457 0.999794 0.999909 0.999969 0.999988 0.999996 0.999999 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0.999997 0.999984 0.999937 0.999769 0.999174 0.997062 0.988889 0.95714 0.856803 0.658774 0.450164 0.272269 0.157992 0.089174 0.0444282 0.0178188 0.00480944 0.000878189 0.000989994 0.00115137 0.00126347 0.00135789 0.00143681 0.00150506 0.00157587 0.00167184 0.00175423 0.00182212 0.00193587 0.00210689 0.00234372 0.00263083 0.00303826 0.00363553 0.00446162 0.00566926 0.0074691 0.0105146 0.0158086 0.0250191 0.0418413 0.0728475 0.12837 0.223403 0.353277 0.509699 0.679183 0.825156 0.918506 0.977728 0.998748 0.999353 0.999706 0.999881 0.999946 0.999981 0.999993 0.999998 0.999999 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0.999998 0.999992 0.99997 0.9999 0.999674 0.998986 0.996798 0.989705 0.967477 0.907985 0.78007 0.614511 0.45436 0.314628 0.207519 0.14074 0.093255 0.0607652 0.037731 0.023049 0.0148569 0.0103141 0.00741547 0.00592953 0.00506771 0.00446637 0.00427768 0.00425857 0.00432245 0.00441002 0.00451134 0.00486014 0.00540733 0.00614299 0.00717998 0.00861852 0.0107223 0.013486 0.0174793 0.0233954 0.0329085 0.048247 0.0733602 0.118016 0.194623 0.307353 0.439126 0.583061 0.733008 0.848525 0.927803 0.979173 0.998841 0.999392 0.99957 0.999867 0.999933 0.999971 0.999992 0.999997 0.999999 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0.999999 0.999998 0.999994 0.999987 0.999968 0.999919 0.999798 0.999465 0.998603 0.99611 0.987952 0.960823 0.883435 0.725315 0.54948 0.385196 0.246198 0.152514 0.102496 0.0675326 0.0427383 0.025464 0.0136901 0.00606373 0.00173397 5.77741e-05 4.05566e-05 2.76991e-05 2.14301e-05 2.2243e-05 3.63143e-05 3.95145e-05 4.12974e-05 4.22743e-05 3.73522e-05 4.20236e-05 4.59948e-05 4.84629e-05 6.64069e-05 9.64347e-05 0.00016306 0.000301166 0.000605012 0.00177726 0.00517023 0.0184187 0.075505 0.249779 0.48869 0.740488 0.922412 0.978906 0.998604 0.999354 0.999799 0.99991 0.999973 0.999991 0.999997 0.999999 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 6.56793e-10 2.05522e-10 1.63439e-10 4.94409e-11 5.36942e-12 4.69008e-14 1.34656e-14 3.54951e-17 9.01492e-20 2.07028e-22 4.19506e-25 3.58649e-26 5.55011e-24 4.49623e-22 3.39309e-20 1.08816e-18 2.15952e-17 5.0848e-16 5.28563e-15 7.30282e-14 7.95221e-07 4.28772e-05 0.0015316 0.02658 0.209683 0.54402 0.858951 0.964089 0.998145 0.999122 0.999699 0.999902 0.999968 0.999991 0.999998 0.999999 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0.999997 0.999986 0.999925 0.999596 0.997884 0.987419 0.928451 0.712393 0.431598 0.192401 0.0802307 0.020875 0.00124678 0.000587194 0.000269903 0.000105443 4.13279e-05 1.78701e-05 8.96664e-06 4.49629e-06 2.81391e-06 4.13088e-06 4.92146e-06 5.64626e-06 6.25811e-06 6.60547e-06 7.17058e-06 7.91024e-06 8.48772e-06 9.86536e-06 1.14637e-05 1.40319e-05 1.86352e-05 2.55397e-05 3.76944e-05 5.63824e-05 8.75248e-05 0.000143719 0.000246161 0.000421516 0.000721243 0.00129941 0.00251755 0.00532523 0.0123567 0.0307796 0.081285 0.21498 0.425939 0.663568 0.855079 0.956868 0.997342 0.999025 0.999672 0.999867 0.999957 0.999985 0.999996 0.999999 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0.999997 0.999986 0.999946 0.999785 0.99916 0.996579 0.983726 0.922597 0.722047 0.457203 0.229384 0.10372 0.034821 0.00477469 0.000597119 0.000295952 0.00013585 9.33146e-05 6.47335e-05 5.49306e-05 5.07273e-05 4.90976e-05 4.74919e-05 4.74093e-05 4.89618e-05 5.01875e-05 5.18455e-05 5.5077e-05 5.74704e-05 5.81963e-05 6.06766e-05 6.71313e-05 7.54027e-05 8.47063e-05 9.73094e-05 0.000117046 0.000145793 0.000186359 0.000240979 0.000330982 0.00048053 0.000721377 0.00117094 0.00198023 0.0034001 0.00646399 0.0135738 0.0312458 0.0766702 0.186642 0.375011 0.591012 0.795971 0.917966 0.983671 0.998617 0.999383 0.999775 0.999919 0.999972 0.999992 0.999998 0.999999 1 1 1 1 1 1 1 1 1 1 1 1 1 0.999997 0.99999 0.999966 0.999881 0.999595 0.998564 0.99467 0.977955 0.914173 0.739987 0.516026 0.311427 0.169001 0.0870329 0.036568 0.00991405 0.00118898 0.000981883 0.000872719 0.000448698 0.000288213 0.000240128 0.00058622 0.000748704 0.000741747 0.00059135 0.000401219 0.000246371 0.0001707 0.000147842 0.000145811 0.000144979 0.000144827 0.000149305 0.000163388 0.000184897 0.000214292 0.000263478 0.00032889 0.000404134 0.000507387 0.000659035 0.000924105 0.00130974 0.00194239 0.00322342 0.00564084 0.0105907 0.0217876 0.046055 0.103548 0.224709 0.402748 0.600701 0.787183 0.904642 0.974554 0.998576 0.999171 0.999602 0.999887 0.999946 0.999986 0.999996 0.999999 1 1 1 1 1 1 1 1 1 1 1 0.999999 0.999997 0.999992 0.999982 0.999956 0.999893 0.99972 0.99922 0.997733 0.992323 0.970328 0.886401 0.679814 0.443689 0.236701 0.119065 0.0523591 0.0151045 0.00106399 0.00036527 0.000186952 9.58526e-05 4.80348e-05 2.297e-05 1.00316e-05 3.79411e-06 2.43833e-06 1.89685e-06 1.37246e-06 1.32908e-06 9.9606e-07 7.94733e-07 7.4908e-07 4.77425e-07 4.33974e-07 4.64215e-07 2.82278e-07 3.49757e-07 3.72414e-07 2.71318e-07 3.67331e-07 3.97045e-07 6.08521e-07 1.08512e-06 1.36746e-06 4.15783e-06 9.90856e-06 2.02379e-05 9.75429e-05 0.000439558 0.00378636 0.0254664 0.170501 0.479785 0.794296 0.950023 0.99639 0.999079 0.999719 0.999903 0.999963 0.999992 0.999997 0.999999 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 9.20082e-12 2.70508e-12 1.29717e-12 3.03395e-13 4.22265e-14 1.50593e-14 3.75913e-17 9.09631e-20 2.11343e-22 4.45685e-25 8.30692e-28 5.0833e-30 5.21922e-28 7.61414e-26 1.93259e-23 1.01491e-21 3.24638e-20 1.1682e-18 3.82162e-17 1.7836e-16 1.19702e-14 4.19628e-14 8.39928e-14 6.45488e-06 0.000154269 0.00631436 0.0810703 0.397714 0.796636 0.954405 0.997287 0.999103 0.999706 0.999911 0.999976 0.999993 0.999999 1 1 1 1 1 1 1 1 1 1 1 1 0.999998 0.999988 0.999933 0.999631 0.997865 0.98472 0.899089 0.61668 0.297951 0.105739 0.0242116 0.00176667 0.000722763 0.000272185 9.46378e-05 3.93098e-05 1.66308e-05 5.98138e-06 2.17332e-06 8.10497e-07 3.5372e-07 1.56199e-07 1.40432e-07 1.43888e-07 1.54858e-07 1.7116e-07 1.85315e-07 1.97505e-07 2.05775e-07 2.3037e-07 2.40868e-07 2.83325e-07 3.45814e-07 4.18449e-07 5.67071e-07 7.62454e-07 1.13545e-06 1.71986e-06 2.70148e-06 4.51093e-06 7.64862e-06 1.34763e-05 2.35466e-05 4.28952e-05 8.3224e-05 0.000169664 0.000360451 0.00080764 0.00201067 0.00576674 0.0189581 0.0668248 0.226831 0.490052 0.764689 0.922359 0.991058 0.99863 0.999554 0.999843 0.999952 0.999986 0.999996 0.999999 1 1 1 1 1 1 1 1 1 0.999999 0.999996 0.999987 0.999953 0.999821 0.999281 0.996817 0.982735 0.901085 0.642699 0.335223 0.131998 0.0371741 0.00290389 0.000765863 0.000313461 9.69518e-05 3.77018e-05 2.61819e-05 1.42841e-05 6.88621e-06 3.32993e-06 2.07122e-06 1.68449e-06 1.62462e-06 1.50743e-06 1.36475e-06 1.38721e-06 1.44691e-06 1.45781e-06 1.5805e-06 1.70884e-06 1.69645e-06 1.66574e-06 1.7887e-06 2.00747e-06 2.25352e-06 2.5203e-06 2.98657e-06 3.73186e-06 4.95794e-06 6.51492e-06 9.11717e-06 1.3642e-05 2.09771e-05 3.65431e-05 6.33578e-05 9.9845e-05 0.000190548 0.000384638 0.000789965 0.00187137 0.00488751 0.0143809 0.0460445 0.149491 0.370392 0.630473 0.845581 0.95636 0.997393 0.999154 0.999677 0.999905 0.999963 0.999993 0.999998 1 1 1 1 1 1 1 1 0.999999 0.999998 0.999995 0.999987 0.999959 0.999868 0.999557 0.998393 0.993405 0.968185 0.851192 0.59124 0.323626 0.14513 0.0544314 0.0108065 0.00130983 0.0012597 0.000688262 0.000246189 9.28581e-05 5.91981e-05 4.52838e-05 1.51285e-05 3.56625e-06 2.17075e-06 1.04363e-05 5.31753e-05 8.63417e-05 8.40306e-05 6.98571e-05 4.19487e-05 1.67669e-05 5.67473e-06 4.81316e-06 4.60656e-06 4.45854e-06 4.25868e-06 4.25642e-06 4.61156e-06 5.1608e-06 6.44135e-06 8.34152e-06 1.05321e-05 1.3721e-05 1.83612e-05 2.69305e-05 3.78991e-05 5.6118e-05 9.84896e-05 0.000174123 0.000288493 0.000564129 0.00107426 0.00232118 0.00576246 0.0161948 0.049278 0.145219 0.342282 0.583144 0.804122 0.929687 0.99006 0.998867 0.999275 0.999799 0.999931 0.99998 0.999996 0.999999 1 1 1 1 1 1 0.999999 0.999998 0.999996 0.99999 0.999978 0.999948 0.999875 0.999672 0.999098 0.997255 0.989938 0.955623 0.810491 0.533289 0.261688 0.10631 0.0292033 0.00182958 0.000773346 0.000382407 0.000119182 4.58501e-05 1.89555e-05 7.72899e-06 3.38998e-06 1.47498e-06 6.11083e-07 2.28237e-07 1.00517e-07 6.46749e-08 4.63616e-08 3.03178e-08 2.71556e-08 1.91501e-08 1.40558e-08 1.24872e-08 7.34399e-09 6.51917e-09 6.46837e-09 3.61589e-09 4.43419e-09 4.08454e-09 2.81374e-09 3.78888e-09 3.62555e-09 4.97123e-09 8.09296e-09 8.60402e-09 2.50615e-08 5.49306e-08 8.22705e-08 3.80478e-07 9.81714e-07 6.12343e-06 2.898e-05 0.00021196 0.0037087 0.0392221 0.285566 0.664696 0.928627 0.990883 0.999007 0.999615 0.99991 0.999967 0.999991 0.999998 0.999999 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1.21842e-13 2.95107e-14 2.75576e-14 2.5181e-14 1.89576e-14 4.48381e-17 1.02939e-19 2.29332e-22 4.89727e-25 9.53073e-28 1.6441e-30 4.65567e-33 5.50876e-31 2.40001e-28 1.61576e-25 1.80803e-24 1.00024e-22 6.76321e-21 2.85117e-17 4.43581e-18 2.52924e-14 8.79155e-14 7.90247e-15 1.30846e-08 1.33469e-11 5.46948e-06 0.000127693 0.00264112 0.0558035 0.355431 0.762183 0.958096 0.997375 0.999174 0.999763 0.999929 0.999984 0.999996 0.999999 1 1 1 1 1 1 1 0.999999 0.999998 0.999989 0.999943 0.999688 0.998066 0.985432 0.891834 0.575667 0.23639 0.070109 0.00661241 0.00132188 0.000500204 0.000169555 6.24645e-05 2.26174e-05 7.18232e-06 2.65462e-06 1.03037e-06 3.40578e-07 1.13537e-07 3.69208e-08 1.40224e-08 5.42959e-09 4.59503e-09 4.33299e-09 4.55901e-09 5.06634e-09 5.38021e-09 5.72553e-09 5.59846e-09 6.36439e-09 6.47478e-09 7.65754e-09 9.7508e-09 1.12992e-08 1.55085e-08 2.05283e-08 3.09575e-08 4.80285e-08 7.63474e-08 1.31032e-07 2.16176e-07 3.7844e-07 6.68662e-07 1.2154e-06 2.3839e-06 4.9467e-06 1.07633e-05 2.47933e-05 6.3459e-05 0.000174282 0.000499815 0.00157557 0.00587036 0.0258083 0.117007 0.376143 0.687136 0.893277 0.982625 0.998386 0.999485 0.999843 0.999953 0.999988 0.999997 0.999999 0.999999 0.999999 0.999999 0.999999 0.999998 0.999997 0.999993 0.999982 0.999947 0.999821 0.999343 0.99721 0.984748 0.907422 0.627263 0.288891 0.095229 0.0150413 0.0015103 0.000657284 0.000181677 6.49608e-05 2.90635e-05 8.08877e-06 3.10635e-06 1.7439e-06 7.78927e-07 2.97357e-07 1.13482e-07 5.65842e-08 4.23836e-08 4.19921e-08 4.02193e-08 3.39442e-08 3.42354e-08 3.70918e-08 3.70224e-08 4.0402e-08 4.62505e-08 4.69805e-08 4.24015e-08 4.31469e-08 4.81343e-08 5.55516e-08 5.95253e-08 6.74288e-08 8.0724e-08 1.15683e-07 1.61247e-07 2.34137e-07 3.65036e-07 5.39391e-07 1.02689e-06 1.78506e-06 2.45599e-06 4.7079e-06 1.05089e-05 2.17814e-05 5.61885e-05 0.000145723 0.000378392 0.00109992 0.00356566 0.0134657 0.0551428 0.21429 0.498061 0.781682 0.935454 0.99455 0.998972 0.999503 0.999884 0.999961 0.99999 0.999997 0.999997 0.999997 0.999996 0.999997 0.999995 0.999993 0.999987 0.999975 0.99994 0.999835 0.999486 0.998236 0.992664 0.96228 0.814283 0.514269 0.22739 0.0797137 0.0145325 0.001944 0.00123099 0.000467112 0.000148851 8.58357e-05 4.4192e-05 1.24828e-05 3.96958e-06 2.33392e-06 1.70888e-06 3.14838e-07 5.96583e-08 1.03922e-07 1.30216e-07 1.94318e-06 5.87868e-06 6.46475e-06 5.9167e-06 3.77307e-06 1.35423e-06 2.37954e-07 1.79741e-07 1.78175e-07 1.74627e-07 1.57333e-07 1.36815e-07 1.3098e-07 1.29202e-07 1.4803e-07 1.96047e-07 2.57655e-07 3.5338e-07 4.90665e-07 7.42824e-07 9.40471e-07 1.24941e-06 2.30848e-06 4.53158e-06 6.90114e-06 1.41501e-05 2.60026e-05 5.55359e-05 0.000136462 0.000371556 0.00119469 0.00370461 0.0120895 0.0437879 0.159882 0.40916 0.688384 0.883633 0.975321 0.998402 0.999046 0.999677 0.999916 0.999975 0.999996 0.999996 0.999997 0.999997 0.999996 0.999995 0.999991 0.999985 0.999969 0.999933 0.999845 0.999621 0.998987 0.996918 0.988627 0.947231 0.768487 0.460652 0.193088 0.0595189 0.00580277 0.00179723 0.00106302 0.000219823 7.84616e-05 3.51413e-05 1.07305e-05 4.68914e-06 1.68647e-06 3.38948e-07 1.24139e-07 4.67345e-08 1.67695e-08 5.97669e-09 2.58921e-09 1.70079e-09 1.11044e-09 6.9557e-10 6.29942e-10 4.23564e-10 2.95803e-10 2.46832e-10 1.41533e-10 1.24875e-10 1.08626e-10 5.90184e-11 7.39569e-11 6.46638e-11 4.21442e-11 5.29988e-11 4.47024e-11 5.89986e-11 8.85818e-11 8.42765e-11 2.45511e-10 4.48608e-10 5.73828e-10 2.66408e-09 5.58813e-09 3.40379e-08 1.32346e-07 4.03336e-07 6.74636e-06 4.24153e-05 0.000596337 0.0141879 0.170734 0.571377 0.9047 0.982842 0.999052 0.999634 0.999895 0.999972 0.999992 0.999998 1 1 1 1 1 1 1 1 1 1 1 1 1 4.95674e-15 7.16654e-15 1.04761e-14 1.6475e-15 6.06547e-17 1.30551e-19 2.77124e-22 5.71579e-25 1.12891e-27 2.03954e-30 3.27848e-33 2.12057e-34 4.04541e-32 1.13738e-29 1.44494e-27 9.63792e-26 1.22507e-23 2.39877e-22 1.72011e-17 1.34694e-18 1.60585e-14 5.53305e-14 2.1452e-15 5.61448e-11 1.18761e-11 2.41363e-08 3.63356e-07 2.85127e-09 0.000192379 0.00277885 0.0475977 0.384944 0.78825 0.96161 0.997761 0.999277 0.999822 0.999951 0.99999 0.999998 1 1 1 1 0.999999 0.999996 0.999985 0.999935 0.999683 0.998241 0.987371 0.899344 0.577326 0.223994 0.0573702 0.00333416 0.00126185 0.000421323 0.000139851 5.17044e-05 1.634e-05 5.45983e-06 1.88105e-06 5.46397e-07 1.81089e-07 6.43556e-08 1.95248e-08 5.93276e-09 1.69889e-09 5.68999e-10 2.0196e-10 1.31263e-10 1.21644e-10 1.29961e-10 1.48686e-10 1.58212e-10 1.72582e-10 1.6202e-10 1.913e-10 1.86119e-10 2.22124e-10 2.9204e-10 3.13532e-10 4.30596e-10 5.47708e-10 8.33745e-10 1.27497e-09 1.93513e-09 3.39228e-09 5.79858e-09 9.93141e-09 1.70629e-08 3.13084e-08 6.19843e-08 1.316e-07 2.98724e-07 7.05767e-07 1.83204e-06 5.08347e-06 1.4983e-05 4.89744e-05 0.000172703 0.000643042 0.00266213 0.0135882 0.073521 0.301666 0.624927 0.86832 0.972225 0.998291 0.999427 0.999779 0.999916 0.999955 0.999974 0.999977 0.999977 0.999976 0.99997 0.999949 0.999895 0.999742 0.999246 0.997381 0.986964 0.921885 0.651572 0.30009 0.0908063 0.0106407 0.00147322 0.000642765 0.000168611 5.59587e-05 1.62888e-05 5.52872e-06 2.2217e-06 5.32472e-07 1.83199e-07 7.86531e-08 2.93514e-08 9.07359e-09 2.68874e-09 1.29806e-09 1.04114e-09 1.02153e-09 9.45716e-10 7.8494e-10 8.70529e-10 9.573e-10 9.16887e-10 1.07249e-09 1.34666e-09 1.31973e-09 1.07354e-09 1.10221e-09 1.23898e-09 1.42066e-09 1.38706e-09 1.50644e-09 1.73893e-09 2.71194e-09 3.79509e-09 5.46015e-09 8.98934e-09 1.31585e-08 2.84534e-08 4.99542e-08 6.05848e-08 1.0325e-07 2.47241e-07 5.43441e-07 1.492e-06 3.81467e-06 9.90545e-06 3.09513e-05 0.000104036 0.000360694 0.00130136 0.00532597 0.0264773 0.134878 0.424902 0.737402 0.915616 0.989282 0.998845 0.999322 0.999766 0.999909 0.999939 0.999955 0.999949 0.999952 0.999942 0.999917 0.999845 0.999682 0.999204 0.997519 0.991073 0.958549 0.797837 0.481037 0.194846 0.0568182 0.00617182 0.00198739 0.000904448 0.000237191 8.94451e-05 3.31491e-05 8.83947e-06 4.46209e-06 2.26303e-06 5.13604e-07 1.33776e-07 6.89974e-08 4.45648e-08 3.57022e-09 1.71507e-09 4.50692e-09 1.9912e-08 1.36104e-07 3.9393e-07 3.9958e-07 2.95945e-07 1.20442e-07 2.21572e-08 6.54392e-09 6.31166e-09 7.07002e-09 7.35049e-09 6.55965e-09 4.82733e-09 3.92584e-09 3.34812e-09 3.62844e-09 4.76887e-09 6.21007e-09 8.62075e-09 1.28643e-08 2.08844e-08 2.20378e-08 2.50694e-08 4.34354e-08 9.31977e-08 1.39803e-07 2.95643e-07 5.1768e-07 1.08416e-06 2.72838e-06 8.35289e-06 3.45572e-05 0.000124573 0.000372749 0.00111115 0.00379865 0.016213 0.0758094 0.289943 0.592705 0.842366 0.95911 0.997165 0.998783 0.999467 0.999873 0.999924 0.999944 0.999957 0.99995 0.999941 0.999915 0.999859 0.999731 0.999435 0.998647 0.996263 0.986979 0.94123 0.750477 0.431797 0.170563 0.0443458 0.00385309 0.0025981 0.00102127 0.000263435 9.72988e-05 1.87517e-05 6.22978e-06 2.6572e-06 8.45429e-07 4.96937e-07 2.22876e-07 2.10327e-08 4.88711e-09 1.63788e-09 4.98378e-10 1.8435e-10 7.45197e-11 5.14657e-11 3.02681e-11 1.86384e-11 1.62467e-11 1.04584e-11 7.35048e-12 4.89963e-12 3.30606e-12 3.13088e-12 2.20565e-12 1.53941e-12 1.73345e-12 1.36568e-12 1.12103e-12 1.3091e-12 1.10759e-12 1.2661e-12 1.2337e-12 1.33932e-12 3.08884e-12 4.20183e-12 6.14561e-12 2.21072e-11 4.53492e-11 2.30767e-10 7.49657e-10 2.52684e-09 3.02059e-08 1.36678e-07 7.2137e-07 2.05501e-05 0.00022648 0.00629191 0.10771 0.479445 0.870227 0.976076 0.998813 0.999651 0.999894 0.999976 0.999995 0.999999 1 1 1 1 1 1 1 1 1 1 1 1.4189e-15 1.83044e-16 8.27016e-17 9.35695e-18 1.9294e-19 3.81562e-22 7.51186e-25 1.43899e-27 2.63854e-30 4.44074e-33 6.67724e-36 2.855e-37 1.45278e-34 1.45555e-31 3.6171e-29 1.81686e-26 2.0653e-25 1.07744e-23 2.64695e-19 3.57876e-20 1.90513e-16 1.70815e-15 1.14915e-16 3.98783e-13 4.24845e-12 1.29415e-10 2.23585e-09 1.90546e-09 8.57607e-07 1.0353e-05 0.000148206 0.00472073 0.0623069 0.416345 0.808065 0.957589 0.998089 0.999393 0.999812 0.999963 0.999991 0.999997 0.999994 0.999987 0.999962 0.999879 0.999493 0.997674 0.985458 0.900016 0.592394 0.232008 0.0574951 0.00346222 0.00131826 0.000412988 0.000151073 4.93716e-05 1.50091e-05 5.34496e-06 1.5774e-06 4.81711e-07 1.5678e-07 4.17437e-08 1.24801e-08 4.05572e-09 1.1304e-09 3.14292e-10 8.40779e-11 3.19601e-11 1.96331e-11 1.92546e-11 2.25679e-11 2.6907e-11 3.24396e-11 3.72055e-11 3.76017e-11 3.7535e-11 4.00558e-11 4.04325e-11 4.3352e-11 4.65314e-11 4.69804e-11 5.05735e-11 5.30164e-11 6.1556e-11 7.28495e-11 8.78188e-11 1.22263e-10 1.92728e-10 2.98248e-10 4.65211e-10 8.39838e-10 1.64145e-09 3.45505e-09 7.89891e-09 1.86081e-08 4.98835e-08 1.42017e-07 4.27389e-07 1.41537e-06 5.09091e-06 1.97417e-05 8.17738e-05 0.00036295 0.00164774 0.00873677 0.0524326 0.251877 0.566465 0.831647 0.95109 0.995923 0.998903 0.999212 0.99958 0.99966 0.99968 0.999666 0.999584 0.999309 0.99853 0.995851 0.98428 0.928373 0.687758 0.338456 0.103857 0.01315 0.00204517 0.00079934 0.000194086 5.96598e-05 1.85136e-05 5.82572e-06 1.54464e-06 4.72098e-07 1.37728e-07 3.40414e-08 9.02463e-09 2.64e-09 7.99854e-10 2.66163e-10 1.4011e-10 9.61295e-11 8.5305e-11 8.60423e-11 8.55781e-11 8.60895e-11 8.73917e-11 8.96422e-11 9.17231e-11 9.39412e-11 1.00283e-10 9.74304e-11 9.33845e-11 9.35075e-11 9.56899e-11 9.84649e-11 9.52581e-11 9.85492e-11 1.03635e-10 1.32218e-10 1.55275e-10 1.97175e-10 2.94355e-10 4.00739e-10 9.01732e-10 1.50011e-09 1.54904e-09 2.44892e-09 5.8473e-09 1.27787e-08 3.66462e-08 9.38253e-08 2.45157e-07 7.95125e-07 2.7552e-06 1.01855e-05 3.97679e-05 0.000154376 0.000633029 0.00308433 0.017722 0.100053 0.364325 0.690037 0.890527 0.973869 0.997341 0.998601 0.998994 0.999341 0.999344 0.999374 0.999279 0.998948 0.998056 0.995519 0.985702 0.937258 0.765195 0.461909 0.186731 0.0510866 0.00547363 0.0021773 0.000809407 0.000204708 7.25595e-05 1.77923e-05 5.14116e-06 1.63152e-06 3.85587e-07 1.64189e-07 7.71225e-08 1.40972e-08 3.15681e-09 1.3622e-09 8.88192e-10 1.97096e-10 2.82454e-10 3.4627e-10 4.82529e-09 1.57299e-08 1.97315e-08 1.22234e-08 3.67769e-09 9.20807e-10 3.58074e-10 2.97636e-10 3.66997e-10 4.09732e-10 3.75014e-10 2.85252e-10 2.05514e-10 1.69268e-10 1.41175e-10 1.56888e-10 1.8306e-10 2.03885e-10 2.98764e-10 4.79992e-10 6.86956e-10 5.16396e-10 4.93284e-10 7.90918e-10 1.70737e-09 2.50583e-09 5.45673e-09 9.56321e-09 1.97461e-08 5.18087e-08 1.79225e-07 9.29e-07 3.87321e-06 1.23021e-05 3.54809e-05 0.000109279 0.000393976 0.00159907 0.00779142 0.0433948 0.215151 0.519215 0.797607 0.934322 0.989877 0.998076 0.998708 0.999038 0.999353 0.999288 0.999235 0.99905 0.9985 0.997197 0.993503 0.980529 0.926433 0.729934 0.418695 0.166485 0.0434467 0.0057319 0.00324034 0.00112295 0.000319481 0.000114675 2.65252e-05 8.40356e-06 1.63412e-06 6.12878e-07 2.00968e-07 6.68088e-08 4.85553e-08 2.51084e-08 2.88987e-09 3.45403e-10 1.63956e-10 3.9465e-11 6.97243e-12 2.82804e-12 1.73036e-12 9.00144e-13 8.05759e-13 7.17099e-13 5.70243e-13 6.86546e-13 9.20985e-13 4.33007e-13 3.22387e-13 1.50162e-13 9.2295e-14 9.98852e-14 6.41009e-14 6.34168e-14 6.8842e-14 5.76643e-14 7.36827e-14 5.70904e-14 7.13796e-14 1.35102e-13 1.02033e-13 1.75962e-13 3.51619e-13 4.55688e-13 1.74723e-12 3.61004e-12 1.42065e-11 1.53049e-10 3.94722e-10 3.43576e-09 5.35887e-08 3.03793e-07 7.23007e-06 8.82858e-05 0.00195834 0.0618668 0.381587 0.762404 0.963971 0.991816 0.999625 0.999904 0.999974 0.999988 0.999997 1 1 1 1 1 1 0.999996 0.976782 0.673198 1.57885e-17 1.73701e-18 6.29863e-19 5.13446e-20 6.25382e-22 1.14662e-24 2.09604e-27 3.73368e-30 6.36573e-33 9.99352e-36 1.40796e-38 8.00276e-39 7.17215e-36 8.39344e-33 7.63683e-30 4.73821e-27 1.60108e-26 2.44806e-24 5.87235e-22 4.01406e-21 4.4325e-18 1.84512e-17 1.10184e-17 1.0589e-14 9.10576e-15 4.64463e-13 9.39682e-12 1.65444e-13 7.74161e-09 3.64313e-08 1.35937e-07 3.09692e-05 0.000257261 0.00557721 0.0765501 0.405248 0.774211 0.933601 0.986697 0.999481 0.999732 0.999801 0.999712 0.999393 0.998241 0.993996 0.970738 0.852493 0.550957 0.223527 0.0611603 0.00384639 0.00135529 0.00044754 0.000170785 5.18832e-05 1.82925e-05 5.7642e-06 1.62321e-06 5.52529e-07 1.52614e-07 4.28381e-08 1.31087e-08 3.20755e-09 8.71005e-10 2.59745e-10 6.93023e-11 2.0228e-11 9.3116e-12 1.01197e-11 1.30825e-11 1.71725e-11 2.17963e-11 2.65445e-11 3.23141e-11 3.70995e-11 4.09502e-11 4.49053e-11 4.85899e-11 5.05189e-11 5.37897e-11 5.46595e-11 5.58979e-11 5.65179e-11 5.69574e-11 5.72158e-11 5.73406e-11 5.7631e-11 5.79939e-11 5.843e-11 5.89541e-11 6.11154e-11 7.01902e-11 8.87125e-11 1.33585e-10 2.4861e-10 5.2079e-10 1.39761e-09 3.82367e-09 1.14807e-08 3.8361e-08 1.41489e-07 5.66679e-07 2.37282e-06 1.09683e-05 5.0271e-05 0.000239269 0.00119596 0.00656485 0.0383884 0.193695 0.477384 0.74486 0.894362 0.964481 0.991384 0.994553 0.994686 0.994564 0.993018 0.987159 0.967272 0.889136 0.65797 0.351598 0.121668 0.0213335 0.00297533 0.0011443 0.000269463 7.37074e-05 2.30146e-05 7.22643e-06 2.0903e-06 6.08693e-07 1.49281e-07 4.11492e-08 1.04491e-08 2.49293e-09 6.2803e-10 2.00042e-10 1.05201e-10 8.44626e-11 9.61148e-11 8.5283e-11 8.13963e-11 8.41053e-11 8.54504e-11 8.55625e-11 8.69611e-11 8.93234e-11 9.15959e-11 9.20491e-11 9.23149e-11 9.27104e-11 9.36678e-11 9.3947e-11 9.40933e-11 9.41287e-11 9.41852e-11 9.4346e-11 9.45879e-11 9.48807e-11 9.52021e-11 9.55738e-11 9.60049e-11 9.64649e-11 1.00412e-10 1.12567e-10 1.10341e-10 1.28812e-10 2.1678e-10 3.74895e-10 1.00258e-09 2.38609e-09 5.83845e-09 1.92261e-08 6.97718e-08 2.79869e-07 1.13841e-06 4.1687e-06 1.72336e-05 9.09338e-05 0.000438731 0.00210241 0.0124696 0.0789703 0.305998 0.586112 0.815159 0.92187 0.969157 0.986762 0.989051 0.989468 0.988244 0.979988 0.959463 0.887743 0.690612 0.396948 0.16957 0.0490621 0.00667054 0.00280488 0.00102303 0.000226466 6.69276e-05 1.58832e-05 5.01582e-06 1.22359e-06 3.33659e-07 7.74636e-08 1.80634e-08 6.3622e-09 2.46161e-09 4.60618e-10 1.43324e-10 1.01227e-10 8.43425e-11 7.68784e-11 1.8917e-10 2.14842e-10 2.01051e-10 3.3541e-10 4.02321e-10 2.59664e-10 1.48833e-10 1.22583e-10 1.14197e-10 1.11137e-10 1.08037e-10 1.00289e-10 9.31418e-11 8.70537e-11 8.01312e-11 7.38689e-11 6.83864e-11 6.29269e-11 5.73776e-11 5.40237e-11 5.02449e-11 5.11225e-11 5.6663e-11 6.31307e-11 8.12659e-11 1.10847e-10 1.44902e-10 1.69799e-10 2.27949e-10 2.95388e-10 4.81874e-10 1.16015e-09 4.14452e-09 2.42778e-08 1.11686e-07 3.95184e-07 1.08791e-06 2.87207e-06 9.40588e-06 3.71766e-05 0.000183021 0.00100452 0.00536154 0.0295746 0.155602 0.429988 0.706445 0.871229 0.941886 0.973689 0.987681 0.987045 0.987407 0.985497 0.975157 0.945037 0.854475 0.649445 0.379034 0.161425 0.0470924 0.00876842 0.00436742 0.00165956 0.000473577 0.000136373 3.41248e-05 1.19852e-05 2.90001e-06 8.71388e-07 1.92123e-07 6.33751e-08 1.81936e-08 5.41056e-09 4.55104e-09 2.16158e-09 3.39795e-10 1.64355e-10 1.09923e-10 2.44892e-11 2.34711e-12 2.12623e-12 1.46671e-12 7.60415e-13 4.18652e-13 2.65798e-13 1.67765e-13 1.2376e-13 7.05619e-14 3.49358e-14 2.70561e-14 1.32798e-14 9.9625e-15 9.27626e-15 5.37536e-15 6.22397e-15 5.26382e-15 3.88926e-15 5.80624e-15 3.63882e-15 5.37366e-15 8.26418e-15 4.67501e-15 1.01791e-14 1.64554e-14 1.52511e-14 5.24017e-14 5.15678e-14 1.64716e-13 7.4417e-13 9.03834e-13 1.15697e-11 1.26283e-10 4.7295e-10 1.35246e-08 7.55554e-08 9.41301e-07 3.25272e-05 0.000478795 0.013109 0.203875 0.533749 0.829467 0.972214 0.988385 0.995238 0.998552 0.999964 1 0.999999 0.999871 0.964019 0.722788 0.41161 0.0844927 0.000776045 1.63717e-19 1.58968e-20 4.62984e-21 2.72927e-22 2.11465e-24 3.59122e-27 6.09044e-30 1.0079e-32 1.5967e-35 2.33585e-38 3.08078e-41 5.29856e-41 7.24171e-38 4.2158e-35 1.22606e-32 3.53148e-30 4.15977e-28 3.23489e-26 2.91794e-24 3.57395e-22 3.9566e-20 4.35932e-20 2.09271e-18 1.92048e-16 3.31346e-16 1.55988e-14 7.82525e-14 9.76356e-14 3.8724e-11 5.6533e-11 8.70129e-10 1.73588e-07 1.01692e-06 3.12652e-05 0.000376925 0.00460995 0.0582847 0.297598 0.585226 0.816477 0.925244 0.966344 0.968692 0.936316 0.833126 0.652998 0.403316 0.160607 0.0486807 0.00274926 0.00119583 0.000441694 0.000179008 5.87471e-05 2.22656e-05 6.52486e-06 2.22071e-06 6.70144e-07 1.76376e-07 5.71307e-08 1.48087e-08 3.83906e-09 1.103e-09 2.50068e-10 6.47291e-11 1.89092e-11 7.6009e-12 4.83001e-12 5.79314e-12 8.66632e-12 1.2707e-11 1.70466e-11 2.16678e-11 2.68189e-11 3.38119e-11 4.0423e-11 4.51808e-11 4.91464e-11 5.36967e-11 5.45311e-11 5.97014e-11 6.00879e-11 6.17233e-11 6.26508e-11 6.32137e-11 6.68783e-11 6.79695e-11 7.00836e-11 7.13747e-11 7.27949e-11 7.31171e-11 7.29067e-11 7.29181e-11 7.29526e-11 7.30308e-11 7.32152e-11 7.3432e-11 8.62313e-11 1.39407e-10 3.29058e-10 9.95095e-10 3.52226e-09 1.44355e-08 5.94505e-08 2.85767e-07 1.31787e-06 6.65274e-06 3.52122e-05 0.000180767 0.000905929 0.00471735 0.0240887 0.110627 0.318058 0.543822 0.719355 0.822893 0.863077 0.860519 0.816941 0.701931 0.513836 0.284274 0.114275 0.0255199 0.00405488 0.00169128 0.000480044 0.000107368 3.03532e-05 9.94142e-06 2.95423e-06 8.76419e-07 2.37686e-07 6.43381e-08 1.46381e-08 3.6674e-09 8.78691e-10 2.26582e-10 9.03036e-11 6.08216e-11 6.93072e-11 7.63287e-11 9.97787e-11 9.31506e-11 8.11445e-11 8.40035e-11 8.75766e-11 9.37565e-11 9.81123e-11 1.03011e-10 1.09227e-10 1.08608e-10 1.07933e-10 1.07625e-10 1.06959e-10 1.06801e-10 1.05167e-10 1.05092e-10 1.04917e-10 1.07504e-10 1.08142e-10 1.0896e-10 1.092e-10 1.10192e-10 1.09855e-10 1.10005e-10 1.09554e-10 1.09864e-10 1.10177e-10 1.10332e-10 1.10592e-10 1.10897e-10 1.11809e-10 1.36099e-10 2.08949e-10 5.36023e-10 1.80478e-09 7.19781e-09 2.9743e-08 1.02571e-07 4.25151e-07 2.41152e-06 1.11158e-05 5.39167e-05 0.000324935 0.00180224 0.00919001 0.0440011 0.182532 0.405869 0.586519 0.71681 0.763325 0.763009 0.747914 0.628832 0.488843 0.291051 0.134525 0.0410786 0.00679057 0.00364367 0.00131099 0.000311094 9.78453e-05 1.98833e-05 5.25993e-06 1.65998e-06 5.06798e-07 1.18781e-07 2.99302e-08 6.09816e-09 1.32109e-09 4.63849e-10 1.8207e-10 9.54362e-11 7.31586e-11 7.20691e-11 7.36079e-11 7.60609e-11 7.68773e-11 7.83357e-11 8.42967e-11 1.47442e-10 1.69675e-10 1.40617e-10 1.26687e-10 1.27363e-10 1.26629e-10 1.24087e-10 1.1979e-10 1.17388e-10 1.15336e-10 1.13546e-10 1.04433e-10 9.0507e-11 8.20423e-11 7.5136e-11 6.82525e-11 5.74913e-11 4.8063e-11 4.39051e-11 5.69639e-11 9.63708e-11 1.73556e-10 2.16377e-10 2.06098e-10 1.90931e-10 1.67103e-10 1.61155e-10 1.60475e-10 1.61096e-10 2.06019e-10 7.51354e-10 3.2007e-09 1.13009e-08 2.90987e-08 6.82349e-08 2.06296e-07 7.83882e-07 4.23797e-06 2.75584e-05 0.000151236 0.000739157 0.00362451 0.0185395 0.0877415 0.273725 0.460759 0.618284 0.746381 0.752887 0.750113 0.706994 0.593429 0.435846 0.257096 0.123424 0.0417322 0.011122 0.005758 0.0023787 0.000754854 0.000227009 5.82609e-05 1.52034e-05 4.1198e-06 1.37252e-06 4.1137e-07 1.17461e-07 2.41128e-08 6.91009e-09 1.76597e-09 4.14424e-10 3.40071e-10 2.45654e-10 2.99442e-10 2.91837e-10 1.81498e-10 1.54143e-11 2.18405e-12 1.21271e-12 5.80228e-13 2.65018e-13 1.34581e-13 7.39377e-14 4.08525e-14 2.49947e-14 1.32344e-14 7.42185e-15 5.26463e-15 2.93272e-15 2.03109e-15 1.52635e-15 8.41622e-16 7.82115e-16 5.52573e-16 3.39626e-16 4.79436e-16 2.8324e-16 4.26936e-16 5.81732e-16 2.66867e-16 7.03716e-16 7.23462e-16 5.28942e-16 2.38057e-15 1.70313e-15 5.30539e-15 1.73732e-14 7.44896e-15 5.75372e-14 1.60348e-13 3.53413e-13 1.22702e-11 3.19522e-11 3.25717e-10 1.06208e-08 4.55275e-08 7.69352e-07 2.16669e-05 0.000338319 0.00896202 0.122486 0.314198 0.454888 0.536708 0.54894 0.501739 0.391215 0.225146 0.042498 0.00448352 0.00111029 0.000111159 1.70823e-05 1.59018e-21 1.39953e-22 3.28616e-23 1.40928e-24 7.56288e-27 1.18565e-29 1.85906e-32 2.84797e-35 4.17775e-38 5.67432e-41 6.97718e-44 4.24495e-44 7.60865e-41 9.28591e-38 4.43091e-35 1.38126e-32 2.79825e-30 2.71303e-28 2.83518e-26 2.80407e-24 9.05969e-23 8.5539e-22 3.8583e-20 1.14458e-18 1.07707e-17 1.53214e-16 7.01444e-16 1.28897e-14 1.26824e-13 3.93946e-14 5.49049e-13 4.46859e-10 9.31418e-11 7.43589e-08 1.02729e-06 1.02624e-05 0.000151453 0.00108665 0.00809352 0.0441663 0.128264 0.19666 0.214933 0.178267 0.112268 0.0673513 0.0196501 0.00134367 0.000722544 0.000296714 0.000147179 5.71508e-05 2.37949e-05 7.70773e-06 2.89469e-06 8.1888e-07 2.69495e-07 7.76432e-08 1.92387e-08 5.91359e-09 1.4451e-09 3.48055e-10 9.71793e-11 2.15255e-11 8.60017e-12 3.78232e-12 2.34222e-12 2.86459e-12 4.52839e-12 7.03465e-12 1.01401e-11 1.39134e-11 1.77655e-11 2.21509e-11 2.77232e-11 3.05231e-11 3.37908e-11 3.36701e-11 3.80559e-11 3.38632e-11 4.19646e-11 3.73181e-11 3.8606e-11 3.94326e-11 3.92776e-11 4.91182e-11 5.2052e-11 6.17364e-11 6.64308e-11 7.22577e-11 7.32081e-11 7.33409e-11 7.33035e-11 7.36598e-11 7.44057e-11 7.42891e-11 7.40148e-11 7.44125e-11 7.52156e-11 7.63178e-11 7.95728e-11 1.25548e-10 3.36233e-10 1.13713e-09 5.4701e-09 2.43681e-08 1.25193e-07 7.00344e-07 3.84328e-06 2.16181e-05 0.000108873 0.000506027 0.00224414 0.00961594 0.0349836 0.0905619 0.168869 0.233203 0.236586 0.200724 0.134174 0.0628916 0.0158405 0.00433357 0.00246678 0.000726924 0.000149023 4.817e-05 1.36487e-05 4.26406e-06 1.34751e-06 3.81812e-07 1.06732e-07 2.72631e-08 6.87246e-09 1.47036e-09 3.6017e-10 1.10266e-10 5.95338e-11 5.56523e-11 5.31656e-11 5.98605e-11 6.02466e-11 9.59423e-11 7.63014e-11 5.65861e-11 6.47037e-11 6.60866e-11 8.05985e-11 8.58509e-11 9.36256e-11 9.7934e-11 1.04207e-10 1.01224e-10 1.00714e-10 8.18114e-11 8.36526e-11 7.47638e-11 8.11258e-11 7.36179e-11 8.40123e-11 8.49158e-11 9.83379e-11 9.75808e-11 1.08836e-10 1.095e-10 1.12505e-10 1.13491e-10 1.14164e-10 1.15165e-10 1.15664e-10 1.15782e-10 1.22895e-10 1.22584e-10 1.22999e-10 1.23739e-10 1.24279e-10 1.28371e-10 2.33348e-10 7.01915e-10 2.05951e-09 8.09402e-09 4.76918e-08 2.13592e-07 1.07421e-06 7.55631e-06 4.30001e-05 0.000217 0.000977456 0.00425947 0.0188281 0.0468715 0.106584 0.151578 0.161353 0.157019 0.109738 0.0574041 0.0203969 0.00707294 0.00418897 0.00148609 0.000468146 0.000128375 2.88461e-05 9.18367e-06 2.27376e-06 6.65006e-07 2.02222e-07 5.81372e-08 1.23853e-08 2.77146e-09 5.39443e-10 1.63988e-10 9.47621e-11 8.10685e-11 7.8188e-11 7.04676e-11 6.17678e-11 6.10122e-11 7.49673e-11 9.30556e-11 1.0927e-10 1.97621e-10 2.82996e-10 2.51303e-10 1.6263e-10 1.2619e-10 1.27639e-10 1.26583e-10 1.25692e-10 1.2606e-10 1.24498e-10 1.25195e-10 1.22289e-10 1.07812e-10 8.9627e-11 8.26151e-11 7.95115e-11 7.25761e-11 5.56935e-11 4.34388e-11 3.81891e-11 6.67532e-11 1.13085e-10 2.15204e-10 3.03252e-10 3.04356e-10 2.98316e-10 2.48473e-10 1.83948e-10 1.5995e-10 1.60511e-10 1.61109e-10 1.62065e-10 1.85228e-10 3.48878e-10 6.79864e-10 1.34195e-09 3.67155e-09 1.37626e-08 7.93776e-08 5.7047e-07 3.38666e-06 1.77065e-05 8.66977e-05 0.00041229 0.00172259 0.00824794 0.0221979 0.0547106 0.123675 0.140802 0.151506 0.136527 0.0951788 0.0497647 0.0186263 0.00858337 0.00539746 0.00251842 0.00097511 0.000335044 9.70451e-05 2.79876e-05 7.39058e-06 1.97674e-06 6.44788e-07 2.04794e-07 6.11228e-08 1.65012e-08 3.20409e-09 8.22807e-10 2.16701e-10 8.24694e-11 8.14296e-11 1.74485e-10 4.97787e-10 7.71742e-10 2.64144e-10 4.7204e-12 1.7307e-12 7.96901e-13 3.50441e-13 1.58818e-13 7.80758e-14 4.06045e-14 2.16886e-14 1.20249e-14 6.66403e-15 3.74731e-15 2.33033e-15 1.41507e-15 8.92272e-16 5.78568e-16 3.26436e-16 2.1376e-16 1.30145e-16 7.31087e-17 7.265e-17 4.33772e-17 4.16211e-17 4.23409e-17 2.60098e-17 4.05653e-17 3.26152e-17 2.08172e-17 3.92567e-17 2.46091e-17 4.06207e-17 6.76834e-17 3.31585e-17 1.77723e-16 2.91233e-16 2.65021e-16 2.30452e-15 2.0438e-15 6.02213e-15 5.39884e-14 1.06032e-13 1.2391e-12 1.1848e-11 5.50635e-11 7.68481e-10 1.26809e-08 7.21988e-08 9.93583e-07 8.84264e-05 0.000214664 0.00202329 0.00113575 0.000144074 9.63313e-05 2.78856e-05 2.88518e-05 1.1896e-05 1.85062e-06 1.45383e-23 1.18393e-24 2.2538e-25 7.08935e-27 2.85528e-29 4.11008e-32 5.92556e-35 8.35611e-38 1.1288e-40 1.41541e-43 1.61368e-46 6.02009e-47 1.97478e-43 4.44995e-40 3.38001e-37 1.64518e-34 4.09908e-32 4.06031e-30 4.01098e-28 2.88593e-26 1.14555e-24 3.94542e-23 1.07933e-21 2.08004e-20 3.19772e-19 4.61706e-18 2.99094e-17 2.31182e-16 2.69972e-15 9.32518e-15 7.06998e-14 2.41921e-13 3.17294e-13 2.78624e-11 2.47828e-10 1.70268e-09 2.50886e-08 8.96545e-08 2.73743e-07 5.54002e-07 6.21282e-07 7.00921e-07 6.63233e-07 8.57059e-05 0.000149289 0.000207382 0.000212071 0.000129008 7.71216e-05 3.24625e-05 1.82795e-05 7.37116e-06 3.14822e-06 1.00657e-06 3.74351e-07 1.02515e-07 3.26675e-08 8.98028e-09 2.11032e-09 6.1568e-10 1.47224e-10 3.44631e-11 1.31156e-11 4.1883e-12 1.59349e-12 1.1996e-12 1.65219e-12 2.0847e-12 2.99259e-12 4.42188e-12 6.11573e-12 7.89598e-12 9.33055e-12 1.06491e-11 1.14456e-11 1.18344e-11 1.24308e-11 1.17723e-11 1.33161e-11 1.15158e-11 1.44753e-11 1.21681e-11 1.22976e-11 1.24718e-11 1.2315e-11 1.76103e-11 1.93617e-11 2.63417e-11 2.99005e-11 3.76255e-11 4.68403e-11 5.47863e-11 6.07896e-11 5.95416e-11 6.04041e-11 6.77187e-11 7.45938e-11 8.04874e-11 8.48119e-11 9.1243e-11 9.15205e-11 9.19655e-11 9.36358e-11 9.53859e-11 1.51473e-10 3.15803e-10 1.01552e-09 3.47565e-09 1.29971e-08 5.17857e-08 2.63026e-07 1.476e-06 8.69388e-06 3.92206e-05 0.000123923 0.000252194 0.000299773 0.000169447 0.00012606 0.000677748 0.00193784 0.00258561 0.00141664 0.000531275 0.000211593 6.5244e-05 1.56451e-05 5.74723e-06 1.97586e-06 6.03107e-07 1.8324e-07 4.95883e-08 1.30566e-08 3.16812e-09 7.54264e-10 1.76384e-10 6.13154e-11 4.86396e-11 3.68043e-11 3.38033e-11 3.07971e-11 3.60016e-11 3.11485e-11 6.248e-11 3.33191e-11 2.21641e-11 2.87648e-11 2.66526e-11 3.6864e-11 3.60911e-11 4.01016e-11 4.87065e-11 6.13275e-11 5.35829e-11 5.34984e-11 3.42844e-11 3.70271e-11 2.83739e-11 3.14857e-11 2.72418e-11 3.63696e-11 3.65016e-11 4.90092e-11 4.80479e-11 7.09064e-11 6.96769e-11 8.15284e-11 8.75863e-11 8.78397e-11 8.65426e-11 1.09217e-10 1.10348e-10 1.33581e-10 1.36428e-10 1.37203e-10 1.37618e-10 1.39713e-10 1.39753e-10 1.40437e-10 1.41756e-10 1.4293e-10 1.71081e-10 4.33372e-10 1.65399e-09 5.88283e-09 2.0552e-08 1.09668e-07 3.48304e-07 1.31083e-06 1.62137e-05 2.86887e-05 0.000113749 0.000100135 0.000289042 0.000519475 7.25368e-05 0.00302333 0.00197492 0.00203112 0.000904108 0.000436034 0.000152303 4.74242e-05 1.25724e-05 3.23802e-06 1.04482e-06 3.09733e-07 8.6664e-08 2.48826e-08 6.72547e-09 1.32391e-09 3.05729e-10 8.94025e-11 8.14972e-11 7.18109e-11 6.59127e-11 5.67997e-11 4.67773e-11 3.70332e-11 3.42087e-11 4.66949e-11 8.41341e-11 1.46056e-10 3.14513e-10 3.18019e-10 2.084e-10 1.24288e-10 9.25396e-11 1.0375e-10 9.51889e-11 9.46096e-11 9.73138e-11 8.8291e-11 9.94185e-11 8.71952e-11 6.30545e-11 4.71851e-11 5.24478e-11 6.80913e-11 5.24491e-11 2.7627e-11 1.69862e-11 1.22605e-11 3.57856e-11 5.59659e-11 1.46814e-10 2.6582e-10 3.02373e-10 2.89938e-10 2.50497e-10 1.88935e-10 1.56928e-10 1.62679e-10 1.64579e-10 1.69286e-10 1.69693e-10 1.70739e-10 1.71921e-10 1.73191e-10 1.74467e-10 2.55725e-10 8.86608e-10 4.1443e-09 1.41037e-08 4.30904e-08 1.75774e-07 1.02108e-06 1.18298e-05 4.30784e-05 8.26929e-05 0.000301855 0.000217779 0.000768949 0.00100874 0.00146004 0.00249926 0.00258209 0.00208739 0.0011858 0.00069004 0.000331649 0.000119998 3.817e-05 1.17154e-05 3.61928e-06 1.06982e-06 3.22319e-07 1.01553e-07 3.14334e-08 9.22081e-09 2.40612e-09 4.80845e-10 1.37167e-10 6.5232e-11 5.83678e-11 8.1305e-11 2.46593e-10 1.50782e-09 1.24379e-09 2.13083e-10 2.56296e-12 1.1652e-12 4.9183e-13 2.12408e-13 9.69558e-14 4.76094e-14 2.4754e-14 1.30642e-14 7.09532e-15 3.91144e-15 2.17713e-15 1.30492e-15 7.89108e-16 4.86404e-16 3.09285e-16 1.72949e-16 1.04231e-16 6.35035e-17 3.4918e-17 2.90486e-17 1.87653e-17 1.62569e-17 1.68406e-17 1.10735e-17 1.37597e-17 1.19339e-17 7.98923e-18 9.0791e-18 6.89458e-18 7.20592e-18 8.75058e-18 6.4083e-18 1.40994e-17 1.92538e-17 2.42373e-17 1.07609e-16 1.06372e-16 2.46828e-16 9.99876e-16 1.31019e-15 6.25009e-15 2.17468e-14 8.8284e-14 2.45823e-12 3.66537e-12 5.28349e-11 4.92292e-09 3.65682e-09 9.07605e-07 1.27317e-06 4.07805e-06 8.20215e-06 7.0744e-06 1.92148e-06 2.51797e-06 1.23302e-06 1.93447e-07 1.25695e-25 9.62344e-27 1.49502e-27 3.48448e-29 1.1213e-31 1.47227e-34 1.93861e-37 2.49945e-40 3.08866e-43 3.55128e-46 3.73634e-49 8.20253e-48 2.96641e-44 6.87231e-41 5.66914e-38 2.88044e-35 7.5977e-33 8.34314e-31 8.50753e-29 6.23176e-27 2.641e-25 1.0187e-23 3.11122e-22 6.14542e-21 9.60549e-20 1.5829e-18 1.2065e-17 9.47899e-17 9.11494e-16 3.79284e-15 3.42937e-14 1.47365e-13 2.54568e-13 3.15569e-12 3.29508e-11 1.99432e-10 6.55737e-09 3.50973e-08 1.78871e-07 6.25631e-07 1.01467e-06 2.08877e-06 2.92859e-06 4.33271e-06 7.67848e-06 1.32039e-05 1.63053e-05 1.16799e-05 8.24477e-06 3.69022e-06 2.26382e-06 9.4355e-07 4.13267e-07 1.30757e-07 4.81534e-08 1.28142e-08 3.95846e-09 1.04224e-09 2.40313e-10 6.87553e-11 2.11254e-11 7.03677e-12 2.2435e-12 8.51924e-13 8.3351e-13 9.66503e-13 1.00412e-12 1.2388e-12 1.76584e-12 2.48123e-12 3.21234e-12 3.90761e-12 4.4133e-12 4.7457e-12 4.7551e-12 4.82789e-12 5.03539e-12 4.99531e-12 5.6088e-12 5.13716e-12 5.93734e-12 5.38345e-12 5.45087e-12 5.6849e-12 5.55386e-12 6.67241e-12 6.87313e-12 7.74697e-12 8.48089e-12 1.06427e-11 1.1889e-11 1.48498e-11 1.90317e-11 2.03614e-11 2.35798e-11 3.2672e-11 4.35059e-11 6.33452e-11 8.15405e-11 1.00771e-10 1.08377e-10 1.17696e-10 1.17536e-10 1.19369e-10 1.2006e-10 1.34452e-10 2.66511e-10 6.00907e-10 1.72541e-09 5.26527e-09 1.92217e-08 5.6735e-08 2.55792e-07 7.50166e-07 1.29712e-06 1.32593e-06 1.88662e-06 6.41455e-07 6.34831e-06 2.18902e-05 7.4256e-05 0.000105662 7.77868e-05 3.46035e-05 1.50365e-05 5.99857e-06 2.24661e-06 8.34343e-07 2.86916e-07 8.55694e-08 2.49779e-08 6.47305e-09 1.6169e-09 3.96212e-10 1.03116e-10 4.91201e-11 3.04657e-11 2.37209e-11 1.68633e-11 1.60762e-11 1.29372e-11 1.27443e-11 8.41796e-12 1.96697e-11 7.9877e-12 7.52923e-12 9.11497e-12 8.6618e-12 1.14916e-11 1.11921e-11 1.26605e-11 1.39914e-11 1.62429e-11 1.45104e-11 1.50698e-11 1.15585e-11 1.21658e-11 9.60781e-12 1.00763e-11 9.12083e-12 1.09536e-11 1.04505e-11 1.44432e-11 1.46041e-11 2.43376e-11 2.54897e-11 3.30116e-11 3.60757e-11 3.71928e-11 3.57158e-11 5.40832e-11 5.72688e-11 8.8181e-11 1.2563e-10 1.24e-10 1.33719e-10 1.48239e-10 1.52118e-10 1.55269e-10 1.51307e-10 1.50028e-10 1.52645e-10 1.65389e-10 2.79313e-10 7.69099e-10 2.34353e-09 8.44181e-09 3.13382e-08 1.04489e-07 8.45606e-07 2.40439e-06 5.73447e-06 1.10706e-05 2.54204e-05 4.54905e-05 1.49447e-06 0.00011181 7.73045e-05 0.000124474 6.79652e-05 3.35297e-05 1.32265e-05 4.77179e-06 1.35647e-06 4.70797e-07 1.50182e-07 4.27425e-08 1.14053e-08 3.08565e-09 7.98947e-10 1.71037e-10 7.65975e-11 5.43263e-11 5.50218e-11 4.31611e-11 3.96494e-11 3.0943e-11 2.12732e-11 1.43799e-11 1.26494e-11 1.59023e-11 3.39954e-11 1.00849e-10 2.87275e-10 2.21749e-10 8.03399e-11 5.77277e-11 4.25278e-11 5.11404e-11 3.93349e-11 3.8877e-11 3.89237e-11 3.29112e-11 4.31867e-11 3.27702e-11 2.06771e-11 1.60305e-11 2.37521e-11 3.59188e-11 2.01391e-11 8.27458e-12 5.53081e-12 4.04476e-12 7.63768e-12 1.14154e-11 4.70944e-11 1.22906e-10 2.08183e-10 1.69096e-10 1.3559e-10 1.14729e-10 1.05725e-10 1.25338e-10 1.5995e-10 1.92483e-10 1.9242e-10 1.90175e-10 1.84439e-10 1.80278e-10 1.79605e-10 1.85209e-10 1.8928e-10 3.95535e-10 1.29718e-09 3.78804e-09 7.48896e-09 1.95666e-08 8.75582e-08 7.49127e-07 2.44349e-06 1.52899e-05 1.96608e-05 2.66813e-05 4.43519e-05 6.27088e-05 9.03775e-05 0.000116485 0.000130726 0.000104038 6.0793e-05 3.17582e-05 1.33648e-05 4.49955e-06 1.47406e-06 5.41786e-07 1.81343e-07 5.27812e-08 1.60113e-08 4.84923e-09 1.42806e-09 3.96321e-10 1.117e-10 5.79507e-11 5.01351e-11 5.75363e-11 8.64645e-11 8.68686e-10 1.81837e-09 1.04494e-09 8.15196e-11 1.64388e-12 6.80027e-13 2.71217e-13 1.17098e-13 5.38456e-14 2.64334e-14 1.38186e-14 7.19888e-15 3.87849e-15 2.09992e-15 1.15946e-15 6.84604e-16 4.01563e-16 2.43746e-16 1.52647e-16 8.25809e-17 4.83879e-17 2.88756e-17 1.54902e-17 1.17313e-17 7.49637e-18 6.12578e-18 6.13651e-18 4.01644e-18 4.54649e-18 4.11271e-18 2.88852e-18 3.00302e-18 2.43196e-18 2.33325e-18 2.50167e-18 1.99489e-18 3.68053e-18 4.15302e-18 5.19456e-18 1.46944e-17 1.78115e-17 3.35078e-17 1.09458e-16 1.53352e-16 6.53044e-16 1.55558e-15 9.46162e-15 9.44967e-14 1.38173e-13 1.12243e-12 1.11259e-10 1.04527e-10 2.15634e-08 4.39905e-08 1.54896e-07 4.60719e-07 5.06104e-07 1.36586e-07 2.18514e-07 1.24024e-07 1.9545e-08 1.03231e-27 7.52212e-29 9.6029e-30 1.67806e-31 4.49514e-34 5.3436e-37 6.37813e-40 7.46177e-43 8.37237e-46 8.76081e-49 9.08352e-52 7.68391e-49 3.02991e-45 7.04171e-42 6.13698e-39 3.22347e-36 9.05739e-34 1.12234e-31 1.21179e-29 8.80334e-28 3.94263e-26 1.81766e-24 5.96279e-23 1.18841e-21 1.92275e-20 3.29814e-19 3.17785e-18 2.7782e-17 2.36449e-16 1.2494e-15 9.13641e-15 5.90355e-14 1.64143e-13 7.9433e-13 4.57226e-12 1.91057e-11 2.28002e-10 1.24176e-09 7.03129e-09 3.79147e-08 9.71086e-08 2.65657e-07 4.62859e-07 5.24104e-07 7.5958e-07 1.08188e-06 1.25898e-06 1.08815e-06 8.75554e-07 4.1749e-07 2.78482e-07 1.19831e-07 5.38157e-08 1.69165e-08 6.16821e-09 1.60731e-09 4.82449e-10 1.28764e-10 3.37755e-11 1.36349e-11 3.8917e-12 1.1199e-12 6.09511e-13 7.29737e-13 5.10234e-13 4.93185e-13 5.71397e-13 7.33859e-13 1.00092e-12 1.33137e-12 1.63882e-12 1.92806e-12 2.15093e-12 2.29701e-12 2.3256e-12 2.39515e-12 2.54526e-12 2.6156e-12 2.94477e-12 2.78241e-12 3.10273e-12 2.89656e-12 2.95291e-12 3.09539e-12 3.08934e-12 3.60437e-12 3.72865e-12 4.14185e-12 4.27924e-12 4.70625e-12 4.71386e-12 4.99275e-12 5.19492e-12 5.62919e-12 6.76877e-12 9.81583e-12 1.54979e-11 2.71161e-11 3.96157e-11 5.91604e-11 7.81665e-11 1.0713e-10 1.20378e-10 1.35488e-10 1.48373e-10 1.49558e-10 1.87453e-10 2.30342e-10 3.2451e-10 1.0087e-09 3.09585e-09 1.113e-08 3.385e-08 1.05685e-07 2.04509e-07 2.71023e-07 3.10001e-07 2.6966e-07 6.42928e-07 1.03099e-06 1.87021e-06 3.7528e-06 3.31642e-06 2.30111e-06 1.36521e-06 6.43684e-07 3.23918e-07 1.22388e-07 4.16958e-08 1.21679e-08 3.41981e-09 8.56338e-10 2.21513e-10 7.21555e-11 3.59991e-11 1.81431e-11 1.04639e-11 9.01028e-12 6.21856e-12 5.44996e-12 4.51935e-12 4.31002e-12 4.20505e-12 4.57222e-12 4.73056e-12 4.7088e-12 5.11958e-12 4.69612e-12 5.54319e-12 5.11639e-12 5.57736e-12 5.54084e-12 5.90797e-12 5.5659e-12 5.73358e-12 5.02798e-12 5.25048e-12 4.36689e-12 4.54234e-12 4.33591e-12 4.97209e-12 4.86603e-12 5.81155e-12 5.73266e-12 7.04721e-12 7.3308e-12 9.24678e-12 9.66875e-12 1.01218e-11 9.81161e-12 1.43524e-11 1.75304e-11 3.15063e-11 6.00882e-11 6.49273e-11 8.11368e-11 1.09777e-10 1.29292e-10 1.57744e-10 1.61864e-10 1.71779e-10 1.91414e-10 2.00143e-10 1.97672e-10 2.54294e-10 4.88424e-10 1.16276e-09 3.78149e-09 1.17952e-08 6.28748e-08 1.70699e-07 3.59016e-07 7.30827e-07 1.08575e-06 1.73786e-06 8.51874e-08 3.25982e-06 2.21699e-06 5.19528e-06 4.21494e-06 2.62203e-06 1.20526e-06 5.09252e-07 1.82819e-07 7.00787e-08 2.18294e-08 5.95488e-09 1.52083e-09 3.96762e-10 1.11638e-10 5.19203e-11 3.7436e-11 2.43081e-11 2.84359e-11 2.0392e-11 1.71357e-11 1.00435e-11 6.42628e-12 5.66636e-12 5.65211e-12 6.44856e-12 9.00841e-12 2.78624e-11 1.3047e-10 5.66776e-11 1.42081e-11 1.82782e-11 1.39504e-11 1.63639e-11 1.21635e-11 1.25691e-11 1.21564e-11 1.10267e-11 1.21225e-11 9.58043e-12 7.78138e-12 6.73508e-12 9.73482e-12 1.24121e-11 7.18276e-12 3.85258e-12 2.56419e-12 1.93988e-12 3.10418e-12 3.69288e-12 1.39144e-11 3.88475e-11 6.51858e-11 6.77054e-11 6.00719e-11 5.61738e-11 5.68818e-11 7.16304e-11 9.96956e-11 1.65702e-10 1.80063e-10 1.91218e-10 1.94261e-10 1.97306e-10 2.05751e-10 2.06568e-10 2.07444e-10 2.30771e-10 3.29595e-10 7.69833e-10 1.34483e-09 3.1303e-09 9.73362e-09 4.99654e-08 1.29662e-07 6.28058e-07 9.87604e-07 1.41525e-06 2.74388e-06 2.96063e-06 2.74133e-06 2.84648e-06 5.29913e-06 5.61274e-06 4.77417e-06 3.06727e-06 1.50088e-06 5.58095e-07 2.41153e-07 9.40929e-08 3.08867e-08 8.68994e-09 2.5593e-09 7.85367e-10 2.63066e-10 1.06561e-10 5.97112e-11 4.65571e-11 4.85705e-11 5.74234e-11 1.72499e-10 1.68672e-09 1.81699e-09 5.35214e-10 5.5405e-12 1.0683e-12 3.90602e-13 1.52027e-13 6.5598e-14 3.02418e-14 1.47407e-14 7.59466e-15 3.87294e-15 2.04103e-15 1.08161e-15 5.90504e-16 3.3992e-16 1.94205e-16 1.16852e-16 7.05054e-17 3.66094e-17 2.06082e-17 1.19338e-17 6.20813e-18 4.22226e-18 2.63248e-18 1.98523e-18 1.82907e-18 1.20696e-18 1.20527e-18 1.09122e-18 7.76483e-19 7.42842e-19 6.10474e-19 5.54438e-19 5.44032e-19 4.56568e-19 7.02266e-19 7.58344e-19 8.25787e-19 1.8752e-18 2.37706e-18 4.13649e-18 8.68823e-18 1.78821e-17 4.84358e-17 9.39552e-17 6.22537e-16 5.34356e-15 9.62233e-15 6.30398e-14 2.79408e-12 3.05221e-12 5.64474e-10 9.69226e-10 5.92648e-09 2.55799e-08 3.5444e-08 9.92013e-09 1.88418e-08 1.21425e-08 1.91406e-09 8.08911e-30 5.66241e-31 5.98151e-32 7.93786e-34 1.81019e-36 1.93166e-39 2.07216e-42 2.18091e-45 2.20315e-48 2.08019e-51 5.70864e-54 4.84174e-50 2.07861e-46 5.06936e-43 4.81475e-40 2.68174e-37 8.12993e-35 1.13947e-32 1.30084e-30 9.77521e-29 4.98077e-27 2.50098e-25 8.25378e-24 1.83206e-22 3.34818e-21 5.41929e-20 6.0779e-19 5.52465e-18 4.81619e-17 2.9075e-16 1.86009e-15 1.27782e-14 4.85735e-14 2.02052e-13 7.29429e-13 2.59015e-12 1.71759e-11 9.29413e-11 4.49616e-10 2.75077e-09 8.08945e-09 2.08532e-08 3.89466e-08 4.46843e-08 6.53497e-08 9.20515e-08 1.0096e-07 1.00353e-07 9.21325e-08 4.69412e-08 3.40188e-08 1.51289e-08 6.96397e-09 2.19109e-09 7.93052e-10 2.13924e-10 6.44066e-11 2.49564e-11 7.60033e-12 2.15343e-12 7.27019e-13 5.54566e-13 4.52482e-13 2.9429e-13 2.53501e-13 2.73981e-13 3.30244e-13 4.27799e-13 5.54079e-13 7.04626e-13 8.42862e-13 9.7784e-13 1.09716e-12 1.18774e-12 1.24692e-12 1.29888e-12 1.38812e-12 1.44788e-12 1.65159e-12 1.58082e-12 1.75453e-12 1.64115e-12 1.68617e-12 1.77432e-12 1.79612e-12 2.07114e-12 2.15013e-12 2.37696e-12 2.48866e-12 2.68958e-12 2.73822e-12 2.92467e-12 3.07134e-12 3.36693e-12 3.66054e-12 4.17511e-12 5.15106e-12 8.58964e-12 1.40245e-11 2.52133e-11 3.77108e-11 5.72838e-11 7.54773e-11 9.52655e-11 1.17793e-10 1.23897e-10 1.40376e-10 1.54794e-10 1.72926e-10 3.19618e-10 6.46386e-10 2.08972e-09 4.95465e-09 1.37334e-08 2.65001e-08 4.17963e-08 6.27319e-08 9.86385e-08 1.50413e-07 1.69989e-07 1.55165e-07 2.20488e-07 2.37344e-07 2.10264e-07 1.75896e-07 8.83298e-08 4.6749e-08 1.79769e-08 6.07621e-09 1.74658e-09 4.85421e-10 1.28162e-10 5.17561e-11 2.62344e-11 7.57295e-12 4.64057e-12 3.94463e-12 3.9529e-12 3.9658e-12 3.97259e-12 3.37499e-12 3.1738e-12 2.72439e-12 3.11615e-12 2.68368e-12 2.70246e-12 2.80885e-12 2.51049e-12 2.80017e-12 2.57285e-12 2.76316e-12 2.72945e-12 2.84828e-12 2.71512e-12 2.78038e-12 2.50253e-12 2.56528e-12 2.23125e-12 2.31815e-12 2.30577e-12 2.57973e-12 2.58194e-12 2.95784e-12 3.00181e-12 3.50721e-12 3.57184e-12 4.03242e-12 4.07018e-12 4.04958e-12 3.9938e-12 4.59721e-12 5.41738e-12 1.07858e-11 1.56343e-11 2.57749e-11 3.91448e-11 5.54236e-11 7.16626e-11 9.95004e-11 1.11031e-10 1.33701e-10 1.56341e-10 1.74263e-10 1.77241e-10 1.92512e-10 2.58364e-10 3.51746e-10 8.2122e-10 2.44855e-09 7.96774e-09 2.03948e-08 3.66281e-08 5.99985e-08 6.16601e-08 7.53092e-08 1.45491e-08 1.47228e-07 9.6481e-08 2.62477e-07 2.68846e-07 2.24762e-07 1.29217e-07 6.64284e-08 2.73453e-08 1.05149e-08 3.20942e-09 8.44431e-10 2.2137e-10 5.97714e-11 3.52257e-11 1.37868e-11 1.2806e-11 8.35771e-12 1.07784e-11 6.2288e-12 5.28246e-12 4.58582e-12 4.41582e-12 3.78545e-12 3.45095e-12 3.64124e-12 4.84914e-12 6.50563e-12 1.49244e-11 6.40635e-12 8.2109e-12 7.3065e-12 6.607e-12 6.83123e-12 5.81561e-12 5.67274e-12 5.30848e-12 4.80336e-12 4.74316e-12 4.15508e-12 3.89832e-12 3.54606e-12 4.76736e-12 5.39288e-12 3.45239e-12 1.97029e-12 1.2717e-12 9.79534e-13 1.58797e-12 2.02513e-12 4.72972e-12 1.25378e-11 2.23773e-11 3.23907e-11 2.99091e-11 2.7637e-11 2.74e-11 3.65268e-11 5.19385e-11 7.62514e-11 8.97881e-11 1.35808e-10 1.34021e-10 1.4144e-10 1.75245e-10 2.05758e-10 2.23565e-10 2.30655e-10 2.27513e-10 3.01082e-10 3.74753e-10 6.1583e-10 1.33801e-09 4.41872e-09 1.18414e-08 4.91428e-08 6.97321e-08 1.05524e-07 1.77413e-07 1.41968e-07 9.55994e-08 4.64875e-08 1.77526e-07 3.13334e-07 3.47758e-07 3.1533e-07 1.77644e-07 8.60751e-08 4.16972e-08 1.64902e-08 5.31775e-09 1.47689e-09 4.52593e-10 1.71523e-10 9.16198e-11 5.92383e-11 4.56446e-11 4.51437e-11 4.82747e-11 7.34601e-11 3.98744e-10 1.56513e-09 1.16068e-09 1.15141e-10 1.9517e-12 6.45957e-13 2.32968e-13 9.0158e-14 3.84644e-14 1.76026e-14 8.51086e-15 4.34355e-15 2.1928e-15 1.11768e-15 5.78356e-16 3.08574e-16 1.70809e-16 9.62765e-17 5.73353e-17 3.30353e-17 1.66077e-17 8.87508e-18 4.9193e-18 2.46162e-18 1.49531e-18 9.04541e-19 6.24978e-19 5.28021e-19 3.4695e-19 3.08624e-19 2.60648e-19 1.75754e-19 1.50352e-19 1.20978e-19 9.95616e-20 8.97467e-20 7.36375e-20 1.00797e-19 1.03061e-19 9.60079e-20 1.78894e-19 2.56767e-19 3.70755e-19 6.91763e-19 1.29713e-18 2.71558e-18 5.47919e-18 3.19284e-17 2.54561e-16 5.7109e-16 4.61394e-15 9.67095e-14 9.98044e-14 1.64605e-11 2.23765e-11 2.37901e-10 1.40697e-09 2.4406e-09 7.31161e-10 1.61387e-09 1.16073e-09 1.82271e-10 6.07397e-32 4.11332e-33 3.61922e-34 3.69572e-36 7.23941e-39 6.864e-42 6.55015e-45 6.13888e-48 5.5271e-51 4.66107e-54 1.87184e-55 2.53342e-51 1.22951e-47 3.2918e-44 3.50991e-41 2.14991e-38 7.29278e-36 1.17515e-33 1.4786e-31 1.19588e-29 6.6939e-28 3.51903e-26 1.22003e-24 3.01027e-23 5.99558e-22 9.83308e-21 1.19823e-19 1.1697e-18 1.04242e-17 7.12186e-17 4.669e-16 3.18019e-15 1.44142e-14 6.25055e-14 2.30555e-13 6.68899e-13 2.45807e-12 1.14096e-11 4.03875e-11 2.06111e-10 6.5785e-10 1.70628e-09 3.49965e-09 3.72239e-09 5.29052e-09 7.75759e-09 8.17586e-09 9.19272e-09 9.62635e-09 5.26275e-09 4.14137e-09 1.91648e-09 9.05367e-10 2.99137e-10 1.11162e-10 4.2284e-11 1.66309e-11 4.44861e-12 1.2313e-12 5.2385e-13 4.56716e-13 2.84118e-13 1.73045e-13 1.39046e-13 1.3692e-13 1.5498e-13 1.88195e-13 2.44118e-13 3.00458e-13 3.69572e-13 4.36649e-13 5.06717e-13 5.75371e-13 6.34442e-13 6.84728e-13 7.13172e-13 7.67791e-13 8.06554e-13 9.18202e-13 8.9109e-13 9.92966e-13 9.23828e-13 9.5806e-13 1.01102e-12 1.03576e-12 1.19465e-12 1.2472e-12 1.38068e-12 1.46703e-12 1.56862e-12 1.63479e-12 1.77462e-12 1.88489e-12 2.0711e-12 2.2592e-12 2.55582e-12 2.89437e-12 3.52974e-12 4.80651e-12 9.81869e-12 1.55793e-11 2.85722e-11 4.16458e-11 5.99617e-11 8.26106e-11 1.00935e-10 1.19214e-10 1.32516e-10 1.45064e-10 1.69314e-10 2.25963e-10 4.2971e-10 7.65005e-10 1.85248e-09 3.44681e-09 5.90768e-09 1.02517e-08 1.75612e-08 2.50839e-08 2.57472e-08 2.14639e-08 2.30264e-08 2.49238e-08 2.42271e-08 2.2846e-08 1.2205e-08 6.7695e-09 2.66661e-09 9.00342e-10 2.735e-10 7.92663e-11 3.68755e-11 1.28012e-11 6.04205e-12 4.23983e-12 3.91207e-12 3.67166e-12 3.37985e-12 2.88846e-12 2.59504e-12 2.16161e-12 1.97776e-12 1.64242e-12 1.78718e-12 1.54011e-12 1.5564e-12 1.57604e-12 1.37031e-12 1.44811e-12 1.33029e-12 1.41376e-12 1.40793e-12 1.45536e-12 1.38741e-12 1.44085e-12 1.27577e-12 1.30106e-12 1.17101e-12 1.22697e-12 1.24529e-12 1.37433e-12 1.39182e-12 1.55974e-12 1.60517e-12 1.82857e-12 1.87437e-12 2.09753e-12 2.12703e-12 2.15673e-12 2.24575e-12 2.57508e-12 2.86761e-12 4.13159e-12 4.91206e-12 7.94866e-12 1.40468e-11 2.37674e-11 3.45274e-11 5.31841e-11 6.74517e-11 9.15964e-11 1.14527e-10 1.38749e-10 1.52569e-10 1.69881e-10 1.92338e-10 2.12417e-10 3.2705e-10 6.74129e-10 1.25033e-09 2.89082e-09 4.68301e-09 6.48828e-09 7.30831e-09 9.71691e-09 8.36856e-09 1.58166e-08 1.07481e-08 2.07148e-08 2.58019e-08 2.24853e-08 1.78888e-08 9.75708e-09 4.15621e-09 1.60547e-09 4.98593e-10 1.36414e-10 5.19845e-11 1.98474e-11 7.95515e-12 4.54495e-12 4.10278e-12 4.05332e-12 4.20461e-12 3.86707e-12 3.91061e-12 3.13454e-12 2.6551e-12 2.20588e-12 2.00265e-12 2.11441e-12 2.73583e-12 4.16552e-12 4.42473e-12 4.76879e-12 4.76783e-12 4.29144e-12 3.38445e-12 3.43656e-12 2.75795e-12 2.68142e-12 2.48795e-12 2.31826e-12 2.28333e-12 2.04648e-12 2.10318e-12 1.98536e-12 2.50179e-12 2.6818e-12 1.77731e-12 1.0363e-12 6.40473e-13 4.99487e-13 8.04785e-13 1.11349e-12 2.49473e-12 4.21109e-12 8.31426e-12 1.04345e-11 8.78348e-12 8.06669e-12 8.56105e-12 1.35471e-11 2.18985e-11 3.65392e-11 4.57483e-11 5.65359e-11 6.85099e-11 8.38459e-11 1.14229e-10 1.42629e-10 1.661e-10 1.74006e-10 1.65814e-10 1.81713e-10 2.00849e-10 2.74203e-10 4.67069e-10 1.32869e-09 4.23635e-09 9.77011e-09 1.15616e-08 1.23301e-08 1.25146e-08 8.73654e-09 7.58084e-09 3.83037e-09 8.77103e-09 2.37002e-08 3.65008e-08 3.62537e-08 2.59398e-08 1.45272e-08 7.33082e-09 2.95521e-09 9.64599e-10 3.01439e-10 1.2557e-10 8.13112e-11 5.89944e-11 4.70849e-11 4.32295e-11 4.48656e-11 5.42052e-11 1.09038e-10 4.50934e-10 8.55915e-10 2.90088e-10 3.14529e-12 1.19611e-12 3.82153e-13 1.3863e-13 5.32611e-14 2.22142e-14 9.99817e-15 4.81917e-15 2.45202e-15 1.23913e-15 6.12784e-16 3.09117e-16 1.60953e-16 8.58782e-17 4.78373e-17 2.79534e-17 1.54482e-17 7.60268e-18 3.85318e-18 2.03225e-18 9.84393e-19 5.38107e-19 3.08438e-19 1.95965e-19 1.49275e-19 9.72414e-20 7.76301e-20 6.01835e-20 3.86934e-20 3.06287e-20 2.31738e-20 1.70506e-20 1.41529e-20 1.0866e-20 1.33822e-20 1.33186e-20 1.04361e-20 1.5879e-20 2.35048e-20 2.99938e-20 5.09322e-20 8.30939e-20 1.46375e-19 3.0986e-19 1.55768e-18 1.04468e-17 2.66703e-17 2.10745e-16 2.86707e-15 1.34778e-14 4.6805e-13 6.24919e-13 9.67624e-12 7.68095e-11 1.65814e-10 5.44012e-11 1.37291e-10 1.08621e-10 1.69203e-11 4.38944e-34 2.89059e-35 2.13138e-36 1.69581e-38 2.85291e-41 2.37277e-44 1.98859e-47 1.63855e-50 1.2983e-53 9.65559e-57 6.89758e-57 1.12772e-52 6.56894e-49 2.0253e-45 2.48887e-42 1.67777e-39 6.39522e-37 1.17081e-34 1.59173e-32 1.3894e-30 8.40752e-29 4.55884e-27 1.66794e-25 4.46917e-24 9.55869e-23 1.61694e-21 2.12581e-20 2.23195e-19 2.05147e-18 1.53806e-17 1.05423e-16 7.03972e-16 3.62951e-15 1.62593e-14 6.24374e-14 1.95145e-13 5.84455e-13 1.6338e-12 5.00792e-12 1.99266e-11 5.92905e-11 1.48745e-10 3.30114e-10 3.51847e-10 4.46292e-10 6.54477e-10 7.00604e-10 8.9327e-10 1.02371e-09 6.07238e-10 5.13779e-10 2.64134e-10 1.30913e-10 5.68604e-11 2.79186e-11 9.61694e-12 2.67888e-12 8.28025e-13 4.19547e-13 4.00875e-13 1.91278e-13 1.01602e-13 7.54322e-14 7.20502e-14 7.58415e-14 8.6301e-14 1.04475e-13 1.35809e-13 1.59106e-13 1.90946e-13 2.24592e-13 2.63783e-13 3.03456e-13 3.39645e-13 3.69596e-13 3.82887e-13 4.15056e-13 4.35027e-13 4.99145e-13 4.87322e-13 5.41733e-13 5.03473e-13 5.26984e-13 5.55451e-13 5.73781e-13 6.63704e-13 6.99709e-13 7.81436e-13 8.36288e-13 9.04629e-13 9.52951e-13 1.04107e-12 1.12986e-12 1.25875e-12 1.36093e-12 1.55451e-12 1.75103e-12 2.05596e-12 2.39706e-12 3.13186e-12 4.00659e-12 7.84363e-12 1.38027e-11 2.53287e-11 4.41872e-11 6.18818e-11 8.85579e-11 1.08234e-10 1.24985e-10 1.34113e-10 1.4822e-10 1.80903e-10 2.18875e-10 3.59448e-10 5.51236e-10 8.82002e-10 1.47522e-09 2.51033e-09 3.59164e-09 3.70361e-09 3.01092e-09 2.98933e-09 3.15034e-09 3.08138e-09 3.04765e-09 1.74311e-09 1.00863e-09 4.31833e-10 1.55719e-10 6.84498e-11 2.71386e-11 9.79697e-12 5.07402e-12 3.66036e-12 3.36875e-12 3.13969e-12 2.61831e-12 2.31475e-12 1.85776e-12 1.63884e-12 1.34618e-12 1.20039e-12 9.75985e-13 1.0162e-12 8.73001e-13 8.84348e-13 8.69992e-13 7.31847e-13 7.36126e-13 6.7495e-13 7.08877e-13 7.02451e-13 7.28037e-13 6.95503e-13 7.26384e-13 6.38361e-13 6.53257e-13 6.05925e-13 6.33357e-13 6.50472e-13 7.12283e-13 7.29927e-13 8.06383e-13 8.3166e-13 9.3493e-13 9.62304e-13 1.09026e-12 1.10171e-12 1.14403e-12 1.23375e-12 1.43292e-12 1.58371e-12 2.01386e-12 2.36955e-12 2.64328e-12 3.39753e-12 5.68156e-12 9.26314e-12 1.9555e-11 2.75417e-11 4.57978e-11 6.76269e-11 9.60581e-11 1.16717e-10 1.40801e-10 1.5629e-10 1.64126e-10 1.90164e-10 2.45397e-10 3.07896e-10 5.34558e-10 7.38479e-10 9.27835e-10 1.26155e-09 1.81567e-09 2.16599e-09 2.66427e-09 2.02726e-09 2.63965e-09 3.23337e-09 3.03273e-09 2.57214e-09 1.48527e-09 6.75935e-10 2.7672e-10 1.00477e-10 4.22511e-11 1.50346e-11 6.03915e-12 4.28753e-12 3.59828e-12 3.85182e-12 3.26317e-12 3.2889e-12 2.5787e-12 2.40868e-12 1.83315e-12 1.54138e-12 1.27459e-12 1.17594e-12 1.24002e-12 1.56417e-12 2.28926e-12 2.6747e-12 2.61889e-12 2.40777e-12 2.13488e-12 1.66992e-12 1.66217e-12 1.35968e-12 1.30266e-12 1.21936e-12 1.15399e-12 1.1472e-12 1.02631e-12 1.15833e-12 1.14144e-12 1.31418e-12 1.34973e-12 8.99113e-13 5.2175e-13 3.11263e-13 2.43965e-13 3.9163e-13 5.77898e-13 1.27335e-12 2.05606e-12 2.97801e-12 3.18396e-12 2.89741e-12 2.93221e-12 2.90746e-12 3.33033e-12 4.932e-12 1.09537e-11 1.40031e-11 2.31841e-11 2.98883e-11 4.11791e-11 6.63161e-11 9.45637e-11 1.19708e-10 1.19743e-10 1.27414e-10 1.57929e-10 1.90499e-10 2.56218e-10 3.49987e-10 6.65699e-10 1.29332e-09 1.71502e-09 1.78991e-09 1.53183e-09 1.53524e-09 1.57031e-09 1.78356e-09 1.52004e-09 1.69384e-09 3.13186e-09 5.01172e-09 5.60371e-09 4.29332e-09 2.56374e-09 1.35991e-09 5.90868e-10 2.28232e-10 1.10161e-10 7.67409e-11 5.98615e-11 5.00667e-11 4.48449e-11 4.29189e-11 4.69506e-11 6.85868e-11 1.16979e-10 3.5352e-10 1.95502e-10 7.7786e-12 1.75045e-12 6.55969e-13 2.18564e-13 7.81222e-14 2.95395e-14 1.19596e-14 5.27574e-15 2.54243e-15 1.29559e-15 6.59166e-16 3.17705e-16 1.55128e-16 7.84829e-17 4.0312e-17 2.21407e-17 1.26864e-17 6.75843e-18 3.25996e-18 1.57528e-18 8.01749e-19 3.81684e-19 1.90261e-19 1.02971e-19 6.0906e-20 4.16973e-20 2.67341e-20 1.96337e-20 1.43764e-20 8.91757e-21 6.43552e-21 4.5625e-21 3.06594e-21 2.26533e-21 1.5963e-21 1.73071e-21 1.63125e-21 1.20655e-21 1.45876e-21 2.08693e-21 2.54634e-21 4.00478e-21 5.77296e-21 9.86838e-21 2.32406e-20 9.65267e-20 4.82819e-19 1.46924e-18 1.04006e-17 9.78669e-17 9.91243e-16 1.74115e-14 5.44292e-14 4.43362e-13 4.1998e-12 1.11643e-11 4.07655e-12 1.16021e-11 9.97436e-12 1.53642e-12 3.06618e-36 1.97066e-37 1.2243e-38 7.67291e-41 1.10109e-43 7.90027e-47 5.71914e-50 4.07515e-53 2.79545e-56 1.80429e-59 4.29974e-58 8.05991e-54 5.34191e-50 1.79043e-46 2.43007e-43 1.75978e-40 7.33123e-38 1.50034e-35 2.15825e-33 1.97914e-31 1.26673e-29 7.01416e-28 2.6986e-26 7.7314e-25 1.73404e-23 3.02282e-22 4.26022e-21 4.72143e-20 4.47731e-19 3.63385e-18 2.52659e-17 1.62557e-16 8.9632e-16 4.34761e-15 1.81534e-14 6.18113e-14 1.91573e-13 5.40034e-13 1.30651e-12 3.19123e-12 7.93904e-12 1.80083e-11 3.89792e-11 4.8867e-11 5.61401e-11 8.03726e-11 9.54847e-11 1.20309e-10 1.3785e-10 9.41518e-11 7.79618e-11 6.01123e-11 3.59197e-11 1.52985e-11 5.17919e-12 1.56941e-12 6.18247e-13 5.05027e-13 2.77281e-13 1.30051e-13 6.47593e-14 4.05594e-14 3.65281e-14 3.87059e-14 4.1547e-14 4.66231e-14 5.61508e-14 7.32213e-14 8.15649e-14 9.58179e-14 1.12299e-13 1.34011e-13 1.55416e-13 1.7479e-13 1.90123e-13 1.95887e-13 2.11911e-13 2.20726e-13 2.57482e-13 2.51454e-13 2.78483e-13 2.57525e-13 2.73004e-13 2.86487e-13 2.9851e-13 3.49138e-13 3.694e-13 4.20467e-13 4.52023e-13 4.95041e-13 5.30621e-13 5.82874e-13 6.45513e-13 7.37715e-13 8.02585e-13 9.28919e-13 1.0364e-12 1.23009e-12 1.45651e-12 1.84795e-12 2.11791e-12 2.68664e-12 3.56614e-12 6.32821e-12 1.35264e-11 2.39189e-11 4.709e-11 6.80324e-11 8.87117e-11 1.08493e-10 1.21715e-10 1.34979e-10 1.45341e-10 1.68123e-10 1.99694e-10 2.33961e-10 2.98487e-10 4.25679e-10 5.71745e-10 5.77534e-10 4.75986e-10 4.75195e-10 5.0269e-10 4.89486e-10 4.89505e-10 3.13076e-10 1.87745e-10 1.0864e-10 5.39797e-11 2.12112e-11 7.91527e-12 4.11954e-12 3.07527e-12 3.10424e-12 2.59087e-12 2.1757e-12 1.73753e-12 1.48455e-12 1.15034e-12 1.00435e-12 8.15405e-13 7.05628e-13 5.58544e-13 5.62269e-13 4.76423e-13 4.82964e-13 4.6036e-13 3.73056e-13 3.58383e-13 3.24766e-13 3.39033e-13 3.31348e-13 3.43716e-13 3.30586e-13 3.44024e-13 3.0061e-13 3.13489e-13 2.95706e-13 3.10422e-13 3.21541e-13 3.54079e-13 3.60485e-13 3.9786e-13 4.16482e-13 4.56953e-13 4.7743e-13 5.36589e-13 5.43661e-13 5.85244e-13 6.473e-13 7.57064e-13 8.55938e-13 1.03026e-12 1.19897e-12 1.40659e-12 1.65129e-12 2.04785e-12 2.5412e-12 4.25741e-12 6.34635e-12 1.33546e-11 2.6211e-11 4.84918e-11 6.91965e-11 9.86454e-11 1.22875e-10 1.34765e-10 1.45036e-10 1.57724e-10 1.71423e-10 2.07464e-10 2.34654e-10 2.46798e-10 2.96658e-10 3.76121e-10 4.59967e-10 4.65654e-10 3.97686e-10 4.69437e-10 5.37981e-10 5.12653e-10 4.46184e-10 2.78103e-10 1.48535e-10 8.34759e-11 3.42558e-11 1.11364e-11 4.76698e-12 3.01927e-12 3.04906e-12 2.81027e-12 2.65304e-12 2.10035e-12 2.05727e-12 1.51551e-12 1.39345e-12 1.03494e-12 8.74621e-13 7.23051e-13 6.70171e-13 6.99096e-13 8.64475e-13 1.21678e-12 1.43049e-12 1.36134e-12 1.18804e-12 1.0408e-12 8.2697e-13 7.99043e-13 6.6361e-13 6.27494e-13 5.83389e-13 5.58002e-13 5.50418e-13 5.01134e-13 6.29326e-13 6.38636e-13 6.64446e-13 6.5134e-13 4.3058e-13 2.43181e-13 1.38636e-13 1.08789e-13 1.76728e-13 2.755e-13 5.99909e-13 9.8344e-13 1.38584e-12 1.53847e-12 1.45224e-12 1.50343e-12 1.53543e-12 1.73712e-12 2.01333e-12 2.61216e-12 3.13984e-12 4.83835e-12 6.81829e-12 1.13686e-11 2.43671e-11 4.65573e-11 7.27134e-11 7.98199e-11 9.23743e-11 1.3721e-10 1.93544e-10 2.47631e-10 2.67922e-10 2.91184e-10 3.41967e-10 3.40721e-10 3.08791e-10 2.99909e-10 3.21514e-10 3.68642e-10 4.38283e-10 3.96552e-10 3.99491e-10 5.6026e-10 8.49991e-10 9.98536e-10 8.21899e-10 5.43608e-10 3.23119e-10 1.72567e-10 1.07603e-10 7.35849e-11 6.38331e-11 5.61802e-11 4.89656e-11 4.38327e-11 4.22081e-11 4.8282e-11 7.09117e-11 1.04222e-10 1.4823e-10 1.00251e-11 2.21134e-12 1.16928e-12 3.54301e-13 1.16254e-13 4.05159e-14 1.49995e-14 5.87538e-15 2.53683e-15 1.22165e-15 6.21375e-16 3.1866e-16 1.50109e-16 7.03173e-17 3.4414e-17 1.69573e-17 9.16326e-18 5.13388e-18 2.64223e-18 1.25315e-18 5.81946e-19 2.90298e-19 1.3825e-19 6.41789e-20 3.3174e-20 1.85403e-20 1.17922e-20 7.5165e-21 5.26333e-21 3.75414e-21 2.30835e-21 1.54009e-21 1.04321e-21 6.73286e-22 4.54225e-22 3.09943e-22 2.86539e-22 2.68733e-22 2.03338e-22 2.13184e-22 2.8637e-22 3.65756e-22 5.69046e-22 8.06304e-22 1.41871e-21 3.25809e-21 1.27158e-20 5.6889e-20 2.12143e-19 1.20542e-18 1.23684e-17 1.05688e-16 1.73576e-15 2.06891e-14 5.54659e-14 2.69293e-13 7.77532e-13 3.33425e-13 9.8702e-13 9.06024e-13 1.3958e-13 2.07943e-38 1.30747e-39 6.8757e-41 3.4218e-43 4.13598e-46 2.50312e-49 1.53058e-52 9.22423e-56 5.35907e-59 2.98902e-62 3.7011e-59 7.79308e-55 5.76926e-51 2.09192e-47 3.12078e-44 2.45316e-41 1.10691e-38 2.51953e-36 3.85533e-34 3.67882e-32 2.46641e-30 1.39474e-28 5.56372e-27 1.68174e-25 3.9159e-24 6.96204e-23 1.03517e-21 1.18656e-20 1.14692e-19 9.84916e-19 6.93426e-18 4.34873e-17 2.48318e-16 1.28974e-15 6.05259e-15 2.27224e-14 7.65811e-14 2.40765e-13 6.50294e-13 1.58632e-12 3.52208e-12 6.68809e-12 1.26071e-11 1.99098e-11 2.93945e-11 4.00164e-11 4.9205e-11 5.3051e-11 5.13195e-11 4.15995e-11 2.98103e-11 1.63946e-11 7.19643e-12 2.44086e-12 9.72801e-13 4.66686e-13 5.03911e-13 2.24723e-13 9.29727e-14 4.24459e-14 2.36997e-14 1.81265e-14 1.86666e-14 2.07996e-14 2.21139e-14 2.42616e-14 2.90313e-14 3.78502e-14 3.98776e-14 4.57286e-14 5.31692e-14 6.41088e-14 7.43985e-14 8.32319e-14 8.97917e-14 9.17184e-14 9.83344e-14 1.01873e-13 1.2011e-13 1.17387e-13 1.29325e-13 1.1907e-13 1.28119e-13 1.33199e-13 1.4078e-13 1.67019e-13 1.77151e-13 2.04998e-13 2.22303e-13 2.46921e-13 2.68626e-13 2.98838e-13 3.3602e-13 3.9585e-13 4.36591e-13 5.09745e-13 5.76496e-13 6.96317e-13 8.40583e-13 1.06976e-12 1.23512e-12 1.56065e-12 1.8752e-12 2.31083e-12 3.27157e-12 5.40691e-12 1.34294e-11 2.55775e-11 4.1102e-11 6.16308e-11 8.24016e-11 1.07922e-10 1.24613e-10 1.34002e-10 1.54102e-10 1.61957e-10 1.71074e-10 1.88326e-10 1.83685e-10 1.81456e-10 1.76502e-10 1.83312e-10 1.90207e-10 1.82943e-10 1.64301e-10 1.24705e-10 7.76243e-11 3.69609e-11 1.44256e-11 5.53118e-12 3.06508e-12 2.6991e-12 2.71299e-12 2.32028e-12 1.75563e-12 1.41958e-12 1.09333e-12 9.09734e-13 6.86293e-13 5.91403e-13 4.70893e-13 3.93162e-13 3.00739e-13 2.94557e-13 2.4364e-13 2.45987e-13 2.2691e-13 1.75795e-13 1.60494e-13 1.43143e-13 1.48316e-13 1.434e-13 1.46939e-13 1.42376e-13 1.49012e-13 1.28157e-13 1.36299e-13 1.29982e-13 1.37524e-13 1.44395e-13 1.60221e-13 1.61637e-13 1.78288e-13 1.90888e-13 2.03895e-13 2.14585e-13 2.41857e-13 2.47191e-13 2.76063e-13 3.15591e-13 3.78001e-13 4.34403e-13 5.12005e-13 5.91888e-13 7.09728e-13 8.51104e-13 1.04384e-12 1.31371e-12 1.67848e-12 1.99288e-12 2.8612e-12 5.45664e-12 1.28958e-11 2.45177e-11 4.60465e-11 7.01046e-11 9.00526e-11 1.13631e-10 1.34756e-10 1.42512e-10 1.57646e-10 1.73548e-10 1.83728e-10 1.98446e-10 2.08856e-10 1.91858e-10 2.00955e-10 1.99963e-10 2.0624e-10 2.12293e-10 1.94288e-10 1.54773e-10 1.08706e-10 5.92697e-11 2.47834e-11 8.65729e-12 3.58354e-12 2.60289e-12 2.49972e-12 2.37898e-12 1.84067e-12 1.67463e-12 1.25128e-12 1.19787e-12 8.48395e-13 7.72822e-13 5.65139e-13 4.77124e-13 3.90427e-13 3.5825e-13 3.6905e-13 4.55461e-13 6.28132e-13 7.38533e-13 6.84675e-13 5.76134e-13 4.9379e-13 3.9208e-13 3.69917e-13 3.06455e-13 2.86843e-13 2.62212e-13 2.51885e-13 2.43902e-13 2.25061e-13 3.16847e-13 3.27622e-13 3.06095e-13 2.85052e-13 1.83681e-13 9.94997e-14 5.41194e-14 4.28588e-14 7.06014e-14 1.16398e-13 2.58681e-13 4.34113e-13 6.3164e-13 7.06629e-13 6.97056e-13 7.44428e-13 7.75615e-13 8.60267e-13 1.02735e-12 1.30085e-12 1.53835e-12 1.79085e-12 1.99206e-12 2.5667e-12 4.98744e-12 1.23324e-11 2.55674e-11 3.17997e-11 4.36141e-11 8.36381e-11 1.40428e-10 1.97846e-10 2.31615e-10 2.28899e-10 2.04517e-10 1.77058e-10 1.61225e-10 1.74551e-10 1.95242e-10 1.73635e-10 1.75507e-10 1.87977e-10 2.13417e-10 2.63264e-10 2.93329e-10 3.02512e-10 2.52574e-10 2.0077e-10 1.47475e-10 9.88024e-11 6.95103e-11 5.86595e-11 5.7946e-11 5.37154e-11 4.77078e-11 4.33509e-11 4.12533e-11 4.77795e-11 6.51729e-11 6.18223e-11 2.15502e-11 3.12662e-12 1.96858e-12 6.27895e-13 1.80143e-13 5.65517e-14 1.9116e-14 6.91437e-15 2.61988e-15 1.10485e-15 5.29769e-16 2.65898e-16 1.36641e-16 6.29497e-17 2.79887e-17 1.31925e-17 6.20219e-18 3.28256e-18 1.78876e-18 8.90442e-19 4.1741e-19 1.88265e-19 9.34511e-20 4.56189e-20 2.01428e-20 1.01181e-20 5.45869e-21 3.34412e-21 2.16067e-21 1.47269e-21 1.04129e-21 6.53592e-22 4.15135e-22 2.78862e-22 1.82008e-22 1.17624e-22 7.97776e-23 6.69751e-23 6.29108e-23 4.87231e-23 4.78757e-23 6.0706e-23 7.62363e-23 1.10279e-22 1.55197e-22 2.76293e-22 6.53881e-22 2.09532e-21 9.62808e-21 3.67472e-20 1.57603e-19 1.36107e-18 1.53681e-17 1.65618e-16 2.47979e-15 2.47988e-14 4.72104e-14 8.2936e-14 4.67048e-14 1.00194e-13 9.15591e-14 1.55537e-14 1.37523e-40 8.47046e-42 3.78474e-43 1.50166e-45 1.49945e-48 7.41539e-52 3.71122e-55 1.83363e-58 8.74884e-62 7.37946e-65 2.77195e-60 6.88922e-56 5.86119e-52 2.40821e-48 4.05386e-45 3.52838e-42 1.76892e-39 4.55347e-37 7.57909e-35 7.56557e-33 5.3001e-31 3.08044e-29 1.26129e-27 3.95691e-26 9.48515e-25 1.71349e-23 2.63846e-22 3.08501e-21 3.008e-20 2.70522e-19 1.86882e-18 1.14421e-17 6.71578e-17 3.54067e-16 1.82893e-15 7.46558e-15 2.51695e-14 8.32099e-14 2.16387e-13 5.0193e-13 1.14207e-12 2.28524e-12 4.93662e-12 8.1399e-12 1.11301e-11 1.61103e-11 1.73075e-11 1.58037e-11 1.31546e-11 8.55405e-12 5.2929e-12 2.59176e-12 1.28142e-12 6.04677e-13 4.58889e-13 3.52282e-13 1.75718e-13 7.34678e-14 3.02845e-14 1.44973e-14 9.58574e-15 8.74042e-15 9.65445e-15 1.09563e-14 1.13266e-14 1.20864e-14 1.43099e-14 1.84889e-14 1.8264e-14 2.03103e-14 2.32373e-14 2.79677e-14 3.21228e-14 3.53585e-14 3.74966e-14 3.76842e-14 4.00024e-14 4.10046e-14 4.87419e-14 4.76814e-14 5.21827e-14 4.77614e-14 5.20745e-14 5.38175e-14 5.77511e-14 6.94366e-14 7.40677e-14 8.70088e-14 9.51039e-14 1.07631e-13 1.18555e-13 1.34143e-13 1.53139e-13 1.85846e-13 2.08505e-13 2.46266e-13 2.84387e-13 3.53565e-13 4.34153e-13 5.63893e-13 6.80426e-13 8.8405e-13 1.10465e-12 1.39739e-12 1.72012e-12 2.00376e-12 2.86858e-12 5.20409e-12 9.97717e-12 1.80797e-11 3.25981e-11 5.72687e-11 8.14536e-11 9.81744e-11 1.19346e-10 1.29421e-10 1.40628e-10 1.41817e-10 1.44109e-10 1.41286e-10 1.46792e-10 1.42355e-10 1.35755e-10 1.06938e-10 7.92218e-11 4.24827e-11 2.15538e-11 9.09123e-12 4.30298e-12 2.63435e-12 2.52391e-12 2.3074e-12 1.91743e-12 1.56924e-12 1.12704e-12 8.8119e-13 6.57009e-13 5.32729e-13 3.89729e-13 3.28689e-13 2.53625e-13 2.03018e-13 1.48912e-13 1.41939e-13 1.13415e-13 1.1323e-13 1.00779e-13 7.38979e-14 6.37421e-14 5.54341e-14 5.67235e-14 5.39759e-14 5.46217e-14 5.29279e-14 5.6027e-14 4.74101e-14 5.12725e-14 4.94179e-14 5.28043e-14 5.64269e-14 6.30065e-14 6.33553e-14 7.00225e-14 7.62957e-14 7.91526e-14 8.35573e-14 9.49053e-14 9.87533e-14 1.15486e-13 1.35588e-13 1.68688e-13 1.97262e-13 2.28421e-13 2.68167e-13 3.21246e-13 3.98518e-13 4.91829e-13 6.22856e-13 8.30658e-13 1.05424e-12 1.26495e-12 1.59803e-12 2.59447e-12 4.77852e-12 1.06861e-11 2.10313e-11 3.52316e-11 5.94429e-11 8.85547e-11 1.02153e-10 1.23426e-10 1.34776e-10 1.42197e-10 1.52206e-10 1.47338e-10 1.47491e-10 1.50651e-10 1.53323e-10 1.61394e-10 1.46975e-10 1.05949e-10 6.15933e-11 3.38554e-11 1.54832e-11 6.32001e-12 2.93806e-12 2.18783e-12 2.33356e-12 1.77282e-12 1.54536e-12 1.11737e-12 9.8747e-13 7.06383e-13 6.6239e-13 4.54191e-13 4.09069e-13 2.92783e-13 2.43912e-13 1.94789e-13 1.74765e-13 1.77595e-13 2.20954e-13 3.06313e-13 3.5959e-13 3.27785e-13 2.65081e-13 2.19212e-13 1.69996e-13 1.56287e-13 1.26957e-13 1.17687e-13 1.0508e-13 9.9498e-14 9.48042e-14 8.85002e-14 1.41311e-13 1.47137e-13 1.22799e-13 1.08401e-13 6.70562e-14 3.44726e-14 1.78556e-14 1.4287e-14 2.41574e-14 4.14829e-14 9.57503e-14 1.70529e-13 2.5913e-13 2.93263e-13 2.98321e-13 3.30776e-13 3.59144e-13 3.92556e-13 4.7186e-13 5.91558e-13 7.23041e-13 8.57266e-13 9.90669e-13 1.22671e-12 1.58015e-12 2.5735e-12 5.07815e-12 6.57497e-12 1.04699e-11 2.75555e-11 6.02455e-11 1.13836e-10 1.71836e-10 2.03869e-10 1.95675e-10 1.52115e-10 1.42107e-10 1.31085e-10 1.41285e-10 1.63397e-10 1.79125e-10 1.99798e-10 2.27123e-10 2.44381e-10 2.34405e-10 2.04944e-10 1.62019e-10 1.18452e-10 8.41841e-11 6.19802e-11 5.29078e-11 5.04239e-11 5.28754e-11 4.93472e-11 4.3712e-11 3.92254e-11 3.64685e-11 4.27159e-11 4.43467e-11 2.14485e-11 3.79255e-12 2.82947e-12 1.15851e-12 3.19428e-13 8.45054e-14 2.51129e-14 8.17658e-15 2.87809e-15 1.05334e-15 4.30488e-16 2.04851e-16 1.00038e-16 5.08749e-17 2.28478e-17 9.54313e-18 4.3117e-18 1.92963e-18 9.94648e-19 5.25429e-19 2.54966e-19 1.1916e-19 5.29855e-20 2.65941e-20 1.36899e-20 5.92529e-21 2.9545e-21 1.58085e-21 9.66992e-22 6.29612e-22 4.20633e-22 2.94677e-22 1.89413e-22 1.17724e-22 7.94148e-23 5.29422e-23 3.37798e-23 2.29053e-23 1.77839e-23 1.63984e-23 1.2709e-23 1.2612e-23 1.58965e-23 2.0312e-23 2.71727e-23 3.55398e-23 5.78969e-23 1.28078e-22 3.32698e-22 1.52373e-21 6.87288e-21 2.26492e-20 1.44547e-19 1.60284e-18 1.55727e-17 2.53672e-16 1.71019e-15 1.69378e-14 2.3902e-14 2.56609e-14 2.14055e-14 1.65275e-14 3.66368e-15 8.90944e-43 5.37761e-44 2.04728e-45 6.46542e-48 5.17968e-51 1.99527e-54 7.79521e-58 3.01348e-61 1.12781e-64 1.81862e-66 1.71129e-61 5.03957e-57 5.01818e-53 2.43947e-49 4.78923e-46 4.7795e-43 2.72158e-40 7.97846e-38 1.47175e-35 1.55139e-33 1.13551e-31 6.80821e-30 2.85177e-28 9.24726e-27 2.29011e-25 4.22844e-24 6.69629e-23 7.99353e-22 7.74062e-21 7.2745e-20 5.06858e-19 3.01592e-18 1.71481e-17 8.63243e-17 4.56524e-16 1.90474e-15 6.08212e-15 1.95532e-14 4.52395e-14 8.83389e-14 1.96827e-13 3.70734e-13 9.13398e-13 1.68855e-12 1.89388e-12 2.92753e-12 2.60296e-12 2.3091e-12 1.9643e-12 1.41273e-12 9.87942e-13 6.42109e-13 4.99466e-13 4.92799e-13 2.74262e-13 1.31548e-13 5.93406e-14 2.37767e-14 9.91331e-15 5.36642e-15 4.24666e-15 4.34688e-15 4.92551e-15 5.58461e-15 5.54152e-15 5.72132e-15 6.64996e-15 8.40302e-15 7.70304e-15 8.2322e-15 9.15695e-15 1.08107e-14 1.20906e-14 1.29197e-14 1.33055e-14 1.29899e-14 1.35876e-14 1.37172e-14 1.6382e-14 1.59894e-14 1.74059e-14 1.58293e-14 1.74536e-14 1.80285e-14 1.95624e-14 2.3863e-14 2.56569e-14 3.06097e-14 3.37655e-14 3.88925e-14 4.33798e-14 5.00792e-14 5.79321e-14 7.25966e-14 8.26049e-14 9.95221e-14 1.18087e-13 1.51465e-13 1.91902e-13 2.56772e-13 3.23841e-13 4.34705e-13 5.67158e-13 7.44187e-13 9.81142e-13 1.09242e-12 1.34748e-12 1.63299e-12 2.37153e-12 3.87764e-12 6.97173e-12 1.37142e-11 2.59145e-11 3.99742e-11 5.94926e-11 7.08998e-11 8.11175e-11 7.99121e-11 8.38255e-11 8.00813e-11 8.3028e-11 7.00322e-11 5.46329e-11 3.36885e-11 2.14375e-11 1.03147e-11 5.46183e-12 3.04625e-12 2.38947e-12 2.32226e-12 1.9989e-12 1.60662e-12 1.27796e-12 1.00432e-12 6.89126e-13 5.21635e-13 3.75683e-13 2.95214e-13 2.0749e-13 1.69322e-13 1.24987e-13 9.52442e-14 6.63299e-14 6.11806e-14 4.66591e-14 4.56038e-14 3.89256e-14 2.66718e-14 2.14513e-14 1.79785e-14 1.81218e-14 1.67017e-14 1.67113e-14 1.61551e-14 1.72878e-14 1.43858e-14 1.58145e-14 1.53921e-14 1.67183e-14 1.81937e-14 2.04159e-14 2.05792e-14 2.28785e-14 2.51894e-14 2.55093e-14 2.68569e-14 3.08701e-14 3.25517e-14 4.02979e-14 4.87739e-14 6.32382e-14 7.56839e-14 8.57341e-14 1.01623e-13 1.23124e-13 1.57063e-13 2.00264e-13 2.56749e-13 3.6575e-13 4.72198e-13 5.97902e-13 7.8217e-13 1.10668e-12 1.37718e-12 2.13577e-12 3.92135e-12 7.26571e-12 1.44378e-11 2.7442e-11 4.15825e-11 6.13428e-11 7.39402e-11 8.34288e-11 9.18104e-11 8.72238e-11 8.90762e-11 8.80893e-11 8.551e-11 7.8908e-11 5.63131e-11 3.1777e-11 1.60477e-11 8.33832e-12 4.23345e-12 2.49041e-12 2.06726e-12 1.89784e-12 1.57604e-12 1.11356e-12 9.30588e-13 6.37195e-13 5.5056e-13 3.79649e-13 3.48047e-13 2.30034e-13 2.03177e-13 1.40562e-13 1.13948e-13 8.74111e-14 7.5669e-14 7.53176e-14 9.4722e-14 1.3497e-13 1.59675e-13 1.43664e-13 1.10703e-13 8.70937e-14 6.45789e-14 5.70718e-14 4.47931e-14 4.10859e-14 3.52557e-14 3.26373e-14 3.06926e-14 2.90256e-14 5.27758e-14 5.50388e-14 4.03448e-14 3.37663e-14 1.98826e-14 9.5894e-15 4.73445e-15 3.80777e-15 6.65973e-15 1.17309e-14 2.90914e-14 5.51283e-14 8.66499e-14 1.02072e-13 1.06491e-13 1.25673e-13 1.40982e-13 1.5074e-13 1.86466e-13 2.30049e-13 2.91463e-13 3.59812e-13 4.27553e-13 5.3759e-13 7.2885e-13 1.08334e-12 1.41392e-12 1.69549e-12 2.28611e-12 5.25089e-12 1.32394e-11 3.77311e-11 7.70231e-11 1.02808e-10 1.06455e-10 8.11483e-11 7.98735e-11 7.05053e-11 8.0877e-11 1.13275e-10 1.30905e-10 1.47036e-10 1.54967e-10 1.46678e-10 1.3477e-10 1.17511e-10 9.12762e-11 6.88036e-11 5.29972e-11 4.49329e-11 4.36399e-11 4.27322e-11 4.42332e-11 4.04075e-11 3.59554e-11 3.16493e-11 2.8163e-11 3.0189e-11 2.30599e-11 4.40743e-12 3.4269e-12 1.83411e-12 6.34663e-13 1.50386e-13 3.6374e-14 1.01572e-14 3.14475e-15 1.06593e-15 3.7411e-16 1.46431e-16 6.89525e-17 3.24278e-17 1.60184e-17 6.9766e-18 2.72405e-18 1.17342e-18 5.03902e-19 2.5253e-19 1.3016e-19 6.3063e-20 2.96994e-20 1.33363e-20 6.8523e-21 3.77574e-21 1.64969e-21 8.31371e-22 4.52702e-22 2.79941e-22 1.81165e-22 1.2064e-22 8.2921e-23 5.42003e-23 3.36993e-23 2.27324e-23 1.56399e-23 1.034e-23 7.05147e-24 5.24934e-24 4.89912e-24 3.71151e-24 3.36892e-24 4.03663e-24 5.3745e-24 6.77077e-24 8.69907e-24 1.20536e-23 2.31032e-23 4.99572e-23 2.11177e-22 1.05418e-21 3.18397e-21 1.59014e-20 1.46526e-19 1.38619e-18 2.39374e-17 1.26112e-16 1.24055e-15 5.04133e-15 2.44913e-15 7.88857e-15 7.75859e-15 1.05724e-15 5.68001e-45 3.35808e-46 1.09117e-47 2.71688e-50 1.66778e-53 4.6199e-57 1.3025e-60 3.64409e-64 9.88845e-68 7.08563e-68 8.14436e-63 2.82556e-58 3.33648e-54 1.94079e-50 4.51491e-47 5.32853e-44 3.46428e-41 1.16975e-38 2.44281e-36 2.74993e-34 2.12164e-32 1.32913e-30 5.76439e-29 1.967e-27 5.15694e-26 9.98114e-25 1.67443e-23 2.11307e-22 2.09342e-21 2.08022e-20 1.53386e-19 9.45392e-19 5.54072e-18 2.84945e-17 1.50811e-16 6.36437e-16 2.01775e-15 6.56236e-15 1.64603e-14 3.53184e-14 7.5013e-14 1.46816e-13 3.11732e-13 5.20339e-13 6.01241e-13 4.6594e-13 5.43268e-13 5.46059e-13 5.47031e-13 5.52916e-13 5.91394e-13 5.30979e-13 3.59507e-13 1.9527e-13 1.01236e-13 4.62889e-14 1.94046e-14 7.61316e-15 3.37063e-15 2.17948e-15 1.98934e-15 2.15576e-15 2.44043e-15 2.72657e-15 2.57065e-15 2.55084e-15 2.87854e-15 3.50186e-15 2.94661e-15 2.99077e-15 3.18016e-15 3.59855e-15 3.82706e-15 3.88831e-15 3.81381e-15 3.54253e-15 3.60099e-15 3.55644e-15 4.24979e-15 4.1305e-15 4.47694e-15 4.03751e-15 4.49853e-15 4.67407e-15 5.11091e-15 6.32755e-15 6.8604e-15 8.31699e-15 9.26627e-15 1.08348e-14 1.22721e-14 1.44706e-14 1.69453e-14 2.19084e-14 2.53051e-14 3.12558e-14 3.8134e-14 5.08047e-14 6.66427e-14 9.30461e-14 1.2203e-13 1.73276e-13 2.37609e-13 3.29027e-13 4.58377e-13 5.07819e-13 6.50166e-13 8.31881e-13 1.20595e-12 1.76245e-12 2.32576e-12 3.4634e-12 5.9711e-12 9.67833e-12 1.69111e-11 2.23383e-11 2.69432e-11 2.61196e-11 2.94666e-11 2.73924e-11 2.90274e-11 2.11298e-11 1.43099e-11 7.65014e-12 5.37279e-12 3.24929e-12 2.54287e-12 2.21758e-12 2.22657e-12 1.73746e-12 1.36595e-12 1.05458e-12 8.08599e-13 6.10888e-13 4.01382e-13 2.9341e-13 2.02702e-13 1.53005e-13 1.02169e-13 7.96722e-14 5.55194e-14 3.99166e-14 2.60518e-14 2.29946e-14 1.64761e-14 1.55305e-14 1.25601e-14 7.9003e-15 5.81234e-15 4.61865e-15 4.52801e-15 3.96569e-15 3.92574e-15 3.72879e-15 4.05473e-15 3.29078e-15 3.71557e-15 3.64282e-15 4.06735e-15 4.49096e-15 5.07785e-15 5.16121e-15 5.78672e-15 6.38057e-15 6.34703e-15 6.56753e-15 7.69068e-15 8.26211e-15 1.0919e-14 1.36531e-14 1.83853e-14 2.26151e-14 2.50691e-14 2.97462e-14 3.6452e-14 4.71513e-14 6.27223e-14 8.24036e-14 1.23111e-13 1.68497e-13 2.25157e-13 3.07368e-13 4.5615e-13 6.25234e-13 8.82947e-13 1.21435e-12 1.62677e-12 3.1562e-12 6.14209e-12 1.0462e-11 1.84072e-11 2.50055e-11 2.9494e-11 3.39772e-11 3.28487e-11 3.41112e-11 3.32078e-11 3.13235e-11 2.64954e-11 1.5484e-11 7.46121e-12 4.34715e-12 2.9121e-12 2.09841e-12 2.00482e-12 1.71606e-12 1.27194e-12 9.97692e-13 6.57332e-13 5.25426e-13 3.43627e-13 2.91077e-13 1.93099e-13 1.72116e-13 1.08474e-13 9.29204e-14 6.12225e-14 4.75851e-14 3.4433e-14 2.82516e-14 2.7148e-14 3.44602e-14 5.13947e-14 6.21298e-14 5.52043e-14 4.02103e-14 2.96806e-14 2.05556e-14 1.70995e-14 1.2703e-14 1.14457e-14 9.24429e-15 8.27381e-15 7.68732e-15 7.33485e-15 1.5301e-14 1.59106e-14 1.00815e-14 7.89726e-15 4.45614e-15 2.01505e-15 9.45861e-16 7.49517e-16 1.35598e-15 2.42604e-15 6.59438e-15 1.32696e-14 2.19647e-14 2.69869e-14 2.9562e-14 3.73879e-14 4.33085e-14 4.52726e-14 5.61043e-14 6.92553e-14 9.15084e-14 1.19534e-13 1.44186e-13 1.95083e-13 2.67477e-13 4.22862e-13 5.9944e-13 7.9775e-13 1.01755e-12 1.37401e-12 2.5091e-12 8.41981e-12 2.32059e-11 3.71159e-11 4.2369e-11 2.60474e-11 2.50324e-11 2.19568e-11 2.82719e-11 5.23066e-11 6.90909e-11 8.15597e-11 8.71657e-11 8.49424e-11 8.03635e-11 6.88164e-11 5.62489e-11 4.64065e-11 3.89769e-11 3.56919e-11 3.45829e-11 3.24498e-11 3.28624e-11 2.96082e-11 2.69593e-11 2.37779e-11 2.01674e-11 1.85591e-11 9.46075e-12 3.43295e-12 2.44063e-12 1.09707e-12 3.17238e-13 6.48709e-14 1.42575e-14 3.69927e-15 1.06703e-15 3.41936e-16 1.13479e-16 4.19592e-17 1.94505e-17 8.71251e-18 4.0891e-18 1.72016e-18 6.31139e-19 2.58721e-19 1.08452e-19 5.33418e-20 2.74257e-20 1.36802e-20 6.5201e-21 3.0234e-21 1.58221e-21 9.17813e-22 4.03083e-22 2.05847e-22 1.14259e-22 7.13738e-23 4.61535e-23 3.13104e-23 2.13973e-23 1.41763e-23 8.85641e-24 6.006e-24 4.18407e-24 2.8815e-24 1.96062e-24 1.45638e-24 1.37644e-24 1.05345e-24 8.59836e-25 9.42703e-25 1.28375e-24 1.55759e-24 2.0537e-24 2.48436e-24 3.97691e-24 7.30711e-24 2.71736e-23 1.39502e-22 4.23429e-22 1.82163e-21 1.34664e-20 1.20891e-19 2.12191e-18 1.00807e-17 9.24462e-17 4.73797e-16 2.35393e-16 7.45108e-16 7.36187e-16 9.19498e-17 3.57999e-47 2.07046e-48 5.74549e-50 1.10435e-52 4.79318e-56 8.11473e-60 1.40718e-63 2.43911e-67 4.13305e-71 1.06548e-69 1.7195e-64 7.80238e-60 1.21902e-55 9.12604e-52 2.70612e-48 4.05278e-45 3.078e-42 1.23493e-39 2.99562e-37 3.63042e-35 2.96066e-33 1.95001e-31 8.82414e-30 3.1909e-28 8.90715e-27 1.81815e-25 3.27153e-24 4.41959e-23 4.57277e-22 4.8529e-21 3.82847e-20 2.47545e-19 1.53563e-18 8.41681e-18 4.798e-17 2.15702e-16 7.14471e-16 2.43165e-15 6.50933e-15 1.49136e-14 3.29476e-14 6.63047e-14 1.30432e-13 2.08637e-13 2.67337e-13 3.57513e-13 4.33871e-13 4.36764e-13 4.38263e-13 4.30235e-13 3.50408e-13 2.29423e-13 1.46426e-13 7.43731e-14 3.60109e-14 1.55672e-14 6.17954e-15 2.44493e-15 1.22365e-15 9.53227e-16 9.4832e-16 1.0441e-15 1.16177e-15 1.26362e-15 1.12204e-15 1.06134e-15 1.14769e-15 1.32174e-15 1.009e-15 9.58047e-16 9.52216e-16 1.002e-15 9.79469e-16 9.15155e-16 8.23781e-16 7.00719e-16 6.71717e-16 6.33713e-16 7.53389e-16 7.27792e-16 7.86705e-16 6.99742e-16 7.90374e-16 8.30169e-16 9.13333e-16 1.14802e-15 1.25097e-15 1.54325e-15 1.73703e-15 2.06039e-15 2.38326e-15 2.86153e-15 3.40849e-15 4.52449e-15 5.31977e-15 6.75727e-15 8.46896e-15 1.17263e-14 1.59093e-14 2.34439e-14 3.22641e-14 4.90411e-14 7.07601e-14 1.0429e-13 1.55378e-13 1.73342e-13 2.30149e-13 3.11067e-13 4.99079e-13 8.97068e-13 1.31221e-12 1.72787e-12 2.02933e-12 2.7398e-12 4.30499e-12 4.86928e-12 4.88123e-12 4.03025e-12 4.21139e-12 3.90536e-12 4.27366e-12 3.45885e-12 3.29967e-12 2.72484e-12 2.50346e-12 2.29628e-12 2.42662e-12 1.87193e-12 1.58182e-12 1.17473e-12 8.87299e-13 6.57818e-13 4.87762e-13 3.53806e-13 2.22135e-13 1.55897e-13 1.02342e-13 7.34516e-14 4.60644e-14 3.38795e-14 2.19821e-14 1.47412e-14 8.87225e-15 7.36974e-15 4.85668e-15 4.31648e-15 3.23167e-15 1.8153e-15 1.18502e-15 8.66151e-16 8.02716e-16 6.477e-16 6.27564e-16 5.76305e-16 6.33925e-16 4.97964e-16 5.83055e-16 5.81164e-16 6.69795e-16 7.52683e-16 8.60988e-16 8.80652e-16 9.96273e-16 1.09862e-15 1.06683e-15 1.07499e-15 1.28521e-15 1.41848e-15 2.01285e-15 2.61756e-15 3.67832e-15 4.65617e-15 4.972e-15 5.81157e-15 7.19435e-15 9.55613e-15 1.30481e-14 1.81171e-14 2.85164e-14 4.13687e-14 5.63359e-14 7.99306e-14 1.24481e-13 1.864e-13 2.96826e-13 4.38383e-13 6.67757e-13 1.05383e-12 1.43823e-12 2.34247e-12 4.32246e-12 6.11903e-12 6.09171e-12 5.86342e-12 5.17459e-12 5.36298e-12 5.24917e-12 4.97489e-12 5.04427e-12 3.50564e-12 2.76184e-12 2.20165e-12 2.18042e-12 1.98145e-12 1.57914e-12 1.15004e-12 8.03299e-13 5.94909e-13 3.66649e-13 2.79936e-13 1.75605e-13 1.45454e-13 9.20556e-14 7.91267e-14 4.6914e-14 3.85153e-14 2.37858e-14 1.74356e-14 1.16502e-14 8.83871e-15 8.00348e-15 1.02041e-14 1.62583e-14 2.03817e-14 1.78762e-14 1.22142e-14 8.3349e-15 5.22361e-15 3.98142e-15 2.71119e-15 2.3358e-15 1.72933e-15 1.44823e-15 1.31402e-15 1.24716e-15 3.05411e-15 3.12663e-15 1.6709e-15 1.22866e-15 6.64567e-16 2.82652e-16 1.24687e-16 9.48912e-17 1.72735e-16 3.13582e-16 9.41975e-16 2.00809e-15 3.60333e-15 4.74548e-15 5.49134e-15 7.46949e-15 9.1833e-15 9.04966e-15 1.12658e-14 1.37779e-14 1.90985e-14 2.62718e-14 3.12721e-14 4.58867e-14 6.78098e-14 1.1253e-13 1.61227e-13 2.51035e-13 3.732e-13 4.61248e-13 6.77282e-13 1.10297e-12 3.45224e-12 6.84729e-12 9.11857e-12 5.90176e-12 5.17884e-12 4.07337e-12 4.62951e-12 1.17521e-11 2.81558e-11 3.99359e-11 4.76198e-11 5.16231e-11 5.3044e-11 4.88034e-11 4.23554e-11 3.54499e-11 2.89484e-11 2.36619e-11 1.83457e-11 1.47259e-11 1.63466e-11 1.44917e-11 1.82124e-11 1.75688e-11 1.43736e-11 1.09568e-11 3.31226e-12 2.59241e-12 1.55161e-12 5.96284e-13 1.44157e-13 2.55449e-14 5.03815e-15 1.1916e-15 3.11597e-16 9.21682e-17 2.83079e-17 9.68045e-18 4.3567e-18 1.81241e-18 7.83774e-19 3.16123e-19 1.10943e-19 4.34316e-20 1.7827e-20 8.73307e-21 4.53746e-21 2.32345e-21 1.11819e-21 5.37602e-22 2.83199e-22 1.67757e-22 7.23494e-23 3.71846e-23 2.08419e-23 1.3187e-23 8.6055e-24 5.98947e-24 4.12789e-24 2.78e-24 1.75389e-24 1.2112e-24 8.56742e-25 6.15966e-25 4.21496e-25 3.20839e-25 3.08569e-25 2.45469e-25 1.87596e-25 1.90793e-25 2.58101e-25 3.11073e-25 4.29817e-25 4.85231e-25 6.78723e-25 1.06507e-24 3.38288e-24 1.72647e-23 5.34604e-23 2.10573e-22 1.35445e-21 1.06717e-20 1.79371e-19 8.62247e-19 7.02638e-18 4.50808e-17 2.27866e-17 7.01854e-17 6.94492e-17 7.94447e-18 2.2412e-49 1.26525e-50 2.99615e-52 4.27132e-55 1.11268e-58 7.24169e-63 5.01566e-67 3.6024e-71 2.62437e-75 6.01118e-72 1.56185e-66 1.06343e-61 2.3697e-57 2.32995e-53 9.24758e-50 1.79798e-46 1.58441e-43 7.48299e-41 2.11234e-38 2.73937e-36 2.3604e-34 1.62786e-32 7.70723e-31 2.95609e-29 8.7457e-28 1.88991e-26 3.65447e-25 5.2977e-24 5.82016e-23 6.64698e-22 5.66079e-21 3.89229e-20 2.58929e-19 1.55406e-18 1.00687e-17 5.09699e-17 1.88846e-16 7.28987e-16 2.18038e-15 5.54956e-15 1.42076e-14 3.08346e-14 6.40559e-14 1.03561e-13 1.42506e-13 1.95892e-13 2.40274e-13 2.3325e-13 2.29001e-13 2.08033e-13 1.51268e-13 9.48626e-14 5.66772e-14 2.70844e-14 1.23718e-14 5.05656e-15 1.93816e-15 8.07006e-16 4.7971e-16 4.33586e-16 4.4716e-16 4.87441e-16 5.26817e-16 5.51479e-16 4.57658e-16 4.08743e-16 4.17488e-16 4.47411e-16 3.06234e-16 2.66903e-16 2.41217e-16 2.27323e-16 1.94935e-16 1.58304e-16 1.2174e-16 8.66897e-17 7.15546e-17 5.90325e-17 6.81182e-17 6.53614e-17 7.06048e-17 6.17717e-17 7.09671e-17 7.5461e-17 8.36808e-17 1.06854e-16 1.16616e-16 1.46658e-16 1.66062e-16 2.00704e-16 2.37583e-16 2.90564e-16 3.53704e-16 4.79166e-16 5.76992e-16 7.54343e-16 9.73155e-16 1.39527e-15 1.94843e-15 3.07129e-15 4.40737e-15 7.27868e-15 1.10555e-14 1.76059e-14 2.81745e-14 3.25091e-14 4.39451e-14 6.27435e-14 1.13199e-13 2.59119e-13 4.46628e-13 6.96862e-13 9.13457e-13 1.51414e-12 1.79719e-12 2.72677e-12 3.23044e-12 3.27454e-12 3.58644e-12 3.45329e-12 3.75155e-12 3.32585e-12 3.17694e-12 2.6052e-12 2.38651e-12 2.00623e-12 1.76937e-12 1.31087e-12 1.07191e-12 7.5875e-13 5.49512e-13 3.91227e-13 2.80605e-13 1.94763e-13 1.1618e-13 7.77101e-14 4.79859e-14 3.24217e-14 1.88745e-14 1.293e-14 7.69876e-15 4.75309e-15 2.58894e-15 1.98031e-15 1.16804e-15 9.46871e-16 6.32806e-16 3.03105e-16 1.66857e-16 1.04532e-16 8.56083e-17 5.7905e-17 5.18645e-17 4.48786e-17 4.92819e-17 3.76422e-17 4.53721e-17 4.67067e-17 5.57915e-17 6.39651e-17 7.41696e-17 7.61409e-17 8.69536e-17 9.58342e-17 8.99505e-17 8.66279e-17 1.0619e-16 1.21178e-16 1.88629e-16 2.57108e-16 3.80828e-16 4.91477e-16 4.87945e-16 5.61611e-16 6.97591e-16 9.16794e-16 1.29743e-15 1.92625e-15 3.21958e-15 4.93829e-15 6.93155e-15 1.0004e-14 1.6705e-14 2.47304e-14 4.56944e-14 6.85478e-14 1.47225e-13 2.59271e-13 4.54538e-13 7.01484e-13 1.00843e-12 1.92517e-12 3.52573e-12 3.96637e-12 4.07436e-12 4.28707e-12 4.32478e-12 4.26453e-12 2.97183e-12 2.72481e-12 2.6443e-12 2.08488e-12 1.8427e-12 1.40738e-12 1.06046e-12 7.30569e-13 4.80282e-13 3.35622e-13 1.93705e-13 1.41071e-13 8.48098e-14 6.8299e-14 4.07211e-14 3.3461e-14 1.83948e-14 1.43074e-14 8.14545e-15 5.52884e-15 3.32668e-15 2.25916e-15 1.85869e-15 2.36501e-15 4.13392e-15 5.45659e-15 4.73508e-15 3.00724e-15 1.86304e-15 1.01474e-15 6.82969e-16 4.0219e-16 3.10012e-16 1.99111e-16 1.43079e-16 1.19072e-16 1.06183e-16 3.12141e-16 3.115e-16 1.35625e-16 9.28632e-17 4.76004e-17 1.92141e-17 8.09073e-18 5.61015e-18 9.21085e-18 1.62112e-17 5.56412e-17 1.2137e-16 2.58068e-16 3.87294e-16 5.11968e-16 7.44351e-16 9.85149e-16 8.61148e-16 1.08772e-15 1.29503e-15 1.90646e-15 2.77128e-15 3.25774e-15 5.14357e-15 8.03419e-15 1.22578e-14 2.00638e-14 3.77432e-14 7.00006e-14 7.56753e-14 9.63716e-14 1.62356e-13 2.84498e-13 4.51839e-13 6.21053e-13 1.94561e-12 3.19606e-12 3.17862e-12 3.76979e-12 4.28339e-12 6.30691e-12 1.26131e-11 1.85852e-11 2.32596e-11 2.66431e-11 2.58094e-11 2.20975e-11 1.72372e-11 1.27646e-11 1.00959e-11 9.45367e-12 9.38346e-12 9.28519e-12 9.24068e-12 9.30207e-12 9.03253e-12 7.25315e-12 4.56351e-12 2.87534e-12 1.70693e-12 9.02782e-13 2.94478e-13 5.97092e-14 9.14763e-15 1.58705e-15 3.33669e-16 7.66873e-17 2.03153e-17 5.59498e-18 1.71529e-18 7.21408e-19 2.65845e-19 1.00174e-19 3.73188e-20 1.25694e-20 4.66808e-21 1.77542e-21 8.42732e-22 4.21225e-22 2.13706e-22 1.03213e-22 5.10147e-23 2.71017e-23 1.63775e-23 6.93676e-24 3.57929e-24 2.01795e-24 1.29515e-24 8.56972e-25 6.14519e-25 4.30647e-25 2.95895e-25 1.89738e-25 1.34685e-25 9.75743e-26 7.34954e-26 5.13298e-26 4.08161e-26 4.05077e-26 3.41167e-26 2.59108e-26 2.57489e-26 3.46167e-26 4.32105e-26 6.41616e-26 7.30147e-26 9.9356e-26 1.4084e-25 3.88451e-25 2.02013e-24 6.32793e-24 2.37402e-23 1.53316e-22 9.72839e-22 1.47863e-20 7.71096e-20 5.44987e-19 4.32428e-18 2.22227e-18 6.60167e-18 6.53095e-18 6.84129e-19 ) ; boundaryField { inlet { type zeroGradient; } bottom { type zeroGradient; } outlet { type zeroGradient; } atmosphere { type inletOutlet; inletValue uniform 0; value nonuniform List<scalar> 357 ( 2.2412e-49 1.26525e-50 2.99615e-52 4.27132e-55 1.11268e-58 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1.03561e-13 1.42506e-13 1.95892e-13 2.40274e-13 2.3325e-13 2.29001e-13 2.08033e-13 1.51268e-13 9.48626e-14 5.66772e-14 2.70844e-14 1.23718e-14 5.05656e-15 1.93816e-15 8.07006e-16 4.7971e-16 4.33586e-16 4.4716e-16 4.87441e-16 5.26817e-16 5.51479e-16 4.57658e-16 4.08743e-16 4.17488e-16 4.47411e-16 3.06234e-16 2.66903e-16 2.41217e-16 2.27323e-16 1.94935e-16 1.58304e-16 1.2174e-16 8.66897e-17 7.15546e-17 5.90325e-17 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 3.58644e-12 3.45329e-12 3.75155e-12 3.32585e-12 3.17694e-12 2.6052e-12 2.38651e-12 2.00623e-12 1.76937e-12 1.31087e-12 1.07191e-12 7.5875e-13 5.49512e-13 3.91227e-13 2.80605e-13 1.94763e-13 1.1618e-13 7.77101e-14 4.79859e-14 3.24217e-14 1.88745e-14 1.293e-14 7.69876e-15 4.75309e-15 2.58894e-15 1.98031e-15 1.16804e-15 9.46871e-16 6.32806e-16 3.03105e-16 1.66857e-16 1.04532e-16 8.56083e-17 5.7905e-17 5.18645e-17 4.48786e-17 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 4.28707e-12 4.32478e-12 4.26453e-12 2.97183e-12 2.72481e-12 2.6443e-12 2.08488e-12 1.8427e-12 1.40738e-12 1.06046e-12 7.30569e-13 4.80282e-13 3.35622e-13 1.93705e-13 1.41071e-13 8.48098e-14 6.8299e-14 4.07211e-14 3.3461e-14 1.83948e-14 1.43074e-14 8.14545e-15 5.52884e-15 3.32668e-15 2.25916e-15 1.85869e-15 2.36501e-15 4.13392e-15 5.45659e-15 4.73508e-15 3.00724e-15 1.86304e-15 1.01474e-15 6.82969e-16 4.0219e-16 3.10012e-16 1.99111e-16 1.43079e-16 1.19072e-16 1.06183e-16 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 4.28339e-12 6.30691e-12 1.26131e-11 1.85852e-11 2.32596e-11 2.66431e-11 2.58094e-11 2.20975e-11 1.72372e-11 1.27646e-11 1.00959e-11 9.45367e-12 9.38346e-12 9.28519e-12 9.24068e-12 9.30207e-12 9.03253e-12 7.25315e-12 4.56351e-12 2.87534e-12 1.70693e-12 9.02782e-13 2.94478e-13 5.97092e-14 9.14763e-15 1.58705e-15 3.33669e-16 7.66873e-17 2.03153e-17 5.59498e-18 1.71529e-18 7.21408e-19 2.65845e-19 1.00174e-19 3.73188e-20 1.25694e-20 4.66808e-21 1.77542e-21 8.42732e-22 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 9.72839e-22 1.47863e-20 7.71096e-20 5.44987e-19 4.32428e-18 2.22227e-18 6.60167e-18 6.53095e-18 6.84129e-19 ) ; } frontBack { type empty; } } // ************************************************************************* //
[ "abenaz15@etudiant.mines-nantes.fr" ]
abenaz15@etudiant.mines-nantes.fr
739d009b165f4982e387dd92e4a225816b728a71
0b3c9fb345e051de4bafca41e120e051a5919fe2
/src/stardank/renderer/texture/renderer.hpp
aa9f930004f0701b3981c823b4efd564d97771b7
[ "MIT", "Zlib", "BSL-1.0", "LicenseRef-scancode-public-domain" ]
permissive
kz04px/stardank
c8b1ce6bab4687d504b67f6950612ebef9c2044a
ef78c9001a32a8d75cfdfbb4df475d9bcc0995de
refs/heads/master
2023-08-12T18:23:14.670715
2021-09-30T17:55:50
2021-09-30T17:55:50
409,592,916
1
0
null
null
null
null
UTF-8
C++
false
false
591
hpp
#ifndef TEXTURE_RENDERER_HPP #define TEXTURE_RENDERER_HPP #include <glm/glm.hpp> #include "../program.hpp" class Quad; class TextureRenderer { public: struct VertexData { glm::vec3 position; glm::vec2 uv; }; TextureRenderer(); ~TextureRenderer(); void draw(const Quad &quad, const float layer = 0.0f); void flush(); glm::mat4x4 m_view; private: constexpr static int m_max_buffer_size = 1024; Program m_program; GLuint m_vao; GLuint m_vbo; int m_buffer_index; VertexData m_data[m_max_buffer_size]; }; #endif
[ "6536046+kz04px@users.noreply.github.com" ]
6536046+kz04px@users.noreply.github.com
3a63bee14ff2cc9d428feab1c9849b6c47eedf0c
2adf0fab717eff0db8724f17e7d7197e9482cc80
/chrome/browser/vr/elements/repositioner.cc
4ce2973a5b08ce003d455e306b667f57997d41c6
[ "BSD-3-Clause" ]
permissive
bishtranjan1/chromium
5981386fbf15f3f4018d7d8c8dea0e3ce4aef6fa
fc308bd8127a92e5db0d36532e8335515dadb4b8
refs/heads/master
2023-03-01T10:41:47.916294
2018-02-22T10:34:07
2018-02-22T10:34:07
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,910
cc
// Copyright 2018 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "chrome/browser/vr/elements/repositioner.h" #include "chrome/browser/vr/pose_util.h" #include "chrome/browser/vr/ui_scene_constants.h" #include "ui/gfx/geometry/angle_conversions.h" #include "ui/gfx/geometry/quaternion.h" namespace vr { namespace { constexpr float kSnapThresholdDegrees = 10.0f; } // namespace Repositioner::Repositioner() = default; Repositioner::~Repositioner() = default; gfx::Transform Repositioner::LocalTransform() const { return transform_; } gfx::Transform Repositioner::GetTargetLocalTransform() const { return transform_; } void Repositioner::SetEnabled(bool enabled) { bool check_for_snap = !enabled && enabled_; enabled_ = enabled; if (!check_for_snap) return; gfx::Vector3dF world_up = {0, 1, 0}; gfx::Vector3dF up = world_up; transform_.TransformVector(&up); if (gfx::AngleBetweenVectorsInDegrees(up, world_up) < kSnapThresholdDegrees) { snap_to_world_up_ = true; } } void Repositioner::UpdateTransform(const gfx::Transform& head_pose) { gfx::Vector3dF head_up_vector = snap_to_world_up_ ? gfx::Vector3dF(0, 1, 0) : vr::GetUpVector(head_pose); snap_to_world_up_ = false; transform_.ConcatTransform( gfx::Transform(gfx::Quaternion(last_laser_direction_, laser_direction_))); gfx::Vector3dF new_right_vector = {1, 0, 0}; transform_.TransformVector(&new_right_vector); gfx::Vector3dF new_forward_vector = {0, 0, -1}; transform_.TransformVector(&new_forward_vector); gfx::Vector3dF expected_right_vector = gfx::CrossProduct(new_forward_vector, head_up_vector); gfx::Quaternion rotate_to_expected_right(new_right_vector, expected_right_vector); transform_.ConcatTransform(gfx::Transform(rotate_to_expected_right)); } bool Repositioner::OnBeginFrame(const base::TimeTicks& time, const gfx::Transform& head_pose) { if (enabled_ || snap_to_world_up_) { UpdateTransform(head_pose); return true; } return false; } #ifndef NDEBUG void Repositioner::DumpGeometry(std::ostringstream* os) const { gfx::Transform t = world_space_transform(); gfx::Vector3dF forward = {0, 0, -1}; t.TransformVector(&forward); // Decompose the rotation to world x axis followed by world y axis float x_rotation = std::asin(forward.y() / forward.Length()); gfx::Vector3dF projected_forward = {forward.x(), 0, forward.z()}; float y_rotation = std::acos(gfx::DotProduct(projected_forward, {0, 0, -1}) / projected_forward.Length()); if (projected_forward.x() > 0.f) y_rotation *= -1; *os << "rx(" << gfx::RadToDeg(x_rotation) << ") " << "ry(" << gfx::RadToDeg(y_rotation) << ") "; } #endif } // namespace vr
[ "commit-bot@chromium.org" ]
commit-bot@chromium.org
d4e5e3165280694a47cac853055ad05ac1b080a8
c72dbe52d952c80c3d7137525b34b8421c925488
/tests/parser/struct.cpp
abf4ebaa51b5452885d09cd88af76ded6b41cc84
[ "LicenseRef-scancode-other-permissive", "LicenseRef-scancode-unknown-license-reference" ]
permissive
reaver-project/vapor
0204d1b4190116ecc4e2e9908f67d591af002c6e
17ddb5c60b483bd17a288319bfd3e8a43656859e
refs/heads/develop
2021-05-03T22:53:00.806550
2019-05-21T15:07:08
2019-05-21T16:02:17
25,346,731
4
4
NOASSERTION
2020-08-26T05:56:20
2014-10-17T08:11:55
C++
UTF-8
C++
false
false
5,933
cpp
/** * Vapor Compiler Licence * * Copyright © 2016-2018 Michał "Griwes" Dominiak * * This software is provided 'as-is', without any express or implied * warranty. In no event will the authors be held liable for any damages * arising from the use of this software. * * Permission is granted to anyone to use this software for any purpose, * including commercial applications, and to alter it and redistribute it * freely, subject to the following restrictions: * * 1. The origin of this software must not be misrepresented; you must not * claim that you wrote the original software. If you use this software * in a product, an acknowledgment in the product documentation is required. * 2. Altered source versions must be plainly marked as such, and must not be * misrepresented as being the original software. * 3. This notice may not be removed or altered from any source distribution. * **/ #include <reaver/mayfly.h> #include "helpers.h" using namespace reaver::vapor; using namespace reaver::vapor::parser; MAYFLY_BEGIN_SUITE("parser"); MAYFLY_BEGIN_SUITE("struct"); MAYFLY_ADD_TESTCASE("empty literal", test(UR"(struct {};)", struct_literal{ { 0, 9 }, {} }, &parse_struct_literal)); MAYFLY_ADD_TESTCASE("single member literal", test(UR"(struct { let i : int; };)", struct_literal{ { 0, 23 }, { { declaration{ { 9, 20 }, std::nullopt, { { 13, 14 }, { lexer::token_type::identifier, UR"(i)", { 13, 14 } } }, std::make_optional<expression>({ { 17, 20 }, postfix_expression{ { 17, 20 }, identifier{ { 17, 20 }, { lexer::token_type::identifier, UR"(int)", { 17, 20 } } }, std::nullopt, {} } }), std::nullopt } } } }, &parse_struct_literal)); MAYFLY_ADD_TESTCASE("multiple member literal", test(UR"(struct { let i : int; let j = 1; };)", struct_literal{ { 0, 34 }, { { declaration{ { 9, 20 }, std::nullopt, { { 13, 14 }, { lexer::token_type::identifier, UR"(i)", { 13, 14 } } }, std::make_optional<expression>({ { 17, 20 }, postfix_expression{ { 17, 20 }, identifier{ { 17, 20 }, { lexer::token_type::identifier, UR"(int)", { 17, 20 } } }, std::nullopt, {} } }), std::nullopt } }, { declaration{ { 22, 31 }, std::nullopt, { { 26, 27 }, { lexer::token_type::identifier, UR"(j)", { 26, 27 } } }, std::nullopt, std::make_optional<expression>({ { 30, 31 }, integer_literal{ { 30, 31 }, { lexer::token_type::integer, UR"(1)", { 30, 31 } }, {} } }) } } } }, &parse_struct_literal)); MAYFLY_ADD_TESTCASE("empty declaration", test(UR"(struct foo {};)", declaration{ { 0, 13 }, std::nullopt, { { 7, 10 }, { lexer::token_type::identifier, UR"(foo)", { 7, 10 } } }, std::nullopt, std::make_optional<expression>({ { 0, 13 }, struct_literal{ { 0, 13 }, {} } }) }, &parse_struct_declaration)); MAYFLY_ADD_TESTCASE("single member declaration", test(UR"(struct foo { let i : int; };)", declaration{ { 0, 27 }, std::nullopt, { { 7, 10 }, { lexer::token_type::identifier, UR"(foo)", { 7, 10 } } }, std::nullopt, std::make_optional<expression>({ { 0, 27 }, struct_literal{ { 0, 27 }, { { declaration{ { 13, 24 }, std::nullopt, { { 17, 18 }, { lexer::token_type::identifier, UR"(i)", { 17, 18 } } }, std::make_optional<expression>({ { 21, 24 }, postfix_expression{ { 21, 24 }, identifier{ { 21, 24 }, { lexer::token_type::identifier, UR"(int)", { 21, 24 } } }, std::nullopt, {} } }), std::nullopt } } } } }) }, &parse_struct_declaration)); MAYFLY_ADD_TESTCASE("multiple member declaration", test(UR"(struct foo { let i : int; let j = 1; };)", declaration{ { 0, 38 }, std::nullopt, { { 7, 10 }, { lexer::token_type::identifier, UR"(foo)", { 7, 10 } } }, std::nullopt, std::make_optional<expression>({ { 0, 38 }, struct_literal{ { 0, 38 }, { { declaration{ { 13, 24 }, std::nullopt, { { 17, 18 }, { lexer::token_type::identifier, UR"(i)", { 17, 18 } } }, std::make_optional<expression>({ { 21, 24 }, postfix_expression{ { 21, 24 }, identifier{ { 21, 24 }, { lexer::token_type::identifier, UR"(int)", { 21, 24 } } }, std::nullopt, {} } }), std::nullopt } }, { declaration{ { 26, 35 }, std::nullopt, { { 30, 31 }, { lexer::token_type::identifier, UR"(j)", { 30, 31 } } }, std::nullopt, std::make_optional<expression>({ { 34, 35 }, integer_literal{ { 34, 35 }, { lexer::token_type::integer, UR"(1)", { 34, 35 } }, {} } }) } } } } }) }, &parse_struct_declaration)); MAYFLY_END_SUITE; MAYFLY_END_SUITE;
[ "griwes@griwes.info" ]
griwes@griwes.info
a535c969b5f41d22c844ab41da84c26bb715d15e
3ff1fe3888e34cd3576d91319bf0f08ca955940f
/cpdp/src/v20190820/model/CloudExternalChannelData.cpp
1c92229b8f1d8b8bc0d4d5c5c054776e8cdd7b1e
[ "Apache-2.0" ]
permissive
TencentCloud/tencentcloud-sdk-cpp
9f5df8220eaaf72f7eaee07b2ede94f89313651f
42a76b812b81d1b52ec6a217fafc8faa135e06ca
refs/heads/master
2023-08-30T03:22:45.269556
2023-08-30T00:45:39
2023-08-30T00:45:39
188,991,963
55
37
Apache-2.0
2023-08-17T03:13:20
2019-05-28T08:56:08
C++
UTF-8
C++
false
false
3,837
cpp
/* * Copyright (c) 2017-2019 THL A29 Limited, a Tencent company. 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. */ #include <tencentcloud/cpdp/v20190820/model/CloudExternalChannelData.h> using TencentCloud::CoreInternalOutcome; using namespace TencentCloud::Cpdp::V20190820::Model; using namespace std; CloudExternalChannelData::CloudExternalChannelData() : m_externalChannelDataNameHasBeenSet(false), m_externalChannelDataValueHasBeenSet(false) { } CoreInternalOutcome CloudExternalChannelData::Deserialize(const rapidjson::Value &value) { string requestId = ""; if (value.HasMember("ExternalChannelDataName") && !value["ExternalChannelDataName"].IsNull()) { if (!value["ExternalChannelDataName"].IsString()) { return CoreInternalOutcome(Core::Error("response `CloudExternalChannelData.ExternalChannelDataName` IsString=false incorrectly").SetRequestId(requestId)); } m_externalChannelDataName = string(value["ExternalChannelDataName"].GetString()); m_externalChannelDataNameHasBeenSet = true; } if (value.HasMember("ExternalChannelDataValue") && !value["ExternalChannelDataValue"].IsNull()) { if (!value["ExternalChannelDataValue"].IsString()) { return CoreInternalOutcome(Core::Error("response `CloudExternalChannelData.ExternalChannelDataValue` IsString=false incorrectly").SetRequestId(requestId)); } m_externalChannelDataValue = string(value["ExternalChannelDataValue"].GetString()); m_externalChannelDataValueHasBeenSet = true; } return CoreInternalOutcome(true); } void CloudExternalChannelData::ToJsonObject(rapidjson::Value &value, rapidjson::Document::AllocatorType& allocator) const { if (m_externalChannelDataNameHasBeenSet) { rapidjson::Value iKey(rapidjson::kStringType); string key = "ExternalChannelDataName"; iKey.SetString(key.c_str(), allocator); value.AddMember(iKey, rapidjson::Value(m_externalChannelDataName.c_str(), allocator).Move(), allocator); } if (m_externalChannelDataValueHasBeenSet) { rapidjson::Value iKey(rapidjson::kStringType); string key = "ExternalChannelDataValue"; iKey.SetString(key.c_str(), allocator); value.AddMember(iKey, rapidjson::Value(m_externalChannelDataValue.c_str(), allocator).Move(), allocator); } } string CloudExternalChannelData::GetExternalChannelDataName() const { return m_externalChannelDataName; } void CloudExternalChannelData::SetExternalChannelDataName(const string& _externalChannelDataName) { m_externalChannelDataName = _externalChannelDataName; m_externalChannelDataNameHasBeenSet = true; } bool CloudExternalChannelData::ExternalChannelDataNameHasBeenSet() const { return m_externalChannelDataNameHasBeenSet; } string CloudExternalChannelData::GetExternalChannelDataValue() const { return m_externalChannelDataValue; } void CloudExternalChannelData::SetExternalChannelDataValue(const string& _externalChannelDataValue) { m_externalChannelDataValue = _externalChannelDataValue; m_externalChannelDataValueHasBeenSet = true; } bool CloudExternalChannelData::ExternalChannelDataValueHasBeenSet() const { return m_externalChannelDataValueHasBeenSet; }
[ "tencentcloudapi@tencent.com" ]
tencentcloudapi@tencent.com
6ba16fbd92905172eee2f8199f68ba1070bfd7be
05ace75fffe21a2d375e3611571f1a815d3c0fbc
/4.0.6/Core/src/server/game/Battlegrounds/Zones/BattlegroundTP.h
921bd0f5520b980a10f5ebb3c4e34072b450448d
[]
no_license
DeKaDeNcE/Project-WoW
97fcf9b505f2cd87e2fb17b27d92d960cdc12668
9307425445316cc4e88c73e116d4ea4d440d5ac2
refs/heads/master
2021-05-27T09:11:53.994059
2014-02-20T06:29:42
2014-02-20T06:29:42
null
0
0
null
null
null
null
UTF-8
C++
false
false
8,522
h
/* * Copyright (C) 2010-2012 Project SkyFire <http://www.projectskyfire.org/> * Copyright (C) 2005-2012 MaNGOS <http://www.getmangos.com/> * Copyright (C) 2008-2012 Trinity <http://www.trinitycore.org/> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef __BATTLEGROUNDTP_H #define __BATTLEGROUNDTP_H #include "Battleground.h" enum BG_TP_TimerOrScore { BG_TP_MAX_TEAM_SCORE = 3, BG_TP_FLAG_RESPAWN_TIME = 23000, BG_TP_FLAG_DROP_TIME = 10000, BG_TP_SPELL_FORCE_TIME = 600000, BG_TP_SPELL_BRUTAL_TIME = 900000 }; enum BG_TP_Sound { BG_TP_SOUND_FLAG_CAPTURED_ALLIANCE = 8173, BG_TP_SOUND_FLAG_CAPTURED_HORDE = 8213, BG_TP_SOUND_FLAG_PLACED = 8232, BG_TP_SOUND_FLAG_RETURNED = 8192, BG_TP_SOUND_HORDE_FLAG_PICKED_UP = 8212, BG_TP_SOUND_ALLIANCE_FLAG_PICKED_UP = 8174, BG_TP_SOUND_FLAGS_RESPAWNED = 8232 }; enum BG_TP_SpellId { BG_TP_SPELL_HORDE_FLAG = 23333, BG_TP_SPELL_HORDE_FLAG_DROPPED = 23334, BG_TP_SPELL_HORDE_FLAG_PICKED = 61266, // fake spell, does not exist but used as timer start event BG_TP_SPELL_ALLIANCE_FLAG = 23335, BG_TP_SPELL_ALLIANCE_FLAG_DROPPED = 23336, BG_TP_SPELL_ALLIANCE_FLAG_PICKED = 61265, // fake spell, does not exist but used as timer start event BG_TP_SPELL_FOCUSED_ASSAULT = 46392, BG_TP_SPELL_BRUTAL_ASSAULT = 46393 }; enum BG_TP_WorldStates { BG_TP_FLAG_UNK_ALLIANCE = 1545, BG_TP_FLAG_UNK_HORDE = 1546, BG_TP_FLAG_CAPTURES_ALLIANCE = 1581, BG_TP_FLAG_CAPTURES_HORDE = 1582, BG_TP_FLAG_CAPTURES_MAX = 1601, BG_TP_FLAG_STATE_HORDE = 2338, BG_TP_FLAG_STATE_ALLIANCE = 2339, BG_TP_STATE_TIMER = 4248, BG_TP_STATE_TIMER_ACTIVE = 4247 }; enum BG_TP_ObjectTypes { BG_TP_OBJECT_DOOR_A_1 = 0, BG_TP_OBJECT_DOOR_A_2 = 1, BG_TP_OBJECT_DOOR_A_3 = 2, BG_TP_OBJECT_DOOR_H_1 = 3, BG_TP_OBJECT_DOOR_H_2 = 4, BG_TP_OBJECT_DOOR_H_3 = 5, BG_TP_OBJECT_A_FLAG = 6, BG_TP_OBJECT_H_FLAG = 7, BG_TP_OBJECT_SPEEDBUFF_1 = 8, BG_TP_OBJECT_SPEEDBUFF_2 = 9, BG_TP_OBJECT_REGENBUFF_1 = 10, BG_TP_OBJECT_REGENBUFF_2 = 11, BG_TP_OBJECT_BERSERKBUFF_1 = 12, BG_TP_OBJECT_BERSERKBUFF_2 = 13, BG_TP_OBJECT_MAX = 14 }; enum BG_TP_ObjectEntry { BG_OBJECT_DOOR_A_1_TP_ENTRY = 6100006, BG_OBJECT_DOOR_A_2_TP_ENTRY = 6100005, BG_OBJECT_DOOR_A_3_TP_ENTRY = 6100007, BG_OBJECT_DOOR_H_1_TP_ENTRY = 6100003, BG_OBJECT_DOOR_H_2_TP_ENTRY = 6100004, BG_OBJECT_DOOR_H_3_TP_ENTRY = 6100002, BG_OBJECT_A_FLAG_TP_ENTRY = 179830, BG_OBJECT_H_FLAG_TP_ENTRY = 179831, BG_OBJECT_A_FLAG_GROUND_TP_ENTRY = 179785, BG_OBJECT_H_FLAG_GROUND_TP_ENTRY = 179786 }; enum BG_TP_FlagState { BG_TP_FLAG_STATE_ON_BASE = 0, BG_TP_FLAG_STATE_WAIT_RESPAWN = 1, BG_TP_FLAG_STATE_ON_PLAYER = 2, BG_TP_FLAG_STATE_ON_GROUND = 3 }; enum BG_TP_Graveyards { TP_GRAVEYARD_FLAGROOM_ALLIANCE = 1726, TP_GRAVEYARD_FLAGROOM_HORDE = 1727, TP_GRAVEYARD_START_ALLIANCE = 1729, TP_GRAVEYARD_START_HORDE = 1728, TP_GRAVEYARD_MIDDLE_ALLIANCE = 1749, TP_GRAVEYARD_MIDDLE_HORDE = 1750 }; enum BG_TP_CreatureTypes { TP_SPIRIT_ALLIANCE = 0, TP_SPIRIT_HORDE = 1, BG_CREATURES_MAX_TP = 2 }; enum BG_TP_CarrierDebuffs { TP_SPELL_FOCUSED_ASSAULT = 46392, TP_SPELL_BRUTAL_ASSAULT = 46393 }; enum BG_TP_Objectives { TP_OBJECTIVE_CAPTURE_FLAG = 42, TP_OBJECTIVE_RETURN_FLAG = 44 }; #define TP_EVENT_START_BATTLE 8563 class BattlegroundTPScore : public BattlegroundScore { public: BattlegroundTPScore() : FlagCaptures(0), FlagReturns(0) {}; virtual ~BattlegroundTPScore() {}; uint32 FlagCaptures; uint32 FlagReturns; }; class BattlegroundTP : public Battleground { friend class BattlegroundMgr; public: /* Construction */ BattlegroundTP(); ~BattlegroundTP(); void Update(uint32 diff); /* inherited from BattlegroundClass */ virtual void AddPlayer(Player *plr); virtual void StartingEventCloseDoors(); virtual void StartingEventOpenDoors(); /* BG Flags */ uint64 GetAllianceFlagPickerGUID() const { return m_FlagKeepers[BG_TEAM_ALLIANCE]; } uint64 GetHordeFlagPickerGUID() const { return m_FlagKeepers[BG_TEAM_HORDE]; } void SetAllianceFlagPicker(uint64 guid) { m_FlagKeepers[BG_TEAM_ALLIANCE] = guid; } void SetHordeFlagPicker(uint64 guid) { m_FlagKeepers[BG_TEAM_HORDE] = guid; } bool IsAllianceFlagPickedup() const { return m_FlagKeepers[BG_TEAM_ALLIANCE] != 0; } bool IsHordeFlagPickedup() const { return m_FlagKeepers[BG_TEAM_HORDE] != 0; } void RespawnFlag(uint32 Team, bool captured); void RespawnFlagAfterDrop(uint32 Team); uint8 GetFlagState(uint32 team) { return m_FlagState[GetTeamIndexByTeamId(team)]; } void AddTimedAura(uint32 aura); void RemoveTimedAura(uint32 aura); bool IsBrutalTimerDone; bool IsForceTimerDone; /* Battleground Events */ virtual void EventPlayerDroppedFlag(Player *Source); virtual void EventPlayerClickedOnFlag(Player *Source, GameObject* target_obj); virtual void EventPlayerCapturedFlag(Player *Source); void RemovePlayer(Player *plr, uint64 guid); void HandleAreaTrigger(Player *Source, uint32 Trigger); void HandleKillPlayer(Player *player, Player *killer); bool SetupBattleground(); virtual void Reset(); void EndBattleground(uint32 winner); virtual WorldSafeLocsEntry const* GetClosestGraveYard(Player* player); void UpdateFlagState(uint32 team, uint32 value); void SetLastFlagCapture(uint32 team) { m_LastFlagCaptureTeam = team; } void UpdateTeamScore(uint32 team); void UpdatePlayerScore(Player *Source, uint32 type, uint32 value, bool doAddHonor = true); void SetDroppedFlagGUID(uint64 guid, uint32 TeamID) { m_DroppedFlagGUID[GetTeamIndexByTeamId(TeamID)] = guid;} uint64 GetDroppedFlagGUID(uint32 TeamID) { return m_DroppedFlagGUID[GetTeamIndexByTeamId(TeamID)];} virtual void FillInitialWorldStates(WorldPacket& data); /* Scorekeeping */ uint32 GetTeamScore(uint32 TeamID) const { return m_TeamScores[GetTeamIndexByTeamId(TeamID)]; } void AddPoint(uint32 TeamID, uint32 Points = 1) { m_TeamScores[GetTeamIndexByTeamId(TeamID)] += Points; } void SetTeamPoint(uint32 TeamID, uint32 Points = 0) { m_TeamScores[GetTeamIndexByTeamId(TeamID)] = Points; } void RemovePoint(uint32 TeamID, uint32 Points = 1) { m_TeamScores[GetTeamIndexByTeamId(TeamID)] -= Points; } private: uint64 m_FlagKeepers[2]; // 0 - alliance, 1 - horde uint64 m_DroppedFlagGUID[2]; uint8 m_FlagState[2]; // for checking flag state int32 m_FlagsTimer[2]; int32 m_FlagsDropTimer[2]; uint32 m_LastFlagCaptureTeam; // Winner is based on this if score is equal uint32 m_ReputationCapture; uint32 m_HonorWinKills; uint32 m_HonorEndKills; int32 m_FlagSpellForceTimer; bool m_BothFlagsKept; uint8 m_FlagDebuffState; // 0 - no debuffs, 1 - focused assault, 2 - brutal assault uint8 m_minutesElapsed; }; #endif
[ "pat_66696@hotmail.com" ]
pat_66696@hotmail.com
52f77cdb8f278e6538d573db51016f8c6a6c31c1
4b44538a9d5552521a0239d1eeb8e0ad382753ad
/src/qt/editaddressdialog.cpp
7356176d9b8bbbe30ef37f18773d14e49d5ad7bd
[ "MIT" ]
permissive
denhag/tribe
07f03aa8be303d1f20f7320fe84b7cbc4167fd4d
09189eb68d5ccf14e14975cc996de1c2877ff58c
refs/heads/master
2020-05-31T03:03:22.797452
2019-06-04T10:11:04
2019-06-04T10:11:04
190,074,039
0
0
MIT
2019-06-03T20:04:57
2019-06-03T20:04:57
null
UTF-8
C++
false
false
3,989
cpp
// Copyright (c) 2011-2013 The Bitcoin Core developers // Copyright (c) 2014-2016 The Tribe Core developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #include "editaddressdialog.h" #include "ui_editaddressdialog.h" #include "addresstablemodel.h" #include "guiutil.h" #include <QDataWidgetMapper> #include <QMessageBox> EditAddressDialog::EditAddressDialog(Mode mode, QWidget *parent) : QDialog(parent), ui(new Ui::EditAddressDialog), mapper(0), mode(mode), model(0) { ui->setupUi(this); GUIUtil::setupAddressWidget(ui->addressEdit, this); switch(mode) { case NewReceivingAddress: setWindowTitle(tr("New receiving address")); ui->addressEdit->setEnabled(false); break; case NewSendingAddress: setWindowTitle(tr("New sending address")); break; case EditReceivingAddress: setWindowTitle(tr("Edit receiving address")); ui->addressEdit->setEnabled(false); break; case EditSendingAddress: setWindowTitle(tr("Edit sending address")); break; } mapper = new QDataWidgetMapper(this); mapper->setSubmitPolicy(QDataWidgetMapper::ManualSubmit); } EditAddressDialog::~EditAddressDialog() { delete ui; } void EditAddressDialog::setModel(AddressTableModel *model) { this->model = model; if(!model) return; mapper->setModel(model); mapper->addMapping(ui->labelEdit, AddressTableModel::Label); mapper->addMapping(ui->addressEdit, AddressTableModel::Address); } void EditAddressDialog::loadRow(int row) { mapper->setCurrentIndex(row); } bool EditAddressDialog::saveCurrentRow() { if(!model) return false; switch(mode) { case NewReceivingAddress: case NewSendingAddress: address = model->addRow( mode == NewSendingAddress ? AddressTableModel::Send : AddressTableModel::Receive, ui->labelEdit->text(), ui->addressEdit->text()); break; case EditReceivingAddress: case EditSendingAddress: if(mapper->submit()) { address = ui->addressEdit->text(); } break; } return !address.isEmpty(); } void EditAddressDialog::accept() { if(!model) return; if(!saveCurrentRow()) { switch(model->getEditStatus()) { case AddressTableModel::OK: // Failed with unknown reason. Just reject. break; case AddressTableModel::NO_CHANGES: // No changes were made during edit operation. Just reject. break; case AddressTableModel::INVALID_ADDRESS: QMessageBox::warning(this, windowTitle(), tr("The entered address \"%1\" is not a valid Tribe address.").arg(ui->addressEdit->text()), QMessageBox::Ok, QMessageBox::Ok); break; case AddressTableModel::DUPLICATE_ADDRESS: QMessageBox::warning(this, windowTitle(), tr("The entered address \"%1\" is already in the address book.").arg(ui->addressEdit->text()), QMessageBox::Ok, QMessageBox::Ok); break; case AddressTableModel::WALLET_UNLOCK_FAILURE: QMessageBox::critical(this, windowTitle(), tr("Could not unlock wallet."), QMessageBox::Ok, QMessageBox::Ok); break; case AddressTableModel::KEY_GENERATION_FAILURE: QMessageBox::critical(this, windowTitle(), tr("New key generation failed."), QMessageBox::Ok, QMessageBox::Ok); break; } return; } QDialog::accept(); } QString EditAddressDialog::getAddress() const { return address; } void EditAddressDialog::setAddress(const QString &address) { this->address = address; ui->addressEdit->setText(address); }
[ "183516+blocksninja@users.noreply.github.com" ]
183516+blocksninja@users.noreply.github.com
91a992589a29e24af63a117fef38895da961334f
66d13f6a4313baa32c6d430da1dec41c27a4b39c
/BOJ(Baekjoon Online Judge)/BOJ_1932_정수 삼각형.cpp
15bd4e472c94e2435dbd4c4658a94007c6784646
[]
no_license
IDdmseo/Online-Judge-Algorithm-
442cad71a0f154be8284bcd497165c3dc2f1ef92
0441123a70fafe5b8a0fb27c00587e37c5bb36bd
refs/heads/master
2021-04-07T01:40:49.817577
2020-09-02T04:14:58
2020-09-02T04:14:58
248,632,338
0
0
null
null
null
null
UTF-8
C++
false
false
1,040
cpp
#include <iostream> #include <string.h> #include <algorithm> using namespace std; int n, triangle[1000000], temp[1000000], mvalue, curr_sidx, prev_sidx = 1, prev_cols = 0; int main() { cin >> n; if (n < 1 || n > 500) return 0; for (int i = 1; i <= n; i++) { curr_sidx = prev_sidx + prev_cols; prev_sidx = curr_sidx, prev_cols = i; for (int j = 0; j < i; j++) { cin >> triangle[curr_sidx + j]; if (triangle[curr_sidx + j] < 0 || triangle[curr_sidx + j] > 9999) return 0; } } memcpy(temp, triangle, sizeof(triangle)); prev_sidx = 1, prev_cols = 0; for (int i = 1; i < n; i++) { curr_sidx = prev_sidx + prev_cols; prev_sidx = curr_sidx, prev_cols = i; for (int j = 0; j < i; j++) { mvalue = max(mvalue, temp[curr_sidx + j + i] = max(temp[curr_sidx + j] + triangle[curr_sidx + j + i], temp[curr_sidx + j + i])); mvalue = max(mvalue, temp[curr_sidx + j + i + 1] = max(temp[curr_sidx + j] + triangle[curr_sidx + j + i + 1], temp[curr_sidx + j + i + 1])); } } cout << mvalue << endl; return 0; }
[ "razorbackk1123@gmail.com" ]
razorbackk1123@gmail.com
20fd265a08fa13b0e0bffa0cbdd1e93360bb2a73
b6ab59730f0c66145f6a224389980c9a0f2a236b
/src/cpu.h
84d72be28b8a0b5418c407f90a32efbf11267173
[ "MIT" ]
permissive
mlavik1/NesEmulator
b40c79d7aea2f8219a22ef46a20b2afbb60026a0
4ef30eb2744f79f3fe4fed0e4883fb88d9cea9b4
refs/heads/master
2021-09-26T03:00:17.825426
2018-10-26T22:27:51
2018-10-26T22:27:51
108,322,720
1
0
null
null
null
null
UTF-8
C++
false
false
3,235
h
#ifndef NESEMU_CPU_H #define NESEMU_CPU_H #include <string> #include <stdint.h> typedef unsigned int statusflag_t; #define STATUSFLAG_NEGATIVE 128 #define STATUSFLAG_OVERFLOW 64 #define STATUSFLAG_DECIMAL 8 #define STATUSFLAG_INTERRUPT 4 #define STATUSFLAG_ZERO 2 #define STATUSFLAG_CARRY 1 namespace nesemu { enum AddressingMode { Accumulator, Immediate, // uses value directly (no memory lookup) ZeroPage, // first 256 bytes ZeroPageX, ZeroPageY, Absolute, // full 16 bit address - LSB MSB AbsoluteX, AbsoluteY, Indirect, IndirectX, IndirectY, Implied }; enum InterruptType { NMI, IRQ }; class CPU; // fwd.decl. struct Opcode { std::string mName; void(CPU::*mCallback)(); AddressingMode mAddressingMode; int mCycles; }; class CPU { private: uint8_t mRegA; uint8_t mRegX; uint8_t mRegY; uint8_t mStatusRegister; uint16_t mProgramCounter; uint8_t mStackPointer; Opcode* mCurrentOpcode; uint16_t mCurrentOperandAddress; uint16_t mNextOperationAddress; int mCurrentCycles = 0; uint16_t mNMILabel; uint16_t mIRQLabel; uint16_t mResetLabel; Opcode* mOpcodeTable[256]; void ClearFlags(statusflag_t flags); void SetFlags(statusflag_t flags); void SetFlags(statusflag_t flags, bool arg_set); void SetZNFlags(uint16_t arg_value); bool GetFlags(statusflag_t flags); Opcode* DecodeOpcode(uint8_t arg_op); void Reset(); void RegisterOpcodes(); void Branch(const uint8_t& arg_offset); /** * Decodes the address of a specified opcode. * @return Actual memory address to use. **/ uint16_t DecodeOperandAddress(const uint16_t arg_addr, AddressingMode arg_addrmode); // ***** OPCODES ***** // file:///C:/Users/DeepThought/Desktop/NES%20DOCS/Opcodes/6502%20Opcodes.html#TOC void opcode_notimplemented(); void opcode_jmp(); void opcode_jsr(); void opcode_rts(); void opcode_rti(); void opcode_brk(); // Processor status instructions void opcode_sei(); void opcode_cli(); void opcode_cld(); void opcode_clc(); void opcode_sec(); // Register manipulation instructions void opcode_lda(); void opcode_ldx(); void opcode_ldy(); void opcode_sta(); void opcode_stx(); void opcode_sty(); void opcode_inx(); void opcode_iny(); void opcode_adc(); // Register instructions void opcode_dey(); void opcode_tax(); void opcode_tay(); void opcode_tya(); void opcode_txa(); void opcode_cmp(); void opcode_cpx(); void opcode_cpy(); // Branch void opcode_bne(); // branch on not equal void opcode_bpl(); // branch on plus (not negative) void opcode_bcs(); // branch on carry set void opcode_bcc(); // branch on carry clear void opcode_bit(); // Stack instructions void opcode_txs(); void opcode_tsx(); void opcode_ora(); void opcode_asl(); void opcode_and(); void opcode_inc(); void opcode_dec(); public: CPU(); void Initialise(); void Tick(); void Interrupt(InterruptType arg_type); void StackPush(uint8_t arg_value); uint8_t StackPop(); void StackPushAddress(uint16_t arg_addr); uint16_t StackPopAddress(); inline int GetCurrentFrameCycles() { return mCurrentCycles; } const int CPUClockRate = 1789773; }; } #endif
[ "matias.lavik@hotmail.com" ]
matias.lavik@hotmail.com
bab86780c70da0a63fe2d5da8a3767c0e61e3771
d528afd7df7dcf44a2b9899a5f1590fa3a139ff1
/test.cpp
f1bf1854021964f567942a1bf69174c0d441cee4
[]
no_license
mmicko/terminal
5bd7382a8e44a8153b044702c7eccb45ce6eb795
e8ea0d4f4d892300e205abaec7eb837b11974d75
refs/heads/master
2021-05-08T19:51:41.719050
2018-01-30T19:35:15
2018-01-30T19:35:15
119,584,483
2
0
null
null
null
null
UTF-8
C++
false
false
1,737
cpp
#include <SDL/SDL.h> #include <verilated.h> #include "Vlcd_test.h" bool running = true; void DoEvents() { SDL_Event sevent; while(SDL_PollEvent(&sevent)) { switch(sevent.type) { case SDL_KEYDOWN: if(sevent.key.keysym.sym == SDLK_ESCAPE) running = false; break; case SDL_KEYUP: break; case SDL_QUIT: running = false; break; } } } int main(int argc, char **argv) { vluint64_t main_time = 0; Vlcd_test *top = new Vlcd_test; //The images SDL_Surface* screen = NULL; SDL_Init(SDL_INIT_VIDEO); //Set up screen screen = SDL_SetVideoMode( 480, 272, 32, SDL_SWSURFACE | SDL_RESIZABLE ); //Update Screen SDL_Flip( screen ); Uint8 *p = (Uint8 *)screen->pixels; Verilated::commandArgs(argc, argv); Verilated::debug(0); top->lcd_clk = 0; vluint64_t hs_cnt = 0; vluint64_t vs_cnt = 0; vluint64_t frames = 0; int x = 0; int y = 0; while (!Verilated::gotFinish() && running) { int prev_hs = top->lcd_hsync; int prev_vs = top->lcd_vsync; top->lcd_clk = top->lcd_clk ? 0 : 1; top->eval(); // Evaluate model if ((main_time % 2) == 0) { if (top->lcd_de==1 && y>3) { *p++ = top->lcd_b; *p++ = top->lcd_g; *p++ = top->lcd_r; p++; x++; } if (prev_hs==0 && top->lcd_hsync==1) { x=0; p = (Uint8 *)screen->pixels + (y-3)*480*4; y++; } if (prev_vs==0 && top->lcd_vsync==1) { y =0; SDL_Flip( screen ); p = (Uint8 *)screen->pixels; } } main_time++; DoEvents(); } top->final(); //Quit SDL SDL_Quit(); exit(0); }
[ "mmicko@gmail.com" ]
mmicko@gmail.com
82fc6e82c62d52887e8b50d11c09082a4fdbffd0
5815fb389338f76c77bc1e46602ea6076d16e523
/lib/RFM69/RFM69.cpp
a0a8ae329dc5dda87662156292238cd4025b3e37
[]
no_license
AlmightyLobsters/CanSat2017.GroundStation
3ba95728a2747b9a549b59d292469ffd4d3babca
e826b45cfc9a58cf3e8fa9364864d022d087843a
refs/heads/master
2021-01-11T17:45:18.830892
2017-09-18T17:22:03
2017-09-18T17:22:03
79,834,324
0
0
null
null
null
null
UTF-8
C++
false
false
20,579
cpp
// ********************************************************************************** // Driver definition for HopeRF RFM69W/RFM69HW/RFM69CW/RFM69HCW, Semtech SX1231/1231H // ********************************************************************************** // Copyright Felix Rusu (2014), felix@lowpowerlab.com // http://lowpowerlab.com/ // ********************************************************************************** // License // ********************************************************************************** // This program is free software; you can redistribute it // and/or modify it under the terms of the GNU General // Public License as published by the Free Software // Foundation; either version 3 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will // be useful, but WITHOUT ANY WARRANTY; without even the // implied warranty of MERCHANTABILITY or FITNESS FOR A // PARTICULAR PURPOSE. See the GNU General Public // License for more details. // // You should have received a copy of the GNU General // Public License along with this program. // If not, see <http://www.gnu.org/licenses/>. // // Licence can be viewed at // http://www.gnu.org/licenses/gpl-3.0.txt // // Please maintain this license information along with authorship // and copyright notices in any redistribution of this code // ********************************************************************************** #include <RFM69.h> #include <RFM69registers.h> #include <SPI.h> volatile uint8_t RFM69::DATA[RF69_MAX_DATA_LEN]; volatile uint8_t RFM69::_mode; // current transceiver state volatile uint8_t RFM69::DATALEN; volatile uint8_t RFM69::SENDERID; volatile uint8_t RFM69::TARGETID; // should match _address volatile uint8_t RFM69::PAYLOADLEN; volatile uint8_t RFM69::ACK_REQUESTED; volatile uint8_t RFM69::ACK_RECEIVED; // should be polled immediately after sending a packet with ACK request volatile int16_t RFM69::RSSI; // most accurate RSSI during reception (closest to the reception) RFM69* RFM69::selfPointer; bool RFM69::initialize(uint8_t freqBand, uint8_t nodeID, uint8_t networkID) { const uint8_t CONFIG[][2] = { /* 0x01 */ { REG_OPMODE, RF_OPMODE_SEQUENCER_ON | RF_OPMODE_LISTEN_OFF | RF_OPMODE_STANDBY }, /* 0x02 */ { REG_DATAMODUL, RF_DATAMODUL_DATAMODE_PACKET | RF_DATAMODUL_MODULATIONTYPE_FSK | RF_DATAMODUL_MODULATIONSHAPING_00 }, // no shaping /* 0x03 */ { REG_BITRATEMSB, RF_BITRATEMSB_1200}, // default: 4.8 KBPS and changed to 1.2 kbps /* 0x04 */ { REG_BITRATELSB, RF_BITRATELSB_1200}, /* 0x05 */ { REG_FDEVMSB, RF_FDEVMSB_50000}, // default: 5KHz, (FDEV + BitRate / 2 <= 500KHz) /* 0x06 */ { REG_FDEVLSB, RF_FDEVLSB_50000}, /* 0x07 */ { REG_FRFMSB, (uint8_t) (freqBand==RF69_315MHZ ? RF_FRFMSB_315 : (freqBand==RF69_433MHZ ? RF_FRFMSB_433 : (freqBand==RF69_868MHZ ? RF_FRFMSB_868 : RF_FRFMSB_915))) }, /* 0x08 */ { REG_FRFMID, (uint8_t) (freqBand==RF69_315MHZ ? RF_FRFMID_315 : (freqBand==RF69_433MHZ ? RF_FRFMID_433 : (freqBand==RF69_868MHZ ? RF_FRFMID_868 : RF_FRFMID_915))) }, /* 0x09 */ { REG_FRFLSB, (uint8_t) (freqBand==RF69_315MHZ ? RF_FRFLSB_315 : (freqBand==RF69_433MHZ ? RF_FRFLSB_433 : (freqBand==RF69_868MHZ ? RF_FRFLSB_868 : RF_FRFLSB_915))) }, // looks like PA1 and PA2 are not implemented on RFM69W, hence the max output power is 13dBm // +17dBm and +20dBm are possible on RFM69HW // +13dBm formula: Pout = -18 + OutputPower (with PA0 or PA1**) // +17dBm formula: Pout = -14 + OutputPower (with PA1 and PA2)** // +20dBm formula: Pout = -11 + OutputPower (with PA1 and PA2)** and high power PA settings (section 3.3.7 in datasheet) ///* 0x11 */ { REG_PALEVEL, RF_PALEVEL_PA0_ON | RF_PALEVEL_PA1_OFF | RF_PALEVEL_PA2_OFF | RF_PALEVEL_OUTPUTPOWER_11111}, ///* 0x13 */ { REG_OCP, RF_OCP_ON | RF_OCP_TRIM_95 }, // over current protection (default is 95mA) // RXBW defaults are { REG_RXBW, RF_RXBW_DCCFREQ_010 | RF_RXBW_MANT_24 | RF_RXBW_EXP_5} (RxBw: 10.4KHz) /* 0x19 */ { REG_RXBW, RF_RXBW_DCCFREQ_010 | RF_RXBW_MANT_16 | RF_RXBW_EXP_2 }, // (BitRate < 2 * RxBw) //for BR-19200: /* 0x19 */ { REG_RXBW, RF_RXBW_DCCFREQ_010 | RF_RXBW_MANT_24 | RF_RXBW_EXP_3 }, /* 0x25 */ { REG_DIOMAPPING1, RF_DIOMAPPING1_DIO0_01 }, // DIO0 is the only IRQ we're using /* 0x26 */ { REG_DIOMAPPING2, RF_DIOMAPPING2_CLKOUT_OFF }, // DIO5 ClkOut disable for power saving /* 0x28 */ { REG_IRQFLAGS2, RF_IRQFLAGS2_FIFOOVERRUN }, // writing to this bit ensures that the FIFO & status flags are reset /* 0x29 */ { REG_RSSITHRESH, 220 }, // must be set to dBm = (-Sensitivity / 2), default is 0xE4 = 228 so -114dBm ///* 0x2D */ { REG_PREAMBLELSB, RF_PREAMBLESIZE_LSB_VALUE } // default 3 preamble bytes 0xAAAAAA /* 0x2E */ { REG_SYNCCONFIG, RF_SYNC_ON | RF_SYNC_FIFOFILL_AUTO | RF_SYNC_SIZE_2 | RF_SYNC_TOL_0 }, /* 0x2F */ { REG_SYNCVALUE1, 0x2D }, // attempt to make this compatible with sync1 byte of RFM12B lib /* 0x30 */ { REG_SYNCVALUE2, networkID }, // NETWORK ID /* 0x37 */ { REG_PACKETCONFIG1, RF_PACKET1_FORMAT_VARIABLE | RF_PACKET1_DCFREE_OFF | RF_PACKET1_CRC_ON | RF_PACKET1_CRCAUTOCLEAR_ON | RF_PACKET1_ADRSFILTERING_OFF }, /* 0x38 */ { REG_PAYLOADLENGTH, 66 }, // in variable length mode: the max frame size, not used in TX ///* 0x39 */ { REG_NODEADRS, nodeID }, // turned off because we're not using address filtering /* 0x3C */ { REG_FIFOTHRESH, RF_FIFOTHRESH_TXSTART_FIFONOTEMPTY | RF_FIFOTHRESH_VALUE }, // TX on FIFO not empty /* 0x3D */ { REG_PACKETCONFIG2, RF_PACKET2_RXRESTARTDELAY_2BITS | RF_PACKET2_AUTORXRESTART_ON | RF_PACKET2_AES_OFF }, // RXRESTARTDELAY must match transmitter PA ramp-down time (bitrate dependent) //for BR-19200: /* 0x3D */ { REG_PACKETCONFIG2, RF_PACKET2_RXRESTARTDELAY_NONE | RF_PACKET2_AUTORXRESTART_ON | RF_PACKET2_AES_OFF }, // RXRESTARTDELAY must match transmitter PA ramp-down time (bitrate dependent) /* 0x6F */ { REG_TESTDAGC, RF_DAGC_IMPROVED_LOWBETA0 }, // run DAGC continuously in RX mode for Fading Margin Improvement, recommended default for AfcLowBetaOn=0 {255, 0} }; digitalWrite(_slaveSelectPin, HIGH); pinMode(_slaveSelectPin, OUTPUT); SPI.begin(); do writeReg(REG_SYNCVALUE1, 0xAA); while (readReg(REG_SYNCVALUE1) != 0xAA); do writeReg(REG_SYNCVALUE1, 0x55); while (readReg(REG_SYNCVALUE1) != 0x55); for (uint8_t i = 0; CONFIG[i][0] != 255; i++) writeReg(CONFIG[i][0], CONFIG[i][1]); // Encryption is persistent between resets and can trip you up during debugging. // Disable it during initialization so we always start from a known state. encrypt(0); setHighPower(_isRFM69HW); // called regardless if it's a RFM69W or RFM69HW setMode(RF69_MODE_STANDBY); while ((readReg(REG_IRQFLAGS1) & RF_IRQFLAGS1_MODEREADY) == 0x00); // wait for ModeReady attachInterrupt(_interruptNum, RFM69::isr0, RISING); selfPointer = this; _address = nodeID; return true; } // return the frequency (in Hz) uint32_t RFM69::getFrequency() { return RF69_FSTEP * (((uint32_t) readReg(REG_FRFMSB) << 16) + ((uint16_t) readReg(REG_FRFMID) << 8) + readReg(REG_FRFLSB)); } // set the frequency (in Hz) void RFM69::setFrequency(uint32_t freqHz) { uint8_t oldMode = _mode; if (oldMode == RF69_MODE_TX) { setMode(RF69_MODE_RX); } freqHz /= RF69_FSTEP; // divide down by FSTEP to get FRF writeReg(REG_FRFMSB, freqHz >> 16); writeReg(REG_FRFMID, freqHz >> 8); writeReg(REG_FRFLSB, freqHz); if (oldMode == RF69_MODE_RX) { setMode(RF69_MODE_SYNTH); } setMode(oldMode); } void RFM69::setMode(uint8_t newMode) { if (newMode == _mode) return; switch (newMode) { case RF69_MODE_TX: writeReg(REG_OPMODE, (readReg(REG_OPMODE) & 0xE3) | RF_OPMODE_TRANSMITTER); if (_isRFM69HW) setHighPowerRegs(true); break; case RF69_MODE_RX: writeReg(REG_OPMODE, (readReg(REG_OPMODE) & 0xE3) | RF_OPMODE_RECEIVER); if (_isRFM69HW) setHighPowerRegs(false); break; case RF69_MODE_SYNTH: writeReg(REG_OPMODE, (readReg(REG_OPMODE) & 0xE3) | RF_OPMODE_SYNTHESIZER); break; case RF69_MODE_STANDBY: writeReg(REG_OPMODE, (readReg(REG_OPMODE) & 0xE3) | RF_OPMODE_STANDBY); break; case RF69_MODE_SLEEP: writeReg(REG_OPMODE, (readReg(REG_OPMODE) & 0xE3) | RF_OPMODE_SLEEP); break; default: return; } // we are using packet mode, so this check is not really needed // but waiting for mode ready is necessary when going from sleep because the FIFO may not be immediately available from previous mode while (_mode == RF69_MODE_SLEEP && (readReg(REG_IRQFLAGS1) & RF_IRQFLAGS1_MODEREADY) == 0x00); // wait for ModeReady _mode = newMode; } //put transceiver in sleep mode to save battery - to wake or resume receiving just call receiveDone() void RFM69::sleep() { setMode(RF69_MODE_SLEEP); } //set this node's address void RFM69::setAddress(uint8_t addr) { _address = addr; writeReg(REG_NODEADRS, _address); } //set this node's network id void RFM69::setNetwork(uint8_t networkID) { writeReg(REG_SYNCVALUE2, networkID); } // set *transmit/TX* output power: 0=min, 31=max // this results in a "weaker" transmitted signal, and directly results in a lower RSSI at the receiver // the power configurations are explained in the SX1231H datasheet (Table 10 on p21; RegPaLevel p66): http://www.semtech.com/images/datasheet/sx1231h.pdf // valid powerLevel parameter values are 0-31 and result in a directly proportional effect on the output/transmission power // this function implements 2 modes as follows: // - for RFM69W the range is from 0-31 [-18dBm to 13dBm] (PA0 only on RFIO pin) // - for RFM69HW the range is from 0-31 [5dBm to 20dBm] (PA1 & PA2 on PA_BOOST pin & high Power PA settings - see section 3.3.7 in datasheet, p22) void RFM69::setPowerLevel(uint8_t powerLevel) { _powerLevel = (powerLevel > 31 ? 31 : powerLevel); if (_isRFM69HW) _powerLevel /= 2; writeReg(REG_PALEVEL, (readReg(REG_PALEVEL) & 0xE0) | _powerLevel); } bool RFM69::canSend() { if (_mode == RF69_MODE_RX && PAYLOADLEN == 0 && readRSSI() < CSMA_LIMIT) // if signal stronger than -100dBm is detected assume channel activity { setMode(RF69_MODE_STANDBY); return true; } return false; } void RFM69::send(uint8_t toAddress, const void* buffer, uint8_t bufferSize, bool requestACK) { writeReg(REG_PACKETCONFIG2, (readReg(REG_PACKETCONFIG2) & 0xFB) | RF_PACKET2_RXRESTART); // avoid RX deadlocks uint32_t now = millis(); while (!canSend() && millis() - now < RF69_CSMA_LIMIT_MS) receiveDone(); sendFrame(toAddress, buffer, bufferSize, requestACK, false); } // to increase the chance of getting a packet across, call this function instead of send // and it handles all the ACK requesting/retrying for you :) // The only twist is that you have to manually listen to ACK requests on the other side and send back the ACKs // The reason for the semi-automaton is that the lib is interrupt driven and // requires user action to read the received data and decide what to do with it // replies usually take only 5..8ms at 50kbps@915MHz bool RFM69::sendWithRetry(uint8_t toAddress, const void* buffer, uint8_t bufferSize, uint8_t retries, uint8_t retryWaitTime) { uint32_t sentTime; for (uint8_t i = 0; i <= retries; i++) { send(toAddress, buffer, bufferSize, true); sentTime = millis(); while (millis() - sentTime < retryWaitTime) { if (ACKReceived(toAddress)) { //Serial.print(" ~ms:"); Serial.print(millis() - sentTime); return true; } } //Serial.print(" RETRY#"); Serial.println(i + 1); } return false; } // should be polled immediately after sending a packet with ACK request bool RFM69::ACKReceived(uint8_t fromNodeID) { if (receiveDone()) return (SENDERID == fromNodeID || fromNodeID == RF69_BROADCAST_ADDR) && ACK_RECEIVED; return false; } // check whether an ACK was requested in the last received packet (non-broadcasted packet) bool RFM69::ACKRequested() { return ACK_REQUESTED && (TARGETID != RF69_BROADCAST_ADDR); } // should be called immediately after reception in case sender wants ACK void RFM69::sendACK(const void* buffer, uint8_t bufferSize) { uint8_t sender = SENDERID; int16_t _RSSI = RSSI; // save payload received RSSI value writeReg(REG_PACKETCONFIG2, (readReg(REG_PACKETCONFIG2) & 0xFB) | RF_PACKET2_RXRESTART); // avoid RX deadlocks uint32_t now = millis(); while (!canSend() && millis() - now < RF69_CSMA_LIMIT_MS) receiveDone(); sendFrame(sender, buffer, bufferSize, false, true); RSSI = _RSSI; // restore payload RSSI } // internal function void RFM69::sendFrame(uint8_t toAddress, const void* buffer, uint8_t bufferSize, bool requestACK, bool sendACK) { setMode(RF69_MODE_STANDBY); // turn off receiver to prevent reception while filling fifo while ((readReg(REG_IRQFLAGS1) & RF_IRQFLAGS1_MODEREADY) == 0x00); // wait for ModeReady writeReg(REG_DIOMAPPING1, RF_DIOMAPPING1_DIO0_00); // DIO0 is "Packet Sent" if (bufferSize > RF69_MAX_DATA_LEN) bufferSize = RF69_MAX_DATA_LEN; // control byte uint8_t CTLbyte = 0x00; if (sendACK) CTLbyte = 0x80; else if (requestACK) CTLbyte = 0x40; // write to FIFO select(); SPI.transfer(REG_FIFO | 0x80); SPI.transfer(bufferSize + 3); SPI.transfer(toAddress); SPI.transfer(_address); SPI.transfer(CTLbyte); for (uint8_t i = 0; i < bufferSize; i++) SPI.transfer(((uint8_t*) buffer)[i]); unselect(); // no need to wait for transmit mode to be ready since its handled by the radio setMode(RF69_MODE_TX); uint32_t txStart = millis(); while (digitalRead(_interruptPin) == 0 && millis() - txStart < RF69_TX_LIMIT_MS); // wait for DIO0 to turn HIGH signalling transmission finish //while (readReg(REG_IRQFLAGS2) & RF_IRQFLAGS2_PACKETSENT == 0x00); // wait for ModeReady setMode(RF69_MODE_STANDBY); } // internal function - interrupt gets called when a packet is received void RFM69::interruptHandler() { //pinMode(4, OUTPUT); //digitalWrite(4, 1); if (_mode == RF69_MODE_RX && (readReg(REG_IRQFLAGS2) & RF_IRQFLAGS2_PAYLOADREADY)) { //RSSI = readRSSI(); setMode(RF69_MODE_STANDBY); select(); SPI.transfer(REG_FIFO & 0x7F); PAYLOADLEN = SPI.transfer(0); PAYLOADLEN = PAYLOADLEN > 66 ? 66 : PAYLOADLEN; // precaution TARGETID = SPI.transfer(0); if(!(_promiscuousMode || TARGETID == _address || TARGETID == RF69_BROADCAST_ADDR) // match this node's address, or broadcast address or anything in promiscuous mode || PAYLOADLEN < 3) // address situation could receive packets that are malformed and don't fit this libraries extra fields { PAYLOADLEN = 0; unselect(); receiveBegin(); //digitalWrite(4, 0); return; } DATALEN = PAYLOADLEN - 3; SENDERID = SPI.transfer(0); uint8_t CTLbyte = SPI.transfer(0); ACK_RECEIVED = CTLbyte & 0x80; // extract ACK-received flag ACK_REQUESTED = CTLbyte & 0x40; // extract ACK-requested flag for (uint8_t i = 0; i < DATALEN; i++) { DATA[i] = SPI.transfer(0); } if (DATALEN < RF69_MAX_DATA_LEN) DATA[DATALEN] = 0; // add null at end of string unselect(); setMode(RF69_MODE_RX); } RSSI = readRSSI(); //digitalWrite(4, 0); } // internal function void RFM69::isr0() { selfPointer->interruptHandler(); } // internal function void RFM69::receiveBegin() { DATALEN = 0; SENDERID = 0; TARGETID = 0; PAYLOADLEN = 0; ACK_REQUESTED = 0; ACK_RECEIVED = 0; RSSI = 0; if (readReg(REG_IRQFLAGS2) & RF_IRQFLAGS2_PAYLOADREADY) writeReg(REG_PACKETCONFIG2, (readReg(REG_PACKETCONFIG2) & 0xFB) | RF_PACKET2_RXRESTART); // avoid RX deadlocks writeReg(REG_DIOMAPPING1, RF_DIOMAPPING1_DIO0_01); // set DIO0 to "PAYLOADREADY" in receive mode setMode(RF69_MODE_RX); } // checks if a packet was received and/or puts transceiver in receive (ie RX or listen) mode bool RFM69::receiveDone() { //ATOMIC_BLOCK(ATOMIC_FORCEON) //{ noInterrupts(); // re-enabled in unselect() via setMode() or via receiveBegin() if (_mode == RF69_MODE_RX && PAYLOADLEN > 0) { setMode(RF69_MODE_STANDBY); // enables interrupts return true; } else if (_mode == RF69_MODE_RX) // already in RX no payload yet { interrupts(); // explicitly re-enable interrupts return false; } receiveBegin(); return false; //} } // To enable encryption: radio.encrypt("ABCDEFGHIJKLMNOP"); // To disable encryption: radio.encrypt(null) or radio.encrypt(0) // KEY HAS TO BE 16 bytes !!! void RFM69::encrypt(const char* key) { setMode(RF69_MODE_STANDBY); if (key != 0) { select(); SPI.transfer(REG_AESKEY1 | 0x80); for (uint8_t i = 0; i < 16; i++) SPI.transfer(key[i]); unselect(); } writeReg(REG_PACKETCONFIG2, (readReg(REG_PACKETCONFIG2) & 0xFE) | (key ? 1 : 0)); } // get the received signal strength indicator (RSSI) int16_t RFM69::readRSSI(bool forceTrigger) { int16_t rssi = 0; if (forceTrigger) { // RSSI trigger not needed if DAGC is in continuous mode writeReg(REG_RSSICONFIG, RF_RSSI_START); while ((readReg(REG_RSSICONFIG) & RF_RSSI_DONE) == 0x00); // wait for RSSI_Ready } rssi = -readReg(REG_RSSIVALUE); rssi >>= 1; return rssi; } uint8_t RFM69::readReg(uint8_t addr) { select(); SPI.transfer(addr & 0x7F); uint8_t regval = SPI.transfer(0); unselect(); return regval; } void RFM69::writeReg(uint8_t addr, uint8_t value) { select(); SPI.transfer(addr | 0x80); SPI.transfer(value); unselect(); } // select the RFM69 transceiver (save SPI settings, set CS low) void RFM69::select() { noInterrupts(); // save current SPI settings _SPCR = SPCR; _SPSR = SPSR; // set RFM69 SPI settings SPI.setDataMode(SPI_MODE0); SPI.setBitOrder(MSBFIRST); SPI.setClockDivider(SPI_CLOCK_DIV4); // decided to slow down from DIV2 after SPI stalling in some instances, especially visible on mega1284p when RFM69 and FLASH chip both present digitalWrite(_slaveSelectPin, LOW); } // unselect the RFM69 transceiver (set CS high, restore SPI settings) void RFM69::unselect() { digitalWrite(_slaveSelectPin, HIGH); // restore SPI settings to what they were before talking to RFM69 SPCR = _SPCR; SPSR = _SPSR; interrupts(); } // true = disable filtering to capture all frames on network // false = enable node/broadcast filtering to capture only frames sent to this/broadcast address void RFM69::promiscuous(bool onOff) { _promiscuousMode = onOff; //writeReg(REG_PACKETCONFIG1, (readReg(REG_PACKETCONFIG1) & 0xF9) | (onOff ? RF_PACKET1_ADRSFILTERING_OFF : RF_PACKET1_ADRSFILTERING_NODEBROADCAST)); } // for RFM69HW only: you must call setHighPower(true) after initialize() or else transmission won't work void RFM69::setHighPower(bool onOff) { _isRFM69HW = onOff; writeReg(REG_OCP, _isRFM69HW ? RF_OCP_OFF : RF_OCP_ON); if (_isRFM69HW) // turning ON writeReg(REG_PALEVEL, (readReg(REG_PALEVEL) & 0x1F) | RF_PALEVEL_PA1_ON | RF_PALEVEL_PA2_ON); // enable P1 & P2 amplifier stages else writeReg(REG_PALEVEL, RF_PALEVEL_PA0_ON | RF_PALEVEL_PA1_OFF | RF_PALEVEL_PA2_OFF | _powerLevel); // enable P0 only } // internal function void RFM69::setHighPowerRegs(bool onOff) { writeReg(REG_TESTPA1, onOff ? 0x5D : 0x55); writeReg(REG_TESTPA2, onOff ? 0x7C : 0x70); } // set the slave select (CS) pin void RFM69::setCS(uint8_t newSPISlaveSelect) { _slaveSelectPin = newSPISlaveSelect; digitalWrite(_slaveSelectPin, HIGH); pinMode(_slaveSelectPin, OUTPUT); } // Serial.print all the RFM69 register values void RFM69::readAllRegs() { uint8_t regVal; for (uint8_t regAddr = 1; regAddr <= 0x4F; regAddr++) { select(); SPI.transfer(regAddr & 0x7F); // send address + r/w bit regVal = SPI.transfer(0); unselect(); Serial.print(regAddr, HEX); Serial.print(" - "); Serial.print(regVal,HEX); Serial.print(" - "); Serial.println(regVal,BIN); } unselect(); } uint8_t RFM69::readTemperature(uint8_t calFactor) // returns centigrade { setMode(RF69_MODE_STANDBY); writeReg(REG_TEMP1, RF_TEMP1_MEAS_START); while ((readReg(REG_TEMP1) & RF_TEMP1_MEAS_RUNNING)); return ~readReg(REG_TEMP2) + COURSE_TEMP_COEF + calFactor; // 'complement' corrects the slope, rising temp = rising val } // COURSE_TEMP_COEF puts reading in the ballpark, user can add additional correction void RFM69::rcCalibration() { writeReg(REG_OSC1, RF_OSC1_RCCAL_START); while ((readReg(REG_OSC1) & RF_OSC1_RCCAL_DONE) == 0x00); }
[ "vojtechstepancik@outlook.com" ]
vojtechstepancik@outlook.com
3a4b3cebc38ae1e19a973ea56c52ce2fd00663d1
06954096d7b4d0732379f6354f8a355af6070831
/src/game/shared/swarm/asw_holdout_mode.h
8806c2385e4c1a2869f89908ba3203bcd2c941ee
[]
no_license
Nightgunner5/Jastian-Summer
9ee590bdac8d5cf281f844d1be3f1f5709ae4b91
22749cf0839bbb559bd13ec7e6a5af4458b8bdb7
refs/heads/master
2016-09-06T15:55:32.938564
2011-04-16T17:57:12
2011-04-16T17:57:12
1,446,629
1
1
null
null
null
null
UTF-8
C++
false
false
4,424
h
#ifndef _INCLUDED_ASW_HOLDOUT_MODE_H #define _INCLUDED_ASW_HOLDOUT_MODE_H #ifdef _WIN32 #pragma once #endif #include "UtlSortVector.h" #ifdef CLIENT_DLL #define CASW_Holdout_Mode C_ASW_Holdout_Mode #else class CASW_Player; class CASW_Marine_Resource; class CASW_EquipItem; #endif class CASW_Holdout_Wave; class CASW_Holdout_Wave_Entry; class CASW_Spawn_Group; enum ASW_Holdout_Event_t { HOLDOUT_EVENT_START_WAVE_ENTRY = 0, HOLDOUT_EVENT_SINGLE_SPAWN, HOLDOUT_EVENT_STATE_CHANGE, }; enum ASW_Holdout_State_t { HOLDOUT_STATE_BRIEFING = 0, HOLDOUT_STATE_ANNOUNCE_NEW_WAVE, HOLDOUT_STATE_WAVE_IN_PROGRESS, HOLDOUT_STATE_SHOWING_WAVE_SCORE, // HOLDOUT_STATE_RESUPPLY, HOLDOUT_STATE_COMPLETE, }; class CASW_Holdout_Event { public: ASW_Holdout_Event_t m_EventType; float m_flEventTime; }; class CASW_Holdout_Spawn_Event : public CASW_Holdout_Event { public: CASW_Holdout_Wave_Entry *m_pWaveEntry; }; class CASW_Holdout_State_Change_Event : public CASW_Holdout_Event { public: ASW_Holdout_State_t m_NewState; }; class CASW_Holdout_Event_LessFunc { public: bool Less( CASW_Holdout_Event * const & lhs, CASW_Holdout_Event * const & rhs, void *pContext ) { return lhs->m_flEventTime < rhs->m_flEventTime; } }; #define MAX_HOLDOUT_WAVES 10 //----------------------------------------------------------------------------- // This entity is responsible for the holdout mode logic. // It process the holdout wave events and controls holdout mode state //----------------------------------------------------------------------------- class CASW_Holdout_Mode : public CBaseEntity { public: DECLARE_CLASS( CASW_Holdout_Mode, CBaseEntity ); DECLARE_NETWORKCLASS(); #ifdef GAME_DLL DECLARE_DATADESC(); #endif CASW_Holdout_Mode(); virtual ~CASW_Holdout_Mode(); void LevelInitPostEntity(); virtual void UpdateOnRemove(); ASW_Holdout_State_t GetHoldoutState() { return (ASW_Holdout_State_t) m_nHoldoutState.Get(); } int GetCurrentWave() { return m_nCurrentWave.Get(); } int GetCurrentScore(); int GetCurrentScore( int i ); int GetAliensKilledThisWave() { return m_nAliensKilledThisWave.Get(); } // float GetResupplyEndTime() { return m_flResupplyEndTime.Get(); } float GetWaveProgress(); int GetNumWaves() { return m_Waves.Count(); } #ifdef GAME_DLL virtual void Spawn(); virtual void Activate(); virtual void Precache(); virtual int ShouldTransmit( const CCheckTransmitInfo *pInfo ) { return FL_EDICT_ALWAYS; } void InputUnlockResupply( inputdata_t &inputdata ); void OnMissionStart(); void OnAlienKilled( CBaseEntity *pAlien, const CTakeDamageInfo &info ); void HoldoutThink(); void SetCurrentWave( int nWave ) { m_nCurrentWave = nWave; } void StartWave( int nWave ); void LoadoutSelect( CASW_Marine_Resource *pMarineResource, int nEquipIndex, int nInvSlot ); #else void OnDataChanged( DataUpdateType_t updateType ); #endif protected: #ifdef GAME_DLL void AddEvent( CASW_Holdout_Event *pEvent ); void ProcessEvent( CASW_Holdout_Event *pEvent ); void ChangeHoldoutState( ASW_Holdout_State_t nNewState ); int SpawnAliens( int nQuantity, CASW_Holdout_Wave_Entry *pEntry, CASW_Spawn_Group *pSpawnGroup ); void RefillMarineAmmo(); void ResurrectDeadMarines(); CUtlSortVector< CASW_Holdout_Event *, CASW_Holdout_Event_LessFunc > m_Events; // Outputs COutputEvent m_OnWave[MAX_HOLDOUT_WAVES]; // Fired when the matching wave starts. COutputEvent m_OnWaveDefault; // Fired on all waves, regardless of number. COutputEvent m_OnAnnounceWave[MAX_HOLDOUT_WAVES]; // Fired when the matching wave is announced. COutputEvent m_OnAnnounceWaveDefault; // Fired when any wave is announced, regardless of number. string_t m_holdoutFilename; float m_nMarineLastRespawned[8]; int m_nUnlockedResupply; bool m_bResurrectingMarines; #endif CNetworkVar( int, m_nHoldoutState ); CNetworkVar( int, m_nCurrentWave ); CNetworkArray( int, m_nCurrentScore, 5 ); CNetworkVar( int, m_nAliensKilledThisWave ); CNetworkVar( float, m_flCurrentWaveStartTime ); // CNetworkVar( float, m_flResupplyEndTime ); CNetworkString( m_netHoldoutFilename, MAX_PATH ); void LoadWaves(); CUtlVector<CASW_Holdout_Wave*> m_Waves; }; // returns the holdout mode, if any in the current map CASW_Holdout_Mode* ASWHoldoutMode(); #endif /* _INCLUDED_ASW_HOLDOUT_MODE_H */
[ "nightgunner5@llamaslayers.net" ]
nightgunner5@llamaslayers.net
8603c64e7777bf5a321271ec765039a4bc1034c9
e76ea38dbe5774fccaf14e1a0090d9275cdaee08
/src/ash/keyboard_controller_proxy_stub.h
25310d716012678fc6c4b05fef83e1b973ec0969
[ "BSD-3-Clause" ]
permissive
eurogiciel-oss/Tizen_Crosswalk
efc424807a5434df1d5c9e8ed51364974643707d
a68aed6e29bd157c95564e7af2e3a26191813e51
refs/heads/master
2021-01-18T19:19:04.527505
2014-02-06T13:43:21
2014-02-06T13:43:21
16,070,101
1
3
null
null
null
null
UTF-8
C++
false
false
1,085
h
// Copyright 2013 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef ASH_KEYBOARD_CONTROLLER_PROXY_STUB_H_ #define ASH_KEYBOARD_CONTROLLER_PROXY_STUB_H_ #include "ash/ash_export.h" #include "ui/keyboard/keyboard_controller_proxy.h" namespace ash { // Stub implementation of KeyboardControllerProxy class ASH_EXPORT KeyboardControllerProxyStub : public keyboard::KeyboardControllerProxy { public: KeyboardControllerProxyStub(); virtual ~KeyboardControllerProxyStub(); private: // Overridden from keyboard::KeyboardControllerProxy: virtual content::BrowserContext* GetBrowserContext() OVERRIDE; virtual ui::InputMethod* GetInputMethod() OVERRIDE; virtual void RequestAudioInput(content::WebContents* web_contents, const content::MediaStreamRequest& request, const content::MediaResponseCallback& callback) OVERRIDE; DISALLOW_COPY_AND_ASSIGN(KeyboardControllerProxyStub); }; } // namespace ash #endif // ASH_KEYBOARD_CONTROLLER_PROXY_STUB_H_
[ "ronan@fridu.net" ]
ronan@fridu.net
58a96f8fb7f0607ae9d50461e70657429f082c32
6cd74c978c7c61009b90ff1b1d5cde56c808fa2b
/parser/ast/unary_operator.h
6c3a802e9e68a3d556d5fc053cb9e7b38d20e97b
[ "MIT" ]
permissive
livace/Oberon-07
0d2db2c1a501fbf36e19f45b2aab25a183d90116
6d5d3c0c92bc09d0c62ed75b0edabbb5e9a09d7b
refs/heads/master
2023-05-10T18:23:09.309747
2021-06-02T21:04:36
2021-06-02T21:04:36
363,972,121
0
0
MIT
2021-06-01T16:46:32
2021-05-03T15:17:05
C++
UTF-8
C++
false
false
69
h
#pragma once #include "ast.h" class UnaryOperator : public Ast {};
[ "l1vac3@gmail.com" ]
l1vac3@gmail.com
c066b7f97d66e940c76fa3308d315bb64d18cd41
a6bb3bfa0826515eae2b0cdaf5361faf654c3a98
/examples/i-am-bejeweled/src/types/TextureTypes.cpp
492111001c7845d151cba5529e670d7e5fae860a
[]
no_license
tromagon/confitureplease
ce94401f4742b2b00971a407073d82708afafcb2
d8f2fde5f0bc693b33c42f8b87fb6acf80c8413a
refs/heads/master
2021-05-28T06:47:44.260430
2015-01-14T02:15:40
2015-01-14T02:15:40
null
0
0
null
null
null
null
UTF-8
C++
false
false
363
cpp
#include "TextureTypes.h" const char* TextureTypes::GRID_BGND = "grid_bgnd.png"; const char* TextureTypes::ORANGE = "orange.png"; const char* TextureTypes::BLUE = "blue.png"; const char* TextureTypes::GREEN = "green.png"; const char* TextureTypes::PURPLE = "purple.png"; const char* TextureTypes::RED = "red.png"; const char* TextureTypes::YELLOW = "yellow.png";
[ "thomas.barembaum@gmail.com" ]
thomas.barembaum@gmail.com
03b8c78a20c3c0c89fd2358df74b28e047f464a1
c7dc17fcfa3312ca2076b5d073d22adc36c14d0f
/Cube/Cube.ino
5c6b3bb65e208c1dea88d5180c6d331f98a629d2
[]
no_license
christineyen/cubes
5342968c1b3f0dd1773ca175a93832fbc97667df
10f897c90bf2d42ca9f3ac7c7006c890e138af81
refs/heads/master
2020-03-25T09:56:16.573640
2018-08-25T07:27:27
2018-08-25T07:27:27
143,679,953
0
0
null
null
null
null
UTF-8
C++
false
false
10,694
ino
// CUBES #define NODEID 2 //PROVIDED BY BUILD -- must be uniquefor each node on same network (range up to 254, 255 is used for broadcast) // ********************************************************************************** #include "FastLED.h" // FastLED library. Please use the latest development version. #include <RFM69.h> // get it here: https://www.github.com/lowpowerlab/rfm69 #include <SPIFlash.h> // get it here: https://www.github.com/lowpowerlab/spiflash #include <SPI.h> // included with Arduino IDE install (www.arduino.cc) // Cube-related stuff #include "Palette.h" //********************************************************************************************* //************ IMPORTANT SETTINGS - YOU MUST CHANGE/CONFIGURE TO FIT YOUR HARDWARE ************ //********************************************************************************************* #define NETWORKID 200 //the same on all nodes that talk to each other (range up to 255) #define FREQUENCY RF69_915MHZ //Match freq to the hardware version of radio on your Moteino #define IS_RFM69HW_HCW //uncomment only for RFM69HW/HCW! Leave out if you have RFM69W/CW! //********************************************************************************************* #ifdef __AVR_ATmega1284P__ #define LED 15 // Moteino MEGAs have LEDs on D15 #define FLASH_SS 23 // and FLASH SS on D23 #else #define LED 9 // Moteinos have LEDs on D9 #define FLASH_SS 8 // and FLASH SS on D8 #endif int TRANSMITPERIOD = 500; //transmit a packet to gateway so often (in ms) int16_t RSSITHRESHOLD = -50; SPIFlash flash(FLASH_SS, 0xEF30); //EF30 for 4mbit Windbond chip (W25X40CL) RFM69 radio; // FastLED/Neopixel constants #define LED_DT 6 // Data pin to connect to the strip. // #define LED_CK 11 // Clock pin for WS2801 or APA102. #define COLOR_ORDER GRB // It's GRB for WS2812 and BGR for APA102. #define LED_TYPE WS2812 // Using APA102, WS2812, WS2801. Don't forget to change LEDS.addLeds. #define NUM_LEDS 60 // Number of LED's. struct CRGB leds[NUM_LEDS]; // Initialize our LED array. // CUBE-SPECIFIC STUFF const char PAYLOAD[] = "4xth]jWt"; // security through obscurity! const uint8_t PAYLOAD_LEN = sizeof(PAYLOAD); const uint8_t RSSI_WINDOW_LEN = 10; // NodeRecord tracks a Node that we've received a message from. typedef struct { // unique identifier for the Node int8_t nodeID; // ticks are the lifeblood of "include me in your color scheme!" // once a NodeRecord runs out of ticks (which are decremented each // TRANSMITPERIOD), it'll stop contributing to the color scheme. uint8_t ticks; // rssis + rssiPtr allow us to track a moving average of the signal strengths // received by this Node from the NodeRecord.nodeID. int16_t rssis[RSSI_WINDOW_LEN]; uint8_t rssiPtr; } NodeRecord; const uint8_t DEFAULT_TICKS = 5; uint8_t NUM_NODES = 0; // we rely on promiscuousMode to pick up other nodes' broadcasts, but we keep // track of which nodes we've seen (in order to maybe impact our colors) NodeRecord XMIT[10]; // currentPalette stores the **current state of the LEDs** CRGBPalette16 currentPalette(COLORS[NODEID]); // targetPalette represents the palette we're blending towards. At steady // state, currentPalette and targetPalette are identical CRGBPalette16 targetPalette; void setup() { Serial.begin(57600); while (!Serial) { ; // wait for serial port to connect. Needed for native USB port only } delay(1000); // Soft startup to ease the flow of electrons. FastLED.addLeds<NEOPIXEL, LED_DT>(leds, NUM_LEDS); set_max_power_in_volts_and_milliamps(5, 100); // FastLED Power management set at 5V, 500mA. radio.initialize(FREQUENCY,NODEID,NETWORKID); #ifdef IS_RFM69HW_HCW radio.setHighPower(); //must include this only for RFM69HW/HCW! #endif radio.encrypt(null); radio.promiscuous(true); //radio.setFrequency(919000000); //set frequency to some custom frequency radio.setPowerLevel(0); } // handleDebug processes any serial input from within the loop() fn void handleDebug() { if (Serial.available() <= 0) { return; } char input = Serial.read(); if (input >= 48 && input <= 57) { //[0,9] TRANSMITPERIOD = 100 * (input-48); if (TRANSMITPERIOD == 0) TRANSMITPERIOD = 1000; Serial.print("\nChanging delay to "); Serial.print(TRANSMITPERIOD); Serial.println("ms\n"); } if (input == 'j') { RSSITHRESHOLD--; Serial.print("\nRSSI threshold:"); Serial.print(RSSITHRESHOLD); Serial.println(";\n"); } if (input == 'k') { RSSITHRESHOLD++; Serial.print("\nRSSI threshold:"); Serial.print(RSSITHRESHOLD); Serial.println(";\n"); } if (input == 'r') { //d=dump register values radio.readAllRegs(); } if (input == 'd') { //d=dump flash area Serial.println("Flash content:"); uint16_t counter = 0; Serial.print("0-256: "); while(counter<=256){ Serial.print(flash.readByte(counter++), HEX); Serial.print('.'); } while(flash.busy()); Serial.println(); } if (input == 'e') { Serial.print("Erasing Flash chip ... "); flash.chipErase(); while(flash.busy()); Serial.println("DONE"); } if (input == 'i') { Serial.print("Node ID: "); Serial.print(NODEID); } if (input == 't') { byte temperature = radio.readTemperature(-1); // -1 = user cal factor, adjust for correct ambient byte fTemp = 1.8 * temperature + 32; // 9/5=1.8 Serial.print( "Radio Temp is "); Serial.print(temperature); Serial.print("C, "); Serial.print(fTemp); //converting to F loses some resolution, obvious when C is on edge between 2 values (ie 26C=78F, 27C=80F) Serial.println('F'); } } // setPaletteColor helps us make sure we have a bit of texture for the many // solid colors we fetched // // It also offers a guardrail against IndexOutOfRange errors since we call this // in weird spots in a loop void setPaletteColor(uint8_t ledIdx, uint8_t nodeIdx) { if (ledIdx >= 16) { return; } CHSV hsv = COLORS[nodeIdx]; hsv.sat = 155 + 100 * (float(ledIdx % 4) / 4); targetPalette[ledIdx] = hsv; } // updateCurrentPalette takes a look at the NodeRecords we know about, and for // the ones with .ticks > 0, updates our palette to include colors from that // Node. void updateCurrentPalette() { // Output diagnostics Serial.print("\n= XMIT NODES: "); for (uint8_t i = 0; i < NUM_NODES; i++) { Serial.print(XMIT[i].nodeID, DEC); Serial.print(":"); Serial.print(XMIT[i].ticks, DEC); Serial.print(" "); } Serial.println(";\n"); uint8_t numOtherColors = 0; for (uint8_t i = 0; i < NUM_NODES; i++) { if (XMIT[i].ticks > 0) { numOtherColors++; } } // Update target palette based on the Nodes (this may be a duplicate, who // knows) uint8_t i = 0; uint8_t nodeIdx = 0; if (numOtherColors == 0) { targetPalette = CRGBPalette16(COLORS[NODEID]); } else { while (i < 16) { // just start off with the NODEID color and essentially kick off another // iteration of the loop if (nodeIdx % numOtherColors == 0) { setPaletteColor(i, NODEID); setPaletteColor(i + 1, NODEID); i += 2; } // find the next XMIT node with a legit number of ticks while (XMIT[nodeIdx % NUM_NODES].ticks <= 0) { nodeIdx++; } setPaletteColor(i, XMIT[nodeIdx % NUM_NODES].nodeID); setPaletteColor(i + 1, XMIT[nodeIdx % NUM_NODES].nodeID); i += 2; nodeIdx++; } } // Crossfade current palette slowly toward the target palette // // Each time that nblendPaletteTowardPalette is called, small changes // are made to currentPalette to bring it closer to matching targetPalette. // You can control how many changes are made in each call: // - meaningful values are 1-48. 1=veeeeeeeery slow, 48=quickest for (uint8_t i = 0; i < 10; i++) { nblendPaletteTowardPalette(currentPalette, targetPalette, 48); } } bool checkPayload(char radioPayload[]) { for (uint8_t i = 0; i < PAYLOAD_LEN; i++) { if (PAYLOAD[i] != radioPayload[i]) { return false; } } return true; } int16_t avgRssis(int16_t rssis[]) { long sum = 0; for (uint8_t i = 0; i < RSSI_WINDOW_LEN; i++) { sum += rssis[i]; } return sum/RSSI_WINDOW_LEN; } long lastPeriod = 0; void loop() { //process any serial input handleDebug(); static uint8_t startIndex = 0; //check for any received packets if (radio.receiveDone()) { Serial.print('[');Serial.print(radio.SENDERID, DEC);Serial.print("] "); Serial.print(" [RX_RSSI:");Serial.print(radio.RSSI, DEC);Serial.println("] "); if ((sizeof(PAYLOAD) == radio.DATALEN) && checkPayload(radio.DATA)) { // Find XMIT record, if appropriate uint8_t idx = 0; for (;idx < NUM_NODES; idx++) { if (XMIT[idx].nodeID == radio.SENDERID) { break; } } // at this point idx will either be the correct index or equal to NUM_NODES if (idx == NUM_NODES) { XMIT[idx] = { radio.SENDERID, 0, { radio.RSSI, -100, -100, -100, -100, -100, -100, -100, -100, -100 }, 1 // so that the position updated next time through the loop is idx 1 }; NUM_NODES++; } else { XMIT[idx].rssis[XMIT[idx].rssiPtr] = radio.RSSI; XMIT[idx].rssiPtr = (XMIT[idx].rssiPtr + 1) % RSSI_WINDOW_LEN; if (avgRssis(XMIT[idx].rssis) > RSSITHRESHOLD) { Serial.print("Node over threshold! "); Serial.println(XMIT[idx].nodeID, DEC); XMIT[idx].ticks = DEFAULT_TICKS; } } } } static unsigned long currPeriod; currPeriod = millis()/TRANSMITPERIOD; if (currPeriod != lastPeriod) { lastPeriod=currPeriod; if (NUM_NODES == 0) { Serial.println("No nodes to transmit to!"); } radio.send(NODEID, PAYLOAD, PAYLOAD_LEN); // decay nodes and renew ones we've been seeing strongly for (uint8_t i = 0; i < NUM_NODES; i++) { if (XMIT[i].ticks > 0) { XMIT[i].ticks--; } } updateCurrentPalette(); } EVERY_N_MILLISECONDS(10) { fill_palette(leds, // LEDs aka CRGB * NUM_LEDS, // length of LEDs startIndex, // startIndex - if constant, then motion will stay constant 1, // higher = higher frequency currentPalette, 255, // max brightness LINEARBLEND); // And now reflect the effects of whatever we received during the receive phase FastLED.show(); // Power managed display startIndex++; } }
[ "cyen@christineyen.com" ]
cyen@christineyen.com
18ce07051f207306182c50eea56bbc4a5688dcd4
09a4962b93c196f2f8a70c2384757142793612fd
/Dripdoctors/build/Android/Preview/Dripdoctors/app/src/main/include/Fuse.GeoLocation.LocationTracker.h
cbf71659f8d86b59ee87883d87f9200018f2d85b
[]
no_license
JimmyRodriguez/apps-fuse
169779ff2827a6e35be91d9ff17e0c444ba7f8cd
14114328c3cea08c1fd766bf085bbf5a67f698ae
refs/heads/master
2020-12-03T09:25:26.566750
2016-09-24T14:24:49
2016-09-24T14:24:49
65,154,944
0
0
null
null
null
null
UTF-8
C++
false
false
3,001
h
// This file was generated based on C:\ProgramData\Uno\Packages\Fuse.GeoLocation\0.32.14\$.uno. // WARNING: Changes might be lost if you edit this file directly. #pragma once #include <Uno.Object.h> namespace g{namespace Fuse{namespace GeoLocation{struct Location;}}} namespace g{namespace Fuse{namespace GeoLocation{struct LocationTracker;}}} namespace g{namespace Uno{namespace Threading{struct Future1;}}} namespace g{namespace Uno{struct Exception;}} namespace g{ namespace Fuse{ namespace GeoLocation{ // public sealed class LocationTracker :266 // { uType* LocationTracker_typeof(); void LocationTracker__ctor__fn(LocationTracker* __this); void LocationTracker__get_AuthorizationType_fn(LocationTracker* __this, int* __retval); void LocationTracker__set_AuthorizationType_fn(LocationTracker* __this, int* value); void LocationTracker__GetLocationAsync_fn(LocationTracker* __this, double* timeout, ::g::Uno::Threading::Future1** __retval); void LocationTracker__Init_fn(LocationTracker* __this); void LocationTracker__get_Location_fn(LocationTracker* __this, ::g::Fuse::GeoLocation::Location** __retval); void LocationTracker__add_LocationChanged_fn(LocationTracker* __this, uDelegate* value); void LocationTracker__remove_LocationChanged_fn(LocationTracker* __this, uDelegate* value); void LocationTracker__add_LocationError_fn(LocationTracker* __this, uDelegate* value); void LocationTracker__remove_LocationError_fn(LocationTracker* __this, uDelegate* value); void LocationTracker__New1_fn(LocationTracker** __retval); void LocationTracker__OnLocationChanged_fn(LocationTracker* __this, ::g::Fuse::GeoLocation::Location* newLocation); void LocationTracker__OnLocationError_fn(LocationTracker* __this, ::g::Uno::Exception* error); void LocationTracker__StartListening_fn(LocationTracker* __this, int* minimumReportInterval, double* desiredAccuracyInMeters); void LocationTracker__StopListening_fn(LocationTracker* __this); struct LocationTracker : uObject { uStrong< ::g::Fuse::GeoLocation::Location*> _lastLocation; static uSStrong<uObject*> _locationTracker_; static uSStrong<uObject*>& _locationTracker() { return _locationTracker_; } int _AuthorizationType; uStrong<uDelegate*> LocationChanged1; uStrong<uDelegate*> LocationError1; void ctor_(); int AuthorizationType(); void AuthorizationType(int value); ::g::Uno::Threading::Future1* GetLocationAsync(double timeout); void Init(); ::g::Fuse::GeoLocation::Location* Location(); void add_LocationChanged(uDelegate* value); void remove_LocationChanged(uDelegate* value); void add_LocationError(uDelegate* value); void remove_LocationError(uDelegate* value); void OnLocationChanged(::g::Fuse::GeoLocation::Location* newLocation); void OnLocationError(::g::Uno::Exception* error); void StartListening(int minimumReportInterval, double desiredAccuracyInMeters); void StopListening(); static LocationTracker* New1(); }; // } }}} // ::g::Fuse::GeoLocation
[ "jimmy_sidney@hotmail.es" ]
jimmy_sidney@hotmail.es
a69a8edd31f3d8c0b906592d07aa5dfc759fcb1b
3745a2d6049ae93dbe298ea6ab8ec675c4112da0
/Editor/DB/DBObjectPropertyGrid.h
d65ade001867698286944a1cf8b334677b2fbd0f
[]
no_license
albertomila/mini-game-engine-and-editor
17aa60c1376b672446950fa4869892880fe57de1
46919411c43b5f046e740a657b0e9f42f4c155ba
refs/heads/master
2020-06-17T08:39:02.331449
2019-07-08T18:18:26
2019-07-08T18:18:26
195,864,185
0
0
null
null
null
null
UTF-8
C++
false
false
1,977
h
#pragma once #include "Game\Core\Callback.h" #include "Game\Core\StringID.h" #include "wx\event.h" #include "wx\dialog.h" #include <vector> class CDbObject; class wxPropertyGridEvent; class wxCommandEvent; class wxPropertyCategory; class CMember; class IPropertyModifier; class DBObjectPtrPropertyModifier; class wxPropertyGrid; class wxPanel; class CEntity; /////////////////////////////////////////////////////////////////////////// //DbPropertyGrid /////////////////////////////////////////////////////////////////////////// class DbPropertyGrid : public wxDialog { DECLARE_EVENT_TABLE(); public: DbPropertyGrid(); ~DbPropertyGrid(); void Init( wxPanel* parentPanel, wxBoxSizer* parentSizer, CDbObject* dbObject ); void Init( wxPanel* parentPanel, wxBoxSizer* parentSizer, CEntity* entity ); void Shutdown(); void OnPropertySelected(wxPropertyGridEvent& event); void OnPropertyRightButton(wxPropertyGridEvent& event); void OnPropertySaveButtonClick( wxCommandEvent& event ); void ComposePropertyPanel( CDbObject* dbObjectNonConst, wxPropertyCategory* parentCategory = NULL ); void ComposePropertyPanel( CDbObject* dbObjectNonConst, const std::vector< CMember* >& memberList, wxPropertyCategory* parentCategory = NULL); void ComposePropertyPanel( CEntity* entity); void Save(); static void SetCallbackDisplayLibrary( CCallback2<DBObjectPtrPropertyModifier*,CStringID>& callback ){ ms_onLibrarySelected = callback; } private: void ParsePropertyChildren( IPropertyModifier* parentProperty ); void Init_Begin( wxPanel* parentPanel, wxBoxSizer* parentSizer ); void Init_End( wxPanel* parentPanel, wxBoxSizer* parentSizer ); wxPanel* m_parentPanel; wxBoxSizer* m_parentSizer; wxBoxSizer* m_currentSizer; wxPanel* m_currentPanel; wxPropertyGrid* m_objectsPropertyGrid; static CCallback2<DBObjectPtrPropertyModifier*,CStringID> ms_onLibrarySelected; };
[ "alberto.miladiaz@gmail.com" ]
alberto.miladiaz@gmail.com
c2abe41f5befa2c962c2edf1c2470a6ed40063b3
4d7086fb5156563ba5c92013c1dfa5bddb9e4159
/src/serialization/set.h
30046fc9bf2a42f157e90c5de2eb344b7f1e574d
[ "BSD-3-Clause", "LicenseRef-scancode-unknown-license-reference" ]
permissive
tritonix/triton
b923277f68e46b193a4f0cedc51fa21e137c7758
0ca804d85efe8efc86edf3663763b479269a3763
refs/heads/master
2020-04-08T04:14:09.030394
2019-01-04T06:17:59
2019-01-04T06:17:59
158,937,437
0
1
NOASSERTION
2018-11-24T14:03:55
2018-11-24T13:10:08
C++
UTF-8
C++
false
false
2,400
h
// Copyright (c) 2018, Triton Developers // // All rights reserved. // // 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 copyright holder nor the names of its contributors may be // used to endorse or promote products derived from this software without specific // prior written permission. // // 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. // // Parts of this file are originally copyright (c) 2012-2013 The Cryptonote developers #pragma once #include <set> template <template <bool> class Archive, class T> bool do_serialize(Archive<false> &ar, std::set<T> &v); template <template <bool> class Archive, class T> bool do_serialize(Archive<true> &ar, std::set<T> &v); namespace serialization { namespace detail { template <typename T> void do_add(std::set<T> &c, T &&e) { c.insert(std::move(e)); } } } #include "serialization.h" template <template <bool> class Archive, class T> bool do_serialize(Archive<false> &ar, std::set<T> &v) { return do_serialize_container(ar, v); } template <template <bool> class Archive, class T> bool do_serialize(Archive<true> &ar, std::set<T> &v) { return do_serialize_container(ar, v); }
[ "dant00300@gmail.com" ]
dant00300@gmail.com
14ef2b282591558797f474c3f5a425d298d68c5b
dda21f4378e37cf448d17b720da4a1c9eb2b24d7
/SDK/SB_BP_Item_Amulet_Leech_classes.hpp
7389485119c81ee00495c6bbc1ce9df767ac710d
[]
no_license
zH4x/SpellBreak-FULL-SDK
ef45d77b63494c8771554a5d0e017cc297d8dbca
cca46d4a13f0e8a56ab8ae0fae778dd389d3b404
refs/heads/master
2020-09-12T17:25:58.697408
2018-12-09T22:49:03
2018-12-09T22:49:03
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,001
hpp
#pragma once // SpellBreak By Respecter (0.15.340) SDK #ifdef _MSC_VER #pragma pack(push, 0x8) #endif #include "SB_BP_Item_Amulet_Leech_structs.hpp" namespace SpellSDK { //--------------------------------------------------------------------------- //Classes //--------------------------------------------------------------------------- // BlueprintGeneratedClass BP_Item_Amulet_Leech.BP_Item_Amulet_Leech_C // 0x0008 (0x03C8 - 0x03C0) class ABP_Item_Amulet_Leech_C : public ABP_Item_Amulet_C { public: struct FPointerToUberGraphFrame UberGraphFrame; // 0x03C0(0x0008) (Transient, DuplicateTransient) static UClass* StaticClass() { static auto ptr = UObject::FindClass("BlueprintGeneratedClass BP_Item_Amulet_Leech.BP_Item_Amulet_Leech_C"); return ptr; } void UserConstructionScript(); void ReceiveBeginPlay(); void ExecuteUbergraph_BP_Item_Amulet_Leech(int EntryPoint); }; } #ifdef _MSC_VER #pragma pack(pop) #endif
[ "45327951+realrespecter@users.noreply.github.com" ]
45327951+realrespecter@users.noreply.github.com
2261d5be239d89534f7356d04d924ce7c192b855
87642775a09940df4132d9bb881cd625b38c6cdf
/Classes/MainMenuScene.cpp
45ce5ba86282b6bf353b4100802c9313000a4054
[]
no_license
X3lnThpi/TicTacToe
852c22f41f787cf9d3566add2f3900f949f76e57
92ebbe4d03b30045c71a3b25a34fceb3b37c07a5
refs/heads/master
2022-04-16T18:09:09.007345
2020-04-06T06:47:48
2020-04-06T06:47:48
null
0
0
null
null
null
null
UTF-8
C++
false
false
6,803
cpp
/**************************************************************************** Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd. http://www.cocos2d-x.org 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 "MainMenuScene.h" #include "SimpleAudioEngine.h" #include "Definitions.h" #include "SinglePlayerScene.h" #include "AIGameScene.h" USING_NS_CC; Scene* MainMenu::createScene() { return MainMenu::create(); } // Print useful error message instead of segfaulting when files are not there. static void problemLoading(const char* filename) { printf("Error while loading: %s\n", filename); printf("Depending on how you compiled you might have to add 'Resources/' in front of filenames in HelloMainMenu.cpp\n"); } // on "init" you need to initialize your instance bool MainMenu::init() { ////////////////////////////// // 1. super init first if ( !Scene::init() ) { return false; } auto visibleSize = Director::getInstance()->getVisibleSize(); Vec2 origin = Director::getInstance()->getVisibleOrigin(); CCLOG("visibleSize:%.1f,%.1f",visibleSize.width,visibleSize.height); CCLOG("origin:%.1f,%.1f",origin.x,origin.y); ///////////////////////////// // 2. add a menu item with "X" image, which is clicked to quit the program // you may modify it. // add a "close" icon to exit the progress. it's an autorelease object auto closeItem = MenuItemImage::create( "CloseNormal.png", "CloseSelected.png", CC_CALLBACK_1(MainMenu::menuCloseCallback, this)); if (closeItem == nullptr || closeItem->getContentSize().width <= 0 || closeItem->getContentSize().height <= 0) { problemLoading("'CloseNormal.png' and 'CloseSelected.png'"); } else { float x = origin.x + visibleSize.width - closeItem->getContentSize().width/2; float y = origin.y + closeItem->getContentSize().height/2; closeItem->setPosition(Vec2(x,y)); } // create menu, it's an autorelease object auto menu = Menu::create(closeItem, NULL); menu->setPosition(Vec2::ZERO); this->addChild(menu, 1); ///////////////////////////// // 3. add your codes below... // add a label shows "Hello World" // create and initialize a label auto label = Label::createWithTTF("Ameer-Rahul", "fonts/Marker Felt.ttf", 24); if (label == nullptr) { problemLoading("'fonts/Marker Felt.ttf'"); } else { // position the label on the center of the screen label->setPosition(Vec2(origin.x + visibleSize.width/2, origin.y + visibleSize.height - label->getContentSize().height)); // add the label as a child to this layer this->addChild(label, 1); } auto bg = Sprite::create(MAIN_MENU_BACKGROUND); bg->setPosition(Vec2(origin.x + visibleSize.width / 2, origin.y + visibleSize.height / 2)); this->addChild(bg); // cocos2d::ui::Button *playButton = cocos2d::ui::Button::create("t.png"); //playButton->setPosition(Vec2(visibleSize.width/2 + origin.x, visibleSize.height * 0.75 + origin.y )); //this->addChild(playButton); // playButton->addTouchEventListener( CC_CALLBACK_0(HelloWorld::changeScene, this) ); ui::Button* btn = ui::Button::create(MAIN_MENU_PLAY_BUTTON); btn->setPosition(Vec2(visibleSize.width/2 + origin.x, visibleSize.height * 0.50+ origin.y )); btn->addTouchEventListener( CC_CALLBACK_0(MainMenu::playButton, this) ); this->addChild(btn); ui::Button *plyer2 = ui::Button::create(MAIN_MENU_MULTIPLAYER_BUTTON); plyer2->setPosition(Vec2(visibleSize.width/2 + origin.x, visibleSize.height * 0.40+ origin.y )); plyer2->addTouchEventListener( CC_CALLBACK_0(MainMenu::multiPlayButton, this) ); this->addChild(plyer2); ui::Button *exitButton = ui::Button::create(EXIT_BUTTON); exitButton->setPosition(Vec2(visibleSize.width / 2 + origin.x, visibleSize.height * 0.30 + origin.y )); exitButton->addTouchEventListener( CC_CALLBACK_0(MainMenu::exitButton, this) ); this->addChild(exitButton); return true; } void MainMenu::menuCloseCallback(Ref* pSender) { //Close the cocos2d-x game scene and quit the application Director::getInstance()->end(); /*To navigate back to native iOS screen(if present) without quitting the application ,do not use Director::getInstance()->end() as given above,instead trigger a custom event created in RootViewController.mm as below*/ //EventCustom customEndEvent("game_scene_close_event"); //_eventDispatcher->dispatchEvent(&customEndEvent); } void MainMenu::changeScene(Ref* pSender) { //Close the cocos2d-x game scene and quit the application // Director::getInstance()->end(); /*To navigate back to native iOS screen(if present) without quitting the application ,do not use Director::getInstance()->end() as given above,instead trigger a custom event created in RootViewController.mm as below*/ //EventCustom customEndEvent("game_scene_close_event"); //_eventDispatcher->dispatchEvent(&customEndEvent); auto scene = SinglePlayer::createScene(); Director::getInstance()->pushScene(scene); } void MainMenu::playButton() { //_eventDispatcher->dispatchEvent(&customEndEvent); auto scene = AIGame::createScene(); CCLOG("playbutton"); Director::getInstance()->pushScene(scene); } void MainMenu::multiPlayButton(){ auto scene = SinglePlayer::createScene(); CCLOG("multiPlayButton"); Director::getInstance()->pushScene(scene); } void MainMenu::exitButton(){ CCLOG("exitButton"); Director::getInstance()->end(); } // Added Build trigger
[ "devmethyl@outlook.com" ]
devmethyl@outlook.com
807836626c0dfd9392b3d68444ea2ceec1c4e9fc
dca5939172b01a0cbb81696537b7daff9180d908
/codebase/apps/dsserver/src/DsMdvServer/Params.cc
ec3c6ea9f299b67dcc445a8b472187a2f6ad8ce6
[ "BSD-3-Clause" ]
permissive
hhuangwx/lrose-core
6d6ff786b42e239c7553595124075a22f91e20f2
ccd1c1021a9979663dfc9678117481082a58634f
refs/heads/master
2021-08-30T15:24:13.868310
2017-12-18T12:34:15
2017-12-18T12:34:15
114,638,806
0
0
null
2017-12-18T12:31:38
2017-12-18T12:31:37
null
UTF-8
C++
false
false
92,690
cc
// *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=* // ** Copyright UCAR (c) 1992 - 2017 // ** University Corporation for Atmospheric Research(UCAR) // ** National Center for Atmospheric Research(NCAR) // ** Boulder, Colorado, USA // *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=* //////////////////////////////////////////// // Params.cc // // TDRP C++ code file for class 'Params'. // // Code for program DsMdvServer // // This file has been automatically // generated by TDRP, do not modify. // ///////////////////////////////////////////// /** * * @file Params.cc * * @class Params * * This class is automatically generated by the Table * Driven Runtime Parameters (TDRP) system * * @note Source is automatically generated from * paramdef file at compile time, do not modify * since modifications will be overwritten. * * * @author Automatically generated * */ using namespace std; #include "Params.hh" #include <cstring> //////////////////////////////////////////// // Default constructor // Params::Params() { // zero out table memset(_table, 0, sizeof(_table)); // zero out members memset(&_start_, 0, &_end_ - &_start_); // class name _className = "Params"; // initialize table _init(); // set members tdrpTable2User(_table, &_start_); _exitDeferred = false; } //////////////////////////////////////////// // Copy constructor // Params::Params(const Params& source) { // sync the source object source.sync(); // zero out table memset(_table, 0, sizeof(_table)); // zero out members memset(&_start_, 0, &_end_ - &_start_); // class name _className = "Params"; // copy table tdrpCopyTable((TDRPtable *) source._table, _table); // set members tdrpTable2User(_table, &_start_); _exitDeferred = false; } //////////////////////////////////////////// // Destructor // Params::~Params() { // free up freeAll(); } //////////////////////////////////////////// // Assignment // void Params::operator=(const Params& other) { // sync the other object other.sync(); // free up any existing memory freeAll(); // zero out table memset(_table, 0, sizeof(_table)); // zero out members memset(&_start_, 0, &_end_ - &_start_); // copy table tdrpCopyTable((TDRPtable *) other._table, _table); // set members tdrpTable2User(_table, &_start_); _exitDeferred = other._exitDeferred; } //////////////////////////////////////////// // loadFromArgs() // // Loads up TDRP using the command line args. // // Check usage() for command line actions associated with // this function. // // argc, argv: command line args // // char **override_list: A null-terminated list of overrides // to the parameter file. // An override string has exactly the format of an entry // in the parameter file itself. // // char **params_path_p: // If this is non-NULL, it is set to point to the path // of the params file used. // // bool defer_exit: normally, if the command args contain a // print or check request, this function will call exit(). // If defer_exit is set, such an exit is deferred and the // private member _exitDeferred is set. // Use exidDeferred() to test this flag. // // Returns 0 on success, -1 on failure. // int Params::loadFromArgs(int argc, char **argv, char **override_list, char **params_path_p, bool defer_exit) { int exit_deferred; if (_tdrpLoadFromArgs(argc, argv, _table, &_start_, override_list, params_path_p, _className, defer_exit, &exit_deferred)) { return (-1); } else { if (exit_deferred) { _exitDeferred = true; } return (0); } } //////////////////////////////////////////// // loadApplyArgs() // // Loads up TDRP using the params path passed in, and applies // the command line args for printing and checking. // // Check usage() for command line actions associated with // this function. // // const char *param_file_path: the parameter file to be read in // // argc, argv: command line args // // char **override_list: A null-terminated list of overrides // to the parameter file. // An override string has exactly the format of an entry // in the parameter file itself. // // bool defer_exit: normally, if the command args contain a // print or check request, this function will call exit(). // If defer_exit is set, such an exit is deferred and the // private member _exitDeferred is set. // Use exidDeferred() to test this flag. // // Returns 0 on success, -1 on failure. // int Params::loadApplyArgs(const char *params_path, int argc, char **argv, char **override_list, bool defer_exit) { int exit_deferred; if (tdrpLoadApplyArgs(params_path, argc, argv, _table, &_start_, override_list, _className, defer_exit, &exit_deferred)) { return (-1); } else { if (exit_deferred) { _exitDeferred = true; } return (0); } } //////////////////////////////////////////// // isArgValid() // // Check if a command line arg is a valid TDRP arg. // bool Params::isArgValid(const char *arg) { return (tdrpIsArgValid(arg)); } //////////////////////////////////////////// // load() // // Loads up TDRP for a given class. // // This version of load gives the programmer the option to load // up more than one class for a single application. It is a // lower-level routine than loadFromArgs, and hence more // flexible, but the programmer must do more work. // // const char *param_file_path: the parameter file to be read in. // // char **override_list: A null-terminated list of overrides // to the parameter file. // An override string has exactly the format of an entry // in the parameter file itself. // // expand_env: flag to control environment variable // expansion during tokenization. // If TRUE, environment expansion is set on. // If FALSE, environment expansion is set off. // // Returns 0 on success, -1 on failure. // int Params::load(const char *param_file_path, char **override_list, int expand_env, int debug) { if (tdrpLoad(param_file_path, _table, &_start_, override_list, expand_env, debug)) { return (-1); } else { return (0); } } //////////////////////////////////////////// // loadFromBuf() // // Loads up TDRP for a given class. // // This version of load gives the programmer the option to // load up more than one module for a single application, // using buffers which have been read from a specified source. // // const char *param_source_str: a string which describes the // source of the parameter information. It is used for // error reporting only. // // char **override_list: A null-terminated list of overrides // to the parameter file. // An override string has exactly the format of an entry // in the parameter file itself. // // const char *inbuf: the input buffer // // int inlen: length of the input buffer // // int start_line_num: the line number in the source which // corresponds to the start of the buffer. // // expand_env: flag to control environment variable // expansion during tokenization. // If TRUE, environment expansion is set on. // If FALSE, environment expansion is set off. // // Returns 0 on success, -1 on failure. // int Params::loadFromBuf(const char *param_source_str, char **override_list, const char *inbuf, int inlen, int start_line_num, int expand_env, int debug) { if (tdrpLoadFromBuf(param_source_str, _table, &_start_, override_list, inbuf, inlen, start_line_num, expand_env, debug)) { return (-1); } else { return (0); } } //////////////////////////////////////////// // loadDefaults() // // Loads up default params for a given class. // // See load() for more detailed info. // // Returns 0 on success, -1 on failure. // int Params::loadDefaults(int expand_env) { if (tdrpLoad(NULL, _table, &_start_, NULL, expand_env, FALSE)) { return (-1); } else { return (0); } } //////////////////////////////////////////// // sync() // // Syncs the user struct data back into the parameter table, // in preparation for printing. // // This function alters the table in a consistent manner. // Therefore it can be regarded as const. // void Params::sync(void) const { tdrpUser2Table(_table, (char *) &_start_); } //////////////////////////////////////////// // print() // // Print params file // // The modes supported are: // // PRINT_SHORT: main comments only, no help or descriptions // structs and arrays on a single line // PRINT_NORM: short + descriptions and help // PRINT_LONG: norm + arrays and structs expanded // PRINT_VERBOSE: long + private params included // void Params::print(FILE *out, tdrp_print_mode_t mode) { tdrpPrint(out, _table, _className, mode); } //////////////////////////////////////////// // checkAllSet() // // Return TRUE if all set, FALSE if not. // // If out is non-NULL, prints out warning messages for those // parameters which are not set. // int Params::checkAllSet(FILE *out) { return (tdrpCheckAllSet(out, _table, &_start_)); } ////////////////////////////////////////////////////////////// // checkIsSet() // // Return TRUE if parameter is set, FALSE if not. // // int Params::checkIsSet(const char *paramName) { return (tdrpCheckIsSet(paramName, _table, &_start_)); } //////////////////////////////////////////// // freeAll() // // Frees up all TDRP dynamic memory. // void Params::freeAll(void) { tdrpFreeAll(_table, &_start_); } //////////////////////////////////////////// // usage() // // Prints out usage message for TDRP args as passed // in to loadFromArgs(). // void Params::usage(ostream &out) { out << "TDRP args: [options as below]\n" << " [ -params/--params path ] specify params file path\n" << " [ -check_params/--check_params] check which params are not set\n" << " [ -print_params/--print_params [mode]] print parameters\n" << " using following modes, default mode is 'norm'\n" << " short: main comments only, no help or descr\n" << " structs and arrays on a single line\n" << " norm: short + descriptions and help\n" << " long: norm + arrays and structs expanded\n" << " verbose: long + private params included\n" << " short_expand: short with env vars expanded\n" << " norm_expand: norm with env vars expanded\n" << " long_expand: long with env vars expanded\n" << " verbose_expand: verbose with env vars expanded\n" << " [ -tdrp_debug] debugging prints for tdrp\n" << " [ -tdrp_usage] print this usage\n"; } //////////////////////////////////////////// // arrayRealloc() // // Realloc 1D array. // // If size is increased, the values from the last array // entry is copied into the new space. // // Returns 0 on success, -1 on error. // int Params::arrayRealloc(const char *param_name, int new_array_n) { if (tdrpArrayRealloc(_table, &_start_, param_name, new_array_n)) { return (-1); } else { return (0); } } //////////////////////////////////////////// // array2DRealloc() // // Realloc 2D array. // // If size is increased, the values from the last array // entry is copied into the new space. // // Returns 0 on success, -1 on error. // int Params::array2DRealloc(const char *param_name, int new_array_n1, int new_array_n2) { if (tdrpArray2DRealloc(_table, &_start_, param_name, new_array_n1, new_array_n2)) { return (-1); } else { return (0); } } //////////////////////////////////////////// // _init() // // Class table initialization function. // // void Params::_init() { TDRPtable *tt = _table; // Parameter 'Comment 0' memset(tt, 0, sizeof(TDRPtable)); tt->ptype = COMMENT_TYPE; tt->param_name = tdrpStrDup("Comment 0"); tt->comment_hdr = tdrpStrDup("DEBUGGING AND PROCESS CONTROL"); tt->comment_text = tdrpStrDup(""); tt++; // Parameter 'debug' // ctype is '_debug_t' memset(tt, 0, sizeof(TDRPtable)); tt->ptype = ENUM_TYPE; tt->param_name = tdrpStrDup("debug"); tt->descr = tdrpStrDup("Debug option"); tt->help = tdrpStrDup("If set, debug messages will be printed appropriately"); tt->val_offset = (char *) &debug - &_start_; tt->enum_def.name = tdrpStrDup("debug_t"); tt->enum_def.nfields = 3; tt->enum_def.fields = (enum_field_t *) tdrpMalloc(tt->enum_def.nfields * sizeof(enum_field_t)); tt->enum_def.fields[0].name = tdrpStrDup("DEBUG_OFF"); tt->enum_def.fields[0].val = DEBUG_OFF; tt->enum_def.fields[1].name = tdrpStrDup("DEBUG_NORM"); tt->enum_def.fields[1].val = DEBUG_NORM; tt->enum_def.fields[2].name = tdrpStrDup("DEBUG_VERBOSE"); tt->enum_def.fields[2].val = DEBUG_VERBOSE; tt->single_val.e = DEBUG_OFF; tt++; // Parameter 'no_threads' // ctype is 'tdrp_bool_t' memset(tt, 0, sizeof(TDRPtable)); tt->ptype = BOOL_TYPE; tt->param_name = tdrpStrDup("no_threads"); tt->descr = tdrpStrDup("Option to prevent server from using a thread per client."); tt->help = tdrpStrDup("For debugging purposes it it sometimes useful to suppress the use of threads. Set no_threads to TRUE for this type of debugging."); tt->val_offset = (char *) &no_threads - &_start_; tt->single_val.b = pFALSE; tt++; // Parameter 'instance' // ctype is 'char*' memset(tt, 0, sizeof(TDRPtable)); tt->ptype = STRING_TYPE; tt->param_name = tdrpStrDup("instance"); tt->descr = tdrpStrDup("Process instance."); tt->help = tdrpStrDup("Used for procmap registration and auto restarting. If an empty instance name is provided, the server automatically uses the port number as its instance name"); tt->val_offset = (char *) &instance - &_start_; tt->single_val.s = tdrpStrDup(""); tt++; // Parameter 'Comment 1' memset(tt, 0, sizeof(TDRPtable)); tt->ptype = COMMENT_TYPE; tt->param_name = tdrpStrDup("Comment 1"); tt->comment_hdr = tdrpStrDup("SERVER MANAGER SUPPORT"); tt->comment_text = tdrpStrDup(""); tt++; // Parameter 'port' // ctype is 'int' memset(tt, 0, sizeof(TDRPtable)); tt->ptype = INT_TYPE; tt->param_name = tdrpStrDup("port"); tt->descr = tdrpStrDup("Port number."); tt->help = tdrpStrDup("The server listens on this port for client requests."); tt->val_offset = (char *) &port - &_start_; tt->single_val.i = 5440; tt++; // Parameter 'qmax' // ctype is 'int' memset(tt, 0, sizeof(TDRPtable)); tt->ptype = INT_TYPE; tt->param_name = tdrpStrDup("qmax"); tt->descr = tdrpStrDup("Max quiescent period (secs)."); tt->help = tdrpStrDup("If the server does not receive requests for this time period, it will die gracefully."); tt->val_offset = (char *) &qmax - &_start_; tt->single_val.i = 1800; tt++; // Parameter 'max_clients' // ctype is 'int' memset(tt, 0, sizeof(TDRPtable)); tt->ptype = INT_TYPE; tt->param_name = tdrpStrDup("max_clients"); tt->descr = tdrpStrDup("Maximum number of clients"); tt->help = tdrpStrDup("This is the maximum number of threads the application will produce to handle client requests. If the maximum is reached, new clients will receive a SERVICE_DENIED error message and will have to request the data again. If set to -1, no maximum is enforced."); tt->val_offset = (char *) &max_clients - &_start_; tt->single_val.i = 32; tt++; // Parameter 'Comment 2' memset(tt, 0, sizeof(TDRPtable)); tt->ptype = COMMENT_TYPE; tt->param_name = tdrpStrDup("Comment 2"); tt->comment_hdr = tdrpStrDup("SECURITY"); tt->comment_text = tdrpStrDup(""); tt++; // Parameter 'run_secure' // ctype is 'tdrp_bool_t' memset(tt, 0, sizeof(TDRPtable)); tt->ptype = BOOL_TYPE; tt->param_name = tdrpStrDup("run_secure"); tt->descr = tdrpStrDup("Option to run in secure mode."); tt->help = tdrpStrDup("If TRUE, the server will reject any URLs which specify an absolute path, or a path with .. in it. This prevents the server from writing any files which are not below DATA_DIR in the directory tree."); tt->val_offset = (char *) &run_secure - &_start_; tt->single_val.b = pFALSE; tt++; // Parameter 'run_read_only' // ctype is 'tdrp_bool_t' memset(tt, 0, sizeof(TDRPtable)); tt->ptype = BOOL_TYPE; tt->param_name = tdrpStrDup("run_read_only"); tt->descr = tdrpStrDup("Option to run in read-only mode."); tt->help = tdrpStrDup("If TRUE, the server will respond only to read requests, and will ignore write requests."); tt->val_offset = (char *) &run_read_only - &_start_; tt->single_val.b = pFALSE; tt++; // Parameter 'allow_http' // ctype is 'tdrp_bool_t' memset(tt, 0, sizeof(TDRPtable)); tt->ptype = BOOL_TYPE; tt->param_name = tdrpStrDup("allow_http"); tt->descr = tdrpStrDup("Option to allow http requests."); tt->help = tdrpStrDup("If TRUE, the server will strip off header in request message."); tt->val_offset = (char *) &allow_http - &_start_; tt->single_val.b = pTRUE; tt++; // Parameter 'Comment 3' memset(tt, 0, sizeof(TDRPtable)); tt->ptype = COMMENT_TYPE; tt->param_name = tdrpStrDup("Comment 3"); tt->comment_hdr = tdrpStrDup("MEMORY MANAGEMENT FOR MESSAGES"); tt->comment_text = tdrpStrDup(""); tt++; // Parameter 'copy_message_memory' // ctype is 'tdrp_bool_t' memset(tt, 0, sizeof(TDRPtable)); tt->ptype = BOOL_TYPE; tt->param_name = tdrpStrDup("copy_message_memory"); tt->descr = tdrpStrDup("Option to copy memory from the messages into the message objects."); tt->help = tdrpStrDup("Setting to FALSE will reduce the memory usage for the program."); tt->val_offset = (char *) &copy_message_memory - &_start_; tt->single_val.b = pTRUE; tt++; // Parameter 'Comment 4' memset(tt, 0, sizeof(TDRPtable)); tt->ptype = COMMENT_TYPE; tt->param_name = tdrpStrDup("Comment 4"); tt->comment_hdr = tdrpStrDup("VERTICAL SECTIONS - READ OPERATIONS ONLY"); tt->comment_text = tdrpStrDup(""); tt++; // Parameter 'vsection_set_nsamples' // ctype is 'tdrp_bool_t' memset(tt, 0, sizeof(TDRPtable)); tt->ptype = BOOL_TYPE; tt->param_name = tdrpStrDup("vsection_set_nsamples"); tt->descr = tdrpStrDup("Option to disable interpolation in vertical sections."); tt->help = tdrpStrDup("Some data is not amenable to interpolation. Setting this to TRUE will disable interpolation when vertical sections are computed."); tt->val_offset = (char *) &vsection_set_nsamples - &_start_; tt->single_val.b = pFALSE; tt++; // Parameter 'vsection_nsamples' // ctype is 'int' memset(tt, 0, sizeof(TDRPtable)); tt->ptype = INT_TYPE; tt->param_name = tdrpStrDup("vsection_nsamples"); tt->descr = tdrpStrDup("Number of samples in the vertical section."); tt->help = tdrpStrDup(""); tt->val_offset = (char *) &vsection_nsamples - &_start_; tt->single_val.i = 500; tt++; // Parameter 'vsection_disable_interp' // ctype is 'tdrp_bool_t' memset(tt, 0, sizeof(TDRPtable)); tt->ptype = BOOL_TYPE; tt->param_name = tdrpStrDup("vsection_disable_interp"); tt->descr = tdrpStrDup("Option to disable interpolation in vertical sections."); tt->help = tdrpStrDup("Some data is not amenable to interpolation. Setting this to TRUE will disable interpolation when vertical sections are computed."); tt->val_offset = (char *) &vsection_disable_interp - &_start_; tt->single_val.b = pFALSE; tt++; // Parameter 'Comment 5' memset(tt, 0, sizeof(TDRPtable)); tt->ptype = COMMENT_TYPE; tt->param_name = tdrpStrDup("Comment 5"); tt->comment_hdr = tdrpStrDup("STATIC FILES - READ OPERATIONS ONLY"); tt->comment_text = tdrpStrDup("Option to serve out data from a static file if a time-based request is made."); tt++; // Parameter 'use_static_file' // ctype is 'tdrp_bool_t' memset(tt, 0, sizeof(TDRPtable)); tt->ptype = BOOL_TYPE; tt->param_name = tdrpStrDup("use_static_file"); tt->descr = tdrpStrDup("Option to serve out data from a static file."); tt->help = tdrpStrDup("If set, the data will always be read from a static file. The file url is specified below. The times in the header will be set to match the request time."); tt->val_offset = (char *) &use_static_file - &_start_; tt->single_val.b = pFALSE; tt++; // Parameter 'static_file_url' // ctype is 'char*' memset(tt, 0, sizeof(TDRPtable)); tt->ptype = STRING_TYPE; tt->param_name = tdrpStrDup("static_file_url"); tt->descr = tdrpStrDup("URL for static file."); tt->help = tdrpStrDup(""); tt->val_offset = (char *) &static_file_url - &_start_; tt->single_val.s = tdrpStrDup("none"); tt++; // Parameter 'Comment 6' memset(tt, 0, sizeof(TDRPtable)); tt->ptype = COMMENT_TYPE; tt->param_name = tdrpStrDup("Comment 6"); tt->comment_hdr = tdrpStrDup("FAILOVER OPTION - READ OPERATIONS ONLY"); tt->comment_text = tdrpStrDup(""); tt++; // Parameter 'use_failover_urls' // ctype is 'tdrp_bool_t' memset(tt, 0, sizeof(TDRPtable)); tt->ptype = BOOL_TYPE; tt->param_name = tdrpStrDup("use_failover_urls"); tt->descr = tdrpStrDup("Option to serve data from another url if the first url fails."); tt->help = tdrpStrDup("A list of urls is specified by the failover_urls parameter, and if one url does not deliver the data, the subsequent url is then checked. This applies to read operations only."); tt->val_offset = (char *) &use_failover_urls - &_start_; tt->single_val.b = pFALSE; tt++; // Parameter 'failover_urls' // ctype is 'char*' memset(tt, 0, sizeof(TDRPtable)); tt->ptype = STRING_TYPE; tt->param_name = tdrpStrDup("failover_urls"); tt->descr = tdrpStrDup("The list of urls to check if use_failover_urls is TRUE."); tt->help = tdrpStrDup("Relevant only if use_failover_urls is true."); tt->array_offset = (char *) &_failover_urls - &_start_; tt->array_n_offset = (char *) &failover_urls_n - &_start_; tt->is_array = TRUE; tt->array_len_fixed = FALSE; tt->array_elem_size = sizeof(char*); tt->array_n = 2; tt->array_vals = (tdrpVal_t *) tdrpMalloc(tt->array_n * sizeof(tdrpVal_t)); tt->array_vals[0].s = tdrpStrDup("mdvp:://fastUnreliable::mdv/data"); tt->array_vals[1].s = tdrpStrDup("mdvp:://slowReliable::mdv/data"); tt++; // Parameter 'Comment 7' memset(tt, 0, sizeof(TDRPtable)); tt->ptype = COMMENT_TYPE; tt->param_name = tdrpStrDup("Comment 7"); tt->comment_hdr = tdrpStrDup("MULTIPLE DOMAINS - READ OPERATIONS ONLY"); tt->comment_text = tdrpStrDup(""); tt++; // Parameter 'serve_multiple_domains' // ctype is 'tdrp_bool_t' memset(tt, 0, sizeof(TDRPtable)); tt->ptype = BOOL_TYPE; tt->param_name = tdrpStrDup("serve_multiple_domains"); tt->descr = tdrpStrDup("Option to serve out data from multiple domains. - So called Smart Zoom"); tt->help = tdrpStrDup("This is applicable for data sets which are available in different resolutions, covering different domains. Generally, the finest resolution data will cover the smallest domain, with increasing resolution covering larger domains. The search is made from the top to the bottom of the list. The required domain is assumed to be the first one which fully encompasses the requested horizontal limits. If no horizontal limits are specified, the bottom (largest) domain is used. Note, problems getting this mechanism to work correctly have been observed when running the DsMdvServer on an alternate port. In this circumstance, the sub-URL would not work when using the full URL form which includes the hosts name or localhost. Proper function was observed when the sub url contained only the directory path part of the URL."); tt->val_offset = (char *) &serve_multiple_domains - &_start_; tt->single_val.b = pFALSE; tt++; // Parameter 'domains' // ctype is '_domain_t' memset(tt, 0, sizeof(TDRPtable)); tt->ptype = STRUCT_TYPE; tt->param_name = tdrpStrDup("domains"); tt->descr = tdrpStrDup("Domain specifications - serve_multiple_domains."); tt->help = tdrpStrDup("The domains should be listed from smallest to largest, which normally corresponds to finest to coarsest resolution. Specify the URL from which the data for each domain should be retrieved. If a URL in this list matches the current one it is ignored. Note for proper function, urls pointing to data on the localhost should never include the host portion in the URL; Use only the path part."); tt->array_offset = (char *) &_domains - &_start_; tt->array_n_offset = (char *) &domains_n - &_start_; tt->is_array = TRUE; tt->array_len_fixed = FALSE; tt->array_elem_size = sizeof(domain_t); tt->array_n = 1; tt->struct_def.name = tdrpStrDup("domain_t"); tt->struct_def.nfields = 5; tt->struct_def.fields = (struct_field_t *) tdrpMalloc(tt->struct_def.nfields * sizeof(struct_field_t)); tt->struct_def.fields[0].ftype = tdrpStrDup("double"); tt->struct_def.fields[0].fname = tdrpStrDup("min_lat"); tt->struct_def.fields[0].ptype = DOUBLE_TYPE; tt->struct_def.fields[0].rel_offset = (char *) &_domains->min_lat - (char *) _domains; tt->struct_def.fields[1].ftype = tdrpStrDup("double"); tt->struct_def.fields[1].fname = tdrpStrDup("min_lon"); tt->struct_def.fields[1].ptype = DOUBLE_TYPE; tt->struct_def.fields[1].rel_offset = (char *) &_domains->min_lon - (char *) _domains; tt->struct_def.fields[2].ftype = tdrpStrDup("double"); tt->struct_def.fields[2].fname = tdrpStrDup("max_lat"); tt->struct_def.fields[2].ptype = DOUBLE_TYPE; tt->struct_def.fields[2].rel_offset = (char *) &_domains->max_lat - (char *) _domains; tt->struct_def.fields[3].ftype = tdrpStrDup("double"); tt->struct_def.fields[3].fname = tdrpStrDup("max_lon"); tt->struct_def.fields[3].ptype = DOUBLE_TYPE; tt->struct_def.fields[3].rel_offset = (char *) &_domains->max_lon - (char *) _domains; tt->struct_def.fields[4].ftype = tdrpStrDup("string"); tt->struct_def.fields[4].fname = tdrpStrDup("url"); tt->struct_def.fields[4].ptype = STRING_TYPE; tt->struct_def.fields[4].rel_offset = (char *) &_domains->url - (char *) _domains; tt->n_struct_vals = 5; tt->struct_vals = (tdrpVal_t *) tdrpMalloc(tt->n_struct_vals * sizeof(tdrpVal_t)); tt->struct_vals[0].d = -90; tt->struct_vals[1].d = -180; tt->struct_vals[2].d = 90; tt->struct_vals[3].d = 180; tt->struct_vals[4].s = tdrpStrDup("none"); tt++; // Parameter 'auto_fail_over' // ctype is 'tdrp_bool_t' memset(tt, 0, sizeof(TDRPtable)); tt->ptype = BOOL_TYPE; tt->param_name = tdrpStrDup("auto_fail_over"); tt->descr = tdrpStrDup("Option to switch to an alternative domain if the request to the most appropriate one fails."); tt->help = tdrpStrDup("The server will first try the domain selected as above. If this fails, it will try the next larger domain, and so on. If no larger domain succeeds, it will try the next smaller domain. If no domain succeeds the call will fail."); tt->val_offset = (char *) &auto_fail_over - &_start_; tt->single_val.b = pTRUE; tt++; // Parameter 'Comment 8' memset(tt, 0, sizeof(TDRPtable)); tt->ptype = COMMENT_TYPE; tt->param_name = tdrpStrDup("Comment 8"); tt->comment_hdr = tdrpStrDup("OVERRIDING ENCODING ON READ"); tt->comment_text = tdrpStrDup(""); tt++; // Parameter 'override_encoding_type_on_read' // ctype is 'tdrp_bool_t' memset(tt, 0, sizeof(TDRPtable)); tt->ptype = BOOL_TYPE; tt->param_name = tdrpStrDup("override_encoding_type_on_read"); tt->descr = tdrpStrDup("Option to override the encoding on read."); tt->help = tdrpStrDup("Normally, the client sets the desired encoding type and it is included in the read message. If this parameter is set to TRUE, the specified encoding type will be used instead of that requested by the client."); tt->val_offset = (char *) &override_encoding_type_on_read - &_start_; tt->single_val.b = pFALSE; tt++; // Parameter 'encoding_type_on_read' // ctype is '_encoding_type_t' memset(tt, 0, sizeof(TDRPtable)); tt->ptype = ENUM_TYPE; tt->param_name = tdrpStrDup("encoding_type_on_read"); tt->descr = tdrpStrDup("Set encoding type for the read operations."); tt->help = tdrpStrDup("Only applies if override_encoding_on_read is TRUE."); tt->val_offset = (char *) &encoding_type_on_read - &_start_; tt->enum_def.name = tdrpStrDup("encoding_type_t"); tt->enum_def.nfields = 4; tt->enum_def.fields = (enum_field_t *) tdrpMalloc(tt->enum_def.nfields * sizeof(enum_field_t)); tt->enum_def.fields[0].name = tdrpStrDup("ENCODING_ASIS"); tt->enum_def.fields[0].val = ENCODING_ASIS; tt->enum_def.fields[1].name = tdrpStrDup("ENCODING_INT8"); tt->enum_def.fields[1].val = ENCODING_INT8; tt->enum_def.fields[2].name = tdrpStrDup("ENCODING_INT16"); tt->enum_def.fields[2].val = ENCODING_INT16; tt->enum_def.fields[3].name = tdrpStrDup("ENCODING_FLOAT32"); tt->enum_def.fields[3].val = ENCODING_FLOAT32; tt->single_val.e = ENCODING_ASIS; tt++; // Parameter 'Comment 9' memset(tt, 0, sizeof(TDRPtable)); tt->ptype = COMMENT_TYPE; tt->param_name = tdrpStrDup("Comment 9"); tt->comment_hdr = tdrpStrDup("OVERRIDING DATA SET SOURCE, NAME AND INFO - READ OPERATIONS ONLY"); tt->comment_text = tdrpStrDup("The following options allow you to override the data set source, name and info when reading. These will be replaced by the specified XML strings, for use by the client."); tt++; // Parameter 'Comment 10' memset(tt, 0, sizeof(TDRPtable)); tt->ptype = COMMENT_TYPE; tt->param_name = tdrpStrDup("Comment 10"); tt->comment_hdr = tdrpStrDup("OVERRIDING DATA SET SOURCE, NAME AND INFO - READ OPERATIONS ONLY"); tt->comment_text = tdrpStrDup("The following options allow you to override the data set source, name and info when reading. These will be replaced by the specified XML strings, for use by the client."); tt++; // Parameter 'override_data_set_name_on_read' // ctype is 'tdrp_bool_t' memset(tt, 0, sizeof(TDRPtable)); tt->ptype = BOOL_TYPE; tt->param_name = tdrpStrDup("override_data_set_name_on_read"); tt->descr = tdrpStrDup("Option to override the data set name on read."); tt->help = tdrpStrDup("If TRUE, the data_set_name in the master header will be overridden by the XML specified in data_set_name parameter. The maximum number of characters supported is 127."); tt->val_offset = (char *) &override_data_set_name_on_read - &_start_; tt->single_val.b = pFALSE; tt++; // Parameter 'data_set_name_read_xml' // ctype is 'char*' memset(tt, 0, sizeof(TDRPtable)); tt->ptype = STRING_TYPE; tt->param_name = tdrpStrDup("data_set_name_read_xml"); tt->descr = tdrpStrDup("XML string used for overriding data_set_name in the master header"); tt->help = tdrpStrDup("It is suggested that you use the <name> and </name> tags to delimit the name. The maximum number of characters in the string, including the tags, is 127. If more characters are used, the string will be truncated at 127."); tt->val_offset = (char *) &data_set_name_read_xml - &_start_; tt->single_val.s = tdrpStrDup("<name></name>"); tt++; // Parameter 'override_data_set_source_on_read' // ctype is 'tdrp_bool_t' memset(tt, 0, sizeof(TDRPtable)); tt->ptype = BOOL_TYPE; tt->param_name = tdrpStrDup("override_data_set_source_on_read"); tt->descr = tdrpStrDup("Option to override the data set source on read."); tt->help = tdrpStrDup("If TRUE, the data_set_source in the master header will be overridden by the XML specified in data_set_source parameter. The maximum number of characters supported is 127."); tt->val_offset = (char *) &override_data_set_source_on_read - &_start_; tt->single_val.b = pFALSE; tt++; // Parameter 'data_set_source_read_xml' // ctype is 'char*' memset(tt, 0, sizeof(TDRPtable)); tt->ptype = STRING_TYPE; tt->param_name = tdrpStrDup("data_set_source_read_xml"); tt->descr = tdrpStrDup("XML string used for overriding data_set_source in the master header"); tt->help = tdrpStrDup("It is suggested that you use the <source> and </source> tags to delimit the source. The maximum number of characters in the string, including the tags, is 127. If more characters are used, the string will be truncated at 127."); tt->val_offset = (char *) &data_set_source_read_xml - &_start_; tt->single_val.s = tdrpStrDup("<source></source>"); tt++; // Parameter 'override_data_set_info_on_read' // ctype is 'tdrp_bool_t' memset(tt, 0, sizeof(TDRPtable)); tt->ptype = BOOL_TYPE; tt->param_name = tdrpStrDup("override_data_set_info_on_read"); tt->descr = tdrpStrDup("Option to override the data set info on read."); tt->help = tdrpStrDup("If TRUE, the data_set_info in the master header will be overridden by the XML specified in data_set_info parameter. The maximum number of characters supported is 511."); tt->val_offset = (char *) &override_data_set_info_on_read - &_start_; tt->single_val.b = pFALSE; tt++; // Parameter 'data_set_info_read_xml' // ctype is 'char*' memset(tt, 0, sizeof(TDRPtable)); tt->ptype = STRING_TYPE; tt->param_name = tdrpStrDup("data_set_info_read_xml"); tt->descr = tdrpStrDup("XML string used for overriding data_set_info in the master header"); tt->help = tdrpStrDup("It is suggested that you use the <info> and </info> tags to delimit the info. Other XML tags can be used to further delimit individual fields. The maximum number of characters in the string, including the tags, is 511. If more characters are used, the string will be truncated at 511."); tt->val_offset = (char *) &data_set_info_read_xml - &_start_; tt->single_val.s = tdrpStrDup("<info></info>"); tt++; // Parameter 'Comment 11' memset(tt, 0, sizeof(TDRPtable)); tt->ptype = COMMENT_TYPE; tt->param_name = tdrpStrDup("Comment 11"); tt->comment_hdr = tdrpStrDup("REMAP TO LAT-LON - READ OPERATIONS ONLY"); tt->comment_text = tdrpStrDup("Option to remap the projection to a Lat-lon grid."); tt++; // Parameter 'auto_remap_to_latlon' // ctype is 'tdrp_bool_t' memset(tt, 0, sizeof(TDRPtable)); tt->ptype = BOOL_TYPE; tt->param_name = tdrpStrDup("auto_remap_to_latlon"); tt->descr = tdrpStrDup("Option to auto-remap to lat-lon grid."); tt->help = tdrpStrDup("If set, the data will be automaticall remapped to a lat-lon grid before being returned to the client. The grid parameters will be chosen to fit the data set as well as possible."); tt->val_offset = (char *) &auto_remap_to_latlon - &_start_; tt->single_val.b = pFALSE; tt++; // Parameter 'Comment 12' memset(tt, 0, sizeof(TDRPtable)); tt->ptype = COMMENT_TYPE; tt->param_name = tdrpStrDup("Comment 12"); tt->comment_hdr = tdrpStrDup("CONSTRAIN THE LEAD TIMES FOR FORECAST DATA - READ OPERATIONS ONLY"); tt->comment_text = tdrpStrDup("This option allows you to select only certain lead times to be served out. You can also specify that the search time be interpreted as the generate time."); tt++; // Parameter 'constrain_forecast_lead_times' // ctype is 'tdrp_bool_t' memset(tt, 0, sizeof(TDRPtable)); tt->ptype = BOOL_TYPE; tt->param_name = tdrpStrDup("constrain_forecast_lead_times"); tt->descr = tdrpStrDup("Option to constrain the lead times to be considered."); tt->help = tdrpStrDup("If true, only forecast lead times within the specified limits will be considerd. Also, you can specify to request the data by generate time rather than valid time. The valid time will be computed as the request_time plus the mean of the min and max lead times."); tt->val_offset = (char *) &constrain_forecast_lead_times - &_start_; tt->single_val.b = pFALSE; tt++; // Parameter 'forecast_constraints' // ctype is '_forecast_constraints_t' memset(tt, 0, sizeof(TDRPtable)); tt->ptype = STRUCT_TYPE; tt->param_name = tdrpStrDup("forecast_constraints"); tt->descr = tdrpStrDup("Set constraints for forecast lead times."); tt->help = tdrpStrDup("See constrain_forecast_lead_times. Only forecast lead times within the specified limits will be considerd. If request_by_gen_time is true, the search_time specified will be interpreted as the generate time rather than the valid time. The valid time will be computed as the search_time plus the mean of the min and max lead times specified."); tt->val_offset = (char *) &forecast_constraints - &_start_; tt->struct_def.name = tdrpStrDup("forecast_constraints_t"); tt->struct_def.nfields = 3; tt->struct_def.fields = (struct_field_t *) tdrpMalloc(tt->struct_def.nfields * sizeof(struct_field_t)); tt->struct_def.fields[0].ftype = tdrpStrDup("int"); tt->struct_def.fields[0].fname = tdrpStrDup("min_lead_time"); tt->struct_def.fields[0].ptype = INT_TYPE; tt->struct_def.fields[0].rel_offset = (char *) &forecast_constraints.min_lead_time - (char *) &forecast_constraints; tt->struct_def.fields[1].ftype = tdrpStrDup("int"); tt->struct_def.fields[1].fname = tdrpStrDup("max_lead_time"); tt->struct_def.fields[1].ptype = INT_TYPE; tt->struct_def.fields[1].rel_offset = (char *) &forecast_constraints.max_lead_time - (char *) &forecast_constraints; tt->struct_def.fields[2].ftype = tdrpStrDup("boolean"); tt->struct_def.fields[2].fname = tdrpStrDup("request_by_gen_time"); tt->struct_def.fields[2].ptype = BOOL_TYPE; tt->struct_def.fields[2].rel_offset = (char *) &forecast_constraints.request_by_gen_time - (char *) &forecast_constraints; tt->n_struct_vals = 3; tt->struct_vals = (tdrpVal_t *) tdrpMalloc(tt->n_struct_vals * sizeof(tdrpVal_t)); tt->struct_vals[0].i = 0; tt->struct_vals[1].i = 0; tt->struct_vals[2].b = pFALSE; tt++; // Parameter 'Comment 13' memset(tt, 0, sizeof(TDRPtable)); tt->ptype = COMMENT_TYPE; tt->param_name = tdrpStrDup("Comment 13"); tt->comment_hdr = tdrpStrDup("CREATE COMPOSITE - READ OPERATIONS ONLY"); tt->comment_text = tdrpStrDup("Option to create a composite - max at any height."); tt++; // Parameter 'create_composite_on_read' // ctype is 'tdrp_bool_t' memset(tt, 0, sizeof(TDRPtable)); tt->ptype = BOOL_TYPE; tt->param_name = tdrpStrDup("create_composite_on_read"); tt->descr = tdrpStrDup("Option to create composite on read."); tt->help = tdrpStrDup("If true, compute the max-in-column on the fly during the read."); tt->val_offset = (char *) &create_composite_on_read - &_start_; tt->single_val.b = pFALSE; tt++; // Parameter 'Comment 14' memset(tt, 0, sizeof(TDRPtable)); tt->ptype = COMMENT_TYPE; tt->param_name = tdrpStrDup("Comment 14"); tt->comment_hdr = tdrpStrDup("DECIMATION - READ OPERATIONS ONLY"); tt->comment_text = tdrpStrDup(""); tt++; // Parameter 'decimate' // ctype is 'tdrp_bool_t' memset(tt, 0, sizeof(TDRPtable)); tt->ptype = BOOL_TYPE; tt->param_name = tdrpStrDup("decimate"); tt->descr = tdrpStrDup("Option to decimate to control number of grid cells served out."); tt->help = tdrpStrDup("This controls the decimation feature. If TRUE, the server decimates the output data to keep the total number of xy points below 'decimation_max_nxy'."); tt->val_offset = (char *) &decimate - &_start_; tt->single_val.b = pFALSE; tt++; // Parameter 'decimation_max_nxy' // ctype is 'int' memset(tt, 0, sizeof(TDRPtable)); tt->ptype = INT_TYPE; tt->param_name = tdrpStrDup("decimation_max_nxy"); tt->descr = tdrpStrDup("Maximum number of XY points."); tt->help = tdrpStrDup("See 'decimate'."); tt->val_offset = (char *) &decimation_max_nxy - &_start_; tt->single_val.i = 1000000; tt++; // Parameter 'Comment 15' memset(tt, 0, sizeof(TDRPtable)); tt->ptype = COMMENT_TYPE; tt->param_name = tdrpStrDup("Comment 15"); tt->comment_hdr = tdrpStrDup("MEASURED RHI DATA OPTION - READ OPERATIONS ONLY"); tt->comment_text = tdrpStrDup(""); tt++; // Parameter 'serve_rhi_data' // ctype is 'tdrp_bool_t' memset(tt, 0, sizeof(TDRPtable)); tt->ptype = BOOL_TYPE; tt->param_name = tdrpStrDup("serve_rhi_data"); tt->descr = tdrpStrDup("Option to serve out data for measured RHIs."); tt->help = tdrpStrDup("Normally a vertical section from polar radar data is served out as a reconstructed RHI. If this option is set, the server will try to read measured RHI data and return this. If the measured request fails, the server will revert to serving out the reconstructed RHI data."); tt->val_offset = (char *) &serve_rhi_data - &_start_; tt->single_val.b = pFALSE; tt++; // Parameter 'rhi_url' // ctype is 'char*' memset(tt, 0, sizeof(TDRPtable)); tt->ptype = STRING_TYPE; tt->param_name = tdrpStrDup("rhi_url"); tt->descr = tdrpStrDup("URL for measured RHI data."); tt->help = tdrpStrDup(""); tt->val_offset = (char *) &rhi_url - &_start_; tt->single_val.s = tdrpStrDup("none"); tt++; // Parameter 'polar_rhi' // ctype is 'tdrp_bool_t' memset(tt, 0, sizeof(TDRPtable)); tt->ptype = BOOL_TYPE; tt->param_name = tdrpStrDup("polar_rhi"); tt->descr = tdrpStrDup("Option to serve out polar data for RHI."); tt->help = tdrpStrDup("If true, the raw polar RHI data is returned. If false, the RHI is remapped onto a grid with height in km."); tt->val_offset = (char *) &polar_rhi - &_start_; tt->single_val.b = pTRUE; tt++; // Parameter 'rhi_time_margin' // ctype is 'int' memset(tt, 0, sizeof(TDRPtable)); tt->ptype = INT_TYPE; tt->param_name = tdrpStrDup("rhi_time_margin"); tt->descr = tdrpStrDup("Time margin when searching for RHIs."); tt->help = tdrpStrDup("The server will look for RHI files, in time, before and after the main field file (PPI or SURVEILLANCE). This is the time margin for the search."); tt->val_offset = (char *) &rhi_time_margin - &_start_; tt->single_val.i = 900; tt++; // Parameter 'rhi_max_az_error' // ctype is 'double' memset(tt, 0, sizeof(TDRPtable)); tt->ptype = DOUBLE_TYPE; tt->param_name = tdrpStrDup("rhi_max_az_error"); tt->descr = tdrpStrDup("Maximum azimuth error for retrieving RHI."); tt->help = tdrpStrDup("The user selects a vertical cross-section in the normal manner. The azimuth of the mid-point of the vert section is computed and the RHI closest to this azimuth is selected. If the azimuth difference between the selected azimuth and the closest RHI exceeds this max error, the RHI request fails and a normal vertical section is returned."); tt->val_offset = (char *) &rhi_max_az_error - &_start_; tt->single_val.d = 2; tt++; // Parameter 'respect_user_rhi_distance' // ctype is 'tdrp_bool_t' memset(tt, 0, sizeof(TDRPtable)); tt->ptype = BOOL_TYPE; tt->param_name = tdrpStrDup("respect_user_rhi_distance"); tt->descr = tdrpStrDup("Option to respect user distance for measured RHI."); tt->help = tdrpStrDup("If false (default) then the end points of the measured RHI are returned. If TRUE then the start point is the sensor but the end point is obtained by travelling in the direction of the RHI azimuth for the distance specified by the user."); tt->val_offset = (char *) &respect_user_rhi_distance - &_start_; tt->single_val.b = pFALSE; tt++; // Parameter 'Comment 16' memset(tt, 0, sizeof(TDRPtable)); tt->ptype = COMMENT_TYPE; tt->param_name = tdrpStrDup("Comment 16"); tt->comment_hdr = tdrpStrDup("VERTICAL UNITS SPECIFICATION - READ OPERATIONS ONLY"); tt->comment_text = tdrpStrDup(""); tt++; // Parameter 'specify_vertical_units' // ctype is 'tdrp_bool_t' memset(tt, 0, sizeof(TDRPtable)); tt->ptype = BOOL_TYPE; tt->param_name = tdrpStrDup("specify_vertical_units"); tt->descr = tdrpStrDup("Option to specify the vertical units for the returned data."); tt->help = tdrpStrDup("If set, the vertical units will be converted, if possible, as specified by 'vertical_units'. If the conversion is not possible, the data will be returned in the normal units."); tt->val_offset = (char *) &specify_vertical_units - &_start_; tt->single_val.b = pFALSE; tt++; // Parameter 'vertical_units' // ctype is '_vertical_units_t' memset(tt, 0, sizeof(TDRPtable)); tt->ptype = ENUM_TYPE; tt->param_name = tdrpStrDup("vertical_units"); tt->descr = tdrpStrDup("Vertical units"); tt->help = tdrpStrDup("See 'specify_vertical_units'. If this is TRUE, vert units will be converted as specified if possible."); tt->val_offset = (char *) &vertical_units - &_start_; tt->enum_def.name = tdrpStrDup("vertical_units_t"); tt->enum_def.nfields = 3; tt->enum_def.fields = (enum_field_t *) tdrpMalloc(tt->enum_def.nfields * sizeof(enum_field_t)); tt->enum_def.fields[0].name = tdrpStrDup("HEIGHT_KM"); tt->enum_def.fields[0].val = HEIGHT_KM; tt->enum_def.fields[1].name = tdrpStrDup("PRESSURE_MB"); tt->enum_def.fields[1].val = PRESSURE_MB; tt->enum_def.fields[2].name = tdrpStrDup("FLIGHT_LEVEL"); tt->enum_def.fields[2].val = FLIGHT_LEVEL; tt->single_val.e = HEIGHT_KM; tt++; // Parameter 'Comment 17' memset(tt, 0, sizeof(TDRPtable)); tt->ptype = COMMENT_TYPE; tt->param_name = tdrpStrDup("Comment 17"); tt->comment_hdr = tdrpStrDup("DERIVED FIELDS - READ OPERATIONS ONLY"); tt->comment_text = tdrpStrDup("Creating derived fields on the fly."); tt++; // Parameter 'handle_derived_fields' // ctype is 'tdrp_bool_t' memset(tt, 0, sizeof(TDRPtable)); tt->ptype = BOOL_TYPE; tt->param_name = tdrpStrDup("handle_derived_fields"); tt->descr = tdrpStrDup("Option to allow the option of computing derived fields on the fly."); tt->help = tdrpStrDup("If TRUE, the server will check the requested fields against the derived_fields array. If any requested field name matches an entry in the derived fields array, it will create the derived field on the fly and add it to the Mdvx object which is returned to the client. All other fields (i.e. those which do not appear in the derived_fields array) will be returned as normal."); tt->val_offset = (char *) &handle_derived_fields - &_start_; tt->single_val.b = pFALSE; tt++; // Parameter 'derived_fields' // ctype is '_derived_field_t' memset(tt, 0, sizeof(TDRPtable)); tt->ptype = STRUCT_TYPE; tt->param_name = tdrpStrDup("derived_fields"); tt->descr = tdrpStrDup("Specifications for derived fields supported by the server."); tt->help = tdrpStrDup("If a requested field name matches one specified in this array, and handle_derived_fields is TRUE, the server will attempt to derive the field on the fly. It will use the function specified, along with the arguments in the struct, to derive the field. The arguments actually used will be dependent on the particular function chosen. The arguments which are relevant to each function type are documented below.\n\nAfter the field has been derived, a linear function will be applied to produce the final field as follows:\n final = derived * multiplier + constant.\n\nThis allows a simple linear scaling and offset to be applied. The field will be added to the returned Mdvx object, with the supplied name, long_name, units and transform filled in.\n\nSUPPORTED FUNCTIONS\n\nFUNC_LINEAR:\n read in the field specified in field_name_1 and apply the linear scaling. This can be used for units conversion. Examples are (a) converting from m/s to knots (multiplier = 0.53996847, constant = 0.0), (b) converting degrees celsius to farenheight (multiplier = 1.8, constant = 32.0)\n\nFUNC_SPEED_FROM_U_V:\n compute speed from U and V fields. U field name is in field_name_1, and V field name is in field_name_2. U and V field data must both be in the same file, at the given URL.\n\nFUNC_DIRN_FROM_U_V:\n compute direction from U and V fields. U field name is in field_name_1, and V field name is in field_name_2. U and V field data must both be in the same file, at the given URL. Direction returned in deg T.\n\nFUNC_DIFF_FIELDS_SAME_FILE:\n compute difference between two fields from the same file. Data for both fields must be present in the file at the requested URL. First field name is in field_name_1, and second field name is in field_name_2. Difference is computed as (field_1 - field_2). Apply a multiplier of -1 to change the sign.\n\nFUNC_DIFF_FIELDS:\n compute difference between two fields. Field data not necessarily in same file. First field name is in field_name_1, and second field name is in field_name_2. First field is in the current file. Second field URL is url_2. Difference is computed as (field_1 - field_2). Apply a multiplier of -1 to change the sign. If i_arg_1 is not 0, the second field search time will be the first field time plus i_arg_1 in secs.\n\nFUNC_DIFF_IN_TIME:\n compute difference between data now and at a different time. Field name is given in field_name_1. Time difference in seconds is given in i_arg_1. So time for second file is time for first file plus i_arg_1. Data difference is computed as value now minus the value at the different time. Apply a multiplier of -1 to change the sign.\n\nFUNC_VERT_COMPOSITE:\n compute a vertical composite, which is the maximum value at any level. Optionally you can specify vertical level limits. Field name to be composited is given in field_name_1. If i_arg_1 is 0, the composite is computed from all vertical levels. If i_arg_1 is 1, the minimum vertical level is given in d_arg_1 and the maximum level in d_arg_2.\n\n \n\n"); tt->array_offset = (char *) &_derived_fields - &_start_; tt->array_n_offset = (char *) &derived_fields_n - &_start_; tt->is_array = TRUE; tt->array_len_fixed = FALSE; tt->array_elem_size = sizeof(derived_field_t); tt->array_n = 1; tt->struct_def.name = tdrpStrDup("derived_field_t"); tt->struct_def.nfields = 23; tt->struct_def.fields = (struct_field_t *) tdrpMalloc(tt->struct_def.nfields * sizeof(struct_field_t)); tt->struct_def.fields[0].ftype = tdrpStrDup("string"); tt->struct_def.fields[0].fname = tdrpStrDup("name"); tt->struct_def.fields[0].ptype = STRING_TYPE; tt->struct_def.fields[0].rel_offset = (char *) &_derived_fields->name - (char *) _derived_fields; tt->struct_def.fields[1].ftype = tdrpStrDup("string"); tt->struct_def.fields[1].fname = tdrpStrDup("long_name"); tt->struct_def.fields[1].ptype = STRING_TYPE; tt->struct_def.fields[1].rel_offset = (char *) &_derived_fields->long_name - (char *) _derived_fields; tt->struct_def.fields[2].ftype = tdrpStrDup("string"); tt->struct_def.fields[2].fname = tdrpStrDup("units"); tt->struct_def.fields[2].ptype = STRING_TYPE; tt->struct_def.fields[2].rel_offset = (char *) &_derived_fields->units - (char *) _derived_fields; tt->struct_def.fields[3].ftype = tdrpStrDup("string"); tt->struct_def.fields[3].fname = tdrpStrDup("transform"); tt->struct_def.fields[3].ptype = STRING_TYPE; tt->struct_def.fields[3].rel_offset = (char *) &_derived_fields->transform - (char *) _derived_fields; tt->struct_def.fields[4].ftype = tdrpStrDup("function_t"); tt->struct_def.fields[4].fname = tdrpStrDup("function"); tt->struct_def.fields[4].ptype = ENUM_TYPE; tt->struct_def.fields[4].rel_offset = (char *) &_derived_fields->function - (char *) _derived_fields; tt->struct_def.fields[4].enum_def.name = tdrpStrDup("function_t"); tt->struct_def.fields[4].enum_def.nfields = 7; tt->struct_def.fields[4].enum_def.fields = (enum_field_t *) tdrpMalloc (tt->struct_def.fields[4].enum_def.nfields * sizeof(enum_field_t)); tt->struct_def.fields[4].enum_def.fields[0].name = tdrpStrDup("FUNC_LINEAR"); tt->struct_def.fields[4].enum_def.fields[0].val = FUNC_LINEAR; tt->struct_def.fields[4].enum_def.fields[1].name = tdrpStrDup("FUNC_SPEED_FROM_U_V"); tt->struct_def.fields[4].enum_def.fields[1].val = FUNC_SPEED_FROM_U_V; tt->struct_def.fields[4].enum_def.fields[2].name = tdrpStrDup("FUNC_DIRN_FROM_U_V"); tt->struct_def.fields[4].enum_def.fields[2].val = FUNC_DIRN_FROM_U_V; tt->struct_def.fields[4].enum_def.fields[3].name = tdrpStrDup("FUNC_DIFF_FIELDS_SAME_FILE"); tt->struct_def.fields[4].enum_def.fields[3].val = FUNC_DIFF_FIELDS_SAME_FILE; tt->struct_def.fields[4].enum_def.fields[4].name = tdrpStrDup("FUNC_DIFF_FIELDS"); tt->struct_def.fields[4].enum_def.fields[4].val = FUNC_DIFF_FIELDS; tt->struct_def.fields[4].enum_def.fields[5].name = tdrpStrDup("FUNC_DIFF_IN_TIME"); tt->struct_def.fields[4].enum_def.fields[5].val = FUNC_DIFF_IN_TIME; tt->struct_def.fields[4].enum_def.fields[6].name = tdrpStrDup("FUNC_VERT_COMPOSITE"); tt->struct_def.fields[4].enum_def.fields[6].val = FUNC_VERT_COMPOSITE; tt->struct_def.fields[5].ftype = tdrpStrDup("string"); tt->struct_def.fields[5].fname = tdrpStrDup("field_name_1"); tt->struct_def.fields[5].ptype = STRING_TYPE; tt->struct_def.fields[5].rel_offset = (char *) &_derived_fields->field_name_1 - (char *) _derived_fields; tt->struct_def.fields[6].ftype = tdrpStrDup("string"); tt->struct_def.fields[6].fname = tdrpStrDup("field_name_2"); tt->struct_def.fields[6].ptype = STRING_TYPE; tt->struct_def.fields[6].rel_offset = (char *) &_derived_fields->field_name_2 - (char *) _derived_fields; tt->struct_def.fields[7].ftype = tdrpStrDup("string"); tt->struct_def.fields[7].fname = tdrpStrDup("url_2"); tt->struct_def.fields[7].ptype = STRING_TYPE; tt->struct_def.fields[7].rel_offset = (char *) &_derived_fields->url_2 - (char *) _derived_fields; tt->struct_def.fields[8].ftype = tdrpStrDup("string"); tt->struct_def.fields[8].fname = tdrpStrDup("url_3"); tt->struct_def.fields[8].ptype = STRING_TYPE; tt->struct_def.fields[8].rel_offset = (char *) &_derived_fields->url_3 - (char *) _derived_fields; tt->struct_def.fields[9].ftype = tdrpStrDup("string"); tt->struct_def.fields[9].fname = tdrpStrDup("s_arg_1"); tt->struct_def.fields[9].ptype = STRING_TYPE; tt->struct_def.fields[9].rel_offset = (char *) &_derived_fields->s_arg_1 - (char *) _derived_fields; tt->struct_def.fields[10].ftype = tdrpStrDup("string"); tt->struct_def.fields[10].fname = tdrpStrDup("s_arg_2"); tt->struct_def.fields[10].ptype = STRING_TYPE; tt->struct_def.fields[10].rel_offset = (char *) &_derived_fields->s_arg_2 - (char *) _derived_fields; tt->struct_def.fields[11].ftype = tdrpStrDup("string"); tt->struct_def.fields[11].fname = tdrpStrDup("s_arg_3"); tt->struct_def.fields[11].ptype = STRING_TYPE; tt->struct_def.fields[11].rel_offset = (char *) &_derived_fields->s_arg_3 - (char *) _derived_fields; tt->struct_def.fields[12].ftype = tdrpStrDup("string"); tt->struct_def.fields[12].fname = tdrpStrDup("s_arg_4"); tt->struct_def.fields[12].ptype = STRING_TYPE; tt->struct_def.fields[12].rel_offset = (char *) &_derived_fields->s_arg_4 - (char *) _derived_fields; tt->struct_def.fields[13].ftype = tdrpStrDup("string"); tt->struct_def.fields[13].fname = tdrpStrDup("s_arg_5"); tt->struct_def.fields[13].ptype = STRING_TYPE; tt->struct_def.fields[13].rel_offset = (char *) &_derived_fields->s_arg_5 - (char *) _derived_fields; tt->struct_def.fields[14].ftype = tdrpStrDup("string"); tt->struct_def.fields[14].fname = tdrpStrDup("s_arg_6"); tt->struct_def.fields[14].ptype = STRING_TYPE; tt->struct_def.fields[14].rel_offset = (char *) &_derived_fields->s_arg_6 - (char *) _derived_fields; tt->struct_def.fields[15].ftype = tdrpStrDup("int"); tt->struct_def.fields[15].fname = tdrpStrDup("i_arg_1"); tt->struct_def.fields[15].ptype = INT_TYPE; tt->struct_def.fields[15].rel_offset = (char *) &_derived_fields->i_arg_1 - (char *) _derived_fields; tt->struct_def.fields[16].ftype = tdrpStrDup("int"); tt->struct_def.fields[16].fname = tdrpStrDup("i_arg_2"); tt->struct_def.fields[16].ptype = INT_TYPE; tt->struct_def.fields[16].rel_offset = (char *) &_derived_fields->i_arg_2 - (char *) _derived_fields; tt->struct_def.fields[17].ftype = tdrpStrDup("int"); tt->struct_def.fields[17].fname = tdrpStrDup("i_arg_3"); tt->struct_def.fields[17].ptype = INT_TYPE; tt->struct_def.fields[17].rel_offset = (char *) &_derived_fields->i_arg_3 - (char *) _derived_fields; tt->struct_def.fields[18].ftype = tdrpStrDup("double"); tt->struct_def.fields[18].fname = tdrpStrDup("d_arg_1"); tt->struct_def.fields[18].ptype = DOUBLE_TYPE; tt->struct_def.fields[18].rel_offset = (char *) &_derived_fields->d_arg_1 - (char *) _derived_fields; tt->struct_def.fields[19].ftype = tdrpStrDup("double"); tt->struct_def.fields[19].fname = tdrpStrDup("d_arg_2"); tt->struct_def.fields[19].ptype = DOUBLE_TYPE; tt->struct_def.fields[19].rel_offset = (char *) &_derived_fields->d_arg_2 - (char *) _derived_fields; tt->struct_def.fields[20].ftype = tdrpStrDup("double"); tt->struct_def.fields[20].fname = tdrpStrDup("d_arg_3"); tt->struct_def.fields[20].ptype = DOUBLE_TYPE; tt->struct_def.fields[20].rel_offset = (char *) &_derived_fields->d_arg_3 - (char *) _derived_fields; tt->struct_def.fields[21].ftype = tdrpStrDup("double"); tt->struct_def.fields[21].fname = tdrpStrDup("multiplier"); tt->struct_def.fields[21].ptype = DOUBLE_TYPE; tt->struct_def.fields[21].rel_offset = (char *) &_derived_fields->multiplier - (char *) _derived_fields; tt->struct_def.fields[22].ftype = tdrpStrDup("double"); tt->struct_def.fields[22].fname = tdrpStrDup("constant"); tt->struct_def.fields[22].ptype = DOUBLE_TYPE; tt->struct_def.fields[22].rel_offset = (char *) &_derived_fields->constant - (char *) _derived_fields; tt->n_struct_vals = 23; tt->struct_vals = (tdrpVal_t *) tdrpMalloc(tt->n_struct_vals * sizeof(tdrpVal_t)); tt->struct_vals[0].s = tdrpStrDup("unknown"); tt->struct_vals[1].s = tdrpStrDup("unknown"); tt->struct_vals[2].s = tdrpStrDup("none"); tt->struct_vals[3].s = tdrpStrDup("none"); tt->struct_vals[4].e = FUNC_SPEED_FROM_U_V; tt->struct_vals[5].s = tdrpStrDup("U"); tt->struct_vals[6].s = tdrpStrDup("V"); tt->struct_vals[7].s = tdrpStrDup(""); tt->struct_vals[8].s = tdrpStrDup(""); tt->struct_vals[9].s = tdrpStrDup(""); tt->struct_vals[10].s = tdrpStrDup(""); tt->struct_vals[11].s = tdrpStrDup(""); tt->struct_vals[12].s = tdrpStrDup(""); tt->struct_vals[13].s = tdrpStrDup(""); tt->struct_vals[14].s = tdrpStrDup(""); tt->struct_vals[15].i = 0; tt->struct_vals[16].i = 0; tt->struct_vals[17].i = 0; tt->struct_vals[18].d = 0; tt->struct_vals[19].d = 0; tt->struct_vals[20].d = 0; tt->struct_vals[21].d = 1; tt->struct_vals[22].d = 0; tt++; // Parameter 'Comment 18' memset(tt, 0, sizeof(TDRPtable)); tt->ptype = COMMENT_TYPE; tt->param_name = tdrpStrDup("Comment 18"); tt->comment_hdr = tdrpStrDup("CLIMATOLOGY DATA"); tt->comment_text = tdrpStrDup("Option to serve out data from a climatology directory if a time-based request is made."); tt++; // Parameter 'use_climatology_url' // ctype is 'tdrp_bool_t' memset(tt, 0, sizeof(TDRPtable)); tt->ptype = BOOL_TYPE; tt->param_name = tdrpStrDup("use_climatology_url"); tt->descr = tdrpStrDup("Option to serve out data from a climatology directory."); tt->help = tdrpStrDup("If set, the data will always be read from a climatology data directory. The climatology type and URL are specified below."); tt->val_offset = (char *) &use_climatology_url - &_start_; tt->single_val.b = pFALSE; tt++; // Parameter 'climatology_type' // ctype is '_climatology_type_t' memset(tt, 0, sizeof(TDRPtable)); tt->ptype = ENUM_TYPE; tt->param_name = tdrpStrDup("climatology_type"); tt->descr = tdrpStrDup("Type of climatology to collect."); tt->help = tdrpStrDup("\tCLIMO_HOURLY - Collect the data at hourly intervals. With this type of collection, there will be a climo file for every hour of the year, with the hourly cut off times being at the top of the hour (so you'll have data for 1:00-2:00 UTC in one file, etc). The climo files will be named at the half hour (so the 1:00 - 2:00 data will be in the 013000.mdv file).\n\tCLIMO_HOURLY_BY_MONTH - Collect the data at hourly intervals, but store all of the data for the entire month for a given hour in the same file (so you'll have data for 1:00-2:00 UTC for every day of June in one file, etc). The climo files will be named at the half hour for the 15th day of the month.\n\tCLIMO_3HOURLY_BY_MONTH - Collect the data at 3-hourly intervals, but store all of the data for the entire month for a given 3-hour period in the same file (so you'll have data for 0:00-2:59 UTC for every day of June in one file, etc). The climo file will be named at the center of the 3-hour time period (1:30, 4:30, etc) for the 15th day of the month.\n\tCLIMO_HOURLY_DIURNAL - Collect the data at hourly intervals and store all of the data for a given hour in the same file. All of the data will be stored under June 15, 2003.\n\tDIURNAL_CLIMATOLOGY - Server data from a diurnal climatology generated externally (not using MdvXxxClimo). In this case, the server will search for the climatology file in the climatology_dir directory that is closest in time to the requested data, ignoring the date information in the request.\n\tCLIMO_3HOURLY_DIURNAL - Collect the data at 3-hour intervals and store all of the data under June 15, 2003.\n\tCLIMO_DAILY - Collect the data daily and store under the current date in the year 2003 at time 12:00:00.\n\tCLIMO_DAILY_BY_YEAR - Collect the data daily and store under the current date at time 12:00:00. Note that this climatology doesn't go back through all time but keeps daily statistics for each year instead. This is useful for computing other statistics through all time.\n\tCLIMO_MONTHLY - Collect the data monthly and store under the 15th of the month in the year 2003 at time 12:00:00.\n\tCLIMO_MONTHLY_BY_YEAR - Collect the data monthly and store under the 15th of the current month at time 12:00:00. Note that this climatology doesn't go back through all time but keeps monthly statistics for each year instead. This is useful for computing other statistics through all time.\n"); tt->val_offset = (char *) &climatology_type - &_start_; tt->enum_def.name = tdrpStrDup("climatology_type_t"); tt->enum_def.nfields = 10; tt->enum_def.fields = (enum_field_t *) tdrpMalloc(tt->enum_def.nfields * sizeof(enum_field_t)); tt->enum_def.fields[0].name = tdrpStrDup("CLIMO_HOURLY"); tt->enum_def.fields[0].val = CLIMO_HOURLY; tt->enum_def.fields[1].name = tdrpStrDup("CLIMO_HOURLY_BY_MONTH"); tt->enum_def.fields[1].val = CLIMO_HOURLY_BY_MONTH; tt->enum_def.fields[2].name = tdrpStrDup("CLIMO_3HOURLY_BY_MONTH"); tt->enum_def.fields[2].val = CLIMO_3HOURLY_BY_MONTH; tt->enum_def.fields[3].name = tdrpStrDup("CLIMO_HOURLY_DIURNAL"); tt->enum_def.fields[3].val = CLIMO_HOURLY_DIURNAL; tt->enum_def.fields[4].name = tdrpStrDup("DIURNAL_CLIMATOLOGY"); tt->enum_def.fields[4].val = DIURNAL_CLIMATOLOGY; tt->enum_def.fields[5].name = tdrpStrDup("CLIMO_3HOURLY_DIURNAL"); tt->enum_def.fields[5].val = CLIMO_3HOURLY_DIURNAL; tt->enum_def.fields[6].name = tdrpStrDup("CLIMO_DAILY"); tt->enum_def.fields[6].val = CLIMO_DAILY; tt->enum_def.fields[7].name = tdrpStrDup("CLIMO_DAILY_BY_YEAR"); tt->enum_def.fields[7].val = CLIMO_DAILY_BY_YEAR; tt->enum_def.fields[8].name = tdrpStrDup("CLIMO_MONTHLY"); tt->enum_def.fields[8].val = CLIMO_MONTHLY; tt->enum_def.fields[9].name = tdrpStrDup("CLIMO_MONTHLY_BY_YEAR"); tt->enum_def.fields[9].val = CLIMO_MONTHLY_BY_YEAR; tt->single_val.e = CLIMO_HOURLY; tt++; // Parameter 'climatology_dir' // ctype is 'char*' memset(tt, 0, sizeof(TDRPtable)); tt->ptype = STRING_TYPE; tt->param_name = tdrpStrDup("climatology_dir"); tt->descr = tdrpStrDup("Directory containing the climatology data."); tt->help = tdrpStrDup("Used only if climatology_type is set to DIURNAL_CLIMATOLOGY."); tt->val_offset = (char *) &climatology_dir - &_start_; tt->single_val.s = tdrpStrDup(""); tt++; // Parameter 'Comment 19' memset(tt, 0, sizeof(TDRPtable)); tt->ptype = COMMENT_TYPE; tt->param_name = tdrpStrDup("Comment 19"); tt->comment_hdr = tdrpStrDup("FILLING IN REGIONS OF MISSING DATA - READ OPERATIONS ONLY"); tt->comment_text = tdrpStrDup(""); tt++; // Parameter 'fill_missing_regions' // ctype is 'tdrp_bool_t' memset(tt, 0, sizeof(TDRPtable)); tt->ptype = BOOL_TYPE; tt->param_name = tdrpStrDup("fill_missing_regions"); tt->descr = tdrpStrDup("Option to fill in regions of missing data from surrounding areas."); tt->help = tdrpStrDup("If set, the server will attempt to fill in missing regions, using adjacent data. This will only be done if less than 20% of the area is missing."); tt->val_offset = (char *) &fill_missing_regions - &_start_; tt->single_val.b = pFALSE; tt++; // Parameter 'Comment 20' memset(tt, 0, sizeof(TDRPtable)); tt->ptype = COMMENT_TYPE; tt->param_name = tdrpStrDup("Comment 20"); tt->comment_hdr = tdrpStrDup("SETTING VALID TIME SEARCH WEIGHT - READ OPERATIONS ONLY"); tt->comment_text = tdrpStrDup("Only applies to forecast data sets stored in the gen_time/forecast_time format."); tt++; // Parameter 'set_valid_time_search_wt' // ctype is 'tdrp_bool_t' memset(tt, 0, sizeof(TDRPtable)); tt->ptype = BOOL_TYPE; tt->param_name = tdrpStrDup("set_valid_time_search_wt"); tt->descr = tdrpStrDup("Option to sey valid time search weight."); tt->help = tdrpStrDup("This applies to finding the best forecast when forecast data is stored in the gen_time/lead_time directory structure.\n\nWhen the data is stored in this manner, forecast times (valid times) from one gen time often overlap with forecast times from a different generate time. As a result there is ambiguity about which is the 'best forecast' to use.\n\nIn this discussion, we will use 'valid time' and 'forecast time' synonymously, referring to the time at which a forecast is valid. The 'generate time' refers to the time at which a model was initialized (the analysis) or the time at which a forecast was made. The 'request time' is the time for which the client has requested the 'best forecast'.\n\nModel data is generally written out at even intervals (on say even hour or half-hour intervals), so that the valid times match exactly. Other forecast systems, such as the auto-nowcaster, produce forecasts at times which are not at even times relative to the hour, so when forecasts overlap the valid times do not match exactly.\n\nThe Mdvx classes perform what amounts to a 2-D search in the time domain, where one axis is valid time and the other axis is generate time. For each applicable file, the following are computed: (a) the difference between the request time and the valid time, say deltaV, and (b) the difference between the request time and generate time, say deltaG.\n\nThe following quantities are then computed:\n\n\twtdDeltaV = weight * deltaV;\n\tdelta2D = sqrt((deltaG * deltaG) + (wtdDeltaV * wtdDeltaV))\n\nThe 'best forecast' is the forecast with the lowest delta2D.\n\nThe optimum weight depends on the relative spacing between the valid times and the gen times. If gen times are much more widely spaced than valid times, a higher weight is needed to make sure we make the decision more on valid time than gen time.\n\nFor model data, the user generally wants to see a valid time closest to the time requested. To achieve this, we want to weight deltaV heavily. If the gen time spacing is 3 hours and the forecast spacing is 1 hour, a weight of 10 seems to work well. If the gen times are 6 hours apart and the forecast times only 30 minutes apart, a weight of 15 or more is recommended.\n\nFor nowcast-type applications, in which the gen time spacing is similar to or less than the valid time spacing, a value of 2.5 seems to work OK.\n\nIf set_valid_time_search_wt is FALSE, the default of 2.5 in the MdvxTimeList class is used.\n\nYou can also set this client-side, using setValidTimeSearchWt() in Mdvx."); tt->val_offset = (char *) &set_valid_time_search_wt - &_start_; tt->single_val.b = pFALSE; tt++; // Parameter 'valid_time_search_wt' // ctype is 'double' memset(tt, 0, sizeof(TDRPtable)); tt->ptype = DOUBLE_TYPE; tt->param_name = tdrpStrDup("valid_time_search_wt"); tt->descr = tdrpStrDup("See 'set_valid_time_search_wt.'"); tt->help = tdrpStrDup(""); tt->val_offset = (char *) &valid_time_search_wt - &_start_; tt->single_val.d = 2.5; tt++; // Parameter 'Comment 21' memset(tt, 0, sizeof(TDRPtable)); tt->ptype = COMMENT_TYPE; tt->param_name = tdrpStrDup("Comment 21"); tt->comment_hdr = tdrpStrDup("FORWARD ON WRITE - WRITE OPERATIONS ONLY"); tt->comment_text = tdrpStrDup(""); tt++; // Parameter 'forward_on_write' // ctype is 'tdrp_bool_t' memset(tt, 0, sizeof(TDRPtable)); tt->ptype = BOOL_TYPE; tt->param_name = tdrpStrDup("forward_on_write"); tt->descr = tdrpStrDup("Option to forward to multiple URLs on write."); tt->help = tdrpStrDup("A list of urls is specified by the 'forward_on_write_urls' parameter. The data is written to these URLs in ADDITION to the client-specified URL."); tt->val_offset = (char *) &forward_on_write - &_start_; tt->single_val.b = pFALSE; tt++; // Parameter 'forward_on_write_urls' // ctype is 'char*' memset(tt, 0, sizeof(TDRPtable)); tt->ptype = STRING_TYPE; tt->param_name = tdrpStrDup("forward_on_write_urls"); tt->descr = tdrpStrDup("The list of ADDITIONAL urls to which data will be written."); tt->help = tdrpStrDup("See 'forward_on_write'. The data is always written to the original URL, and will be optioanlly written to the additional specified URLs."); tt->array_offset = (char *) &_forward_on_write_urls - &_start_; tt->array_n_offset = (char *) &forward_on_write_urls_n - &_start_; tt->is_array = TRUE; tt->array_len_fixed = FALSE; tt->array_elem_size = sizeof(char*); tt->array_n = 2; tt->array_vals = (tdrpVal_t *) tdrpMalloc(tt->array_n * sizeof(tdrpVal_t)); tt->array_vals[0].s = tdrpStrDup("mdvp:://localhost::mdv/data/set1"); tt->array_vals[1].s = tdrpStrDup("mdvp:://remotehost::mdv/data/set1"); tt++; // Parameter 'Comment 22' memset(tt, 0, sizeof(TDRPtable)); tt->ptype = COMMENT_TYPE; tt->param_name = tdrpStrDup("Comment 22"); tt->comment_hdr = tdrpStrDup("OVERRIDE FORMAT for WRITES"); tt->comment_text = tdrpStrDup("If set, these override the write format specified in the message from the client.\n\nFORMAT_MDV: normal legacy MDV format\n\nFORMAT_XML: XML format. XML data consists of 2 buffers/files: an XML text buffer for the headers/meta-data, and a data buffer for the data. NOTE: only COMPRESSION_NONE and COMPRESSION_GZIP_VOL are supported in XML. File extensions are .mdv.xml and .xml.buf\n\nFORMAT_NCF: netCDF CF format. File extension is .mdv.nc"); tt++; // Parameter 'override_write_format' // ctype is 'tdrp_bool_t' memset(tt, 0, sizeof(TDRPtable)); tt->ptype = BOOL_TYPE; tt->param_name = tdrpStrDup("override_write_format"); tt->descr = tdrpStrDup("Option to override write format as specified by the client."); tt->help = tdrpStrDup("If specified, this will override that specified by the client. Default is MDV.\n\nHowever, if the environment variable MDV_WRITE_FORMAT is set, that will override this write_format parameter.\n\nThe environment variable MDV_WRITE_FORMAT can take the value 'FORMAT_MDV', 'FORMAT_XML' or 'FORMAT_NCF'."); tt->val_offset = (char *) &override_write_format - &_start_; tt->single_val.b = pFALSE; tt++; // Parameter 'write_format' // ctype is '_data_format_t' memset(tt, 0, sizeof(TDRPtable)); tt->ptype = ENUM_TYPE; tt->param_name = tdrpStrDup("write_format"); tt->descr = tdrpStrDup("Specify format of data files to be written."); tt->help = tdrpStrDup("See 'override_write_format'"); tt->val_offset = (char *) &write_format - &_start_; tt->enum_def.name = tdrpStrDup("data_format_t"); tt->enum_def.nfields = 3; tt->enum_def.fields = (enum_field_t *) tdrpMalloc(tt->enum_def.nfields * sizeof(enum_field_t)); tt->enum_def.fields[0].name = tdrpStrDup("FORMAT_MDV"); tt->enum_def.fields[0].val = FORMAT_MDV; tt->enum_def.fields[1].name = tdrpStrDup("FORMAT_XML"); tt->enum_def.fields[1].val = FORMAT_XML; tt->enum_def.fields[2].name = tdrpStrDup("FORMAT_NCF"); tt->enum_def.fields[2].val = FORMAT_NCF; tt->single_val.e = FORMAT_MDV; tt++; // Parameter 'Comment 23' memset(tt, 0, sizeof(TDRPtable)); tt->ptype = COMMENT_TYPE; tt->param_name = tdrpStrDup("Comment 23"); tt->comment_hdr = tdrpStrDup("WRITE IN FORECAST PATH STYLE"); tt->comment_text = tdrpStrDup(""); tt++; // Parameter 'write_as_forecast' // ctype is 'tdrp_bool_t' memset(tt, 0, sizeof(TDRPtable)); tt->ptype = BOOL_TYPE; tt->param_name = tdrpStrDup("write_as_forecast"); tt->descr = tdrpStrDup("Set to write the data as forecast in mdv format."); tt->help = tdrpStrDup("This forces a forecast style write."); tt->val_offset = (char *) &write_as_forecast - &_start_; tt->single_val.b = pFALSE; tt++; // Parameter 'if_forecast_write_as_forecast' // ctype is 'tdrp_bool_t' memset(tt, 0, sizeof(TDRPtable)); tt->ptype = BOOL_TYPE; tt->param_name = tdrpStrDup("if_forecast_write_as_forecast"); tt->descr = tdrpStrDup("Set to write the files in forecast style, if the data is of a forecast type."); tt->help = tdrpStrDup("This only writes out in forecast style if the data_collection_type in the master header is of type FORECAST or EXTRAPOLATED."); tt->val_offset = (char *) &if_forecast_write_as_forecast - &_start_; tt->single_val.b = pFALSE; tt++; // Parameter 'Comment 24' memset(tt, 0, sizeof(TDRPtable)); tt->ptype = COMMENT_TYPE; tt->param_name = tdrpStrDup("Comment 24"); tt->comment_hdr = tdrpStrDup("WRITE USING EXTENDED PATHS"); tt->comment_text = tdrpStrDup("This will be overridden if the environment variable MDV_WRITE_USING_EXTENDED_PATHS exists and is set to TRUE."); tt++; // Parameter 'write_using_extended_paths' // ctype is 'tdrp_bool_t' memset(tt, 0, sizeof(TDRPtable)); tt->ptype = BOOL_TYPE; tt->param_name = tdrpStrDup("write_using_extended_paths"); tt->descr = tdrpStrDup("Option to write files with extended paths."); tt->help = tdrpStrDup("If specified, this will override that specified by the client. Default is FALSE.\n\nIf set, paths will include a separate year subdirectory, and the file name will include date and time.\n\nNon-forecast path:\n dir/yyyy/yyyymmdd/yyyymmdd_hhmmss.mdv.\n\nForecast path:\n dir/yyyy/yyyymmdd/yyyymmdd_g_hhmmss_f_llllllll.mdv."); tt->val_offset = (char *) &write_using_extended_paths - &_start_; tt->single_val.b = pFALSE; tt++; // Parameter 'Comment 25' memset(tt, 0, sizeof(TDRPtable)); tt->ptype = COMMENT_TYPE; tt->param_name = tdrpStrDup("Comment 25"); tt->comment_hdr = tdrpStrDup("NETCDF CF SUPPORT."); tt->comment_text = tdrpStrDup("The following parameters control conversion of MDV files to NetCDF CF-compliant files."); tt++; // Parameter 'control_mdv2ncf' // ctype is 'tdrp_bool_t' memset(tt, 0, sizeof(TDRPtable)); tt->ptype = BOOL_TYPE; tt->param_name = tdrpStrDup("control_mdv2ncf"); tt->descr = tdrpStrDup("Option to set parameters for converting MDV to NCF."); tt->help = tdrpStrDup("If TRUE, the following netCDF-specific parameters will be used. If FALSE, these are ignored and the default conversion is performed."); tt->val_offset = (char *) &control_mdv2ncf - &_start_; tt->single_val.b = pFALSE; tt++; // Parameter 'ncf_global_attributes' // ctype is '_ncf_global_attributes_t' memset(tt, 0, sizeof(TDRPtable)); tt->ptype = STRUCT_TYPE; tt->param_name = tdrpStrDup("ncf_global_attributes"); tt->descr = tdrpStrDup("Global attributes for netCDF file"); tt->help = tdrpStrDup("These strings will be included as global attributes in the NetCDF file. Other global attributes will be determined from the MDV headers."); tt->val_offset = (char *) &ncf_global_attributes - &_start_; tt->struct_def.name = tdrpStrDup("ncf_global_attributes_t"); tt->struct_def.nfields = 3; tt->struct_def.fields = (struct_field_t *) tdrpMalloc(tt->struct_def.nfields * sizeof(struct_field_t)); tt->struct_def.fields[0].ftype = tdrpStrDup("string"); tt->struct_def.fields[0].fname = tdrpStrDup("institution"); tt->struct_def.fields[0].ptype = STRING_TYPE; tt->struct_def.fields[0].rel_offset = (char *) &ncf_global_attributes.institution - (char *) &ncf_global_attributes; tt->struct_def.fields[1].ftype = tdrpStrDup("string"); tt->struct_def.fields[1].fname = tdrpStrDup("references"); tt->struct_def.fields[1].ptype = STRING_TYPE; tt->struct_def.fields[1].rel_offset = (char *) &ncf_global_attributes.references - (char *) &ncf_global_attributes; tt->struct_def.fields[2].ftype = tdrpStrDup("string"); tt->struct_def.fields[2].fname = tdrpStrDup("comment"); tt->struct_def.fields[2].ptype = STRING_TYPE; tt->struct_def.fields[2].rel_offset = (char *) &ncf_global_attributes.comment - (char *) &ncf_global_attributes; tt->n_struct_vals = 3; tt->struct_vals = (tdrpVal_t *) tdrpMalloc(tt->n_struct_vals * sizeof(tdrpVal_t)); tt->struct_vals[0].s = tdrpStrDup("UCAR"); tt->struct_vals[1].s = tdrpStrDup(""); tt->struct_vals[2].s = tdrpStrDup("Converted by DsMdvServer"); tt++; // Parameter 'mdv2ncf_field_transforms' // ctype is '_mdv2ncf_field_transform_t' memset(tt, 0, sizeof(TDRPtable)); tt->ptype = STRUCT_TYPE; tt->param_name = tdrpStrDup("mdv2ncf_field_transforms"); tt->descr = tdrpStrDup("List of transforms. If mdv_field_name is found in the MDV data, these other parameters will be used to set the field variable in the netCDF file."); tt->help = tdrpStrDup(""); tt->array_offset = (char *) &_mdv2ncf_field_transforms - &_start_; tt->array_n_offset = (char *) &mdv2ncf_field_transforms_n - &_start_; tt->is_array = TRUE; tt->array_len_fixed = FALSE; tt->array_elem_size = sizeof(mdv2ncf_field_transform_t); tt->array_n = 1; tt->struct_def.name = tdrpStrDup("mdv2ncf_field_transform_t"); tt->struct_def.nfields = 9; tt->struct_def.fields = (struct_field_t *) tdrpMalloc(tt->struct_def.nfields * sizeof(struct_field_t)); tt->struct_def.fields[0].ftype = tdrpStrDup("string"); tt->struct_def.fields[0].fname = tdrpStrDup("mdv_field_name"); tt->struct_def.fields[0].ptype = STRING_TYPE; tt->struct_def.fields[0].rel_offset = (char *) &_mdv2ncf_field_transforms->mdv_field_name - (char *) _mdv2ncf_field_transforms; tt->struct_def.fields[1].ftype = tdrpStrDup("string"); tt->struct_def.fields[1].fname = tdrpStrDup("ncf_field_name"); tt->struct_def.fields[1].ptype = STRING_TYPE; tt->struct_def.fields[1].rel_offset = (char *) &_mdv2ncf_field_transforms->ncf_field_name - (char *) _mdv2ncf_field_transforms; tt->struct_def.fields[2].ftype = tdrpStrDup("string"); tt->struct_def.fields[2].fname = tdrpStrDup("ncf_standard_name"); tt->struct_def.fields[2].ptype = STRING_TYPE; tt->struct_def.fields[2].rel_offset = (char *) &_mdv2ncf_field_transforms->ncf_standard_name - (char *) _mdv2ncf_field_transforms; tt->struct_def.fields[3].ftype = tdrpStrDup("string"); tt->struct_def.fields[3].fname = tdrpStrDup("ncf_long_name"); tt->struct_def.fields[3].ptype = STRING_TYPE; tt->struct_def.fields[3].rel_offset = (char *) &_mdv2ncf_field_transforms->ncf_long_name - (char *) _mdv2ncf_field_transforms; tt->struct_def.fields[4].ftype = tdrpStrDup("string"); tt->struct_def.fields[4].fname = tdrpStrDup("ncf_units"); tt->struct_def.fields[4].ptype = STRING_TYPE; tt->struct_def.fields[4].rel_offset = (char *) &_mdv2ncf_field_transforms->ncf_units - (char *) _mdv2ncf_field_transforms; tt->struct_def.fields[5].ftype = tdrpStrDup("boolean"); tt->struct_def.fields[5].fname = tdrpStrDup("do_linear_transform"); tt->struct_def.fields[5].ptype = BOOL_TYPE; tt->struct_def.fields[5].rel_offset = (char *) &_mdv2ncf_field_transforms->do_linear_transform - (char *) _mdv2ncf_field_transforms; tt->struct_def.fields[6].ftype = tdrpStrDup("float"); tt->struct_def.fields[6].fname = tdrpStrDup("linear_multiplier"); tt->struct_def.fields[6].ptype = FLOAT_TYPE; tt->struct_def.fields[6].rel_offset = (char *) &_mdv2ncf_field_transforms->linear_multiplier - (char *) _mdv2ncf_field_transforms; tt->struct_def.fields[7].ftype = tdrpStrDup("float"); tt->struct_def.fields[7].fname = tdrpStrDup("linear_const"); tt->struct_def.fields[7].ptype = FLOAT_TYPE; tt->struct_def.fields[7].rel_offset = (char *) &_mdv2ncf_field_transforms->linear_const - (char *) _mdv2ncf_field_transforms; tt->struct_def.fields[8].ftype = tdrpStrDup("data_pack_t"); tt->struct_def.fields[8].fname = tdrpStrDup("packed_data_type"); tt->struct_def.fields[8].ptype = ENUM_TYPE; tt->struct_def.fields[8].rel_offset = (char *) &_mdv2ncf_field_transforms->packed_data_type - (char *) _mdv2ncf_field_transforms; tt->struct_def.fields[8].enum_def.name = tdrpStrDup("data_pack_t"); tt->struct_def.fields[8].enum_def.nfields = 4; tt->struct_def.fields[8].enum_def.fields = (enum_field_t *) tdrpMalloc (tt->struct_def.fields[8].enum_def.nfields * sizeof(enum_field_t)); tt->struct_def.fields[8].enum_def.fields[0].name = tdrpStrDup("DATA_PACK_FLOAT"); tt->struct_def.fields[8].enum_def.fields[0].val = DATA_PACK_FLOAT; tt->struct_def.fields[8].enum_def.fields[1].name = tdrpStrDup("DATA_PACK_SHORT"); tt->struct_def.fields[8].enum_def.fields[1].val = DATA_PACK_SHORT; tt->struct_def.fields[8].enum_def.fields[2].name = tdrpStrDup("DATA_PACK_BYTE"); tt->struct_def.fields[8].enum_def.fields[2].val = DATA_PACK_BYTE; tt->struct_def.fields[8].enum_def.fields[3].name = tdrpStrDup("DATA_PACK_ASIS"); tt->struct_def.fields[8].enum_def.fields[3].val = DATA_PACK_ASIS; tt->n_struct_vals = 9; tt->struct_vals = (tdrpVal_t *) tdrpMalloc(tt->n_struct_vals * sizeof(tdrpVal_t)); tt->struct_vals[0].s = tdrpStrDup("mdv_field_name"); tt->struct_vals[1].s = tdrpStrDup("ncf_field_name"); tt->struct_vals[2].s = tdrpStrDup("ncf_standard_name"); tt->struct_vals[3].s = tdrpStrDup("ncf_long_name"); tt->struct_vals[4].s = tdrpStrDup("ncf_units"); tt->struct_vals[5].b = pFALSE; tt->struct_vals[6].f = 1; tt->struct_vals[7].f = 0; tt->struct_vals[8].e = DATA_PACK_ASIS; tt++; // Parameter 'ncf_compress_data' // ctype is 'tdrp_bool_t' memset(tt, 0, sizeof(TDRPtable)); tt->ptype = BOOL_TYPE; tt->param_name = tdrpStrDup("ncf_compress_data"); tt->descr = tdrpStrDup("Option to compress field data."); tt->help = tdrpStrDup("Only applies to NETCDF4 and NETCDF4_CLASSIC files."); tt->val_offset = (char *) &ncf_compress_data - &_start_; tt->single_val.b = pTRUE; tt++; // Parameter 'ncf_compression_level' // ctype is 'int' memset(tt, 0, sizeof(TDRPtable)); tt->ptype = INT_TYPE; tt->param_name = tdrpStrDup("ncf_compression_level"); tt->descr = tdrpStrDup("Compression level from 1 to 9 with 9 being the greatest compression. Default is 9."); tt->help = tdrpStrDup("Only applies to NETCDF4 and NETCDF4_CLASSIC files."); tt->val_offset = (char *) &ncf_compression_level - &_start_; tt->single_val.i = 9; tt++; // Parameter 'ncf_filename_suffix' // ctype is 'char*' memset(tt, 0, sizeof(TDRPtable)); tt->ptype = STRING_TYPE; tt->param_name = tdrpStrDup("ncf_filename_suffix"); tt->descr = tdrpStrDup("Suffix of netCDF files"); tt->help = tdrpStrDup("File extension is always .nc. File name will end with mdv.suffix.nc. Set to the empty string for no suffix, in which case file name will end with .mdv.nc."); tt->val_offset = (char *) &ncf_filename_suffix - &_start_; tt->single_val.s = tdrpStrDup(""); tt++; // Parameter 'ncf_file_format' // ctype is '_ncformat_t' memset(tt, 0, sizeof(TDRPtable)); tt->ptype = ENUM_TYPE; tt->param_name = tdrpStrDup("ncf_file_format"); tt->descr = tdrpStrDup("NetCDF file format"); tt->help = tdrpStrDup("netCDF classic format, netCDF 64-bit offset format, netCDF4 using HDF5 format, netCDF4 using HDF5 format but only netCDF3 calls"); tt->val_offset = (char *) &ncf_file_format - &_start_; tt->enum_def.name = tdrpStrDup("ncformat_t"); tt->enum_def.nfields = 4; tt->enum_def.fields = (enum_field_t *) tdrpMalloc(tt->enum_def.nfields * sizeof(enum_field_t)); tt->enum_def.fields[0].name = tdrpStrDup("CLASSIC"); tt->enum_def.fields[0].val = CLASSIC; tt->enum_def.fields[1].name = tdrpStrDup("NC64BIT"); tt->enum_def.fields[1].val = NC64BIT; tt->enum_def.fields[2].name = tdrpStrDup("NETCDF4"); tt->enum_def.fields[2].val = NETCDF4; tt->enum_def.fields[3].name = tdrpStrDup("NETCDF4_CLASSIC"); tt->enum_def.fields[3].val = NETCDF4_CLASSIC; tt->single_val.e = NETCDF4; tt++; // Parameter 'ncf_output_latlon_arrays' // ctype is 'tdrp_bool_t' memset(tt, 0, sizeof(TDRPtable)); tt->ptype = BOOL_TYPE; tt->param_name = tdrpStrDup("ncf_output_latlon_arrays"); tt->descr = tdrpStrDup("If true latitude and longitude arrays of each grid point are output"); tt->help = tdrpStrDup("The CF convention requires that these arrays are present in the netCDF file; however, the information is redundant since the lat and lon arrays could be constructed using the other projection and grid information required with a gridded data field"); tt->val_offset = (char *) &ncf_output_latlon_arrays - &_start_; tt->single_val.b = pFALSE; tt++; // Parameter 'ncf_output_start_end_times' // ctype is 'tdrp_bool_t' memset(tt, 0, sizeof(TDRPtable)); tt->ptype = BOOL_TYPE; tt->param_name = tdrpStrDup("ncf_output_start_end_times"); tt->descr = tdrpStrDup("If true Mdv start_time and end_time are output"); tt->help = tdrpStrDup("If the information contained in the Mdv start_time and end_time is redundant or irrelevant the user can choose not to output these variables "); tt->val_offset = (char *) &ncf_output_start_end_times - &_start_; tt->single_val.b = pTRUE; tt++; // Parameter 'ncf_output_mdv_attributes' // ctype is 'tdrp_bool_t' memset(tt, 0, sizeof(TDRPtable)); tt->ptype = BOOL_TYPE; tt->param_name = tdrpStrDup("ncf_output_mdv_attributes"); tt->descr = tdrpStrDup("Option to output non-CF compliant MDV attributes."); tt->help = tdrpStrDup("If true, MDV attributes which are not CF compliant will be output. This will facilitate the translation of the data back into MDV with the minimal loss of information."); tt->val_offset = (char *) &ncf_output_mdv_attributes - &_start_; tt->single_val.b = pTRUE; tt++; // Parameter 'ncf_output_mdv_chunks' // ctype is 'tdrp_bool_t' memset(tt, 0, sizeof(TDRPtable)); tt->ptype = BOOL_TYPE; tt->param_name = tdrpStrDup("ncf_output_mdv_chunks"); tt->descr = tdrpStrDup("Option to output non-CF compliant MDV chunks."); tt->help = tdrpStrDup("If true, MDV chunks will be included as byte binary variables."); tt->val_offset = (char *) &ncf_output_mdv_chunks - &_start_; tt->single_val.b = pTRUE; tt++; // trailing entry has param_name set to NULL tt->param_name = NULL; return; }
[ "dixon@ucar.edu" ]
dixon@ucar.edu
6c02a68fa51f825a49d36a64d809c7f8854d6dc7
39b003b15d9cdf42483f43ee59293a935cd26ef1
/RemoteV/Plt_Remote/BitVncApp/platform/module/wificonnect.cpp
e5d55494232911ba006f540d1d251647a7b10d55
[]
no_license
hanqianjin/kang
f16fb3835ecd850a3a86bb93f0679c878c82acab
cc40e6be18287a7a3269e50371f2850cd03bfb5d
refs/heads/master
2021-06-25T23:47:54.108574
2020-11-20T02:46:25
2020-11-20T02:46:25
142,751,390
1
0
null
null
null
null
UTF-8
C++
false
false
1,648
cpp
#include "wificonnect.h" #include "ui_wificonnect.h" WifiConnect::WifiConnect(SSIDInfo *Info, pltKeyBoard* keyBoard, QWidget *parent) : pKeyBoard(keyBoard), QDialog(parent), pWifiInfo(Info), ui(new Ui::WifiConnect) { ui->setupUi(this); initDisplay(); setAttribute(Qt::WA_DeleteOnClose); setWindowModality(Qt::WindowModal); setWindowFlags(Qt::WindowStaysOnTopHint |Qt::FramelessWindowHint /*| Qt::Dialog*/); netFd = -1; } WifiConnect::~WifiConnect() { delete ui; } void WifiConnect::on_pb_pair_clicked() { char * passwd = ui->passWordEdit->text().toUtf8().data(); char *ssid = pWifiInfo->ssid; qint32 res = wireless_connect(&netFd, ssid, passwd); if(res == 0) { this->close(); }else { ui->lblWarning->setVisible(true); } return; } qint32 WifiConnect::exec() { pKeyBoard->show(); ui->passWordEdit->setFocus(); QDialog::exec(); pKeyBoard->hide(); return netFd; } void WifiConnect::on_pb_cancel_clicked() { this->close(); } void WifiConnect::initDisplay() { QString strNotice = QString("Wi-fi network “ %1 ” need to enter password.").arg(pWifiInfo->ssid); ui->lblnotice->setText(strNotice); ui->lblWarning->setVisible(false); } void WifiConnect::on_pb_pwView_clicked(bool checked) { if(checked) { ui->passWordEdit->setEchoMode(QLineEdit::Normal); }else { ui->passWordEdit->setEchoMode(QLineEdit::Password); } } void WifiConnect::on_passWordEdit_clicked() { pKeyBoard->show(); } void WifiConnect::on_passWordEdit_loseFocus() { pKeyBoard->hide(); close(); }
[ "41859296+hanqianjin@users.noreply.github.com" ]
41859296+hanqianjin@users.noreply.github.com
6eaed068ad1499c8ce81aec2d196dfc69f11d327
4ceae5c211120dc52c086dc8d80121808f1eb692
/src/imio.cpp
8761ab56c98b39814ec2f5489703f558706a59ef
[]
no_license
htcr/masterpiece
f4afc6d7e23102ff7e1808ced238b06f4edfc469
0d237dc705e5b470c8c82195c3963e96c0357356
refs/heads/master
2021-09-02T05:04:26.702502
2017-12-30T16:08:52
2017-12-30T16:08:52
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,445
cpp
#include <stdlib.h> //#include <random> #include <opencv2/opencv.hpp> //#include <float.h> #include "imio.hpp" using namespace cv; //using namespace std; float mean_c[3] = {104,117,123}; int img_in(char* file_path, float** pdst, int* c, int* h, int* w){ Mat img; img = imread(file_path); if(!img.data){ return -1; } unsigned char *data = img.data; *c = img.channels(); *h = img.rows; *w = img.cols; int count = (*c)*(*h)*(*w); *pdst = (float*) malloc(count*sizeof(float)); float *it = *pdst; for(int c_ = 0;c_<img.channels();c_++){ for(int i = 0;i<img.rows*img.cols;i++){ *(it) = (float)(data[img.channels()*i+c_]-mean_c[c_]); it++; } } return 0; } /* int noise(float* dst, int c, int h, int w){ default_random_engine e; uniform_real_distribution<float> u(0,10); for(int i = 0;i<c*h*w;i++){ dst[i] = u(e); } return 0; } */ int img_out(char* file_path, float* src, int c, int h, int w){ //linear_map(src,c,h,w); Mat img; img.create(h,w,CV_8UC(c)); unsigned char *data = img.data; for(int c_ = 0;c_<c;c_++){ for(int i = 0;i<h*w;i++){ float pix = (*src)+mean_c[c_]; pix = pix<0?0:pix; pix = pix>255?255:pix; data[i*c+c_] = (unsigned char)pix; src++; } } imwrite(file_path,img); return 0; } int img_show(float* src, int c, int h, int w){ Mat img; img.create(h,w,CV_8UC(c)); unsigned char *data = img.data; for(int c_ = 0;c_<c;c_++){ for(int i = 0;i<h*w;i++){ float pix = (*src)+mean_c[c_]; pix = pix<0?0:pix; pix = pix>255?255:pix; data[i*c+c_] = (unsigned char)pix; src++; } } namedWindow("imshow", WINDOW_AUTOSIZE); imshow("imshow", img); waitKey(0); return 0; } void sub_mean(float* src, float* mean, int c, int h, int w){ float sum = 0; for(int i = 0;i<c*h*w;i++){ sum+=src[i]; } sum/=(c*h*w); *mean = sum; for(int i = 0;i<c*h*w;i++){ src[i]-=sum; } } void add_mean(float* src, float mean, int c, int h, int w){ for(int i = 0;i<c*h*w;i++){ src[i]+=mean; } } /* void linear_map(float* src, int c, int h, int w){ for(int c_ = 0; c_<c;c_++){ float min = FLT_MAX; float max = FLT_MIN; for(int h_ = 0;h_<h;h_++){ for(int w_ = 0;w_<w;w_++){ float pix = src[h_*w+w_]; min = (pix<min)?(pix):(min); max = (pix>max)?(pix):(max); } } float d = max-min; for(int h_ = 0;h_<h;h_++){ for(int w_ = 0;w_<w;w_++){ float pix = src[h_*w+w_]; src[h_*w+w_] = (255.0/d*(pix-min)); } } src+=(h*w); } } */
[ "0987654321htcr@163.com" ]
0987654321htcr@163.com