blob_id
stringlengths
40
40
directory_id
stringlengths
40
40
path
stringlengths
3
264
content_id
stringlengths
40
40
detected_licenses
listlengths
0
85
license_type
stringclasses
2 values
repo_name
stringlengths
5
140
snapshot_id
stringlengths
40
40
revision_id
stringlengths
40
40
branch_name
stringclasses
905 values
visit_date
timestamp[us]date
2015-08-09 11:21:18
2023-09-06 10:45:07
revision_date
timestamp[us]date
1997-09-14 05:04:47
2023-09-17 19:19:19
committer_date
timestamp[us]date
1997-09-14 05:04:47
2023-09-06 06:22:19
github_id
int64
3.89k
681M
star_events_count
int64
0
209k
fork_events_count
int64
0
110k
gha_license_id
stringclasses
22 values
gha_event_created_at
timestamp[us]date
2012-06-07 00:51:45
2023-09-14 21:58:39
gha_created_at
timestamp[us]date
2008-03-27 23:40:48
2023-08-21 23:17:38
gha_language
stringclasses
141 values
src_encoding
stringclasses
34 values
language
stringclasses
1 value
is_vendor
bool
1 class
is_generated
bool
2 classes
length_bytes
int64
3
10.4M
extension
stringclasses
115 values
content
stringlengths
3
10.4M
authors
listlengths
1
1
author_id
stringlengths
0
158
cb441d405f550c04c231dc5754b3a8cd07dcae4c
3c9f984766c81ba95f1f4f828fd9c4e6efef9da1
/SupplyFinanceChain/src/SupplyFinanceChain/protocol/Serializer.h
9a052c07becddeec37f87eadc74b07c94e4fdd83
[]
no_license
SCF-Team/scfchain
5f73e3c3a41ac5e33d2637980f428a9b8173fda5
41f020da81e1c69a61d0c1698df04cf33b20fc63
refs/heads/master
2020-06-26T21:51:29.263077
2019-08-05T11:11:24
2019-08-05T11:11:24
199,766,740
1
1
null
null
null
null
UTF-8
C++
false
false
10,013
h
//------------------------------------------------------------------------------ /* This file is part of SupplyFinanceChaind: https://github.com/SupplyFinanceChain/SupplyFinanceChaind Copyright (c) 2012, 2013 SupplyFinanceChain 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. */ //============================================================================== #ifndef SUPPLYFINANCECHAIN_PROTOCOL_SERIALIZER_H_INCLUDED #define SUPPLYFINANCECHAIN_PROTOCOL_SERIALIZER_H_INCLUDED #include <SupplyFinanceChain/basics/base_uint.h> #include <SupplyFinanceChain/basics/Blob.h> #include <SupplyFinanceChain/basics/contract.h> #include <SupplyFinanceChain/basics/Buffer.h> #include <SupplyFinanceChain/basics/safe_cast.h> #include <SupplyFinanceChain/basics/Slice.h> #include <SupplyFinanceChain/beast/crypto/secure_erase.h> #include <SupplyFinanceChain/protocol/SField.h> #include <cassert> #include <cstdint> #include <iomanip> #include <sstream> #include <type_traits> namespace SupplyFinanceChain { class CKey; // forward declaration class Serializer { private: // DEPRECATED Blob mData; public: explicit Serializer (int n = 256) { mData.reserve (n); } Serializer (void const* data, std::size_t size) { mData.resize(size); if (size) { assert(data != nullptr); std::memcpy(mData.data(), data, size); } } Slice slice() const noexcept { return Slice(mData.data(), mData.size()); } std::size_t size() const noexcept { return mData.size(); } void const* data() const noexcept { return mData.data(); } // assemble functions int add8 (unsigned char byte); int add16 (std::uint16_t); int add32 (std::uint32_t); // ledger indexes, account sequence, timestamps int add64 (std::uint64_t); // native currency amounts int add128 (const uint128&); // private key generators int add256 (uint256 const& ); // transaction and ledger hashes template <typename Integer> int addInteger(Integer); template <int Bits, class Tag> int addBitString(base_uint<Bits, Tag> const& v) { int ret = mData.size (); mData.insert (mData.end (), v.begin (), v.end ()); return ret; } // TODO(tom): merge with add128 and add256. template <class Tag> int add160 (base_uint<160, Tag> const& i) { return addBitString<160, Tag>(i); } int addRaw (Blob const& vector); int addRaw (const void* ptr, int len); int addRaw (const Serializer& s); int addZeros (size_t uBytes); int addVL (Blob const& vector); int addVL (Slice const& slice); template<class Iter> int addVL (Iter begin, Iter end, int len); int addVL (const void* ptr, int len); // disassemble functions bool get8 (int&, int offset) const; bool get256 (uint256&, int offset) const; template <typename Integer> bool getInteger(Integer& number, int offset) { static const auto bytes = sizeof(Integer); if ((offset + bytes) > mData.size ()) return false; number = 0; auto ptr = &mData[offset]; for (auto i = 0; i < bytes; ++i) { if (i) number <<= 8; number |= *ptr++; } return true; } template <int Bits, typename Tag = void> bool getBitString(base_uint<Bits, Tag>& data, int offset) const { auto success = (offset + (Bits / 8)) <= mData.size (); if (success) memcpy (data.begin (), & (mData.front ()) + offset, (Bits / 8)); return success; } // TODO(tom): merge with get128 and get256. template <class Tag> bool get160 (base_uint<160, Tag>& o, int offset) const { return getBitString<160, Tag>(o, offset); } bool getRaw (Blob&, int offset, int length) const; Blob getRaw (int offset, int length) const; bool getVL (Blob& objectVL, int offset, int& length) const; bool getVLLength (int& length, int offset) const; int addFieldID (int type, int name); int addFieldID (SerializedTypeID type, int name) { return addFieldID (safe_cast<int> (type), name); } // DEPRECATED uint256 getSHA512Half() const; // totality functions Blob const& peekData () const { return mData; } Blob getData () const { return mData; } Blob& modData () { return mData; } int getDataLength () const { return mData.size (); } const void* getDataPtr () const { return mData.data(); } void* getDataPtr () { return mData.data(); } int getLength () const { return mData.size (); } std::string getString () const { return std::string (static_cast<const char*> (getDataPtr ()), size ()); } void secureErase () { beast::secure_erase(mData.data(), mData.size()); mData.clear (); } void erase () { mData.clear (); } bool chop (int num); // vector-like functions Blob ::iterator begin () { return mData.begin (); } Blob ::iterator end () { return mData.end (); } Blob ::const_iterator begin () const { return mData.begin (); } Blob ::const_iterator end () const { return mData.end (); } void reserve (size_t n) { mData.reserve (n); } void resize (size_t n) { mData.resize (n); } size_t capacity () const { return mData.capacity (); } bool operator== (Blob const& v) { return v == mData; } bool operator!= (Blob const& v) { return v != mData; } bool operator== (const Serializer& v) { return v.mData == mData; } bool operator!= (const Serializer& v) { return v.mData != mData; } std::string getHex () const { std::stringstream h; for (unsigned char const& element : mData) { h << std::setw (2) << std::hex << std::setfill ('0') << safe_cast<unsigned int>(element); } return h.str (); } static int decodeLengthLength (int b1); static int decodeVLLength (int b1); static int decodeVLLength (int b1, int b2); static int decodeVLLength (int b1, int b2, int b3); private: static int lengthVL (int length) { return length + encodeLengthLength (length); } static int encodeLengthLength (int length); // length to encode length int addEncoded (int length); }; template<class Iter> int Serializer::addVL(Iter begin, Iter end, int len) { int ret = addEncoded(len); for (; begin != end; ++begin) { addRaw(begin->data(), begin->size()); #ifndef NDEBUG len -= begin->size(); #endif } assert(len == 0); return ret; } //------------------------------------------------------------------------------ // DEPRECATED // Transitional adapter to new serialization interfaces class SerialIter { private: std::uint8_t const* p_; std::size_t remain_; std::size_t used_ = 0; public: SerialIter (void const* data, std::size_t size) noexcept; SerialIter (Slice const& slice) : SerialIter(slice.data(), slice.size()) { } // Infer the size of the data based on the size of the passed array. template<int N> explicit SerialIter (std::uint8_t const (&data)[N]) : SerialIter(&data[0], N) { static_assert (N > 0, ""); } std::size_t empty() const noexcept { return remain_ == 0; } void reset() noexcept; int getBytesLeft() const noexcept { return static_cast<int>(remain_); } // get functions throw on error unsigned char get8(); std::uint16_t get16(); std::uint32_t get32(); std::uint64_t get64(); template <int Bits, class Tag = void> base_uint<Bits, Tag> getBitString(); uint128 get128() { return getBitString<128>(); } uint160 get160() { return getBitString<160>(); } uint256 get256() { return getBitString<256>(); } void getFieldID (int& type, int& name); // Returns the size of the VL if the // next object is a VL. Advances the iterator // to the beginning of the VL. int getVLDataLength (); Slice getSlice (std::size_t bytes); // VFALCO DEPRECATED Returns a copy Blob getRaw (int size); // VFALCO DEPRECATED Returns a copy Blob getVL(); void skip (int num); Buffer getVLBuffer(); template<class T> T getRawHelper (int size); }; template <int Bits, class Tag> base_uint<Bits, Tag> SerialIter::getBitString() { base_uint<Bits, Tag> u; auto const n = Bits/8; if (remain_ < n) Throw<std::runtime_error> ( "invalid SerialIter getBitString"); std::memcpy (u.begin(), p_, n); p_ += n; used_ += n; remain_ -= n; return u; } } // SupplyFinanceChain #endif
[ "ghubdevelop@protonmail.com" ]
ghubdevelop@protonmail.com
616f94a1e07924a650257fdc40f5926c25cad923
e68c1f9134b44ddea144f7efa7523076f3f12d3a
/FinalCode/Monk_Male_DW_SF_DebilitatingBlows_03_2.h
5b63030a18c15861073ba59b15385ef15566354a
[]
no_license
iso5930/Direct-3D-Team-Portfolio
4ac710ede0c9176702595cba5579af42887611cf
84e64eb4e91c7e5b4aed77212cd08cfee038fcd3
refs/heads/master
2021-08-23T08:15:00.128591
2017-12-04T06:14:39
2017-12-04T06:14:39
112,998,717
0
0
null
null
null
null
UTF-8
C++
false
false
304
h
#pragma once #include "playerstate.h" class CMonk_Male_DW_SF_DebilitatingBlows_03_2 : public CPlayerState { public: virtual void Initialize(); virtual CPlayerState* Action(); public: explicit CMonk_Male_DW_SF_DebilitatingBlows_03_2(void); virtual ~CMonk_Male_DW_SF_DebilitatingBlows_03_2(void); };
[ "iso5930@naver.com" ]
iso5930@naver.com
8e8c4679fa4f8fe4d70e266d7918cf86e8703c2f
54f352a242a8ad6ff5516703e91da61e08d9a9e6
/Source Codes/AtCoder/abc103/C/4814128.cpp
c5ae9db1ee4cc6f2b7b3cfe77f3f96f23e4abe81
[]
no_license
Kawser-nerd/CLCDSA
5cbd8a4c3f65173e4e8e0d7ed845574c4770c3eb
aee32551795763b54acb26856ab239370cac4e75
refs/heads/master
2022-02-09T11:08:56.588303
2022-01-26T18:53:40
2022-01-26T18:53:40
211,783,197
23
9
null
null
null
null
UTF-8
C++
false
false
2,163
cpp
// https://atcoder.jp/contests/abc118/tasks/abc118_c // http://ctylim.hatenablog.com/entry/2015/08/30/191553 #include <iostream> #include <iomanip> #include <vector> #include <algorithm> #include <numeric> #include <functional> #include <cmath> #include <queue> #include <stack> #include <cstdlib> #include <cstdio> #define ALL(a) (a).begin(), (a).end() #define EACH(i, c) for (auto i = (c).begin(); i != (c).end(); ++i) #define EXIST(s, e) ((s).find(e) != (s).end()) #define SORT(c) sort((c).begin(), (c).end()) #define RSORT(c) sort((c).rbegin(), (c).rend()) #define MAXINDEX(c) distance((c).begin(), max_element((c).begin(), (c).end())) #define MININDEX(c) distance((c).begin(), min_element((c).begin(), (c).end())) #define DEBUG(x) std::cerr << #x << " = " << (x) << " (" << __FILE__ << "::" << __LINE__ << ")" << std::endl; #define ERROR(s) std::cerr << "Error::" << __FILE__ << "::" << __LINE__ << "::" << __FUNCTION__ << "::" << (s) << std::endl; #define FOR(i, a, b) for (auto i = (a); i < (b); i++) #define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--) #define repd(i, a, b) for (int i = (a); i < (b); i++) #define rep(i, n) repd(i, 0, n) typedef long long ll; int inputValue() { int a; // std::cin >> a; scanf("%d", &a); return a; } void inputArray(int *p, int a) { rep(i, a) { // std::cin >> p[i]; scanf("%d",p+i); } } void inputVector(std::vector<int> *p, int a) { rep(i, a) { int input; // std::cin >> input; scanf("%d", &input); p->push_back(input); } } template <typename T> void output(T a, int precision) { if (precision > 0) { std::cout << std::setprecision(precision) << a << "\n"; } else { std::cout << a << "\n"; } } using namespace std; int gcd(int a, int b) { while (1) { if (a < b) swap(a, b); if (!b) break; a %= b; } return a; } int main(int argc, char **argv) { int N = inputValue(); vector<int> v; inputVector(&v, N); int sum = 0; EACH(k, v) { sum += (*k-1); } cout << sum << endl; return 0; } //
[ "kwnafi@yahoo.com" ]
kwnafi@yahoo.com
0c212f1d989b5c5a05490e91ec8075d49f1646c8
aeae9a59fb57b672429c75693140ac9afb3e500e
/Gruppuppgift3/Pyramid.h
0fc25b3da2110b16576db844f5ccf668974cdfa7
[]
no_license
GameProject/Tower
8d31a1cb70c76f461222a07abfb67cb03d806da8
91501df975f3d3dd1dd252ed78b6206f8fff5e24
refs/heads/master
2021-01-21T02:30:54.781582
2011-05-11T02:00:23
2011-05-11T02:00:23
1,728,394
1
0
null
null
null
null
UTF-8
C++
false
false
532
h
#ifndef PYRAMID_H #define PYRAMID_H #include <d3dx10.h> #include <vector> #include "Vertex.h" class Pyramid { private: D3DXMATRIX mWorld; D3DXVECTOR3 pos; ID3D10Device* d3dDevice; ID3D10Buffer* vertexBuffer; ID3D10Buffer* indexBuffer; DWORD nrOfVertices; std::vector<Vertex> v; public: Pyramid(); ~Pyramid(); void init(ID3D10Device *device, D3DXVECTOR3 size, D3DXVECTOR3 pos); void move(D3DXVECTOR3 newPos); void Draw(); D3DXMATRIX& getWorld(); int GetVertexCount(); std::vector<Vertex> CopyVertexArray(); }; #endif
[ "ning09@.students.ad.bth.se" ]
ning09@.students.ad.bth.se
830900213b3f0761801e348f0056e3cd55a1e41e
474ca3fbc2b3513d92ed9531a9a99a2248ec7f63
/ThirdParty/boost_1_63_0/libs/config/test/has_tr1_result_of_fail.cpp
7e3c63147d7bedeffccbe80e6f7c1f5660c7872e
[ "BSL-1.0" ]
permissive
LazyPlanet/MX-Architecture
17b7b2e6c730409b22b7f38633e7b1f16359d250
732a867a5db3ba0c716752bffaeb675ebdc13a60
refs/heads/master
2020-12-30T15:41:18.664826
2018-03-02T00:59:12
2018-03-02T00:59:12
91,156,170
4
0
null
2018-02-04T03:29:46
2017-05-13T07:05:52
C++
UTF-8
C++
false
false
1,098
cpp
// This file was automatically generated on Sat Jul 12 12:39:32 2008 // by libs/config/tools/generate.cpp // Copyright John Maddock 2002-4. // Use, modification and distribution are subject to 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) // See http://www.boost.org/libs/config for the most recent version.// // Revision $Id$ // // Test file for macro BOOST_HAS_TR1_RESULT_OF // This file should not compile, if it does then // BOOST_HAS_TR1_RESULT_OF should be defined. // See file boost_has_tr1_result_of.ipp for details // Must not have BOOST_ASSERT_CONFIG set; it defeats // the objective of this file: #ifdef BOOST_ASSERT_CONFIG # undef BOOST_ASSERT_CONFIG #endif #include <boost/config.hpp> #include <boost/tr1/detail/config.hpp> #include "test.hpp" #ifndef BOOST_HAS_TR1_RESULT_OF #include "boost_has_tr1_result_of.ipp" #else #error "this file should not compile" #endif int main( int, char *[] ) { return boost_has_tr1_result_of::test(); }
[ "1211618464@qq.com" ]
1211618464@qq.com
b2794a5b3f3a25e30d9835d3dd5cf918d35076af
88eb1422ff4f56bd30be327a37fc83d97f167af7
/BabyMaker/BabyMaker/opencv2.framework/Versions/A/Headers/stitching/detail/blenders.hpp
49981081b9df1188ab8d837e8b68c17f74d1ee0f
[]
no_license
templeblock/BabyMaker_app
3e14a368ba6674fa0211768f153b5968e16e3b91
034f30d041d1954e348c4e7758f44540fd2ef580
refs/heads/master
2020-04-05T00:30:55.004859
2016-04-13T14:36:19
2016-04-13T14:36:19
null
0
0
null
null
null
null
UTF-8
C++
false
false
4,977
hpp
/*M/////////////////////////////////////////////////////////////////////////////////////// // // IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. // // By downloading, copying, installing or using the software you agree to this license. // If you do not agree to this license, do not download, install, // copy or use the software. // // // License Agreement // For Open Source Computer Vision Library // // Copyright (C) 2000-2008, Intel Corporation, all rights reserved. // Copyright (C) 2009, Willow Garage Inc., all rights reserved. // Third party copyrights are property of their respective owners. // // Redistribution and use in source and binary forms, with or without modification, // are permitted provided that the following conditions are met: // // * Redistribution's of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // // * Redistribution's 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. // // * The name of the copyright holders may not 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 Intel Corporation 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. // //M*/ #ifndef __OPENCV_STITCHING_BLENDERS_HPP__ #define __OPENCV_STITCHING_BLENDERS_HPP__ #include "opencv2/core/core.hpp" namespace cv { namespace detail { // Simple blender which puts one image over another class CV_EXPORTS Blender { public: virtual ~Blender() {} //enum { NO, FEATHER, MULTI_BAND }; static Ptr<Blender> createDefault(int type, bool try_gpu = false); void prepare(const std::vector<Point> &corners, const std::vector<Size> &sizes); virtual void prepare(Rect dst_roi); virtual void feed(const Mat &img, const Mat &mask, Point tl); virtual void blend(Mat &dst, Mat &dst_mask); protected: Mat dst_, dst_mask_; Rect dst_roi_; }; class CV_EXPORTS FeatherBlender : public Blender { public: FeatherBlender(float sharpness = 0.02f); float sharpness() const { return sharpness_; } void setSharpness(float val) { sharpness_ = val; } void prepare(Rect dst_roi); void feed(const Mat &img, const Mat &mask, Point tl); void blend(Mat &dst, Mat &dst_mask); // Creates weight maps for fixed set of source images by their masks and top-left corners. // Final image can be obtained by simple weighting of the source images. Rect createWeightMaps(const std::vector<Mat> &masks, const std::vector<Point> &corners, std::vector<Mat> &weight_maps); private: float sharpness_; Mat weight_map_; Mat dst_weight_map_; }; inline FeatherBlender::FeatherBlender(float _sharpness) { setSharpness(_sharpness); } class CV_EXPORTS MultiBandBlender : public Blender { public: MultiBandBlender(int try_gpu = false, int num_bands = 5, int weight_type = CV_32F); int numBands() const { return actual_num_bands_; } void setNumBands(int val) { actual_num_bands_ = val; } void prepare(Rect dst_roi); void feed(const Mat &img, const Mat &mask, Point tl); void blend(Mat &dst, Mat &dst_mask); private: int actual_num_bands_, num_bands_; std::vector<Mat> dst_pyr_laplace_; std::vector<Mat> dst_band_weights_; Rect dst_roi_final_; bool can_use_gpu_; int weight_type_; //CV_32F or CV_16S }; ////////////////////////////////////////////////////////////////////////////// // Auxiliary functions void CV_EXPORTS normalizeUsingWeightMap(const Mat& weight, Mat& src); void CV_EXPORTS createWeightMap(const Mat& mask, float sharpness, Mat& weight); void CV_EXPORTS createLaplacePyr(const Mat &img, int num_levels, std::vector<Mat>& pyr); void CV_EXPORTS createLaplacePyrGpu(const Mat &img, int num_levels, std::vector<Mat>& pyr); // Restores source image void CV_EXPORTS restoreImageFromLaplacePyr(std::vector<Mat>& pyr); void CV_EXPORTS restoreImageFromLaplacePyrGpu(std::vector<Mat>& pyr); } // namespace detail } // namespace cv #endif // __OPENCV_STITCHING_BLENDERS_HPP__
[ "Gritsenko1987514@hotmail.com" ]
Gritsenko1987514@hotmail.com
a48ba363d5bef39201cc55ae60508349fdff9653
b1a6d48e2f6444493f695739c842c5fd5a7ebe49
/src/ListaCircular.cpp
28e85e9eb7f21b391600acbf15aa4099ba8dcb20
[]
no_license
DanielSaturnino/ListaCircular
03b03077f53af17d0c0538a3436548edb18aa4c1
53e0005856eda4ec0f45cca81dec1c3a8c1fbda3
refs/heads/master
2020-04-09T08:34:49.670625
2016-09-12T02:07:32
2016-09-12T02:07:32
68,176,001
0
0
null
null
null
null
UTF-8
C++
false
false
7,445
cpp
/** Daniel Manzano Saturnino */ #include "ListaCircular.h" /* Constructor: @Parametros: void @Result: void Crea un nodo de con H y T apuntando a NULL */ ListaCircular::ListaCircular() { this->H=NULL; this->T=NULL; } /* Constructor @Parametros:int Dato @Result: void Crea un nodo que apunta a H y T apunta a H */ ListaCircular::ListaCircular(int Dato) { Nodo * aux= new Nodo(Dato); this->H=aux; this->T->setSig(this->H); } /* Lista Vacia @Parametros: void @Result: bool True o False Comprueba si la lista esta vacia revisando los apuntadores de H y T si apuntan a NULL devuelve un true de lo contrario un false */ bool ListaCircular::ListaVacia() { if (this->H == NULL && this->T == NULL) return true; return false; } /* AddInicio @Parametros: int Dato @Result: Void Este metodo crea un nodo auxiliar que apunta a H llama al metodo lista vacia si se encuentra vacia agrega el elemento y asigna a T el nodo creado este a su vez apunta a H de lo contrario H se le asigna el nuevo nodo */ void ListaCircular::AddInicio(int Dato) { Nodo* aux = new Nodo(Dato,this->H); if (ListaVacia()) { this->T= aux; T->setSig(this->H); } this->H= aux; } /* AddFinal @Parametros: int Dato @Result: void Crea un nuevo nodo con dato nuevo, verifica si la lista esta vacia si si lo esta a H y T se le asigna el nuevo nodo, de lo contrario a T apunta a l nuevo nodo y a T se le asigna el nodo que se ha creado y hace que apunte a H */ void ListaCircular::AddFinal(int Dato) { Nodo* aux=new Nodo (Dato); if(ListaVacia()) { this->H= aux; this->T= aux; T->setSig(this->H); }else{ this->T->setSig(aux); this->T= aux; T->setSig(this->H); } } /* AddRef @Parametros: int Dato, int Ref @Result: void Verifica si la lista esta vacia llamando al metodo lista Vacia si esto se cumple crea un dato con un dato a H se le asigna el nodo creado y finalmente T es igual a H e imprime una leyenda de lo contrario crea un nodo que apunta a H recorre la lista hasta que el nodo tenga el valor de la referencia y apunte a un valor diferente de T si se cumple lo anterior apuntara al siguiente valor hasta que llegue al elemento de referencia una vez llegado verifica si el nodo no apunta a null si esto se cumple crea un nodo con el valor de dato y que apunta al siguiente del nodo que se creo y que apuntaba a H y finalmente a el primer nodo creado se le asigna la referencia a la que apuntaba el segundo nodo creado si esto no se cumple arroja una leyenda */ void ListaCircular::AddRef(int Dato,int Ref) { if(ListaVacia()) { Nodo* aux=new Nodo(Dato); this->H=aux; this->T=this->H; std::cout<<"No se encontro la referencia por que la lista esta vacia"<<std::endl; return; } Nodo*aux=this->H; while(aux->getDato()!=Ref && aux!=NULL) { aux=aux->getSig(); } if(aux!=NULL) { Nodo* aux2=new Nodo(Dato,aux->getSig()); aux->setSig(aux2); }else { std::cout<<"NO EXISTE LA REFERENCIA EN LA LISTA"<<std::endl; } } /* Remove Lista @Parametros: void @Result: int Dato verifica que la lista este vacia con el metodo lista Vacia Si se cumple arroja una leyenda y regresamos un cero si no creamos una variablede tipo entero y le asignamos el valor de H despues H ahora apuntara al siguiente de H y preguntamos si H apunta NULL si apunta a NULL si apunta entonces T tambien apuntara a NULL si no solo retorna un dato */ int ListaCircular::RemoveInicio() { if(ListaVacia()) { std::cout<<"LA LISTA ESTA VACIA"<<std::endl; return 0; }else { int Dato=H->getDato(); this->H=H->getSig(); if(this->H==NULL) this->T=NULL; return Dato; } } /* RemoveFinal @Parametros: void @Result: int Dato Verifica si la lista esta vacia con el metodo Lista Vacia si esta vacia da una leyenda y retorna un cero si no crea un dato se le asigna el dato de T y pregunta si H es diferente de T si esto es correcto crea un nodo que apunta a H recorre la lista con un while hasta que apunte a T cuando llegue sale y a T se le asigna el nuevo nodo que apunta a H y el nodo nuevo es T ahora el T anterior apunta a un NULL, si no se cumplio lo anterior H y T apuntan a NuLL al final regresa un dato */ int ListaCircular::RemoveFinal() { if(ListaVacia()) { std::cout<<"LA LISTA ESTA VACIA"<<std::endl; return 0; } int Dato=T->getDato(); if(this->H!=this->T) { Nodo* aux=this->H; while(aux->getSig()!=this->T) { aux=aux->getSig(); } aux->setSig(this->H); this->T=aux; this->T->setSig(NULL); }else { this->H=NULL; this->T=NULL; } return Dato; } /* RemoveRef @Parametros:int Ref @Result: int Dato Verifica si la lista esta vacia con el metodo Lista Vacia si esta vacia retorna UN NuLL si no va crear dos nodos el primero se recorrera desde H hasta el dato dado por el usuario el segundo desde H hasta uno antes del primer nodo creado y preguntamos si el primer nodo creado no apunta NULL si se cumple al segundo creado se le asigna el siguiente del primer nodo perdiendo la referencia del primer nodo si apunta a NULL arroja una leyenda de que no se encontro nada retorna un Dato */ int ListaCircular::RemoveRef(int Ref) { if(ListaVacia()) { std::cout<<"LA LISTA ESTA VACIA"<<std::endl; return 0; }else { Nodo*aux=this->H; while(aux->getDato()!=Ref && aux!=this->T) { aux=aux->getSig(); } Nodo* aux2=this->H; while(aux2->getSig()!=aux) { aux2=aux2->getSig(); } if(aux!=NULL) { aux2->setSig(aux->getSig()); }else { std::cout<<"NO EXISTE LA REFERENCIA EN LA LISTA"<<std::endl; } return Ref; } } /* Lista Vacia @Parametros: void @Result: int Dato Verifica si la liasta esta vacia con el metodo Lista vacia si lo esta envia una leyenda y retorna un cero si no a H y T los apunta a NULL e imprime una leyenda retorna un cero */ int ListaCircular::VaciarLista() { if (ListaVacia()) { std::cout<<"La lista esta vacia"<<std::endl; return 0; }else{ this->H=NULL; this->T=NULL; std::cout<<"He vasiado la lista"<<std::endl; } return 0; } /* Buscar elemento @paramametros: int Ref @Result: Nodo* Verifica con el metodo lista vacia si la lista esta vacia si esta arroja una leyenda y devuelve un NULL de lo contrario crea un nodo y lo recorre hasta encontrar el dato y pregunta si el dato es igual al dato que esta en ese nodo entonces imprime una leyenda y el valor del nodo si no devuelve una leyenda en ambos casos regresa el nodo creado */ Nodo* ListaCircular::BuscarElemento(int Dato) { if (ListaVacia()) { std::cout<<"NO SE ENCOTRO ELEMENTOS PORQUE LA LISTA ESTA VACIA"<<std::endl; return NULL; }else { Nodo* aux=this->H; while(aux->getDato()!=Dato && aux!=this->T) { aux=aux->getSig(); } if(aux->getDato()==Dato) { std::cout<<"ELEMENTO ENCONTRADO:"<<std::endl; std::cout<<aux->getDato()<<std::endl; return aux; } std::cout<<"NO se encontro el elemento"<<std::endl; } } /* Show @parametros: void @Result: void Crea un nodo auxiliar que apunta a H y este nodo recorre la lista hasta llegar a T caba vez que cambia imprime el dato donde se encuentra */ void ListaCircular::Show() { Nodo* aux = this->H; while(aux!=T) { std::cout<<aux->getDato()<<std::endl; aux=aux->getSig(); } std::cout<<T->getDato()<<std::endl; }
[ "sktosaturmx€€@live.com.mx" ]
sktosaturmx€€@live.com.mx
5d497d7dc1985be3cfd701a4f39b3a596672e8aa
600c23efaf263d8053353157e03067cd940e8877
/android/My_slam_v3/app/src/main/cpp/cpprint.cpp
db153991417c5ffcddef010bce242a6798e0801b
[]
no_license
tony92151/Moblie_SLAM
c68352a41fa035cbfd5486bf915d32221219ac4e
40c9efe46e8accd6941777244fa7fe34f8c3f701
refs/heads/master
2020-06-14T14:32:01.856859
2019-08-31T10:55:10
2019-08-31T10:55:10
195,026,389
0
0
null
null
null
null
UTF-8
C++
false
false
423
cpp
#include <jni.h> #include <string> #include "cpprint.h" #include <vector> #include "stdio.h" #include "opencv2/core/core.hpp" //#include <opencv2/opencv.hpp> using namespace std; extern "C" JNIEXPORT jstring JNICALL Java_com_example_ctest_cpprint_sayhi( JNIEnv *env, jobject /* this */) { //cv::Mat img; std::string hello = "Hello from me"; return env->NewStringUTF(hello.c_str()); }
[ "tony92151@gmail.com" ]
tony92151@gmail.com
fe51833e14d287acc23c64384d750b890665d275
ce14a65381dee16422737c2b816169b7dc5d1a58
/Resources/GoogleTestFixtures/GoogleTest-no-fixtures/LibraryCode.hpp
18469e0abf3a7fa45f27846a7ed6911fd8bf592c
[]
no_license
fjpolo/UdemyCppUnitTestingGoogleTestAndGoogleMock
417348e997725edc745832fb5e177c784534525c
6405425dc1ea5977417063e3fdbbd4c1dec728c8
refs/heads/master
2023-03-11T05:31:17.990023
2021-03-03T08:00:14
2021-03-03T08:00:14
341,893,889
2
0
null
null
null
null
UTF-8
C++
false
false
218
hpp
#pragma once class Account { public: Account(); void deposit(double sum); void withdraw(double sum); double getBalance() const; void transfer(Account &to, double sum); private: double mBalance; };
[ "franco.polo@ii-vi.com" ]
franco.polo@ii-vi.com
55d8dc06deed10b30accac33b20ae740f6ea5193
a8bb9df3dd47350be0e82c6ec76fb1c19c86f323
/vhls/src/tenos/io_backdoor.h
dcc88043be61ce242b40ec6bd228f4123c19c7d4
[]
no_license
Appledee/fpga-matrix-mult
f4a42e1b54d33ce694a3cc79ab8b4f3cdbf1f67f
a28dc234c89db3912eb3d9c75904ea7a9592bfac
refs/heads/master
2023-03-18T19:14:10.850434
2017-04-24T17:05:23
2017-04-24T17:06:08
null
0
0
null
null
null
null
UTF-8
C++
false
false
716
h
// Copyright (C) 2016 XPARCH, Ltd. <info@xparch.com> #ifndef IO_BACKDOOR_H #define IO_BACKDOOR_H #include "tenos.h" #include "socdam_bdoor_mapping.h" /* FIXME: Maximum 256 can be open at any time */ #define MAX_FILES 256 class io_backdoor_setup { public: io_backdoor_setup(const char* image, u8_t psize, char e); /* opens file */ int open(const char* name, const char* mode); /* fills buffer */ int fill(int fid, char* buf, int max); /* close */ int close(int handle); /* flush */ int flush(int fid, char* buf); private: const char* image_name; u8_t pointer_size; int open_files; int curr_idx; FILE* files[MAX_FILES]; }; extern class io_backdoor_setup *io_backdoor_su; #endif
[ "cjw218@cl.cam.ac.uk" ]
cjw218@cl.cam.ac.uk
0611b5dc79ef941223560c2b0c0264b6c2330ad6
d01b295c6776fe7646799eed2963abee8dd4cda4
/experimental/gdal-3.0.1_extended/frmts/pdf/pdfcreatefromcomposition.cpp
73c8aa7ad785690932a930c77169f4827d2e3cd1
[ "Apache-2.0", "LicenseRef-scancode-public-domain", "BSD-2-Clause", "LicenseRef-scancode-warranty-disclaimer", "MIT", "SunPro", "LicenseRef-scancode-info-zip-2005-02", "BSD-3-Clause" ]
permissive
DevotionZhu/SUMOLibraries
1a56c224fdb0dceba8e7e8ae6afcea65b20e7553
0c8ca7149cd2b9194a9db0f595e471b8ce3b2189
refs/heads/master
2022-07-16T19:22:31.480232
2020-05-19T08:05:56
2020-05-19T08:07:01
null
0
0
null
null
null
null
UTF-8
C++
false
false
92,710
cpp
/****************************************************************************** * $Id: pdfcreatefromcomposition.cpp 5a04126b888092d810db40222dce30479b5ff901 2019-04-09 18:05:52 +0200 Even Rouault $ * * Project: PDF driver * Purpose: GDALDataset driver for PDF dataset. * Author: Even Rouault, <even dot rouault at spatialys dot com> * ****************************************************************************** * Copyright (c) 2019, Even Rouault <even dot rouault at spatialys dot com> * * 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 "gdal_pdf.h" #include "pdfcreatecopy.h" #include <cmath> #include <cstdlib> #include "pdfcreatefromcomposition.h" #include "cpl_conv.h" #include "cpl_minixml.h" #include "cpl_vsi_virtual.h" #include "ogr_geometry.h" /************************************************************************/ /* GDALPDFComposerWriter() */ /************************************************************************/ GDALPDFComposerWriter::GDALPDFComposerWriter(VSILFILE* fp): GDALPDFBaseWriter(fp) { StartNewDoc(); } /************************************************************************/ /* ~GDALPDFComposerWriter() */ /************************************************************************/ GDALPDFComposerWriter::~GDALPDFComposerWriter() { Close(); } /************************************************************************/ /* Close() */ /************************************************************************/ void GDALPDFComposerWriter::Close() { if (m_fp) { CPLAssert(!m_bInWriteObj); if (m_nPageResourceId.toBool()) { WritePages(); WriteXRefTableAndTrailer(false, 0); } } GDALPDFBaseWriter::Close(); } /************************************************************************/ /* CreateOCGOrder() */ /************************************************************************/ GDALPDFArrayRW* GDALPDFComposerWriter::CreateOCGOrder(const TreeOfOCG* parent) { auto poArrayOrder = new GDALPDFArrayRW(); for( const auto& child: parent->m_children ) { poArrayOrder->Add(child->m_nNum, 0); if( !child->m_children.empty() ) { poArrayOrder->Add(CreateOCGOrder(child.get())); } } return poArrayOrder; } /************************************************************************/ /* CollectOffOCG() */ /************************************************************************/ void GDALPDFComposerWriter::CollectOffOCG(std::vector<GDALPDFObjectNum>& ar, const TreeOfOCG* parent) { if( !parent->m_bInitiallyVisible ) ar.push_back(parent->m_nNum); for( const auto& child: parent->m_children ) { CollectOffOCG(ar, child.get()); } } /************************************************************************/ /* WritePages() */ /************************************************************************/ void GDALPDFComposerWriter::WritePages() { StartObj(m_nPageResourceId); { GDALPDFDictionaryRW oDict; GDALPDFArrayRW* poKids = new GDALPDFArrayRW(); oDict.Add("Type", GDALPDFObjectRW::CreateName("Pages")) .Add("Count", (int)m_asPageId.size()) .Add("Kids", poKids); for(size_t i=0;i<m_asPageId.size();i++) poKids->Add(m_asPageId[i], 0); VSIFPrintfL(m_fp, "%s\n", oDict.Serialize().c_str()); } EndObj(); if (m_nStructTreeRootId.toBool()) { auto nParentTreeId = AllocNewObject(); StartObj(nParentTreeId); VSIFPrintfL(m_fp, "<< /Nums [ "); for( size_t i = 0; i < m_anParentElements.size(); i++ ) { VSIFPrintfL(m_fp, "%d %d 0 R ", static_cast<int>(i), m_anParentElements[i].toInt()); } VSIFPrintfL(m_fp, " ] >> \n"); EndObj(); StartObj(m_nStructTreeRootId); VSIFPrintfL(m_fp, "<< " "/Type /StructTreeRoot " "/ParentTree %d 0 R " "/K [ ", nParentTreeId.toInt()); for( const auto& num: m_anFeatureLayerId ) { VSIFPrintfL(m_fp, "%d 0 R ", num.toInt()); } VSIFPrintfL(m_fp,"] >>\n"); EndObj(); } StartObj(m_nCatalogId); { GDALPDFDictionaryRW oDict; oDict.Add("Type", GDALPDFObjectRW::CreateName("Catalog")) .Add("Pages", m_nPageResourceId, 0); if (m_nOutlinesId.toBool()) oDict.Add("Outlines", m_nOutlinesId, 0); if (m_nXMPId.toBool()) oDict.Add("Metadata", m_nXMPId, 0); if (!m_asOCGs.empty() ) { GDALPDFDictionaryRW* poDictOCProperties = new GDALPDFDictionaryRW(); oDict.Add("OCProperties", poDictOCProperties); GDALPDFDictionaryRW* poDictD = new GDALPDFDictionaryRW(); poDictOCProperties->Add("D", poDictD); if( m_bDisplayLayersOnlyOnVisiblePages ) { poDictD->Add("ListMode", GDALPDFObjectRW::CreateName("VisiblePages")); } /* Build "Order" array of D dict */ GDALPDFArrayRW* poArrayOrder = CreateOCGOrder(&m_oTreeOfOGC); poDictD->Add("Order", poArrayOrder); /* Build "OFF" array of D dict */ std::vector<GDALPDFObjectNum> offOCGs; CollectOffOCG(offOCGs, &m_oTreeOfOGC); if( !offOCGs.empty() ) { GDALPDFArrayRW* poArrayOFF = new GDALPDFArrayRW(); for( const auto& num: offOCGs ) { poArrayOFF->Add(num, 0); } poDictD->Add("OFF", poArrayOFF); } /* Build "RBGroups" array of D dict */ if( !m_oMapExclusiveOCGIdToOCGs.empty() ) { GDALPDFArrayRW* poArrayRBGroups = new GDALPDFArrayRW(); for( const auto& group: m_oMapExclusiveOCGIdToOCGs ) { GDALPDFArrayRW* poGroup = new GDALPDFArrayRW(); for( const auto& num: group.second ) { poGroup->Add(num, 0); } poArrayRBGroups->Add(poGroup); } poDictD->Add("RBGroups", poArrayRBGroups); } GDALPDFArrayRW* poArrayOGCs = new GDALPDFArrayRW(); for(const auto& ocg: m_asOCGs ) poArrayOGCs->Add(ocg.nId, 0); poDictOCProperties->Add("OCGs", poArrayOGCs); } if (m_nStructTreeRootId.toBool()) { GDALPDFDictionaryRW* poDictMarkInfo = new GDALPDFDictionaryRW(); oDict.Add("MarkInfo", poDictMarkInfo); poDictMarkInfo->Add("UserProperties", GDALPDFObjectRW::CreateBool(TRUE)); oDict.Add("StructTreeRoot", m_nStructTreeRootId, 0); } if (m_nNamesId.toBool()) oDict.Add("Names", m_nNamesId, 0); VSIFPrintfL(m_fp, "%s\n", oDict.Serialize().c_str()); } EndObj(); } /************************************************************************/ /* CreateLayerTree() */ /************************************************************************/ bool GDALPDFComposerWriter::CreateLayerTree(const CPLXMLNode* psNode, const GDALPDFObjectNum& nParentId, TreeOfOCG* parent) { for(const auto* psIter = psNode->psChild; psIter; psIter = psIter->psNext) { if( psIter->eType == CXT_Element && strcmp(psIter->pszValue, "Layer") == 0 ) { const char* pszId = CPLGetXMLValue(psIter, "id", nullptr); if( !pszId ) { CPLError(CE_Failure, CPLE_AppDefined, "Missing id attribute in Layer"); return false; } const char* pszName = CPLGetXMLValue(psIter, "name", nullptr); if( !pszName ) { CPLError(CE_Failure, CPLE_AppDefined, "Missing name attribute in Layer"); return false; } if( m_oMapLayerIdToOCG.find(pszId) != m_oMapLayerIdToOCG.end() ) { CPLError(CE_Failure, CPLE_AppDefined, "Layer.id = %s is not unique", pszId); return false; } const bool bInitiallyVisible = CPLTestBool( CPLGetXMLValue(psIter, "initiallyVisible", "true")); const char* pszMutuallyExclusiveGroupId = CPLGetXMLValue(psIter, "mutuallyExclusiveGroupId", nullptr); auto nThisObjId = WriteOCG( pszName, nParentId ); m_oMapLayerIdToOCG[pszId] = nThisObjId; std::unique_ptr<TreeOfOCG> newTreeOfOCG(new TreeOfOCG()); newTreeOfOCG->m_nNum = nThisObjId; newTreeOfOCG->m_bInitiallyVisible = bInitiallyVisible; parent->m_children.emplace_back(std::move(newTreeOfOCG)); if( pszMutuallyExclusiveGroupId ) { m_oMapExclusiveOCGIdToOCGs[pszMutuallyExclusiveGroupId]. push_back(nThisObjId); } if( !CreateLayerTree(psIter, nThisObjId, parent->m_children.back().get()) ) { return false; } } } return true; } /************************************************************************/ /* ParseActions() */ /************************************************************************/ bool GDALPDFComposerWriter::ParseActions(const CPLXMLNode* psNode, std::vector<std::unique_ptr<Action>>& actions) { std::set<GDALPDFObjectNum> anONLayers{}; std::set<GDALPDFObjectNum> anOFFLayers{}; for(const auto* psIter = psNode->psChild; psIter; psIter = psIter->psNext) { if( psIter->eType == CXT_Element && strcmp(psIter->pszValue, "GotoPageAction") == 0 ) { std::unique_ptr<GotoPageAction> poAction(new GotoPageAction()); const char* pszPageId = CPLGetXMLValue(psIter, "pageId", nullptr); if( !pszPageId ) { CPLError(CE_Failure, CPLE_AppDefined, "Missing pageId attribute in GotoPageAction"); return false; } auto oIter = m_oMapPageIdToObjectNum.find(pszPageId); if( oIter == m_oMapPageIdToObjectNum.end() ) { CPLError(CE_Failure, CPLE_AppDefined, "GotoPageAction.pageId = %s not pointing to a Page.id", pszPageId); return false; } poAction->m_nPageDestId = oIter->second; poAction->m_dfX1 = CPLAtof(CPLGetXMLValue(psIter, "x1", "0")); poAction->m_dfX2 = CPLAtof(CPLGetXMLValue(psIter, "y1", "0")); poAction->m_dfY1 = CPLAtof(CPLGetXMLValue(psIter, "x2", "0")); poAction->m_dfY2 = CPLAtof(CPLGetXMLValue(psIter, "y2", "0")); actions.push_back(std::move(poAction)); } else if( psIter->eType == CXT_Element && strcmp(psIter->pszValue, "SetAllLayersStateAction") == 0 ) { if( CPLTestBool(CPLGetXMLValue(psIter, "visible", "true")) ) { for( const auto& ocg: m_asOCGs ) { anOFFLayers.erase(ocg.nId); anONLayers.insert(ocg.nId); } } else { for( const auto& ocg: m_asOCGs ) { anONLayers.erase(ocg.nId); anOFFLayers.insert(ocg.nId); } } } else if( psIter->eType == CXT_Element && strcmp(psIter->pszValue, "SetLayerStateAction") == 0 ) { const char* pszLayerId = CPLGetXMLValue(psIter, "layerId", nullptr); if( !pszLayerId ) { CPLError(CE_Failure, CPLE_AppDefined, "Missing layerId"); return false; } auto oIter = m_oMapLayerIdToOCG.find(pszLayerId); if( oIter == m_oMapLayerIdToOCG.end() ) { CPLError(CE_Failure, CPLE_AppDefined, "Referencing layer of unknown id: %s", pszLayerId); return false; } const auto& ocg = oIter->second; if( CPLTestBool(CPLGetXMLValue(psIter, "visible", "true")) ) { anOFFLayers.erase(ocg); anONLayers.insert(ocg); } else { anONLayers.erase(ocg); anOFFLayers.insert(ocg); } } else if( psIter->eType == CXT_Element && strcmp(psIter->pszValue, "JavascriptAction") == 0 ) { std::unique_ptr<JavascriptAction> poAction(new JavascriptAction()); poAction->m_osScript = CPLGetXMLValue(psIter, nullptr, ""); actions.push_back(std::move(poAction)); } } if( !anONLayers.empty() || !anOFFLayers.empty() ) { std::unique_ptr<SetLayerStateAction> poAction(new SetLayerStateAction()); poAction->m_anONLayers = std::move(anONLayers); poAction->m_anOFFLayers = std::move(anOFFLayers); actions.push_back(std::move(poAction)); } return true; } /************************************************************************/ /* CreateOutlineFirstPass() */ /************************************************************************/ bool GDALPDFComposerWriter::CreateOutlineFirstPass(const CPLXMLNode* psNode, OutlineItem* poParentItem) { for(const auto* psIter = psNode->psChild; psIter; psIter = psIter->psNext) { if( psIter->eType == CXT_Element && strcmp(psIter->pszValue, "OutlineItem") == 0 ) { std::unique_ptr<OutlineItem> newItem(new OutlineItem()); const char* pszName = CPLGetXMLValue(psIter, "name", nullptr); if( !pszName ) { CPLError(CE_Failure, CPLE_AppDefined, "Missing name attribute in OutlineItem"); return false; } newItem->m_osName = pszName; newItem->m_bOpen = CPLTestBool(CPLGetXMLValue(psIter, "open", "true")); if( CPLTestBool(CPLGetXMLValue(psIter, "italic", "false")) ) newItem->m_nFlags |= 1 << 0; if( CPLTestBool(CPLGetXMLValue(psIter, "bold", "false")) ) newItem->m_nFlags |= 1 << 1; const auto poActions = CPLGetXMLNode(psIter, "Actions"); if( poActions ) { if( !ParseActions(poActions, newItem->m_aoActions) ) return false; } newItem->m_nObjId = AllocNewObject(); if( !CreateOutlineFirstPass(psIter, newItem.get()) ) { return false; } poParentItem->m_nKidsRecCount += 1 + newItem->m_nKidsRecCount; poParentItem->m_aoKids.push_back(std::move(newItem)); } } return true; } /************************************************************************/ /* SerializeActions() */ /************************************************************************/ GDALPDFDictionaryRW* GDALPDFComposerWriter::SerializeActions( GDALPDFDictionaryRW* poDictForDest, const std::vector<std::unique_ptr<Action>>& actions) { GDALPDFDictionaryRW* poRetAction = nullptr; GDALPDFDictionaryRW* poLastActionDict = nullptr; for( const auto& poAction: actions ) { GDALPDFDictionaryRW* poActionDict = nullptr; auto poGotoPageAction = dynamic_cast<GotoPageAction*>(poAction.get()); if( poGotoPageAction ) { GDALPDFArrayRW* poDest = new GDALPDFArrayRW; poDest->Add(poGotoPageAction->m_nPageDestId, 0); if( poGotoPageAction->m_dfX1 == 0.0 && poGotoPageAction->m_dfX2 == 0.0 && poGotoPageAction->m_dfY1 == 0.0 && poGotoPageAction->m_dfY2 == 0.0 ) { poDest->Add(GDALPDFObjectRW::CreateName("XYZ")) .Add(GDALPDFObjectRW::CreateNull()) .Add(GDALPDFObjectRW::CreateNull()) .Add(GDALPDFObjectRW::CreateNull()); } else { poDest->Add(GDALPDFObjectRW::CreateName("FitR")) .Add(poGotoPageAction->m_dfX1) .Add(poGotoPageAction->m_dfY1) .Add(poGotoPageAction->m_dfX2) .Add(poGotoPageAction->m_dfY2); } if( poDictForDest && actions.size() == 1 ) { poDictForDest->Add("Dest", poDest); } else { poActionDict = new GDALPDFDictionaryRW(); poActionDict->Add("Type", GDALPDFObjectRW::CreateName("Action")); poActionDict->Add("S", GDALPDFObjectRW::CreateName("GoTo")); poActionDict->Add("D", poDest); } } auto setLayerStateAction = dynamic_cast<SetLayerStateAction*>(poAction.get()); if( setLayerStateAction ) { poActionDict = new GDALPDFDictionaryRW(); poActionDict->Add("Type", GDALPDFObjectRW::CreateName("Action")); poActionDict->Add("S", GDALPDFObjectRW::CreateName("SetOCGState")); auto poStateArray = new GDALPDFArrayRW(); if( !setLayerStateAction->m_anOFFLayers.empty() ) { poStateArray->Add(GDALPDFObjectRW::CreateName("OFF")); for( const auto& ocg: setLayerStateAction->m_anOFFLayers ) poStateArray->Add(ocg, 0); } if( !setLayerStateAction->m_anONLayers.empty() ) { poStateArray->Add(GDALPDFObjectRW::CreateName("ON")); for( const auto& ocg: setLayerStateAction->m_anONLayers ) poStateArray->Add(ocg, 0); } poActionDict->Add("State", poStateArray); } auto javascriptAction = dynamic_cast<JavascriptAction*>(poAction.get()); if( javascriptAction ) { poActionDict = new GDALPDFDictionaryRW(); poActionDict->Add("Type", GDALPDFObjectRW::CreateName("Action")); poActionDict->Add("S", GDALPDFObjectRW::CreateName("JavaScript")); poActionDict->Add("JS", javascriptAction->m_osScript); } if( poActionDict ) { if( poLastActionDict == nullptr ) { poRetAction = poActionDict; } else { poLastActionDict->Add("Next", poActionDict); } poLastActionDict = poActionDict; } } return poRetAction; } /************************************************************************/ /* SerializeOutlineKids() */ /************************************************************************/ bool GDALPDFComposerWriter::SerializeOutlineKids(const OutlineItem* poParentItem) { for( size_t i = 0; i < poParentItem->m_aoKids.size(); i++ ) { const auto& poItem = poParentItem->m_aoKids[i]; StartObj(poItem->m_nObjId); GDALPDFDictionaryRW oDict; oDict.Add("Title", poItem->m_osName); auto poActionDict = SerializeActions(&oDict, poItem->m_aoActions); if( poActionDict ) { oDict.Add("A", poActionDict); } if( i > 0 ) { oDict.Add("Prev", poParentItem->m_aoKids[i-1]->m_nObjId, 0); } if( i + 1 < poParentItem->m_aoKids.size() ) { oDict.Add("Next", poParentItem->m_aoKids[i+1]->m_nObjId, 0); } if( poItem->m_nFlags ) oDict.Add("F", poItem->m_nFlags); oDict.Add("Parent", poParentItem->m_nObjId, 0); if( !poItem->m_aoKids.empty() ) { oDict.Add("First", poItem->m_aoKids.front()->m_nObjId, 0); oDict.Add("Last", poItem->m_aoKids.back()->m_nObjId, 0); oDict.Add("Count", poItem->m_bOpen ? poItem->m_nKidsRecCount : -poItem->m_nKidsRecCount); } VSIFPrintfL(m_fp, "%s\n", oDict.Serialize().c_str()); EndObj(); SerializeOutlineKids(poItem.get()); } return true; } /************************************************************************/ /* CreateOutline() */ /************************************************************************/ bool GDALPDFComposerWriter::CreateOutline(const CPLXMLNode* psNode) { OutlineItem oRootOutlineItem; if( !CreateOutlineFirstPass(psNode, &oRootOutlineItem) ) return false; if( oRootOutlineItem.m_aoKids.empty() ) return true; m_nOutlinesId = AllocNewObject(); StartObj(m_nOutlinesId); GDALPDFDictionaryRW oDict; oDict.Add("Type", GDALPDFObjectRW::CreateName("Outlines")) .Add("First", oRootOutlineItem.m_aoKids.front()->m_nObjId, 0) .Add("Last", oRootOutlineItem.m_aoKids.back()->m_nObjId, 0) .Add("Count", oRootOutlineItem.m_nKidsRecCount); VSIFPrintfL(m_fp, "%s\n", oDict.Serialize().c_str()); EndObj(); oRootOutlineItem.m_nObjId = m_nOutlinesId; return SerializeOutlineKids(&oRootOutlineItem); } /************************************************************************/ /* GenerateGeoreferencing() */ /************************************************************************/ bool GDALPDFComposerWriter::GenerateGeoreferencing(const CPLXMLNode* psGeoreferencing, double dfWidthInUserUnit, double dfHeightInUserUnit, GDALPDFObjectNum& nViewportId, GDALPDFObjectNum& nLGIDictId, Georeferencing& georeferencing) { double bboxX1 = 0; double bboxY1 = 0; double bboxX2 = dfWidthInUserUnit; double bboxY2 = dfHeightInUserUnit; const auto psBoundingBox = CPLGetXMLNode(psGeoreferencing, "BoundingBox"); if( psBoundingBox ) { bboxX1 = CPLAtof( CPLGetXMLValue(psBoundingBox, "x1", CPLSPrintf("%.18g", bboxX1))); bboxY1 = CPLAtof( CPLGetXMLValue(psBoundingBox, "y1", CPLSPrintf("%.18g", bboxY1))); bboxX2 = CPLAtof( CPLGetXMLValue(psBoundingBox, "x2", CPLSPrintf("%.18g", bboxX2))); bboxY2 = CPLAtof( CPLGetXMLValue(psBoundingBox, "y2", CPLSPrintf("%.18g", bboxY2))); if( bboxX2 <= bboxX1 || bboxY2 <= bboxY1 ) { CPLError(CE_Failure, CPLE_AppDefined, "Invalid BoundingBox"); return false; } } std::vector<GDAL_GCP> aGCPs; for(const auto* psIter = psGeoreferencing->psChild; psIter; psIter = psIter->psNext) { if( psIter->eType == CXT_Element && strcmp(psIter->pszValue, "ControlPoint") == 0 ) { const char* pszx = CPLGetXMLValue(psIter, "x", nullptr); const char* pszy = CPLGetXMLValue(psIter, "y", nullptr); const char* pszX = CPLGetXMLValue(psIter, "GeoX", nullptr); const char* pszY = CPLGetXMLValue(psIter, "GeoY", nullptr); if( !pszx || !pszy || !pszX || !pszY ) { CPLError(CE_Failure, CPLE_NotSupported, "At least one of x, y, GeoX or GeoY attribute " "missing on ControlPoint"); return false; } GDAL_GCP gcp; gcp.pszId = nullptr; gcp.pszInfo = nullptr; gcp.dfGCPPixel = CPLAtof(pszx); gcp.dfGCPLine = CPLAtof(pszy); gcp.dfGCPX = CPLAtof(pszX); gcp.dfGCPY = CPLAtof(pszY); gcp.dfGCPZ = 0; aGCPs.emplace_back(std::move(gcp)); } } if( aGCPs.size() < 4 ) { CPLError(CE_Failure, CPLE_NotSupported, "At least 4 ControlPoint are required"); return false; } const char* pszBoundingPolygon = CPLGetXMLValue(psGeoreferencing, "BoundingPolygon", nullptr); std::vector<xyPair> aBoundingPolygon; if( pszBoundingPolygon ) { OGRGeometry* poGeom = nullptr; OGRGeometryFactory::createFromWkt(pszBoundingPolygon, nullptr, &poGeom); if( poGeom && poGeom->getGeometryType() == wkbPolygon ) { auto poPoly = poGeom->toPolygon(); auto poRing = poPoly->getExteriorRing(); if( poRing ) { if( psBoundingBox == nullptr ) { OGREnvelope sEnvelope; poRing->getEnvelope(&sEnvelope); bboxX1 = sEnvelope.MinX; bboxY1 = sEnvelope.MinY; bboxX2 = sEnvelope.MaxX; bboxY2 = sEnvelope.MaxY; } for( int i = 0; i < poRing->getNumPoints(); i++ ) { aBoundingPolygon.emplace_back( xyPair(poRing->getX(i), poRing->getY(i))); } } } delete poGeom; } const auto pszSRS = CPLGetXMLValue(psGeoreferencing, "SRS", nullptr); if( !pszSRS ) { CPLError(CE_Failure, CPLE_NotSupported, "Missing SRS"); return false; } std::unique_ptr<OGRSpatialReference> poSRS(new OGRSpatialReference()); if( poSRS->SetFromUserInput(pszSRS) != OGRERR_NONE ) { return false; } poSRS->SetAxisMappingStrategy(OAMS_TRADITIONAL_GIS_ORDER); if( CPLTestBool(CPLGetXMLValue(psGeoreferencing, "ISO32000ExtensionFormat", "true")) ) { nViewportId = GenerateISO32000_Georeferencing( OGRSpatialReference::ToHandle(poSRS.get()), bboxX1, bboxY1, bboxX2, bboxY2, aGCPs, aBoundingPolygon); if( !nViewportId.toBool() ) { return false; } } if( CPLTestBool(CPLGetXMLValue(psGeoreferencing, "OGCBestPracticeFormat", "false")) ) { nLGIDictId = GenerateOGC_BP_Georeferencing( OGRSpatialReference::ToHandle(poSRS.get()), bboxX1, bboxY1, bboxX2, bboxY2, aGCPs, aBoundingPolygon); if( !nLGIDictId.toBool() ) { return false; } } const char* pszId = CPLGetXMLValue(psGeoreferencing, "id", nullptr); if( pszId ) { if (!GDALGCPsToGeoTransform( static_cast<int>(aGCPs.size()), aGCPs.data(), georeferencing.m_adfGT, TRUE)) { CPLError(CE_Failure, CPLE_AppDefined, "Could not compute geotransform with approximate match."); return false; } if( std::fabs(georeferencing.m_adfGT[2]) < 1e-5 * std::fabs(georeferencing.m_adfGT[1]) && std::fabs(georeferencing.m_adfGT[4]) < 1e-5 * std::fabs(georeferencing.m_adfGT[5]) ) { georeferencing.m_adfGT[2] = 0; georeferencing.m_adfGT[4] = 0; } if( georeferencing.m_adfGT[2] != 0 || georeferencing.m_adfGT[4] != 0 || georeferencing.m_adfGT[5] < 0 ) { CPLError(CE_Failure, CPLE_AppDefined, "Geotransform should define a north-up non rotated area."); return false; } georeferencing.m_osID = pszId; georeferencing.m_oSRS = *(poSRS.get()); georeferencing.m_bboxX1 = bboxX1; georeferencing.m_bboxY1 = bboxY1; georeferencing.m_bboxX2 = bboxX2; georeferencing.m_bboxY2 = bboxY2; } return true; } /************************************************************************/ /* GenerateISO32000_Georeferencing() */ /************************************************************************/ GDALPDFObjectNum GDALPDFComposerWriter::GenerateISO32000_Georeferencing( OGRSpatialReferenceH hSRS, double bboxX1, double bboxY1, double bboxX2, double bboxY2, const std::vector<GDAL_GCP>& aGCPs, const std::vector<xyPair>& aBoundingPolygon) { OGRSpatialReferenceH hSRSGeog = OSRCloneGeogCS(hSRS); if( hSRSGeog == nullptr ) { return GDALPDFObjectNum(); } OSRSetAxisMappingStrategy(hSRSGeog, OAMS_TRADITIONAL_GIS_ORDER); OGRCoordinateTransformationH hCT = OCTNewCoordinateTransformation( hSRS, hSRSGeog); if( hCT == nullptr ) { OSRDestroySpatialReference(hSRSGeog); return GDALPDFObjectNum(); } std::vector<GDAL_GCP> aGCPReprojected; bool bSuccess = true; for( const auto& gcp: aGCPs ) { double X = gcp.dfGCPX; double Y = gcp.dfGCPY; bSuccess &= OCTTransform( hCT, 1,&X, &Y, nullptr ) == 1; GDAL_GCP newGCP; newGCP.pszId = nullptr; newGCP.pszInfo = nullptr; newGCP.dfGCPPixel = gcp.dfGCPPixel; newGCP.dfGCPLine = gcp.dfGCPLine; newGCP.dfGCPX = X; newGCP.dfGCPY = Y; newGCP.dfGCPZ = 0; aGCPReprojected.emplace_back(std::move(newGCP)); } if( !bSuccess ) { OSRDestroySpatialReference(hSRSGeog); OCTDestroyCoordinateTransformation(hCT); return GDALPDFObjectNum(); } const char * pszAuthorityCode = OSRGetAuthorityCode( hSRS, nullptr ); const char * pszAuthorityName = OSRGetAuthorityName( hSRS, nullptr ); int nEPSGCode = 0; if( pszAuthorityName != nullptr && EQUAL(pszAuthorityName, "EPSG") && pszAuthorityCode != nullptr ) nEPSGCode = atoi(pszAuthorityCode); int bIsGeographic = OSRIsGeographic(hSRS); char* pszESRIWKT = nullptr; const char* apszOptions[] = { "FORMAT=WKT1_ESRI", nullptr }; OSRExportToWktEx(hSRS, &pszESRIWKT, apszOptions); OSRDestroySpatialReference(hSRSGeog); OCTDestroyCoordinateTransformation(hCT); auto nViewportId = AllocNewObject(); auto nMeasureId = AllocNewObject(); auto nGCSId = AllocNewObject(); StartObj(nViewportId); GDALPDFDictionaryRW oViewPortDict; oViewPortDict.Add("Type", GDALPDFObjectRW::CreateName("Viewport")) .Add("Name", "Layer") .Add("BBox", &((new GDALPDFArrayRW()) ->Add(bboxX1).Add(bboxY1) .Add(bboxX2).Add(bboxY2))) .Add("Measure", nMeasureId, 0); VSIFPrintfL(m_fp, "%s\n", oViewPortDict.Serialize().c_str()); EndObj(); GDALPDFArrayRW* poGPTS = new GDALPDFArrayRW(); GDALPDFArrayRW* poLPTS = new GDALPDFArrayRW(); const int nPrecision = atoi(CPLGetConfigOption("PDF_COORD_DOUBLE_PRECISION", "16")); for( const auto& gcp: aGCPReprojected ) { poGPTS->AddWithPrecision(gcp.dfGCPY, nPrecision). AddWithPrecision(gcp.dfGCPX, nPrecision); // Lat, long order poLPTS->AddWithPrecision((gcp.dfGCPPixel - bboxX1) / (bboxX2 - bboxX1), nPrecision). AddWithPrecision((gcp.dfGCPLine - bboxY1) / (bboxY2 - bboxY1), nPrecision); } StartObj(nMeasureId); GDALPDFDictionaryRW oMeasureDict; oMeasureDict .Add("Type", GDALPDFObjectRW::CreateName("Measure")) .Add("Subtype", GDALPDFObjectRW::CreateName("GEO")) .Add("GPTS", poGPTS) .Add("LPTS", poLPTS) .Add("GCS", nGCSId, 0); if( !aBoundingPolygon.empty() ) { GDALPDFArrayRW* poBounds = new GDALPDFArrayRW(); for( const auto& xy: aBoundingPolygon ) { poBounds->Add((xy.x - bboxX1) / (bboxX2 - bboxX1)). Add((xy.y - bboxY1) / (bboxY2 - bboxY1)); } oMeasureDict.Add("Bounds", poBounds); } VSIFPrintfL(m_fp, "%s\n", oMeasureDict.Serialize().c_str()); EndObj(); StartObj(nGCSId); GDALPDFDictionaryRW oGCSDict; oGCSDict.Add("Type", GDALPDFObjectRW::CreateName(bIsGeographic ? "GEOGCS" : "PROJCS")) .Add("WKT", pszESRIWKT); if (nEPSGCode) oGCSDict.Add("EPSG", nEPSGCode); VSIFPrintfL(m_fp, "%s\n", oGCSDict.Serialize().c_str()); EndObj(); CPLFree(pszESRIWKT); return nViewportId; } /************************************************************************/ /* GenerateOGC_BP_Georeferencing() */ /************************************************************************/ GDALPDFObjectNum GDALPDFComposerWriter::GenerateOGC_BP_Georeferencing( OGRSpatialReferenceH hSRS, double bboxX1, double bboxY1, double bboxX2, double bboxY2, const std::vector<GDAL_GCP>& aGCPs, const std::vector<xyPair>& aBoundingPolygon) { const OGRSpatialReference* poSRS = OGRSpatialReference::FromHandle(hSRS); GDALPDFDictionaryRW* poProjectionDict = GDALPDFBuildOGC_BP_Projection(poSRS); if (poProjectionDict == nullptr) { OSRDestroySpatialReference(hSRS); return GDALPDFObjectNum(); } GDALPDFArrayRW* poNeatLineArray = new GDALPDFArrayRW(); if( !aBoundingPolygon.empty() ) { for( const auto& xy: aBoundingPolygon ) { poNeatLineArray->Add(xy.x).Add(xy.y); } } else { poNeatLineArray->Add(bboxX1).Add(bboxY1). Add(bboxX2).Add(bboxY2); } GDALPDFArrayRW* poRegistration = new GDALPDFArrayRW(); for( const auto& gcp: aGCPs ) { GDALPDFArrayRW* poGCP = new GDALPDFArrayRW(); poGCP->Add(gcp.dfGCPPixel, TRUE).Add(gcp.dfGCPLine, TRUE). Add(gcp.dfGCPX, TRUE).Add(gcp.dfGCPY, TRUE); poRegistration->Add(poGCP); } auto nLGIDictId = AllocNewObject(); StartObj(nLGIDictId); GDALPDFDictionaryRW oLGIDict; oLGIDict.Add("Type", GDALPDFObjectRW::CreateName("LGIDict")) .Add("Version", "2.1") .Add("Neatline", poNeatLineArray); oLGIDict.Add("Registration", poRegistration); /* GDAL extension */ if( CPLTestBool( CPLGetConfigOption("GDAL_PDF_OGC_BP_WRITE_WKT", "TRUE") ) ) { char* pszWKT = nullptr; OSRExportToWkt(hSRS, &pszWKT); if( pszWKT ) poProjectionDict->Add("WKT", pszWKT); CPLFree(pszWKT); } oLGIDict.Add("Projection", poProjectionDict); VSIFPrintfL(m_fp, "%s\n", oLGIDict.Serialize().c_str()); EndObj(); return nLGIDictId; } /************************************************************************/ /* GeneratePage() */ /************************************************************************/ bool GDALPDFComposerWriter::GeneratePage(const CPLXMLNode* psPage) { double dfWidthInUserUnit = CPLAtof(CPLGetXMLValue(psPage, "Width", "-1")); double dfHeightInUserUnit = CPLAtof(CPLGetXMLValue(psPage, "Height", "-1")); if( dfWidthInUserUnit <= 0 || dfWidthInUserUnit >= MAXIMUM_SIZE_IN_UNITS || dfHeightInUserUnit <= 0 || dfHeightInUserUnit >= MAXIMUM_SIZE_IN_UNITS ) { CPLError(CE_Failure, CPLE_AppDefined, "Missing or invalid Width and/or Height"); return false; } double dfUserUnit = CPLAtof(CPLGetXMLValue(psPage, "DPI", CPLSPrintf("%f", DEFAULT_DPI))) * USER_UNIT_IN_INCH; std::vector<GDALPDFObjectNum> anViewportIds; std::vector<GDALPDFObjectNum> anLGIDictIds; PageContext oPageContext; for(const auto* psIter = psPage->psChild; psIter; psIter = psIter->psNext) { if( psIter->eType == CXT_Element && strcmp(psIter->pszValue, "Georeferencing") == 0 ) { GDALPDFObjectNum nViewportId; GDALPDFObjectNum nLGIDictId; Georeferencing georeferencing; if( !GenerateGeoreferencing(psIter, dfWidthInUserUnit, dfHeightInUserUnit, nViewportId, nLGIDictId, georeferencing) ) { return false; } if( nViewportId.toBool() ) anViewportIds.emplace_back(nViewportId); if( nLGIDictId.toBool() ) anLGIDictIds.emplace_back(nLGIDictId); if( !georeferencing.m_osID.empty() ) { oPageContext.m_oMapGeoreferencedId[georeferencing.m_osID] = georeferencing; } } } auto nPageId = AllocNewObject(); m_asPageId.push_back(nPageId); const char* pszId = CPLGetXMLValue(psPage, "id", nullptr); if( pszId ) { if( m_oMapPageIdToObjectNum.find(pszId) != m_oMapPageIdToObjectNum.end() ) { CPLError(CE_Failure, CPLE_AppDefined, "Duplicated page id %s", pszId); return false; } m_oMapPageIdToObjectNum[pszId] = nPageId; } const auto psContent = CPLGetXMLNode(psPage, "Content"); if( !psContent ) { CPLError(CE_Failure, CPLE_AppDefined, "Missing Content"); return false; } const bool bDeflateStreamCompression = EQUAL( CPLGetXMLValue(psContent, "streamCompression", "DEFLATE"), "DEFLATE"); oPageContext.m_dfWidthInUserUnit = dfWidthInUserUnit; oPageContext.m_dfHeightInUserUnit = dfHeightInUserUnit; oPageContext.m_eStreamCompressMethod = bDeflateStreamCompression ? COMPRESS_DEFLATE : COMPRESS_NONE; if( !ExploreContent(psContent, oPageContext) ) return false; int nStructParentsIdx = -1; if( !oPageContext.m_anFeatureUserProperties.empty() ) { nStructParentsIdx = static_cast<int>(m_anParentElements.size()); auto nParentsElements = AllocNewObject(); m_anParentElements.push_back(nParentsElements); { StartObj(nParentsElements); VSIFPrintfL(m_fp, "[ "); for( const auto& num: oPageContext.m_anFeatureUserProperties ) VSIFPrintfL(m_fp, "%d 0 R ", num.toInt()); VSIFPrintfL(m_fp, " ]\n"); EndObj(); } } GDALPDFObjectNum nAnnotsId; if( !oPageContext.m_anAnnotationsId.empty() ) { /* -------------------------------------------------------------- */ /* Write annotation arrays. */ /* -------------------------------------------------------------- */ nAnnotsId = AllocNewObject(); StartObj(nAnnotsId); { GDALPDFArrayRW oArray; for(size_t i = 0; i < oPageContext.m_anAnnotationsId.size(); i++) { oArray.Add(oPageContext.m_anAnnotationsId[i], 0); } VSIFPrintfL(m_fp, "%s\n", oArray.Serialize().c_str()); } EndObj(); } auto nContentId = AllocNewObject(); auto nResourcesId = AllocNewObject(); StartObj(nPageId); GDALPDFDictionaryRW oDictPage; oDictPage.Add("Type", GDALPDFObjectRW::CreateName("Page")) .Add("Parent", m_nPageResourceId, 0) .Add("MediaBox", &((new GDALPDFArrayRW()) ->Add(0).Add(0). Add(dfWidthInUserUnit). Add(dfHeightInUserUnit))) .Add("UserUnit", dfUserUnit) .Add("Contents", nContentId, 0) .Add("Resources", nResourcesId, 0); if( nAnnotsId.toBool() ) oDictPage.Add("Annots", nAnnotsId, 0); oDictPage.Add("Group", &((new GDALPDFDictionaryRW()) ->Add("Type", GDALPDFObjectRW::CreateName("Group")) .Add("S", GDALPDFObjectRW::CreateName("Transparency")) .Add("CS", GDALPDFObjectRW::CreateName("DeviceRGB")))); if (!anViewportIds.empty()) { auto poViewports = new GDALPDFArrayRW(); for( const auto& id: anViewportIds ) poViewports->Add(id, 0); oDictPage.Add("VP", poViewports); } if (anLGIDictIds.size() == 1 ) { oDictPage.Add("LGIDict", anLGIDictIds[0], 0); } else if (!anLGIDictIds.empty()) { auto poLGIDict = new GDALPDFArrayRW(); for( const auto& id: anLGIDictIds ) poLGIDict->Add(id, 0); oDictPage.Add("LGIDict", poLGIDict); } if( nStructParentsIdx >= 0 ) { oDictPage.Add("StructParents", nStructParentsIdx); } VSIFPrintfL(m_fp, "%s\n", oDictPage.Serialize().c_str()); EndObj(); /* -------------------------------------------------------------- */ /* Write content dictionary */ /* -------------------------------------------------------------- */ { GDALPDFDictionaryRW oDict; StartObjWithStream(nContentId, oDict, bDeflateStreamCompression); VSIFPrintfL(m_fp, "%s", oPageContext.m_osDrawingStream.c_str()); EndObjWithStream(); } /* -------------------------------------------------------------- */ /* Write page resource dictionary. */ /* -------------------------------------------------------------- */ StartObj(nResourcesId); { GDALPDFDictionaryRW oDict; if( !oPageContext.m_oXObjects.empty() ) { GDALPDFDictionaryRW* poDict = new GDALPDFDictionaryRW(); for( const auto&kv: oPageContext.m_oXObjects ) { poDict->Add(kv.first, kv.second, 0); } oDict.Add("XObject", poDict); } if( !oPageContext.m_oProperties.empty() ) { GDALPDFDictionaryRW* poDict = new GDALPDFDictionaryRW(); for( const auto&kv: oPageContext.m_oProperties ) { poDict->Add(kv.first, kv.second, 0); } oDict.Add("Properties", poDict); } if( !oPageContext.m_oExtGState.empty() ) { GDALPDFDictionaryRW* poDict = new GDALPDFDictionaryRW(); for( const auto&kv: oPageContext.m_oExtGState ) { poDict->Add(kv.first, kv.second, 0); } oDict.Add("ExtGState", poDict); } VSIFPrintfL(m_fp, "%s\n", oDict.Serialize().c_str()); } EndObj(); return true; } /************************************************************************/ /* ExploreContent() */ /************************************************************************/ bool GDALPDFComposerWriter::ExploreContent(const CPLXMLNode* psNode, PageContext& oPageContext) { for(const auto* psIter = psNode->psChild; psIter; psIter = psIter->psNext) { if( psIter->eType == CXT_Element && strcmp(psIter->pszValue, "IfLayerOn") == 0 ) { const char* pszLayerId = CPLGetXMLValue(psIter, "layerId", nullptr); if( !pszLayerId ) { CPLError(CE_Failure, CPLE_AppDefined, "Missing layerId"); return false; } auto oIter = m_oMapLayerIdToOCG.find(pszLayerId); if( oIter == m_oMapLayerIdToOCG.end() ) { CPLError(CE_Failure, CPLE_AppDefined, "Referencing layer of unknown id: %s", pszLayerId); return false; } oPageContext.m_oProperties[ CPLOPrintf("Lyr%d", oIter->second.toInt())] = oIter->second; oPageContext.m_osDrawingStream += CPLOPrintf("/OC /Lyr%d BDC\n", oIter->second.toInt()); if( !ExploreContent(psIter, oPageContext) ) return false; oPageContext.m_osDrawingStream += "EMC\n"; } else if( psIter->eType == CXT_Element && strcmp(psIter->pszValue, "Raster") == 0 ) { if( !WriteRaster(psIter, oPageContext) ) return false; } else if( psIter->eType == CXT_Element && strcmp(psIter->pszValue, "Vector") == 0 ) { if( !WriteVector(psIter, oPageContext) ) return false; } else if( psIter->eType == CXT_Element && strcmp(psIter->pszValue, "VectorLabel") == 0 ) { if( !WriteVectorLabel(psIter, oPageContext) ) return false; } else if( psIter->eType == CXT_Element && strcmp(psIter->pszValue, "PDF") == 0 ) { #ifdef HAVE_PDF_READ_SUPPORT if( !WritePDF(psIter, oPageContext) ) return false; #else CPLError(CE_Failure, CPLE_NotSupported, "PDF node not supported due to PDF read support in this GDAL build"); return false; #endif } } return true; } /************************************************************************/ /* StartBlending() */ /************************************************************************/ void GDALPDFComposerWriter::StartBlending(const CPLXMLNode* psNode, PageContext& oPageContext, double& dfOpacity) { dfOpacity = 1; const auto psBlending = CPLGetXMLNode(psNode, "Blending"); if( psBlending ) { auto nExtGState = AllocNewObject(); StartObj(nExtGState); { GDALPDFDictionaryRW gs; gs.Add("Type", GDALPDFObjectRW::CreateName("ExtGState")); dfOpacity = CPLAtof(CPLGetXMLValue( psBlending, "opacity", "1")); gs.Add("ca", dfOpacity); gs.Add("BM", GDALPDFObjectRW::CreateName( CPLGetXMLValue(psBlending, "function", "Normal"))); VSIFPrintfL(m_fp, "%s\n", gs.Serialize().c_str()); } EndObj(); oPageContext.m_oExtGState[ CPLOPrintf("GS%d", nExtGState.toInt())] = nExtGState; oPageContext.m_osDrawingStream += "q\n"; oPageContext.m_osDrawingStream += CPLOPrintf("/GS%d gs\n", nExtGState.toInt()); } } /************************************************************************/ /* EndBlending() */ /************************************************************************/ void GDALPDFComposerWriter::EndBlending(const CPLXMLNode* psNode, PageContext& oPageContext) { const auto psBlending = CPLGetXMLNode(psNode, "Blending"); if( psBlending ) { oPageContext.m_osDrawingStream += "Q\n"; } } /************************************************************************/ /* WriteRaster() */ /************************************************************************/ bool GDALPDFComposerWriter::WriteRaster(const CPLXMLNode* psNode, PageContext& oPageContext) { const char* pszDataset = CPLGetXMLValue(psNode, "dataset", nullptr); if( !pszDataset ) { CPLError(CE_Failure, CPLE_AppDefined, "Missing dataset"); return false; } double dfX1 = CPLAtof(CPLGetXMLValue(psNode, "x1", "0")); double dfY1 = CPLAtof(CPLGetXMLValue(psNode, "y1", "0")); double dfX2 = CPLAtof(CPLGetXMLValue(psNode, "x2", CPLSPrintf("%.18g", oPageContext.m_dfWidthInUserUnit))); double dfY2 = CPLAtof(CPLGetXMLValue(psNode, "y2", CPLSPrintf("%.18g", oPageContext.m_dfHeightInUserUnit))); if( dfX2 <= dfX1 || dfY2 <= dfY1 ) { CPLError(CE_Failure, CPLE_AppDefined, "Invalid x1,y1,x2,y2"); return false; } GDALDatasetUniquePtr poDS(GDALDataset::Open( pszDataset, GDAL_OF_RASTER | GDAL_OF_VERBOSE_ERROR, nullptr, nullptr, nullptr)); if( !poDS ) return false; const int nWidth = poDS->GetRasterXSize(); const int nHeight = poDS->GetRasterYSize(); const int nBlockXSize = std::max(16, atoi(CPLGetXMLValue(psNode, "tileSize", "256"))); const int nBlockYSize = nBlockXSize; const char* pszCompressMethod = CPLGetXMLValue( psNode, "Compression.method", "DEFLATE"); PDFCompressMethod eCompressMethod = COMPRESS_DEFLATE; if( EQUAL(pszCompressMethod, "JPEG") ) eCompressMethod = COMPRESS_JPEG; else if( EQUAL(pszCompressMethod, "JPEG2000") ) eCompressMethod = COMPRESS_JPEG2000; const int nPredictor = CPLTestBool(CPLGetXMLValue( psNode, "Compression.predictor", "false")) ? 2 : 0; const int nJPEGQuality = atoi( CPLGetXMLValue(psNode, "Compression.quality", "-1")); const char* pszJPEG2000_DRIVER = m_osJPEG2000Driver.empty() ? nullptr : m_osJPEG2000Driver.c_str();; const char* pszGeoreferencingId = CPLGetXMLValue(psNode, "georeferencingId", nullptr); double dfClippingMinX = 0; double dfClippingMinY = 0; double dfClippingMaxX = 0; double dfClippingMaxY = 0; bool bClip = false; double adfRasterGT[6] = {0,1,0,0,0,1}; double adfInvGeoreferencingGT[6]; // from georeferenced to PDF coordinates if( pszGeoreferencingId ) { auto iter = oPageContext.m_oMapGeoreferencedId.find(pszGeoreferencingId); if( iter == oPageContext.m_oMapGeoreferencedId.end() ) { CPLError(CE_Failure, CPLE_AppDefined, "Cannot find georeferencing of id %s", pszGeoreferencingId); return false; } auto& georeferencing = iter->second; dfX1 = georeferencing.m_bboxX1; dfY1 = georeferencing.m_bboxY1; dfX2 = georeferencing.m_bboxX2; dfY2 = georeferencing.m_bboxY2; bClip = true; dfClippingMinX = APPLY_GT_X(georeferencing.m_adfGT, dfX1, dfY1); dfClippingMinY = APPLY_GT_Y(georeferencing.m_adfGT, dfX1, dfY1); dfClippingMaxX = APPLY_GT_X(georeferencing.m_adfGT, dfX2, dfY2); dfClippingMaxY = APPLY_GT_Y(georeferencing.m_adfGT, dfX2, dfY2); if( poDS->GetGeoTransform(adfRasterGT) != CE_None || adfRasterGT[2] != 0 || adfRasterGT[4] != 0 || adfRasterGT[5] > 0 ) { CPLError(CE_Failure, CPLE_AppDefined, "Raster has no geotransform or a rotated geotransform"); return false; } auto poSRS = poDS->GetSpatialRef(); if( !poSRS || !poSRS->IsSame(&georeferencing.m_oSRS) ) { CPLError(CE_Failure, CPLE_AppDefined, "Raster has no projection, or different from the one " "of the georeferencing area"); return false; } CPL_IGNORE_RET_VAL( GDALInvGeoTransform(georeferencing.m_adfGT, adfInvGeoreferencingGT)); } const double dfRasterMinX = adfRasterGT[0]; const double dfRasterMaxY = adfRasterGT[3]; /* Does the source image has a color table ? */ const auto nColorTableId = WriteColorTable(poDS.get()); double dfIgnoredOpacity; StartBlending(psNode, oPageContext, dfIgnoredOpacity); CPLString osGroupStream; std::vector<GDALPDFObjectNum> anImageIds; const int nXBlocks = (nWidth + nBlockXSize - 1) / nBlockXSize; const int nYBlocks = (nHeight + nBlockYSize - 1) / nBlockYSize; int nBlockXOff, nBlockYOff; for(nBlockYOff = 0; nBlockYOff < nYBlocks; nBlockYOff ++) { for(nBlockXOff = 0; nBlockXOff < nXBlocks; nBlockXOff ++) { int nReqWidth = std::min(nBlockXSize, nWidth - nBlockXOff * nBlockXSize); int nReqHeight = std::min(nBlockYSize, nHeight - nBlockYOff * nBlockYSize); int nX = nBlockXOff * nBlockXSize; int nY = nBlockYOff * nBlockYSize; double dfXPDFOff = nX * (dfX2 - dfX1) / nWidth + dfX1; double dfYPDFOff = (nHeight - nY - nReqHeight) * (dfY2 - dfY1) / nHeight + dfY1; double dfXPDFSize = nReqWidth * (dfX2 - dfX1) / nWidth; double dfYPDFSize = nReqHeight * (dfY2 - dfY1) / nHeight; if( bClip ) { /* Compute extent of block to write */ double dfBlockMinX = adfRasterGT[0] + nX * adfRasterGT[1]; double dfBlockMaxX = adfRasterGT[0] + (nX + nReqWidth) * adfRasterGT[1]; double dfBlockMinY = adfRasterGT[3] + (nY + nReqHeight) * adfRasterGT[5]; double dfBlockMaxY = adfRasterGT[3] + nY * adfRasterGT[5]; // Clip the extent of the block with the extent of the main raster. const double dfIntersectMinX = std::max(dfBlockMinX, dfClippingMinX); const double dfIntersectMinY = std::max(dfBlockMinY, dfClippingMinY); const double dfIntersectMaxX = std::min(dfBlockMaxX, dfClippingMaxX); const double dfIntersectMaxY = std::min(dfBlockMaxY, dfClippingMaxY); bool bOK = false; if( dfIntersectMinX < dfIntersectMaxX && dfIntersectMinY < dfIntersectMaxY ) { /* Re-compute (x,y,width,height) subwindow of current raster from */ /* the extent of the clipped block */ nX = (int)((dfIntersectMinX - dfRasterMinX) / adfRasterGT[1] + 0.5); nY = (int)((dfRasterMaxY - dfIntersectMaxY) / (-adfRasterGT[5]) + 0.5); nReqWidth = (int)((dfIntersectMaxX - dfRasterMinX) / adfRasterGT[1] + 0.5) - nX; nReqHeight = (int)((dfRasterMaxY - dfIntersectMinY) / (-adfRasterGT[5]) + 0.5) - nY; if( nReqWidth > 0 && nReqHeight > 0) { dfBlockMinX = adfRasterGT[0] + nX * adfRasterGT[1]; dfBlockMaxX = adfRasterGT[0] + (nX + nReqWidth) * adfRasterGT[1]; dfBlockMinY = adfRasterGT[3] + (nY + nReqHeight) * adfRasterGT[5]; dfBlockMaxY = adfRasterGT[3] + nY * adfRasterGT[5]; double dfPDFX1 = APPLY_GT_X(adfInvGeoreferencingGT, dfBlockMinX, dfBlockMinY); double dfPDFY1 = APPLY_GT_Y(adfInvGeoreferencingGT, dfBlockMinX, dfBlockMinY); double dfPDFX2 = APPLY_GT_X(adfInvGeoreferencingGT, dfBlockMaxX, dfBlockMaxY); double dfPDFY2 = APPLY_GT_Y(adfInvGeoreferencingGT, dfBlockMaxX, dfBlockMaxY); dfXPDFOff = dfPDFX1; dfYPDFOff = dfPDFY1; dfXPDFSize = dfPDFX2 - dfPDFX1; dfYPDFSize = dfPDFY2 - dfPDFY1; bOK = true; } } if( !bOK ) { continue; } } const auto nImageId = WriteBlock(poDS.get(), nX, nY, nReqWidth, nReqHeight, nColorTableId, eCompressMethod, nPredictor, nJPEGQuality, pszJPEG2000_DRIVER, nullptr, nullptr); if (!nImageId.toBool()) return false; anImageIds.push_back(nImageId); osGroupStream += "q\n"; GDALPDFObjectRW* poXSize = GDALPDFObjectRW::CreateReal(dfXPDFSize); GDALPDFObjectRW* poYSize = GDALPDFObjectRW::CreateReal(dfYPDFSize); GDALPDFObjectRW* poXOff = GDALPDFObjectRW::CreateReal(dfXPDFOff); GDALPDFObjectRW* poYOff = GDALPDFObjectRW::CreateReal(dfYPDFOff); osGroupStream += CPLOPrintf("%s 0 0 %s %s %s cm\n", poXSize->Serialize().c_str(), poYSize->Serialize().c_str(), poXOff->Serialize().c_str(), poYOff->Serialize().c_str()); delete poXSize; delete poYSize; delete poXOff; delete poYOff; osGroupStream += CPLOPrintf("/Image%d Do\n", nImageId.toInt()); osGroupStream += "Q\n"; } } if( anImageIds.size() <= 1 || CPLGetXMLNode(psNode, "Blending") == nullptr ) { for( const auto& nImageId: anImageIds ) { oPageContext.m_oXObjects[ CPLOPrintf("Image%d", nImageId.toInt())] = nImageId; } oPageContext.m_osDrawingStream += osGroupStream; } else { // In case several tiles are drawn with blending, use a transparency // group to avoid edge effects. auto nGroupId = AllocNewObject(); GDALPDFDictionaryRW oDictGroup; GDALPDFDictionaryRW* poGroup = new GDALPDFDictionaryRW(); poGroup->Add("Type", GDALPDFObjectRW::CreateName("Group")) .Add("S",GDALPDFObjectRW::CreateName("Transparency")); GDALPDFDictionaryRW* poXObjects = new GDALPDFDictionaryRW(); for( const auto& nImageId: anImageIds ) { poXObjects->Add(CPLOPrintf("Image%d", nImageId.toInt()), nImageId, 0); } GDALPDFDictionaryRW* poResources = new GDALPDFDictionaryRW(); poResources->Add("XObject", poXObjects); oDictGroup.Add("Type", GDALPDFObjectRW::CreateName("XObject")) .Add("BBox", &((new GDALPDFArrayRW()) ->Add(0).Add(0)). Add(oPageContext.m_dfWidthInUserUnit). Add(oPageContext.m_dfHeightInUserUnit)) .Add("Subtype", GDALPDFObjectRW::CreateName("Form")) .Add("Group", poGroup) .Add("Resources", poResources); StartObjWithStream(nGroupId, oDictGroup, oPageContext.m_eStreamCompressMethod != COMPRESS_NONE); VSIFPrintfL(m_fp, "%s", osGroupStream.c_str()); EndObjWithStream(); oPageContext.m_oXObjects[ CPLOPrintf("Group%d", nGroupId.toInt())] = nGroupId; oPageContext.m_osDrawingStream += CPLOPrintf("/Group%d Do\n", nGroupId.toInt()); } EndBlending(psNode, oPageContext); return true; } /************************************************************************/ /* SetupVectorGeoreferencing() */ /************************************************************************/ bool GDALPDFComposerWriter::SetupVectorGeoreferencing( const char* pszGeoreferencingId, OGRLayer* poLayer, const PageContext& oPageContext, double& dfClippingMinX, double& dfClippingMinY, double& dfClippingMaxX, double& dfClippingMaxY, double adfMatrix[4], std::unique_ptr<OGRCoordinateTransformation>& poCT) { CPLAssert( pszGeoreferencingId ); auto iter = oPageContext.m_oMapGeoreferencedId.find(pszGeoreferencingId); if( iter == oPageContext.m_oMapGeoreferencedId.end() ) { CPLError(CE_Failure, CPLE_AppDefined, "Cannot find georeferencing of id %s", pszGeoreferencingId); return false; } auto& georeferencing = iter->second; const double dfX1 = georeferencing.m_bboxX1; const double dfY1 = georeferencing.m_bboxY1; const double dfX2 = georeferencing.m_bboxX2; const double dfY2 = georeferencing.m_bboxY2; dfClippingMinX = APPLY_GT_X(georeferencing.m_adfGT, dfX1, dfY1); dfClippingMinY = APPLY_GT_Y(georeferencing.m_adfGT, dfX1, dfY1); dfClippingMaxX = APPLY_GT_X(georeferencing.m_adfGT, dfX2, dfY2); dfClippingMaxY = APPLY_GT_Y(georeferencing.m_adfGT, dfX2, dfY2); auto poSRS = poLayer->GetSpatialRef(); if( !poSRS ) { CPLError(CE_Failure, CPLE_AppDefined, "Layer has no SRS"); return false; } if( !poSRS->IsSame(&georeferencing.m_oSRS) ) { poCT.reset( OGRCreateCoordinateTransformation(poSRS, &georeferencing.m_oSRS)); } if( !poCT ) { poLayer->SetSpatialFilterRect(dfClippingMinX, dfClippingMinY, dfClippingMaxX, dfClippingMaxY); } double adfInvGeoreferencingGT[6]; // from georeferenced to PDF coordinates CPL_IGNORE_RET_VAL( GDALInvGeoTransform(const_cast<double*>(georeferencing.m_adfGT), adfInvGeoreferencingGT)); adfMatrix[0] = adfInvGeoreferencingGT[0]; adfMatrix[1] = adfInvGeoreferencingGT[1]; adfMatrix[2] = adfInvGeoreferencingGT[3]; adfMatrix[3] = adfInvGeoreferencingGT[5]; return true; } /************************************************************************/ /* WriteVector() */ /************************************************************************/ bool GDALPDFComposerWriter::WriteVector(const CPLXMLNode* psNode, PageContext& oPageContext) { const char* pszDataset = CPLGetXMLValue(psNode, "dataset", nullptr); if( !pszDataset ) { CPLError(CE_Failure, CPLE_AppDefined, "Missing dataset"); return false; } const char* pszLayer = CPLGetXMLValue(psNode, "layer", nullptr); if( !pszLayer ) { CPLError(CE_Failure, CPLE_AppDefined, "Missing layer"); return false; } GDALDatasetUniquePtr poDS(GDALDataset::Open( pszDataset, GDAL_OF_VECTOR | GDAL_OF_VERBOSE_ERROR, nullptr, nullptr, nullptr)); if( !poDS ) return false; OGRLayer* poLayer = poDS->GetLayerByName(pszLayer); if( !poLayer ) { CPLError(CE_Failure, CPLE_AppDefined, "Cannt find layer %s", pszLayer); return false; } const bool bVisible = CPLTestBool(CPLGetXMLValue(psNode, "visible", "true")); const auto psLogicalStructure = CPLGetXMLNode(psNode, "LogicalStructure"); const char* pszOGRDisplayField = nullptr; std::vector<CPLString> aosIncludedFields; const bool bLogicalStructure = psLogicalStructure != nullptr; if( psLogicalStructure ) { pszOGRDisplayField = CPLGetXMLValue(psLogicalStructure, "fieldToDisplay", nullptr); if( CPLGetXMLNode(psLogicalStructure, "ExcludeAllFields") != nullptr || CPLGetXMLNode(psLogicalStructure, "IncludeField") != nullptr ) { for(const auto* psIter = psLogicalStructure->psChild; psIter; psIter = psIter->psNext) { if( psIter->eType == CXT_Element && strcmp(psIter->pszValue, "IncludeField") == 0 ) { aosIncludedFields.push_back(CPLGetXMLValue(psIter, nullptr, "")); } } } else { std::set<CPLString> oSetExcludedFields; for(const auto* psIter = psLogicalStructure->psChild; psIter; psIter = psIter->psNext) { if( psIter->eType == CXT_Element && strcmp(psIter->pszValue, "ExcludeField") == 0 ) { oSetExcludedFields.insert(CPLGetXMLValue(psIter, nullptr, "")); } } const auto poLayerDefn = poLayer->GetLayerDefn(); for( int i = 0; i < poLayerDefn->GetFieldCount(); i++ ) { const auto poFieldDefn = poLayerDefn->GetFieldDefn(i); const char* pszName = poFieldDefn->GetNameRef(); if( oSetExcludedFields.find(pszName) == oSetExcludedFields.end() ) { aosIncludedFields.push_back(pszName); } } } } const char* pszStyleString = CPLGetXMLValue(psNode, "ogrStyleString", nullptr); const char* pszOGRLinkField = CPLGetXMLValue(psNode, "linkAttribute", nullptr); const char* pszGeoreferencingId = CPLGetXMLValue(psNode, "georeferencingId", nullptr); std::unique_ptr<OGRCoordinateTransformation> poCT; double dfClippingMinX = 0; double dfClippingMinY = 0; double dfClippingMaxX = 0; double dfClippingMaxY = 0; double adfMatrix[4] = { 0, 1, 0, 1 }; if( pszGeoreferencingId && !SetupVectorGeoreferencing(pszGeoreferencingId, poLayer, oPageContext, dfClippingMinX, dfClippingMaxX, dfClippingMinY, dfClippingMaxY, adfMatrix, poCT) ) { return false; } double dfOpacityFactor = 1.0; if( !bVisible ) { if( oPageContext.m_oExtGState.find("GSinvisible") == oPageContext.m_oExtGState.end() ) { auto nExtGState = AllocNewObject(); StartObj(nExtGState); { GDALPDFDictionaryRW gs; gs.Add("Type", GDALPDFObjectRW::CreateName("ExtGState")); gs.Add("ca", 0); gs.Add("CA", 0); VSIFPrintfL(m_fp, "%s\n", gs.Serialize().c_str()); } EndObj(); oPageContext.m_oExtGState["GSinvisible"] = nExtGState; } oPageContext.m_osDrawingStream += "q\n"; oPageContext.m_osDrawingStream += "/GSinvisible gs\n"; oPageContext.m_osDrawingStream += "0 w\n"; dfOpacityFactor = 0; } else { StartBlending(psNode, oPageContext, dfOpacityFactor); } if (!m_nStructTreeRootId.toBool()) m_nStructTreeRootId = AllocNewObject(); GDALPDFObjectNum nFeatureLayerId; if( bLogicalStructure ) { nFeatureLayerId = AllocNewObject(); m_anFeatureLayerId.push_back(nFeatureLayerId); } std::vector<GDALPDFObjectNum> anFeatureUserProperties; for( auto&& poFeature: poLayer ) { auto hFeat = OGRFeature::ToHandle(poFeature.get()); auto hGeom = OGR_F_GetGeometryRef(hFeat); if( !hGeom || OGR_G_IsEmpty(hGeom) ) continue; if( poCT ) { if( OGRGeometry::FromHandle(hGeom)->transform(poCT.get()) != OGRERR_NONE ) continue; OGREnvelope sEnvelope; OGR_G_GetEnvelope(hGeom, &sEnvelope); if( sEnvelope.MinX > dfClippingMaxX || sEnvelope.MaxX < dfClippingMinX || sEnvelope.MinY > dfClippingMaxY || sEnvelope.MaxY < dfClippingMinY ) { continue; } } if( bLogicalStructure ) { CPLString osOutFeatureName; anFeatureUserProperties.push_back( WriteAttributes( hFeat, aosIncludedFields, pszOGRDisplayField, oPageContext.m_nMCID, nFeatureLayerId, m_asPageId.back(), osOutFeatureName)); } ObjectStyle os; GetObjectStyle(pszStyleString, hFeat, adfMatrix, m_oMapSymbolFilenameToDesc, os); os.nPenA = static_cast<int>(std::round(os.nPenA * dfOpacityFactor)); os.nBrushA = static_cast<int>(std::round(os.nBrushA * dfOpacityFactor)); const double dfRadius = os.dfSymbolSize; if( os.nImageSymbolId.toBool() ) { oPageContext.m_oXObjects[ CPLOPrintf("SymImage%d", os.nImageSymbolId.toInt())] = os.nImageSymbolId; } if( pszOGRLinkField ) { OGREnvelope sEnvelope; OGR_G_GetEnvelope(hGeom, &sEnvelope); int bboxXMin, bboxYMin, bboxXMax, bboxYMax; ComputeIntBBox(hGeom, sEnvelope, adfMatrix, os, dfRadius, bboxXMin, bboxYMin, bboxXMax, bboxYMax); auto nLinkId = WriteLink(hFeat, pszOGRLinkField, adfMatrix, bboxXMin, bboxYMin, bboxXMax, bboxYMax); if( nLinkId.toBool() ) oPageContext.m_anAnnotationsId.push_back(nLinkId); } if( bLogicalStructure ) { oPageContext.m_osDrawingStream += CPLOPrintf("/feature <</MCID %d>> BDC\n", oPageContext.m_nMCID); } if( bVisible || bLogicalStructure ) { oPageContext.m_osDrawingStream += "q\n"; if (bVisible && (os.nPenA != 255 || os.nBrushA != 255)) { CPLString osGSName; osGSName.Printf("GS_CA_%d_ca_%d", os.nPenA, os.nBrushA); if( oPageContext.m_oExtGState.find(osGSName) == oPageContext.m_oExtGState.end() ) { auto nExtGState = AllocNewObject(); StartObj(nExtGState); { GDALPDFDictionaryRW gs; gs.Add("Type", GDALPDFObjectRW::CreateName("ExtGState")); if (os.nPenA != 255) gs.Add("CA", (os.nPenA == 127 || os.nPenA == 128) ? 0.5 : os.nPenA / 255.0); if (os.nBrushA != 255) gs.Add("ca", (os.nBrushA == 127 || os.nBrushA == 128) ? 0.5 : os.nBrushA / 255.0 ); VSIFPrintfL(m_fp, "%s\n", gs.Serialize().c_str()); } EndObj(); oPageContext.m_oExtGState[osGSName] = nExtGState; } oPageContext.m_osDrawingStream += "/" + osGSName +" gs\n"; } oPageContext.m_osDrawingStream += GenerateDrawingStream(hGeom, adfMatrix, os, dfRadius); oPageContext.m_osDrawingStream += "Q\n"; } if( bLogicalStructure ) { oPageContext.m_osDrawingStream += "EMC\n"; oPageContext.m_nMCID ++; } } if( bLogicalStructure ) { for( const auto& num: anFeatureUserProperties ) { oPageContext.m_anFeatureUserProperties.push_back(num); } { StartObj(nFeatureLayerId); GDALPDFDictionaryRW oDict; GDALPDFDictionaryRW* poDictA = new GDALPDFDictionaryRW(); oDict.Add("A", poDictA); poDictA->Add("O", GDALPDFObjectRW::CreateName("UserProperties")); GDALPDFArrayRW* poArrayK = new GDALPDFArrayRW(); for( const auto& num: anFeatureUserProperties ) poArrayK->Add(num, 0); oDict.Add("K", poArrayK); oDict.Add("P", m_nStructTreeRootId, 0); oDict.Add("S", GDALPDFObjectRW::CreateName("Layer")); const char* pszOGRDisplayName = CPLGetXMLValue(psLogicalStructure, "displayLayerName", poLayer->GetName()); oDict.Add("T", pszOGRDisplayName); VSIFPrintfL(m_fp, "%s\n", oDict.Serialize().c_str()); EndObj(); } } if( !bVisible ) { oPageContext.m_osDrawingStream += "Q\n"; } else { EndBlending(psNode, oPageContext); } return true; } /************************************************************************/ /* WriteVectorLabel() */ /************************************************************************/ bool GDALPDFComposerWriter::WriteVectorLabel(const CPLXMLNode* psNode, PageContext& oPageContext) { const char* pszDataset = CPLGetXMLValue(psNode, "dataset", nullptr); if( !pszDataset ) { CPLError(CE_Failure, CPLE_AppDefined, "Missing dataset"); return false; } const char* pszLayer = CPLGetXMLValue(psNode, "layer", nullptr); if( !pszLayer ) { CPLError(CE_Failure, CPLE_AppDefined, "Missing layer"); return false; } GDALDatasetUniquePtr poDS(GDALDataset::Open( pszDataset, GDAL_OF_VECTOR | GDAL_OF_VERBOSE_ERROR, nullptr, nullptr, nullptr)); if( !poDS ) return false; OGRLayer* poLayer = poDS->GetLayerByName(pszLayer); if( !poLayer ) { CPLError(CE_Failure, CPLE_AppDefined, "Cannt find layer %s", pszLayer); return false; } const char* pszStyleString = CPLGetXMLValue(psNode, "ogrStyleString", nullptr); double dfOpacityFactor = 1.0; StartBlending(psNode, oPageContext, dfOpacityFactor); const char* pszGeoreferencingId = CPLGetXMLValue(psNode, "georeferencingId", nullptr); std::unique_ptr<OGRCoordinateTransformation> poCT; double dfClippingMinX = 0; double dfClippingMinY = 0; double dfClippingMaxX = 0; double dfClippingMaxY = 0; double adfMatrix[4] = { 0, 1, 0, 1 }; if( pszGeoreferencingId && !SetupVectorGeoreferencing(pszGeoreferencingId, poLayer, oPageContext, dfClippingMinX, dfClippingMaxX, dfClippingMinY, dfClippingMaxY, adfMatrix, poCT) ) { return false; } for( auto&& poFeature: poLayer ) { auto hFeat = OGRFeature::ToHandle(poFeature.get()); auto hGeom = OGR_F_GetGeometryRef(hFeat); if( !hGeom || OGR_G_IsEmpty(hGeom) ) continue; if( poCT ) { if( OGRGeometry::FromHandle(hGeom)->transform(poCT.get()) != OGRERR_NONE ) continue; OGREnvelope sEnvelope; OGR_G_GetEnvelope(hGeom, &sEnvelope); if( sEnvelope.MinX > dfClippingMaxX || sEnvelope.MaxX < dfClippingMinX || sEnvelope.MinY > dfClippingMaxY || sEnvelope.MaxY < dfClippingMinY ) { continue; } } ObjectStyle os; GetObjectStyle(pszStyleString, hFeat, adfMatrix, m_oMapSymbolFilenameToDesc, os); os.nPenA = static_cast<int>(std::round(os.nPenA * dfOpacityFactor)); os.nBrushA = static_cast<int>(std::round(os.nBrushA * dfOpacityFactor)); if (!os.osLabelText.empty() && wkbFlatten(OGR_G_GetGeometryType(hGeom)) == wkbPoint) { auto nObjectId = WriteLabel(hGeom, adfMatrix, os, oPageContext.m_eStreamCompressMethod, 0,0, oPageContext.m_dfWidthInUserUnit, oPageContext.m_dfHeightInUserUnit); oPageContext.m_osDrawingStream += CPLOPrintf("/Label%d Do\n", nObjectId.toInt()); oPageContext.m_oXObjects[ CPLOPrintf("Label%d", nObjectId.toInt())] = nObjectId; } } EndBlending(psNode, oPageContext); return true; } #ifdef HAVE_PDF_READ_SUPPORT /************************************************************************/ /* EmitNewObject() */ /************************************************************************/ GDALPDFObjectNum GDALPDFComposerWriter::EmitNewObject(GDALPDFObject* poObj, RemapType& oRemapObjectRefs) { auto nId = AllocNewObject(); const auto nRefNum = poObj->GetRefNum(); if( nRefNum.toBool() ) { int nRefGen = poObj->GetRefGen(); std::pair<int, int> oKey(nRefNum.toInt(), nRefGen); oRemapObjectRefs[oKey] = nId; } CPLString osStr; if( !SerializeAndRenumberIgnoreRef(osStr, poObj, oRemapObjectRefs) ) return GDALPDFObjectNum(); StartObj(nId); VSIFWriteL(osStr.data(), 1, osStr.size(), m_fp); VSIFPrintfL(m_fp, "\n"); EndObj(); return nId; } /************************************************************************/ /* SerializeAndRenumber() */ /************************************************************************/ bool GDALPDFComposerWriter::SerializeAndRenumber(CPLString& osStr, GDALPDFObject* poObj, RemapType& oRemapObjectRefs) { auto nRefNum = poObj->GetRefNum(); if( nRefNum.toBool() ) { int nRefGen = poObj->GetRefGen(); std::pair<int, int> oKey(nRefNum.toInt(), nRefGen); auto oIter = oRemapObjectRefs.find(oKey); if( oIter != oRemapObjectRefs.end() ) { osStr.append(CPLSPrintf("%d 0 R", oIter->second.toInt())); return true; } else { auto nId = EmitNewObject(poObj, oRemapObjectRefs); osStr.append(CPLSPrintf("%d 0 R", nId.toInt())); return nId.toBool(); } } else { return SerializeAndRenumberIgnoreRef(osStr, poObj, oRemapObjectRefs); } } /************************************************************************/ /* SerializeAndRenumberIgnoreRef() */ /************************************************************************/ bool GDALPDFComposerWriter::SerializeAndRenumberIgnoreRef(CPLString& osStr, GDALPDFObject* poObj, RemapType& oRemapObjectRefs) { switch(poObj->GetType()) { case PDFObjectType_Array: { auto poArray = poObj->GetArray(); int nLength = poArray->GetLength(); osStr.append("[ "); for(int i=0;i<nLength;i++) { if( !SerializeAndRenumber(osStr, poArray->Get(i), oRemapObjectRefs) ) return false; osStr.append(" "); } osStr.append("]"); break; } case PDFObjectType_Dictionary: { osStr.append("<< "); auto poDict = poObj->GetDictionary(); auto& oMap = poDict->GetValues(); for( const auto& oIter: oMap ) { const char* pszKey = oIter.first.c_str(); GDALPDFObject* poSubObj = oIter.second; osStr.append("/"); osStr.append(pszKey); osStr.append(" "); if( !SerializeAndRenumber(osStr, poSubObj, oRemapObjectRefs) ) return false; osStr.append(" "); } osStr.append(">>"); auto poStream = poObj->GetStream(); if( poStream ) { // CPLAssert( poObj->GetRefNum().toBool() ); // should be a top level object osStr.append("\nstream\n"); auto pRawBytes = poStream->GetRawBytes(); if( !pRawBytes ) { CPLError(CE_Failure, CPLE_AppDefined, "Cannot get stream content"); return false; } osStr.append(pRawBytes, poStream->GetRawLength()); VSIFree(pRawBytes); osStr.append("\nendstream\n"); } break; } case PDFObjectType_Unknown: { CPLError(CE_Failure, CPLE_AppDefined, "Corrupted PDF"); return false; } default: { poObj->Serialize(osStr, false); break; } } return true; } /************************************************************************/ /* SerializeAndRenumber() */ /************************************************************************/ GDALPDFObjectNum GDALPDFComposerWriter::SerializeAndRenumber(GDALPDFObject* poObj) { RemapType oRemapObjectRefs; return EmitNewObject(poObj, oRemapObjectRefs); } /************************************************************************/ /* WritePDF() */ /************************************************************************/ bool GDALPDFComposerWriter::WritePDF(const CPLXMLNode* psNode, PageContext& oPageContext) { const char* pszDataset = CPLGetXMLValue(psNode, "dataset", nullptr); if( !pszDataset ) { CPLError(CE_Failure, CPLE_AppDefined, "Missing dataset"); return false; } GDALOpenInfo oOpenInfo(pszDataset, GA_ReadOnly); std::unique_ptr<PDFDataset> poDS(PDFDataset::Open(&oOpenInfo)); if( !poDS ) { CPLError(CE_Failure, CPLE_OpenFailed, "%s is not a valid PDF file", pszDataset); return false; } if( poDS->GetPageWidth() != oPageContext.m_dfWidthInUserUnit || poDS->GetPageHeight() != oPageContext.m_dfHeightInUserUnit ) { CPLError(CE_Warning, CPLE_AppDefined, "Dimensions of the inserted PDF page are %fx%f, which is " "different from the output PDF page %fx%f", poDS->GetPageWidth(), poDS->GetPageHeight(), oPageContext.m_dfWidthInUserUnit, oPageContext.m_dfHeightInUserUnit); } auto poPageObj = poDS->GetPageObj(); if( !poPageObj ) return false; auto poPageDict = poPageObj->GetDictionary(); if( !poPageDict ) return false; auto poContents = poPageDict->Get("Contents"); if (poContents != nullptr && poContents->GetType() == PDFObjectType_Array) { GDALPDFArray* poContentsArray = poContents->GetArray(); if (poContentsArray->GetLength() == 1) { poContents = poContentsArray->Get(0); } } if (poContents == nullptr || poContents->GetType() != PDFObjectType_Dictionary ) { CPLError(CE_Failure, CPLE_AppDefined, "Missing Contents"); return false; } auto poResources = poPageDict->Get("Resources"); if( !poResources ) { CPLError(CE_Failure, CPLE_AppDefined, "Missing Resources"); return false; } // Serialize and renumber the Page Resources dictionary auto nClonedResources = SerializeAndRenumber(poResources); if( !nClonedResources.toBool() ) { return false; } // Create a Transparency group using cloned Page Resources, and // the Page Contents stream auto nFormId = AllocNewObject(); GDALPDFDictionaryRW oDictGroup; GDALPDFDictionaryRW* poGroup = new GDALPDFDictionaryRW(); poGroup->Add("Type", GDALPDFObjectRW::CreateName("Group")) .Add("S",GDALPDFObjectRW::CreateName("Transparency")); oDictGroup.Add("Type", GDALPDFObjectRW::CreateName("XObject")) .Add("BBox", &((new GDALPDFArrayRW()) ->Add(0).Add(0)). Add(oPageContext.m_dfWidthInUserUnit). Add(oPageContext.m_dfHeightInUserUnit)) .Add("Subtype", GDALPDFObjectRW::CreateName("Form")) .Add("Group", poGroup) .Add("Resources", nClonedResources, 0); auto poStream = poContents->GetStream(); if( !poStream ) { CPLError(CE_Failure, CPLE_AppDefined, "Missing Contents stream"); return false; } auto pabyContents = poStream->GetBytes(); if( !pabyContents ) { return false; } const auto nContentsLength = poStream->GetLength(); StartObjWithStream(nFormId, oDictGroup, oPageContext.m_eStreamCompressMethod != COMPRESS_NONE); VSIFWriteL(pabyContents, 1, nContentsLength, m_fp); VSIFree(pabyContents); EndObjWithStream(); // Paint the transparency group double dfIgnoredOpacity; StartBlending(psNode, oPageContext, dfIgnoredOpacity); oPageContext.m_osDrawingStream += CPLOPrintf("/Form%d Do\n", nFormId.toInt()); oPageContext.m_oXObjects[ CPLOPrintf("Form%d", nFormId.toInt())] = nFormId; EndBlending(psNode, oPageContext); return true; } #endif // HAVE_PDF_READ_SUPPORT /************************************************************************/ /* Generate() */ /************************************************************************/ bool GDALPDFComposerWriter::Generate(const CPLXMLNode* psComposition) { m_osJPEG2000Driver = CPLGetXMLValue(psComposition, "JPEG2000Driver", ""); auto psMetadata = CPLGetXMLNode(psComposition, "Metadata"); if( psMetadata ) { SetInfo( CPLGetXMLValue(psMetadata, "Author", nullptr), CPLGetXMLValue(psMetadata, "Producer", nullptr), CPLGetXMLValue(psMetadata, "Creator", nullptr), CPLGetXMLValue(psMetadata, "CreationDate", nullptr), CPLGetXMLValue(psMetadata, "Subject", nullptr), CPLGetXMLValue(psMetadata, "Title", nullptr), CPLGetXMLValue(psMetadata, "Keywords", nullptr)); SetXMP(nullptr, CPLGetXMLValue(psMetadata, "XMP", nullptr)); } const char* pszJavascript = CPLGetXMLValue(psComposition, "Javascript", nullptr); if( pszJavascript ) WriteJavascript(pszJavascript, false); auto psLayerTree = CPLGetXMLNode(psComposition, "LayerTree"); if( psLayerTree ) { m_bDisplayLayersOnlyOnVisiblePages = CPLTestBool( CPLGetXMLValue(psLayerTree, "displayOnlyOnVisiblePages", "false")); if( !CreateLayerTree(psLayerTree, GDALPDFObjectNum(), &m_oTreeOfOGC) ) return false; } bool bFoundPage = false; for(const auto* psIter = psComposition->psChild; psIter; psIter = psIter->psNext) { if( psIter->eType == CXT_Element && strcmp(psIter->pszValue, "Page") == 0 ) { if( !GeneratePage(psIter) ) return false; bFoundPage = true; } } if( !bFoundPage ) { CPLError(CE_Failure, CPLE_AppDefined, "At least one page should be defined"); return false; } auto psOutline = CPLGetXMLNode(psComposition, "Outline"); if( psOutline ) { if( !CreateOutline(psOutline) ) return false; } return true; } /************************************************************************/ /* GDALPDFErrorHandler() */ /************************************************************************/ static void CPL_STDCALL GDALPDFErrorHandler(CPL_UNUSED CPLErr eErr, CPL_UNUSED CPLErrorNum nType, const char *pszMsg) { std::vector<CPLString> *paosErrors = static_cast<std::vector<CPLString> *>(CPLGetErrorHandlerUserData()); paosErrors->push_back(pszMsg); } /************************************************************************/ /* GDALPDFCreateFromCompositionFile() */ /************************************************************************/ GDALDataset* GDALPDFCreateFromCompositionFile(const char* pszPDFFilename, const char *pszXMLFilename) { CPLXMLTreeCloser oXML( (pszXMLFilename[0] == '<' && strstr(pszXMLFilename, "<PDFComposition") != nullptr) ? CPLParseXMLString(pszXMLFilename) : CPLParseXMLFile(pszXMLFilename)); if( !oXML.get() ) return nullptr; auto psComposition = CPLGetXMLNode(oXML.get(), "=PDFComposition"); if( !psComposition ) { CPLError(CE_Failure, CPLE_AppDefined, "Cannot find PDFComposition"); return nullptr; } // XML Validation. if( CPLTestBool(CPLGetConfigOption("GDAL_XML_VALIDATION", "YES")) ) { const char *pszXSD = CPLFindFile("gdal", "pdfcomposition.xsd"); if( pszXSD != nullptr ) { std::vector<CPLString> aosErrors; CPLPushErrorHandlerEx(GDALPDFErrorHandler, &aosErrors); const int bRet = CPLValidateXML(pszXMLFilename, pszXSD, nullptr); CPLPopErrorHandler(); if( !bRet ) { if( !aosErrors.empty() && strstr(aosErrors[0].c_str(), "missing libxml2 support") == nullptr ) { for( size_t i = 0; i < aosErrors.size(); i++ ) { CPLError(CE_Warning, CPLE_AppDefined, "%s", aosErrors[i].c_str()); } } } CPLErrorReset(); } } /* -------------------------------------------------------------------- */ /* Create file. */ /* -------------------------------------------------------------------- */ VSILFILE* fp = VSIFOpenL(pszPDFFilename, "wb"); if( fp == nullptr ) { CPLError( CE_Failure, CPLE_OpenFailed, "Unable to create PDF file %s.\n", pszPDFFilename ); return nullptr; } GDALPDFComposerWriter oWriter(fp); if( !oWriter.Generate(psComposition) ) return nullptr; return new GDALFakePDFDataset(); }
[ "pablo.alvarezlopez@dlr.de" ]
pablo.alvarezlopez@dlr.de
05dc36e6f2cbfa9cebe2cbd999136c223abe641e
1884b52d923717d7a406ff5dbf860a431692de81
/C-Z/恶俗的C语言作业之辗转相除.cpp
d5b03ee0d3182817cedf718893c0bed170ad57b5
[]
no_license
ShijieQ/C-
da7de3adf71581597b987aee04a28c49fbd9d24e
4b3f363a5e5d836d8c84f0ccc2e121078a8f6fa7
refs/heads/master
2021-06-11T17:38:52.054092
2021-03-24T15:23:30
2021-03-24T15:23:30
159,472,051
0
0
null
null
null
null
UTF-8
C++
false
false
192
cpp
#include <stdio.h> int gcd(int x,int y) { if(y==0) return x; return gcd(y,x%y); } int main() { int a,b; scanf("%d %d",&a,&b); printf("gcd=%d\n",gcd(a,b)); return 0; }
[ "582162019@qq.com" ]
582162019@qq.com
b0e7a2f5641924721f59210083879de89d6974b4
2d1fe67daaeb9bd9dbe3f5f313cba81902997276
/Converter.CPP
2213bad5c0ea34d9262f90a85c1fb9f87dfb13dc
[]
no_license
monowar123/C
832541f56a49703cf66c5b2253e81b03722396b3
42e5624120e192192433dd284561f016084ff002
refs/heads/master
2021-01-09T20:27:30.802730
2016-06-23T04:30:08
2016-06-23T04:30:08
61,773,367
0
0
null
null
null
null
UTF-8
C++
false
false
34,971
cpp
#include<stdio.h> #include<conio.h> #include<stdlib.h> #include<graphics.h> #include<dos.h> #include<math.h> #include<time.h> void mouse_reset(); void mouse_on(); void mouse_off(); void get_position(int *x,int *y); int left_button_pressed(); void main_window(); void window(); void temperature(); void length(); void waight(); void area(); void volume(); void num_sys(); void trigon(); void help(); int bin_to_dec(int num); void date_show(); void main() { clrscr(); int gdriver = DETECT, gmode; initgraph(&gdriver, &gmode, "c:\\tc\\bgi"); main_window(); date_show(); window(); getch(); } void main_window() { setfillstyle(1,5); bar(0,0,getmaxx(),getmaxy()); //border setfillstyle(1,0); bar(5,330,getmaxx()-5,420); //bar4 setfillstyle(1,3); bar(5,5,getmaxx()-5,50); //bar1 bar(5,302,getmaxx()-5,325); //bar3 bar(5,425,getmaxx()-5,getmaxy()-5); //bar5 setfillstyle(1,8); bar(getmaxx()-20,5,getmaxx()-5,20); //x:close bar(getmaxx()-37,5,getmaxx()-22,20); //maximize bar(getmaxx()-54,5,getmaxx()-39,20); //minimize bar(450,305,550,323); //clear setfillstyle(1,15); bar(getmaxx()-33,10,getmaxx()-27,15); setcolor(15); outtextxy(getmaxx()-50,9,"-"); setcolor(4); outtextxy(getmaxx()-16,9,"x"); settextstyle(0,0,3); setcolor(15); outtextxy(190,18,"CONVERTER"); setcolor(9); outtextxy(188,16,"CONVERTER"); settextstyle(0,0,2); setcolor(15); outtextxy(240,307,"OUTPUT"); setcolor(9); outtextxy(238,305,"OUTPUT"); settextstyle(7,0,2); setcolor(15); outtextxy(470,300,"Clear"); settextstyle(7,0,2); setcolor(15); outtextxy(35,getmaxy()-53,"Md.Monowarul Islam"); outtextxy(35,getmaxy()-30,"CE-09016"); setcolor(9); outtextxy(34,getmaxy()-54,"Md.Monowarul Islam"); outtextxy(34,getmaxy()-31,"CE-09016"); } void window() { int end=0,x,y; setfillstyle(1,1); bar(5,55,getmaxx()-5,297); //bar2 /////////////* Button *////////////// setfillstyle(1,8); bar(30,80,210,110); //tempetature bar(30,115,210,145); //length bar(30,150,210,180); //waight bar(30,185,210,215); //area bar(30,220,210,250); //volume bar(300,80,572,110); //number system bar(300,115,572,145); //trigon ratios bar(300,150,572,180); //help settextstyle(7,0,2); setcolor(15); outtextxy(50,80,"Temperature"); outtextxy(50,117,"Length"); outtextxy(50,152,"Waight"); outtextxy(50,187,"Area"); outtextxy(50,223,"Volume"); outtextxy(320,82,"Number System"); outtextxy(320,117,"Trigonometrical Ratios"); outtextxy(320,152,"Help"); mouse_reset(); mouse_on(); while(!end) { if(left_button_pressed()) { get_position(&x,&y); if(x>30&&x<210&&y>80&&y<110) temperature(); if(x>30&&x<210&&y>115&&y<145) length(); if(x>30&&x<210&&y>150&&y<180) waight(); if(x>30&&x<210&&y>185&&y<215) area(); if(x>30&&x<210&&y>220&&y<250) volume(); if(x>300&&x<572&&y>80&&y<110) num_sys(); if(x>300&&x<572&&y>115&&y<145) trigon(); if(x>300&&x<572&&y>150&&y<180) help(); if(x>450&&x<550&&y>305&&y<323) //clear { setfillstyle(1,0); bar(5,330,getmaxx()-5,420); //bar4 } if(x>(getmaxx()-20)&&x<(getmaxx()-5)&&y>5&&y<20) exit(0); } } } void temperature() { mouse_off(); int x,y; setfillstyle(1,1); bar(5,55,getmaxx()-5,297); setfillstyle(1,8); bar(30,80,300,110); // C to F bar(330,80,600,110); // F to K bar(30,150,300,180); // C to K bar(330,150,600,180); // F to R bar(30,220,300,250); // C to R bar(330,220,600,250); // K to R bar(getmaxx()-80,267,getmaxx()-10,292); //back settextstyle(7,0,2); setcolor(15); outtextxy(50,80,"Celcious to Fahrenheit"); outtextxy(50,150,"Celcious to Kelvin"); outtextxy(50,220,"Celcious to Rankine"); outtextxy(350,80,"Fahrenheit to kelvin"); outtextxy(350,150,"Fahrenheit to Rankine"); outtextxy(350,220,"Kelvin to Rankine"); outtextxy(getmaxx()-70,267,"Back"); mouse_on(); while(1) { if(left_button_pressed()) { get_position(&x,&y); if(x>30&&x<300&&y>80&&y<110) //C to F { float a; gotoxy(3,22); printf("Celcious to Fahrenheit press 1"); gotoxy(3,24); printf("Fahrenheit to Celcious press 2"); char ch=getche(); setfillstyle(1,0); bar(5,330,getmaxx()-5,420); //bar4 switch(ch) { case '1': gotoxy(3,22); printf("Input value in Celcious:"); scanf("%f",&a); float f=1.8*a+32; gotoxy(3,24); printf("Value in Fahrenheit:%f",f); break; case '2': gotoxy(3,22); printf("Input value in Fahrenheit:"); scanf("%f",&a); float c=(a-32)/1.8; gotoxy(3,24); printf("Value in Celcious:%f",c); break; default : gotoxy(3,22); printf("Wrong selection."); } } if(x>30&&x<300&&y>150&&y<180) //C to K { float a; gotoxy(3,22); printf("Celcious to Kelvin press 1"); gotoxy(3,24); printf("Kelvin to Celcious press 2"); char ch=getche(); setfillstyle(1,0); bar(5,330,getmaxx()-5,420); //bar4 switch(ch) { case '1': gotoxy(3,22); printf("Input value in Celcious:"); scanf("%f",&a); float k=a+273; gotoxy(3,24); printf("Value in Kelvin:%f",k); break; case '2': gotoxy(3,22); printf("Input value in Kelvin:"); scanf("%f",&a); float c=a-273; gotoxy(3,24); printf("Value in Celcious:%f",c); break; default : gotoxy(3,22); printf("Wrong selection."); } } if(x>30&&x<300&&y>220&&y<250) //C to R { float a; gotoxy(3,22); printf("Celcious to Rankine press 1"); gotoxy(3,24); printf("Rankine to Celcious press 2"); char ch=getche(); setfillstyle(1,0); bar(5,330,getmaxx()-5,420); //bar4 switch(ch) { case '1': gotoxy(3,22); printf("Input value in Celcious:"); scanf("%f",&a); float r=(a*1.8)+492; gotoxy(3,24); printf("Value in Rankine:%f",r); break; case '2': gotoxy(3,22); printf("Input value in Rankine:"); scanf("%f",&a); float c=(a-492)/1.8; gotoxy(3,24); printf("Value in Celcious:%f",c); break; default : gotoxy(3,22); printf("Wrong selection."); } } if(x>330&&x<600&&y>80&&y<110) //F to K { float a; gotoxy(3,22); printf("Fahrenheit to Kelvin press 1"); gotoxy(3,24); printf("Kelvin to Fahrenheit press 2"); char ch=getche(); setfillstyle(1,0); bar(5,330,getmaxx()-5,420); //bar4 switch(ch) { case '1': gotoxy(3,22); printf("Input value in Fahrenheit:"); scanf("%f",&a); float k=(a-32)/1.8+273; gotoxy(3,24); printf("Value in Kelvin:%f",k); break; case '2': gotoxy(3,22); printf("Input value in Kelvin:"); scanf("%f",&a); float f=(a-273)*1.8+32; gotoxy(3,24); printf("Value in Fahrenheit:%f",f); break; default : gotoxy(3,22); printf("Wrong selection."); } } if(x>330&&x<600&&y>150&&y<180) //F to R { float a; gotoxy(3,22); printf("Fahrenheit to Rankine press 1"); gotoxy(3,24); printf("Rankine to Fahrenheit press 2"); char ch=getche(); setfillstyle(1,0); bar(5,330,getmaxx()-5,420); //bar4 switch(ch) { case '1': gotoxy(3,22); printf("Input value in Fahrenheit:"); scanf("%f",&a); float r=a+460; gotoxy(3,24); printf("Value in Rankine:%f",r); break; case '2': gotoxy(3,22); printf("Input value in Rankine:"); scanf("%f",&a); float f=a-460; gotoxy(3,24); printf("Value in Fahrenheit:%f",f); break; default : gotoxy(3,22); printf("Wrong selection."); } } if(x>330&&x<600&&y>220&&y<250) //K to R { float a; gotoxy(3,22); printf("Kelvin to Rankine press 1"); gotoxy(3,24); printf("Rankine to Kelvin press 2"); char ch=getche(); setfillstyle(1,0); bar(5,330,getmaxx()-5,420); //bar4 switch(ch) { case '1': gotoxy(3,22); printf("Input value in Kelvin:"); scanf("%f",&a); float r=(a-273)*1.8+492; gotoxy(3,24); printf("Value in Rankine:%f",r); break; case '2': gotoxy(3,22); printf("Input value in Rankine:"); scanf("%f",&a); float k=(a-492)/1.8+273; gotoxy(3,24); printf("Value in Kelvin:%f",k); break; default : gotoxy(3,22); printf("Wrong selection."); } } if(x>(getmaxx()-80)&&y>267&&x<(getmaxx()-10)&&y<292) //back window(); //back if(x>450&&x<550&&y>305&&y<323) //clear { setfillstyle(1,0); bar(5,330,getmaxx()-5,420); //bar4 } if(x>(getmaxx()-20)&&x<(getmaxx()-5)&&y>5&&y<20) exit(0); } } } void length() { mouse_off(); int x,y; setfillstyle(1,1); bar(5,55,getmaxx()-5,297); setfillstyle(1,8); bar(200,65,430,95); bar(200,105,430,135); bar(200,145,430,175); bar(200,185,430,215); bar(200,225,430,255); bar(getmaxx()-80,267,getmaxx()-10,292); //back settextstyle(7,0,2); setcolor(15); outtextxy(220,65,"Mile to Kilo-Metre"); outtextxy(220,105,"Yard to Metre"); outtextxy(220,145,"Foot to Metre"); outtextxy(220,185,"Foot to Centi-Metre"); outtextxy(217,225,"Inch to Centi-Metre"); outtextxy(getmaxx()-70,267,"Back"); mouse_on(); while(1) { if(left_button_pressed()) { get_position(&x,&y); if(x>200&&x<430&&y>65&&y<95) //mile to km { float a,b; gotoxy(3,22); printf("Mile to KM press 1"); gotoxy(3,24); printf("KM to Mile press 2"); char ch=getche(); setfillstyle(1,0); bar(5,330,getmaxx()-5,420); //bar4 switch(ch) { case '1': gotoxy(3,22); printf("Input value in Mile:"); scanf("%f",&a); b=a*1.609; gotoxy(3,24); printf("Value in KM:%f",b); break; case '2': gotoxy(3,22); printf("Input value in KM:"); scanf("%f",&a); b=a*0.621504; gotoxy(3,24); printf("Value in Mile:%f",b); break; default : gotoxy(3,22); printf("Wrong selection."); } } if(x>200&&x<430&&y>105&&y<135) //yard to metre { float a,b; gotoxy(3,22); printf("Yard to Metre press 1"); gotoxy(3,24); printf("Metre to Yard press 2"); char ch=getche(); setfillstyle(1,0); bar(5,330,getmaxx()-5,420); //bar4 switch(ch) { case '1': gotoxy(3,22); printf("Input value in Yard:"); scanf("%f",&a); b=a*.9144; gotoxy(3,24); printf("Value in Metre:%f",b); break; case '2': gotoxy(3,22); printf("Input value in Metre:"); scanf("%f",&a); b=a*1.0936133; gotoxy(3,24); printf("Value in Yard:%f",b); break; default : gotoxy(3,22); printf("Wrong selection."); } } if(x>200&&x<430&&y>145&&y<175) //foot to metre { float a,b; gotoxy(3,22); printf("Foot to metre press 1"); gotoxy(3,24); printf("Metre to Foot press 2"); char ch=getche(); setfillstyle(1,0); bar(5,330,getmaxx()-5,420); //bar4 switch(ch) { case '1': gotoxy(3,22); printf("Input value in Foot:"); scanf("%f",&a); b=a*.3048; gotoxy(3,24); printf("Value in Metre:%f",b); break; case '2': gotoxy(3,22); printf("Input value in Metre:"); scanf("%f",&a); b=a*3.2808399; gotoxy(3,24); printf("Value in Foot:%f",b); break; default : gotoxy(3,22); printf("Wrong selection."); } } if(x>200&&x<430&&y>185&&y<215) //foot to cm { float a,b; gotoxy(3,22); printf("Foot to CM press 1"); gotoxy(3,24); printf("CM to Foot press 2"); char ch=getche(); setfillstyle(1,0); bar(5,330,getmaxx()-5,420); //bar4 switch(ch) { case '1': gotoxy(3,22); printf("Input value in Foot:"); scanf("%f",&a); b=a*30.48; gotoxy(3,24); printf("Value in CM:%f",b); break; case '2': gotoxy(3,22); printf("Input value in CM:"); scanf("%f",&a); b=a*.0328084; gotoxy(3,24); printf("Value in Foot:%f",b); break; default : gotoxy(3,22); printf("Wrong selection."); } } if(x>200&&x<430&&y>225&&y<255) //inch to cm { float a,b; gotoxy(3,22); printf("Inch to CM press 1"); gotoxy(3,24); printf("CM to Inch press 2"); char ch=getche(); setfillstyle(1,0); bar(5,330,getmaxx()-5,420); //bar4 switch(ch) { case '1': gotoxy(3,22); printf("Input value in Inch:"); scanf("%f",&a); b=a*2.54; gotoxy(3,24); printf("Value in CM:%f",b); break; case '2': gotoxy(3,22); printf("Input value in CM:"); scanf("%f",&a); b=a*.3937008; gotoxy(3,24); printf("Value in Inch:%f",b); break; default : gotoxy(3,22); printf("Wrong selection."); } } if(x>(getmaxx()-80)&&y>267&&x<(getmaxx()-10)&&y<292) //back window(); //back if(x>450&&x<550&&y>305&&y<323) //clear { setfillstyle(1,0); bar(5,330,getmaxx()-5,420); //bar4 } if(x>(getmaxx()-20)&&x<(getmaxx()-5)&&y>5&&y<20) exit(0); } } } void waight() { mouse_off(); int x,y; setfillstyle(1,1); bar(5,55,getmaxx()-5,297); setfillstyle(1,8); bar(200,65,430,95); bar(200,105,430,135); bar(200,145,430,175); bar(200,185,430,215); bar(200,225,430,255); bar(getmaxx()-80,267,getmaxx()-10,292); //back settextstyle(7,0,2); setcolor(15); outtextxy(220,65,"Pound to Kilo"); outtextxy(220,105,"Carat to Gram"); outtextxy(220,145,"Ounce to Gram"); outtextxy(220,185,"Troy oz. to Gram"); outtextxy(217,225,"Stone to Kilo"); outtextxy(getmaxx()-70,267,"Back"); mouse_on(); while(1) { if(left_button_pressed()) { get_position(&x,&y); if(x>200&&x<430&&y>65&&y<95) //pound to kilo { float a,b; gotoxy(3,22); printf("Pound to Kilo press 1"); gotoxy(3,24); printf("Kilo to Pound press 2"); char ch=getche(); setfillstyle(1,0); bar(5,330,getmaxx()-5,420); //bar4 switch(ch) { case '1': gotoxy(3,22); printf("Input value in Pound:"); scanf("%f",&a); b=a*.4536; gotoxy(3,24); printf("Value in Kilo:%f",b); break; case '2': gotoxy(3,22); printf("Input value in Kilo:"); scanf("%f",&a); b=a*2.2045955; gotoxy(3,24); printf("Value in Pound:%f",b); break; default : gotoxy(3,22); printf("Wrong selection."); } } if(x>200&&x<430&&y>105&&y<135) //carat to gram { float a,b; gotoxy(3,22); printf("Carat to Gram press 1"); gotoxy(3,24); printf("Gram to Carat press 2"); char ch=getche(); setfillstyle(1,0); bar(5,330,getmaxx()-5,420); //bar4 switch(ch) { case '1': gotoxy(3,22); printf("Input value in Carat:"); scanf("%f",&a); b=a*.2; gotoxy(3,24); printf("Value in Gram:%f",b); break; case '2': gotoxy(3,22); printf("Input value in Gram:"); scanf("%f",&a); b=a*5; gotoxy(3,24); printf("Value in Carat:%f",b); break; default : gotoxy(3,22); printf("Wrong selection."); } } if(x>200&&x<430&&y>145&&y<175) //ounce to gram { float a,b; gotoxy(3,22); printf("Ounce to Gram press 1"); gotoxy(3,24); printf("Gram to Ounce press 2"); char ch=getche(); setfillstyle(1,0); bar(5,330,getmaxx()-5,420); //bar4 switch(ch) { case '1': gotoxy(3,22); printf("Input value in Ounce:"); scanf("%f",&a); b=a*28.35; gotoxy(3,24); printf("Value in Gram:%f",b); break; case '2': gotoxy(3,22); printf("Input value in Gram:"); scanf("%f",&a); b=a*.0352734; gotoxy(3,24); printf("Value in Ounce:%f",b); break; default : gotoxy(3,22); printf("Wrong selection."); } } if(x>200&&x<430&&y>185&&y<215) // troy.oz to gram { float a,b; gotoxy(3,22); printf("Troy.oz to Gram press 1"); gotoxy(3,24); printf("Gram to Troy.oz press 2"); char ch=getche(); setfillstyle(1,0); bar(5,330,getmaxx()-5,420); //bar4 switch(ch) { case '1': gotoxy(3,22); printf("Input value in Troy.oz:"); scanf("%f",&a); b=a*31.103477; gotoxy(3,24); printf("Value in Gram:%f",b); break; case '2': gotoxy(3,22); printf("Input value in Gram:"); scanf("%f",&a); b=a*.0321507; gotoxy(3,24); printf("Value in Troy.oz:%f",b); break; default : gotoxy(3,22); printf("Wrong selection."); } } if(x>200&&x<430&&y>225&&y<255) //stone to kilo { float a,b; gotoxy(3,22); printf("Stone to Kilo press 1"); gotoxy(3,24); printf("Kilo to Stone press 2"); char ch=getche(); setfillstyle(1,0); bar(5,330,getmaxx()-5,420); //bar4 switch(ch) { case '1': gotoxy(3,22); printf("Input value in Stone:"); scanf("%f",&a); b=a*6.3502932; gotoxy(3,24); printf("Value in Kilo:%f",b); break; case '2': gotoxy(3,22); printf("Input value in Kilo:"); scanf("%f",&a); b=a*.157473; gotoxy(3,24); printf("Value in Stone:%f",b); break; default : gotoxy(3,22); printf("Wrong selection."); } } if(x>(getmaxx()-80)&&y>267&&x<(getmaxx()-10)&&y<292) //back window(); //back if(x>450&&x<550&&y>305&&y<323) //clear { setfillstyle(1,0); bar(5,330,getmaxx()-5,420); //bar4 } if(x>(getmaxx()-20)&&x<(getmaxx()-5)&&y>5&&y<20) exit(0); } } } void area() { mouse_off(); int x,y; setfillstyle(1,1); bar(5,55,getmaxx()-5,297); setfillstyle(1,8); bar(150,65,500,95); bar(150,105,500,135); bar(150,145,500,175); bar(150,185,500,215); bar(150,225,500,255); bar(getmaxx()-80,267,getmaxx()-10,292); //back settextstyle(7,0,2); setcolor(15); outtextxy(170,65,"Square Foot to Square Metre"); outtextxy(170,105,"Square Inch to Square CM"); outtextxy(170,145,"Square Yard to Square Metre"); outtextxy(170,185,"Square Milw to Square KM"); outtextxy(170,225,"Acre to Hectare"); outtextxy(getmaxx()-70,267,"Back"); mouse_on(); while(1) { if(left_button_pressed()) { get_position(&x,&y); if(x>150&&x<500&&y>65&&y<95) //s foot to s metre { float a,b; gotoxy(3,22); printf("Square Foot to Square Metre press 1"); gotoxy(3,24); printf("Square Metre to Square Foot press 2"); char ch=getche(); setfillstyle(1,0); bar(5,330,getmaxx()-5,420); //bar4 switch(ch) { case '1': gotoxy(3,22); printf("Input value in Square Foot:"); scanf("%f",&a); b=a*.0929; gotoxy(3,24); printf("Value in Square Metre:%f",b); break; case '2': gotoxy(3,22); printf("Input value in Square Metre:"); scanf("%f",&a); b=a*10.764263; gotoxy(3,24); printf("Value in Square Foot:%f",b); break; default : gotoxy(3,22); printf("Wrong selection."); } } if(x>150&&x<500&&y>105&&y<135) //s inch to s cm { float a,b; gotoxy(3,22); printf("Square Inch to Square CM press 1"); gotoxy(3,24); printf("Square CM to Square Inch press 2"); char ch=getche(); setfillstyle(1,0); bar(5,330,getmaxx()-5,420); //bar4 switch(ch) { case '1': gotoxy(3,22); printf("Input value in Square Inch:"); scanf("%f",&a); b=a*6.4516; gotoxy(3,24); printf("Value in Square CM:%f",b); break; case '2': gotoxy(3,22); printf("Input value in Square CM:"); scanf("%f",&a); gotoxy(3,24); b=a*.1550003; printf("Value in Square Inch:%f",b); break; default : gotoxy(3,22); printf("Wrong selection."); } } if(x>150&&x<500&&y>145&&y<175) //s yard to s metre { float a,b; gotoxy(3,22); printf("Square Yard to Square Metre press 1"); gotoxy(3,24); printf("Square Metre to Square Yard press 2"); char ch=getche(); setfillstyle(1,0); bar(5,330,getmaxx()-5,420); //bar4 switch(ch) { case '1': gotoxy(3,22); printf("Input value in Square Yard:"); scanf("%f",&a); b=a*.8361274; gotoxy(3,24); printf("Value in Square Metre:%f",b); break; case '2': gotoxy(3,22); printf("Input value in Square Metre:"); scanf("%f",&a); b=a*1.19599; gotoxy(3,24); printf("Value in Square Yard:%f",b); break; default : gotoxy(3,22); printf("Wrong selection."); } } if(x>150&&x<500&&y>185&&y<215) //s mile to s km { float a,b; gotoxy(3,22); printf("Square Mile to Square KM press 1"); gotoxy(3,24); printf("Square KM to Square Mile press 2"); char ch=getche(); setfillstyle(1,0); bar(5,330,getmaxx()-5,420); //bar4 switch(ch) { case '1': gotoxy(3,22); printf("Input value in Square Mile:"); scanf("%f",&a); b=a*2.59; gotoxy(3,24); printf("Value in Square KM:%f",b); break; case '2': gotoxy(3,22); printf("Input value in Square KM:"); scanf("%f",&a); b=a*.3861004; gotoxy(3,24); printf("Value in Square Mile:%f",b); break; default : gotoxy(3,22); printf("Wrong selection."); } } if(x>150&&x<500&&y>225&&y<255) //acre to hectare { float a,b; gotoxy(3,22); printf("Acre to Hectare press 1"); gotoxy(3,24); printf("Hectare to Acre press 2"); char ch=getche(); setfillstyle(1,0); bar(5,330,getmaxx()-5,420); //bar4 switch(ch) { case '1': gotoxy(3,22); printf("Input value in Acre:"); scanf("%f",&a); b=a*.4047; gotoxy(3,24); printf("Value in Hectare:%f",b); break; case '2': gotoxy(3,22); printf("Input value in Hectare:"); scanf("%f",&a); b=a*2.4709661; gotoxy(3,24); printf("Value in Acre:%f",b); break; default : gotoxy(3,22); printf("Wrong selection."); } } if(x>(getmaxx()-80)&&y>267&&x<(getmaxx()-10)&&y<292) //back window(); //back if(x>450&&x<550&&y>305&&y<323) //clear { setfillstyle(1,0); bar(5,330,getmaxx()-5,420); //bar4 } if(x>(getmaxx()-20)&&x<(getmaxx()-5)&&y>5&&y<20) exit(0); } } } void volume() { mouse_off(); int x,y; setfillstyle(1,1); bar(5,55,getmaxx()-5,297); setfillstyle(1,8); bar(200,70,430,100); bar(200,115,430,145); bar(200,160,430,190); bar(200,205,430,235); bar(getmaxx()-80,267,getmaxx()-10,292); //back settextstyle(7,0,2); setcolor(15); outtextxy(220,70,"V Inch to V CM"); outtextxy(220,115,"V Foot to V Metre"); outtextxy(220,160,"V Metre to V Yard"); outtextxy(220,205,"Gallon to Litre"); outtextxy(getmaxx()-70,267,"Back"); mouse_on(); while(1) { if(left_button_pressed()) { get_position(&x,&y); if(x>200&&x<430&&y>70&&y<100) // v inch to v cm { float a,b; gotoxy(3,22); printf("Cubic Inch to Cubic CM press 1"); gotoxy(3,24); printf("Cubic CM to Cubic Inch press 2"); char ch=getche(); setfillstyle(1,0); bar(5,330,getmaxx()-5,420); //bar4--output bar switch(ch) { case '1': gotoxy(3,22); printf("Input value in Cubic Inch:"); scanf("%f",&a); b=a*16.387064; gotoxy(3,24); printf("Value in Cubic CM:%f",b); break; case '2': gotoxy(3,22); printf("Input value in Cubic CM:"); scanf("%f",&a); b=a*.0610237; gotoxy(3,24); printf("Value in Cubic Inch:%f",b); break; default : gotoxy(3,22); printf("Wrong selection."); } } if(x>200&&x<430&&y>115&&y<145) //v foot to v metre { float a,b; gotoxy(3,22); printf("Cubic Foot to Cubic Metre press 1"); gotoxy(3,24); printf("Cubic Metre to Cubic Foot press 2"); char ch=getche(); setfillstyle(1,0); bar(5,330,getmaxx()-5,420); //bar4 switch(ch) { case '1': gotoxy(3,22); printf("Input value in Cubic Foot:"); scanf("%f",&a); b=a*.0283168; gotoxy(3,24); printf("Value in Cubic Metre:%f",b); break; case '2': gotoxy(3,22); printf("Input value in Cubic Metre:"); scanf("%f",&a); b=a*35.314667; gotoxy(3,24); printf("Value in Cubic Foot:%f",b); break; default : gotoxy(3,22); printf("Wrong selection."); } } if(x>200&&x<430&&y>160&&y<190) //v metre to v yard { float a,b; gotoxy(3,22); printf("Cubic Metre to Cubic Yard press 1"); gotoxy(3,24); printf("Cubic Yard to Cubic Metre press 2"); char ch=getche(); setfillstyle(1,0); bar(5,330,getmaxx()-5,420); //bar4 switch(ch) { case '1': gotoxy(3,22); printf("Input value in Cubic Metre:"); scanf("%f",&a); b=a*1.3079505; gotoxy(3,24); printf("Value in Cubic Yard:%f",b); break; case '2': gotoxy(3,22); printf("Input value in Cubic Yard:"); scanf("%f",&a); b=a*.7645549; gotoxy(3,24); printf("Value in Cubic Metre:%f",b); break; default : gotoxy(3,22); printf("Wrong selection."); } } if(x>200&&x<430&&y>205&&y<235) // gallon to litre { float a,b; gotoxy(3,22); printf("Gallon to Litre press 1"); gotoxy(3,24); printf("Litre to Gallon press 2"); char ch=getche(); setfillstyle(1,0); bar(5,330,getmaxx()-5,420); //bar4 switch(ch) { case '1': gotoxy(3,22); printf("Input value in Gallon:"); scanf("%f",&a); b=a*3.78541; gotoxy(3,24); printf("Value in Litre:%f",b); break; case '2': gotoxy(3,22); printf("Input value in Litre:"); scanf("%f",&a); b=a*.2641722; gotoxy(3,24); printf("Value in Gallon:%f",b); break; default : gotoxy(3,22); printf("Wrong selection."); } } if(x>(getmaxx()-80)&&y>267&&x<(getmaxx()-10)&&y<292) //back window(); //back if(x>450&&x<550&&y>305&&y<323) //clear { setfillstyle(1,0); bar(5,330,getmaxx()-5,420); //bar4 } if(x>(getmaxx()-20)&&x<(getmaxx()-5)&&y>5&&y<20) exit(0); } } } void num_sys() { mouse_off(); int x,y; setfillstyle(1,1); bar(5,55,getmaxx()-5,297); setfillstyle(1,8); bar(30,80,300,110); // bar(330,80,600,110); // bar(30,150,300,180); // bar(330,150,600,180); // bar(30,220,300,250); // bar(330,220,600,250); // bar(getmaxx()-80,267,getmaxx()-10,292); //back settextstyle(7,0,2); setcolor(15); outtextxy(50,80,"Decimal to Binary"); outtextxy(40,150,"Decimal to Hexadecimal"); outtextxy(50,220,"Decimal to Octal"); outtextxy(340,80,"Binary to Hexadecimal"); outtextxy(350,150,"Binary to Octal"); outtextxy(350,220,"Hexadecimal to Octal"); outtextxy(getmaxx()-70,267,"Back"); mouse_on(); while(1) { if(left_button_pressed()) { get_position(&x,&y); if(x>30&&x<300&&y>80&&y<110) // decimal to binary { int a; gotoxy(3,22); printf("Decimal to Binary press 1"); gotoxy(3,24); printf("Binary to Decimal press 2"); char ch=getche(); setfillstyle(1,0); bar(5,330,getmaxx()-5,420); //bar4 switch(ch) { case '1': gotoxy(3,22); printf("Input value in Decimal:"); scanf("%d",&a); int arr[100],i=0; while(a!=0) { arr[i]=a%2; a/=2; i++; } gotoxy(3,24); printf("Value in Binary:"); for(int j=i-1;j>=0;j--) printf("%d",arr[j]); break; case '2': gotoxy(3,22); printf("Input value in Binary:"); scanf("%d",&a); gotoxy(3,24); printf("Value in Decimal:%d",bin_to_dec(a)); break; default : gotoxy(3,22); printf("Wrong selection."); } } if(x>30&&x<300&&y>150&&y<180) //decimal to hexadecimal { int a; gotoxy(3,22); printf("Decimal to Hexadecimal press 1"); gotoxy(3,24); printf("Hexadecimal to Decimal press 2"); char ch=getche(); setfillstyle(1,0); bar(5,330,getmaxx()-5,420); //bar4 switch(ch) { case '1': gotoxy(3,22); printf("Input value in Decimal:"); scanf("%d",&a); gotoxy(3,24); printf("Value in Hexadecimal:%X",a); break; case '2': gotoxy(3,22); printf("Input value in Hexadecimal:"); scanf("%X",&a); gotoxy(3,24); printf("Value in Decimal:%d",a); break; default : gotoxy(3,22); printf("Wrong selection."); } } if(x>30&&x<300&&y>220&&y<250) // decimal to octal { int a; gotoxy(3,22); printf("Decimal to Octal press 1"); gotoxy(3,24); printf("Octal to Decimal press 2"); char ch=getche(); setfillstyle(1,0); bar(5,330,getmaxx()-5,420); //bar4 switch(ch) { case '1': gotoxy(3,22); printf("Input value in Decimal:"); scanf("%d",&a); gotoxy(3,24); printf("Value in Octal:%o",a); break; case '2': gotoxy(3,22); printf("Input value in Octal:"); scanf("%o",&a); gotoxy(3,24); printf("Value in Decimal:%d",a); break; default : gotoxy(3,22); printf("Wrong selection."); } } if(x>330&&x<600&&y>80&&y<110) // binary to hexadecimal { int a; gotoxy(3,22); printf("Binary to Hexadecimal press 1"); gotoxy(3,24); printf("Hexadecimal to Binary press 2"); char ch=getche(); setfillstyle(1,0); bar(5,330,getmaxx()-5,420); //bar4 switch(ch) { case '1': gotoxy(3,22); printf("Input value in Binary:"); scanf("%d",&a); int p=bin_to_dec(a); gotoxy(3,24); printf("Value in Hexadecimal:%X",p); break; case '2': gotoxy(3,22); printf("Input value in Hexadecimal:"); scanf("%X",&a); int arr[100],i=0; while(a!=0) { arr[i]=a%2; a/=2; i++; } gotoxy(3,24); printf("Value in Binary:"); for(int j=i-1;j>=0;j--) printf("%d",arr[j]); break; default : gotoxy(3,22); printf("Wrong selection."); } } if(x>330&&x<600&&y>150&&y<180) // binary to octal { int a; gotoxy(3,22); printf("Binary to Octal press 1"); gotoxy(3,24); printf("Octal to Binary press 2"); char ch=getche(); setfillstyle(1,0); bar(5,330,getmaxx()-5,420); //bar4 switch(ch) { case '1': gotoxy(3,22); printf("Input value in Binary:"); scanf("%d",&a); int p=bin_to_dec(a); gotoxy(3,24); printf("Value in Octal:%o",p); break; case '2': gotoxy(3,22); printf("Input value in Octal:"); scanf("%o",&a); int arr[100],i=0; while(a!=0) { arr[i]=a%2; a/=2; i++; } gotoxy(3,24); printf("Value in Binary:"); for(int j=i-1;j>=0;j--) printf("%d",arr[j]); break; default : gotoxy(3,22); printf("Wrong selection."); } } if(x>330&&x<600&&y>220&&y<250) //hexadecimal to octal { int a; gotoxy(3,22); printf("Hexadecimal to Octal press 1"); gotoxy(3,24); printf("Octal to Hexadecimal press 2"); char ch=getche(); setfillstyle(1,0); bar(5,330,getmaxx()-5,420); //bar4 switch(ch) { case '1': gotoxy(3,22); printf("Input value in Hexadecimal:"); scanf("%X",&a); gotoxy(3,24); printf("Value in Octal:%o",a); break; case '2': gotoxy(3,22); printf("Input value in Octal:"); scanf("%o",&a); gotoxy(3,24); printf("Value in Hexadecimal:%X",a); break; default : gotoxy(3,22); printf("Wrong selection."); } } if(x>(getmaxx()-80)&&y>267&&x<(getmaxx()-10)&&y<292) //back window(); //back if(x>450&&x<550&&y>305&&y<323) //clear { setfillstyle(1,0); bar(5,330,getmaxx()-5,420); //bar4 } if(x>(getmaxx()-20)&&x<(getmaxx()-5)&&y>5&&y<20) exit(0); } } } void trigon() { } void help() { } int bin_to_dec(int num) { int a[100],i=0,j=0,sum=0; while(num!=0) { a[i]=num%10; num/=10;i++; } for(j=0;j<i;j++) sum+=a[j]*pow(2,j); return sum; } void date_show() { char *wday[]={"Sunday","Monday","Tuesday","Wednasday","Thursday","Friday","Saturday","Unknown"}; struct date d; getdate(&d); gotoxy(10,28); //printf("%d:%d:%d",d.da_day,d.da_mon,d.da_year); char *str1,*str2,*str3; //date showing gcvt(d.da_day,5,str1); gcvt(d.da_mon,5,str2); gcvt(d.da_year,5,str3); setcolor(4); outtextxy(getmaxx()-200,getmaxy()-55,str1); outtextxy(getmaxx()-170,getmaxy()-55,"-"); outtextxy(getmaxx()-145,getmaxy()-55,str2); outtextxy(getmaxx()-130,getmaxy()-55,"-"); outtextxy(getmaxx()-115,getmaxy()-55,str3); struct tm time_check; //name of the day time_check.tm_year=d.da_year-1900; time_check.tm_mon=d.da_mon-1; time_check.tm_mday=d.da_day; time_check.tm_hour=0; time_check.tm_min=0; time_check.tm_sec=1; time_check.tm_isdst=-1; if(mktime(&time_check)==-1) time_check.tm_wday=7; setcolor(4); outtextxy(getmaxx()-185,getmaxy()-35,wday[time_check.tm_wday]); } void mouse_reset() { union REGS r; r.x.ax=0; int86(0x33,&r,&r); if(int(r.x.ax)!=-1) { printf("Hardware failure!"); exit(1); } } void mouse_on() { union REGS r; r.x.ax=1; int86(0x33,&r,&r); } void mouse_off() { union REGS r; r.x.ax=2; int86(0x33,&r,&r); } void get_position(int *x,int *y) { union REGS r; r.x.ax=3; int86(0x33,&r,&r); *x=r.x.cx; *y=r.x.dx; } int left_button_pressed() { union REGS r; r.x.ax=3; int86(0x33,&r,&r); return(r.x.bx & 1); }
[ "monowar.mbstu@gmail.com" ]
monowar.mbstu@gmail.com
0a15ddd180ab1e638b5ce1bec1448260693e7340
5a157ee5838918ef1fe6624cdbcd9d5408e498e8
/BOJ/10828.cpp
28ca40bf5ee89ef45c76da5a360e239288619d35
[]
no_license
rlagksruf16/Algorithm_Everyday
93e1071ef667e0a3417104cb1d6f14a5f39967ae
cf9032a04d8be7732a71b874dde124e0cb06421e
refs/heads/master
2023-06-22T01:55:20.751238
2021-07-15T08:01:48
2021-07-15T08:01:48
217,672,321
0
0
null
null
null
null
UTF-8
C++
false
false
959
cpp
// simple stack algorithm #include <iostream> #include <algorithm> #include <stack> using namespace std; int main() { stack<int>s; int N; string a; int num; cin >> N; for(int i = 0; i < N; i++) { cin >> a; if(a == "push") { cin >> num; s.push(num); } else if( a == "pop") { if(s.empty() == 1) cout << -1 << endl; else { cout << s.top() << endl; s.pop(); } } else if( a == "top") { if(s.empty() == 1) cout << -1 << endl; else cout << s.top() << endl; } else if( a == "size") { cout << s.size() << endl; } else if( a == "empty") { cout << s.empty() << endl; } } return 0; }
[ "rlagksruf16@gmail.com" ]
rlagksruf16@gmail.com
f11bc13d424a9759e7ffc98aae4a70eddd98a40d
cf8ddfc720bf6451c4ef4fa01684327431db1919
/SDK/ARKSurvivalEvolved_OptionsMenu_classes.hpp
72926078277a533dff3320c36d35678ef476151f
[ "MIT" ]
permissive
git-Charlie/ARK-SDK
75337684b11e7b9f668da1f15e8054052a3b600f
c38ca9925309516b2093ad8c3a70ed9489e1d573
refs/heads/master
2023-06-20T06:30:33.550123
2021-07-11T13:41:45
2021-07-11T13:41:45
null
0
0
null
null
null
null
UTF-8
C++
false
false
48,172
hpp
#pragma once // ARKSurvivalEvolved (329.9) SDK #ifdef _MSC_VER #pragma pack(push, 0x8) #endif #include "ARKSurvivalEvolved_OptionsMenu_structs.hpp" namespace sdk { //--------------------------------------------------------------------------- //Classes //--------------------------------------------------------------------------- // WidgetBlueprintGeneratedClass OptionsMenu.OptionsMenu_C // 0x07AE (0x1106 - 0x0958) class UOptionsMenu_C : public UUI_OptionsMenu { public: class UWidgetAnimation* FadeIn; // 0x0958(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UWidgetAnimation* FadeOut; // 0x0960(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UWidgetAnimation* Close; // 0x0968(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UWidgetAnimation* Open; // 0x0970(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UKeyInputWidget* AccessInventory; // 0x0978(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UCustomButtonWidget* AdvancedSettingsMenuButton; // 0x0980(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UCheckBox* AllowAnimationStaggeringCheckbox; // 0x0988(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UCheckBox* AllowCrosshairCheckbox; // 0x0990(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UCheckBox* AllowEnhancedDistanceDetailModeCheckbox; // 0x0998(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UCheckBox* AllowHitMarkersCheckbox; // 0x09A0(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UKeyInputWidget* AltFire; // 0x09A8(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class USlider* AmbientSoundVolumeSlider; // 0x09B0(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UComboBoxString* AntiAliasingComboBox; // 0x09B8(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UCustomButtonWidget* ApplyButton; // 0x09C0(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class USlider* AudioVolumeSlider; // 0x09C8(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UKeyInputWidget* BrakeDino; // 0x09D0(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UKeyInputWidget* CallAggressive; // 0x09D8(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UKeyInputWidget* CallAttackTarget; // 0x09E0(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UKeyInputWidget* CallFollow; // 0x09E8(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UKeyInputWidget* CallFollowDistanceCycleOne; // 0x09F0(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UKeyInputWidget* CallFollowOne; // 0x09F8(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UKeyInputWidget* CallLandOne; // 0x0A00(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UKeyInputWidget* CallMoveTo; // 0x0A08(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UKeyInputWidget* CallNeutral; // 0x0A10(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UKeyInputWidget* CallPassive; // 0x0A18(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UKeyInputWidget* CallSetAggressive; // 0x0A20(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UKeyInputWidget* CallStay; // 0x0A28(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UKeyInputWidget* CallStayOne; // 0x0A30(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UCheckBox* CameraBobCheckbox; // 0x0A38(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class USlider* CameraShakeScaleSlider; // 0x0A40(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UCustomButtonWidget* CancelButton; // 0x0A48(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UKeyInputWidget* CancelOrder; // 0x0A50(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UKeyInputWidget* CenterPlayer; // 0x0A58(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UKeyInputWidget* CenterSelection; // 0x0A60(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UKeyInputWidget* CharacterActionWheel; // 0x0A68(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class USlider* CharacterSlider; // 0x0A70(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UCheckBox* ChatBubblesCheckbox; // 0x0A78(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UCheckBox* ChatShowSteamNameCheckbox; // 0x0A80(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UCheckBox* ChatShowTribeNameCheckbox; // 0x0A88(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UComboBoxString* ClientNetSpeedComboBox; // 0x0A90(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UButton* CloseGamepadControlsButton; // 0x0A98(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UCheckBox* ColorizedItemNamesCheckbox; // 0x0AA0(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UImage* CreatureBottomBorder; // 0x0AA8(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UImage* CreatureTopBorder; // 0x0AB0(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UKeyInputWidget* Crouch; // 0x0AB8(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UCheckBox* DefaultCharacterItemsCheckbox; // 0x0AC0(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UCheckBox* DisableBloomCheckbox; // 0x0AC8(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UCheckBox* DisableLightShaftsCheckbox; // 0x0AD0(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UCheckBox* DisableMenuMusicCheckbox; // 0x0AD8(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UCheckBox* DisableMenuTransitionsCheckbox; // 0x0AE0(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UCheckBox* DisableSubtitlesCheckbox; // 0x0AE8(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UCheckBox* DisableTorporEffectCheckbox; // 0x0AF0(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UCheckBox* DisableTPVCameraInterpolationCheckbox; // 0x0AF8(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UCheckBox* DistanceFieldShadowingCheckbox; // 0x0B00(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UKeyInputWidget* Drag; // 0x0B08(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UKeyInputWidget* DropItem; // 0x0B10(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UCheckBox* DynamicTessCheckbox; // 0x0B18(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UKeyInputWidget* EmoteKey1; // 0x0B20(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UKeyInputWidget* EmoteKey2; // 0x0B28(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UCheckBox* EnableBloodEffectsCheckbox; // 0x0B30(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UCheckBox* EnableColorGradingCheckbox; // 0x0B38(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UCustomButtonWidget* EnableHMDButton; // 0x0B40(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UCheckBox* ExtraLevelStreamingDistanceCheckbox; // 0x0B48(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UCheckBox* FilmGrainCheckbox; // 0x0B50(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UKeyInputWidget* Fire; // 0x0B58(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UCheckBox* FirstPersonRidingCheckbox; // 0x0B60(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UCheckBox* FloatingNamesCheckbox; // 0x0B68(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UKeyInputWidget* ForceCraftButton; // 0x0B70(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UCheckBox* ForceTPVCameraOffsetCheckbox; // 0x0B78(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class USlider* FOVSlider; // 0x0B80(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UImage* FrontOverlayAdditive; // 0x0B88(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UButton* GamepadControlsButton; // 0x0B90(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UImage* GamepadIcon_NextMenu; // 0x0B98(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UImage* GamepadIcon_PrevMenu; // 0x0BA0(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UImage* GamepadImage; // 0x0BA8(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UCustomButtonWidget* GamepadMenuButton; // 0x0BB0(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UEditableTextBox* Gamma1Editbox; // 0x0BB8(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UEditableTextBox* Gamma2Editbox; // 0x0BC0(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UKeyInputWidget* GiveDefaultWeapon; // 0x0BC8(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UComboBoxString* GraphicsQualityComboBox; // 0x0BD0(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UBorder* GraphicsQualityHelpTooltip; // 0x0BD8(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class USlider* GroundClutterDensitySlider; // 0x0BE0(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class USlider* GroundClutterDistanceSlider; // 0x0BE8(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UKeyInputWidget* GroupAddOrRemoveTame; // 0x0BF0(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UEditableTextBox* HeightTextBox; // 0x0BF8(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UCheckBox* HideFloatingPlayerNamesCheckbox; // 0x0C00(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UCheckBox* HideGamepadItemSelectionModifierCheckbox; // 0x0C08(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UCheckBox* HideServerInfoCheckbox; // 0x0C10(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UCheckBox* HighQualityAnisotropicFilteringCheckbox; // 0x0C18(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UCheckBox* HighQualityLODsCheckbox; // 0x0C20(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UCheckBox* HighQualityMaterialsCheckbox; // 0x0C28(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UCheckBox* HighQualitySurfacesCheckbox; // 0x0C30(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UCheckBox* HighQualityVFXCheckbox; // 0x0C38(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UImage* Image_12; // 0x0C40(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UImage* Image_152; // 0x0C48(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UImage* Image_1545; // 0x0C50(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UImage* Image_1546; // 0x0C58(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UImage* Image_1586; // 0x0C60(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UImage* Image_2016; // 0x0C68(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UImage* Image_242; // 0x0C70(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UImage* Image_243; // 0x0C78(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UImage* Image_257; // 0x0C80(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UImage* Image_266; // 0x0C88(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UImage* Image_270; // 0x0C90(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UImage* Image_321; // 0x0C98(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UImage* Image_419; // 0x0CA0(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UImage* Image_537; // 0x0CA8(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UImage* Image_538; // 0x0CB0(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UImage* Image_55; // 0x0CB8(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UImage* Image_56; // 0x0CC0(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UImage* Image_59; // 0x0CC8(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UImage* Image_610; // 0x0CD0(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UImage* Image_64; // 0x0CD8(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UImage* Image_66; // 0x0CE0(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UImage* Image_67; // 0x0CE8(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UImage* Image_9; // 0x0CF0(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UImage* Image_93; // 0x0CF8(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UImage* Image_922; // 0x0D00(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UImage* Image_923; // 0x0D08(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UImage* Image_963; // 0x0D10(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UCheckBox* InventoryAccessSoundCheckbox; // 0x0D18(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UCheckBox* InvertMouse; // 0x0D20(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UKeyInputWidget* IssueOrder; // 0x0D28(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UCheckBox* JoinNotificationsCheckbox; // 0x0D30(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UKeyInputWidget* Jump; // 0x0D38(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UCustomButtonWidget* KeyBindingsMenuButton; // 0x0D40(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class USlider* LODScalarSlider; // 0x0D48(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UKeyInputWidget* LookDown; // 0x0D50(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class USlider* LookLeftRightSensitivitySlider; // 0x0D58(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UKeyInputWidget* LookUp; // 0x0D60(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class USlider* LookUpDownSensitivitySlider; // 0x0D68(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UCheckBox* LowQualityAnimationsCheckbox; // 0x0D70(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UCheckBox* MeleeCameraSwingAnimsCheckbox; // 0x0D78(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UCheckBox* MotionBlurCheckbox; // 0x0D80(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UKeyInputWidget* MoveBackward; // 0x0D88(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UKeyInputWidget* MoveForward; // 0x0D90(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class USlider* MusicSlider; // 0x0D98(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UCheckBox* NoTooltipDelayCheckbox; // 0x0DA0(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UKeyInputWidget* OpenMapMarkers; // 0x0DA8(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UCustomButtonWidget* OptionsMenuButton; // 0x0DB0(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UKeyInputWidget* OrbitCam; // 0x0DB8(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UKeyInputWidget* OrbitCamToggle; // 0x0DC0(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UCheckBox* PlayActionWheelClickSoundCheckbox; // 0x0DC8(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UKeyInputWidget* Poop; // 0x0DD0(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UComboBoxString* PostProcessingComboBox; // 0x0DD8(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UKeyInputWidget* Prone; // 0x0DE0(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UKeyInputWidget* PushToTalk; // 0x0DE8(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UCheckBox* QuickToggleItemNamesCheckbox; // 0x0DF0(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UKeyInputWidget* Reload; // 0x0DF8(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UCustomButtonWidget* RepositionHMDViewButton; // 0x0E00(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UCustomButtonWidget* ResetButton; // 0x0E08(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UCustomButtonWidget* ResetIntroCinematicsButton; // 0x0E10(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UButton* ResetTutorials; // 0x0E18(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class USlider* ResolutionScaleSlider; // 0x0E20(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UComboBoxString* ResolutionsComboBox; // 0x0E28(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UCustomButtonWidget* RTSMenuButton; // 0x0E30(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UKeyInputWidget* Run; // 0x0E38(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UKeyInputWidget* RunToggle; // 0x0E40(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UCustomButtonWidget* SaveButton; // 0x0E48(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class USlider* ScaleSlider; // 0x0E50(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UKeyInputWidget* SelectUnit; // 0x0E58(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UKeyInputWidget* SetGamma1; // 0x0E60(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UKeyInputWidget* SetGamma2; // 0x0E68(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class USlider* SFXSlider; // 0x0E70(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UComboBoxString* ShadowsComboBox; // 0x0E78(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UCheckBox* ShowChatCheckbox; // 0x0E80(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UKeyInputWidget* ShowExtendedInfo; // 0x0E88(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UKeyInputWidget* ShowLocalChat; // 0x0E90(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UKeyInputWidget* ShowMyCraftables; // 0x0E98(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UKeyInputWidget* ShowMyInventory; // 0x0EA0(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UKeyInputWidget* ShowTribeChat; // 0x0EA8(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UKeyInputWidget* ShowTribeManager; // 0x0EB0(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UCheckBox* SimpleDistanceMovementCheckbox; // 0x0EB8(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UCheckBox* SSAOCheckbox; // 0x0EC0(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UCheckBox* StatusNotificationMessagesCheckbox; // 0x0EC8(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UKeyInputWidget* StrafeLeft; // 0x0ED0(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UKeyInputWidget* StrafeRight; // 0x0ED8(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UWidgetSwitcher* SubMenuSwitcher; // 0x0EE0(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UKeyInputWidget* Targeting; // 0x0EE8(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UCheckBox* TemperatureFCheckbox; // 0x0EF0(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UComboBoxString* TerrainShadowComboBox; // 0x0EF8(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UComboBoxString* TexturesComboBox; // 0x0F00(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UKeyInputWidget* ToggleAutoChat; // 0x0F08(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UKeyInputWidget* ToggleConsole; // 0x0F10(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UCheckBox* ToggleExtendedHUDInfoCheckbox; // 0x0F18(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UKeyInputWidget* ToggleHUDHidden; // 0x0F20(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UKeyInputWidget* ToggleMap; // 0x0F28(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UKeyInputWidget* ToggleRTS; // 0x0F30(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UCheckBox* ToggleToTalkCheckBox; // 0x0F38(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class USlider* TrueSkyQualitySlider; // 0x0F40(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UKeyInputWidget* TurnLeft; // 0x0F48(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UKeyInputWidget* TurnRight; // 0x0F50(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class USlider* UIQuickbarScalingSlider; // 0x0F58(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UKeyInputWidget* Use; // 0x0F60(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UCheckBox* UseDFAOCheckbox; // 0x0F68(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UKeyInputWidget* UseItem1; // 0x0F70(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UKeyInputWidget* UseItem10; // 0x0F78(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UKeyInputWidget* UseItem2; // 0x0F80(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UKeyInputWidget* UseItem3; // 0x0F88(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UKeyInputWidget* UseItem4; // 0x0F90(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UKeyInputWidget* UseItem5; // 0x0F98(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UKeyInputWidget* UseItem6; // 0x0FA0(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UKeyInputWidget* UseItem7; // 0x0FA8(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UKeyInputWidget* UseItem8; // 0x0FB0(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UKeyInputWidget* UseItem9; // 0x0FB8(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UCheckBox* UseLowQualityFarLevelStreamingCheckbox; // 0x0FC0(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UComboBoxString* ViewDistanceComboBox; // 0x0FC8(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class USlider* VoiceSlider; // 0x0FD0(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UKeyInputWidget* WeaponAccessory; // 0x0FD8(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UKeyInputWidget* Whisper; // 0x0FE0(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UEditableTextBox* WidthTextBox; // 0x0FE8(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UComboBoxString* WindowModeComboBox; // 0x0FF0(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UComboBoxString* WorldTileBufferComboBox; // 0x0FF8(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UKeyInputWidget* Yell; // 0x1000(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UKeyInputWidget* ZoomIn; // 0x1008(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) class UKeyInputWidget* ZoomOut; // 0x1010(0x0008) (BlueprintVisible, ZeroConstructor, IsPlainOldData) bool GraphicsToolTipIsVisible; // 0x1018(0x0001) (Edit, BlueprintVisible, ZeroConstructor, DisableEditOnInstance, IsPlainOldData) unsigned char UnknownData00[0x3]; // 0x1019(0x0003) MISSED OFFSET struct FGeometry K2Node_Event_MyGeometry; // 0x101C(0x0034) (Transient, DuplicateTransient, IsPlainOldData) float K2Node_Event_InDeltaTime; // 0x1050(0x0004) (ZeroConstructor, Transient, DuplicateTransient, IsPlainOldData) unsigned char UnknownData01[0x4]; // 0x1054(0x0004) MISSED OFFSET class FString K2Node_ComponentBoundEvent_SelectedItem5; // 0x1058(0x0010) (ZeroConstructor, Transient, DuplicateTransient) TEnumAsByte<ESelectInfo> K2Node_ComponentBoundEvent_SelectionType5; // 0x1068(0x0001) (ZeroConstructor, Transient, DuplicateTransient, IsPlainOldData) unsigned char UnknownData02[0x7]; // 0x1069(0x0007) MISSED OFFSET class FString K2Node_ComponentBoundEvent_SelectedItem4; // 0x1070(0x0010) (ZeroConstructor, Transient, DuplicateTransient) TEnumAsByte<ESelectInfo> K2Node_ComponentBoundEvent_SelectionType4; // 0x1080(0x0001) (ZeroConstructor, Transient, DuplicateTransient, IsPlainOldData) unsigned char UnknownData03[0x7]; // 0x1081(0x0007) MISSED OFFSET class FString K2Node_ComponentBoundEvent_SelectedItem3; // 0x1088(0x0010) (ZeroConstructor, Transient, DuplicateTransient) TEnumAsByte<ESelectInfo> K2Node_ComponentBoundEvent_SelectionType3; // 0x1098(0x0001) (ZeroConstructor, Transient, DuplicateTransient, IsPlainOldData) unsigned char UnknownData04[0x7]; // 0x1099(0x0007) MISSED OFFSET class FString K2Node_ComponentBoundEvent_SelectedItem2; // 0x10A0(0x0010) (ZeroConstructor, Transient, DuplicateTransient) TEnumAsByte<ESelectInfo> K2Node_ComponentBoundEvent_SelectionType2; // 0x10B0(0x0001) (ZeroConstructor, Transient, DuplicateTransient, IsPlainOldData) unsigned char UnknownData05[0x7]; // 0x10B1(0x0007) MISSED OFFSET class FString K2Node_ComponentBoundEvent_SelectedItem; // 0x10B8(0x0010) (ZeroConstructor, Transient, DuplicateTransient) TEnumAsByte<ESelectInfo> K2Node_ComponentBoundEvent_SelectionType; // 0x10C8(0x0001) (ZeroConstructor, Transient, DuplicateTransient, IsPlainOldData) unsigned char UnknownData06[0x7]; // 0x10C9(0x0007) MISSED OFFSET class FString K2Node_ComponentBoundEvent_SelectedItem6; // 0x10D0(0x0010) (ZeroConstructor, Transient, DuplicateTransient) TEnumAsByte<ESelectInfo> K2Node_ComponentBoundEvent_SelectionType6; // 0x10E0(0x0001) (ZeroConstructor, Transient, DuplicateTransient, IsPlainOldData) unsigned char UnknownData07[0x3]; // 0x10E1(0x0003) MISSED OFFSET float K2Node_ComponentBoundEvent_Value2; // 0x10E4(0x0004) (ZeroConstructor, Transient, DuplicateTransient, IsPlainOldData) float K2Node_ComponentBoundEvent_Value; // 0x10E8(0x0004) (ZeroConstructor, Transient, DuplicateTransient, IsPlainOldData) bool K2Node_ComponentBoundEvent_bIsChecked4; // 0x10EC(0x0001) (ZeroConstructor, Transient, DuplicateTransient, IsPlainOldData) bool K2Node_ComponentBoundEvent_bIsChecked3; // 0x10ED(0x0001) (ZeroConstructor, Transient, DuplicateTransient, IsPlainOldData) bool K2Node_ComponentBoundEvent_bIsChecked2; // 0x10EE(0x0001) (ZeroConstructor, Transient, DuplicateTransient, IsPlainOldData) bool K2Node_ComponentBoundEvent_bIsChecked; // 0x10EF(0x0001) (ZeroConstructor, Transient, DuplicateTransient, IsPlainOldData) class FString K2Node_ComponentBoundEvent_SelectedItem7; // 0x10F0(0x0010) (ZeroConstructor, Transient, DuplicateTransient) TEnumAsByte<ESelectInfo> K2Node_ComponentBoundEvent_SelectionType7; // 0x1100(0x0001) (ZeroConstructor, Transient, DuplicateTransient, IsPlainOldData) bool CallFunc_Not_PreBool_ReturnValue; // 0x1101(0x0001) (ZeroConstructor, Transient, DuplicateTransient, IsPlainOldData) bool CallFunc_IsHovered_ReturnValue; // 0x1102(0x0001) (ZeroConstructor, Transient, DuplicateTransient, IsPlainOldData) bool CallFunc_BooleanAND_ReturnValue; // 0x1103(0x0001) (ZeroConstructor, Transient, DuplicateTransient, IsPlainOldData) bool CallFunc_Not_PreBool_ReturnValue2; // 0x1104(0x0001) (ZeroConstructor, Transient, DuplicateTransient, IsPlainOldData) bool CallFunc_BooleanAND_ReturnValue2; // 0x1105(0x0001) (ZeroConstructor, Transient, DuplicateTransient, IsPlainOldData) static UClass* StaticClass() { static auto ptr = UObject::FindClass("WidgetBlueprintGeneratedClass OptionsMenu.OptionsMenu_C"); return ptr; } void BndEvt__GraphicsQualityComboBox_K2Node_ComponentBoundEvent_11_OnSelectionChangedEvent__DelegateSignature(const class FString& SelectedItem, TEnumAsByte<ESelectInfo> SelectionType); void BndEvt__ViewDistanceComboBox_K2Node_ComponentBoundEvent_7_OnSelectionChangedEvent__DelegateSignature(const class FString& SelectedItem, TEnumAsByte<ESelectInfo> SelectionType); void BndEvt__AntiAliasingComboBox_K2Node_ComponentBoundEvent_13_OnSelectionChangedEvent__DelegateSignature(const class FString& SelectedItem, TEnumAsByte<ESelectInfo> SelectionType); void BndEvt__PostProcessingComboBox_K2Node_ComponentBoundEvent_20_OnSelectionChangedEvent__DelegateSignature(const class FString& SelectedItem, TEnumAsByte<ESelectInfo> SelectionType); void BndEvt__ShadowsComboBox_K2Node_ComponentBoundEvent_28_OnSelectionChangedEvent__DelegateSignature(const class FString& SelectedItem, TEnumAsByte<ESelectInfo> SelectionType); void BndEvt__TerrainShadowComboBox_K2Node_ComponentBoundEvent_37_OnSelectionChangedEvent__DelegateSignature(const class FString& SelectedItem, TEnumAsByte<ESelectInfo> SelectionType); void BndEvt__TexturesComboBox_K2Node_ComponentBoundEvent_47_OnSelectionChangedEvent__DelegateSignature(const class FString& SelectedItem, TEnumAsByte<ESelectInfo> SelectionType); void BndEvt__TrueSkyQualitySlider_K2Node_ComponentBoundEvent_67_OnFloatValueChangedEvent__DelegateSignature(float Value); void BndEvt__GroundClutterDensitySlider_K2Node_ComponentBoundEvent_81_OnFloatValueChangedEvent__DelegateSignature(float Value); void BndEvt__MotionBlurCheckbox_K2Node_ComponentBoundEvent_181_OnCheckBoxComponentStateChanged__DelegateSignature(bool bIsChecked); void BndEvt__FilmGrainCheckbox_K2Node_ComponentBoundEvent_193_OnCheckBoxComponentStateChanged__DelegateSignature(bool bIsChecked); void BndEvt__UseDFAOCheckbox_K2Node_ComponentBoundEvent_206_OnCheckBoxComponentStateChanged__DelegateSignature(bool bIsChecked); void BndEvt__SSAOCheckbox_K2Node_ComponentBoundEvent_220_OnCheckBoxComponentStateChanged__DelegateSignature(bool bIsChecked); void OptionsGraphTick(struct FGeometry* MyGeometry, float* InDeltaTime); void ExecuteUbergraph_OptionsMenu(int EntryPoint); }; } #ifdef _MSC_VER #pragma pack(pop) #endif
[ "sergey.2bite@gmail.com" ]
sergey.2bite@gmail.com
0962b111422a629aa1d5ea03b1d2948790991d47
784e683fe0239f991228e0d7632ace5cc2f55ad8
/src/global/gui/src/MGUIAssistant.cxx
a397ad7f8ecae52eea42fad459341aae3726bf4a
[]
no_license
rheask8246/megalib
5751ee8e5b00bc6c9a0cacea2c1d82a600f08336
a681302a429aa4a9cb1201c00db1d964fb92a056
refs/heads/master
2021-07-23T14:13:32.687763
2019-01-11T05:41:49
2019-01-11T05:41:49
239,953,431
0
0
null
2020-02-12T07:39:40
2020-02-12T07:39:39
null
UTF-8
C++
false
false
11,261
cxx
/* * MGUIAssistant.cxx * * * Copyright (C) by Andreas Zoglauer. * All rights reserved. * * * This code implementation is the intellectual property of * Andreas Zoglauer. * * By copying, distributing or modifying the Program (or any work * based on the Program) you indicate your acceptance of this statement, * and all its terms. * */ //////////////////////////////////////////////////////////////////////////////// // // MGUIAssistant // // // This is the base class for most of the other Dialogs. // It provides some methods all other dialogs need // // Important info: // Always call a derived class via // MDerived *d = new MDerived(...) // and never use MDerived d(..) because it will simply always and ever crash. // //////////////////////////////////////////////////////////////////////////////// // Include the header: #include "MGUIAssistant.h" // Standard libs: #include <stdlib.h> #include <ctype.h> // ROOT libs: #include "TGLabel.h" #include "TSystem.h" // MEGAlib libs: #include "MStreams.h" #include "MString.h" #include "MFile.h" //////////////////////////////////////////////////////////////////////////////// //#ifdef ___CINT___ //ClassImp(MGUIAssistant) //#endif //////////////////////////////////////////////////////////////////////////////// MGUIAssistant::MGUIAssistant() : TGTransientFrame(gClient->GetRoot(), gClient->GetRoot(), 480, 360) { // standard constructor m_ParentWindow = (TGFrame *) gClient->GetRoot(); } //////////////////////////////////////////////////////////////////////////////// MGUIAssistant::MGUIAssistant(const TGWindow *p, const TGWindow *main, unsigned int Type, unsigned int w, unsigned int h, unsigned int options) : TGTransientFrame(p, main, w, h, options) { m_ParentWindow = (TGFrame *) main; m_Type = Type; MString Path(g_MEGAlibPath + "/resource/icons/global/Icon.xpm"); MFile::ExpandFileName(Path); SetIconPixmap(Path); m_SubTitleLabel = 0; m_SubTitleFirstLayout = 0; m_SubTitleMiddleLayout = 0; m_SubTitleLastLayout = 0; m_SubTitleOnlyLayout = 0; m_ButtonsAdded = false; m_SubTitleAdded = false; m_LabelFrame = 0; m_LabelFrameLayout = 0; m_ButtonFrame = 0; m_ButtonFrameLayout = 0; m_BackText = "<< Back <<"; m_BackButton = 0; m_BackButtonLayout = 0; m_CancelText = "Cancel"; m_CancelButton = 0; m_CancelButtonLayout = 0; m_NextText = ">> Next >>"; m_NextButton = 0; m_NextButtonLayout = 0; m_ButtonFrame = 0; m_ButtonFrameLayout = 0; } //////////////////////////////////////////////////////////////////////////////// MGUIAssistant::~MGUIAssistant() { m_ParentWindow = 0; //if (m_SubTitleAdded == true) { delete m_SubTitleLabel; delete m_SubTitleFirstLayout; delete m_SubTitleMiddleLayout; delete m_SubTitleLastLayout; delete m_SubTitleOnlyLayout; delete m_LabelFrame; delete m_LabelFrameLayout; //} delete m_BackButton; delete m_BackButtonLayout; delete m_CancelButton; delete m_CancelButtonLayout; delete m_NextButton; delete m_NextButtonLayout; delete m_ButtonFrame; delete m_ButtonFrameLayout; } //////////////////////////////////////////////////////////////////////////////// void MGUIAssistant::CloseWindow() { // When the x is pressed, this function is called. DeleteWindow(); } //////////////////////////////////////////////////////////////////////////////// void MGUIAssistant::PositionWindow(int Width, int Height, bool AllowResize) { // This method positions the dialog window in the center of its parent window, // but (if possible) the whole window is shown on the screen. // First we compute the above-mentioned x and y coordinates ... int x = 0, y = 0; Window_t WindowDummy; gVirtualX->TranslateCoordinates(m_ParentWindow->GetId(), GetParent()->GetId(), (m_ParentWindow->GetWidth() - Width) >> 1, (m_ParentWindow->GetHeight() - Height) >> 1, x, y, WindowDummy); // ... get the width and height of the display ... int xDisplay, yDisplay; unsigned int wDisplay, hDisplay; gVirtualX->GetGeometry(-1, xDisplay, yDisplay, wDisplay, hDisplay); // ... make sure that the whole dialog window is shown on the screen ... if (Width > (int) wDisplay) Width = wDisplay - 50; if (Height > (int) hDisplay) Height = hDisplay - 50; if (x + Width > (int) wDisplay) x = wDisplay - Width - 8; if (y + Height > (int) hDisplay) y = hDisplay - Height - 28; if (x < 0) x = 0; if (y < 0) y = 0; // ... and bring the dialog to the calculated position. MoveResize(x, y, Width, Height); if (AllowResize == true) { TGDimension size = GetSize(); SetWMSize(size.fWidth, size.fHeight); SetWMSizeHints(size.fWidth, size.fHeight, size.fWidth, size.fHeight, 0, 0); } return; } //////////////////////////////////////////////////////////////////////////////// void MGUIAssistant::Header(MString SubTitle) { // Add a label to the top of the window: if (m_SubTitleAdded == false) { m_LabelFrame = new TGVerticalFrame(this, 100, 10, kRaisedFrame); m_LabelFrameLayout = new TGLayoutHints(kLHintsExpandX, 10, 10, 10, 30); AddFrame(m_LabelFrame, m_LabelFrameLayout); m_SubTitleLabel = new TObjArray(); m_SubTitleFirstLayout = new TGLayoutHints(kLHintsCenterX | kLHintsExpandX | kLHintsTop, 20, 20, 5, 1); m_SubTitleMiddleLayout = new TGLayoutHints(kLHintsCenterX | kLHintsExpandX | kLHintsTop, 20, 20, 1, 1); m_SubTitleLastLayout = new TGLayoutHints(kLHintsCenterX | kLHintsExpandX | kLHintsTop, 20, 20, 1, 5); m_SubTitleOnlyLayout = new TGLayoutHints(kLHintsCenterX | kLHintsExpandX | kLHintsTop, 20, 20, 5, 5); bool First = true; int LabelIndex = 0; MString SubString; // (start a new line for each '\n') while (SubTitle.Contains('\n') == true) { SubString = SubTitle; SubString = SubString.Remove(SubString.First('\n'), SubString.Length() - SubString.First('\n')); m_SubTitleLabel->AddAt(new TGLabel(m_LabelFrame, new TGString(SubString)), LabelIndex++); if (First == true) { m_LabelFrame->AddFrame((TGLabel *) m_SubTitleLabel->At(LabelIndex-1), m_SubTitleFirstLayout); First = false; } else { m_LabelFrame->AddFrame((TGLabel *) m_SubTitleLabel->At(LabelIndex-1), m_SubTitleMiddleLayout); } SubTitle.Replace(0, SubTitle.First('\n')+1, ""); } m_SubTitleLabel->AddAt(new TGLabel(m_LabelFrame, new TGString(SubTitle)), LabelIndex++); if (First == true) { m_LabelFrame->AddFrame((TGLabel *) m_SubTitleLabel->At(LabelIndex-1), m_SubTitleOnlyLayout); } else { m_LabelFrame->AddFrame((TGLabel *) m_SubTitleLabel->At(LabelIndex-1), m_SubTitleLastLayout); } } else { Error("void MGUIAssistant::AddSubTitle(MString SubTitle)", "SubTitle has already been added!"); } m_SubTitleAdded = true; return; } //////////////////////////////////////////////////////////////////////////////// void SetFooterText(MString Back, MString Next, MString Cancel); //////////////////////////////////////////////////////////////////////////////// void MGUIAssistant::Footer() { // Add the Ok- and Cancel-Buttons if (m_ButtonsAdded == false) { m_ButtonFrame = new TGHorizontalFrame(this, 150, 25); m_ButtonFrameLayout = new TGLayoutHints(kLHintsBottom | kLHintsExpandX | kLHintsCenterX, 5, 5, 30, 10); AddFrame(m_ButtonFrame, m_ButtonFrameLayout); m_BackButton = new TGTextButton(m_ButtonFrame, m_BackText, c_Back); if (m_Type == c_First) { m_BackButton->SetState(kButtonDisabled); //m_BackButton->SetText(""); //m_BackButton->ChangeOptions(0); } m_BackButton->Associate(this); m_BackButtonLayout = new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX, 5, 15, 0, 0); m_ButtonFrame->AddFrame(m_BackButton, m_BackButtonLayout); m_CancelButton = new TGTextButton(m_ButtonFrame, m_CancelText, c_Cancel); m_CancelButton->Associate(this); m_CancelButtonLayout = new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX, 15, 15, 0, 0); m_ButtonFrame->AddFrame(m_CancelButton, m_CancelButtonLayout); if (m_Type == c_Last) { m_NextText = "Finish"; } m_NextButton = new TGTextButton(m_ButtonFrame, m_NextText, c_Next); m_NextButton->Associate(this); m_NextButtonLayout = new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX, 15, 5, 0, 0); m_ButtonFrame->AddFrame(m_NextButton, m_NextButtonLayout); } PositionWindow(GetDefaultWidth(), GetDefaultHeight()); // and bring it to the screen. MapSubwindows(); MapWindow(); Layout(); return; } //////////////////////////////////////////////////////////////////////////////// bool MGUIAssistant::ProcessMessage(long Message, long Parameter1, long Parameter2) { // Process the messages for this application switch (GET_MSG(Message)) { case kC_COMMAND: switch (GET_SUBMSG(Message)) { case kCM_BUTTON: switch (Parameter1) { case c_Back: OnBack(); break; case c_Next: OnNext(); break; case c_Cancel: OnCancel(); break; default: break; } break; default: break; } break; default: break; } return true; } //////////////////////////////////////////////////////////////////////////////// void MGUIAssistant::OnBack() { // The back button has been pressed return; } //////////////////////////////////////////////////////////////////////////////// void MGUIAssistant::OnNext() { // The next button has been pressed return; } //////////////////////////////////////////////////////////////////////////////// void MGUIAssistant::OnCancel() { // The cancel button has been pressed m_ParentWindow->MapWindow(); CloseWindow(); } //////////////////////////////////////////////////////////////////////////////// void MGUIAssistant::SetTextBack(MString String) { m_BackText = String; if (m_BackButton != 0) { m_BackButton->SetText(m_BackText.Data()); m_BackButton->Layout(); } } //////////////////////////////////////////////////////////////////////////////// void MGUIAssistant::SetTextNext(MString String) { m_NextText = String; if (m_NextButton != 0) { m_NextButton->SetText(m_NextText.Data()); m_NextButton->Layout(); } } //////////////////////////////////////////////////////////////////////////////// void MGUIAssistant::SetTextCancel(MString String) { m_CancelText = String; if (m_CancelButton != 0) { m_CancelButton->SetText(m_CancelText.Data()); m_CancelButton->Layout(); } } // MGUIAssistant: the end... ////////////////////////////////////////////////////////////////////////////////
[ "andreas@megalibtoolkit.com" ]
andreas@megalibtoolkit.com
2b97be7fe69cc673482b826d6d505c360c7683d0
157c9997e9011b301322f3169570a0c612e1fdf4
/BmpDisplayDemo/BmpDisplayDemoDoc.cpp
ad0f9084af49fb2b7c5ed11a01aeb94abdde0cd0
[]
no_license
0nehu1/BmpDisplayDemo
3a1d2207e700418ae343c8e58f584ebc69656b50
84481f9292027db97e3b10e46cf25a0e318855a1
refs/heads/master
2023-07-04T15:09:59.726326
2021-08-06T06:54:44
2021-08-06T06:54:44
393,284,395
0
0
null
null
null
null
UTF-8
C++
false
false
3,012
cpp
 // BmpDisplayDemoDoc.cpp: CBmpDisplayDemoDoc 클래스의 구현 // #include "pch.h" #include "framework.h" // SHARED_HANDLERS는 미리 보기, 축소판 그림 및 검색 필터 처리기를 구현하는 ATL 프로젝트에서 정의할 수 있으며 // 해당 프로젝트와 문서 코드를 공유하도록 해 줍니다. #ifndef SHARED_HANDLERS #include "BmpDisplayDemo.h" #endif #include "BmpDisplayDemoDoc.h" #include <propkey.h> #ifdef _DEBUG #define new DEBUG_NEW #endif // CBmpDisplayDemoDoc IMPLEMENT_DYNCREATE(CBmpDisplayDemoDoc, CDocument) BEGIN_MESSAGE_MAP(CBmpDisplayDemoDoc, CDocument) END_MESSAGE_MAP() // CBmpDisplayDemoDoc 생성/소멸 CBmpDisplayDemoDoc::CBmpDisplayDemoDoc() noexcept { // TODO: 여기에 일회성 생성 코드를 추가합니다. } CBmpDisplayDemoDoc::~CBmpDisplayDemoDoc() { } BOOL CBmpDisplayDemoDoc::OnNewDocument() { if (!CDocument::OnNewDocument()) return FALSE; // TODO: 여기에 재초기화 코드를 추가합니다. // SDI 문서는 이 문서를 다시 사용합니다. return TRUE; } // CBmpDisplayDemoDoc serialization void CBmpDisplayDemoDoc::Serialize(CArchive& ar) { if (ar.IsStoring()) { // TODO: 여기에 저장 코드를 추가합니다. } else { // TODO: 여기에 로딩 코드를 추가합니다. } } #ifdef SHARED_HANDLERS // 축소판 그림을 지원합니다. void CBmpDisplayDemoDoc::OnDrawThumbnail(CDC& dc, LPRECT lprcBounds) { // 문서의 데이터를 그리려면 이 코드를 수정하십시오. dc.FillSolidRect(lprcBounds, RGB(255, 255, 255)); CString strText = _T("TODO: implement thumbnail drawing here"); LOGFONT lf; CFont* pDefaultGUIFont = CFont::FromHandle((HFONT) GetStockObject(DEFAULT_GUI_FONT)); pDefaultGUIFont->GetLogFont(&lf); lf.lfHeight = 36; CFont fontDraw; fontDraw.CreateFontIndirect(&lf); CFont* pOldFont = dc.SelectObject(&fontDraw); dc.DrawText(strText, lprcBounds, DT_CENTER | DT_WORDBREAK); dc.SelectObject(pOldFont); } // 검색 처리기를 지원합니다. void CBmpDisplayDemoDoc::InitializeSearchContent() { CString strSearchContent; // 문서의 데이터에서 검색 콘텐츠를 설정합니다. // 콘텐츠 부분은 ";"로 구분되어야 합니다. // 예: strSearchContent = _T("point;rectangle;circle;ole object;"); SetSearchContent(strSearchContent); } void CBmpDisplayDemoDoc::SetSearchContent(const CString& value) { if (value.IsEmpty()) { RemoveChunk(PKEY_Search_Contents.fmtid, PKEY_Search_Contents.pid); } else { CMFCFilterChunkValueImpl *pChunk = nullptr; ATLTRY(pChunk = new CMFCFilterChunkValueImpl); if (pChunk != nullptr) { pChunk->SetTextValue(PKEY_Search_Contents, value, CHUNK_TEXT); SetChunkValue(pChunk); } } } #endif // SHARED_HANDLERS // CBmpDisplayDemoDoc 진단 #ifdef _DEBUG void CBmpDisplayDemoDoc::AssertValid() const { CDocument::AssertValid(); } void CBmpDisplayDemoDoc::Dump(CDumpContext& dc) const { CDocument::Dump(dc); } #endif //_DEBUG // CBmpDisplayDemoDoc 명령
[ "onejun0320@gmail.com" ]
onejun0320@gmail.com
bf3305606c9445b82fd7b534c8a8d3cecf0f7ca4
a44e151d2ff82b07d4c332ad0dab559a454bd724
/upnpls.h
9fcf3adec92ce6ba7c0deaa3f94991fe25500bf2
[]
no_license
nikhilm/upnpls
19ce9128b05c92746ff6584f9e612e197f063963
04c00f30b9b46972dc527c4dadc36df7349015d1
refs/heads/master
2021-01-16T18:40:24.779662
2010-04-12T15:09:00
2010-04-12T15:09:00
null
0
0
null
null
null
null
UTF-8
C++
false
false
989
h
#ifndef UPNPLS_H #define UPNPLS_H #include <QMainWindow> #include <QModelIndex> #include <QStringList> #include <QUuid> #include <QUrl> #include <HUdn> class QStandardItemModel; class QTreeView; namespace Herqq { namespace Upnp { class HControlPoint; class HDevice; class HService; } } class Upnpls : public QMainWindow { Q_OBJECT public: Upnpls(); ~Upnpls(); private: enum Roles { ServiceRole = Qt::UserRole + 1 }; void setupGui(); bool ready(); void waitForDevice(); bool initCDS( Herqq::Upnp::HDevice *dev ); Herqq::Upnp::HControlPoint *m_cp; Herqq::Upnp::HService *m_cds; Herqq::Upnp::HUdn m_udn; QStandardItemModel *m_model; QTreeView *m_view; const QStringList m_args; signals: void done(); private slots: void rootDeviceOnline( Herqq::Upnp::HDevice *device ); void rootDeviceOffline( Herqq::Upnp::HDevice *device ); void browse( const QModelIndex & ); }; #endif
[ "nsm.nikhil@gmail.com" ]
nsm.nikhil@gmail.com
df01d74b7419e29d04d569a1157594dd369c4c14
57484230c26cf67d8ef9bc17513d6389ad1ba103
/Chapter 9 Texturing/9_TexWaves/GameTimer.h
4aea8f35c911d2031ca959eb018c1b5201c65bb5
[]
no_license
akatokikwok/DX12Ebook
ab2edf2e8e3fcb6b9133e58f444f07dc5fc2e519
aed2a1a79ab7fb5b23e72ec0997e39b61f67a760
refs/heads/master
2023-09-02T06:27:19.518305
2021-10-27T07:24:48
2021-11-12T10:40:50
349,897,570
0
1
null
null
null
null
UTF-8
C++
false
false
1,360
h
//*************************************************************************************** // GameTimer.h by Frank Luna (C) 2011 All Rights Reserved. //*************************************************************************************** #ifndef GAMETIMER_H #define GAMETIMER_H class GameTimer { public: /* 计时器类的构造函数会查询 计数器的频率, 对其取倒数之后就拿到转换因子(实际上就是几分之一秒)*/ GameTimer(); /* 计算到现在为止不算暂停的游玩时长*/ float TotalTime()const; // in seconds /* 拿两帧之间的时间差*/ float DeltaTime()const; // in seconds /* 重置base时刻以及前一时刻为当前时刻*/ void Reset(); // Call before message loop. /* 此方法主要是计算累加的暂停时长 同时更新前一时刻为startTime时刻*/ void Start(); // Call when unpaused. /* 存储被停止的时刻,同时命中停止标志*/ void Stop(); // Call when paused. /* 计算时刻差(单位:"计数")的函数*/ void Tick(); // Call every frame. private: double mSecondsPerCount;// 转换因子(实际上就是几分之一秒) double mDeltaTime; __int64 mBaseTime; __int64 mPausedTime;// 应该理解为停止的时长,而非时刻 __int64 mStopTime;// 被停止的时刻 __int64 mPrevTime; __int64 mCurrTime; bool mStopped; }; #endif // GAMETIMER_H
[ "akatokikwok@outlook.com" ]
akatokikwok@outlook.com
8a1671c30ed46e4813954fd131e83ab9730785b1
3d3454b57ed72a03db9c11432ff9e79c4071d849
/amazon_archives/trees/inorder_and_preorder.cpp
a0827137dfee589bb71c77cb45beb5a142505f9d
[]
no_license
L04DB4L4NC3R/placement-prep
49d46eebe1e8c6e353f7fd8de4032db062cc9c0d
756ca128d4699c463541ebbbd5e5b112e961698f
refs/heads/master
2022-11-19T00:20:08.751449
2020-07-18T13:49:02
2020-07-18T13:49:02
249,736,200
5
0
null
null
null
null
UTF-8
C++
false
false
464
cpp
// https://practice.geeksforgeeks.org/problems/inorder-traversal/1 // https://practice.geeksforgeeks.org/problems/preorder-traversal/1 void inorder(Node* root) { // Your code here if(root == NULL) return; inorder(root->left); cout << root->data << " "; inorder(root->right); } void preorder(Node* root) { // Your code here if(root == NULL) return; cout << root->data << " "; preorder(root->left); preorder(root->right); }
[ "angadsharma1016@gmail.com" ]
angadsharma1016@gmail.com
6accd5f0562bce5d2ad03ca3bd02fb7d42217164
4ae76cff653cac15b992e938e7758481f9ffeed3
/MeshViewer/QtOpenGLWidget.cpp
d85f69d33e06be8aeca0f076ba1ef22e001c0e19
[]
no_license
congcong-hehe/MeshViewer
e81d728d0fd746546775a9eea38293527fd30425
b6fa439c3fc58d5ad4c44e692a35850a6cfd0375
refs/heads/main
2023-02-25T15:37:27.456242
2021-02-01T07:25:02
2021-02-01T07:25:02
319,618,014
2
2
null
null
null
null
GB18030
C++
false
false
2,340
cpp
#include "QtOpenGLWidget.h" #include <QDebug> #include <QFileDialog> static int x_angle = 0; // x方向旋转角度 static int y_angle = 0; // y方向旋转角度 static float zoom = 45.0f; // 视野度数 QtOpenGLWidget::QtOpenGLWidget(QWidget* parent) : QOpenGLWidget(parent) { } QtOpenGLWidget::~QtOpenGLWidget() { } void QtOpenGLWidget::initializeGL() { ff = QOpenGLContext::currentContext()->versionFunctions<QOpenGLFunctions_3_3_Core>(); mesh_ = new QuadMesh; mesh_->loadFile("../model/3cube.obj"); mesh_->setMesh(); ff->glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); //设置绘制的线框模式 } void QtOpenGLWidget::resizeGL(int width, int height) { ff->glViewport(0, 0, width, height); } void QtOpenGLWidget::paintGL() { // 投影变换矩阵 QMatrix4x4 projection; projection.perspective(zoom, (float)width() / height(), 0.1f, 100.0f); // 模型变换矩阵 QMatrix4x4 model; model.rotate(x_angle, QVector3D(0.0f, 1.0f, 0.0f)); model.rotate(y_angle, QVector3D(1.0f, 0.0f, 0.0f)); ff->glClearColor(0.2f, 0.3f, 0.3f, 1.0f); // 清屏颜色,(背景颜色) ff->glClear(GL_COLOR_BUFFER_BIT); // 清空颜色缓存 if (mesh_ != nullptr && !mesh_->isEmpty()) // 防止出现文件为空的情况,访问首地址越界访问 { mesh_->drawMesh(ff, projection, model); } } void QtOpenGLWidget::mousePressEvent(QMouseEvent* event) { if (event->button() == Qt::LeftButton) { mouse_pressed_ = true; last_pos_ = event->pos(); } } void QtOpenGLWidget::mouseReleaseEvent(QMouseEvent* event) { Q_UNUSED(event); mouse_pressed_ = false; } void QtOpenGLWidget::mouseMoveEvent(QMouseEvent* event) { if (mouse_pressed_) { int xpos = event->pos().x(); int ypos = event->pos().y(); int xoffset = xpos - last_pos_.x(); int yoffset = ypos - last_pos_.y(); last_pos_ = event->pos(); x_angle = (x_angle + xoffset / 2) % 360; y_angle = (y_angle + yoffset / 2) % 360; } update(); } void QtOpenGLWidget::wheelEvent(QWheelEvent* event) { QPoint offset = event->angleDelta(); zoom -= (float)offset.y() / 20.0f; if (zoom < 10.0f) zoom = 10.0f; if (zoom > 45.0f) zoom = 45.0f; update(); }
[ "heyaqihehe@163.com" ]
heyaqihehe@163.com
6cb90584f1108b979495562f83ac163345d584e8
72fdf2efd7d9e8c4e15c9a9f7d6b595bc540cfa4
/Tests/include/ListLogHandler.hpp
f593f0b061bd4e79d66c2091ad4f7b2cfd7a65e3
[ "BSD-3-Clause" ]
permissive
BlockProject3D/Engine
0222cb25b797ed7566acf4679c01027189555664
6de000b335c374fe47a5df3d98a716aadb1967c9
refs/heads/master
2021-04-20T13:38:28.886449
2020-08-05T21:04:30
2020-08-05T21:04:30
249,688,344
0
0
null
null
null
null
UTF-8
C++
false
false
2,030
hpp
// Copyright (c) 2020, BlockProject // // 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 BlockProject 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. #pragma once #include <Framework/Log/ILogAdapter.hpp> #include <Framework/Collection/List.hpp> class ListLogHandler final : public bpf::log::ILogAdapter { private: bpf::collection::List<bpf::String> &_logs; public: explicit inline ListLogHandler(bpf::collection::List<bpf::String> &lst) : _logs(lst) { } void LogMessage(bpf::log::ELogLevel level, const bpf::String &category, const bpf::String &msg) final; };
[ "nicolas1.fraysse@epitech.eu" ]
nicolas1.fraysse@epitech.eu
6b12486c9ffa7c19a129ededa338574572ee9635
b00cffac7bd7f62ac15cd00f378d9e135bfb59af
/bignum.h
6d6112e86fe66235e54db2c01fcaf325121c1acb
[]
no_license
HurricaneFist/BigNum
4a021f7d6e52d1ad746f24eaf5431c14b0a0a591
ddbc3f6afa83e40553fdd70d5ea6385d3fc57aa5
refs/heads/master
2020-03-30T08:00:17.109761
2016-05-24T20:19:53
2016-05-24T20:19:53
59,605,512
0
0
null
null
null
null
UTF-8
C++
false
false
5,988
h
#ifndef BIGNUM_H #define BIGNUM_H #include <sstream> /** * This header file provides algorithms for addition, multiplication, and exponentiation * of unsigned arbitrary-precision integers (AKA big numbers). * * https://github.com/HurricaneFist */ namespace BigNum { // convert a character to an integer int val(char c) { return c - '0'; } // convert an integer to a character char unval(int n) { return n + '0'; } /* * Arbitrary-precision unsigned integer. Usually used for big numbers. * Min value = 0 * Max value = 9.999... x 10^4294967293 * A Num of max value would theoretically consume over 4 GB of memory or disk space. */ struct Num { std::string digits; Num() { digits = ""; } Num(std::string digits_) { digits = digits_; } friend std::ostream &operator<<(std::ostream &os, const Num &n) { os << n.digits; return os; } }; // Scientific notation with significant figures std::string scino(Num n, int sigfigs) { std::stringstream res; res << n.digits[0]; if (sigfigs > 1) { res << '.'; for (int i = 1; i < sigfigs; i++) { if (i > n.digits.length()-1) res << '0'; else res << n.digits[i]; } } res << 'E'; res << n.digits.length()-1; return res.str(); } std::string scino(Num n) { return scino(n, 5); } std::string scino(std::string n, int sigfigs) { return scino(Num(n), sigfigs); } std::string scino(std::string n) { return scino(Num(n), 5); } int compare(Num x, Num y) { if (x.digits.length() > y.digits.length()) return 1; if (x.digits.length() < y.digits.length()) return -1; for (int i = 0; i < x.digits.length(); i++) { if (val(x.digits[i]) > val(y.digits[i])) return 1; if (val(x.digits[i]) < val(y.digits[i])) return -1; } return 0; } Num add(Num m, Num n) { Num x, y; std::string sum = ""; // x will always be greater or equal to y in terms of number of digits if (m.digits.length() >= n.digits.length()) { x = m; y = n; } else { x = n; y = m; } int xind = x.digits.length()-1, yind = y.digits.length()-1; int drem = 0, dsum; while (xind >= 0 || yind >= 0 || drem == 1) { dsum = drem; if (xind >= 0) dsum += val(x.digits[xind]); if (yind >= 0) dsum += val(y.digits[yind]); if (dsum >= 10) { dsum -= 10; drem = 1; } else drem = 0; sum = unval(dsum) + sum; xind--; yind--; } return Num(sum); } Num add(std::string m, std::string n) { return add(Num(m), Num(n)); } Num multiply(Num m, Num n) { if (m.digits == "0" || n.digits == "0") return Num("0"); Num x, y, product("0"); // x will always be greater or equal to y in terms of number of digits if (m.digits.length() >= n.digits.length()) { x = m; y = n; } else { x = n; y = m; } int zeroes = 0; for (int yind = y.digits.length()-1; yind >= 0; yind--, zeroes++) { std::string dtotal = ""; int drem = 0; for (int i = 0; i < zeroes; i++) dtotal = '0' + dtotal; for (int xind = x.digits.length()-1; xind >= 0; xind--) { int dprod = val(x.digits[xind]) * val(y.digits[yind]) + drem; if (dprod >= 10) { drem = dprod / 10; dprod -= drem * 10; } else drem = 0; dtotal = unval(dprod) + dtotal; } if (drem > 0) dtotal = unval(drem) + dtotal; product = add(product, Num(dtotal)); } return product; } Num multiply(std::string m, std::string n) { return multiply(Num(m), Num(n)); } // Decrement a Num (down to zero) Num decrement(Num n) { std::string res = ""; char digit; bool decr = true; for (int i = n.digits.length()-1; i >= 0; i--) { if (decr) { if (i == 0 && n.digits[i] == '1' && n.digits.length() > 1) break; else if (n.digits[i] == '0') digit = '9'; else { digit = unval(val(n.digits[i])-1); decr = false; } } else digit = n.digits[i]; res = digit + res; } return Num(res); } Num decrement(std::string n) { return decrement(Num(n)); } // Exponentiation. N to the power of P. Num power(Num n, Num p) { Num res("1"); while (p.digits != "0") { res = multiply(n, res); p = decrement(p); } return res; } Num power(std::string n, std::string p) { return power(Num(n), Num(p)); } // Compute the factorial of a Num. Num factorial(Num n) { if (n.digits != "0" && n.digits != "1") return multiply(n, factorial(decrement(n))); return Num("1"); } Num factorial(std::string n) { return factorial(Num(n)); } } #endif
[ "hurricanefist@users.noreply.github.com" ]
hurricanefist@users.noreply.github.com
62e0760680b96761aa33a62a420e80ba00630243
fb0ecd924b6529bb31bdc2e0ffa12e60ae641cf9
/src/common/ThreadManager.h
f14fc6978814ba9c6893696d2bbe418c68d0a4d6
[ "Apache-2.0" ]
permissive
huiqiaoqiu/Hercules
3aa272165f79eeb57f6db29c51fbf0a3688102d3
aa245e08474e60bf0903ca182a5884a8047be3ec
refs/heads/master
2023-06-15T19:31:11.640163
2021-06-21T03:55:45
2021-06-21T03:55:45
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,894
h
// Copyright 2021 HUYA // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. #pragma once #include "Singleton.h" #include "Common.h" #include "Log.h" #include <map> #include <thread> #include <mutex> #include <utility> #include <string> namespace hercules { class ThreadManager : public Singleton<ThreadManager> { friend class Singleton<ThreadManager>; private: ThreadManager() { } ~ThreadManager() { } public: void registerThread(std::thread::id id, const std::string &name, std::thread *t) { std::unique_lock<std::mutex> lockGuard(m_mutex); m_threads[id] = make_pair(name, t); logInfo(MIXLOG << "register thread: " << name); } void unregisterThread(std::thread::id id) { std::unique_lock<std::mutex> lockGuard(m_mutex); std::string name = ""; auto iter = m_threads.find(id); if (iter != m_threads.end()) { name = iter->second.first; } logInfo(MIXLOG << "unregister thread: " << name << ", id: " << id); m_threads.erase(id); } void dumpAllThread() { std::unique_lock<std::mutex> lockGuard(m_mutex); logInfo(MIXLOG << "thread num: " << m_threads.size()); std::map<std::string, int> threadStatistic; for (const auto &kv : m_threads) { threadStatistic[kv.second.first]++; } for (const auto &kv : threadStatistic) { logInfo(MIXLOG << "thread: " << kv.first << ", count: " << kv.second); } } void joinAllThread() { std::unique_lock<std::mutex> lockGuard(m_mutex); logInfo(MIXLOG << "thread num: " << m_threads.size()); auto iter = m_threads.begin(); while (!m_threads.empty()) { std::thread *t = iter->second.second; if (t != nullptr) { t->join(); } iter = m_threads.erase(iter); } } private: std::mutex m_mutex; std::map<std::thread::id, std::pair<std::string, std::thread *>> m_threads; }; } // namespace hercules
[ "674913892@qq.com" ]
674913892@qq.com
ab538a16b30e585751ac192d70cea2db95dfd79a
4e6bc7cc8316a5543751e5f89dde3c20343cdfcf
/CUDADataFormats/Vertex/interface/ZVertexSoA.h
cd1f8aea4e340636c82010a708eb34eefa4778bc
[ "Apache-2.0" ]
permissive
PNWCMS/cmssw
53624854d74c49caf1c77c74ba8e28397d67eedf
a13af767b0806291ccda8947c3ed19fcd5b91850
refs/heads/master
2020-10-02T03:07:01.372161
2019-12-02T20:58:47
2019-12-02T20:58:47
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,178
h
#ifndef CUDADataFormatsVertexZVertexSoA_H #define CUDADataFormatsVertexZVertexSoA_H #include <cstdint> #include "HeterogeneousCore/CUDAUtilities/interface/cudaCompat.h" // SOA for vertices // These vertices are clusterized and fitted only along the beam line (z) // to obtain their global coordinate the beam spot position shall be added (eventually correcting for the beam angle as well) struct ZVertexSoA { static constexpr uint32_t MAXTRACKS = 32 * 1024; static constexpr uint32_t MAXVTX = 1024; int16_t idv[MAXTRACKS]; // vertex index for each associated (original) track (-1 == not associate) float zv[MAXVTX]; // output z-posistion of found vertices float wv[MAXVTX]; // output weight (1/error^2) on the above float chi2[MAXVTX]; // vertices chi2 float ptv2[MAXVTX]; // vertices pt^2 int32_t ndof[MAXVTX]; // vertices number of dof (reused as workspace for the number of nearest neighbours) uint16_t sortInd[MAXVTX]; // sorted index (by pt2) ascending uint32_t nvFinal; // the number of vertices __host__ __device__ void init() { nvFinal = 0; } }; #endif // CUDADataFormatsVertexZVertexSoA.H
[ "andrea.bocci@cern.ch" ]
andrea.bocci@cern.ch
a09736a231797426d7cecda50fd1075746c9e5e1
03542f93a8bee33fb88413d29613c9fd59a68dde
/HW/HW5/HW5_1/RandomArray.cpp
c17365e73eb05cd91684914fef9f03cb3704aaf7
[]
no_license
TSLsun/OOP2018_Lab_HW
9a5286c1a5774e490740485753b195daedd6a047
aa651d2d7fd6f4fdf4068a7493f7e0e04a5d25cb
refs/heads/master
2020-04-01T07:47:08.348755
2018-12-28T12:37:05
2018-12-28T12:37:05
153,003,349
0
0
null
null
null
null
UTF-8
C++
false
false
564
cpp
#include <ctime> #include <cstdlib> #include <iostream> #include "RandomArray.h" time_t RandomArray::seed_time = time(0); void RandomArray::setSeed() { srand(seed_time); } void RandomArray::loadArray() { this->ir = new int[this->n]; for (int i=0; i!= this->n; i++) this->ir[i] = rand()%1000; } void RandomArray::printArray() { for (int i=0; i!= this->n; i++) std::cout << this->ir[i] << " "; std::cout << "\n"; } void RandomArray::freeArray() { delete[] this->ir; } void RandomArray::setSize(int n) { this->n = n; }
[ "smartsunnytsai@gmail.com" ]
smartsunnytsai@gmail.com
9eb2cf457e4ccd7e37132deec5ebb5987fb99f63
927c7fa3c34d2ea8cb9d3647cc8759d2cd7229fe
/source/h/substance/bullet/enemy_shot/Enemy_shot.h
543c8bb41548c36c55a4de48461d3c98e0b62a2c
[]
no_license
yu-chan/shooting
effec1dc1bca29ec32163c70820a77aee597ee99
b31ca14036bdc5b130fb43da597fe84ca649e6e5
refs/heads/master
2021-01-21T04:55:21.389270
2016-06-29T21:35:14
2016-06-29T21:35:14
55,126,299
0
0
null
null
null
null
UTF-8
C++
false
false
125
h
#pragma once class Enemy_shot : public Shot { public: Enemy_shot(); ~Enemy_shot(); void shot_regist(); void move(); };
[ "y.ooki0125@outlook.com" ]
y.ooki0125@outlook.com
17038f6365fa76c694e4cfc5f2f98239f174357d
b5275b89d28a1182c126e6af6369d95f297536a2
/AlgorithmTraining/IOI/2007/miners.cpp
65b18ed1fb0639e8b7d19ed9a6c8b4420081de41
[]
no_license
riryk/AlgorithmTraining
b84722dee58cfe76e61bb721da351a596b44ec2c
5d232180a603bb445c784d1bbba532d81ed904a5
refs/heads/master
2021-08-04T16:49:02.050175
2021-07-22T14:31:43
2021-07-22T14:31:43
102,188,532
0
0
null
null
null
null
UTF-8
C++
false
false
1,022
cpp
#include "stdafx.h" #include <vector> #include <map> #include <algorithm> #include <errno.h> using namespace System; using namespace std; int A[100000]; int N; int dp[16][16][100000]; // supply: 1, 2, 3. // prev supply 000000aabb int getScore(int prevsupply, int supply) { int a = (prevsupply >> 2); int b = (prevsupply & 3); int c = supply; int total = ((1 << a)|(1 << b)|(1 << c)) & 14; int bitcount = ((total >> 2) & 1) + ((total >> 3) & 1) + ((total >> 4) & 1); return bitcount; } int solve(int m1, int m2, int i) { if (i == N) return 0; return min(solve(((m1 << 2)|A[i])&15, m2, i + 1) + getScore(m1, A[i]), solve(m1, ((m2 << 2)|A[i])&15, i + 1) + getScore(m2, A[i])); } int solvedp(int m1, int m2, int i) { if (i == N) return 0; if (dp[m1][m2][i] != -1) return dp[m1][m2][i]; int result = min(solve(((m1 << 2)|A[i])&15, m2, i + 1) + getScore(m1, A[i]), solve(m1, ((m2 << 2)|A[i])&15, i + 1) + getScore(m2, A[i])); dp[m1][m2][i] = result; return result; }
[ "Ruslan_Iryk@epam.com" ]
Ruslan_Iryk@epam.com
5464ff8e7c937bc81fa5402de0aee6dcb8f906f5
df140b749b654e3bfa70e92b91a4433c91017b6a
/Lab2/word/index.cpp
96d497fb6c1f12f1e34e00b7a45d4625646a4db7
[]
no_license
nnaaaa/dsa
1a19e9d15f2f2ebe49eccd7231f0c079f28b2a38
4915565a14f2df17b23184874ab6ab2125667d7f
refs/heads/main
2023-07-16T17:57:22.811788
2021-09-04T16:34:45
2021-09-04T16:34:45
395,194,733
0
0
null
null
null
null
UTF-8
C++
false
false
2,276
cpp
#include <iostream> #include <stdio.h> #include <fstream> #include <vector> #include <string> #include <stdio.h> using namespace std; int *countWord(vector <string> clone,int &c_assign,int &c_compare){ vector <string> word; int *count = new int[clone.size()]; c_assign+=2; for (int i = 0;++c_compare && i < clone.size();++c_assign && ++i){ bool repeat = false; count[i] = 1; c_assign += 2; for (int j = 0;++c_compare && j < word.size();++c_assign && ++j){ if (++c_compare && word[j] == clone[i]){ count[j]++; repeat = true; c_assign += 2; break; } } if (++c_compare && !repeat){ ++c_assign; word.push_back(clone[i]); } } return count; } int *countWord2(vector <string> clone,int &c_assign,int &c_compare){ for (int i = 0; i < clone.size()-1; ++i){ for (int j = i + 1; j < clone.size(); ++j){ if ( clone[i].compare(clone[j]) < 0){ string temp = clone[i]; clone[i] = clone[j]; clone[j] = temp; } } } int *count = new int[clone.size()]; int index = 0; c_assign += 3; for (int i = 0;++c_compare && i < clone.size()-1;++c_assign && ++i){ if (++c_compare && clone[i].compare(clone[i+1]) == 0){ ++c_assign; count[index]++; } else{ ++c_assign; count[index++]++; } } return count; } int main() { vector <string> randomArr{"nguyenanh","end","start","connect","out","the","quit"}; vector<string> a; ofstream f("word.txt"); ofstream f2("word2.txt"); for (int i = 0;i<=500;i+=10) { for (int j = 0; j <= i;++j){ int x = rand() % 7; a.push_back(randomArr[x]); } int c_assign = 0, c_compare = 0; int *arr = countWord(a,c_assign,c_compare); f << i << " " << c_assign << " " << c_compare << endl; c_assign = 0; c_compare = 0; int *arr2 = countWord2(a,c_assign,c_compare); f2 << i << " " << c_assign << " " << c_compare << endl; } system("pause"); return 0; }
[ "nngguyen.anh@gmail.com" ]
nngguyen.anh@gmail.com
30f4c59b1af4bb0bc1d4329b478d1d773f415dac
1ec01a36f14f92c29e161915d8b6a2b0bec8c777
/ouzel/audio/coreaudio/CAAudioDevice.cpp
b7600c06b2d2a463612fd63dbb2ce5268fbd5066
[ "BSD-2-Clause", "BSD-3-Clause" ]
permissive
WengJunFeng/ouzel
f00fcb18ae569ddf5f047b8242e19aede4582ef1
84c3f9779d7913250efe9ac399f272fdc341cee0
refs/heads/master
2020-05-07T16:55:45.104573
2019-04-10T22:37:44
2019-04-10T22:37:44
null
0
0
null
null
null
null
UTF-8
C++
false
false
14,755
cpp
// Copyright 2015-2019 Elviss Strazdins. All rights reserved. #include "core/Setup.h" #if OUZEL_COMPILE_COREAUDIO #include <system_error> #include "CAAudioDevice.hpp" #include "core/Engine.hpp" #include "utils/Log.hpp" #if TARGET_OS_IOS || TARGET_OS_TV # include <objc/message.h> extern "C" id const AVAudioSessionCategoryAmbient; #elif TARGET_OS_MAC static OSStatus deviceListChanged(AudioObjectID, UInt32, const AudioObjectPropertyAddress*, void*) { // TODO: implement return 0; } static OSStatus deviceUnplugged(AudioObjectID, UInt32, const AudioObjectPropertyAddress*, void*) { // TODO: implement return noErr; } #endif static OSStatus outputCallback(void* inRefCon, AudioUnitRenderActionFlags*, const AudioTimeStamp*, UInt32, UInt32, AudioBufferList* ioData) { ouzel::audio::CAAudioDevice* audioDeviceCA = static_cast<ouzel::audio::CAAudioDevice*>(inRefCon); try { audioDeviceCA->outputCallback(ioData); } catch (const std::exception& e) { ouzel::engine->log(ouzel::Log::Level::ERR) << e.what(); return -1; } return noErr; } namespace ouzel { namespace audio { class CoreAudioErrorCategory final: public std::error_category { public: const char* name() const noexcept override { return "CoreAudio"; } std::string message(int condition) const override { switch (condition) { case kAudio_UnimplementedError: return "kAudio_UnimplementedError"; case kAudio_FileNotFoundError: return "kAudio_FileNotFoundError"; case kAudio_FilePermissionError: return "kAudio_FilePermissionError"; case kAudio_TooManyFilesOpenError: return "kAudio_TooManyFilesOpenError"; case kAudio_BadFilePathError: return "kAudio_BadFilePathError"; case kAudio_ParamError: return "kAudio_ParamError"; case kAudio_MemFullError: return "kAudio_MemFullError"; default: return "Unknown error (" + std::to_string(condition) + ")"; } } }; const CoreAudioErrorCategory coreAudioErrorCategory {}; CAAudioDevice::CAAudioDevice(uint32_t initBufferSize, uint32_t initSampleRate, uint16_t initChannels, const std::function<void(uint32_t frames, uint16_t channels, uint32_t sampleRate, std::vector<float>& samples)>& initDataGetter): AudioDevice(Driver::COREAUDIO, initBufferSize, initSampleRate, initChannels, initDataGetter) { OSStatus result; #if TARGET_OS_IOS || TARGET_OS_TV id audioSession = reinterpret_cast<id (*)(Class, SEL)>(&objc_msgSend)(objc_getClass("AVAudioSession"), sel_getUid("sharedInstance")); reinterpret_cast<BOOL (*)(id, SEL, id, id)>(&objc_msgSend)(audioSession, sel_getUid("setCategory:error:"), AVAudioSessionCategoryAmbient, nil); #elif TARGET_OS_MAC static constexpr AudioObjectPropertyAddress deviceListAddress = { kAudioHardwarePropertyDevices, kAudioObjectPropertyScopeGlobal, kAudioObjectPropertyElementMaster }; if ((result = AudioObjectAddPropertyListener(kAudioObjectSystemObject, &deviceListAddress, deviceListChanged, this)) != noErr) throw std::system_error(result, coreAudioErrorCategory, "Failed to add CoreAudio property listener"); static constexpr AudioObjectPropertyAddress defaultDeviceAddress = { kAudioHardwarePropertyDefaultOutputDevice, kAudioObjectPropertyScopeGlobal, kAudioObjectPropertyElementMaster }; UInt32 size = sizeof(AudioDeviceID); if ((result = AudioObjectGetPropertyData(kAudioObjectSystemObject, &defaultDeviceAddress, 0, nullptr, &size, &deviceId)) != noErr) throw std::system_error(result, coreAudioErrorCategory, "Failed to get CoreAudio output device"); static constexpr AudioObjectPropertyAddress aliveAddress = { kAudioDevicePropertyDeviceIsAlive, kAudioDevicePropertyScopeOutput, kAudioObjectPropertyElementMaster }; UInt32 alive = 0; size = sizeof(alive); if ((result = AudioObjectGetPropertyData(deviceId, &aliveAddress, 0, nullptr, &size, &alive)) != noErr) throw std::system_error(result, coreAudioErrorCategory, "Failed to get CoreAudio device status"); if (!alive) throw std::system_error(result, coreAudioErrorCategory, "Requested CoreAudio device is not alive"); static constexpr AudioObjectPropertyAddress hogModeAddress = { kAudioDevicePropertyHogMode, kAudioDevicePropertyScopeOutput, kAudioObjectPropertyElementMaster }; pid_t pid = 0; size = sizeof(pid); if ((result = AudioObjectGetPropertyData(deviceId, &hogModeAddress, 0, nullptr, &size, &pid)) != noErr) throw std::system_error(result, coreAudioErrorCategory, "Failed to check if CoreAudio device is in hog mode"); if (pid != -1) throw std::runtime_error("Requested CoreAudio device is being hogged"); static constexpr AudioObjectPropertyAddress nameAddress = { kAudioObjectPropertyName, kAudioDevicePropertyScopeOutput, kAudioObjectPropertyElementMaster }; CFStringRef tempStringRef = nullptr; size = sizeof(CFStringRef); if ((result = AudioObjectGetPropertyData(deviceId, &nameAddress, 0, nullptr, &size, &tempStringRef)) != noErr) throw std::system_error(result, coreAudioErrorCategory, "Failed to get CoreAudio device name"); if (tempStringRef) { std::string name; if (const char* deviceName = CFStringGetCStringPtr(tempStringRef, kCFStringEncodingUTF8)) name = deviceName; else { CFIndex stringLength = CFStringGetLength(tempStringRef); std::vector<char> temp(static_cast<size_t>(CFStringGetMaximumSizeForEncoding(stringLength, kCFStringEncodingUTF8)) + 1); if (CFStringGetCString(tempStringRef, temp.data(), static_cast<CFIndex>(temp.size()), kCFStringEncodingUTF8)) for (auto i = temp.begin(); i != temp.end() && *i; ++i) name.push_back(*i); } CFRelease(tempStringRef); engine->log(Log::Level::INFO) << "Using " << name << " for audio"; } #endif AudioComponentDescription desc; desc.componentType = kAudioUnitType_Output; #if TARGET_OS_IOS || TARGET_OS_TV desc.componentSubType = kAudioUnitSubType_RemoteIO; #elif TARGET_OS_MAC desc.componentSubType = kAudioUnitSubType_DefaultOutput; #endif desc.componentManufacturer = kAudioUnitManufacturer_Apple; desc.componentFlags = 0; desc.componentFlagsMask = 0; audioComponent = AudioComponentFindNext(nullptr, &desc); if (!audioComponent) throw std::runtime_error("Failed to find requested CoreAudio component"); #if TARGET_OS_MAC && !TARGET_OS_IOS && !TARGET_OS_TV if ((result = AudioObjectAddPropertyListener(deviceId, &aliveAddress, deviceUnplugged, this)) != noErr) throw std::system_error(result, coreAudioErrorCategory, "Failed to add CoreAudio property listener"); #endif if ((result = AudioComponentInstanceNew(audioComponent, &audioUnit)) != noErr) throw std::system_error(result, coreAudioErrorCategory, "Failed to create CoreAudio component instance"); #if TARGET_OS_MAC && !TARGET_OS_IOS && !TARGET_OS_TV if ((result = AudioUnitSetProperty(audioUnit, kAudioOutputUnitProperty_CurrentDevice, kAudioUnitScope_Global, 0, &deviceId, sizeof(AudioDeviceID))) != noErr) throw std::system_error(result, coreAudioErrorCategory, "Failed to set CoreAudio unit property"); #endif constexpr AudioUnitElement bus = 0; AudioStreamBasicDescription streamDescription; streamDescription.mSampleRate = sampleRate; streamDescription.mFormatID = kAudioFormatLinearPCM; streamDescription.mFormatFlags = kLinearPCMFormatFlagIsFloat; streamDescription.mChannelsPerFrame = channels; streamDescription.mFramesPerPacket = 1; streamDescription.mBitsPerChannel = sizeof(float) * 8; streamDescription.mBytesPerFrame = streamDescription.mBitsPerChannel * streamDescription.mChannelsPerFrame / 8; streamDescription.mBytesPerPacket = streamDescription.mBytesPerFrame * streamDescription.mFramesPerPacket; streamDescription.mReserved = 0; sampleFormat = SampleFormat::FLOAT32; sampleSize = sizeof(float); if ((result = AudioUnitSetProperty(audioUnit, kAudioUnitProperty_StreamFormat, kAudioUnitScope_Input, bus, &streamDescription, sizeof(streamDescription))) != noErr) { engine->log(Log::Level::WARN) << "Failed to set CoreAudio unit stream format to float, error: " << result; streamDescription.mFormatFlags = kLinearPCMFormatFlagIsPacked | kAudioFormatFlagIsSignedInteger; streamDescription.mBitsPerChannel = sizeof(int16_t) * 8; streamDescription.mBytesPerFrame = streamDescription.mBitsPerChannel * streamDescription.mChannelsPerFrame / 8; streamDescription.mBytesPerPacket = streamDescription.mBytesPerFrame * streamDescription.mFramesPerPacket; if ((result = AudioUnitSetProperty(audioUnit, kAudioUnitProperty_StreamFormat, kAudioUnitScope_Input, bus, &streamDescription, sizeof(streamDescription))) != noErr) throw std::system_error(result, coreAudioErrorCategory, "Failed to set CoreAudio unit stream format"); sampleFormat = SampleFormat::SINT16; sampleSize = sizeof(int16_t); } AURenderCallbackStruct callback; callback.inputProc = ::outputCallback; callback.inputProcRefCon = this; if ((result = AudioUnitSetProperty(audioUnit, kAudioUnitProperty_SetRenderCallback, kAudioUnitScope_Input, bus, &callback, sizeof(callback))) != noErr) throw std::system_error(result, coreAudioErrorCategory, "Failed to set CoreAudio unit output callback"); UInt32 inIOBufferFrameSize = 512; if ((result = AudioUnitSetProperty(audioUnit, kAudioDevicePropertyBufferFrameSize, kAudioUnitScope_Global, 0, &inIOBufferFrameSize, sizeof(UInt32))) != noErr) throw std::system_error(result, coreAudioErrorCategory, "Failed to set CoreAudio buffer size"); if ((result = AudioUnitInitialize(audioUnit)) != noErr) throw std::system_error(result, coreAudioErrorCategory, "Failed to initialize CoreAudio unit"); } CAAudioDevice::~CAAudioDevice() { if (audioUnit) { AudioOutputUnitStop(audioUnit); AURenderCallbackStruct callback; callback.inputProc = nullptr; callback.inputProcRefCon = nullptr; constexpr AudioUnitElement bus = 0; AudioUnitSetProperty(audioUnit, kAudioUnitProperty_SetRenderCallback, kAudioUnitScope_Input, bus, &callback, sizeof(callback)); AudioComponentInstanceDispose(audioUnit); } #if TARGET_OS_MAC && !TARGET_OS_IOS && !TARGET_OS_TV static constexpr AudioObjectPropertyAddress deviceListAddress = { kAudioHardwarePropertyDevices, kAudioObjectPropertyScopeGlobal, kAudioObjectPropertyElementMaster }; AudioObjectRemovePropertyListener(kAudioObjectSystemObject, &deviceListAddress, deviceListChanged, this); if (deviceId) { static constexpr AudioObjectPropertyAddress aliveAddress = { kAudioDevicePropertyDeviceIsAlive, kAudioDevicePropertyScopeOutput, kAudioObjectPropertyElementMaster }; AudioObjectRemovePropertyListener(deviceId, &aliveAddress, deviceUnplugged, this); } #endif } void CAAudioDevice::start() { OSStatus result; if ((result = AudioOutputUnitStart(audioUnit)) != noErr) throw std::system_error(result, coreAudioErrorCategory, "Failed to start CoreAudio output unit"); } void CAAudioDevice::outputCallback(AudioBufferList* ioData) { for (UInt32 i = 0; i < ioData->mNumberBuffers; ++i) { AudioBuffer& buffer = ioData->mBuffers[i]; getData(buffer.mDataByteSize / (sampleSize * channels), data); std::copy(data.begin(), data.end(), static_cast<uint8_t*>(buffer.mData)); } } } // namespace audio } // namespace ouzel #endif
[ "elviss@elviss.lv" ]
elviss@elviss.lv
7e82a8e820151319aba6bf1e4bae3a0195d66c55
54399f5d4ac16ca0e241cf504368c92f6885b005
/tags/trunk_before_2.0_switch/libfreebob/src/bebob/bebob_dl_codes.cpp
b93181c12308b0fdb017cdfee3f8e2b620ee852b
[ "LicenseRef-scancode-warranty-disclaimer" ]
no_license
janosvitok/ffado
82dcafeeed08a53a7ab48949a0b1e89fba59a799
99b2515d787332e8def72f3d4f0411157915134c
refs/heads/master
2020-04-09T11:14:29.768311
2018-06-26T13:38:39
2018-06-26T13:38:39
6,838,393
0
0
null
null
null
null
UTF-8
C++
false
false
9,314
cpp
/* bebob_dl_codes.cpp * Copyright (C) 2006 by Daniel Wagner * * This file is part of FreeBoB. * * FreeBoB 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. * FreeBoB 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 FreeBoB; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, * MA 02111-1307 USA. */ #include "bebob/bebob_dl_codes.h" #include "bebob/bebob_dl_bcd.h" unsigned short BeBoB::CommandCodes::m_gCommandId = 0; BeBoB::CommandCodes::CommandCodes( fb_quadlet_t protocolVersion, fb_byte_t commandCode, size_t msgSize, fb_byte_t operandSizeRequest, fb_byte_t operandSizeRespone ) : m_commandId( m_gCommandId++ ) , m_protocolVersion( protocolVersion ) , m_commandCode( commandCode ) , m_msgSize( msgSize ) , m_operandSizeRequest( operandSizeRequest ) , m_operandSizeResponse( operandSizeRespone ) , m_resp_protocolVersion( 0 ) , m_resp_commandId( 0 ) , m_resp_commandCode( 0 ) , m_resp_operandSize( 0 ) { } BeBoB::CommandCodes::~CommandCodes() { } bool BeBoB::CommandCodes::serialize( IOSSerialize& se ) { byte_t tmp; bool result = se.write( m_protocolVersion, "CommandCodes: protocol version" ); tmp = m_commandId & 0xff; result &= se.write( tmp, "CommandCodes: command id low" ); tmp = m_commandId >> 8; result &= se.write( tmp, "CommandCodes: command id high" ); result &= se.write( m_commandCode, "CommandCodes: command code" ); result &= se.write( m_operandSizeRequest, "CommandCodes: request operand size" ); return result; } bool BeBoB::CommandCodes::deserialize( IISDeserialize& de ) { bool result = de.read( &m_resp_protocolVersion ); fb_byte_t tmp; result &= de.read( &tmp ); m_resp_commandId = tmp; result &= de.read( &tmp ); m_resp_commandId |= tmp << 8; result &= de.read( &m_resp_commandCode ); result &= de.read( &m_resp_operandSize ); return result; } size_t BeBoB::CommandCodes::getMaxSize() { return 2 * sizeof( fb_quadlet_t ) + m_msgSize; } //////////////////////////////// BeBoB::CommandCodesReset::CommandCodesReset( fb_quadlet_t protocolVersion, EStartMode startMode ) : CommandCodes( protocolVersion, eCmdC_Reset, sizeof( m_startMode ), 1, 0 ) , m_startMode( startMode ) { } BeBoB::CommandCodesReset::~CommandCodesReset() { } bool BeBoB::CommandCodesReset::serialize( IOSSerialize& se ) { bool result = CommandCodes::serialize( se ); result &= se.write( m_startMode, "CommandCodesReset: boot mode" ); return result; } bool BeBoB::CommandCodesReset::deserialize( IISDeserialize& de ) { return CommandCodes::deserialize( de ); } //////////////////////////////// BeBoB::CommandCodesProgramGUID::CommandCodesProgramGUID( fb_quadlet_t protocolVersion, fb_octlet_t guid ) : CommandCodes( protocolVersion, eCmdC_ProgramGUID, sizeof( m_guid ), 2, 0 ) , m_guid( guid ) { } BeBoB::CommandCodesProgramGUID::~CommandCodesProgramGUID() { } bool BeBoB::CommandCodesProgramGUID::serialize( IOSSerialize& se ) { bool result = CommandCodes::serialize( se ); fb_quadlet_t tmp = m_guid >> 32; result &= se.write( tmp, "CommandCodesProgramGUID: GUID (high)" ); tmp = m_guid & 0xffffffff; result &= se.write( tmp, "CommandCodesProgramGUID: GUID (low)" ); return result; } bool BeBoB::CommandCodesProgramGUID::deserialize( IISDeserialize& de ) { return CommandCodes::deserialize( de ); } //////////////////////////////// BeBoB::CommandCodesDownloadStart::CommandCodesDownloadStart( fb_quadlet_t protocolVersion, EObject object ) : CommandCodes( protocolVersion, eCmdC_DownloadStart, 10*4, 10, 1 ) , m_object( object ) , m_date( 0 ) , m_time( 0 ) , m_id( 0 ) , m_version( 0 ) , m_address( 0 ) , m_length( 0 ) , m_crc( 0 ) { } BeBoB::CommandCodesDownloadStart::~CommandCodesDownloadStart() { } bool BeBoB::CommandCodesDownloadStart::serialize( IOSSerialize& se ) { bool result = CommandCodes::serialize( se ); result &= se.write( m_object, "CommandCodesDownloadStart: object" ); for ( unsigned int i = 0; i < sizeof( m_date ); ++i ) { fb_byte_t* tmp = ( fb_byte_t* )( &m_date ); result &= se.write( tmp[i], "CommandCodesDownloadStart: date" ); } for ( unsigned int i = 0; i < sizeof( m_date ); ++i ) { fb_byte_t* tmp = ( fb_byte_t* )( &m_time ); result &= se.write( tmp[i], "CommandCodesDownloadStart: time" ); } result &= se.write( m_id, "CommandCodesDownloadStart: id" ); result &= se.write( m_version, "CommandCodesDownloadStart: version" ); result &= se.write( m_address, "CommandCodesDownloadStart: address" ); result &= se.write( m_length, "CommandCodesDownloadStart: length" ); result &= se.write( m_crc, "CommandCodesDownloadStart: crc" ); return result; } bool BeBoB::CommandCodesDownloadStart::deserialize( IISDeserialize& de ) { bool result = CommandCodes::deserialize( de ); result &= de.read( reinterpret_cast<fb_quadlet_t*>( &m_resp_max_block_size ) ); return result; } //////////////////////////////// BeBoB::CommandCodesDownloadBlock::CommandCodesDownloadBlock( fb_quadlet_t protocolVersion ) : CommandCodes( protocolVersion, eCmdC_DownloadBlock, 12, 3, 2 ) , m_seqNumber( 0 ) , m_address ( 0 ) , m_resp_seqNumber( 0 ) , m_resp_errorCode( 0 ) { } BeBoB::CommandCodesDownloadBlock::~CommandCodesDownloadBlock() { } bool BeBoB::CommandCodesDownloadBlock::serialize( IOSSerialize& se ) { bool result = CommandCodes::serialize( se ); result &= se.write( m_seqNumber, "CommandCodesDownloadBlock: sequence number" ); result &= se.write( m_address, "CommandCodesDownloadBlock: address" ); result &= se.write( m_numBytes, "CommandCodesDownloadBlock: number of bytes" ); return result; } bool BeBoB::CommandCodesDownloadBlock::deserialize( IISDeserialize& de ) { bool result = CommandCodes::deserialize( de ); result &= de.read( &m_resp_seqNumber ); result &= de.read( &m_resp_errorCode ); return result; } //////////////////////////////// BeBoB::CommandCodesDownloadEnd::CommandCodesDownloadEnd( fb_quadlet_t protocolVersion ) : CommandCodes( protocolVersion, eCmdC_DownloadEnd, 2, 0, 2 ) { } BeBoB::CommandCodesDownloadEnd::~CommandCodesDownloadEnd() { } bool BeBoB::CommandCodesDownloadEnd::serialize( IOSSerialize& se ) { return CommandCodes::serialize( se ); } bool BeBoB::CommandCodesDownloadEnd::deserialize( IISDeserialize& de ) { bool result = CommandCodes::deserialize( de ); result &= de.read( &m_resp_crc32 ); result &= de.read( &m_resp_valid ); return result; } //////////////////////////////// BeBoB::CommandCodesInitializePersParam::CommandCodesInitializePersParam( fb_quadlet_t protocolVersion ) : CommandCodes( protocolVersion, eCmdC_InitPersParams, 0, 0, 0 ) { } BeBoB::CommandCodesInitializePersParam::~CommandCodesInitializePersParam() { } bool BeBoB::CommandCodesInitializePersParam::serialize( IOSSerialize& se ) { return CommandCodes::serialize( se ); } bool BeBoB::CommandCodesInitializePersParam::deserialize( IISDeserialize& de ) { return CommandCodes::deserialize( de ); } //////////////////////////////// BeBoB::CommandCodesInitializeConfigToFactorySetting::CommandCodesInitializeConfigToFactorySetting( fb_quadlet_t protocolVersion ) : CommandCodes( protocolVersion, eCmdC_InitConfigToFactorySetting, 0, 0, 0 ) { } BeBoB::CommandCodesInitializeConfigToFactorySetting::~CommandCodesInitializeConfigToFactorySetting() { } bool BeBoB::CommandCodesInitializeConfigToFactorySetting::serialize( IOSSerialize& se ) { return CommandCodes::serialize( se ); } bool BeBoB::CommandCodesInitializeConfigToFactorySetting::deserialize( IISDeserialize& de ) { return CommandCodes::deserialize( de ); } //////////////////////////////// BeBoB::CommandCodesGo::CommandCodesGo( fb_quadlet_t protocolVersion, EStartMode startMode ) : CommandCodes( protocolVersion, eCmdC_Go, sizeof( m_startMode ), 1, 1 ) , m_startMode( startMode ) { } BeBoB::CommandCodesGo::~CommandCodesGo() { } bool BeBoB::CommandCodesGo::serialize( IOSSerialize& se ) { bool result = CommandCodes::serialize( se ); result &= se.write( m_startMode, "CommandCodesGo: start mode" ); return result; } bool BeBoB::CommandCodesGo::deserialize( IISDeserialize& de ) { bool result = CommandCodes::deserialize( de ); result &= de.read( &m_resp_validCRC ); return result; }
[ "pieterpalmers@2be59082-3212-0410-8809-b0798e1608f0" ]
pieterpalmers@2be59082-3212-0410-8809-b0798e1608f0
e733e63c172cdf6eb0156c44cf7d6490fa0f034d
0141a8f26284dbfd824d9b054a899f6b6d7510eb
/abc/abc/100-150/abc139/d.cpp
d5eefbf45876cea9bf56ac7ffff7463d4345f105
[]
no_license
yunotama/atcoder
2da758f479da6aaaa17c88f13995e42554cb0701
ddb16580416d04abaa6c4d543dc82a62706d283a
refs/heads/master
2021-03-15T06:20:52.038947
2020-03-12T13:19:34
2020-03-12T13:19:34
246,830,843
0
0
null
2020-03-12T13:19:36
2020-03-12T12:39:16
null
UTF-8
C++
false
false
184
cpp
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); i++) using namespace std; int main() { long long n; cin >> n; cout << (n - 1) * n / 2 << endl; }
[ "kabi.hiroya@gmail.com" ]
kabi.hiroya@gmail.com
a348ff7c2d276bae6f4786450983b70448e4dd4f
3a5a2dc09a6a3fd49c65dcae0d39200af5ea5e3f
/src/core/exceptions/NoMemoryException.cpp
e49fc9d4427036fd60d103fba057e645aae28e37
[ "BSD-3-Clause" ]
permissive
intel/ixpdimm_sw
d72ec153471bedb9c95db119e5fc422be4c66cc7
dbd3c99f3524ca6aff80f194ff0f67d4a543b9e3
refs/heads/master
2023-06-06T22:02:20.199697
2022-08-04T22:49:58
2022-08-04T22:49:58
46,385,178
17
7
BSD-3-Clause
2018-03-08T20:51:05
2015-11-18T00:47:04
C
UTF-8
C++
false
false
1,592
cpp
/* * Copyright (c) 2016, Intel Corporation * * 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 Intel Corporation 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. */ #include "NoMemoryException.h"
[ "nicholas.w.moulin@intel.com" ]
nicholas.w.moulin@intel.com
a9345df1e90fd0a1a130ba2405222ec2a5561bf9
28c000caf6617ba2074e0f2a8fc936ccb8c01fb3
/poj/1394/6565061_WA.cc
5997e22e2c7235541adeea90b25307eb9f000483
[]
no_license
ATM006/acm_problem_code
f597fa31033fd663b14d74ad94cae3f7c1629b99
ac40d230cd450bcce60df801eb3b8ce9409dfaac
refs/heads/master
2020-08-31T21:34:00.707529
2014-01-23T05:30:42
2014-01-23T05:30:42
null
0
0
null
null
null
null
UTF-8
C++
false
false
3,014
cc
#include <cstdio> #include <cstring> #include <map> #include <queue> #include <string> using namespace std; struct edge{ int to; int d; edge *next; }edg[100002],*vert[102]; struct QN{ int u; int start,d; bool operator <(const QN &a)const{ if(a.d==d) return a.start>start; return a.d<d; } }; int dis[102]; void add_edge(int x,int y,int tim1,int tim2,int &top){ edge *p=&edg[++top]; p->to=y; p->d=tim1*10000+tim2; p->next=vert[x]; vert[x]=p; } void dijkstra(int s,int t,int &st,int &ed,int X,int n){ QN now,next; priority_queue<QN>Q; for(int i=0;i<n;i++)dis[i]=10000; for(edge *p=vert[s];p;p=p->next){ if(p->d/10000>=X){ now.u=p->to; now.start=p->d/10000; now.d=p->d%10000; Q.push(now); } } while(!Q.empty()){ now=Q.top();Q.pop(); //printf("%d %d\n",now.u,now.d); if(now.u==t){ st=now.start;ed=now.d; return ; } int u=now.u; int d=now.d; for(edge *p=vert[u];p;p=p->next){ if(p->d/10000>=d&&(p->d%10000<dis[p->to])){ now.u=p->to; now.d=p->d%10000; dis[p->to]=p->d%10000; Q.push(now); } } } } int main() { int nca=1,n; while(scanf("%d",&n),n){ char sta[50],end[50]; map<string,int>mp; map<string,int>::iterator p,q; for(int i=0;i<n;i++){ scanf("%s",sta); mp[sta]=i; } int T,top=-1; memset(vert,0,sizeof(vert)); scanf("%d",&T); for(int i=0;i<T;i++){ int u,v,m,tim1,tim2; scanf("%d",&m); for(int j=0;j<m;j++){ scanf("%d%s",&tim2,end); if(j!=0){ p=mp.find(sta); q=mp.find(end); if(p!=mp.end()&&q!=mp.end()&&tim1<=tim2){ u=p->second; v=q->second; add_edge(u,v,tim1,tim2,top); } } strcpy(sta,end); tim1=tim2; } } scanf("%d%s%s",&T,sta,end); int u=-1,v=-1; p=mp.find(sta); if(p!=mp.end()) u=p->second; p=mp.find(end); if(p!=mp.end()) v=p->second; printf("Scenario #%d\n",nca++); if(u==-1||v==-1){ puts("No connection\n"); } else{ int tim1=-1,tim2=1000000; dijkstra(u,v,tim1,tim2,T,n); if(tim2==1000000) puts("No connection\n"); else{ printf("Departure %.4d %s\n",tim1,sta); printf("Arrival %.4d %s\n\n",tim2,end); } } } return 0; }
[ "wangjunyong@doodlemobile.com" ]
wangjunyong@doodlemobile.com
d10592bbedfd868c9336ba62e9e1d1d384ebe956
c605c0bdc5c80539b3302ab892d3378ef11d4047
/백준 using c++/10026.cpp
91d469f47cf1bc49ef73fea68bde680b33453d35
[]
no_license
yujin0719/Problem-Solving
44b4d6e5669c56488ab347e17d22b8346f560a88
a481d7028f98b107f96483a7b3718b6d401c7822
refs/heads/master
2023-06-08T07:47:27.584629
2021-07-01T11:26:53
2021-07-01T11:26:53
252,609,862
0
0
null
null
null
null
UTF-8
C++
false
false
2,182
cpp
//10026: 적록색약 #include <bits/stdc++.h> using namespace std; char board[101][101]; int vis[101][101]; int dx[4] = {1,0,-1,0}; int dy[4] = {0,1,0,-1}; char color[3] = {'R','B','G'}; int main(){ ios::sync_with_stdio(0); cin.tie(0); int N; cin >> N; for(int i = 0; i < N; i++) cin >> board[i]; queue<pair<int,int> > q; int origin = 0; int error = 0; for(int k = 0; k < 3; k++){ for(int i = 0; i < N; i++){ for (int j = 0; j < N; j++){ if(color[k] == board[i][j] && vis[i][j] == 0){ origin +=1; q.push({i,j}); vis[i][j] = 1; while(!q.empty()){ pair<int,int> cur = q.front(); q.pop(); for(int m = 0; m < 4; m ++){ if(cur.first+dx[m] >= 0 && cur.second+dy[m] >= 0 && cur.first+dx[m] < N && cur.second+dy[m] < N){ if(vis[cur.first+dx[m]][cur.second+dy[m]] == 0 && board[cur.first+dx[m]][cur.second+dy[m]] == color[k]){ q.push({cur.first+dx[m],cur.second+dy[m]}); vis[cur.first+dx[m]][cur.second+dy[m]] = 1; } } } } } } } } for(int i = 0; i < N; i++){ fill(vis[i],vis[i]+N,0); for(int j = 0; j < N; j++){ if(board[i][j] == 'G') board[i][j] = 'R'; } } for(int k = 0; k < 2; k++){ for(int i = 0; i < N; i++){ for (int j = 0; j < N; j++){ if(color[k] == board[i][j] && vis[i][j] == 0){ error +=1; q.push({i,j}); vis[i][j] = 1; while(!q.empty()){ pair<int,int> cur = q.front(); q.pop(); for(int m = 0; m < 4; m ++){ if(cur.first+dx[m] >= 0 && cur.second+dy[m] >= 0 && cur.first+dx[m] < N && cur.second+dy[m] < N){ if(vis[cur.first+dx[m]][cur.second+dy[m]] == 0 && board[cur.first+dx[m]][cur.second+dy[m]] == color[k]){ q.push({cur.first+dx[m],cur.second+dy[m]}); vis[cur.first+dx[m]][cur.second+dy[m]] = 1; } } } } } } } } cout << origin << ' ' << error << '\n'; }
[ "yujin1760@naver.com" ]
yujin1760@naver.com
0481a5ae07f2a69c9beab888097a02c1261cb7c2
1af49694004c6fbc31deada5618dae37255ce978
/ui/ozone/platform/wayland/host/wayland_zaura_shell.h
3057ff66ce824b29906a3ccc9b220df95f6f6352
[ "BSD-3-Clause" ]
permissive
sadrulhc/chromium
59682b173a00269ed036eee5ebfa317ba3a770cc
a4b950c23db47a0fdd63549cccf9ac8acd8e2c41
refs/heads/master
2023-02-02T07:59:20.295144
2020-12-01T21:32:32
2020-12-01T21:32:32
317,678,056
3
0
BSD-3-Clause
2020-12-01T21:56:26
2020-12-01T21:56:25
null
UTF-8
C++
false
false
1,092
h
// Copyright 2020 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 UI_OZONE_PLATFORM_WAYLAND_HOST_WAYLAND_ZAURA_SHELL_H_ #define UI_OZONE_PLATFORM_WAYLAND_HOST_WAYLAND_ZAURA_SHELL_H_ #include "ui/ozone/platform/wayland/common/wayland_object.h" namespace ui { class WaylandConnection; // Wraps the zaura_shell object. class WaylandZAuraShell { public: WaylandZAuraShell(zaura_shell* aura_shell, WaylandConnection* connection); WaylandZAuraShell(const WaylandZAuraShell&) = delete; WaylandZAuraShell& operator=(const WaylandZAuraShell&) = delete; ~WaylandZAuraShell(); zaura_shell* wl_object() const { return obj_.get(); } private: // zaura_shell_listener static void OnLayoutMode(void* data, struct zaura_shell* zaura_shell, uint32_t layout_mode); wl::Object<zaura_shell> obj_; WaylandConnection* const connection_; }; } // namespace ui #endif // UI_OZONE_PLATFORM_WAYLAND_HOST_WAYLAND_ZAURA_SHELL_H_
[ "commit-bot@chromium.org" ]
commit-bot@chromium.org
69561bc3145a4f6ccdba59817ead744521eb6aca
aa8a7cb9058b9c68e9688fe650124ba518a3bbc9
/Assignment1/Source/MovableCamera.cpp
d6fc0b19af05db603fff5066d47c366a20dbd76d
[]
no_license
kiozune/Climbing-Simulator
162b6568be477cb6015574a49eb2f50ead528364
c018ec9cf6287cfc1bea9a3fb8073cdde64d6cc0
refs/heads/master
2020-04-22T08:17:36.757266
2019-02-27T20:11:36
2019-02-27T20:11:36
170,239,626
1
1
null
null
null
null
UTF-8
C++
false
false
1,335
cpp
#include "MovableCamera.h" #include "Utility.h" void MoveableCamera::update() { front.x = cos(rad(yaw)) * cos(rad(pitch)); front.y = sin(rad(pitch)); front.z = sin(rad(yaw)) * cos(rad(pitch)); if (front.IsZero()) return; front = front.Normalize(); right = front.Cross(worldUp).Normalize(); up = right.Cross(front).Normalize(); target = position + front; forward = right.Cross(worldUp).Normalize(); } void MoveableCamera::setTarget(Vector3 target) {} void MoveableCamera::move(const double dt) { GLfloat velocity = moveSpeed * dt; if (Application::IsKeyPressed('W')) position -= forward * velocity; if (Application::IsKeyPressed('S')) position += forward * velocity; if (Application::IsKeyPressed('A')) position -= right * velocity; if (Application::IsKeyPressed('D')) position += right * velocity; if (Application::IsKeyPressed(VK_SHIFT)) position -= worldUp * velocity; if (Application::IsKeyPressed(VK_SPACE)) position += worldUp * velocity; } void MoveableCamera::lookAround(GLfloat xPos, GLfloat yPos) { GLfloat xDiff = (xPos - prevX) / 10.0; GLfloat yDiff = (yPos - prevY) / 10.0; if (xDiff) yaw += xDiff; if (yDiff) pitch -= yDiff; // lock pitch if (pitch > 89) pitch = 89; else if (pitch < -89) pitch = -89; prevX = xPos, prevY = yPos; // update vectors update(); }
[ "jameslimbj@gmail.com" ]
jameslimbj@gmail.com
8526437b98c6ea8d311fe63748ab0883c40c3722
f4bc7cf7f667f98e0599ae87a4a558e87be0675a
/C++/121_BestTimetoBuyandSellStock.cpp
483d9572399b69a4f3597bc83d82199c498dc100
[]
no_license
Darren2017/LeetCode
7867cbb8f0946045a51d0ffd80793fcd68c7d987
cf4a6f402b32852affbc78c96e878b924db6cd0b
refs/heads/master
2020-03-27T18:02:18.498098
2019-07-11T15:15:11
2019-07-11T15:15:11
146,894,108
0
0
null
null
null
null
UTF-8
C++
false
false
434
cpp
class Solution { public: int maxProfit(vector<int>& prices) { int min = prices[0], maxprice = 0, len = prices.size(); for(int i = 0; i < len; i++){ if(prices[i] < min){ min = prices[i]; } if(prices[i] - min > maxprice){ maxprice = prices[i] - min; } } return maxprice; } }; /* 感觉这个不像是DP啊! */
[ "17362990052@163.com" ]
17362990052@163.com
28347f87ba7d6a950832025c3ceeab2ebbe369e5
d7cca7519e5c3b3b728a2a0646a5aeb1a9563eeb
/source/development/device-api/device-server-writing/cpp_exchanging/any.cpp
65f1fb16c902060e7286da0e9b54c36793e644c0
[]
no_license
tango-controls/tango-doc
b0354144eb873e3af550365f9becb42638e86e73
d6115b8216ca590b1d47e17046bf71e8af438cb9
refs/heads/master
2021-07-15T20:17:32.897753
2021-02-04T19:00:35
2021-02-04T19:00:35
69,636,146
10
30
null
2021-02-24T21:21:51
2016-09-30T05:19:33
TeX
UTF-8
C++
false
false
561
cpp
CORBA_Any a; Tango_DevLong l1,l2; l1 = 2; a <<= l1; a >>= l2; CORBA_Any b; Tango_DevBoolean b1,b2; b1 = true; b <<= CORBA_Any::from_boolean(b1); b >>= CORBA_Any::to_boolean(b2); CORBA_Any s; Tango_DevString str1,str2; str1 = "I like dancing TANGO"; a <<= str1; a >>= str2; // CORBA_string_free(str2); // a <<= CORBA_string_dup("Oups"); CORBA_Any seq; Tango_DevVarFloatArray fl_arr1; fl_arr1.length(2); fl_arr1[0] = 1.0; fl_arr1[1] = 2.0; seq <<= fl_arr1; Tango_DevVarFloatArray *fl_arr_ptr; seq >>= fl_arr_ptr; // delete fl_arr_ptr;
[ "piotr.goryl@3-controls.com" ]
piotr.goryl@3-controls.com
d5b12df6fc9f226fd8603bf2a9bd6e00bf4cfdf0
2a63cbaee66b1697890bdbd11ff80359317d612f
/SimpleRpc/rpcserver.h
28c3d7a65806c80ca620d3c054349abb79298f08
[]
no_license
Meteorix/UnrealPocoSdk
757ede5254cf17f89b055aabe85c101dd971bc9a
b3dfdafcc9bf1e44092f17bf49cf58bb8897b7f4
refs/heads/master
2020-03-22T17:45:52.318670
2018-07-11T13:29:17
2018-07-11T13:29:17
140,414,184
1
0
null
null
null
null
UTF-8
C++
false
false
957
h
#ifndef RPCSERVER_H #define RPCSERVER_H #include "iostream" #include <string> #include "Tcp/PassiveSocket.h" #include "WinSock2.h" #include "protocol.h" #include "json.hpp" #include <list> #include <map> #include <thread> #include <functional> using std::string; using std::cout; using std::endl; using json = nlohmann::json; #define MAX_PACKET 4096 class RpcServer { public: RpcServer(); ~RpcServer(); void start(); void close(); void client_task(CActiveSocket *pClient, Protocol proto); void client_task2(SOCKET *ClientSocket, Protocol proto); string handle_rpc_request(string request); void register_rpc_method(string method_name, std::function<json(json)> method_ptr); private: bool running = false; CPassiveSocket m_socket; SOCKET ListenSocket = INVALID_SOCKET; Protocol proto = Protocol(); std::list<std::thread*> client_thread_list = {}; std::map<string, std::function<json(json)>> rpc_method_map = {}; }; #endif // RPCSERVER_H
[ "gzliuxin@corp.netease.com" ]
gzliuxin@corp.netease.com
f9b15bf6096df19270cfdc6688cd04f079ba574b
2b39fffb9b36f79614eccb3e940bcebce465dc46
/protocol/rtp_impl.cpp
c34e220ae11ce98cb4209dd3571faab04e1ed84c
[]
no_license
tonytonyfly/audioengine
d81d93f8d55165996f85c1c00de09c77b1a4b676
4e37f1986ae7cf0ac5fe3cd0be0adf0df6fed8cb
refs/heads/master
2020-06-05T18:48:56.345501
2017-11-18T11:59:19
2017-11-18T11:59:19
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,234
cpp
#include "atp.h" #include "rtp_impl.h" RTPImpl::RTPImpl() { clock_ = Clock::GetRealTimeClock(); receiver_stat_ = ReceiveStatistics::Create( clock_ ); rtp_payload_registry_ = new RTPPayloadRegistry( RTPPayloadStrategy::CreateStrategy(true) ); rtp_parse_ = RtpHeaderParser::Create(); rtp_receiver_ = RtpReceiver::CreateAudioReceiver( clock_, nullptr, this, nullptr, rtp_payload_registry_ ); RtpRtcp::Configuration configure; configure.audio = true; configure.bandwidth_callback = this; configure.clock = clock_; configure.outgoing_transport = this; configure.rtt_stats = this; configure.send_bitrate_observer = this; configure.receive_statistics = receiver_stat_; rtp_rtcp_ = RtpRtcp::CreateRtpRtcp(configure); } RTPImpl::~RTPImpl() { delete receiver_stat_; delete rtp_payload_registry_; delete rtp_parse_; delete rtp_receiver_; delete rtp_rtcp_; delete clock_; } bool RTPImpl::EncodePacket( void* payload, size_t len_of_byte ) { return true; } bool RTPImpl::DecodePacket( void* packet, size_t len_of_byte ) { return true; } bool RTPImpl::SendRtp( const uint8_t* packet, size_t length, const webrtc::PacketOptions& options ) { return true; } bool RTPImpl::SendRtcp( const uint8_t* packet, size_t length ) { return true; } int32_t RTPImpl::OnReceivedPayloadData( const uint8_t* payloadData, const size_t payloadSize, const webrtc::WebRtcRTPHeader* rtpHeader ) { return true; } bool RTPImpl::OnRecoveredPacket( const uint8_t* packet, size_t packet_length ) { return true; } void RTPImpl::OnReceivedEstimatedBitrate( uint32_t bitrate ) { } void RTPImpl::OnReceivedRtcpReceiverReport( const webrtc::ReportBlockList& report_blocks, int64_t rtt, int64_t now_ms ) { } void RTPImpl::OnRttUpdate( int64_t rtt ) { } int64_t RTPImpl::LastProcessedRtt() const { return 0; } void RTPImpl::Notify( const webrtc::BitrateStatistics& total_stats, const webrtc::BitrateStatistics& retransmit_stats, uint32_t ssrc ) { }
[ "zhangnaigan_1989@163.com" ]
zhangnaigan_1989@163.com
cd069c396c5ae70315145d43089e7660f0cd2347
cd433b32df1cc7d3d18f23eb1c10e8bcacd7f1b8
/ClearEEPROM/testStringtoInt/testStringtoInt.ino
0ec2101b317be9519cac4d63c44cf859166554f2
[]
no_license
criticalhitx/ArduinoTA
9818f2a466df01f114fba2ab4fa2d7fc6f175b34
ffd3754b02f4dfa2ef37da3761a2d6624e5c8bce
refs/heads/master
2020-07-12T02:13:45.133498
2019-12-27T17:59:57
2019-12-27T17:59:57
204,691,361
0
0
null
null
null
null
UTF-8
C++
false
false
631
ino
#include<EEPROM.h> //Use 120-125 void setup() { // put your setup code here, to run once: Serial.begin(115200); EEPROM.begin(512); writeKeyEEPROM("176184",24,29); } void loop() { // put your main code here, to run repeatedly: } void writeKeyEEPROM (String key,int startadd,int untiladd) { int count = 0; for (int i=startadd;i<=untiladd;i++) { EEPROM.write(i, key[count]); count++; } EEPROM.commit(); } String readKey (int startadd, int untiladd) { String key; for (int i=startadd;i<=untiladd;i++) { char karakter = char(EEPROM.read(i)); key = String (key+karakter); } return key; }
[ "clink200032@gmail.com" ]
clink200032@gmail.com
91e737f0d1e9eee11da9d94a26a044f198cbef0c
2a7e77565c33e6b5d92ce6702b4a5fd96f80d7d0
/fuzzedpackages/Rfast2/src/apply_funcs_templates.h
9bdd3aeadc1011698b17bc2c4a248713bf74592a
[]
no_license
akhikolla/testpackages
62ccaeed866e2194652b65e7360987b3b20df7e7
01259c3543febc89955ea5b79f3a08d3afe57e95
refs/heads/master
2023-02-18T03:50:28.288006
2021-01-18T13:23:32
2021-01-18T13:23:32
329,981,898
7
1
null
null
null
null
UTF-8
C++
false
false
4,261
h
#include "templates.h" using namespace std; #ifndef FUNCS_TEMPLATES_H #define FUNCS_TEMPLATES_H /* * sum(Bin_Fun( a, b)) * ? is a binary function * a, b are iterators (should be same size) */ template<Binary_Function B, class T1, class T2> inline double apply_funcs(T1 a, T2 b, const int sz){ double ret = 0.0; for(int i=0;i<sz;i++,++a,++b){ ret+=B(*a, *b); } return ret; } /* * sum(fun0( Bin_Fun( fun1(a), fun2(b)))) * fun0, fun1, fun2 are Unary_Functions * ? is a binary function * a, b are iterators (should be same size) */ template<Unary_Function F0, Unary_Function F1, Binary_Function B, Unary_Function F2, typename T1, typename T2> inline double apply_funcs(T1 a, T2 b, const int sz){ double ret = 0.0; for(int i=0;i<sz;i++,++a,b++){ ret+=F0( B(F1(*a), F2(*b)) ); } return ret; } /* * sum(fun0( fun1(a) ? fun2(b))) (only now, one of fun0, fun1, fun2 doesn't exist) * fun0, fun1, fun2 are Unary_Functions * ? is a binary function * a, b are iterators (should be same size) * type indicates which of fun0, fun1, fun2 doesn't exist */ template<Unary_Function F0, Unary_Function F1, Binary_Function B, typename T1, typename T2> inline double apply_funcs(T1 a, T2 b, const int sz, const int type){ double ret = 0.0; if(type==0){ for(int i=0;i<sz;i++,++a,++b){ ret+=B(F0(*a), F1(*b)); } } else if(type==1){ for(int i=0;i<sz;i++,++a,++b){ ret+=F0( B(*a, F1(*b)) ); } } else{ for(int i=0;i<sz;i++,++a,++b){ ret+=F0( B(F1(*a), *b) ); } } return ret; } /* * sum(fun0( fun1(a) ? fun2(b))) (like before, only now only one fun exists) * fun0, fun1, fun2 are Unary_Functions * ? is a binary function * a, b are iterators (should be same size) * type indicates which of fun0, fun1, fun2 exists */ template<Unary_Function F, Binary_Function B, typename T1, typename T2> inline double apply_funcs(T1 a, T2 b, const int sz, const int type){ double ret = 0.0; if(type==0){ for(int i=0;i<sz;i++,++a,++b){ ret+=F( B(*a, *b) ); } } else if(type==1){ for(int i=0;i<sz;i++,++a,++b){ ret+=B(F(*a), *b); } } else{ for(int i=0;i<sz;i++,++a,++b){ ret+=B(*a, F(*b)); } } return ret; } template<Binary_Function B, typename T1, typename T2, typename T3> inline void apply_funcs(T1 a, T2 b, T3 out, const int sz){ for(int i=0;i<sz;i++,++a,++b,++out){ *out=B(*a, *b); } return; } /* * each element of out is filled with (fun0( fun1(a) ? fun2(b))) * fun0, fun1, fun2 are Unary_Functions * ? is a binary function * a, b, out are iterators (should refer to elements with the same size) */ template<Unary_Function F0, Unary_Function F1, Binary_Function B, Unary_Function F2, typename T1, typename T2, typename T3> inline void apply_funcs(T1 a, T2 b, T3 out, const int sz){ for(int i=0;i<sz;i++,++a,++b, ++out){ *out=F0( B(F1(*a), F2(*b)) ); } return; } /* * each element of out is filled with sum(fun0( fun1(a) ? fun2(b))) (only now, one of fun0, fun1, fun2 doesn't exist) * fun0, fun1, fun2 are Unary_Functions * ? is a binary function * a, b are iterators (should be same size) * type indicates which of fun0, fun1, fun2 doesn't exist */ template<Unary_Function F0, Unary_Function F1, Binary_Function B, typename T1, typename T2, typename T3> inline void apply_funcs(T1 a, T2 b, T3 out, const int sz, const int type){ if(type==0){ for(int i=0;i<sz;i++,++a,++b,++out){ *out=B(F0(*a), F1(*b)); } } else if(type==1){ for(int i=0;i<sz;i++,++a,++b,++out){ *out=F0( B(*a, F1(*b)) ); } } else{ for(int i=0;i<sz;i++,++a,++b,++out){ *out=F0( B(F1(*a), *b) ); } } return; } /* * each element of out is filled with sum(fun0( fun1(a) ? fun2(b))) (like before, only now only one fun exists) * fun0, fun1, fun2 are Unary_Functions * ? is a binary function * a, b are iterators (should be same size) * type indicates which of fun0, fun1, fun2 exists */ template<Unary_Function F, Binary_Function B, typename T1, typename T2, typename T3> inline void apply_funcs(T1 a, T2 b, T3 out, const int sz, const int type){ if(type==0){ for(int i=0;i<sz;i++,++a,++b,++out){ *out=F( B(*a, *b) ); } } else if(type==1){ for(int i=0;i<sz;i++,++a,++b,++out){ *out=B(F(*a), *b); } } else{ for(int i=0;i<sz;i++,++a,++b,++out){ *out=B(*a, F(*b)); } } return; } #endif
[ "akhilakollasrinu424jf@gmail.com" ]
akhilakollasrinu424jf@gmail.com
09d6a7f66daeb5e5f487ba54e081915920f31170
9bc24fa2c325b5cb8c6ec6b3515e051a631956b7
/vector2dsort.cpp
6418d723d6d893ace37ad6dbad7c501b344be438
[]
no_license
syedsiddhiqq/Competitive_programming
5cdca1594fdc1dc78bccc6149e3ab327b57aadeb
c55fa87b8f4803d9f25ed2b028ad482501570697
refs/heads/master
2020-04-22T09:08:08.155827
2019-02-12T06:08:05
2019-02-12T06:08:05
170,261,794
0
0
null
null
null
null
UTF-8
C++
false
false
438
cpp
/* * @Author: SyedAli * @Date: 2019-01-11 17:08:32 * @Last Modified by: SyedAli * @Last Modified time: 2019-01-11 17:09:31 */ #include <bits/stdc++.h> using namespace std; int main() { int n, k; cin >> n >> k; vector<pair<int, int> > a(n); for (int i = 0; i < n; ++i) { cin >> a[i].first; a[i].second = i; } sort(a.begin(), a.end()); for(int i=0;i<n;i++){ printf("%d%d\n",a[i].first,a[i].second); } return 0; }
[ "dineshananth97@gmail.com" ]
dineshananth97@gmail.com
db94f32db8c711bc743614f9b7cc2e3c2c4ff2a7
5fa00ff2f8f6e903c706d6731ee69c20e5440e5f
/src/shared/LogWriter.cpp
5b93fe9304dfb40a5087007a60571358682d7e4d
[ "MIT" ]
permissive
5433D-R32433/pcap-ndis6
9e93d8b47ebe0b68373785323be92c57c90669e2
77c9f02f5a774a5976e7fb96f667b5abb335d299
refs/heads/master
2022-01-13T07:58:42.002164
2019-06-24T00:24:02
2019-06-24T00:24:02
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,523
cpp
////////////////////////////////////////////////////////////////////// // Project: pcap-ndis6 // Description: WinPCAP fork with NDIS6.x support // License: MIT License, read LICENSE file in project root for details // // Copyright (c) 2019 Change Dynamix, Inc. // All Rights Reserved. // // https://changedynamix.io/ // // Author: Andrey Fedorinin ////////////////////////////////////////////////////////////////////// #include "LogWriter.h" #include "CommonDefs.h" #include "StrUtils.h" #include "MiscUtils.h" #include <vector> std::wstring CLogWriter::InternalFormatMessage( __in const std::wstring &Message) { return UTILS::STR::FormatW( L"[%s] %04x %s", UTILS::STR::GetTimeStr().c_str(), GetCurrentThreadId(), Message.c_str()); }; void CLogWriter::InternalLogMessage( __in const std::wstring &Message) { UNREFERENCED_PARAMETER(Message); }; void CLogWriter::InternalLogOSDetails() { std::wstring Message = UTILS::STR::FormatW( L"%s\n", UTILS::MISC::GetOSVersionInfoStrFromRegistry().c_str()); InternalLogMessage(Message); }; CLogWriter::CLogWriter(): CCSObject() { }; CLogWriter::~CLogWriter() { }; void CLogWriter::LogMessage( __in const std::wstring &Message) { std::wstring FormattedMessage = InternalFormatMessage(Message); Enter(); try { InternalLogMessage(FormattedMessage); } catch (...) { } Leave(); }; void CLogWriter::LogMessage( __in LPCWSTR Message) { Enter(); try { InternalLogMessage(Message); } catch (...) { } Leave(); }; void CLogWriter::LogMessageFmt( __in const std::wstring Format, __in ...) { va_list ArgList; va_start(ArgList, Format); DWORD BufferChCnt = _vscwprintf(Format.c_str(), ArgList); if (BufferChCnt > 0) { std::vector<wchar_t> Buffer; Buffer.resize(BufferChCnt + 2, 0); if (_vsnwprintf_s( &Buffer[0], BufferChCnt + 1, BufferChCnt + 1, Format.c_str(), ArgList) > 0) { LogMessage(&Buffer[0]); } } va_end(ArgList); }; void CLogWriter::LogOSDetails() { Enter(); __try { InternalLogOSDetails(); } __finally { Leave(); } };
[ "andrey.fedorinin.wrk@gmail.com" ]
andrey.fedorinin.wrk@gmail.com
85512cc521466c99bb84b18a878f812691dd8ae7
c5b20eb450210a73e4acb49f347e16b861bee934
/Arduino Code/Sailboat/Sailboat.ino
21c629094c85ddfeac7a5bc88701d77601e66c20
[]
no_license
rflmota/Sailboat
446d2bfbe773f5fa5f2169d4b4074b953e74c9d6
fae527d4c6fa0c166c24ef9145183fb93ef8cc2f
refs/heads/master
2020-05-31T11:37:15.632018
2014-05-19T19:00:58
2014-05-19T19:00:58
null
0
0
null
null
null
null
UTF-8
C++
false
false
3,585
ino
#include <sail_controller.h> #include <rudder_controller.h> #include <Wire.h> #include <Servo.h> #include <TinyGPSPlus.h> #define _DEBUG TRUE const unsigned int COMPASS_I2C_ADDRESS = 0x60; const unsigned int DEBUG_SERIAL_BAUDRATE = 57600; const unsigned int GPS_SERIAL_BAUDRATE = 57600; const unsigned int GPS_VALID_DATA_LIMIT_AGE = 5000; const unsigned long GPS_GOAL_LATITUDE = 90500000; // 90°30’00″ const unsigned long GPS_GOAL_LONGITUDE = 90500000; // 90°30’00″ const unsigned int ROTARY_ENCODER_PIN = 8; const unsigned int SAIL_SERVO_PIN = 49; const unsigned int RUDDER_SERVO_PIN = 53; const unsigned int ROTARY_ENC_MIN_PULSE_WIDTH = 1000; const unsigned int ROTARY_ENC_MAX_PULSE_WIDTH = 4000; const unsigned int SAIL_MIN_PULSE_WIDTH = 1000; const unsigned int SAIL_MAX_PULSE_WIDTH = 2000; const unsigned int RUDDER_MIN_PULSE_WIDTH = 1000; const unsigned int RUDDER_MAX_PULSE_WIDTH = 2000; TinyGPSPlus gps; Servo rudder; Servo sail; void setup() { #ifdef _DEBUG Serial.begin(DEBUG_SERIAL_BAUDRATE); #endif // _DEBUG Serial3.begin(GPS_SERIAL_BAUDRATE); Wire.begin(); pinMode(ROTARY_ENCODER_PIN, INPUT_PULLUP); rudder.attach(RUDDER_SERVO_PIN); sail.attach(SAIL_SERVO_PIN); rudder.writeMicroseconds(1500); sail.writeMicroseconds(1500); while (!gps.location.isValid()) retrieveGPSData(); #ifdef _DEBUG Serial.println("GPS Position Fixed !"); #endif // DEBUG } void loop() { byte highByte, lowByte; char pitch, roll; int bearing; double rudderActuationValue; double sailActuationValue; double goalAlignment; double windAlignment; retrieveCompassData(&bearing, &pitch, &roll); retrieveGPSData(); if (gps.location.age() < GPS_VALID_DATA_LIMIT_AGE) { goalAlignment = gps.courseTo(gps.location.lat(), gps.location.lng(), GPS_GOAL_LATITUDE, GPS_GOAL_LONGITUDE); windAlignment = abs(retrievePositionEncoderData()); rudder_controllerInferenceEngine(goalAlignment, &rudderActuationValue); sail_controllerInferenceEngine(abs(roll), goalAlignment, windAlignment, &sailActuationValue); rudder.writeMicroseconds(map(rudderActuationValue, 0, 100, RUDDER_MIN_PULSE_WIDTH, RUDDER_MAX_PULSE_WIDTH)); sail.writeMicroseconds(map(sailActuationValue, 0, 100, SAIL_MIN_PULSE_WIDTH, SAIL_MAX_PULSE_WIDTH)); #ifdef _DEBUG Serial.print("Position Encoder : "); Serial.println(retrievePositionEncoderData()); Serial.print("Roll : "); Serial.println(roll, DEC); Serial.print("Bearing : "); Serial.println(bearing); Serial.print("GPS Location : "); Serial.print(gps.location.lat(), 6); Serial.print(F(",")); Serial.println(gps.location.lng(), 6); Serial.print("Goal Position Alignment : "); Serial.println(goalAlignment); Serial.print("Wind Alignment : "); Serial.println(windAlignment); Serial.print("Sail Actuation Value : "); Serial.println(sailActuationValue); Serial.print("Rudder Actuation Value : "); Serial.println(rudderActuationValue); #endif // DEBUG } } void retrieveCompassData(int *bearing, char *pitch, char *roll) { byte highByte, lowByte; Wire.beginTransmission((int)COMPASS_I2C_ADDRESS); Wire.write(2); Wire.endTransmission(); Wire.requestFrom(COMPASS_I2C_ADDRESS, 4); while (Wire.available() < 4); highByte = Wire.read(); lowByte = Wire.read(); *pitch = (int)Wire.read(); *roll = (int)Wire.read(); *bearing = word(highByte, lowByte) / 10.0; } void retrieveGPSData() { while (Serial3.available() > 0) gps.encode(Serial3.read()); } int retrievePositionEncoderData() { return map(pulseIn(ROTARY_ENCODER_PIN, HIGH), ROTARY_ENC_MIN_PULSE_WIDTH, ROTARY_ENC_MAX_PULSE_WIDTH, -180, 180); }
[ "ricardoflmota@gmail.com" ]
ricardoflmota@gmail.com
00434465cc3d7a82483463fe9fcd6e4a77fdc620
da86d9f9cf875db42fd912e3366cfe9e0aa392c6
/2017/solutions/D/DPK-Gabrovo/bio.cpp
16454983b5d27cbeb4b0d4f320188c44b95a7929
[]
no_license
Alaxe/noi2-ranking
0c98ea9af9fc3bd22798cab523f38fd75ed97634
bb671bacd369b0924a1bfa313acb259f97947d05
refs/heads/master
2021-01-22T23:33:43.481107
2020-02-15T17:33:25
2020-02-15T17:33:25
85,631,202
2
4
null
null
null
null
UTF-8
C++
false
false
513
cpp
#include <iostream> #include <algorithm> #include <cctype> using namespace std; struct dm { int d,m; }; int main () { char k; dm a,b,c,d; cin>>a.d; cin.get(k); cin>>a.m; cin>>b.d; cin.get(k); cin>>b.m; cin>>c.d; cin.get(k); cin>>c.m; cin>>d.d; cin.get(k); cin>>d.m; if (a.d==b.d && a.d==c.d && a.d==d.d && a.m==b.m && a.m==c.m && a.m==d.m) { cout<<21252<<endl; return 0; } return 0; }
[ "aleks.tcr@gmail.com" ]
aleks.tcr@gmail.com
53568ae1f9836ded44cc08a8af5c18f094712e33
00788ef473065316489de368dbc9ccb14dd1b863
/Classes/scene/TitleScene.cpp
892941ed906a6118f8e0a5575f11c233db0901f0
[]
no_license
KeitaShiratori/KusoGame4
3656632f067fa658b697398afe0893e43522ed7f
92aff72a795ec466d9ef2a55205a781cd060f268
refs/heads/master
2021-01-22T01:54:42.552120
2015-05-06T06:42:58
2015-05-06T06:42:58
35,141,301
0
0
null
null
null
null
UTF-8
C++
false
false
3,835
cpp
#include "TitleScene.h" #include "StageSelectScene.h" #define WINSIZE Director::getInstance()->getWinSize() #define T_DIALOG 1000 #define STAGE_SELECT_SCENE 1 USING_NS_CC; //コンストラクタ TitleScene::TitleScene() { } //シーン生成 Scene* TitleScene::createScene() { auto scene = Scene::create(); auto layer = TitleScene::create(); scene->addChild(layer); return scene; } //インスタンス生成 TitleScene* TitleScene::create() { TitleScene *pRet = new TitleScene(); pRet->init(); pRet->autorelease(); return pRet; } //初期化 bool TitleScene::init() { if (!Layer::init()) return false; // パスを追加 CCFileUtils::sharedFileUtils()->addSearchPath("extensions"); // 湯気エフェクトのプール _pool = ParticleSystemPool::create("yuge_texture.plist", 20); _pool->retain(); // シングルタップイベントの取得 auto touchListener = EventListenerTouchOneByOne::create(); touchListener->setSwallowTouches(_swallowsTouches); touchListener->onTouchBegan = CC_CALLBACK_2(TitleScene::onTouchBegan, this); touchListener->onTouchMoved = CC_CALLBACK_2(TitleScene::onTouchMoved, this); touchListener->onTouchEnded = CC_CALLBACK_2(TitleScene::onTouchEnded, this); touchListener->onTouchCancelled = CC_CALLBACK_2(TitleScene::onTouchCancelled, this); _eventDispatcher->addEventListenerWithSceneGraphPriority(touchListener, this); initTitle(); //タイトルの初期化 initMenu(); // 初回起動時に限り、ステージオープン情報を初期化する UserDefault *userDef = UserDefault::getInstance(); if(!userDef->getBoolForKey("IS_OPEN_STAGE1", false)){ for(int i = 1; i <= 10; i++){ std::string keyIsOpen = StringUtils::format("IS_OPEN_STAGE%2d", i); userDef->setBoolForKey(keyIsOpen.c_str(), true); // 更新したステージ情報を保存 userDef->flush(); } } return true; } bool TitleScene::onTouchBegan(Touch* touch, Event* unused_event) { CCLOG("onToucnBegan"); auto p = _pool->pop(); if(p != nullptr){ CCPoint pos = ccp(touch->getLocation().x, touch->getLocation().y); p->setPosition(pos); p->setAutoRemoveOnFinish(true); // 表示が終わったら自分を親から削除! this->addChild(p); } return false; } void TitleScene::onTouchMoved(Touch* touch, Event* unused_event) { CCLOG("onTouchMoved"); } void TitleScene::onTouchEnded(Touch* touch, Event* unused_event) { CCLOG("onTouchEnded"); } void TitleScene::onTouchCancelled(Touch* touch, Event* unused_event) { CCLOG("onTouchCancelled"); } //背景の初期化 void TitleScene::initTitle() { // タイトル画像 auto title = Sprite::create("Title.png"); title->setPosition(WINSIZE / 2); addChild(title); } void TitleScene::initMenu(){ auto label1 = Label::createWithSystemFont("スタート", "fonts/Marker Felt.ttf", 64); label1->enableShadow(Color4B::GRAY, Size(0.5, 0.5), 15); label1->enableOutline(Color4B::BLUE, 5); auto item1 = MenuItemLabel::create(label1, [&](Ref* pSender) { //指定秒数後に次のシーンへ nextScene(STAGE_SELECT_SCENE, 1.0f); }); auto menu = Menu::create(item1, NULL); menu->alignItemsVerticallyWithPadding(50); this->addChild(menu); } //次のシーンへ遷移 void TitleScene::nextScene(int NEXT_SCENE, float dt) { // 次のシーンを生成する Scene* scene; switch(NEXT_SCENE){ case STAGE_SELECT_SCENE: scene = StageSelectScene::createScene(); break; default: scene = NULL; } Director::getInstance()->replaceScene( TransitionFadeTR::create(dt, scene) ); }
[ "keita.shiratori@gmail.com" ]
keita.shiratori@gmail.com
e1aacb4d5261f52e5f0e87bb65845a4a0dac2af6
44aa2e76764f37d27146f18e57f3d7397a29940c
/C++/ISC-EVA1/EVA1_10_CUNAESFERICA.cpp
99d81ca902802e9e964efddad4af82fa101bb899
[]
no_license
Nidia08/fundamentospro
8118fa5fe8f29b091e69bea240989f2f3087d21d
102c5f68b0b14595a0d93996ba2db3429cb34a4a
refs/heads/master
2020-03-27T12:22:03.147615
2018-12-09T18:18:06
2018-12-09T18:18:06
146,542,568
0
0
null
null
null
null
UTF-8
C++
false
false
526
cpp
//Nidia Gonzalez Morales 18550676 #include <iostream> #include <sstream> #include <string> #include <cstdlib> #include <cmath> using namespace std; string toString (double); int toInt (string); double toDouble (string); int main() { cout<< "Ingresa el radio"<<endl; double r; cin>>r; cout<<"Ingresa los grados"<<endl; double g; cin>>g; double vT; vT = (double) 4/3 * (3.1416* pow(r,3)/360)*g; cout<<"El volumen de la cuna esferica es "<<vT<<endl; return 0; }
[ "nidia.gonzalezm08@gmail.com" ]
nidia.gonzalezm08@gmail.com
84601eac4df491b674cdcf809efe46c4e6b56752
3ff1fe3888e34cd3576d91319bf0f08ca955940f
/dsgc/include/tencentcloud/dsgc/v20190723/model/ReportInfo.h
e7c0867fae6f38fdb5a5991b8bf1deb5f364607e
[ "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
19,301
h
/* * 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. */ #ifndef TENCENTCLOUD_DSGC_V20190723_MODEL_REPORTINFO_H_ #define TENCENTCLOUD_DSGC_V20190723_MODEL_REPORTINFO_H_ #include <string> #include <vector> #include <map> #include <tencentcloud/core/utils/rapidjson/document.h> #include <tencentcloud/core/utils/rapidjson/writer.h> #include <tencentcloud/core/utils/rapidjson/stringbuffer.h> #include <tencentcloud/core/AbstractModel.h> namespace TencentCloud { namespace Dsgc { namespace V20190723 { namespace Model { /** * 报表信息 */ class ReportInfo : public AbstractModel { public: ReportInfo(); ~ReportInfo() = default; void ToJsonObject(rapidjson::Value &value, rapidjson::Document::AllocatorType& allocator) const; CoreInternalOutcome Deserialize(const rapidjson::Value &value); /** * 获取任务id * @return Id 任务id * */ uint64_t GetId() const; /** * 设置任务id * @param _id 任务id * */ void SetId(const uint64_t& _id); /** * 判断参数 Id 是否已赋值 * @return Id 是否已赋值 * */ bool IdHasBeenSet() const; /** * 获取报告名称 * @return ReportName 报告名称 * */ std::string GetReportName() const; /** * 设置报告名称 * @param _reportName 报告名称 * */ void SetReportName(const std::string& _reportName); /** * 判断参数 ReportName 是否已赋值 * @return ReportName 是否已赋值 * */ bool ReportNameHasBeenSet() const; /** * 获取报告类型(AssetSorting:资产梳理) 注意:此字段可能返回 null,表示取不到有效值。 * @return ReportType 报告类型(AssetSorting:资产梳理) 注意:此字段可能返回 null,表示取不到有效值。 * */ std::string GetReportType() const; /** * 设置报告类型(AssetSorting:资产梳理) 注意:此字段可能返回 null,表示取不到有效值。 * @param _reportType 报告类型(AssetSorting:资产梳理) 注意:此字段可能返回 null,表示取不到有效值。 * */ void SetReportType(const std::string& _reportType); /** * 判断参数 ReportType 是否已赋值 * @return ReportType 是否已赋值 * */ bool ReportTypeHasBeenSet() const; /** * 获取报告周期(0单次 1每天 2每周 3每月) 注意:此字段可能返回 null,表示取不到有效值。 * @return ReportPeriod 报告周期(0单次 1每天 2每周 3每月) 注意:此字段可能返回 null,表示取不到有效值。 * */ uint64_t GetReportPeriod() const; /** * 设置报告周期(0单次 1每天 2每周 3每月) 注意:此字段可能返回 null,表示取不到有效值。 * @param _reportPeriod 报告周期(0单次 1每天 2每周 3每月) 注意:此字段可能返回 null,表示取不到有效值。 * */ void SetReportPeriod(const uint64_t& _reportPeriod); /** * 判断参数 ReportPeriod 是否已赋值 * @return ReportPeriod 是否已赋值 * */ bool ReportPeriodHasBeenSet() const; /** * 获取执行计划 (0:单次报告 1:定时报告) 注意:此字段可能返回 null,表示取不到有效值。 * @return ReportPlan 执行计划 (0:单次报告 1:定时报告) 注意:此字段可能返回 null,表示取不到有效值。 * */ uint64_t GetReportPlan() const; /** * 设置执行计划 (0:单次报告 1:定时报告) 注意:此字段可能返回 null,表示取不到有效值。 * @param _reportPlan 执行计划 (0:单次报告 1:定时报告) 注意:此字段可能返回 null,表示取不到有效值。 * */ void SetReportPlan(const uint64_t& _reportPlan); /** * 判断参数 ReportPlan 是否已赋值 * @return ReportPlan 是否已赋值 * */ bool ReportPlanHasBeenSet() const; /** * 获取报告导出状态(Success 成功, Failed 失败, InProgress 进行中) 注意:此字段可能返回 null,表示取不到有效值。 * @return ReportStatus 报告导出状态(Success 成功, Failed 失败, InProgress 进行中) 注意:此字段可能返回 null,表示取不到有效值。 * */ std::string GetReportStatus() const; /** * 设置报告导出状态(Success 成功, Failed 失败, InProgress 进行中) 注意:此字段可能返回 null,表示取不到有效值。 * @param _reportStatus 报告导出状态(Success 成功, Failed 失败, InProgress 进行中) 注意:此字段可能返回 null,表示取不到有效值。 * */ void SetReportStatus(const std::string& _reportStatus); /** * 判断参数 ReportStatus 是否已赋值 * @return ReportStatus 是否已赋值 * */ bool ReportStatusHasBeenSet() const; /** * 获取任务下次启动时间 注意:此字段可能返回 null,表示取不到有效值。 * @return TimingStartTime 任务下次启动时间 注意:此字段可能返回 null,表示取不到有效值。 * */ std::string GetTimingStartTime() const; /** * 设置任务下次启动时间 注意:此字段可能返回 null,表示取不到有效值。 * @param _timingStartTime 任务下次启动时间 注意:此字段可能返回 null,表示取不到有效值。 * */ void SetTimingStartTime(const std::string& _timingStartTime); /** * 判断参数 TimingStartTime 是否已赋值 * @return TimingStartTime 是否已赋值 * */ bool TimingStartTimeHasBeenSet() const; /** * 获取创建时间 注意:此字段可能返回 null,表示取不到有效值。 * @return CreateTime 创建时间 注意:此字段可能返回 null,表示取不到有效值。 * */ std::string GetCreateTime() const; /** * 设置创建时间 注意:此字段可能返回 null,表示取不到有效值。 * @param _createTime 创建时间 注意:此字段可能返回 null,表示取不到有效值。 * */ void SetCreateTime(const std::string& _createTime); /** * 判断参数 CreateTime 是否已赋值 * @return CreateTime 是否已赋值 * */ bool CreateTimeHasBeenSet() const; /** * 获取完成时间 注意:此字段可能返回 null,表示取不到有效值。 * @return FinishedTime 完成时间 注意:此字段可能返回 null,表示取不到有效值。 * */ std::string GetFinishedTime() const; /** * 设置完成时间 注意:此字段可能返回 null,表示取不到有效值。 * @param _finishedTime 完成时间 注意:此字段可能返回 null,表示取不到有效值。 * */ void SetFinishedTime(const std::string& _finishedTime); /** * 判断参数 FinishedTime 是否已赋值 * @return FinishedTime 是否已赋值 * */ bool FinishedTimeHasBeenSet() const; /** * 获取子账号uin 注意:此字段可能返回 null,表示取不到有效值。 * @return SubUin 子账号uin 注意:此字段可能返回 null,表示取不到有效值。 * */ std::string GetSubUin() const; /** * 设置子账号uin 注意:此字段可能返回 null,表示取不到有效值。 * @param _subUin 子账号uin 注意:此字段可能返回 null,表示取不到有效值。 * */ void SetSubUin(const std::string& _subUin); /** * 判断参数 SubUin 是否已赋值 * @return SubUin 是否已赋值 * */ bool SubUinHasBeenSet() const; /** * 获取失败信息 注意:此字段可能返回 null,表示取不到有效值。 * @return FailedMessage 失败信息 注意:此字段可能返回 null,表示取不到有效值。 * */ std::string GetFailedMessage() const; /** * 设置失败信息 注意:此字段可能返回 null,表示取不到有效值。 * @param _failedMessage 失败信息 注意:此字段可能返回 null,表示取不到有效值。 * */ void SetFailedMessage(const std::string& _failedMessage); /** * 判断参数 FailedMessage 是否已赋值 * @return FailedMessage 是否已赋值 * */ bool FailedMessageHasBeenSet() const; /** * 获取是否启用(0:否 1:是) 注意:此字段可能返回 null,表示取不到有效值。 * @return Enable 是否启用(0:否 1:是) 注意:此字段可能返回 null,表示取不到有效值。 * */ uint64_t GetEnable() const; /** * 设置是否启用(0:否 1:是) 注意:此字段可能返回 null,表示取不到有效值。 * @param _enable 是否启用(0:否 1:是) 注意:此字段可能返回 null,表示取不到有效值。 * */ void SetEnable(const uint64_t& _enable); /** * 判断参数 Enable 是否已赋值 * @return Enable 是否已赋值 * */ bool EnableHasBeenSet() const; /** * 获取识别模板名称 注意:此字段可能返回 null,表示取不到有效值。 * @return ComplianceName 识别模板名称 注意:此字段可能返回 null,表示取不到有效值。 * */ std::string GetComplianceName() const; /** * 设置识别模板名称 注意:此字段可能返回 null,表示取不到有效值。 * @param _complianceName 识别模板名称 注意:此字段可能返回 null,表示取不到有效值。 * */ void SetComplianceName(const std::string& _complianceName); /** * 判断参数 ComplianceName 是否已赋值 * @return ComplianceName 是否已赋值 * */ bool ComplianceNameHasBeenSet() const; /** * 获取进度百分比 注意:此字段可能返回 null,表示取不到有效值。 * @return ProgressPercent 进度百分比 注意:此字段可能返回 null,表示取不到有效值。 * */ uint64_t GetProgressPercent() const; /** * 设置进度百分比 注意:此字段可能返回 null,表示取不到有效值。 * @param _progressPercent 进度百分比 注意:此字段可能返回 null,表示取不到有效值。 * */ void SetProgressPercent(const uint64_t& _progressPercent); /** * 判断参数 ProgressPercent 是否已赋值 * @return ProgressPercent 是否已赋值 * */ bool ProgressPercentHasBeenSet() const; private: /** * 任务id */ uint64_t m_id; bool m_idHasBeenSet; /** * 报告名称 */ std::string m_reportName; bool m_reportNameHasBeenSet; /** * 报告类型(AssetSorting:资产梳理) 注意:此字段可能返回 null,表示取不到有效值。 */ std::string m_reportType; bool m_reportTypeHasBeenSet; /** * 报告周期(0单次 1每天 2每周 3每月) 注意:此字段可能返回 null,表示取不到有效值。 */ uint64_t m_reportPeriod; bool m_reportPeriodHasBeenSet; /** * 执行计划 (0:单次报告 1:定时报告) 注意:此字段可能返回 null,表示取不到有效值。 */ uint64_t m_reportPlan; bool m_reportPlanHasBeenSet; /** * 报告导出状态(Success 成功, Failed 失败, InProgress 进行中) 注意:此字段可能返回 null,表示取不到有效值。 */ std::string m_reportStatus; bool m_reportStatusHasBeenSet; /** * 任务下次启动时间 注意:此字段可能返回 null,表示取不到有效值。 */ std::string m_timingStartTime; bool m_timingStartTimeHasBeenSet; /** * 创建时间 注意:此字段可能返回 null,表示取不到有效值。 */ std::string m_createTime; bool m_createTimeHasBeenSet; /** * 完成时间 注意:此字段可能返回 null,表示取不到有效值。 */ std::string m_finishedTime; bool m_finishedTimeHasBeenSet; /** * 子账号uin 注意:此字段可能返回 null,表示取不到有效值。 */ std::string m_subUin; bool m_subUinHasBeenSet; /** * 失败信息 注意:此字段可能返回 null,表示取不到有效值。 */ std::string m_failedMessage; bool m_failedMessageHasBeenSet; /** * 是否启用(0:否 1:是) 注意:此字段可能返回 null,表示取不到有效值。 */ uint64_t m_enable; bool m_enableHasBeenSet; /** * 识别模板名称 注意:此字段可能返回 null,表示取不到有效值。 */ std::string m_complianceName; bool m_complianceNameHasBeenSet; /** * 进度百分比 注意:此字段可能返回 null,表示取不到有效值。 */ uint64_t m_progressPercent; bool m_progressPercentHasBeenSet; }; } } } } #endif // !TENCENTCLOUD_DSGC_V20190723_MODEL_REPORTINFO_H_
[ "tencentcloudapi@tencent.com" ]
tencentcloudapi@tencent.com
c6d1ba859689b6c19f71f3d4cd71a5afa9f54eda
05ac4e5a18cd01102719c67b591fa376d7f65ad0
/src/RE/TESDescription.cpp
64a5729e91d0e3eb8e53e40e43362b435009cb62
[ "MIT" ]
permissive
CakeTheLiar/CommonLibSSE
5beb42dee876e2b17265a63903d37f1b1586453e
ad4c94d0373f20a6f5bcdc776ba84bd4a3b24cea
refs/heads/master
2020-08-14T05:47:28.042591
2019-10-14T19:21:03
2019-10-14T19:21:03
215,108,918
0
0
MIT
2019-10-14T17:47:07
2019-10-14T17:47:06
null
UTF-8
C++
false
false
453
cpp
#include "RE/TESDescription.h" #include "skse64/GameFormComponents.h" // TESDescription #include "RE/BSString.h" // BSString namespace RE { void TESDescription::GetDescription(BSString& a_out, TESForm* a_parent, UInt32 a_fieldType) { using func_t = function_type_t<decltype(&TESDescription::GetDescription)>; func_t* func = EXTRACT_SKSE_MEMBER_FN_ADDR(::TESDescription, Get, func_t*); return func(this, a_out, a_parent, a_fieldType); } }
[ "ryan__mckenzie@hotmail.com" ]
ryan__mckenzie@hotmail.com
dba8ad70a01928a37a8f7a3ced1408509804b5e1
3aa8a1168d18eda2ce0b0855a2fd265b5b445528
/build-RefInfoEditor-Desktop_Qt_5_7_0_MinGW_32bit-Debug/debug/moc_showkeyboardfilter.cpp
8012cb0acefa29963095a15f6199a74684480609
[]
no_license
rymarchik/QtLearning
49587addbcc8f878f421dfd6c47edcda4b3618f1
14986ea6120828f05bf2dab9dc5d0cce6ee969cc
refs/heads/master
2021-01-17T20:32:15.858422
2017-01-16T13:41:09
2017-01-16T13:41:09
64,671,336
1
0
null
null
null
null
UTF-8
C++
false
false
2,783
cpp
/**************************************************************************** ** Meta object code from reading C++ file 'showkeyboardfilter.h' ** ** Created by: The Qt Meta Object Compiler version 67 (Qt 5.7.0) ** ** WARNING! All changes made in this file will be lost! *****************************************************************************/ #include "../../RefInfoEditor/showkeyboardfilter.h" #include <QtCore/qbytearray.h> #include <QtCore/qmetatype.h> #if !defined(Q_MOC_OUTPUT_REVISION) #error "The header file 'showkeyboardfilter.h' doesn't include <QObject>." #elif Q_MOC_OUTPUT_REVISION != 67 #error "This file was generated using the moc from 5.7.0. It" #error "cannot be used with the include files from this version of Qt." #error "(The moc has changed too much.)" #endif QT_BEGIN_MOC_NAMESPACE struct qt_meta_stringdata_ShowKeyboardFilter_t { QByteArrayData data[1]; char stringdata0[19]; }; #define QT_MOC_LITERAL(idx, ofs, len) \ Q_STATIC_BYTE_ARRAY_DATA_HEADER_INITIALIZER_WITH_OFFSET(len, \ qptrdiff(offsetof(qt_meta_stringdata_ShowKeyboardFilter_t, stringdata0) + ofs \ - idx * sizeof(QByteArrayData)) \ ) static const qt_meta_stringdata_ShowKeyboardFilter_t qt_meta_stringdata_ShowKeyboardFilter = { { QT_MOC_LITERAL(0, 0, 18) // "ShowKeyboardFilter" }, "ShowKeyboardFilter" }; #undef QT_MOC_LITERAL static const uint qt_meta_data_ShowKeyboardFilter[] = { // content: 7, // revision 0, // classname 0, 0, // classinfo 0, 0, // methods 0, 0, // properties 0, 0, // enums/sets 0, 0, // constructors 0, // flags 0, // signalCount 0 // eod }; void ShowKeyboardFilter::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a) { Q_UNUSED(_o); Q_UNUSED(_id); Q_UNUSED(_c); Q_UNUSED(_a); } const QMetaObject ShowKeyboardFilter::staticMetaObject = { { &QObject::staticMetaObject, qt_meta_stringdata_ShowKeyboardFilter.data, qt_meta_data_ShowKeyboardFilter, qt_static_metacall, Q_NULLPTR, Q_NULLPTR} }; const QMetaObject *ShowKeyboardFilter::metaObject() const { return QObject::d_ptr->metaObject ? QObject::d_ptr->dynamicMetaObject() : &staticMetaObject; } void *ShowKeyboardFilter::qt_metacast(const char *_clname) { if (!_clname) return Q_NULLPTR; if (!strcmp(_clname, qt_meta_stringdata_ShowKeyboardFilter.stringdata0)) return static_cast<void*>(const_cast< ShowKeyboardFilter*>(this)); return QObject::qt_metacast(_clname); } int ShowKeyboardFilter::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QObject::qt_metacall(_c, _id, _a); if (_id < 0) return _id; return _id; } QT_END_MOC_NAMESPACE
[ "alexander.rymarchik@gmail.com" ]
alexander.rymarchik@gmail.com
517c9aa953f8fe7390817853726510980e386663
84120b6b73012288fcc907c37a165d548398d319
/task1/src/2_power.cpp
7a7e5b7379b01eb52af1aa8954a71744d404e696
[]
no_license
t0pcup/cpp
6866122d3d7c711fae35dcc2bb7a128a0bbb1ad9
cf2b66d0b7397faa4a112b689f9d3ff0198e1a1e
refs/heads/master
2022-12-17T00:07:46.233528
2020-09-28T09:48:55
2020-09-28T09:48:55
299,297,025
1
0
null
2020-09-28T12:10:35
2020-09-28T12:10:34
null
UTF-8
C++
false
false
630
cpp
#include <cmath> #include <gtest/gtest.h> using namespace std; // Написать реализацию функции возведения числа в степень long long power(int, int); #pragma region power tests TEST(power, case1) { EXPECT_EQ(8, power(2, 3)); } TEST(power, case2) { EXPECT_EQ(1, power(3, 0)); } TEST(power, case3) { EXPECT_EQ(1125899906842624, power(2, 50)); } TEST(power, case4) { EXPECT_EQ(-125, power(-5, 3)); } TEST(power, case5) { EXPECT_EQ(81, power(-3, 4)); } #pragma endregion // todo long long power(int, int) { throw std::runtime_error("Not implemented!"); }
[ "h33el@yandex.ru" ]
h33el@yandex.ru
6805d27c7ec0c8fca8ad1c22a9a680c8eb62dd08
f9f493d11ad7e9e088d60714fa3e0209a7e70a5b
/Harkka_Sorsakivi_Manninen/Harkka_Sorsakivi_Manninen/include/vaittamavirhe.hh
fc7f5b8458182124cd4590c86c928c5e2d78408d
[]
no_license
Hirmuli/Labyrintti
dc5e7e6ff09adea7bd09b7947b9038d20e3c4b6e
bb39e0625f11fa93639d714a5d9337245a809d3f
refs/heads/master
2021-01-10T18:36:52.004522
2015-05-04T17:58:04
2015-05-04T17:58:04
33,736,457
0
0
null
null
null
null
UTF-8
C++
false
false
2,567
hh
#ifndef JULKINEN_TOT_VAITTAMAVIRHE_HH #define JULKINEN_TOT_VAITTAMAVIRHE_HH /** * \file vaittamavirhe.hh * \brief Julkinen::Vaittamavirhe-luokan esittely. * \author ©2010 Jarmo Jaakkola <jarmo.jaakkola@tut.fi>, * TTY Ohjelmistotekniikka */ // Kantaluokat #include "virhe.hh" // Standardikirjastot #include <iosfwd> // std::basic_ostream namespace Julkinen { /** * \brief Assertio rajapinnan käyttämä virhetyyppi. */ class Vaittamavirhe : public Virhe { public: /** * \brief Vaittamavirhe rakentaja. * * \param lauseke Merkkijono. * \param tiedosto Merkkijono. * \param rivi Rivinumero. * \param funktio Merkkijono. */ Vaittamavirhe( char const* lauseke, char const* tiedosto, unsigned int rivi, char const* funktio ) throw(); /** * \brief Kopiorakentaja. * * \param toinen Kopioitava Vaittamavirhe. */ Vaittamavirhe(Vaittamavirhe const& toinen) throw(); /** * \brief Purkaja. */ virtual ~Vaittamavirhe() throw() =0; /** * \brief Virhe tiedoston kertova metodi. * * \return Palauttaa virhe tiedoston nimen. */ char const* tiedosto() const throw(); /** * \brief Virhe rivin kertova metodi. * * \return Palauttaa virheen rivin. */ unsigned int rivi() const throw(); /** * \brief Virhe funktion kertova metodi. * * \return Palauttaa virhe funktion nimen. */ char const* funktio() const throw(); /** * \brief Tulostus virran luonti metodi * * \param tuloste Perus tulostevirta. * \return Palauttaa perus tulostevirran. */ std::basic_ostream<char>& tulosta(std::basic_ostream<char>& tuloste) const; /** * \brief Yhtäsuuruus vertailu operaattori. * * \param toinen Verrattava Vaittamavirhe. */ Vaittamavirhe& operator==(Vaittamavirhe const& toinen) throw(); private: /** * \brief */ char const* tiedosto_; /** * \brief */ unsigned int rivi_; /** * \brief */ char const* funktio_; }; } #endif // JULKINEN_TOT_VAITTAMAVIRHE_HH
[ "e0tmanni@KA32012.tamk.ad" ]
e0tmanni@KA32012.tamk.ad
0e48a0784bc7daadc65c37b8d8cdb008759cc81d
6929e7c71a6b12294a5307640ac04628221e5d54
/2749.cpp
46d280b2ea3f5ec51efaea7a792672cbfae4bbf2
[]
no_license
right-x2/Algorithm_study
2ad61ea80149cfe20b8248a6d35de55f87385c02
a1459bfc391d15a741c786d8c47394a3e1337dc6
refs/heads/master
2021-06-29T23:13:56.230954
2021-03-03T08:25:35
2021-03-03T08:25:35
216,532,752
0
0
null
null
null
null
UTF-8
C++
false
false
495
cpp
#include <iostream> using namespace std; long long arr[4]={0,1,2,0}; int fibo(long long x, long long n) { long long a; if (n==1) return 1; else if(n==2) return 2; else if(x==n) return arr[3]; else { arr[3] = (arr[2]+arr[1])%1000000; a = arr[2]; arr[2] = arr[3]; arr[1] = a; x++; fibo(x, n); } } int main() { long long x; cin>>x; int k = (x/1000); int a = x - (x/1000); for (int i = 0; i < k; ++i) { fibo(3,1000); } //int a = x/1000; x = fibo(3,a); cout<<x<<""; }
[ "kjw970103@gmail.com" ]
kjw970103@gmail.com
d2915d4130b5ee72227ec0857729a52410166ef1
2148f667cc1b75213c8ae10f8f1b499aae3df980
/LeetCode/90.子集2.cpp
cde571b99354afa79063e7747da203922aa98a7e
[]
no_license
zkk258369/Practice-of-some-Test
346d14714bc3f9ea965abf294eadcb2f28622847
599914056f2b263a69621724961175f08bb622ac
refs/heads/master
2021-07-12T16:24:18.974614
2020-10-11T07:29:45
2020-10-11T07:29:45
209,548,733
0
0
null
null
null
null
UTF-8
C++
false
false
2,479
cpp
#include<iostream> #include<vector> #include<algorithm> using namespace std; /* 思路一 * 1.先排序 * 2.递归过程中,遇到nums[i] == nums[i-1],则跳过这次递归 * 这样就避免了同层次的相同元素,而没有避免不同层次的相同元素,实现了去重。 */ class Solution { private: vector<vector<int>> res; vector<int> cur; public: vector<vector<int>> subsetsWithDup(vector<int>& nums) { sort(nums.begin(), nums.end()); BackTrack(nums, 0, nums.size()); return res; } void BackTrack(vector<int>& nums, int index, int n) { res.push_back(cur); for(int i=index; i<n; i++) { if(i != index && nums[i] == nums[i-1]) continue; cur.push_back(nums[i]); BackTrack(nums, i+1, n); cur.pop_back(); } } }; /*思路二 * 按照 无重复元素子集解法 每次给cur中添加新元素,与原有的元素组合生成新的子集。 * 示例为 nums = { 1, 2, 2} * 第一步:cur = {}, 则res = { { } } * 第二步:添加元素nums[0],则res = { { }, {1} } * 第三步:添加元素nums[1],则res = { { }, {1}, {2}, {1, 2} } * 第四步:添加元素nums[2],则res = { { }, {1}, {2}, {1, 2}, {2}, {1, 2}, {2, 2}, {1, 2, 2} } * 我们发现添加重复元素时,还会与第三步的旧解res = { { }, {1} }生成{ {2}, {1, 2} }, * 会与第三步的新解{ {2}, {1, 2} }重复,我们发现这个规律后, * 就设置遍历left,right记录前一步的新解,即记录第三步中的{ { }, {1} }, * 每次添加重复元素时,只与前一步的新解组合。 */ class Solution { private: vector<vector<int>> res; public: vector<vector<int>> subsetsWithDup(vector<int>& nums) { sort(nums.begin(), nums.end()); res.push_back(vector<int>()); int left = 0; int right = 0; int n = nums.size(); for(int i=0; i<n; i++) { int start = 0; int end = res.size() - 1; if(i != 0 && nums[i] == nums[i-1]) { start = left; end = right; } left = res.size(); for(int j=start; j<=end; j++) { vector<int> cur = res[j]; cur.push_back(nums[i]); res.push_back(cur); } right = res.size() - 1; } return res; } };
[ "zkk258369@163.com" ]
zkk258369@163.com
ffddf61a74de9c70c8c4b5fa6bb4c43bb047e74e
8b08822c5b94516353b0b76f1b5fea5de0d6023b
/src/multi_armed_bandit.hpp
04d222066f3d707893285c7f8bf599f845eadb6b
[]
no_license
phpisciuneri/k-armed-bandit
72f031307efd28a3587bcc3992778a79788ffb44
dd7f3d00d2d553abf20c866dde7521ca2edf60cd
refs/heads/main
2023-06-16T09:48:00.894273
2021-07-16T15:51:42
2021-07-16T15:51:42
384,190,999
0
0
null
null
null
null
UTF-8
C++
false
false
1,014
hpp
#ifndef MULTI_ARMED_BANDIT_HPP_ #define MULTI_ARMED_BANDIT_HPP_ #include <random> #include <vector> class Multi_armed_bandit { public: Multi_armed_bandit(int n_arms, std::default_random_engine& generator) : k(n_arms) { // initialize known action values from ~ N(0, 1) q_star.resize(k); std::normal_distribution<double> distribution; for (int i=0; i<k; i++) q_star[i] = distribution(generator); // initialize reward distributions from ~ N(q_star(k), 1) reward_distributions.resize(k); for (int i=0; i<k; i++) { std::normal_distribution<double> dist(q_star[i], 1); reward_distributions[i] = dist; } } double pull_arm(size_t arm, std::default_random_engine& generator) { assert(arm >=0 && arm < k); return reward_distributions[arm](generator); } private: int k; // number of arms std::vector<double> q_star; // known action values std::vector< std::normal_distribution<double> > reward_distributions; }; #endif // MULTI_ARMED_BANDIT_HPP_
[ "phpisciuneri@gmail.com" ]
phpisciuneri@gmail.com
3ee61ace8a63c88a419e16fe01eee1b0f5521f64
788aed39b7253d761079a1478594488d67c4d1ef
/ue4Prj/Source/ue4Prj/Pickable.cpp
ac3c7f2f1a73ac19b198c4b0d5d4ad3cbcd5a576
[]
no_license
Arbint/VersionCtrl
e6e384a474e0df4f9ec227ca479387f6370be1d0
b3d92a99b144eadc1dffb0f2c9548616dfe3c0d7
refs/heads/master
2020-12-14T07:42:18.521443
2017-06-29T02:41:08
2017-06-29T02:41:08
95,582,532
0
0
null
null
null
null
UTF-8
C++
false
false
772
cpp
// Fill out your copyright notice in the Description page of Project Settings. #include "Pickable.h" // Sets default values APickable::APickable() { // Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it. PrimaryActorTick.bCanEverTick = true; VisualMesh = CreateDefaultSubobject<UStaticMeshComponent>("Mesh"); VisualMesh->SetCollisionResponseToChannel(ECC_PlayerTracing, ECR_Block); VisualMesh->SetMobility(EComponentMobility::Movable); VisualMesh->SetSimulatePhysics(true); RootComponent = VisualMesh; } // Called when the game starts or when spawned void APickable::BeginPlay() { Super::BeginPlay(); } // Called every frame void APickable::Tick(float DeltaTime) { Super::Tick(DeltaTime); }
[ "jingtianli.animation@gmail.com" ]
jingtianli.animation@gmail.com
7e3d302e2a0d8ed086ef5033c05732aaac8deb5e
a4f6a06e41f0873bc5d71783051c2483e4a90314
/UNITTESTS/stubs/storage/ProfilingBlockDevice_stub.cpp
52a94fa5b1d805a744b74d56385559904afc3ce1
[ "SGI-B-1.1", "Apache-2.0", "LicenseRef-scancode-public-domain", "BSD-2-Clause", "MPL-2.0", "BSD-3-Clause", "BSD-4-Clause", "LicenseRef-scancode-unknown-license-reference" ]
permissive
jeromecoutant/mbed
20b7a5a4dfbcace7c5a6a2086fde939c28dc8a8b
bf07820e47131a4b72889086692224f5ecc0ddd7
refs/heads/master
2023-05-25T09:50:33.111837
2021-06-18T09:27:53
2021-06-18T15:18:48
56,680,851
2
4
Apache-2.0
2018-09-28T12:55:38
2016-04-20T11:20:08
C
UTF-8
C++
false
false
1,898
cpp
/* * Copyright (c) 2017, Arm Limited and affiliates. * SPDX-License-Identifier: Apache-2.0 * * 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 "ProfilingBlockDevice.h" ProfilingBlockDevice::ProfilingBlockDevice(BlockDevice *bd) { } int ProfilingBlockDevice::init() { return 0; } int ProfilingBlockDevice::deinit() { return 0; } int ProfilingBlockDevice::sync() { return 0; } int ProfilingBlockDevice::read(void *b, bd_addr_t addr, bd_size_t size) { return 0; } int ProfilingBlockDevice::program(const void *b, bd_addr_t addr, bd_size_t size) { return 0; } int ProfilingBlockDevice::erase(bd_addr_t addr, bd_size_t size) { return 0; } bd_size_t ProfilingBlockDevice::get_read_size() const { return 0; } bd_size_t ProfilingBlockDevice::get_program_size() const { return 0; } bd_size_t ProfilingBlockDevice::get_erase_size() const { return 0; } bd_size_t ProfilingBlockDevice::get_erase_size(bd_addr_t addr) const { return 0; } int ProfilingBlockDevice::get_erase_value() const { return 0; } bd_size_t ProfilingBlockDevice::size() const { return 0; } void ProfilingBlockDevice::reset() { } bd_size_t ProfilingBlockDevice::get_read_count() const { return 0; } bd_size_t ProfilingBlockDevice::get_program_count() const { return 0; } bd_size_t ProfilingBlockDevice::get_erase_count() const { return 0; }
[ "antti.kauppila@arm.com" ]
antti.kauppila@arm.com
8f082dfb0cc805a168500f84bc9beb4848dffda0
aff0153d6d792b1396a34813809b1c2b4738a157
/Engine/include/kat/renderer/VertexArray.hpp
e7deb80709b4c3c00279b3678ba1d1a85a128ba5
[ "MIT" ]
permissive
superspeeder/thegame
1614593bfb8afd59bf7d4d96c227c857b4334dcd
a8b80c919b6790236e9496ed1cdcbe1649fa3344
refs/heads/master
2023-03-17T17:23:27.461069
2021-03-11T17:23:12
2021-03-11T17:23:12
345,518,190
0
0
null
null
null
null
UTF-8
C++
false
false
438
hpp
#pragma once #include <glad/glad.h> #include "kat/renderer/Buffer.hpp" namespace kat { class VertexArray { private: uint32_t m_VertexArray; uint32_t m_NextIndex = 0; public: VertexArray(); ~VertexArray(); void bind(); void unbind(); void attachEBO(kat::ElementBuffer* ebo); void attribute(uint32_t size, uint32_t stride, uint32_t offset); void vbo(kat::VertexBuffer* vbo, std::vector<uint32_t> defs); }; }
[ "andy@delusion.org" ]
andy@delusion.org
9e98b7a97e167cb2bfbe06aca38c7b00c7c83d9c
d4bcd690abb41c6720aab07feeb205392c712793
/Chapter 9/OOP Project/OOPProjectStep3/OOPProjectStep3/Source.cpp
32a72724477c9eb9e60586c11a630a73aa1b8192
[]
no_license
HyungMinKang/Cplusplus-Pratice
39b26bf2a58b47d29ca7401ad4c47e1b87f2f899
22aa3d93d0304bff062e63a290a20d08bcb271a8
refs/heads/master
2022-05-28T01:41:22.711717
2020-04-29T01:21:17
2020-04-29T01:21:17
259,792,112
0
0
null
null
null
null
UHC
C++
false
false
3,131
cpp
/* step3 수정사항 깊은 복사- 복사 생성자 정의 Account 클래스 */ #define _CRT_SECURE_NO_WARNINGS #include <iostream> #include <cstring> using namespace std; const int NAME_LEN = 20; void showMenu(void); void makeAccount(void); void depositMoney(void); void withdrawMoney(void); void showAll(void); enum { MAKE = 1, DEPOSIT, WITHDRAW, INQUIRE, EXIT }; class Account { private: char* cusName; // 고객이름 int accID; //고객 아이디 int balance; // 잔액 public: Account(int id, int money, char* name) : accID(id), balance(money) { cusName = new char[strlen(name) + 1]; strcpy(cusName, name); } Account(const Account& ref) : accID(ref.accID), balance(ref.balance) { cusName = new char[strlen(ref.cusName) + 1]; strcpy(cusName, ref.cusName); } int GetAccID() { return accID; } void Deposit(int money) { balance += money; } int Withdraw(int money) { if (balance < money) return 0; balance -= money; return money; } void ShowAccInfo() { cout << "계좌ID: " << accID << endl; cout << "이름: " << cusName << endl; cout << "잔액: " << balance << endl; } ~Account() { delete[] cusName; } }; Account* accArr[100]; //객체 배열 int accNum = 0; // 객체수 int main(void) { int choice; while (1) { showMenu(); cout << "선택: "; cin >> choice; cout << endl; switch (choice) { case MAKE: makeAccount(); break; case DEPOSIT: depositMoney(); break; case WITHDRAW: withdrawMoney(); break; case INQUIRE: showAll(); break; case EXIT: return 0; default: cout << "illegal selection!" << endl; } } return 0; } void showMenu(void) { cout << "-----Menu-----" << endl; cout << "1. 계좌개설" << endl; cout << "2. 입 금 " << endl; cout << "3. 출 금 " << endl; cout << "4. 계좌정보 전체출력 " << endl; cout << "5. 프로그래 종료 " << endl; } void makeAccount(void) { int id; char name[NAME_LEN]; int balance; cout << "계좌개설" << endl; cout << "계좌ID: "; cin >> id; cout << "이 름: "; cin >> name; cout << "입금액: "; cin >> balance; accArr[accNum++] = new Account(id, balance, name); } void depositMoney(void) { int id; int money; cout << "[입 금]" << endl; cout << "계좌ID: "; cin >> id; cout << "입금액: "; cin >> money; for (int i = 0; i < accNum; i++) { if (accArr[i]->GetAccID() == id) { accArr[i]->Deposit(money); cout << "입 금 완 료" << endl << endl; return; } } cout << "유효하지 않은 ID입니다" << endl << endl; } void withdrawMoney(void) { int money; int id; cout << "[출 금]" << endl; cout << "계좌ID: "; cin >> id; cout << "입금액: "; cin >> money; for (int i = 0; i < accNum; i++) { if (accArr[i]->GetAccID() == id) { if (accArr[i]->Withdraw(money) == 0) { cout << "잔액부족 " << endl << endl; return; } cout << "출 금 완 료" << endl << endl; return; } } cout << "유효하지 않은 ID입니다" << endl << endl; } void showAll(void) { for (int i = 0; i < accNum; i++) { accArr[i]->ShowAccInfo(); cout << endl; } }
[ "ramkid91@gmail.com" ]
ramkid91@gmail.com
d8a5cbc8bb4a8a2fbe58c0c80f272a23e87d7fb2
5f3cb89f65805aac2e9b69ac89d59b74062927aa
/AVL/AVLTest.cpp
29738d38d65cc015bed78207992435ae54a6fc51
[]
no_license
kk-codezeus/BST-AVL-Treap-Splay-Trees-Analysis
5cc75d2c386827dab3bd3c128e8c0c5f7654227f
ae0de1db9f9ebd99e3cc31ed41bbc85d257caadf
refs/heads/master
2020-05-21T14:30:06.628016
2019-05-11T03:33:36
2019-05-11T03:33:36
186,080,071
0
0
null
null
null
null
UTF-8
C++
false
false
4,082
cpp
#include "AVL.cpp" using namespace chrono; vector<int> randomKeys; vector<int> sequentialKeys; vector<int> recentAccessedKeys; void loadThreeVectors() { ifstream random("../random_keys.txt",ifstream::in); ifstream sequential("../sequential_keys.txt",ifstream::in); ifstream recent("../recentAccess_keys.txt",ifstream::in); int temp; for(int i = 0;i < 10000;i++) { random>>temp; randomKeys.push_back(temp); } for(int i = 0;i < 10000;i++) { sequential>>temp; sequentialKeys.push_back(temp); } for(int i = 0;i < 10000;i++) { recent>>temp; recentAccessedKeys.push_back(temp); } } void printThreeVectors() { for(int i = 0;i < 10000;i++) cout<<randomKeys[i]<<" "; cout<<endl<<endl<<endl; for(int i = 0;i < 10000;i++) cout<<sequentialKeys[i]<<" "; cout<<endl<<endl<<endl; for(int i = 0;i < 10000;i++) cout<<recentAccessedKeys[i]<<" "; cout<<endl<<endl<<endl; } void test_randomKeys() { AVL tree; tree.create(); steady_clock::time_point t1,t2; t1 = steady_clock::now(); for(int i = 0;i < randomKeys.size();i++) //random keys insert time tree.insertKey(randomKeys[i]); t2 = steady_clock::now(); auto duration = duration_cast<nanoseconds>((t2 - t1)); cout<<duration.count()<<"\n"; t1 = steady_clock::now(); for(int i = 0;i < randomKeys.size();i++) //random keys search time tree.searchKey(randomKeys[i]); t2 = steady_clock::now(); auto duration2 = duration_cast<nanoseconds>((t2 - t1)); cout<<duration2.count()<<"\n"; t1 = steady_clock::now(); for(int i = 0;i < randomKeys.size();i++) //random keys delete time tree.deleteKey(randomKeys[i]); t2 = steady_clock::now(); auto duration3 = duration_cast<nanoseconds>((t2 - t1)); cout<<duration3.count()<<"\n"; } void test_sequentialKeys() { AVL tree; tree.create(); steady_clock::time_point t1,t2; t1 = steady_clock::now(); for(int i = 0;i < sequentialKeys.size();i++) //sequential keys insert time tree.insertKey(sequentialKeys[i]); t2 = steady_clock::now(); auto duration = duration_cast<nanoseconds>((t2 - t1)); cout<<duration.count()<<"\n"; t1 = steady_clock::now(); for(int i = 0;i < sequentialKeys.size();i++) //sequential keys search time tree.searchKey(sequentialKeys[i]); t2 = steady_clock::now(); auto duration2 = duration_cast<nanoseconds>((t2 - t1)); cout<<duration2.count()<<"\n"; t1 = steady_clock::now(); for(int i = 0;i < sequentialKeys.size();i++) //sequential keys delete time tree.deleteKey(sequentialKeys[i]); t2 = steady_clock::now(); auto duration3 = duration_cast<nanoseconds>((t2 - t1)); cout<<duration3.count()<<"\n"; } void test_recentAccessedKeys() { AVL tree; tree.create(); steady_clock::time_point t1,t2; t1 = steady_clock::now(); for(int i = 0;i < recentAccessedKeys.size();i++) //recentAccess keys insert time tree.insertKey(recentAccessedKeys[i]); t2 = steady_clock::now(); auto duration = duration_cast<nanoseconds>((t2 - t1)); cout<<duration.count()<<"\n"; t1 = steady_clock::now(); for(int i = 0;i < recentAccessedKeys.size();i++) //recentAccess keys search time tree.searchKey(recentAccessedKeys[i]); t2 = steady_clock::now(); auto duration2 = duration_cast<nanoseconds>((t2 - t1)); cout<<duration2.count()<<"\n"; t1 = steady_clock::now(); for(int i = 0;i < recentAccessedKeys.size();i++) //recentAccess keys delete time tree.deleteKey(recentAccessedKeys[i]); t2 = steady_clock::now(); auto duration3 = duration_cast<nanoseconds>((t2 - t1)); cout<<duration3.count()<<"\n"; } int main() { loadThreeVectors(); //test_randomKeys(); //test_sequentialKeys(); test_recentAccessedKeys(); return 0; }
[ "kk3117@gmail.com" ]
kk3117@gmail.com
e7aae108e7307ddaf212935ef993a137cc8daf31
6fa29c69e3e5ec1acf2a0c25f94d733e523b731f
/LabProject13/LabProject13/GameFramework.h
ea25c8f11358da613720c256e77f11d6ae64d295
[]
no_license
KU-t/3D-Game-Programming
62bb4062cf79e871b88522e8f7f71933b502c7b7
f4078b06362bf75a26bac6a2fc915f273a04585b
refs/heads/master
2022-02-23T13:05:21.921440
2019-06-26T11:06:59
2019-06-26T11:06:59
174,095,293
0
0
null
null
null
null
UHC
C++
false
false
3,507
h
#pragma once #include "Timer.h" #include "Player.h" #include "Scene.h" class GameFramework{ private: //게임 프레임워크에서 사용할 타이머 GameTimer m_GameTimer; //프레임 레이트를 주 윈도우의 캡션에 출력하기 위한 문자열 _TCHAR m_pszFrameRate[50]; // Scene Scene *m_pScene; // Camera Camera *m_pCamera = NULL; // Player Player *m_pPlayer = NULL; // 마지막으로 마우스 버튼을 클릭할 때의 마우스 커서의 위치 POINT m_ptOldCursorPos; HINSTANCE m_hInstance; HWND m_hWnd; int m_nWndClientWidth; int m_nWndClientHeight; IDXGIFactory4* m_pdxgiFactory; // 디스플레이 제어를 위해 IDXGISwapChain3* m_pdxgiSwapChain; // 리소스 생성을 위해 ID3D12Device* m_pd3dDevice; // 다중 샘플링을 활성화 bool m_bMsaa4xEnable = false; // 다중 샘플링 레벨을 설정 UINT m_nMsaa4xQualityLevels = 0; static const UINT m_nSwapChainBuffers = 2; //스왑체인 백버퍼 수 //스왑체인 백버퍼 현재 인덱스 UINT m_nSwapChainBufferIndex; // 렌더 타겟 버퍼 ID3D12Resource *m_ppd3dRenderTargetBuffers[m_nSwapChainBuffers]; // 렌더 타켓 서술자 힙 주소 ID3D12DescriptorHeap *m_pd3dRtvDescriptorHeap; // 렌더 타켓 서술자 원소의 크기 UINT m_nRtvDescriptorIncrementSize; // 깊이-스텐실 버퍼 ID3D12Resource *m_pd3dDepthStencilBuffer; // 디프스텐실 서술자 힙 주소 ID3D12DescriptorHeap *m_pd3dDsvDescriptorHeap; // 디프스텐실 서술자 원소의 크기 UINT m_nDsvDescriptorIncrementSize; //명령 큐, 명령 할당자, 명령 리스트 인터페이스 ID3D12CommandQueue *m_pd3dCommandQueue; ID3D12CommandAllocator *m_pd3dCommandAllocator; ID3D12GraphicsCommandList *m_pd3dCommandList; //그래픽 파이프라인 상태 ID3D12PipelineState *m_pd3dPipelineState; //펜스 인터페이스 ID3D12Fence *m_pd3dFence; UINT64 m_nFenceValues[m_nSwapChainBuffers]; HANDLE m_hFenceEvent; //if~endif: if의 내용이 참이면 endif까지 컴파일이 진행된다. #if defined(_DEBUG) ID3D12Debug *m_pd3dDebugController; #endif public: GameFramework(); ~GameFramework(); // 주 윈도우가 생성되면 호출된다. bool OnCreate(HINSTANCE hInstance, HWND hMainWnd); void OnDestory(); // 스왑체인 생성 void CreateSwapChain(); // 디바이스 생성 void CreateDirect3DDevice(); // 서술자 힙 생성 void CreateRtvAndDsvDescriptorHeaps(); // 명령 큐, 할당자, 리스트 생성 void CreateCommandQueueAndList(); // 렌더 타겟 뷰 생성 void CreateRenderTargetViews(); // 깊이 - 스텐실 뷰 생성 void CreateDepthStencilViews(); // 렌더링할 메쉬와 게임 객체를 생성 void BuildObjects(); // 렌더링할 메쉬와 게임 객체를 소멸 void ReleaseObjects(); // 프레임위크의 핵심(사용자 입력, 애니메이션, 렌더링)을 구성하는 함수 void ProcessInput(); void AnimateObject(); void FrameAdvance(); // CPU와 GPU를 동기화하는 함수이다. void WaitForGpuComplete(); //[따라하기5 fullscreenmode] void ChangeSwapChainState(); void MoveToNextFrame(); // 윈도우의 메시지(키보드, 마우스 입력)을 처리하는 함수 void OnProcessingMouseMessage(HWND hWnd, UINT nMessageID, WPARAM wParam, LPARAM lParam); void OnProcessingKeyboardMessage(HWND hWnd, UINT nMessageID, WPARAM wParam, LPARAM lParam); LRESULT CALLBACK OnProcessingWindowMessage(HWND hWnd, UINT nMessageID, WPARAM wParam, LPARAM lParam); };
[ "jhltk2426@naver.com" ]
jhltk2426@naver.com
073ade734c17a6dd23400224a13e62112dcd8ee3
4597f9e8c2772f276904b76c334b4d181fa9f839
/C++/First-Missing-Positive.cpp
20148f4dc840a2676ee855c4ed47615c1a5d336b
[]
no_license
xxw1122/Leetcode
258ee541765e6b04a95e225284575e562edc4db9
4c991a8cd024b504ceb0ef7abd8f3cceb6be2fb8
refs/heads/master
2020-12-25T11:58:00.223146
2015-08-11T02:10:25
2015-08-11T02:10:25
40,542,869
2
6
null
2020-09-30T20:54:57
2015-08-11T13:21:17
C++
UTF-8
C++
false
false
624
cpp
class Solution { public: int firstMissingPositive(vector<int>& nums) { int cur = 0; while (cur < nums.size()) { while (nums[cur] != cur + 1) { if (nums[cur] > nums.size() || nums[cur] <= 0) { break; } else { if (nums[nums[cur] - 1] == nums[cur]) break; swap(nums[cur], nums[nums[cur] - 1]); } } cur ++; } for (int i = 0; i < nums.size(); i ++) { if (nums[i] != i + 1) return i + 1; } return nums.size() + 1; } };
[ "jiangyi0425@gmail.com" ]
jiangyi0425@gmail.com
1a864b989c02d636a73d935cfc22927e514ec171
03a4884c3feb088379967f404ebc844941695b67
/Leetcode/周赛162/11.17_4.cpp
27e24ce66096cf86ecc77f08c1512b076b2a1bd6
[]
no_license
875325155/Start_Leetcode_caishunzhe
26686ae9284be2bdd09241be2d12bc192e8684bd
af15bf61ab31748724048ca04efb5fa007d4f7f5
refs/heads/master
2020-09-02T06:42:01.896405
2020-02-17T10:42:38
2020-02-17T10:42:38
219,158,659
0
0
null
null
null
null
UTF-8
C++
false
false
672
cpp
#include<cstdio> #include<algorithm> using namespace std; struct city { char name[100]; double g1,g2,g3; double gdp; double ans; }City[1005]; int cmp1(city a,city b) { return a.gdp<b.gdp; } int cmp2(city a,city b) { return a.ans<b.ans; } int main() { int n; scanf("%d",&n); for(int i=0;i<n;i++) { scanf("%s %lf %lf %lf",&City[i].name,&City[i].g1,&City[i].g2,&City[i].g3); City[i].gdp=City[i].g1+City[i].g2+City[i].g3; City[i].ans=City[i].g3/City[i].gdp; } sort(City,City+n,cmp1); printf("%s ",City[n-1].name); sort(City+n-3,City+n,cmp2); printf("%s",City[n-1].name); return 0; }
[ "875325155@qq.com" ]
875325155@qq.com
093d5b7e52c133f037ecaba064ed6ebb67163429
f5f053975aadd70cadbf3831cb27d2873e51c808
/ceEngine/Texture_D3D.cpp
3a24097806d03bfe283b84256608137b2ec1e785
[]
no_license
YoelShoshan/Dooake
fd5ded20b21075276c27899215392f6078d8713e
254b74bc8fa30d38511d5bda992a59253cc8c37d
refs/heads/master
2021-01-20T11:11:23.048481
2016-09-15T20:03:32
2016-09-15T20:03:32
68,323,638
1
0
null
null
null
null
UTF-8
C++
false
false
2,826
cpp
#include "stdafx.h" #include "Texture_D3D.h" #include "Defines.h" #include "LogFile.h" extern ILogFile* g_pLogFile; #include "ce.h" #include <string> #include "stdio.h" /////////////////////////////////////////////////////////////////// // RESTORE RESTORE RESTORE RESTORE RESTORE RESTORE RESTORE RESTORE #include "TextureManager.h" /////////////////////////////////////////////////////////////////// extern LPDIRECT3DDEVICE9 g_pDirect3DDevice; CTexture_D3D::CTexture_D3D() { m_pD3DTexture = NULL; } CTexture_D3D::~CTexture_D3D() { char message[200]; sprintf_s(message,200,"deleting texture: ""%s"".",m_pcTexName); ////////////////////////////////////////////////////////////////////////////////////////// // RESTORE RESTORE RESTORE RESTORE RESTORE RESTORE RESTORE RESTORE st_TextureManager->Unregister(m_pcTexName); // unregister this texture from the tex manager ////////////////////////////////////////////////////////////////////////////////////////// SafeDeleteArray(m_pcTexName); SAFE_RELEASE(m_pD3DTexture); g_pLogFile->OutPutPlainText(message,LOG_MESSAGE_INFORMATIVE); } bool CTexture_D3D::FindTextureExtension(char *strFileName) { // i need to avoid all the string copies // which i'm doing because of the find-extension process (for q3 maps)... FILE *fp = NULL; // if already has extension, change nothing. if((fp = fopen(strFileName, "rb")) != NULL) return true; std::string strJPGPath; std::string strTGAPath; std::string strBMPPath; strJPGPath+=strFileName; strJPGPath+=".jpg"; strTGAPath+=strFileName; strTGAPath+=".tga"; strBMPPath+=strFileName; strBMPPath+=".bmp"; if((fp = fopen(strJPGPath.c_str(), "rb")) != NULL) { strcat(strFileName, ".jpg"); fclose(fp); return true; } if((fp = fopen(strTGAPath.c_str(), "rb")) != NULL) { strcat(strFileName, ".tga"); fclose(fp); return true; } if((fp = fopen(strBMPPath.c_str(), "rb")) != NULL) { strcat(strFileName, ".bmp"); fclose(fp); return true; } return false; } bool CTexture_D3D::Load(const char* strFileName,bool bMipMap,bool bClamp, bool bCompress) { if(!strFileName) { BREAKPOINT(1); return false; } static char ExtendedName[500]; strcpy(ExtendedName,strFileName); if (!FindTextureExtension(ExtendedName)) return false; if (D3DXCreateTextureFromFile(g_pDirect3DDevice,ExtendedName,&m_pD3DTexture)!=D3D_OK) return false; // I MUST do something like: // m_iWidth = texture width; // m_iHeight = texture height; //BREAKPOINT(1); m_pcTexName = new char[strlen(ExtendedName)+1]; strcpy(m_pcTexName,ExtendedName); return true; } void CTexture_D3D::Bind(int iSamplerNum) const { CR_ERROR(!m_pD3DTexture,"Trying to bind a null d3d texture!"); HRESULT hr = g_pDirect3DDevice->SetTexture(iSamplerNum,m_pD3DTexture); assert(SUCCEEDED(hr)); }
[ "yoelshoshan@gmail.com" ]
yoelshoshan@gmail.com
2a5c1b35af01afca4bab98b00bd1e828b46a1822
5a60d60fca2c2b8b44d602aca7016afb625bc628
/aws-cpp-sdk-iotwireless/include/aws/iotwireless/model/TagResourceResult.h
3fb3cb40432ffea19cf708c4faa9a112bdf74813
[ "Apache-2.0", "MIT", "JSON" ]
permissive
yuatpocketgems/aws-sdk-cpp
afaa0bb91b75082b63236cfc0126225c12771ed0
a0dcbc69c6000577ff0e8171de998ccdc2159c88
refs/heads/master
2023-01-23T10:03:50.077672
2023-01-04T22:42:53
2023-01-04T22:42:53
134,497,260
0
1
null
2018-05-23T01:47:14
2018-05-23T01:47:14
null
UTF-8
C++
false
false
800
h
/** * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0. */ #pragma once #include <aws/iotwireless/IoTWireless_EXPORTS.h> namespace Aws { template<typename RESULT_TYPE> class AmazonWebServiceResult; namespace Utils { namespace Json { class JsonValue; } // namespace Json } // namespace Utils namespace IoTWireless { namespace Model { class TagResourceResult { public: AWS_IOTWIRELESS_API TagResourceResult(); AWS_IOTWIRELESS_API TagResourceResult(const Aws::AmazonWebServiceResult<Aws::Utils::Json::JsonValue>& result); AWS_IOTWIRELESS_API TagResourceResult& operator=(const Aws::AmazonWebServiceResult<Aws::Utils::Json::JsonValue>& result); }; } // namespace Model } // namespace IoTWireless } // namespace Aws
[ "aws-sdk-cpp-automation@github.com" ]
aws-sdk-cpp-automation@github.com
9e7898d3f2ba8258fdfb3ab370a984326733e92a
8263d56e3b565bdbec506b3823a9e4f1361ce284
/19-01to03/qt_udpsocket/netcomm/cameradatapool.cpp
0cdea1a8e7edaf96a515e23905b53535676a288b
[ "MIT" ]
permissive
18325391772/blog-code-example
52268d63f08a441f3a4819ae62c8d278c22d1baf
8ea0cc00855334da045b4566072611c24c14c844
refs/heads/master
2020-05-30T12:23:52.054077
2019-05-31T03:54:27
2019-05-31T03:54:27
189,733,193
0
0
MIT
2019-06-01T12:59:48
2019-06-01T12:59:47
null
UTF-8
C++
false
false
656
cpp
#include "cameradatapool.h" #include <QDebug> template<class T> DataObjPool<T>::DataObjPool(int size) { T *pt; pool.reserve(size); for(int i = 0; i < size; i++) { pt = new T(); pt->setValid(true); pt->setId(i); pool.append(pt); } numAvailable = size; } template <class T> template <class T2> DataObjPool<T>::operator DataObjPool<T2>() { Stack<T2> StackT2; for (int i = 0; i < m_size; i++) { StackT2.push((T2)m_pT[m_size - 1]); } return StackT2; } RawDataObjPool::RawDataObjPool(int size) : DataObjPool(size) { } LineDataPool::LineDataPool(int size) : DataObjPool(size) { }
[ "752736341@qq.com" ]
752736341@qq.com
c115ec5974c812caea42f391e5e1810a24abfec4
51c59bc864255b95ee29f9a87f1a9f84acbcc25b
/YellowBelt/Week3/Task3/bus_manager.cpp
88d1a32e76931303726ecb4697ae29c44673bc22
[]
no_license
Handwhale/Coursera
2c8d6c25d6aba357a8172d4663f6640c1350d042
e4fcf28394203f274a9180d4a7d30ee380d262fb
refs/heads/master
2021-07-04T16:58:32.559122
2020-11-01T10:55:38
2020-11-01T10:55:38
195,672,184
0
0
null
null
null
null
UTF-8
C++
false
false
772
cpp
#include "bus_manager.h" #include <vector> void BusManager::AddBus(const string &bus, const vector<string> &stops) { buses_to_stops[bus] = stops; for (const auto &item : stops) { stops_to_buses[item].push_back(bus); } } BusesForStopResponse BusManager::GetBusesForStop(const string &stop) const { if (stops_to_buses.count(stop) == 0) { return {}; // No stops } else { return {stops_to_buses.at(stop)}; } } StopsForBusResponse BusManager::GetStopsForBus(const string &bus) const { if (buses_to_stops.count(bus) == 0) { return {}; // No buses } else { return {bus, buses_to_stops.at(bus), stops_to_buses}; } } AllBusesResponse BusManager::GetAllBuses() const { return {buses_to_stops}; }
[ "mr.rabbiton@gmail.com" ]
mr.rabbiton@gmail.com
93df2275918f6d65f6e197bba8b5412a613c441b
7579d827cb7b50b438dfd9ef6fa80ba2797848c9
/sources/plug_wx/src/luna/bind_wxAuiNotebookPage.cpp
c2a1591585c67e521b8ba11b61252eca8006ae03
[]
no_license
roche-emmanuel/sgt
809d00b056e36b7799bbb438b8099e3036377377
ee3a550f6172c7d14179d9d171e0124306495e45
refs/heads/master
2021-05-01T12:51:39.983104
2014-09-08T03:35:15
2014-09-08T03:35:15
79,538,908
3
0
null
null
null
null
UTF-8
C++
false
false
4,276
cpp
#include <plug_common.h> class luna_wrapper_wxAuiNotebookPage { public: typedef Luna< wxAuiNotebookPage > luna_t; inline static bool _lg_typecheck___eq(lua_State *L) { if( lua_gettop(L)!=2 ) return false; if( !Luna<void>::has_uniqueid(L,1,43006525) ) return false; return true; } static int _bind___eq(lua_State *L) { if (!_lg_typecheck___eq(L)) { luaL_error(L, "luna typecheck failed in __eq function, expected prototype:\n__eq(wxAuiNotebookPage*). Got arguments:\n%s",luna_dumpStack(L).c_str()); } wxAuiNotebookPage* rhs =(Luna< wxAuiNotebookPage >::check(L,2)); wxAuiNotebookPage* self=(Luna< wxAuiNotebookPage >::check(L,1)); if(!self) { luaL_error(L, "Invalid object in function call __eq(...)"); } lua_pushboolean(L,self==rhs?1:0); return 1; } inline static bool _lg_typecheck_fromVoid(lua_State *L) { if( lua_gettop(L)!=1 ) return false; if( !Luna<void>::has_uniqueid(L,1,3625364) ) return false; return true; } static int _bind_fromVoid(lua_State *L) { if (!_lg_typecheck_fromVoid(L)) { luaL_error(L, "luna typecheck failed in fromVoid function, expected prototype:\nfromVoid(void*). Got arguments:\n%s",luna_dumpStack(L).c_str()); } wxAuiNotebookPage* self= (wxAuiNotebookPage*)(Luna< void >::check(L,1)); if(!self) { luaL_error(L, "Invalid object in function call fromVoid(...)"); } Luna< wxAuiNotebookPage >::push(L,self,false); return 1; } inline static bool _lg_typecheck_asVoid(lua_State *L) { if( lua_gettop(L)!=1 ) return false; if( !Luna<void>::has_uniqueid(L,1,43006525) ) return false; return true; } static int _bind_asVoid(lua_State *L) { if (!_lg_typecheck_asVoid(L)) { luaL_error(L, "luna typecheck failed in fromVoid function, expected prototype:\nasVoid(). Got arguments:\n%s",luna_dumpStack(L).c_str()); } void* self= (void*)(Luna< wxAuiNotebookPage >::check(L,1)); if(!self) { luaL_error(L, "Invalid object in function call asVoid(...)"); } Luna< void >::push(L,self,false); return 1; } // Base class dynamic cast support: inline static bool _lg_typecheck_dynCast(lua_State *L) { if( lua_gettop(L)!=2 ) return false; if( lua_type(L,2)!=LUA_TSTRING ) return false; return true; } static int _bind_dynCast(lua_State *L) { if (!_lg_typecheck_dynCast(L)) { luaL_error(L, "luna typecheck failed in dynCast function, expected prototype:\ndynCast(const std::string &). Got arguments:\n%s",luna_dumpStack(L).c_str()); } std::string name(lua_tostring(L,2),lua_objlen(L,2)); wxAuiNotebookPage* self=(Luna< wxAuiNotebookPage >::check(L,1)); if(!self) { luaL_error(L, "Invalid object in function call dynCast(...)"); } static LunaConverterMap& converters = luna_getConverterMap("wxAuiNotebookPage"); return luna_dynamicCast(L,converters,"wxAuiNotebookPage",name); } // Constructor checkers: // Function checkers: // Operator checkers: // (found 0 valid operators) // Constructor binds: // Function binds: // Operator binds: }; wxAuiNotebookPage* LunaTraits< wxAuiNotebookPage >::_bind_ctor(lua_State *L) { return NULL; // No valid default constructor. } void LunaTraits< wxAuiNotebookPage >::_bind_dtor(wxAuiNotebookPage* obj) { delete obj; } const char LunaTraits< wxAuiNotebookPage >::className[] = "wxAuiNotebookPage"; const char LunaTraits< wxAuiNotebookPage >::fullName[] = "wxAuiNotebookPage"; const char LunaTraits< wxAuiNotebookPage >::moduleName[] = "wx"; const char* LunaTraits< wxAuiNotebookPage >::parents[] = {0}; const int LunaTraits< wxAuiNotebookPage >::hash = 43006525; const int LunaTraits< wxAuiNotebookPage >::uniqueIDs[] = {43006525,0}; luna_RegType LunaTraits< wxAuiNotebookPage >::methods[] = { {"dynCast", &luna_wrapper_wxAuiNotebookPage::_bind_dynCast}, {"__eq", &luna_wrapper_wxAuiNotebookPage::_bind___eq}, {"fromVoid", &luna_wrapper_wxAuiNotebookPage::_bind_fromVoid}, {"asVoid", &luna_wrapper_wxAuiNotebookPage::_bind_asVoid}, {0,0} }; luna_ConverterType LunaTraits< wxAuiNotebookPage >::converters[] = { {0,0} }; luna_RegEnumType LunaTraits< wxAuiNotebookPage >::enumValues[] = { {0,0} };
[ "roche.emmanuel@gmail.com" ]
roche.emmanuel@gmail.com
e4a434214f75311828d431b69b07540d390f43a0
cb6588134336d847031f6e5b76ec1565ab786013
/src/interfaces/node.h
e601a964cd8151c316247dfa8da7b8df13d57d0a
[ "MIT" ]
permissive
mkscoin/mkscoin
10d4bb1ee557aa1ab50b46a36cfa66995821b888
a4436857087a727a5d1b03f8380764b04d954f04
refs/heads/master
2023-06-02T19:49:30.987647
2021-06-11T05:34:29
2021-06-11T05:34:29
375,903,358
0
0
null
null
null
null
UTF-8
C++
false
false
8,669
h
// Copyright (c) 2018 The mkscoin Core developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #ifndef mkscoin_INTERFACES_NODE_H #define mkscoin_INTERFACES_NODE_H #include <addrdb.h> // For banmap_t #include <amount.h> // For CAmount #include <net.h> // For CConnman::NumConnections #include <netaddress.h> // For Network #include <functional> #include <memory> #include <stddef.h> #include <stdint.h> #include <string> #include <tuple> #include <vector> class BanMan; class CCoinControl; class CFeeRate; class CNodeStats; class Coin; class RPCTimerInterface; class UniValue; class proxyType; struct CNodeStateStats; namespace interfaces { class Handler; class Wallet; //! Top-level interface for a mkscoin node (mkscoind process). class Node { public: virtual ~Node() {} //! Set command line arguments. virtual bool parseParameters(int argc, const char* const argv[], std::string& error) = 0; //! Set a command line argument if it doesn't already have a value virtual bool softSetArg(const std::string& arg, const std::string& value) = 0; //! Set a command line boolean argument if it doesn't already have a value virtual bool softSetBoolArg(const std::string& arg, bool value) = 0; //! Load settings from configuration file. virtual bool readConfigFiles(std::string& error) = 0; //! Choose network parameters. virtual void selectParams(const std::string& network) = 0; //! Get the (assumed) blockchain size. virtual uint64_t getAssumedBlockchainSize() = 0; //! Get the (assumed) chain state size. virtual uint64_t getAssumedChainStateSize() = 0; //! Get network name. virtual std::string getNetwork() = 0; //! Init logging. virtual void initLogging() = 0; //! Init parameter interaction. virtual void initParameterInteraction() = 0; //! Get warnings. virtual std::string getWarnings(const std::string& type) = 0; // Get log flags. virtual uint32_t getLogCategories() = 0; //! Initialize app dependencies. virtual bool baseInitialize() = 0; //! Start node. virtual bool appInitMain() = 0; //! Stop node. virtual void appShutdown() = 0; //! Start shutdown. virtual void startShutdown() = 0; //! Return whether shutdown was requested. virtual bool shutdownRequested() = 0; //! Setup arguments virtual void setupServerArgs() = 0; //! Map port. virtual void mapPort(bool use_upnp) = 0; //! Get proxy. virtual bool getProxy(Network net, proxyType& proxy_info) = 0; //! Get number of connections. virtual size_t getNodeCount(CConnman::NumConnections flags) = 0; //! Get stats for connected nodes. using NodesStats = std::vector<std::tuple<CNodeStats, bool, CNodeStateStats>>; virtual bool getNodesStats(NodesStats& stats) = 0; //! Get ban map entries. virtual bool getBanned(banmap_t& banmap) = 0; //! Ban node. virtual bool ban(const CNetAddr& net_addr, BanReason reason, int64_t ban_time_offset) = 0; //! Unban node. virtual bool unban(const CSubNet& ip) = 0; //! Disconnect node by address. virtual bool disconnect(const CNetAddr& net_addr) = 0; //! Disconnect node by id. virtual bool disconnect(NodeId id) = 0; //! Get total bytes recv. virtual int64_t getTotalBytesRecv() = 0; //! Get total bytes sent. virtual int64_t getTotalBytesSent() = 0; //! Get mempool size. virtual size_t getMempoolSize() = 0; //! Get mempool dynamic usage. virtual size_t getMempoolDynamicUsage() = 0; //! Get header tip height and time. virtual bool getHeaderTip(int& height, int64_t& block_time) = 0; //! Get num blocks. virtual int getNumBlocks() = 0; //! Get last block time. virtual int64_t getLastBlockTime() = 0; //! Get verification progress. virtual double getVerificationProgress() = 0; //! Is initial block download. virtual bool isInitialBlockDownload() = 0; //! Get reindex. virtual bool getReindex() = 0; //! Get importing. virtual bool getImporting() = 0; //! Set network active. virtual void setNetworkActive(bool active) = 0; //! Get network active. virtual bool getNetworkActive() = 0; //! Get max tx fee. virtual CAmount getMaxTxFee() = 0; //! Estimate smart fee. virtual CFeeRate estimateSmartFee(int num_blocks, bool conservative, int* returned_target = nullptr) = 0; //! Get dust relay fee. virtual CFeeRate getDustRelayFee() = 0; //! Execute rpc command. virtual UniValue executeRpc(const std::string& command, const UniValue& params, const std::string& uri) = 0; //! List rpc commands. virtual std::vector<std::string> listRpcCommands() = 0; //! Set RPC timer interface if unset. virtual void rpcSetTimerInterfaceIfUnset(RPCTimerInterface* iface) = 0; //! Unset RPC timer interface. virtual void rpcUnsetTimerInterface(RPCTimerInterface* iface) = 0; //! Get unspent outputs associated with a transaction. virtual bool getUnspentOutput(const COutPoint& output, Coin& coin) = 0; //! Return default wallet directory. virtual std::string getWalletDir() = 0; //! Return available wallets in wallet directory. virtual std::vector<std::string> listWalletDir() = 0; //! Return interfaces for accessing wallets (if any). virtual std::vector<std::unique_ptr<Wallet>> getWallets() = 0; //! Attempts to load a wallet from file or directory. //! The loaded wallet is also notified to handlers previously registered //! with handleLoadWallet. virtual std::unique_ptr<Wallet> loadWallet(const std::string& name, std::string& error, std::string& warning) = 0; //! Register handler for init messages. using InitMessageFn = std::function<void(const std::string& message)>; virtual std::unique_ptr<Handler> handleInitMessage(InitMessageFn fn) = 0; //! Register handler for message box messages. using MessageBoxFn = std::function<bool(const std::string& message, const std::string& caption, unsigned int style)>; virtual std::unique_ptr<Handler> handleMessageBox(MessageBoxFn fn) = 0; //! Register handler for question messages. using QuestionFn = std::function<bool(const std::string& message, const std::string& non_interactive_message, const std::string& caption, unsigned int style)>; virtual std::unique_ptr<Handler> handleQuestion(QuestionFn fn) = 0; //! Register handler for progress messages. using ShowProgressFn = std::function<void(const std::string& title, int progress, bool resume_possible)>; virtual std::unique_ptr<Handler> handleShowProgress(ShowProgressFn fn) = 0; //! Register handler for load wallet messages. using LoadWalletFn = std::function<void(std::unique_ptr<Wallet> wallet)>; virtual std::unique_ptr<Handler> handleLoadWallet(LoadWalletFn fn) = 0; //! Register handler for number of connections changed messages. using NotifyNumConnectionsChangedFn = std::function<void(int new_num_connections)>; virtual std::unique_ptr<Handler> handleNotifyNumConnectionsChanged(NotifyNumConnectionsChangedFn fn) = 0; //! Register handler for network active messages. using NotifyNetworkActiveChangedFn = std::function<void(bool network_active)>; virtual std::unique_ptr<Handler> handleNotifyNetworkActiveChanged(NotifyNetworkActiveChangedFn fn) = 0; //! Register handler for notify alert messages. using NotifyAlertChangedFn = std::function<void()>; virtual std::unique_ptr<Handler> handleNotifyAlertChanged(NotifyAlertChangedFn fn) = 0; //! Register handler for ban list messages. using BannedListChangedFn = std::function<void()>; virtual std::unique_ptr<Handler> handleBannedListChanged(BannedListChangedFn fn) = 0; //! Register handler for block tip messages. using NotifyBlockTipFn = std::function<void(bool initial_download, int height, int64_t block_time, double verification_progress)>; virtual std::unique_ptr<Handler> handleNotifyBlockTip(NotifyBlockTipFn fn) = 0; //! Register handler for header tip messages. using NotifyHeaderTipFn = std::function<void(bool initial_download, int height, int64_t block_time, double verification_progress)>; virtual std::unique_ptr<Handler> handleNotifyHeaderTip(NotifyHeaderTipFn fn) = 0; }; //! Return implementation of Node interface. std::unique_ptr<Node> MakeNode(); } // namespace interfaces #endif // mkscoin_INTERFACES_NODE_H
[ "15370399888@163.com" ]
15370399888@163.com
d386ac319fef8b60b9b768a64b4ebb5a994c9741
cfeac52f970e8901871bd02d9acb7de66b9fb6b4
/generated/src/aws-cpp-sdk-sagemaker/include/aws/sagemaker/model/AutoMLSortBy.h
71c6768156d431e4febc85c2bc0485a37b2836e2
[ "Apache-2.0", "MIT", "JSON" ]
permissive
aws/aws-sdk-cpp
aff116ddf9ca2b41e45c47dba1c2b7754935c585
9a7606a6c98e13c759032c2e920c7c64a6a35264
refs/heads/main
2023-08-25T11:16:55.982089
2023-08-24T18:14:53
2023-08-24T18:14:53
35,440,404
1,681
1,133
Apache-2.0
2023-09-12T15:59:33
2015-05-11T17:57:32
null
UTF-8
C++
false
false
659
h
/** * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0. */ #pragma once #include <aws/sagemaker/SageMaker_EXPORTS.h> #include <aws/core/utils/memory/stl/AWSString.h> namespace Aws { namespace SageMaker { namespace Model { enum class AutoMLSortBy { NOT_SET, Name, CreationTime, Status }; namespace AutoMLSortByMapper { AWS_SAGEMAKER_API AutoMLSortBy GetAutoMLSortByForName(const Aws::String& name); AWS_SAGEMAKER_API Aws::String GetNameForAutoMLSortBy(AutoMLSortBy value); } // namespace AutoMLSortByMapper } // namespace Model } // namespace SageMaker } // namespace Aws
[ "sdavtaker@users.noreply.github.com" ]
sdavtaker@users.noreply.github.com
9fadac1b5794ea48fba046e23a8d080436d1a7ce
157668c81e84c9fd675a7fdcc7b350333a38f50d
/Selector.h
7b76b1e95eb00fefb0db32b4e2af3e0e94ae1a41
[]
no_license
SohaylaMohamed/Tournment-Predictor
7a0f2e480fe35f5ec37f2c44231b7211d746c3d8
e5fb7eb9b4e194e41c061cbe690c4c898b24beaf
refs/heads/master
2022-09-15T02:15:29.443818
2020-06-02T19:51:49
2020-06-02T19:51:49
268,894,565
0
0
null
null
null
null
UTF-8
C++
false
false
464
h
// // Created by sohayla on 13/03/19. // #ifndef TOURNMENT_PREDICTOR_SELECTOR_H #define TOURNMENT_PREDICTOR_SELECTOR_H #include <string> #include <map> #include "State.h" using namespace std; class Selector { private: string index; State *currentState; public: Selector(string index); string getSelection(); void updateSelectionState(bool local, bool global, bool actual); string getIndex(); }; #endif //TOURNMENT_PREDICTOR_SELECTOR_H
[ "sohaylaMohammed734@gmail.com" ]
sohaylaMohammed734@gmail.com
ceaa1419e7a2942b101102b19b67d496b1171197
e1bfbf48adea8cc8e2a4daa2dc1dbcb5ae811df5
/Hashing/hashChain.h
aa0efeed57b40b6208ed1913d2b036b6fe2701a2
[]
no_license
utec-cs-aed/solution_mix
c702394a719c6232baf798a18d1c76a7f8c9cf4f
06d75534ef185b770e20c4fc6a211d97bb03fd33
refs/heads/main
2023-04-20T18:32:17.694779
2021-05-10T19:48:51
2021-05-10T19:48:51
300,741,408
0
0
null
null
null
null
UTF-8
C++
false
false
1,771
h
template <typename TK, typename TV> class Hash { private: struct Node { int hashCode; TK value; TV value; Node* next; }; int arrayLength; int size; Node** array; public: Hash(int _length) { arrayLength = _length; array = new Node*[arrayLength]; for (int i = 0; i < arrayLength; i++) array[i] = nullptr; } void insert(TK key, TV value) { int hashCode = getHashCode(key); //funcion hash int index = hashCode % arrayLength; //colisiones if (array[index] == nullptr) array[index] = new Node(hashCode, value); else push_front(array[index], new Node(hashCode, key, value)); } void insert(Node* node) { int hashCode = node->hashCode; int index = hashCode % arrayLength;//colisiones node->next = nullptr; if (array[index] == nullptr) array[index] = node; push_front(array[index], node); } void rehashing() { int tempL = arrayLength; Node** temp = array; arrayLength = arrayLength * 2; array = new Node*[arrayLength]; for(int i=0;i<arrayLength;i++) array[i] = nullptr; for (int i = 0; i < tempL; i++) { for(Node* node = temp[i]; node != null; node = node->next) insert(node); } delete[] temp; } TV operator[](TK key){ //TODO } TV find(TK key){ // TODO } bool remove(TK key){ // TODO } vector<TK> getAllKeys(){ // TODO } vector<pairs<TK, TV>> getAll(){ // TODO } };
[ "heider.sanchez.pe@gmail.com" ]
heider.sanchez.pe@gmail.com
d9e5fdad5396e973cbc0797fff346da2bd149651
c3f18073dac4767129e28dece885dc95525c1f53
/LeetCode/All/cpp/141.linked-list-cycle.cpp
4be4dff40aab45aeae1044682b365db21fef4adc
[ "MIT" ]
permissive
sunnysetia93/competitive-coding-problems
670ffe1ec90bfee0302f0b023c09e80bf5547e96
e8fad1a27a9e4df8b4138486a52bef044586c066
refs/heads/master
2023-08-09T04:31:24.027037
2023-07-24T12:39:46
2023-07-24T12:39:46
89,518,943
20
22
MIT
2023-07-24T12:39:48
2017-04-26T19:29:18
JavaScript
UTF-8
C++
false
false
453
cpp
/** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; */ class Solution { public: bool hasCycle(ListNode *head) { ListNode *slow = head, *fast = head; while (fast && fast->next) { slow = slow->next; fast = fast->next->next; if (slow == fast) return true; } return false; } };
[ "bhavi.dhingra@gmail.com" ]
bhavi.dhingra@gmail.com
8ac3d1612b1617d2b1a66459033ce7d96637aa25
850c8077bfa06b340f54f44a425f79e2b583e415
/Source/LivingAvatars/MyAnimationBlueprintLibrary.cpp
16d2058ddb10ba2a072bcc5ea11f8626d8bc8eb7
[ "MIT" ]
permissive
adamriley1219/VRAvatarMotion
7d37fe611c022df86b802c9344779abbd3bfd179
17ca530d0a26fd77ccb9406947479585574a0aae
refs/heads/master
2021-09-14T10:33:53.168961
2018-05-11T21:11:47
2018-05-11T21:11:47
105,055,644
0
0
null
null
null
null
UTF-8
C++
false
false
125
cpp
// Fill out your copyright notice in the Description page of Project Settings. #include "MyAnimationBlueprintLibrary.h"
[ "adamriley1219@gmail.com" ]
adamriley1219@gmail.com
f3bf32d9a46f4d375e16ed5c0ce2e142460ed71c
307ff7435a9b6f0090c873626ff2861ccc0b7c41
/c메모/문장만들기.cpp
521c02891538510e6a424ea89fcc6d43b9f9666e
[]
no_license
sjoon627/basic_200
eb579eca1d9633314ba98d981f426472d9109f3e
4ab045557458e40e83752b1bc017b2047c84b253
refs/heads/master
2020-09-02T04:40:31.776787
2020-04-11T14:45:03
2020-04-11T14:45:03
219,133,766
2
0
null
null
null
null
UTF-8
C++
false
false
681
cpp
#include <stdio.h> #include <string.h> int main() { freopen("input.txt","r",stdin); freopen("output.txt","w",stdout); int l,i,j,n; char str[2][10000]={0}; int A[2][26]={0}; scanf("%s",str[0]); l=strlen(str[0]); for(i=0;i<26;i++){ A[0][i]=i; } for(i=0;i<l;i++){ A[1][str[0][i]-'a']+=1; } for(j=1;j<26;j++){ for(i=1;i<26;i++){ if(A[1][i-1]<A[1][i]){ for(j=0;j<2;j++){ n=A[j][i-1]; A[j][i-1]=A[j][i]; A[j][i]=n; } } } } i=0; do{ for(j=0;j<l;j++){ if(str[1][j]==0){ printf("%c",str[0][j]); if(A[0][i]==str[0][j]-'a') str[1][j]=1; } }printf("\n"); i++; }while(A[1][i]!=0); return 0; }
[ "48435096+sjoon627@users.noreply.github.com" ]
48435096+sjoon627@users.noreply.github.com
b49b4f5e70bdfdd70db0b4ecc8e8eef792efbdf5
0b049f21ccdb20c78dc8e94fdca9c5f089345642
/算法竞赛宝典/第三部资源包/第八章 线段树/天网.cpp
1b36df77ee70726b7dc9898db9eda856b741179d
[]
no_license
yannick-cn/book_caode
4eb26241056160a19a2898a80f8b9a7d0ed8dd99
5ea468841703667e5f666be49fece17ae0d5f808
refs/heads/master
2020-05-07T14:17:50.802858
2019-04-10T13:01:19
2019-04-10T13:01:19
180,582,574
0
0
null
null
null
null
GB18030
C++
false
false
1,786
cpp
//天网 #include<stdio.h> #define Max 200001 struct data { int l,r,max; }node[3*Max]; int score[Max];//保存分数 int max(int a,int b) { return a>b? a:b; } void BuildTree(int left,int right,int num)//建树 { node[num].l=left; node[num].r=right; if(left==right) { node[num].max=score[left]; } else { BuildTree(left,(left+right)>>1,2*num); BuildTree(((left+right)>>1)+1,right,2*num+1); node[num].max=max(node[2*num].max,node[2*num+1].max); } } void Update(int stu,int val,int num)//更新成绩 { node[num].max=max(val,node[num].max);//只更新最大值即可 if(node[num].l==node[num].r) return; if(stu<=node[2*num].r) Update(stu,val,2*num); else Update(stu,val,2*num+1); } int Query(int left,int right,int num)//询问操作 { if(node[num].l==left && node[num].r==right) return node[num].max; if(right<=node[2*num].r) return Query(left,right,2*num); if(left>=node[2*num+1].l) return Query(left,right,2*num+1); int mid=(node[num].l+node[num].r)>>1; return max(Query(left,mid,2*num),Query(mid+1,right,2*num+1)); } int main() { int N,M; while(scanf("%d%d",&N,&M)!=EOF) { int i; for(i=1;i<=N;i++) { scanf("%d",&score[i]); } getchar(); char c; int s,e; BuildTree(1,N,1); for(i=0;i<M;i++) { scanf("%c%d%d",&c,&s,&e); getchar(); if(c=='U') { Update(s,e,1); } if(c=='Q') { printf("%d\n",Query(s,e,1)); } } } return 0; }
[ "happyhpuyj@gmail.com" ]
happyhpuyj@gmail.com
d5d52a68655d2d0f84aaefd0a82b3f9bbc114817
ce814fc0678bc864f8d38362660adc8de9e25329
/Coursework/nclgl/Mesh.h
82ea6f3ea3a076bb3cf0e4da85cf70dcb575c4bc
[]
no_license
nutiel/CSC5802
c7329e3a4062b3e80bae0add7a6bcb349fb6394d
d0e26f9249625c90f98d856d707e68a75527c866
refs/heads/master
2021-08-18T21:34:21.308191
2017-11-23T21:06:09
2017-11-23T21:06:09
110,700,424
0
0
null
null
null
null
UTF-8
C++
false
false
1,119
h
#pragma once #include "OGLRenderer.h" enum MeshBuffer { VERTEX_BUFFER, COLOUR_BUFFER, TEXTURE_BUFFER, NORMAL_BUFFER, TANGENT_BUFFER, INDEX_BUFFER, MAX_BUFFER }; class Mesh { public: Mesh(void); ~Mesh(void); virtual void Draw(); static Mesh * GenerateTriangle(float x, float y, float z); static Mesh * GenerateSquare(float x, float y, float z); static Mesh * GenerateQuad(); static Mesh * GeneratePyramid(); void SetTexture(GLuint tex) { texture = tex; } void SetBumpMap(GLuint tex) { bumpTexture = tex; } GLuint GetBumpMap() { return bumpTexture; } GLuint GetTexture() { return texture; } protected: unsigned int * indices; void GenerateNormals(); void BufferData(); void GenerateTangents(); Vector3 GenerateTangent(const Vector3 &a, const Vector3 &b, const Vector3 &c, const Vector2 & ta,const Vector2 & tb, const Vector2 & tc); Vector3 * tangents; GLuint bumpTexture; GLuint texture; GLuint numIndices; GLuint arrayObject; GLuint bufferObject[MAX_BUFFER]; GLuint numVertices; GLuint type; Vector2 * textureCoords; Vector3 * vertices; Vector3 * normals; Vector4 * colours; };
[ "32769684+nutiel@users.noreply.github.com" ]
32769684+nutiel@users.noreply.github.com
bf357ec8c055f8aeb88b152187db92ae8df705e3
bfd6feab3383162d4cc6f7bbecc94ed7e1fb369b
/UI/Source/Crash.h
ebc70d833db327098fe0946cb394a4224cdef76f
[ "Apache-2.0" ]
permissive
paultcn/launcher
1a9200ecf57bf8703031a442063d6ed904ce8dfe
d8397995e18200b12d60781ed485af04f70bff03
refs/heads/master
2021-07-13T00:52:56.408370
2017-09-27T09:13:31
2017-09-27T09:13:31
null
0
0
null
null
null
null
UTF-8
C++
false
false
530
h
#ifndef __CRASH_H__ #define __CRASH_H__ #include "../JuceLibraryCode/JuceHeader.h" #include "Poco/Logger.h" class Crash : public juce::Component, public juce::ButtonListener { public: Crash(); ~Crash(); void paint (juce::Graphics&) override; void resized() override; void buttonClicked(juce::Button* button) override; private: Poco::Logger* _logger; juce::ImageComponent _crashBot; JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (Crash); }; #endif
[ "i@crioto.com" ]
i@crioto.com
ef6f61e71bb0eebc8d0b82289aaf6e97658cab9f
4e49f2b456882ba8643907a196f86b3062004243
/MFCTeeChart/MFCTeeChart/TeeChar/surfaceseries.h
81c1db4b88c1f559d1c30528ef5bbd01fa448c26
[]
no_license
772148702/Artificial-Intelligence
d4616acf13a38658fc38e71874091b4a0596f6ac
3b2c48af7a88adc2d2fab01176db7c811deda1d1
refs/heads/master
2018-08-29T19:14:37.293494
2018-07-06T15:16:10
2018-07-06T15:16:10
108,261,921
0
1
null
null
null
null
UTF-8
C++
false
false
3,030
h
// Machine generated IDispatch wrapper class(es) created by Microsoft Visual C++ // NOTE: Do not modify the contents of this file. If this class is regenerated by // Microsoft Visual C++, your modifications will be overwritten. // Dispatch interfaces referenced by this interface class CValueList; class CBrush1; class CPen1; class CChartHiddenPen; ///////////////////////////////////////////////////////////////////////////// // CSurfaceSeries wrapper class class CSurfaceSeries : public COleDispatchDriver { public: CSurfaceSeries() {} // Calls COleDispatchDriver default constructor CSurfaceSeries(LPDISPATCH pDispatch) : COleDispatchDriver(pDispatch) {} CSurfaceSeries(const CSurfaceSeries& dispatchSrc) : COleDispatchDriver(dispatchSrc) {} // Attributes public: // Operations public: long AddXYZ(double AX, double AY, double AZ, LPCTSTR AXLabel, unsigned long Value); double MaxZValue(); double MinZValue(); long GetTimesZOrder(); void SetTimesZOrder(long nNewValue); CValueList GetZValues(); double GetZValue(long Index); void SetZValue(long Index, double newValue); CBrush1 GetBrush(); CPen1 GetPen(); void AddArrayXYZ(const VARIANT& XArray, const VARIANT& YArray, const VARIANT& ZArray); void AddArrayGrid(long NumX, long NumZ, const VARIANT& XZArray); long CalcZPos(long ValueIndex); long AddPalette(double Value, unsigned long Color); unsigned long GetStartColor(); void SetStartColor(unsigned long newValue); unsigned long GetEndColor(); void SetEndColor(unsigned long newValue); long GetPaletteSteps(); void SetPaletteSteps(long nNewValue); BOOL GetUsePalette(); void SetUsePalette(BOOL bNewValue); BOOL GetUseColorRange(); void SetUseColorRange(BOOL bNewValue); void ClearPalette(); void CreateDefaultPalette(long NumSteps); unsigned long GetSurfacePaletteColor(double Y); unsigned long GetMidColor(); void SetMidColor(unsigned long newValue); void CreateRangePalette(); long GetPaletteStyle(); void SetPaletteStyle(long nNewValue); BOOL GetUsePaletteMin(); void SetUsePaletteMin(BOOL bNewValue); double GetPaletteMin(); void SetPaletteMin(double newValue); double GetPaletteStep(); void SetPaletteStep(double newValue); void InvertPalette(); void AddCustomPalette(const VARIANT& colorArray); long GetNumXValues(); void SetNumXValues(long nNewValue); long GetNumZValues(); void SetNumZValues(long nNewValue); double GetXZValue(long X, long Z); BOOL GetIrregularGrid(); void SetIrregularGrid(BOOL bNewValue); void SmoothGrid3D(); BOOL GetReuseGridIndex(); void SetReuseGridIndex(BOOL bNewValue); void FillGridIndex(long StartIndex); BOOL GetDotFrame(); void SetDotFrame(BOOL bNewValue); BOOL GetWireFrame(); void SetWireFrame(BOOL bNewValue); CBrush1 GetSideBrush(); BOOL GetSmoothPalette(); void SetSmoothPalette(BOOL bNewValue); long GetTransparency(); void SetTransparency(long nNewValue); BOOL GetFastBrush(); void SetFastBrush(BOOL bNewValue); BOOL GetHideCells(); void SetHideCells(BOOL bNewValue); CChartHiddenPen GetSideLines(); };
[ "772148702@qq.com" ]
772148702@qq.com
4107e7e24488ba4dd79c841baf3d6d43edced4c8
331dd3ecae04a64b0e9d54a86c5bd9d5db6a53ac
/src/http/Url.cpp
5a349d7339cca79d20d5692e02cc4d403b5b2d3d
[]
no_license
makarenya/vantagefx
e6a3a3162beb1c29e627a5f94f8afc52ab961149
413e5568b55a1cb028063825681d32407a1fb277
refs/heads/master
2020-12-29T02:36:34.127314
2017-04-10T12:17:28
2017-04-10T12:17:28
55,528,986
0
0
null
null
null
null
UTF-8
C++
false
false
2,753
cpp
// // Created by alexx on 17.04.2016. // #include "Url.h" #ifdef _MSC_VER #pragma warning(disable : 4503) #pragma warning(push) #pragma warning(disable: 4348) // possible loss of data #endif #include <boost/lexical_cast.hpp> #include <boost/spirit/include/qi.hpp> #include <boost/fusion/adapted.hpp> #include <boost/fusion/tuple.hpp> #include <string> #ifdef _MSC_VER #pragma warning(pop) #endif namespace vantagefx { namespace http { namespace parser { namespace qi = boost::spirit::qi; using boost::optional; typedef std::tuple<optional<std::string>, std::string, optional<int>, optional<std::string>, optional<std::string>> RawUrl; template<typename Iterator> struct UrlParser : qi::grammar<Iterator, RawUrl()> { UrlParser(); qi::rule<Iterator, RawUrl()> entry; qi::rule<Iterator, std::string()> string; qi::rule<Iterator, std::string()> domain; qi::rule<Iterator, char()> escaped; qi::rule<Iterator, std::string()> scheme; }; template <typename Iterator> UrlParser<Iterator>::UrlParser() : UrlParser::base_type(entry) { entry = -(scheme >> "://") >> domain >> -(qi::lit(':') >> qi::int_) >> -(qi::char_('/') >> string) >> -(qi::char_('#') >> string); string = +(escaped | qi::alnum | qi::char_("$_.+!*'(),/-")); domain = +(escaped | qi::alnum | qi::char_("$_.+!*'(),-")); escaped = qi::lit('%') >> qi::int_; scheme = +(qi::alnum); } } Url::Url() : _port(0) {} Url::Url(std::string url) : _port(0) { parser::RawUrl raw; parser::UrlParser<std::string::iterator> urlParser; boost::spirit::qi::parse(url.begin(), url.end(), urlParser, raw); auto scheme = std::get<0>(raw); if (scheme) _scheme = *scheme; _host = std::get<1>(raw); auto port = std::get<2>(raw); if (port) _port = *port; auto path = std::get<3>(raw); if (path) _path = *path; auto hash = std::get<4>(raw); if (hash) _hash = *hash; _uri = url; } std::string Url::serverUrl() const { if (port() == 0) return scheme() + "://" + host(); return scheme() + "://" + host() + ":" + boost::lexical_cast<std::string>(port()); } Url::operator std::string() const { return _uri; } } }
[ "alexey@deli.su" ]
alexey@deli.su
59cb28ded54536f411976be14cad000c2b8373a2
c76346e1ac0e6ac32c2ada9496a5a92133146ced
/src/cpu_bsplv.cpp
49b581cb0b006bb7cfbe96ebf2d4212082977f5f
[]
no_license
mhieronymus/GUSTAV
ed2cf58c4c6d4c6acf870118d88c142d9030829e
97d09ae60e6734acf06c2780d0d4f814e0800446
refs/heads/master
2020-03-30T04:14:09.223343
2018-10-19T07:34:32
2018-10-19T07:34:32
null
0
0
null
null
null
null
UTF-8
C++
false
false
10,636
cpp
#include "cpu_bsplv.hpp" CPU_BSPLV::CPU_BSPLV( char * filename) { load_table(filename); } CPU_BSPLV::~CPU_BSPLV() { free_table(); } // Binary search to find the leftmost spline with support. // Uses left as first guess void CPU_BSPLV::find_left_knot( value_t * knots, index_t n_knts, index_t & left, value_t x) { if(left == n_knts) {left--; return;} if(left == n_knts-1) return; if(knots[left] < x && knots[left+1] > x) return; index_t high = n_knts; do { if(knots[left] > x) { high = left; left = left >> 1; } else { left += (high - left) >> 1; } } while(knots[left] > x || knots[left+1] < x); } /* * Evaluate the result of a full spline basis given a set of knots, a position, * an order and the leftmost spline for the position (or -1) that has support. */ value_t CPU_BSPLV::ndsplineeval_core_2( index_t * centers, index_t maxdegree, value_t * biatx) { value_t result = 0; value_t basis_tree[table->ndim+1]; index_t decomposed_pos[table->ndim]; index_t tablepos = 0; basis_tree[0] = 1; index_t nchunks = 1; for(index_t i=0; i<table->ndim; ++i) { decomposed_pos[i] = 0; tablepos += (centers[i]-table->order[i]) * table->strides[i]; basis_tree[i+1] = basis_tree[i] * biatx[i*(maxdegree+1)]; } for(index_t i=0; i<table->ndim - 1; ++i) nchunks *= (table->order[i] + 1); index_t n = 0; while(true) { // I did not see any improvements by using __builtin_expect for (index_t i = 0; __builtin_expect(i < table->order[table->ndim-1] + 1, 1); i++) // for(index_t i=0; i<table->order[table->ndim-1]+1; ++i) { result += basis_tree[table->ndim-1] * biatx[(table->ndim-1)*(maxdegree+1) + i] * table->coefficients[tablepos+i]; } if (__builtin_expect(++n == nchunks, 0)) break; // if(++n == nchunks) break; tablepos += table->strides[table->ndim-2]; decomposed_pos[table->ndim-2]++; // Now to higher dimensions index_t i; for(i=table->ndim-2; decomposed_pos[i]>table->order[i]; --i) { decomposed_pos[i-1]++; tablepos += (table->strides[i-1] - decomposed_pos[i]*table->strides[i]); decomposed_pos[i] = 0; } // for(index_t j=i; j < table->ndim-1; ++j) for (index_t j = i; __builtin_expect(j < table->ndim-1, 1); ++j) basis_tree[j+1] = basis_tree[j] * biatx[j*(maxdegree+1) + decomposed_pos[j]]; } return result; } // See "A Practical Guide to Splines (revisited)" by Carl de Boor () // Chapter X, page 112f /* See "A Practical Guide to Splines (revisited)" by Carl de Boor () * Chapter X, page 112f * Input: knots = knot sequence (non-decreasing) * jhigh = the number of columns-1 of values that shall be generated * should agree with the order * index = order of spline * x = the point at which the splines shall be evaluated * left = index with knots[left] <= x <= knots[left+1] * biatx = help array that stores the evaluations */ void CPU_BSPLV::bsplvb_2( value_t * knots, index_t jhigh, index_t index, value_t x, index_t left, value_t * biatx, index_t nknots) { index_t j = 0; // In case if x is outside of the full support of the spline surface. if(left == jhigh) { while(left >= 0 && x < knots[left]) left--; } else if(left == nknots-jhigh-2) { while (left < nknots-1 && x > knots[left+1]) left++; } if(index != 2) { biatx[j] = 1; // Check if no more columns need to be evaluated. if(j >= jhigh) return; } value_t delta_r[jhigh]; value_t delta_l[jhigh]; do { delta_r[j] = knots[left + j + 1] - x; delta_l[j] = x - knots[left-j]; value_t saved = 0; for(index_t i=0; i<=j; ++i) { value_t term = biatx[i] / (delta_r[i] + delta_l[j-i]); biatx[i] = saved + delta_r[i] * term; saved = delta_l[j-i] * term; } biatx[j+1] = saved; j++; } while(j < jhigh); // shouldn't that be sufficient? /* * If left < (spline order), only the first (left+1) * splines are valid; the remainder are utter nonsense. * TODO: Check why */ index_t i = jhigh-left; if (i > 0) { for (j = 0; j < left+1; j++) biatx[j] = biatx[j+i]; /* Move valid splines over. */ for ( ; j <= jhigh; j++) biatx[j] = 0.0; /* The rest are zero by construction. */ } i = left+jhigh+2-nknots; if (i > 0) { for (j = jhigh; j > i-1; j--) biatx[j] = biatx[j-i]; for ( ; j >= 0; j--) biatx[j] = 0.0; } } value_t CPU_BSPLV::wiki_bsplines( value_t * knots, value_t x, index_t left, index_t order) { if(order == 0) { if(knots[left] <= x && x < knots[left+1]) return 1; return 0; } value_t result = (x-knots[left]) * wiki_bsplines(knots, x, left, order-1) / (knots[left+order] - knots[left]); result += (knots[left+order+1] - x) * wiki_bsplines(knots, x, left+1, order-1) / (knots[left+order+1] - knots[left+1]); return result; } // Create n_evals times a random array of size n_dims and evaluate the spline void CPU_BSPLV::eval_splines( index_t n_evals, value_t * y_array) { std::mt19937 engine(42); std::uniform_real_distribution<value_t> normal_dist(0, 1); value_t range[table->ndim]; index_t maxdegree = 0; for(index_t d=0; d<table->ndim; d++) { range[d] = table->knots[d][table->nknots[d]-1] - table->knots[d][0]; maxdegree = maxdegree > table->order[d] ? maxdegree : table->order[d]; } for(index_t i=0; i<n_evals; ++i) { value_t biatx[table->ndim*(maxdegree+1)]; // index_t lefties[table->ndim]; index_t centers[table->ndim]; // Get a random parameter within the splines value_t par[table->ndim]; // That's the way IceCube does that. But why search for tablecenters? for(index_t d=0; d<table->ndim; ++d) par[d] = range[d] * normal_dist(engine) + table->knots[d][0]; // We actually search for table centers. Who knows, why tablesearchcenters(table, par, centers); // For every dimension for(index_t d=0; d<table->ndim; ++d) { // Get the values bsplvb_2( table->knots[d], table->order[d], 1, par[d], centers[d], &(biatx[d*(maxdegree+1)]), table->nknots[d] ); } // store y or something // y_array[i] = biatx[(table->ndim)*(maxdegree + 1) - 1]; y_array[i] = ndsplineeval_core_2(centers, maxdegree, biatx); } } /* * The original IceCube call. */ void CPU_BSPLV::eval_splines_vanilla( index_t n_evals, value_t * y_array) { std::mt19937 engine(42); std::uniform_real_distribution<value_t> normal_dist(0, 1); value_t range[table->ndim]; for(index_t d=0; d<table->ndim; d++) { range[d] = table->knots[d][table->nknots[d]-1] - table->knots[d][0]; } for(index_t i=0; i<n_evals; ++i) { index_t centers[table->ndim]; // Get a random parameter within the splines value_t par[table->ndim]; for(index_t d=0; d<table->ndim; d++) par[d] = range[d] * normal_dist(engine) + table->knots[d][0]; // We actually search for table centers. Who knows, why tablesearchcenters(table, par, centers); y_array[i] = ndsplineeval(table, par, centers, 0); } } /* * Evaluate the splines as in IceCube but use my multi dimensional overall * evaluation. */ void CPU_BSPLV::eval_splines_simple( index_t n_evals, value_t * y_array) { std::mt19937 engine(42); std::uniform_real_distribution<value_t> normal_dist(0, 1); value_t range[table->ndim]; index_t maxdegree = 0; for(index_t d=0; d<table->ndim; d++) { range[d] = table->knots[d][table->nknots[d]-1] - table->knots[d][0]; maxdegree = maxdegree > table->order[d] ? maxdegree : table->order[d]; } for(index_t i=0; i<n_evals; ++i) { value_t biatx[table->ndim*(maxdegree+1)]; // index_t lefties[table->ndim]; index_t centers[table->ndim]; // Get a random parameter within the splines value_t par[table->ndim]; for(index_t d=0; d<table->ndim; d++) par[d] = range[d] * normal_dist(engine) + table->knots[d][0]; tablesearchcenters(table, par, centers); // For every dimension for(index_t d=0; d<table->ndim; d++) { bsplvb_simple( table->knots[d], table->nknots[d], par[d], centers[d], table->order[d]+1, &(biatx[d*(maxdegree+1)]) ); } // store y or something // y_array[i] = biatx[(table->ndim)*(maxdegree + 1) - 1]; y_array[i] = ndsplineeval_core_2(centers, maxdegree, biatx); } } void CPU_BSPLV::load_table( char * filename) { if(table != nullptr) free_table(); table = new splinetable(); std::cout << "loading from " << filename << "\n"; start("load_from_file"); // Load a spline file from a file given by the command line if(!load_splines(table, filename)) { std::cout << "Failed to load. Abort the mission!\n"; std::cout << "I repeat: Abort the mission!\n"; } stop(); } void CPU_BSPLV::free_table() { for(index_t i=0; i<table->ndim; ++i) free(table->knots[i] - table->order[i]); free(table->knots); free(table->order); free(table->nknots); free(table->periods); free(table->coefficients); free(table->naxes); free(table->strides); free(table->extents[0]); free(table->extents); for(index_t i=0; i<table->naux; ++i) { free(table->aux[i][1]); free(table->aux[i][0]); free(table->aux[i]); } free(table->aux); delete table; }
[ "mhierony@students.uni-mainz.de" ]
mhierony@students.uni-mainz.de
319b044afa2e5f84360e2658bd4be8639a2780f9
976aa8b8ec51241cbac230d5488ca4a24b5101dd
/lib/dart_analyzer_execreq_normalizer.h
15ec09c1f43fb183a1a67a00fd7099126239ea85
[ "BSD-3-Clause" ]
permissive
djd0723/goma-client
023a20748b363c781dce7e7536ffa2b5be601327
1cffeb7978539ac2fee02257ca0a95a05b4c6cc0
refs/heads/master
2023-03-29T07:44:30.644108
2021-03-24T11:49:54
2021-03-24T15:03:09
null
0
0
null
null
null
null
UTF-8
C++
false
false
855
h
// Copyright 2019 The Goma 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 DEVTOOLS_GOMA_LIB_DART_ANALYZER_EXECREQ_NORMALIZER_H_ #define DEVTOOLS_GOMA_LIB_DART_ANALYZER_EXECREQ_NORMALIZER_H_ #include "lib/execreq_normalizer.h" namespace devtools_goma { class DartAnalyzerExecReqNormalizer : public ConfigurableExecReqNormalizer { protected: Config Configure( int id, const std::vector<std::string>& args, bool normalize_include_path, bool is_linking, const std::vector<std::string>& normalize_weak_relative_for_arg, const std::map<std::string, std::string>& debug_prefix_map, const ExecReq* req) const override; }; } // namespace devtools_goma #endif // DEVTOOLS_GOMA_LIB_DART_ANALYZER_EXECREQ_NORMALIZER_H_
[ "tikuta@chromium.org" ]
tikuta@chromium.org
767d664db770d1a35c6bea61e8c1a3cd06e13ec0
097b30de420bd68117a20613e4ed62f1f994626a
/crc8saej1850.h
d24002d1a7d43b10b0225b5c205b1f491b54d97b
[]
no_license
Kompot11181/BreakCRC
276a8afaeb5e26c54b7933929a0f17223cfe2c77
4fb5045b241d6b9f7aa01888170f64e0faa1af51
refs/heads/master
2022-11-10T17:00:51.352924
2020-06-27T13:29:20
2020-06-27T13:41:52
275,375,019
0
0
null
null
null
null
UTF-8
C++
false
false
593
h
#ifndef CRC8SAEJ1850_H #define CRC8SAEJ1850_H #include <QtCore> // класс, описывающий алгоритм CRC-8-SAE J1850 // x8 + x4 + x3 + x2 + 1 (0x1D | 0x100) // Нормальное представление: 0x1D // Реверсивное представление: 0xB8 // Реверснивное от обратного: 0x8E class crc8SAEJ1850 { public: crc8SAEJ1850(); void CRCInit(void); quint8 CalcCRC(QByteArray buf); quint8 crcTable[256]; bool isInited; quint8 start; quint8 polinom; quint8 xorOut; }; #endif // CRC8SAEJ1850_H
[ "chosen_i@inbox.ru" ]
chosen_i@inbox.ru
09cc47113b6223766cb38eebc0e022fbf49ed53e
41ece9eafe777948758fa3c5d12bc238829164bc
/Arduino/dj_controller/dj_controller.ino
dad40ff043bab160745079b50ccedff13faef57a
[]
no_license
edition89/projects
d4d3a6ecb80cad18e74d9402c401d85077eb974a
d2052d89b2b460f8b6cb9d0f3a08904c50df7862
refs/heads/main
2023-04-06T13:02:30.321554
2021-04-19T08:46:20
2021-04-19T08:46:20
359,360,035
0
0
null
null
null
null
UTF-8
C++
false
false
6,928
ino
#define CLK 15 //Энкодер #define DT 14 #define SW 16 #define PIN 6 //Neopixel #define NUMPIXELS 32 #define ARRENC 6 // Массив действий энкодера #define DOUBLEARR 16 // Смешение на массив #define ROWS 4 // Столбцы #define COLS 4 // Строки #include <TM1638lite.h> #include "GyverEncoder.h" #include "MIDIUSB.h" #include <Adafruit_NeoPixel.h> #ifdef __AVR__ #include <avr/power.h> #endif Encoder enc1(CLK, DT, SW, TYPE2); TM1638lite tm(4, 7, 8); byte byteTwo = 0; // Значения громкости deckA byte byteThree = 0; // Значения громкости deckB byte dval = 0; // Текущие значение кнопки byte pval = 0; // Текущие значение потенциометра bool arrEnc[ARRENC] = {true, true, true, true, true, true}; byte deckA[COLS][ROWS] = { //Массив состояния кнопок левой панели {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0} }; byte deckB[COLS][ROWS] = { //Массив состояния кнопок правой панели {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0} }; byte mainDigital[COLS][ROWS] = { //Массив состояния кнопок ценртальной панели {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0} }; byte potPrVal1[COLS][ROWS] = { //Массив состояниея потенциометров 1 {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0} }; byte potPrVal2[COLS][ROWS] = { //Массив состояниея потенциометров 1 {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0} }; byte pitch[2] = {0, 0}; //Чтение питча Adafruit_NeoPixel pixels(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800); void setup() { Serial.begin(115200); #if defined(__AVR_ATtiny85__) && (F_CPU == 16000000) clock_prescale_set(clock_div_1); #endif tm.reset(); pixels.begin(); pixels.setBrightness(64); } void loop() { midiEventPacket_t rx; rx = MidiUSB.read(); enc1.tick(); if (enc1.isTurn()) { // если был совершён поворот (индикатор поворота в любую сторону) if (enc1.isRight() && arrEnc[0]) changeEncoder(0, arrEnc[0]); // Удержание и поворт if (enc1.isLeft() && arrEnc[1]) changeEncoder(1, arrEnc[1]); if (enc1.isRightH() && arrEnc[2]) changeEncoder(2, arrEnc[2]); // Поворот if (enc1.isLeftH() && arrEnc[3]) changeEncoder(3, arrEnc[3]); if (enc1.isSingle() && arrEnc[4]) changeEncoder(4, arrEnc[4]); // Двойной клик if (enc1.isDouble() && arrEnc[5]) changeEncoder(5, arrEnc[5]); // Тройной клик for (byte i = 0; i < ARRENC; i++ )if (!arrEnc[i]) changeEncoder(i, arrEnc[i]); } if (rx.header != 0) { //VuMetr if (rx.byte1 == 191 && rx.byte2 == 0) byteTwo = rx.byte3; if (rx.byte1 == 191 && rx.byte2 == 1) byteThree = rx.byte3; vuMetr(); Serial.print("Received: "); Serial.print(rx.header, HEX); Serial.print("-"); Serial.print(rx.byte1, HEX); Serial.print("-"); Serial.print(rx.byte2, HEX); Serial.print("-"); Serial.println(rx.byte3, HEX); } //Аналоговые значения. Main1 for (byte col = 0; col < COLS; col++) { //-Цикл чтения значений потенциометров Столбцы for (byte row = 0; row < ROWS; row++) { //-Цикл чтения значений потенциометров Строки //pval = analogRead(*Значения с модуля мультиплексера аналоговых значений*) / 8; if (abs(pval - potPrVal1[col][row]) > 10) { //--Если текущее значение отл. от прошлого controlChange(3, 1 * col + row, pval); potPrVal1[col][row] = pval; } } } //Аналоговые значения. Main2 for (byte col = 0; col < COLS; col++) { //-Цикл чтения значений потенциометров Столбцы for (byte row = 0; row < ROWS; row++) { //-Цикл чтения значений потенциометров Строки //pval = analogRead(*Значения с модуля мультиплексера аналоговых значений*) / 8; if (abs(pval - potPrVal2[col][row]) > 10) { //--Если текущее значение отл. от прошлого controlChange(4, DOUBLEARR + 1 * col + row, pval); potPrVal2[col][row] = pval; } } } //Цифровые значения. DeckA for (byte col = 0; col < COLS; col++) { //-Цикл чтения значений кнопок Столбцы for (byte row = 0; row < ROWS; row++) { //-Цикл чтения значений кнопок Строки //dval = *Значения с модуля мультиплексера цифровых значений* if ( dval == HIGH && deckA[col][row] == LOW ) { noteOn(0, 1 * col + row , 64); MidiUSB.flush(); } if ( dval == LOW && deckA[col][row] == HIGH ) { noteOff(0, 1 * col + row, 64); MidiUSB.flush(); } deckA[col][row] = dval; } } //Цифровые значения. DeckB for (byte col = 0; col < COLS; col++) { //-Цикл чтения значений кнопок Столбцы for (byte row = 0; row < ROWS; row++) { //-Цикл чтения значений кнопок Строки //dval = *Значения с модуля мультиплексера цифровых значений* if ( dval == HIGH && deckB[col][row] == LOW ) { noteOn(1, DOUBLEARR + 1 * col + row , 64); MidiUSB.flush(); } if ( dval == LOW && deckB[col][row] == HIGH ) { noteOff(1, DOUBLEARR + 1 * col + row, 64); MidiUSB.flush(); } deckB[col][row] = dval; } } //Цифровые значения. DeckB for (byte col = 0; col < COLS; col++) { //-Цикл чтения значений кнопок Столбцы for (byte row = 0; row < ROWS; row++) { //-Цикл чтения значений кнопок Строки //dval = *Значения с модуля мультиплексера цифровых значений* if ( dval == HIGH && mainDigital[col][row] == LOW ) { noteOn(2, 2 * DOUBLEARR + 1 * col + row , 64); MidiUSB.flush(); } if ( dval == LOW && mainDigital[col][row] == HIGH ) { noteOff(2, 2 * DOUBLEARR + 1 * col + row, 64); MidiUSB.flush(); } mainDigital[col][row] = dval; } } }
[ "roman_gabibullae@mail.ru" ]
roman_gabibullae@mail.ru
f28be2d03da382d7464f610a983f84d6e3f8d966
bf26310b4c2b5010b38eabc1db859b7d2c98aaf4
/tailieu/stack.cpp
6ce82967da7f7ed5839a4a98f78139d955f7c44f
[]
no_license
nhaantran/ctdl
03ed8583a56c8a8a266afb58ff4b76e6e05e212c
7dd34adbea6ff807767cdd9f8fb4310a73841481
refs/heads/master
2023-07-03T00:29:53.042004
2021-08-08T09:04:15
2021-08-08T09:04:15
393,911,277
0
0
null
null
null
null
UTF-8
C++
false
false
846
cpp
#include <iostream> using namespace std; struct node { int info; node *pnext; }; struct List { node *phead; node *ptail; }; void createlist(List &l) { l.phead=l.ptail=NULL; } node *createnode(int info) { node *p=new node; p->info=info; p->pnext=NULL; return p; } void push(node *p, List &l) { if (l.phead == NULL) { l.phead = p; l.ptail = p; } else { p->pnext = l.phead; l.phead = p; } } void pop(List& l) { node *s = l.phead; if (s == l.ptail) { l.ptail = NULL; l.phead = NULL; } else l.phead = l.phead->pnext; delete s; } void print(List l) { node *p=l.phead; while(p!=NULL) { cout<<p->info<<" "; p=p->pnext; } }
[ "20520259@gm.uit.edu.vn" ]
20520259@gm.uit.edu.vn
eaa77ce02591f2e0b52f55b6d4c33ad21c7ed0b9
e51382641be2b0ba5c6dfcb8952ab5bc7ee295bd
/include/Vertex.h
185728036ac4cae329fb6657bcd2107e02d750fb
[]
no_license
dragod812/Straight-Skeleton-Implementation
c55c715800b1b6d0f66634d227a61e54eeeb70b7
52dfc23b8db20e69e6e5f5ff3520ae92e47afccf
refs/heads/master
2020-03-14T09:08:28.438776
2018-04-29T23:53:52
2018-04-29T23:53:52
131,539,229
2
0
null
null
null
null
UTF-8
C++
false
false
551
h
#ifndef VERTEX_H #define VERTEX_H class Vertex; #include "Point.h" #include "CLLNode.h" #include<memory> #include "Ray.h" #include "Edge.h" #include "Direction.h" enum Type { EDGE, SPLIT }; class Vertex{ public: Point<double> coord; Ray* bisector; Edge* inEdge; Edge* outEdge; CLLNode* cllNode; bool processed; Type type; Vertex(double x, double y); Vertex(Point<double> X); Vertex operator - (const Vertex &rhs); double operator * (const Vertex &rhs); Type getType(); void calculateBisector(); }; #endif
[ "sidtastic11@gmail.com" ]
sidtastic11@gmail.com
baca92bd21304160fdebe65fd867dbf076c7ef66
2f6278ca84cef2b2f5b85bf979d65dcbd4fa32a9
/algorithms/scrambleString.cpp
00f32f5ca38cbd7593557a0e7eab11d9f3a57f4a
[ "MIT" ]
permissive
finalspace/leetcode
ffae6d78a8de1ab2f43c40bccc10653e3dec2410
4a8763e0a60f8c887e8567751bd25674ea6e5120
refs/heads/master
2021-06-03T13:39:16.763922
2019-07-26T07:35:03
2019-07-26T07:35:03
40,842,685
0
0
null
null
null
null
UTF-8
C++
false
false
4,151
cpp
// Source : https://leetcode.com/problems/scramble-string/ // Author : Siyuan Xu // Date : 2015-08-14 /********************************************************************************** * * Given a string s1, we may represent it as a binary tree by partitioning it to two non-empty substrings recursively. * * Below is one possible representation of s1 = "great": * * great * / \ * gr eat * / \ / \ * g r e at * / \ * a t * * To scramble the string, we may choose any non-leaf node and swap its two children. * * For example, if we choose the node "gr" and swap its two children, it produces a scrambled string "rgeat". * * rgeat * / \ * rg eat * / \ / \ * r g e at * / \ * a t * * We say that "rgeat" is a scrambled string of "great". * * Similarly, if we continue to swap the children of nodes "eat" and "at", it produces a scrambled string "rgtae". * * rgtae * / \ * rg tae * / \ / \ * r g ta e * / \ * t a * * We say that "rgtae" is a scrambled string of "great". * * Given two strings s1 and s2 of the same length, determine if s2 is a scrambled string of s1. * * **********************************************************************************/ //dfs + pruning //4ms(best) class Solution1 { public: bool helper(string &s1, string &s2, int p1, int p2, int l) { if (l == 1) return s1[p1] == s2[p2]; bool flag = false; int count[26]; fill_n(count, 26, 0); for (int i = 0; i < l; i++) { count[s1[p1 + i] - 'a']++; count[s2[p2 + i] - 'a']--; } for (int i = 0; i < 26; i++) { if (count[i] != 0) return false; } for (int k = 1; k <= l - 1 && !flag; k++) { flag = (helper(s1, s2, p1, p2, k) && helper(s1, s2, p1 + k, p2 + k, l - k)) || (helper(s1, s2, p1, p2 + l - k, k) && helper(s1, s2, p1 + k, p2, l - k)); } return flag; } bool isScramble(string s1, string s2) { if (s1.size() != s2.size()) return false; return helper(s1, s2, 0, 0, s1.size()); } }; //dfs + pruning + caching //8ms(slower than dfs + pruning) class Solution2 { public: bool helper(string &s1, string &s2, int*** cache, int p1, int p2, int l) { if (l == 1) return s1[p1] == s2[p2]; if (cache[p1][p2][l] != -1) return cache[p1][p2][l]; bool flag = false; int count[26]; fill_n(count, 26, 0); for (int i = 0; i < l; i++) { count[s1[p1 + i] - 'a']++; count[s2[p2 + i] - 'a']--; } for (int i = 0; i < 26; i++) { if (count[i] != 0) return false; } for (int k = 1; k <= l - 1 && !flag; k++) { flag = (helper(s1, s2, cache, p1, p2, k) && helper(s1, s2, cache, p1 + k, p2 + k, l - k)) || (helper(s1, s2, cache, p1, p2 + l - k, k) && helper(s1, s2, cache, p1 + k, p2, l - k)); } if (cache[p1][p2][l] == -1) cache[p1][p2][l] = flag ? 1 : 0; return flag; } bool isScramble(string s1, string s2) { if (s1.size() != s2.size()) return false; int n = s1.size(); int*** cache = new int**[n]; for (int i = 0; i < n; i++) { cache[i] = new int*[n]; for (int j = 0; j < n; j++) { cache[i][j] = new int[n + 1]; fill_n(cache[i][j], n + 1, -1); } } for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { cache[i][j][1] = (s1[i] == s2[j]) ? 1 : 0; } } return helper(s1, s2, cache, 0, 0, s1.size()); } }; //3d dp //24ms(slower) class Solution3 { public: bool isScramble(string s1, string s2) { if (s1.size() != s2.size()) return false; int n = s1.size(); bool*** dp = new bool**[n]; for (int i = 0; i < n; i++) { dp[i] = new bool*[n]; for (int j = 0; j < n; j++) { dp[i][j] = new bool[n + 1]; } } for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { dp[i][j][1] = s1[i] == s2[j]; } } for (int l = 2; l <= n; l++) { for (int i = 0; i <= n - l; i++) { for (int j = 0; j <= n - l; j++) { for (int k = 1; k <= l - 1 && !dp[i][j][l]; k++) { dp[i][j][l] = (dp[i][j][k] && dp[i + k][j + k][l - k]) || (dp[i][j + l - k][k] && dp[i + k][j][l - k]); } } } } return dp[0][0][n]; } };
[ "finalspace.1031@gmail.com" ]
finalspace.1031@gmail.com
a6ce341b1c339a679de64b507e70b915cf30ddc7
fdf6a2c879bf56bfa684cb82cbc09d28de5a30ce
/simplealignment.h
86aed7fdc3f9a08154fd87fd696425e2e032f5a7
[]
no_license
rickbassham/indi-celestron-cgx
2820cb230c0535cb3cc014a5f09f276c28bd5d23
1878fbd8ac8b638c596bc6df5cfeb61f4aa0f5a7
refs/heads/main
2023-02-26T09:27:43.434670
2021-02-03T22:04:20
2021-02-03T22:04:20
318,504,488
5
2
null
2021-01-02T21:39:52
2020-12-04T12:06:24
C++
UTF-8
C++
false
false
1,622
h
#pragma once #include <stdint.h> /* Simple class to map steps on a motor to RA/Dec and back on an EQ mount. Call UpdateSteps before using RADecFromEncoderValues. Or call EncoderValuesFromRADec to get the steps for a given RA/Dec. */ class EQAlignment { public: enum TelescopePierSide { PIER_UNKNOWN = -1, PIER_WEST = 0, PIER_EAST = 1 }; EQAlignment(uint32_t stepsPerRevolution); void UpdateSteps(uint32_t ra, uint32_t dec); void UpdateStepsRA(uint32_t steps); void UpdateStepsDec(uint32_t steps); void UpdateLongitude(double lng); void EncoderValuesFromRADec(double ra, double dec, uint32_t &raSteps, uint32_t &decSteps, TelescopePierSide &pierSide); void RADecFromEncoderValues(double &ra, double &dec, TelescopePierSide &pierSide); double hourAngleFromEncoder(); uint32_t encoderFromHourAngle(double hourAngle); void decAndPierSideFromEncoder(double &dec, TelescopePierSide &pierSide); uint32_t encoderFromDecAndPierSide(double dec, TelescopePierSide pierSide); double localSiderealTime(); TelescopePierSide expectedPierSide(double ra); uint32_t GetStepsAtHomePositionDec() { return m_stepsAtHomePositionDec; } uint32_t GetStepsAtHomePositionRA() { return m_stepsAtHomePositionRA; } private: uint32_t m_stepsPerRevolution; uint32_t m_stepsAtHomePositionDec; uint32_t m_stepsAtHomePositionRA; double m_stepsPerDegree; double m_stepsPerHour; uint32_t m_raSteps; uint32_t m_decSteps; double m_longitude; };
[ "brodrick.bassham@gmail.com" ]
brodrick.bassham@gmail.com
6465726d9bcd0d53683cc5d3e1442ed3631db2ab
0ea91e94e0f4ce02ffb5afc1af806f660cf6131e
/Fourth/class.cpp
66c40c6f2df3ba47a992a9d169ae0b15b455c37d
[]
no_license
Syxxx/Coursework
f8399654f2cc72799d9f549c148276b4392ab4b1
40840de6fe282bf5ae59dcb4d446f027c81f9041
refs/heads/master
2021-01-20T03:06:32.670448
2017-06-12T06:08:56
2017-06-12T06:08:56
89,145,567
0
0
null
null
null
null
GB18030
C++
false
false
1,845
cpp
#include <iostream> #include "Arithmetic_H.h" using namespace std; void UserInteraction::printNumber() { switch (language) { case 1:cout << "请输入题数:"; break; case 2:cout << "Please enter a number of questions:"; break; defaul:cout << "Error!"; break; } } UserInteraction::UserInteraction() { } UserInteraction::~UserInteraction() { } void UserInteraction::getNumber(int nums) { n = nums; } void UserInteraction::chooseLanguage() { cout << "请选择语言(Please choose language)" << endl; cout << "1.中文 2.English : "; } void UserInteraction::getLaguage(int lan) { language = lan; } Expression::Expression() { } Expression::~Expression() { } void Expression::randomNumber() { digit = rand() % 3 + 4; //数字的个数 for (int i = 0; i<digit; i++) { nums[i] = rand() % 9 + 1; // 数字 } } void Expression::randomOperation() { char c[] = "+-*/"; for (int i = 0; i<digit; i++) { signs[i] = c[rand() % 4]; //符号 } signs[digit - 1] = '='; } void Expression::generateExpression() { bracketNum = rand() % 2; //括号个数 if (bracketNum == 1) { flag = 0; temp = 0; braO = rand() % ((digit - 1) / 2) + 1; braT = braO + rand() % ((digit - 1) / 2) + 2; //分别在第几个数加括号 //braO+1是第一个括号的位置,braT是第二个括号的位置 } if (bracketNum == 0) { for (int i = 0; i<digit; i++) { if (signs[i] == '/') cout << nums[i] << "÷"; else cout << nums[i] << signs[i]; } // cout<<result; } else if (bracketNum == 1) { for (int i = 0; i<digit; i++) //测试算式 { if (i == braO) cout << "("; cout << nums[i]; if (i == braT - 1) cout << ")"; if (signs[i] == '/') cout << "÷"; else cout << signs[i]; } // cout<<result; } } Answer::Answer() { } Answer::~Answer() { }
[ "303241829@qq.com" ]
303241829@qq.com
2a9e34f4b80718544072cd3628aa865b2fc2444d
cfeac52f970e8901871bd02d9acb7de66b9fb6b4
/generated/src/aws-cpp-sdk-cloudtrail/source/model/ListImportFailuresRequest.cpp
ade8ef608d1c86bd1bd4cc70982c26793f66a1d9
[ "Apache-2.0", "MIT", "JSON" ]
permissive
aws/aws-sdk-cpp
aff116ddf9ca2b41e45c47dba1c2b7754935c585
9a7606a6c98e13c759032c2e920c7c64a6a35264
refs/heads/main
2023-08-25T11:16:55.982089
2023-08-24T18:14:53
2023-08-24T18:14:53
35,440,404
1,681
1,133
Apache-2.0
2023-09-12T15:59:33
2015-05-11T17:57:32
null
UTF-8
C++
false
false
1,237
cpp
/** * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0. */ #include <aws/cloudtrail/model/ListImportFailuresRequest.h> #include <aws/core/utils/json/JsonSerializer.h> #include <utility> using namespace Aws::CloudTrail::Model; using namespace Aws::Utils::Json; using namespace Aws::Utils; ListImportFailuresRequest::ListImportFailuresRequest() : m_importIdHasBeenSet(false), m_maxResults(0), m_maxResultsHasBeenSet(false), m_nextTokenHasBeenSet(false) { } Aws::String ListImportFailuresRequest::SerializePayload() const { JsonValue payload; if(m_importIdHasBeenSet) { payload.WithString("ImportId", m_importId); } if(m_maxResultsHasBeenSet) { payload.WithInteger("MaxResults", m_maxResults); } if(m_nextTokenHasBeenSet) { payload.WithString("NextToken", m_nextToken); } return payload.View().WriteReadable(); } Aws::Http::HeaderValueCollection ListImportFailuresRequest::GetRequestSpecificHeaders() const { Aws::Http::HeaderValueCollection headers; headers.insert(Aws::Http::HeaderValuePair("X-Amz-Target", "com.amazonaws.cloudtrail.v20131101.CloudTrail_20131101.ListImportFailures")); return headers; }
[ "sdavtaker@users.noreply.github.com" ]
sdavtaker@users.noreply.github.com
c63707a0834964c3e154bedfc5914cc05a594069
2277375bd4a554d23da334dddd091a36138f5cae
/ThirdParty/CUDA/include/thrust/system/detail/generic/reduce_by_key.h
e8e182aa99c61dfc682eaf52cc2c91a69ad9fbf7
[]
no_license
kevinmore/Project-Nebula
9a0553ccf8bdc1b4bb5e2588fc94516d9e3532bc
f6d284d4879ae1ea1bd30c5775ef8733cfafa71d
refs/heads/master
2022-10-22T03:55:42.596618
2020-06-19T09:07:07
2020-06-19T09:07:07
25,372,691
6
5
null
null
null
null
UTF-8
C++
false
false
2,803
h
/* * Copyright 2008-2013 NVIDIA Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #pragma once #include <thrust/detail/config.h> #include <thrust/system/detail/generic/tag.h> #include <thrust/iterator/iterator_traits.h> namespace thrust { namespace system { namespace detail { namespace generic { template<typename DerivedPolicy, typename InputIterator1, typename InputIterator2, typename OutputIterator1, typename OutputIterator2> thrust::pair<OutputIterator1,OutputIterator2> reduce_by_key(thrust::execution_policy<DerivedPolicy> &exec, InputIterator1 keys_first, InputIterator1 keys_last, InputIterator2 values_first, OutputIterator1 keys_output, OutputIterator2 values_output); template<typename DerivedPolicy, typename InputIterator1, typename InputIterator2, typename OutputIterator1, typename OutputIterator2, typename BinaryPredicate> thrust::pair<OutputIterator1,OutputIterator2> reduce_by_key(thrust::execution_policy<DerivedPolicy> &exec, InputIterator1 keys_first, InputIterator1 keys_last, InputIterator2 values_first, OutputIterator1 keys_output, OutputIterator2 values_output, BinaryPredicate binary_pred); template<typename DerivedPolicy, typename InputIterator1, typename InputIterator2, typename OutputIterator1, typename OutputIterator2, typename BinaryPredicate, typename BinaryFunction> thrust::pair<OutputIterator1,OutputIterator2> reduce_by_key(thrust::execution_policy<DerivedPolicy> &exec, InputIterator1 keys_first, InputIterator1 keys_last, InputIterator2 values_first, OutputIterator1 keys_output, OutputIterator2 values_output, BinaryPredicate binary_pred, BinaryFunction binary_op); } // end namespace generic } // end namespace detail } // end namespace system } // end namespace thrust #include <thrust/system/detail/generic/reduce_by_key.inl>
[ "dingfengyu@gmail.com" ]
dingfengyu@gmail.com
fd1ab0aef283e9c3eb3170325bd53a5cb79579a8
4a28104787a4ce3bf362fda9182e4f1fe6276c30
/implementations/1348A.cpp
e08a5ef3d986b9c2647e84ec6c4348038ec5c4ba
[]
no_license
Ason4901/geeksforgeeks
d0538a22db00c86e97ec8b9f6c548ebd1ecef8ce
777aa4c0752bb0a9b942922e1ad99095a161cc6b
refs/heads/master
2023-02-24T07:51:15.469015
2021-01-30T15:36:20
2021-01-30T15:36:20
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,056
cpp
#include <bits/stdc++.h> #include <cstdio> #include <cstring> #include <cmath> #include <cstring> #include <chrono> #include <complex> #define endl "\n" #define ll long long int #define vi vector<int> #define vll vector<ll> #define vvi vector < vi > #define pii pair<int,int> #define pll pair<long long, long long> #define mod 1000000007 #define inf 1000000000000000001; #define all(c) c.begin(),c.end() #define mp(x,y) make_pair(x,y) #define mem(a,val) memset(a,val,sizeof(a)) #define eb emplace_back #define f first #define s second using namespace std; int main() { std::ios::sync_with_stdio(false); int T; cin>>T; ll po[31] = {0}; po[0] =1; for (int i = 1; i <= 30; ++i) { po[i] = 2*po[i-1]; } // cin.ignore(); must be there when using getline(cin, s) while(T--) { ll n; cin>>n; ll sum1 = po[n]; for (int i = 1; i < n/2; ++i) { sum1+= po[i]; } ll sum2 = 0ll; for (int i = n/2; i < n; ++i) { sum2 += po[i]; } cout<<abs(sum2 -sum1)<<endl; } return 0; }
[ "51023991+abhinavprkash@users.noreply.github.com" ]
51023991+abhinavprkash@users.noreply.github.com
1eb5ec136545e8c7e67712b9e62b8e415f495146
cf27788f1c1e5b732c073d99b2db0f61bb16b083
/test.cc
037b0665d2e68e557291094699a87b8f75c1f1ba
[]
no_license
mjorgen1/LinearRegressionMLE
1958db24771c01f368650a14a1be830ff85f81b2
2a79c35595b378227cdfc91d67732814ade69847
refs/heads/master
2021-06-20T04:52:27.452594
2017-06-28T19:31:08
2017-06-28T19:31:08
null
0
0
null
null
null
null
UTF-8
C++
false
false
3,457
cc
#include <iostream> #include <fstream> #include <string> #include <sstream> #include <vector> #include <cmath> #include "Eigen/Dense" using namespace std; using namespace Eigen; MatrixXd fromFile(const string &input_file_path) { // Reads in the file from "input_file_path" ifstream input_file(input_file_path, ifstream::in); MatrixXd m; string line; vector<float> temp_buffer; float coef; int num_cols = 0; int num_rows = 0; int cols_in_row; if (input_file) { // Iterates over every line in the input file while (!input_file.eof()) { getline(input_file, line); if (line.find_first_not_of(' ') == std::string::npos) continue; replace(line.begin(), line.end(), ',', ' '); // Creates a stringstream out of every line in the file stringstream stream(line); cols_in_row = 0; // Reads every coefficient in the stringstream into the temporary buffer while (stream >> coef) { temp_buffer.push_back(coef); ++cols_in_row; } // If the number of columns in the matrix hasn't been set, make it the // current number of columns in the row if (num_cols == 0) { num_cols = cols_in_row; // If the matrix in the file is shaped incorrectly, throw an error } else if (num_cols != cols_in_row) { cerr << "Problem with Matrix in: " + input_file_path + ", exiting..." << endl; exit(1); } ++num_rows; } // Instantiate the matrix's size and feed it the coefficients in the // temporary buffer m.resize(num_rows, num_cols); for (int i = 0; i < num_rows; ++i) for (int j = 0; j < num_cols; ++j) m(i, j) = temp_buffer[i * num_cols + j]; return m; } else { // Error for when the file doesn't exist cerr << "Cannot open file " + input_file_path + ", exiting..."<< endl; exit(1); } } VectorXd fromFile(const string &input_file_path, int num_elements) { ifstream input_file(input_file_path, ifstream::in); VectorXd m(num_elements); if (input_file) { for(int i = 0; i < num_elements; i++) input_file >> m(i); return m; } else { cerr << "Cannot open file " + input_file_path + ", exiting..." <<endl; exit(1); } } //gives the sum of squared error for two vectors float SSE(VectorXd b, VectorXd bTest, int bRows) //do i need to put in the location? { float sseNum = 0; for(int i = 0; i < 20; i++) { sseNum = sseNum + pow((b(i) - bTest(i)), 2.0); } return sseNum; } int main(){ //defines the matrices and vectors VectorXd b; MatrixXd x (1000,100); x = fromFile("/home/mackenzie/practiceCode/X-12321.csv"); VectorXd y (1000); y = fromFile("/home/mackenzie/practiceCode/y-26465.csv", 1000); VectorXd bTest(100); bTest = fromFile("/home/mackenzie/practiceCode/beta-12566.csv", 100); /*prints the matrix and vector thus far cout << "The matrix is " << x << endl; cout << "The vector is " << endl << y << endl;*/ //the formula MatrixXd xTransposed = x.transpose(); MatrixXd bPart1 = xTransposed*x; MatrixXd bPart1Inv = bPart1.inverse(); VectorXd bPart2 = xTransposed*y; b = bPart1Inv*bPart2; int bRows = b.size(); //cout << "The MLE estimator is " << endl <<b << endl; prints the b values we got float sum_of_squares = SSE(b, bTest, bRows); cout << "The sum of squared error is " << sum_of_squares << endl; }
[ "mjorgen1@villanova.edu" ]
mjorgen1@villanova.edu
4776dcc3397d6a31edce20e052df04eaae95f1a6
1aa38513e62d081e7c3733aad9fe1487f22d7a73
/compat/shm.h
61efaf6880a2d0288b65f68930f990cba6822c96
[ "ISC", "LicenseRef-scancode-warranty-disclaimer" ]
permissive
cpuwolf/opentrack
c3eae3700a585193b67187c6619bf32e1dedd1aa
5541cfc68d87c2fc254eb2f2a5aad79831871a88
refs/heads/unstable
2021-06-05T14:18:24.851128
2017-11-02T13:10:54
2017-11-02T13:10:54
83,854,103
1
0
null
2017-03-04T00:44:16
2017-03-04T00:44:15
null
UTF-8
C++
false
false
884
h
/* Copyright (c) 2013 Stanislaw Halik <sthalik@misaki.pl> * 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. */ #pragma once #if defined(_WIN32) #include <windows.h> #else #include <stdio.h> #include <string.h> #include <sys/file.h> #include <sys/mman.h> #include <fcntl.h> #include <limits.h> #include <unistd.h> #include <sys/types.h> #endif #include "export.hpp" class OTR_COMPAT_EXPORT shm_wrapper final { void* mem; #if defined(_WIN32) HANDLE mutex, mapped_file; #else int fd, size; #endif public: shm_wrapper(const char *shm_name, const char *mutex_name, int map_size); ~shm_wrapper(); bool lock(); bool unlock(); bool success(); inline void* ptr() { return mem; } };
[ "sthalik@misaki.pl" ]
sthalik@misaki.pl
c6b00d9b7b67737b7ddab6c33da4683b6d498b2d
8f2a6d9e1fbd84f2956ee0b34f5ca488558c9ab9
/reports/jscope_hugefile/write_huge.cpp
3240a1f71333476a6b6cd0bc3e8b97f8e57f4419
[]
no_license
MDSplus/MDSip-tests
51275346aaca15da76212a98c093e4e0a2b45ba2
11721c8c0d0415608d93a2501ea74ad5d1e95189
refs/heads/master
2020-12-21T23:17:58.618124
2017-05-26T12:49:52
2017-05-26T12:49:52
29,479,981
0
0
null
2017-05-26T08:37:11
2015-01-19T16:28:54
C++
UTF-8
C++
false
false
1,759
cpp
#include <mdsobjects.h> #include <stdio.h> #include <time.h> #include <math.h> #include <sys/time.h> #include<math.h> #define SEGMENT_SAMPLES 500000 #define NUM_SEGMENTS 1000 int main(int argc, char *argv[]) { int loopCount = 0; struct timespec waitTime; struct timeval currTime; waitTime.tv_sec = 0; waitTime.tv_nsec = 500000000; try { MDSplus::Tree *tree = new MDSplus::Tree("huge", -1, "NEW"); MDSplus::TreeNode *node = tree->addNode("HUGE_0", "SIGNAL"); MDSplus::TreeNode *node1 = tree->addNode("HUGE_0_RES", "SIGNAL"); delete node; delete node1; tree->write(); delete tree; tree = new MDSplus::Tree("huge", -1); tree->createPulse(1); delete tree; tree = new MDSplus::Tree("huge", 1); node = tree->getNode("HUGE_0"); node1 = tree->getNode("HUGE_0_RES"); float *values = new float[SEGMENT_SAMPLES]; double currTime = 0; double startTime, endTime; double deltaTime = 1; for(int i = 0; i < NUM_SEGMENTS; i++) { std::cout << "Writing Segment " << i << std::endl; startTime = currTime; for(int j = 0; j < SEGMENT_SAMPLES; j++) { values[j] = sin(currTime/1000.); currTime++; } endTime = currTime; MDSplus::Data *startData = new MDSplus::Float64(startTime); MDSplus::Data *endData = new MDSplus::Float64(endTime); MDSplus::Data *deltaData = new MDSplus::Float64(deltaTime); MDSplus::Data *dimData = new MDSplus::Range(startData, endData, deltaData); MDSplus::Array *valsData = new MDSplus::Float32Array(values, SEGMENT_SAMPLES); node->makeSegmentMinMax(startData, endData, dimData, valsData, node1); deleteData(dimData); deleteData(valsData); } } catch(MDSplus::MdsException &exc) { std::cout << exc.what() << std::endl; } return 0; }
[ "andrea.rigoni@pd.infn.it" ]
andrea.rigoni@pd.infn.it
803bcb47eeff7d8871d343a44751b277134adad6
528f3cc7cadbf30ccce8286ee04e375e03cb3a15
/smskinedit/implementation/control/impl/EditorControl.cpp
4866a689cb23bca0c26d8fd999daef909977c935
[ "MIT" ]
permissive
CorneliaXaos/SMSkinEdit
b59f26aade2ead8d4f10dc1ef884ea7cc96d0bed
119766d3cb4f0ac1f43ee4e102ed0f8939aea87b
refs/heads/master
2021-01-18T16:40:24.829422
2017-04-18T10:29:53
2017-04-18T10:29:53
86,755,611
0
0
null
null
null
null
UTF-8
C++
false
false
408
cpp
#include "control/impl/EditorControl.h" namespace smskinedit { namespace control { void EditorControl::setUseInternalEditor(bool useInternalEditor) { _useInternalEditor = useInternalEditor; onControlUpdated(EditorControl::INTERNAL_EDITOR); } bool EditorControl::shouldUseInternalEditor() const { return _useInternalEditor; } } }
[ "cornelia.xaos@gmail.com" ]
cornelia.xaos@gmail.com
e107dbe5f8cc956665c2c4572712dd1a16bd65af
2ff6e1f31cc46bb5d3b3dbb9f7bcf0a61da252ab
/tetris2/tetris2.ino
e6c9092abaa29fd5b400ea0451c9490e161efecf
[]
no_license
ondras/arduino
c0fc37e373935c30ec1b61f5043ae32e1dc951e4
f41fa693c317a1794f2784dc3f7442ae28eee6ed
refs/heads/master
2023-08-25T23:29:01.565826
2020-08-22T10:54:29
2020-08-22T10:54:29
19,730,254
3
2
null
null
null
null
UTF-8
C++
false
false
1,675
ino
#include <tetris.h> #include "output-rgbmatrix.h" #ifdef BENCH #include <stdio.h> #include <limits.h> #define MAX_GAMES 100 Output output; int total_score = 0; int min_score = INT_MAX; int max_score = 0; int games = 0; #elif TERM OutputTerminal output; #else OutputRGBMatrix output; #endif //Weights weights { .holes = 20, .max_depth = 2, .cells = 1, .max_slope = 1, .slope = 1, .weighted_cells = 1 }; //Weights weights { .holes = 11.8, .max_depth = 0.1, .cells = -1.1, .max_slope = 0.6, .slope = 2.2, .weighted_cells = 0.6 }; //Game game(&output, weights); Game game(output); void setup() { // randomSeed(analogRead(A0) * analogRead(A1) * analogRead(A2)); #ifdef BENCH srandom(games); #endif game.start(); } void loop() { game.step(); if (game.playing) { #ifndef BENCH delay(100); #endif } else { #ifdef BENCH games++; total_score += game.score; min_score = min(min_score, game.score); max_score = max(max_score, game.score); #else delay(1000); #endif #ifdef BENCH if (games > MAX_GAMES) { printf("total: %i, min: %i, max: %i\n", total_score, min_score, max_score); // printf("%i\n", total_score); exit(0); } else { setup(); } #else setup(); #endif } } #if defined(BENCH) || defined(TERM) int main(int argc, char** argv) { #ifdef BENCH if (argc < 7) { printf("USAGE: %s holes max_depth cells max_slope slope weighted_cells\n", argv[0]); exit(1); } weights.holes = atof(argv[1]); weights.max_depth = atof(argv[2]); weights.cells = atof(argv[3]); weights.max_slope = atof(argv[4]); weights.slope = atof(argv[5]); weights.weighted_cells = atof(argv[6]); #endif setup(); while (true) { loop(); } } #endif
[ "ondrej.zara@gmail.com" ]
ondrej.zara@gmail.com
e4b1d126bdfa72583dbdff7118343bf1c0875958
44b79f3468fc295e856e8cadd42441c7f05dd1e7
/module06-study-stl/city.cpp
892c44d1104d818fe54bd6ea1a4e2ebf34296479
[ "MIT" ]
permissive
deepcloudlabs/dcl118-2020-sep-21
e000a2e83692a08dd7064af9b9df8aea8c0377f4
900a601f8c9a631a342ad8ce131ad08825d00466
refs/heads/master
2022-12-25T14:36:20.319743
2020-09-23T14:56:50
2020-09-23T14:56:50
297,109,828
5
1
null
null
null
null
UTF-8
C++
false
false
574
cpp
#include "city.h" namespace world { city::city(int id, const std::string &name, const std::string &country_code, int population) { this->id = id; this->name = name; this->population = population; this->country_code = country_code; } }; std::ostream &operator<<(std::ostream &out, const world::city &_city) { out << "city [ id=" << _city.id << ", name=" << _city.name << ", " << *(_city.belongs_to) << ", population=" << _city.population << " ]"; return out; }
[ "deepcloudlabs@gmail.com" ]
deepcloudlabs@gmail.com