blob_id
stringlengths
40
40
directory_id
stringlengths
40
40
path
stringlengths
4
201
content_id
stringlengths
40
40
detected_licenses
listlengths
0
85
license_type
stringclasses
2 values
repo_name
stringlengths
7
100
snapshot_id
stringlengths
40
40
revision_id
stringlengths
40
40
branch_name
stringclasses
260 values
visit_date
timestamp[us]
revision_date
timestamp[us]
committer_date
timestamp[us]
github_id
int64
11.4k
681M
star_events_count
int64
0
209k
fork_events_count
int64
0
110k
gha_license_id
stringclasses
17 values
gha_event_created_at
timestamp[us]
gha_created_at
timestamp[us]
gha_language
stringclasses
80 values
src_encoding
stringclasses
28 values
language
stringclasses
1 value
is_vendor
bool
1 class
is_generated
bool
2 classes
length_bytes
int64
8
9.86M
extension
stringclasses
52 values
content
stringlengths
8
9.86M
authors
listlengths
1
1
author
stringlengths
0
119
98a7656f2698d442cf309cd18cc60dfdb15947c3
e76ea38dbe5774fccaf14e1a0090d9275cdaee08
/src/ui/message_center/views/message_center_focus_border.h
de49bae0e2d63c12270d8f8abad27d370e32f6c4
[ "BSD-3-Clause" ]
permissive
eurogiciel-oss/Tizen_Crosswalk
efc424807a5434df1d5c9e8ed51364974643707d
a68aed6e29bd157c95564e7af2e3a26191813e51
refs/heads/master
2021-01-18T19:19:04.527505
2014-02-06T13:43:21
2014-02-06T13:43:21
16,070,101
1
3
null
null
null
null
UTF-8
C++
false
false
913
h
// Copyright 2013 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef UI_MESSAGE_CENTER_VIEWS_MESSAGE_CENTER_FOCUS_BORDER_H_ #define UI_MESSAGE_CENTER_VIEWS_MESSAGE_CENTER_FOCUS_BORDER_H_ #include "ui/views/focus_border.h" #include "ui/views/view.h" namespace message_center { // Focus border class that draws a 1px blue border inset more on the bottom than // on the sides. class MessageCenterFocusBorder : public views::FocusBorder { public: MessageCenterFocusBorder(); virtual ~MessageCenterFocusBorder(); private: // views::FocusBorder overrides: virtual void Paint(const views::View& view, gfx::Canvas* canvas) const OVERRIDE; DISALLOW_COPY_AND_ASSIGN(MessageCenterFocusBorder); }; } // namespace message_center #endif // UI_MESSAGE_CENTER_VIEWS_MESSAGE_CENTER_FOCUS_BORDER_H_
41f234d6a1c85e7c92b2f98a2d747f85cd2337df
5505de1ead33f2df87022d588ba22423b9586989
/src/libtsduck/dtv/descriptors/tsFlexMuxTimingDescriptor.cpp
471243f8b7e255e5de3d721acb0e624afa605be0
[ "BSD-2-Clause" ]
permissive
TUISTERa/tsduck
c7fce59b391b0e264f93d67d54e375ab1b9e5985
cf043719344c00d5af79fb4c638972700fb20362
refs/heads/master
2022-05-29T04:22:32.865233
2020-05-01T22:31:20
2020-05-01T22:31:20
null
0
0
null
null
null
null
UTF-8
C++
false
false
6,051
cpp
//---------------------------------------------------------------------------- // // TSDuck - The MPEG Transport Stream Toolkit // Copyright (c) 2005-2020, Thierry Lelegard // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are met: // // 1. Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // 2. Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // // 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 "tsFlexMuxTimingDescriptor.h" #include "tsDescriptor.h" #include "tsTablesDisplay.h" #include "tsTablesFactory.h" #include "tsxmlElement.h" TSDUCK_SOURCE; #define MY_XML_NAME u"flexmux_timing_descriptor" #define MY_DID ts::DID_FLEX_MUX_TIMING #define MY_STD ts::STD_MPEG TS_XML_DESCRIPTOR_FACTORY(ts::FlexMuxTimingDescriptor, MY_XML_NAME); TS_ID_DESCRIPTOR_FACTORY(ts::FlexMuxTimingDescriptor, ts::EDID::Standard(MY_DID)); TS_FACTORY_REGISTER(ts::FlexMuxTimingDescriptor::DisplayDescriptor, ts::EDID::Standard(MY_DID)); //---------------------------------------------------------------------------- // Constructors //---------------------------------------------------------------------------- ts::FlexMuxTimingDescriptor::FlexMuxTimingDescriptor() : AbstractDescriptor(MY_DID, MY_XML_NAME, MY_STD, 0), FCR_ES_ID(0), FCRResolution(0), FCRLength(0), FmxRateLength(0) { _is_valid = true; } ts::FlexMuxTimingDescriptor::FlexMuxTimingDescriptor(DuckContext& duck, const Descriptor& desc) : FlexMuxTimingDescriptor() { deserialize(duck, desc); } //---------------------------------------------------------------------------- // Serialization //---------------------------------------------------------------------------- void ts::FlexMuxTimingDescriptor::serialize(DuckContext& duck, Descriptor& desc) const { ByteBlockPtr bbp(serializeStart()); bbp->appendUInt16(FCR_ES_ID); bbp->appendUInt32(FCRResolution); bbp->appendUInt8(FCRLength); bbp->appendUInt8(FmxRateLength); serializeEnd(desc, bbp); } //---------------------------------------------------------------------------- // Deserialization //---------------------------------------------------------------------------- void ts::FlexMuxTimingDescriptor::deserialize(DuckContext& duck, const Descriptor& desc) { const uint8_t* data = desc.payload(); size_t size = desc.payloadSize(); _is_valid = desc.isValid() && desc.tag() == _tag && size == 8; if (_is_valid) { FCR_ES_ID = GetUInt16(data); FCRResolution = GetUInt32(data + 2); FCRLength = GetUInt8(data + 6); FmxRateLength = GetUInt8(data + 7); } } //---------------------------------------------------------------------------- // Static method to display a descriptor. //---------------------------------------------------------------------------- void ts::FlexMuxTimingDescriptor::DisplayDescriptor(TablesDisplay& display, DID did, const uint8_t* data, size_t size, int indent, TID tid, PDS pds) { DuckContext& duck(display.duck()); std::ostream& strm(duck.out()); const std::string margin(indent, ' '); if (size >= 8) { const uint16_t id = GetUInt16(data); const uint32_t res = GetUInt32(data + 2); const uint8_t len = GetUInt8(data + 6); const uint8_t fmx = GetUInt8(data + 7); data += 8; size -= 8; strm << margin << UString::Format(u"FCR ES ID: 0x%X (%d)", {id, id}) << std::endl << margin << UString::Format(u"FCR resolution: %'d cycles/second", {res}) << std::endl << margin << UString::Format(u"FCR length: %'d", {len}) << std::endl << margin << UString::Format(u"FMX rate length: %d", {fmx}) << std::endl; } display.displayExtraData(data, size, indent); } //---------------------------------------------------------------------------- // XML serialization //---------------------------------------------------------------------------- void ts::FlexMuxTimingDescriptor::buildXML(DuckContext& duck, xml::Element* root) const { root->setIntAttribute(u"FCR_ES_ID", FCR_ES_ID, true); root->setIntAttribute(u"FCRResolution", FCRResolution); root->setIntAttribute(u"FCRLength", FCRLength); root->setIntAttribute(u"FmxRateLength", FmxRateLength); } //---------------------------------------------------------------------------- // XML deserialization //---------------------------------------------------------------------------- void ts::FlexMuxTimingDescriptor::fromXML(DuckContext& duck, const xml::Element* element) { _is_valid = checkXMLName(element) && element->getIntAttribute<uint16_t>(FCR_ES_ID, u"FCR_ES_ID", true) && element->getIntAttribute<uint32_t>(FCRResolution, u"FCRResolution", true) && element->getIntAttribute<uint8_t>(FCRLength, u"FCRLength", true) && element->getIntAttribute<uint8_t>(FmxRateLength, u"FmxRateLength", true); }
768a11c5391e25c99d41c5216286193b6a12df98
dd4a1d4ab74076c19e20a7620995b2b5baa00d48
/silbot3_src/silbot3_common_tools/src/robocare/exception/NumberFormatException.h
9ae48a81498fe3e4c037099c8996d80b40acbf4a
[]
no_license
AnastasiyaRybakova/simulation_sb3_navi
27289b0ee675de4223eb7d78b0d4f2e10eab94b5
19e1e6eaa97698b7103d68d2418663f03159a64b
refs/heads/master
2020-03-21T07:22:39.107573
2018-06-22T08:31:01
2018-06-22T08:31:01
138,276,737
0
0
null
null
null
null
UTF-8
C++
false
false
543
h
/* * NumberFormatException.h * * Created on: Aug 9, 2013 * Author: ijpark */ #ifndef __ROSCIR_EXCEPTION_NUMBERFORMATEXCEPTION_H_ #define __ROSCIR_EXCEPTION_NUMBERFORMATEXCEPTION_H_ #include "Exception.h" #include <robocare/device/CirApi.h> namespace roscir { namespace exception { class CIRAPI NumberFormatException : public Exception { public: NumberFormatException(); virtual ~NumberFormatException() throw(); }; } /* namespace exception */ } /* namespace roscir */ #endif /* __ROSCIR_EXCEPTION_NUMBERFORMATEXCEPTION_H_ */
821082765ce391b4d45e9f7d7a26ef2bf1c1d7d8
a87a798fd54b8c75d298a581b7e9a04bfea03e95
/extra/mainB.cpp
064ccb3ebb86adbb9c17295a574fac4eb428744d
[]
no_license
igoswamik/cpp
dd3468b1d305453285c5d6979534126de527839e
035336462c800059065421c0a6daf3fbc92249da
refs/heads/main
2023-07-11T19:34:41.853207
2021-08-20T06:29:25
2021-08-20T06:29:25
338,746,040
0
0
null
null
null
null
UTF-8
C++
false
false
1,221
cpp
/****************************************************************************** Online C++ Compiler. Code, Compile, Run and Debug C++ program online. Write your code in this editor and press "Run" button to compile and execute it. *******************************************************************************/ #include <iostream> using namespace std; typedef long long ll; int main() { // ll t; // cin>>t; // while(t--) // { ll n; cin>>n; ll arr[n]; ll temp[n]; for(int i=0;i<n;i++) { cin>>arr[i]; } ll count=0; for(ll i=0;i<n;i++) { for(ll j=i+1;j<n;j++) { ll x=arr[i]&arr[j]; ll y=arr[i]^arr[j]; if(x>=y)count++; } } cout<<count<<endl; /* ll total=_mergeSort(arr,temp,0,n-1); ll allowed=((n*(n-1))/2)-1; //cout<<total<<" "<<allowed<<endl; if(total<=allowed) { cout<<"YES"<<endl; } else { cout<<"NO"<<endl; } */ // } return 0; }
ea15dadc5a2ca3486a4b011b1ffe82ad115e5619
9c5573e7c75cda9e79e84765e34f6b498088c1a3
/DX11_Engine/include/util/ErrorLogger.h
2e82af3c371fa78c6e6ff47669620516d18728f8
[]
no_license
intrepid249/DX11_Engine
cff6ee919cd9cc244012bc8e41196c248126f23e
57489977345324e618e1839fdffb4e3fd2cb9fc1
refs/heads/master
2020-05-24T06:34:10.137132
2019-05-28T22:28:53
2019-05-28T22:28:53
187,140,403
1
0
null
null
null
null
UTF-8
C++
false
false
205
h
#pragma once #include <string> typedef long HRESULT; namespace TrepiCoder { class ErrorLogger { public: static void Log(std::string message); static void Log(HRESULT hr, std::string message); }; }
73623ba9ffd5a8e23f4a21a1be59c0cec1b807a6
b8f1f7c061182da37e634a9d8eadc917d9a396a5
/Sorted-old.cc
56542cf9b24c9a001934a69560aa1152475fd7ce
[]
no_license
UFLAcademicProjects/DatabaseImplementation
1c55a268958e7f7522778c1fc95d31e8fdb7c5ce
cf1271f2be706f958bb8e89fcebb520d42c116c2
refs/heads/master
2016-09-05T11:25:53.525842
2014-09-29T16:50:09
2014-09-29T16:50:09
24,603,686
1
0
null
null
null
null
UTF-8
C++
false
false
10,144
cc
#include "TwoWayList.h" #include "Record.h" #include "Schema.h" #include "File.h" #include "Comparison.h" #include "ComparisonEngine.h" #include "DBFile.h" #include "Defs.h" #include "Sorted.h" #include <iostream> #include <fstream> //Just a simple copy of Heap.cc. //Need to change the datastructure using namespace std; Sorted::Sorted () { } Sorted::~Sorted(){ } //Create Done int Sorted::Create (char *f_path, void *startup) { cout<<"Sorted:Saving Metadata"<<endl; //Save metadata file path name metadataFile=f_path; sortInfo=(SortInfo*)startup; this->file.Open(0, f_path); if(this->file.GetFileStatus()<0) return 0; this->isPageDirty=false; this->currentPageNumber=1; WriteMetadata(); return 1; } //Load the schema void Sorted::Load (Schema &f_schema, char *loadpath) { //Set writing mode to true i.e. reading mode is false if(readingMode) readingMode=false; //Open the file FILE *fileToLoad = fopen(loadpath, "r"); if(!fileToLoad){ cout<< "Can't open file name :" + string(loadpath); } Record record; //Load the schema and add each record while(record.SuckNextRecord(&f_schema,fileToLoad)==1){ readingMode = false; Add(record); } } //Open Done //Open the file int Sorted::Open (char *f_path) { cout<<"Sorted:Opening a sorted file"<<endl; string fileType; string type; string metadataFilePath=f_path; int numberOfAttributes; metadataFilePath=metadataFilePath+".metadata"; ifstream readMetadata; readMetadata.open(metadataFilePath.c_str()); if(!sortInfo){ sortInfo=new SortInfo(); sortInfo->myOrder=new OrderMaker(); readMetadata>>fileType; readMetadata>>sortInfo->runLength; readMetadata>>numberOfAttributes; int whichAtts[MAX_ANDS]; Type whichTypes[MAX_ANDS]; for(int count=0;count<numberOfAttributes;count++){ //Set which attribute; readMetadata>>whichAtts[count]; readMetadata>>type; if(type.compare("Int")==0){ whichTypes[count]=Int; } else if(type.compare("Double")==0){ whichTypes[count]=Double; } else whichTypes[count]=String; } //Set numberOfAttributes whichAtts and whichTypes sortInfo->myOrder->SetAttributeMetadata(numberOfAttributes,whichAtts,whichTypes); } this->file.Open(1, f_path); if(this->file.GetFileStatus()<0) return 0; cout<<"File opened successfully"<<endl; //Initialize parameters this->isPageDirty=false; this->currentPageNumber=1; return 1; } void Sorted::MoveFirst () { /*Since we are moving to the first page, page number is 1*/ this->file.GetPage(&this->page, 1); this->currentPageNumber = 1; } int Sorted::Close () { WritePageToFileIfDirty(&this->page, this->currentPageNumber); return this->file.Close(); } void Sorted :: WritePageToFileIfDirty(){ /** Shutdown the inPipe so that no new records are added, when you are trying to insert existing records. */ inPipe->ShutDown(); bigQ = new BigQ(*inPipe, *outPipe, *sortInfo->myOrder, sortInfo->runLength); /** Consume the records and write to the file */ while(outPipe->Remove(<#Record *removeMe#>)){ } /*Free the bigQ instance*/ delete bigQ; /*Open the inPipe*/ inPipe->Open(); } void Sorted::Add (Record &rec) { /** initialize the big queue instance */ int buffSize = 100; inPipe = new Pipe(buffSize); outPipe = new Pipe (buffSize); /** Insert the record into inPipe*/ inPipe->Insert(&rec); /** Now, we want to merge this record with the other records in the file */ /*This function should check if the current page number is 0. If it is then it should set it to 1*/ if(this->currentPageNumber == 0){ this->currentPageNumber++; // cout<< "Setting current page to " << this->currentPageNumber << " during add " << endl; } // cout << "No of records in page are "<< this->page.GetNumRecs() << endl; /*This function will take care of writing the page out if the page becomes full before adding a record. But it will NOT take care of writing the page out once all records are added and still page is not full. Calling function should take care of it*/ /*Check if the page is full before adding a record*/ if(!this->page.Append(&rec)){ WritePageToFileIfDirty(&this->page, this->currentPageNumber); cout << "Page is full.Appending the record to next page."<<endl; this->currentPageNumber++; /*Here, File::GetPage function can't be called. This is because that function returns an existing page whereas here we are adding a new page. But WritePageToFile... takes care of cleaning up of page instance, hence we just have to append the records to the new page*/ /*Now load further records*/ this->page.Append(&rec); /*Since we added a record, we should set page as dirty*/ this->isPageDirty = true; }else{ //cout << "Records appended" << endl; /*This means record is appended so set page as dirty*/ this->isPageDirty = true; } } bool Sorted :: InsertIntoBigQ(){ bigQ = new BigQ(*inPipe, *outPipe, *sortInfo->myOrder, sortInfo->runLength); /*This is created just for merging.*/ char *mergeFileName="mergedFile.bin"; File *mergeFile; int pagesTotal=0; currentPageNumber=0; /*Check if the main file exists*/ if(file.GetLength() != 0){ pagesTotal=file.GetLength()-1; mergeFile->Open(0, mergeFileName); Record *pipeRec, *fileRec; /*Get initial record from output pipe and file*/ if(outPipe->Remove(pipeRec)){ /*Insert it into the queue*/ } file.GetPage(&page, currentPageNumber); if(page.GetFirst(fileRec)){ /*Insert it into the queue*/ } while(queue not empty){ create a record structure copy insert the record into the merge file if(record is from output pipe){ get next record(Rec, outputPipe) }else{ get next record(Rec, file); } } /* This will be getNextRecord from file else{ pagesTotal--; if(pagesTotal>0){ currentPageNumber++; file.GetPage(&page,currentPageNumber); } }*/ /*Delete merge file when job is done*/ }else{ Record *rec; while(outPipe->Remove(rec)){ if(!page.Append(rec)){ file.AddPage(&page,pagesTotal); pagesTotal++; page.EmptyItOut(); } } return false; } } int Sorted::GetNext (Record &fetchme) { /*For each page, perform getPage to bring the page into the buffer. Then perform GetFirst() to get records from the page. The moment GetFirst returns 0 means scanning of that page is completed. So fetch next page i.e. continue the loop. */ int noOfPagesInFile = (this->file.GetLength()) - 1; /*Decrementing the length by 1 because first page of the file does not contain the data*/ // cout<< "File length is :: " << noOfPagesInFile <<endl; if(this->page.GetFirst (&fetchme)){ // cout << "Should print records" <<endl; return 1; }else{ /*This means that we have scanned all the records on that page So we should move to next page */ this->page.EmptyItOut(); this->currentPageNumber++; // cout << "Current Page number is " << this->currentPageNumber << endl; // cout << "No of pages in file is " << noOfPagesInFile << endl; if(this->currentPageNumber < noOfPagesInFile){ this->file.GetPage(&this->page, this->currentPageNumber); if(this->page.GetFirst(&fetchme)){ return 1; } else{ //this case should never occur ideally return 0; } }else{ /*This means that we have scanned the file till the end*/ return 0; } } } int Sorted::GetNext (Record &fetchme, CNF &cnf, Record &literal) { ComparisonEngine comp; while(GetNext(fetchme)){ if(comp.Compare(&fetchme, &literal, &cnf)) { return 1; } } return 0; } /*This function writes a page to the disk ONLY if it is dirty*/ void Sorted:: WritePageToFileIfDirty(Page* page, int whichPage){ /*Write dirty page to the file*/ if(this->isPageDirty){ this->file.AddPage(page, whichPage); this->page.EmptyItOut(); } } void Sorted::WriteMetadata(){ if(!GetMetadataFile().empty()){ ofstream outputStream; outputStream.open(string(GetMetadataFile() +".metadata").c_str(),ios::trunc); outputStream<<"sorted\n"; outputStream<<sortInfo->runLength<<"\n"; outputStream<<sortInfo->myOrder->ToString(); outputStream.close(); } }
2c8f1660928d2d9181fec9ac3c669d64a21ec2e2
120d045c9e2c1937a3bd51c8cadcf03ee3d2d292
/lw2/translator/pch.h
97df2212addfe1ad91b8c7c20a195788db60454e
[]
no_license
Alexander-Golova/oop
6deb5ea1112c15168e75b9bf5b06bcbd931cee43
551d724e59c0dcb1984cb1efa4eaafdf21878f3d
refs/heads/master
2021-01-16T19:19:12.850316
2020-02-09T12:46:32
2020-02-09T12:46:32
68,306,579
1
0
null
null
null
null
UTF-8
C++
false
false
274
h
#ifndef PCH_H #define PCH_H #include <Windows.h> #include <algorithm> #include <fstream> #include <iostream> #include <iterator> #include <locale> #include <map> #include <stdio.h> #include <string> #include <strstream> #include <tchar.h> #include <vector> #endif //PCH_H
d20780c63ca244042f16283d29edffd27caa92ad
05c249ce4bbd6dc7c8c78782679ada4b2d93675b
/Engine/Objects/ObjectFactory.cpp
e3c5ada63adcaf9ba8203ddb1d3baf24357b2089
[]
no_license
yaakgold/Intro-To-Game-Programming
7bea021477d95b64be4c48cf418ad4c4eb2bcd47
1ed8b1935b51a63d70c33fa8b04d8377e4c482bb
refs/heads/master
2022-12-07T05:07:09.218914
2020-09-01T21:58:05
2020-09-01T21:58:05
284,754,688
0
0
null
null
null
null
UTF-8
C++
false
false
825
cpp
#include "pch.h" #include "ObjectFactory.h" #include "Components/AudioComponent.h" #include "Components/RigidBodyComponent.h" #include "Components/SpriteAnimationComponent.h" namespace hummus { void ObjectFactoryImpl::Initialize() { ObjectFactory::Instance().Register("GameObject", new Creator<GameObject, Object>); ObjectFactory::Instance().Register("PhysicsComponent", new Creator<PhysicsComponent, Object>); ObjectFactory::Instance().Register("SpriteComponent", new Creator<SpriteComponent, Object>); ObjectFactory::Instance().Register("SpriteAnimationComponent", new Creator<SpriteAnimationComponent, Object>); ObjectFactory::Instance().Register("RigidBodyComponent", new Creator<RigidBodyComponent, Object>); ObjectFactory::Instance().Register("AudioComponent", new Creator<AudioComponent, Object>); } }
3b89c994ad1ca5c1a1ec5d8c0f1e89817d7b1910
483f7be3f28b5e0776644d0b985eaf48fbfee989
/src/matlabCodegenHandle.cpp
1fb2e61b9fe3d6f28034b397ae373f318fb5d8ac
[]
no_license
For-LD/MatLabToCPlus--VoiceRecognize
f097d96d37e2062834a4c63bd9438fe2d76a3660
45cafaf3b52e2eeefe42741496618d9ed5243867
refs/heads/main
2023-08-13T09:42:15.009336
2021-09-30T10:49:12
2021-09-30T10:49:12
412,021,621
0
0
null
null
null
null
UTF-8
C++
false
false
1,124
cpp
// // File: matlabCodegenHandle.cpp // // MATLAB Coder version : 5.0 // C/C++ source code generated on : 23-Oct-2020 20:33:52 // // Include Files #include "matlabCodegenHandle.h" #include "DeepLearningNetwork.h" #include "SystemCore.h" #include "VoiceRecognize.h" #include "rt_nonfinite.h" // Function Definitions // // Arguments : void // Return Type : void // dsp_private_AsyncBuffercg::~dsp_private_AsyncBuffercg() { this->matlabCodegenDestructor(); } // // Arguments : void // Return Type : void // dsp_private_AsyncBuffercgHelper::~dsp_private_AsyncBuffercgHelper() { this->matlabCodegenDestructor(); } // // Arguments : void // Return Type : void // void dsp_private_AsyncBuffercg::matlabCodegenDestructor() { if (!this->matlabCodegenIsDeleted) { this->matlabCodegenIsDeleted = true; } } // // Arguments : void // Return Type : void // void dsp_private_AsyncBuffercgHelper::matlabCodegenDestructor() { if (!this->matlabCodegenIsDeleted) { this->matlabCodegenIsDeleted = true; this->release(); } } // // File trailer for matlabCodegenHandle.cpp // // [EOF] //
31c06c2ec07c2ed74585d34de549be12da8cf3ef
8481b904e1ed3b25f5daa982a3d0cafff5a8d201
/C++/BZOJ/BZOJ 3531.cpp
21a6ea926059dfe0067556f0ce472b52f556648f
[]
no_license
lwher/Algorithm-exercise
e4ac914b90b6e4098ab5236cc936a58f437c2e06
2d545af90f7051bf20db0a7a51b8cd0588902bfa
refs/heads/master
2021-01-17T17:39:33.019131
2017-09-12T09:58:54
2017-09-12T09:58:54
70,559,619
1
2
null
null
null
null
UTF-8
C++
false
false
4,137
cpp
#include<iostream> #include<cstdio> #include<cstdlib> #include<cstring> #include<cmath> #include<algorithm> using namespace std; int n,q,tt,fa[100010][17],deep[100010],W[100010],C[100010],pl[100010],belong[100010],size[100010]; int sz,to[200010],pre[200010],last[100010]; int tot,root[100010],ls[3500000],rs[3500000],tmax[3500000],tsum[3500000]; int read() { char ch=getchar(); while(!(ch>='0' && ch<='9')) ch=getchar(); int x=0; while(ch>='0' && ch<='9') {x=x*10+(ch-'0');ch=getchar();} return x; } void Ins(int a,int b) { sz++;to[sz]=b;pre[sz]=last[a];last[a]=sz; } void swap(int &a,int &b) {int t=a;a=b;b=t;} void dfs1(int x) { size[x]=1; for(int i=1;i<=16;i++) fa[x][i]=fa[fa[x][i-1]][i-1]; for(int i=last[x];i;i=pre[i]) { if(to[i]==fa[x][0]) continue; deep[to[i]]=deep[x]+1; fa[to[i]][0]=x; dfs1(to[i]); size[x]+=size[to[i]]; } } void dfs2(int x,int chain) { pl[x]=++tt;belong[x]=chain; int i,k=0,maxx=0; for(i=last[x];i;i=pre[i]) { if(to[i]==fa[x][0]) continue; if(size[to[i]]>maxx) {maxx=size[to[i]];k=to[i];} } if(k==0) return; dfs2(k,chain); for(i=last[x];i;i=pre[i]) { if(to[i]==fa[x][0] || to[i]==k) continue; dfs2(to[i],to[i]); } } int LCA(int a,int b) { if(deep[a]<deep[b]) swap(a,b); int t=deep[a]-deep[b],i; for(i=16;i>=0;i--) if(t>=(1<<i)) {t-=(1<<i);a=fa[a][i];} for(i=16;i>=0;i--) if(fa[a][i]!=fa[b][i]) {a=fa[a][i];b=fa[b][i];} if(a==b) return a; return fa[a][0]; } void updata(int &x,int l,int r,int w,int num) { if(!x) x=++tot; if(l==r) {tmax[x]=num;tsum[x]=num;return;} int mid=(l+r)>>1; if(w<=mid) updata(ls[x],l,mid,w,num); else updata(rs[x],mid+1,r,w,num); tsum[x]=tsum[ls[x]]+tsum[rs[x]]; tmax[x]=max(tmax[ls[x]],tmax[rs[x]]); } int askmax(int x,int l,int r,int zuo,int you) { if(!x || l>you || r<zuo) return 0; if(l>=zuo && r<=you) return tmax[x]; int mid=(l+r)>>1; return max(askmax(ls[x],l,mid,zuo,you),askmax(rs[x],mid+1,r,zuo,you)); } int asksum(int x,int l,int r,int zuo,int you) { if(!x || l>you || r<zuo) return 0; if(l>=zuo && r<=you) return tsum[x]; int mid=(l+r)>>1; return asksum(ls[x],l,mid,zuo,you)+asksum(rs[x],mid+1,r,zuo,you); } int solvemax(int x,int f,int c) { int maxx=0,l,r; while(belong[x]!=belong[f]) { l=pl[belong[x]];r=pl[x]; maxx=max(maxx,askmax(root[c],1,n,l,r)); x=fa[belong[x]][0]; } l=pl[f];r=pl[x]; maxx=max(maxx,askmax(root[c],1,n,l,r)); return maxx; } int solvesum(int x,int f,int c) { int sum=0,l,r; while(belong[x]!=belong[f]) { l=pl[belong[x]];r=pl[x]; sum+=asksum(root[c],1,n,l,r); x=fa[belong[x]][0]; } l=pl[f];r=pl[x]; sum+=asksum(root[c],1,n,l,r); return sum; } void solve() { int i,a,b,c,ans;char s[5]; for(i=1;i<=n;i++) updata(root[C[i]],1,n,pl[i],W[i]); for(i=1;i<=q;i++) { scanf("%s",s);a=read();b=read();//scanf("%d%d",&a,&b); if(s[1]=='C') { updata(root[C[a]],1,n,pl[a],0); updata(root[b],1,n,pl[a],W[a]); C[a]=b; }else if(s[1]=='W') { updata(root[C[a]],1,n,pl[a],b); W[a]=b; }else if(s[1]=='M') { c=LCA(a,b); ans=max(solvemax(a,c,C[b]),solvemax(b,c,C[b])); printf("%d\n",ans); }else { c=LCA(a,b); ans=solvesum(a,c,C[b])+solvesum(b,c,C[b]); if(C[c]==C[b]) ans-=W[c]; printf("%d\n",ans); } } } void init() { int i,a,b; n=read();q=read();//scanf("%d%d",&n,&q); for(i=1;i<=n;i++) {W[i]=read();C[i]=read();}//scanf("%d%d",&W[i],&C[i]); for(i=1;i<n;i++) { a=read();b=read();//scanf("%d%d",&a,&b); Ins(a,b);Ins(b,a); } dfs1((n+1)/2); dfs2((n+1)/2,(n+1)/2); } int main() { init(); solve(); system("pause"); return 0; }
a7d29b215358b4d99b8118d0f688482ab64a9797
d7b20252fdb6036c9ec87e02d1ce8f1f8ce729e2
/src/allegro_flare/framework/gui/surface_areas/box_padded.cpp
1d1be6dcbd4c7b298a84c6a4968e5f6a8cf07105
[]
no_license
MarkOates/KrampusHack2018
a439d30249605c1801d183d36f86be1e4ac7a061
f2f5803c76f2e67c71a3bae93459d6fe8595f74d
refs/heads/master
2020-04-12T07:05:16.257298
2018-12-19T01:14:27
2018-12-19T01:14:27
162,356,790
0
0
null
null
null
null
UTF-8
C++
false
false
1,158
cpp
#include <iostream> #include <allegro_flare/gui/surface_areas/box_padded.h> #include <allegro_flare/color.h> UISurfaceAreaBoxPadded::UISurfaceAreaBoxPadded(float x, float y, float w, float h, float pt, float pr, float pb, float pl) : UISurfaceAreaBase(x, y, w, h) , padding_top(pt) , padding_right(pr) , padding_bottom(pb) , padding_left(pl) { } UISurfaceAreaBoxPadded::~UISurfaceAreaBoxPadded() { } bool UISurfaceAreaBoxPadded::collides(float x, float y) { return placement.collide(x, y, padding_top, padding_right, padding_bottom, padding_left); } void UISurfaceAreaBoxPadded::draw_bounding_area() { placement.draw_box_with_padding(color::color(color::aliceblue, 0.2), true, padding_top, padding_right, padding_bottom, padding_left); } void UISurfaceAreaBoxPadded::get_padding(float *pt, float *pr, float *pb, float *pl) { *pt = padding_top; *pr = padding_right; *pb = padding_bottom; *pl = padding_left; } void UISurfaceAreaBoxPadded::set_padding(float pt, float pr, float pb, float pl) { padding_top = pt; padding_right = pr; padding_bottom = pb; padding_left = pl; }
2100b76829c13c0a4bbd203efbf391ead9c6fe80
cd6883984a46e76dfc134db8209e79232b7cc172
/Game/Engine/RendererDX11.h
047e45ddc8dbbfc1a9e8458f180a32472a693bc0
[]
no_license
woocom2/Game
25f817cb50b4dd7f99e7e74db0826c5b2f7e5211
7829cdf1ac1f194a7502dd2aeb6ae07590da0fe7
refs/heads/master
2020-04-24T21:55:28.974371
2014-07-27T14:49:33
2014-07-27T14:49:33
null
0
0
null
null
null
null
UTF-8
C++
false
false
762
h
#pragma once #include "IRenderer.h" #include <d3d11.h> class RendererDX11 : public IRenderer { public: RendererDX11() : m_hWnd(nullptr), m_pDevice(nullptr), m_pContext(nullptr) {} virtual ~RendererDX11(){} HRESULT Initialize(HWND hWnd); void Render(); void Destroy(); ID3D11Device* GetDevice() const { return m_pDevice; } ID3D11DeviceContext* GetDeviceContext() const { return m_pContext; } private: HWND m_hWnd; D3D_DRIVER_TYPE m_DriverType; D3D_FEATURE_LEVEL m_FeatureLevel; ID3D11Device* m_pDevice; ID3D11DeviceContext* m_pContext; IDXGISwapChain* m_pSwapChain; ID3D11RenderTargetView* m_pRenderTargetView; ID3D11Texture2D* m_pDepthBuffer; ID3D11DepthStencilView* m_pDepthStencilView; D3D11_VIEWPORT m_ViewPort; };
c207b1e7ab52418ad89bfaa042cfebf125fd8611
e5c219a6647647a1326e7287233a1fa41efa48f1
/ThePartingOfSarah/HudObserver.h
c3d68575bd414eb431af40bf294a2e447e15f70e
[ "MIT" ]
permissive
kriogenia/the-parting-of-sarah
6c02aece39aa5861013bdca7f35e0f88728a1c8b
91cdd70f4beb1530652021ebb3a5d81c6e981e1a
refs/heads/master
2023-06-03T03:22:48.783343
2020-12-04T20:28:08
2020-12-04T20:28:08
304,705,001
0
0
null
2020-12-04T17:23:29
2020-10-16T18:13:05
C++
UTF-8
C++
false
false
408
h
#pragma once #include "Hud.h" #include "Observer.h" #include "Player.h" #include "Room.h" class HudObserver : public Observer { public: HudObserver(Hud* hud); /* Observer */ void notify(eObserverMessages message, void* publisher = nullptr) override; private: Hud* hud; // predeclared pointers int* integer; Item* item; Player* player; Room* room; Boss* boss; };
1ae149fcd1c3b474488db91759f6c4ba2e896fe1
768d2722884910bc05e9baaece13dbb21fd9cb16
/Codebook/All the Code/Data Structures/Treaps/Implicit Treap Cut And Paste.cpp
aa8f8bed16b7e06e4cbc2b09050ef645630055e2
[]
no_license
sapjv/Competitive_Programming
83e7ddc13d67240d1f2db5b4300f2d5fc2629ab1
157cfdf246991a625c64fdc14f614a30dbb19950
refs/heads/master
2022-03-07T17:13:22.975772
2019-11-27T19:53:41
2019-11-27T19:53:41
271,464,234
1
0
null
2020-06-11T05:59:21
2020-06-11T05:59:21
null
UTF-8
C++
false
false
2,447
cpp
// Hackerrank Zalando Codesprint #include "bits/stdc++.h" using namespace std; struct node{ int left, right, pr, sz, val; }; const int MAX = 100000 + 50; node tree[MAX]; int N, root, null = 100000 + 5; inline int create_node(int val){ tree[N].pr = rand(); tree[N].sz = 1; tree[N].val = val; tree[N].left = tree[N].right = null; return N++; } // Update Treap Information (when you're moving it around) inline int upd(int x){ int l = tree[x].left, r = tree[x].right; tree[x].sz = tree[l].sz + 1 + tree[r].sz; return x; } /* Takes the treap rooted at "rt" and puts the k smallest elements in it into sp.first, and the rest into sp.second */ inline pair < int, int > split(int rt, int k){ if(rt >= null) return make_pair(null, null); pair < int, int > sp; if(tree[tree[rt].left].sz >= k){ sp = split(tree[rt].left, k); tree[rt].left = sp.second; sp.second = upd(rt); return sp; } else{ k -= tree[tree[rt].left].sz; sp = split(tree[rt].right, k - 1); tree[rt].right = sp.first; sp.first = upd(rt); return sp; } } // Merges treaps (l) and (r) inline int merge(int l, int r){ if(l >= null) return r; if(r >= null) return l; if(tree[l].pr > tree[r].pr){ tree[l].right = merge(tree[l].right,r); return upd(l); } else{ tree[r].left = merge(l,tree[r].left); return upd(r); } } /* Inserts element at position (i + 1) i.e after position (i) in the treap */ inline int insert(int i){ pair < int, int > sp = split(root, i); int val; scanf("%d", &val); int x = create_node(val); sp.first = merge(sp.first,x); return merge(sp.first, sp.second); } /* Let arr[1...N] be the current array :- It looks like arr[1...i - 1] -> arr[i...j] -> arr[j + 1...N] work(i, j) takes subarray arr[i...j], cuts it, and pastes it at the beginning So the new array looks like arr[i..j] -> arr[1, i - 1] -> arr[j + 1..n] */ inline void work(int i, int j){ pair < int, int > sp, sp2; sp = split(root, j); sp2 = split(sp.first, i - 1); root = merge(merge(sp2.second, sp2.first), sp.second); } /* Prints the in-order traversal of the treap i.e the sorted order of elements. */ inline void print(int idx){ upd(idx); if(idx >= null) return; print(tree[idx].left); cout << tree[idx].val << ' '; print(tree[idx].right); } int main(){ int n, q, i, j; scanf("%d", &n); root = null; while(n--) root = insert(N); scanf("%d", &q); while(q--){ scanf("%d %d", &i, &j); work(i, j); } print(root); }
666b17db4b7e6b195d03b24d00e48bd9813af47d
9efd18a1b7a9fa1b65083ced3d4ef54c856e3594
/HW7/Image3.h
dade519e41155c6d46df96664bc692a760d2e15c
[]
no_license
hbmoore2/CS201
403c60ef75e3b03a459c9022d4ea839cdada4dea
3d976a0e0ad7b4b246904c38fc6005969b149c19
refs/heads/master
2020-12-12T14:42:18.097837
2020-04-25T09:55:27
2020-04-25T09:55:27
234,146,035
0
0
null
null
null
null
UTF-8
C++
false
false
725
h
// Image3.hpp // Interface for Image3 class // Original Author: Jonathan Metzgar // CS 201 course #ifndef IMAGE3_H #define IMAGE3_CPP #include <iostream> #include <vector> #include "Color3.h" class Image3 { public: Image3(unsigned width, unsigned height); const Color3& getPixel(unsigned x, unsigned y) const; void setPixel(unsigned x, unsigned y, const Color3& color); bool savePPM(const std::string& path) const; bool loadPPM(const std::string& path); void printASCII(std::ostream& ostr) const; std::vector<Color3> pixels; unsigned w; unsigned h; Color3 borderColor; }; std::ostream& operator<<(std::ostream& ostr, const Image3& image); std::istream& operator>>(std::istream& istr, Image3& image); #endif
0787b278b7dea2c091bd41504cd2192619c73fd2
aa90fd5a0aee4fa58bf4425c9143ca63afc42021
/GameScene/GameScene_9.h
f4c0d6cd14086c10091044c54eeeda046e937e51
[]
no_license
LJC619/EvilSYSU
aaf852ba3d228702f590067a139786242f40ae3b
2a549468f9b5904be36c904cd78a902e1fd068e0
refs/heads/master
2020-04-03T12:46:23.643034
2014-06-07T15:29:26
2014-06-07T15:29:26
null
0
0
null
null
null
null
UTF-8
C++
false
false
673
h
#pragma once #include "cocos2d.h" #include "GameScene_7.h" #include "GameScene_10.h" #define userDataFile CCUserDefault::sharedUserDefault() USING_NS_CC; class GameScene_9 : public CCLayer { public: GameScene_9(); ~GameScene_9(); static CCScene* scene(); virtual bool init(); CREATE_FUNC(GameScene_9); //init the game scene void InitScene(); void showTip_1(); //run game void runGame(CCNode* sender); //move menu void toScene_7(CCObject* pSender); void toScene_10(CCObject* pSender); private: //Size CCSize visibleSize; //Original point CCPoint visibleOrigin; //background image CCSprite* background; };
1b5dc012d4cd8c8c3e5028ac7905a484e58baff9
1516bbee0ee2394fd66176b9fa160406a79df4af
/demo/demo.cpp
15b5c7194528b937781b27ba571fac193e37402f
[]
no_license
stvwll/ICP-demo
0c3249eafa20da84fbdf5141834daff5ca4d416b
953c921f35b99311ed846af2389eccc3736f3b15
refs/heads/master
2020-06-12T16:22:56.954796
2019-07-08T12:37:12
2019-07-08T12:37:12
194,358,033
1
1
null
null
null
null
UTF-8
C++
false
false
2,859
cpp
#include "pch.h" #include <iostream> #include "icpPointToPlane.h" #include "icpPointToPoint.h" #include <fstream> using namespace std; //统计文件的行数 int getLineNum(string filename) { ifstream ifs(filename); int res = 0; string tmp; while (getline(ifs, tmp))//逐行读取文件,将行读入字符串tmp 等价于ifs>>tmp;默认回车符停止读入词 res++;//统计行数 return res; } //读文件数据,每行三个数据,结果保存到data指针数组 double* readfile(string filename) { int lineNum = getLineNum(filename); double *data = (double*)calloc(3 * lineNum, sizeof(double));//申请空间 ifstream ifs(filename); string tmp; int count = 0; while (getline(ifs, tmp)) { double x, y, z; ifs >> x >> y >> z; data[3 * count + 0] = x; data[3 * count + 1] = y; data[3 * count + 2] = z; count++; } return data; } //保存文件:注意传入的是指针数组的索引,num2是要读取的文件的行数 void savefile(double *&T, int num2, string filename = "savedT.xyz") { ofstream ofs(filename);//打开文件 for (int i = 0; i < num2; ++i) ofs << T[3 * i + 0] << " " << T[3 * i + 1] << " " << T[3 * i + 2] << "\n"; } //R矩阵是3*3,t矩阵是3*1 点值,根据旋转矩阵计算之后的值 void rotatePoint(double *&T, int num2, Matrix R, Matrix t) { for (int i = 0; i < num2; ++i) { FLOAT *val = new FLOAT[3]; val[0] = (FLOAT)(T[3 * i + 0]); val[1] = (FLOAT)(T[3 * i + 1]); val[2] = (FLOAT)(T[3 * i + 2]); Matrix point(3, 1, val); Matrix pointout = R * point + t; T[3 * i + 0] = pointout.val[0][0]; T[3 * i + 1] = pointout.val[1][0]; T[3 * i + 2] = pointout.val[2][0]; } } int main(int argc, char** argv) { // string filename1="originalM.xyz";//"../facedata/result3_1.xyz"; // string filename2="originalT.xyz";//"../facedata/result3_2.xyz"; string filename1 = "D:/visual studio learning/demo/originalM.xyz"; string filename2 = "D:/visual studio learning/demo/originalT.xyz"; //点云图 int num1 = getLineNum(filename1); int num2 = getLineNum(filename2); cout << num1 << " " << num2 << endl; double *M = readfile(filename1); double *T = readfile(filename2); int32_t dim = 3; // for(int i=0;i<num2;++i){ // T[3*i+0]+=10; // T[3*i+1]+=10; // T[3*i+2]+=10; // } // savefile(M,num1,"originalM.xyz"); // savefile(T,num2,"originalT.xyz"); Matrix R = Matrix::eye(3); Matrix t(3, 1); // run point-to-plane ICP (-1 = no outlier threshold) cout << endl << "Running ICP (point-to-plane, no outliers)" << endl; IcpPointToPlane icp(M, num1, dim); double residual = icp.fit(T, num2, R, t, -1); cout << "R:" << endl << R << endl << endl; cout << "t:" << endl << t << endl << endl; cout << "Residual:" << residual; rotatePoint(T, num2, R, t); savefile(T, num2, "D:/visual studio learning/demo/rotatedT.xyz"); free(M); free(T); return 0; }
fe3a48cccc42281eb73a7f179f6dfe271ef33807
91a882547e393d4c4946a6c2c99186b5f72122dd
/Source/XPSP1/NT/ds/security/passport/passportmanager/stdafx.h
22ad378d54334e94545789c23e6a3953d553794c
[]
no_license
IAmAnubhavSaini/cryptoAlgorithm-nt5src
94f9b46f101b983954ac6e453d0cf8d02aa76fc7
d9e1cdeec650b9d6d3ce63f9f0abe50dabfaf9e2
refs/heads/master
2023-09-02T10:14:14.795579
2021-11-20T13:47:06
2021-11-20T13:47:06
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,478
h
// stdafx.h : include file for standard system include files, // or project specific include files that are used frequently, // but are changed infrequently #if !defined(AFX_STDAFX_H__41651BE6_A5C8_11D2_95DF_00C04F8E7A70__INCLUDED_) #define AFX_STDAFX_H__41651BE6_A5C8_11D2_95DF_00C04F8E7A70__INCLUDED_ #if _MSC_VER > 1000 #pragma once #endif // _MSC_VER > 1000 #ifndef STRICT #define STRICT #endif #ifndef _WIN32_WINNT #define _WIN32_WINNT 0x0400 #endif #define _ATL_FREE_THREADED // We'll use import to pick up ASP, so make sure includes don't // accidentally beat us to it #define ___asptlb_h__ #include <atlbase.h> //You may derive a class from CComModule and use it if you want to override //something, but do not change the name of _Module extern CComModule _Module; #include <atlcom.h> #include <comdef.h> #include "commd5.h" #include "BstrDebug.h" #ifdef MEM_DBG #define _CRTDBG_MAP_ALLOC #include <crtdbg.h> #endif #include "PassportConfiguration.h" #include "Monitoring.h" #include "PassportTypes.h" extern CPassportConfiguration* g_config; // extern CProfileSchema* g_authSchema; HRESULT GetGlobalCOMmd5(IMD5 ** ppMD5); #define MEMBERNAME_INDEX 0 #define LANGPREF_INDEX 8 #import "asp.dll" no_namespace using namespace ATL; //{{AFX_INSERT_LOCATION}} // Microsoft Visual C++ will insert additional declarations immediately before the previous line. #endif // !defined(AFX_STDAFX_H__41651BE6_A5C8_11D2_95DF_00C04F8E7A70__INCLUDED)
fc9d8550e104a85a9ebde4ac08163ed9a152ec6a
c98bffce9b9201b8c7b0f0a7bde3ea0171bb3efa
/课程/分块/Color the ball.cpp
1f7785224201dc12c7ba651b14904468c52b603e
[]
no_license
iOranges/KoalaWY
4edc87eaeb9d5f54a96f3689a3cb7d3c63a5ebc9
b99383d5484ed3e61ed935b0ff47971e3a448e2b
refs/heads/master
2020-12-14T09:40:51.195501
2020-01-18T08:20:59
2020-01-18T08:20:59
234,699,509
0
0
null
null
null
null
UTF-8
C++
false
false
952
cpp
#include<cmath> #include<cstdio> #include<cstring> #define N 100005 #define min(x,y) ((x)<(y)?(x):(y)) int l[350],r[350],num[N],v[N],lzy[N],n; void build() { register int i; int block = sqrt(n); int cnt = n / block; if(n % block) ++ cnt; for(i = 1;i <= cnt;++ i) { l[i] = (i - 1) * block + 1; r[i] = i * block; } r[cnt] = n; for(i = 1;i <= n; ++ i) num[i] = (i - 1) / block + 1; } void add(int a,int b) { register int i; for(i = a;i <= min(b,r[num[a]]);++ i) v[i] ++; if(num[a]!=num[b]) for(i = l[num[b]];i <= b;++ i) v[i] ++; for(i = num[a] + 1;i < num[b];++ i) lzy[i] ++; } int main() { int a,b; register int i; while(~scanf("%d",&n)) { if(!n) break; memset(v,0,sizeof v); memset(lzy,0,sizeof lzy); build(); for(i = 1;i <= n;++ i) { scanf("%d%d",&a,&b); add(a,b); } printf("%d",v[1] + lzy[num[1]]); for(i = 2;i <= n;++ i) printf(" %d",v[i] + lzy[num[i]]); printf("\n"); } return 0; }
1bfd53f05b3fd74fdf3df6cdb9dd15fa50d784ff
7f785671244ef36aadd85ce8feceb3181c7e5976
/shared_files/COMM_CarProtocol/headers/CarProtocol.h
f9b16546ac16f944fbdf2ee000515a8329851a54
[]
no_license
hds17/hwswcd-car2x
5585205da8d05febb4a94069a34cc1b4c5f52adf
90adaa103062a09bb826fa8442e795050d76c259
refs/heads/master
2021-01-17T17:05:56.813444
2015-02-26T15:22:47
2015-02-26T15:22:47
26,859,422
0
0
null
null
null
null
UTF-8
C++
false
false
5,096
h
/* * CarProtocol.h * * Created on: 17.11.2013 * Author: Florian */ #ifndef CARPROTOCOL_H_ #define CARPROTOCOL_H_ //define CARP MSG IDs #define CARP_MSGID_WELCOME 0x01 #define CARP_MSGID_MOTORVELOCITY 0x04 #define CARP_MSGID_MOTORMEASUREMENT 0x05 #define CARP_MSGID_ULTRASOUNDSENSOR 0x08 #define CARP_MSGID_ACCELERATIONSENSOR 0x09 #define CARP_MSGID_ADCSENSOR 0x0A //define Car2X Message IDs #define C2X_MSGID_EMERGENCY_BRAKE 0x20 #define C2X_MSGID_CONTROL 0x30 #define C2X_MSGID_INFO_STATE 0x40 #define C2X_MSGID_INFO_SENSORS 0x50 #define C2X_MSGID_REMOTE_CONTROL 0x60 // Export interfaces #include <alt_types.h> #include "CarMessage.h" /* * Class CCarProtocol. * This class manages the complete communication protocol. Each protocol object consists of a protocol-header * and a list of messages (see CarMessage). * * Note: Due to some renaming conflicts there are the following synonyms: * CarProtocol = Packet * CarMessage = Message * The fields in CarProtocol and CarMessage may have the same name. Make sure that you are in the right class! * * The total structure of a packet looks like: * * 1st Byte | 2nd Byte | 3rd Byte | 4th Byte * ---------|----------|----------|----------- * 'C' | 'A' | 'R' | 'P' * PacketNumber | PayloadLength * ---------|----------|----------|----------- * P A Y L O A D * * 'C''A''R''P': Start sequence of the packet to detect a packet in the incoming byte-stream. * PacketNumber: Consecutive increasing 16 bit number which works as an ID. The number is never changed by the * Nios2, only by the central ECU (Linux-PC). Thereby the central ECU can detect a protocol fail * if the response packet has not the same PacketNumber as the request packet. * Please remember the wrap around after the PacketNumber 65535! * PayloadLength: Total length of the payload in Bytes. This length information contains not the packet-header length! * * The payload contains at least one message and max. 8 messages. All messages start at a multiple of 4 assuming * that all messages have a multiple of 4 as length. There must be no gap between two messages!! * * * The order of the messages in a packet is important: * Contains the packet a WelcomeMessage this message as to be the first. All other messages in this packet will * be ignored! * * Otherwise the first message is the most important followed by the second and so on... See main.cpp for the * meaning of important. * Note: As the velocity-message is the most important in normal mode it will be assumed to be the first message! * See also the main file for possible side-effects on the speed control. * * */ class CCarProtocol { public: /* * Constructor which fills the new object with data from the given byte array. * Note: Even if there are more packets in the byte stream, only the first occurrence is used. All other * packets will be ignored! * * pPacket: byte array containing the byte (network) representation of the packet. * iLength: length of the byte stream. */ CCarProtocol(alt_u8 *pPacket, int iLength); /* * Constructor which packs the given messages to a new packet. This constructor is primarily called by the * central ECU (Linux-PC). * * uiPacketNumber: packet number of the new packet. Don't forget to increase afterwards! * pMessages: array of pointer (references) to the CarMessages. * uiMessageCount: length of the array above. */ CCarProtocol(alt_u16 uiPacketNumber, CCarMessage **pMessages, alt_u32 uiMessageCount); /* * Destructor which calls the destructors of all CarMessage objects if necessary. */ virtual ~CCarProtocol(); /* * Returns m_bValid. */ bool isValid(); /* * Returns the total length of complete packet (packet-header + payload). * Please note that this call has only O(n) but avoid multiple calls. */ alt_u32 getLength(); /* * Returns the complete byte (network) representation of this packet including * packet-header and payload (messages). * Returns also m_bValid. */ bool getBytes(alt_u8 *pPacket); /* * Returns a pointer to the nth message in this packet. First message has n = 0! * Is n >= m_uiMessageCount then a 0 is returned, otherwise the pointer to the * message object. */ CCarMessage *getNthMessage(alt_u32 uiIdx); /* * Returns m_uiMessageCount. */ alt_u32 getMessageCount(); // Additional getter methods alt_u16 getUiPacketNumber() const { return m_uiPacketNumber; } bool isBThereIsMore() const { return m_bThereIsMore; } private: bool m_bValid; // True if the packet was successfully generated / parsed. bool m_bThereIsMore; // True if the packet was partially parsed but there is something missing in the byte array. alt_u16 m_uiPacketNumber; // The packet number given in the packet-header. CCarMessage *m_pMessages[8]; // Array of the pointer to the messages which are in this packet. alt_u32 m_uiMessageCount; // Count of messages in this packet. /* * Parsing method called by the constructors. * Important note: * >>>>>> You have to edit this method if there are new sensors / messages <<<<< * * Detailed comment in the .cpp file! */ void parsePacket(alt_u8 *pPacket, int iLength); }; #endif /* CARPROTOCOL_H_ */
cbf83d185873437a71cca561dd8d2cdfa0eb2b3c
c1191e2881935674992d4857c0350d9e0bd69909
/BIN/PRINTPSC.CPP
d0f1f7440c4733b08b9f4b0b2273ddbe3f5f1742
[]
no_license
jamesmattluyon/JML-Cplus_plus-Files
381983e1a29de0cad3e082c614a0a9e1ef9e1a72
c90c999f6a5d8dfef3be3ca08242457b31751c67
refs/heads/master
2023-09-01T02:23:38.318083
2021-10-06T09:10:07
2021-10-06T09:10:07
414,140,822
0
0
null
null
null
null
UTF-8
C++
false
false
235
cpp
#include<iostream.h> #include<conio.h> #include<stdio.h> void main() { int n,row,col; clrscr(); cout<<" Enter a value "; cin>> n; for(row=1;row<=n;row++) { for(col=1;col<=row;col++) cout<<" * "; cout<<" \n"; } getch(); }
77d0e40e8aae04e0fffebd84f2674f82f5104394
844cc9741c69988042dc4c71b3699da0ca048a6e
/test1.cpp
75e717cb7645de3ea8152c6f25629aa2a90cd435
[]
no_license
yejin-gif/project1
caad8abe2e8f841c66dfe844bacd5c011aae5d1f
90bf73a5b1325ffa1879528a597f1ff4516d277e
refs/heads/master
2020-08-21T19:42:26.615839
2019-10-24T06:12:14
2019-10-24T06:12:14
216,231,936
0
0
null
null
null
null
UTF-8
C++
false
false
121
cpp
#include <iostream> using namespace std; int main(void) { int a, b, c; int a = b + c; cout << a << endl; return 0; }
a47659b428c3298b72c0938e53e14326c49ab6d7
54b9e39a6b4b412223f234e9791a208a1368be9e
/March/multiinheritance_shaon.cpp
0fdd398ba95c67a707c2673a0ea8bcbf219ec91a
[]
no_license
RKMVCC-BSc-Comp-Sci-2020-21/Programming-C-Cpp-Sem1
90272d55002c7beec1e2d542c5fe3446cd0c4719
6cda8177e95f5d368881ed52c499cc4e1a2bb680
refs/heads/main
2023-03-31T02:57:04.662744
2021-03-30T14:52:44
2021-03-30T14:52:44
315,950,354
9
35
null
2021-03-22T15:31:14
2020-11-25T13:38:49
C++
UTF-8
C++
false
false
349
cpp
#include<iostream> using namespace std; class A { public: A() { cout << "A's constructor called" << endl; } }; class B { public: B() { cout << "B's constructor called" << endl; } }; class C: public B, public A // Note the order { public: C() { cout << "C's constructor called" << endl; } }; int main() { C c; return 0; }
4b68daa9738bb4176400f8bf02fb58b8bb573bfb
8f95017e9c9223c4fefddbd80b717ddba5b7a589
/Design Patterns/Padrões Estruturais/Adapter/TecladoAdapter/EntradaPS2.hpp
dc294d502a9db278a7b63f3f495ff215422590f0
[]
no_license
joaovitor11/EstudoCppp
d11f7df8cc3e9818922286696d7edfeb3ce419fb
83b83343da79dc375c3e9f62087a620c956ca26d
refs/heads/master
2021-01-20T17:20:13.846068
2017-09-15T16:41:03
2017-09-15T16:41:03
62,401,117
1
0
null
null
null
null
UTF-8
C++
false
false
122
hpp
#ifndef EntradaPS2_hpp #define EntradaPS2_hpp class EntradaPS2{ public: void conectarEntradaPS2(); }; #endif
b754022b4080a781bbddfffa6d8f3f26c94c3115
816b6fc348ae61537585e9c8898c6d5ddec9a93c
/FactoryDealer/ICarType.h
bde32be94d2a2e2d600fdbeb9b2a50a03ff20e83
[]
no_license
Kapoor1/CPPPrograms
90de63e4ee74bbb3deafd5571a0afb3dac6cc228
39a20525ed7d51d41740cb06d077995c666f5f0f
refs/heads/master
2022-04-21T03:19:25.636802
2020-04-19T16:47:57
2020-04-19T16:47:57
257,021,666
0
0
null
null
null
null
UTF-8
C++
false
false
133
h
#pragma once #include<iostream> class ICarType { public: //car type can be huthback or sidan virtual void DisplayCarType() = 0; };
bb30929e0e66af1be99c76fad36b9ac39be4edeb
f3a5e1bb43fb4e2465d51d85f7e5102e734a271a
/src/qt/askpassphrasedialog.cpp
dcd7fd85edba316deee6c2f4c1cacb331a9d71de
[ "MIT" ]
permissive
eyccoin/energycoin-qt
904169301ead1b08572376227f381fa0e9825b67
a3d6b2df47498fd0b41820fcd3136904a41298d7
refs/heads/master
2021-04-15T04:02:43.617855
2018-03-22T05:35:08
2018-03-22T05:35:08
125,786,857
0
0
null
null
null
null
UTF-8
C++
false
false
9,698
cpp
#include "askpassphrasedialog.h" #include "ui_askpassphrasedialog.h" #include "guiconstants.h" #include "walletmodel.h" #include <QMessageBox> #include <QPushButton> #include <QKeyEvent> AskPassphraseDialog::AskPassphraseDialog(Mode mode, QWidget *parent) : QDialog(parent), ui(new Ui::AskPassphraseDialog), mode(mode), model(0), fCapsLock(false) { ui->setupUi(this); ui->passEdit1->setMaxLength(MAX_PASSPHRASE_SIZE); ui->passEdit2->setMaxLength(MAX_PASSPHRASE_SIZE); ui->passEdit3->setMaxLength(MAX_PASSPHRASE_SIZE); // Setup Caps Lock detection. ui->passEdit1->installEventFilter(this); ui->passEdit2->installEventFilter(this); ui->passEdit3->installEventFilter(this); switch(mode) { case Encrypt: // Ask passphrase x2 ui->passLabel1->hide(); ui->passEdit1->hide(); ui->warningLabel->setText(tr("Enter the new passphrase to the wallet.<br/>Please use a passphrase of <b>10 or more random characters</b>, or <b>eight or more words</b>.")); setWindowTitle(tr("Encrypt wallet")); break; case Unlock: // Ask passphrase ui->warningLabel->setText(tr("This operation needs your wallet passphrase to unlock the wallet.")); ui->passLabel2->hide(); ui->passEdit2->hide(); ui->passLabel3->hide(); ui->passEdit3->hide(); setWindowTitle(tr("Unlock wallet")); break; case Decrypt: // Ask passphrase ui->warningLabel->setText(tr("This operation needs your wallet passphrase to decrypt the wallet.")); ui->passLabel2->hide(); ui->passEdit2->hide(); ui->passLabel3->hide(); ui->passEdit3->hide(); setWindowTitle(tr("Decrypt wallet")); break; case ChangePass: // Ask old passphrase + new passphrase x2 setWindowTitle(tr("Change passphrase")); ui->warningLabel->setText(tr("Enter the old and new passphrase to the wallet.")); break; } textChanged(); connect(ui->passEdit1, SIGNAL(textChanged(QString)), this, SLOT(textChanged())); connect(ui->passEdit2, SIGNAL(textChanged(QString)), this, SLOT(textChanged())); connect(ui->passEdit3, SIGNAL(textChanged(QString)), this, SLOT(textChanged())); } AskPassphraseDialog::~AskPassphraseDialog() { // Attempt to overwrite text so that they do not linger around in memory ui->passEdit1->setText(QString(" ").repeated(ui->passEdit1->text().size())); ui->passEdit2->setText(QString(" ").repeated(ui->passEdit2->text().size())); ui->passEdit3->setText(QString(" ").repeated(ui->passEdit3->text().size())); delete ui; } void AskPassphraseDialog::setModel(WalletModel *model) { this->model = model; } void AskPassphraseDialog::accept() { SecureString oldpass, newpass1, newpass2; if(!model) return; oldpass.reserve(MAX_PASSPHRASE_SIZE); newpass1.reserve(MAX_PASSPHRASE_SIZE); newpass2.reserve(MAX_PASSPHRASE_SIZE); // TODO: get rid of this .c_str() by implementing SecureString::operator=(std::string) // Alternately, find a way to make this input mlock()'d to begin with. oldpass.assign(ui->passEdit1->text().toStdString().c_str()); newpass1.assign(ui->passEdit2->text().toStdString().c_str()); newpass2.assign(ui->passEdit3->text().toStdString().c_str()); switch(mode) { case Encrypt: { if(newpass1.empty() || newpass2.empty()) { // Cannot encrypt with empty passphrase break; } QMessageBox::StandardButton retval = QMessageBox::question(this, tr("Confirm wallet encryption"), tr("Warning: If you encrypt your wallet and lose your passphrase, you will <b>LOSE ALL OF YOUR COINS</b>!") + "<br><br>" + tr("Are you sure you wish to encrypt your wallet?"), QMessageBox::Yes|QMessageBox::Cancel, QMessageBox::Cancel); if(retval == QMessageBox::Yes) { if(newpass1 == newpass2) { if(model->setWalletEncrypted(true, newpass1)) { QMessageBox::warning(this, tr("Wallet encrypted"), "<qt>" + tr("energycoin will close now to finish the encryption process. " "Remember that encrypting your wallet cannot fully protect " "your coins from being stolen by malware infecting your computer.") + "<br><br><b>" + tr("IMPORTANT: Any previous backups you have made of your wallet file " "should be replaced with the newly generated, encrypted wallet file. " "For security reasons, previous backups of the unencrypted wallet file " "will become useless as soon as you start using the new, encrypted wallet.") + "</b></qt>"); QApplication::quit(); } else { QMessageBox::critical(this, tr("Wallet encryption failed"), tr("Wallet encryption failed due to an internal error. Your wallet was not encrypted.")); } QDialog::accept(); // Success } else { QMessageBox::critical(this, tr("Wallet encryption failed"), tr("The supplied passphrases do not match.")); } } else { QDialog::reject(); // Cancelled } } break; case Unlock: if(!model->setWalletLocked(false, oldpass)) { QMessageBox::critical(this, tr("Wallet unlock failed"), tr("The passphrase entered for the wallet decryption was incorrect.")); } else { QDialog::accept(); // Success } break; case Decrypt: if(!model->setWalletEncrypted(false, oldpass)) { QMessageBox::critical(this, tr("Wallet decryption failed"), tr("The passphrase entered for the wallet decryption was incorrect.")); } else { QDialog::accept(); // Success } break; case ChangePass: if(newpass1 == newpass2) { if(model->changePassphrase(oldpass, newpass1)) { QMessageBox::information(this, tr("Wallet encrypted"), tr("Wallet passphrase was successfully changed.")); QDialog::accept(); // Success } else { QMessageBox::critical(this, tr("Wallet encryption failed"), tr("The passphrase entered for the wallet decryption was incorrect.")); } } else { QMessageBox::critical(this, tr("Wallet encryption failed"), tr("The supplied passphrases do not match.")); } break; } } void AskPassphraseDialog::textChanged() { // Validate input, set Ok button to enabled when acceptable bool acceptable = false; switch(mode) { case Encrypt: // New passphrase x2 acceptable = !ui->passEdit2->text().isEmpty() && !ui->passEdit3->text().isEmpty(); break; case Unlock: // Old passphrase x1 case Decrypt: acceptable = !ui->passEdit1->text().isEmpty(); break; case ChangePass: // Old passphrase x1, new passphrase x2 acceptable = !ui->passEdit1->text().isEmpty() && !ui->passEdit2->text().isEmpty() && !ui->passEdit3->text().isEmpty(); break; } ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(acceptable); } bool AskPassphraseDialog::event(QEvent *event) { // Detect Caps Lock key press. if (event->type() == QEvent::KeyPress) { QKeyEvent *ke = static_cast<QKeyEvent *>(event); if (ke->key() == Qt::Key_CapsLock) { fCapsLock = !fCapsLock; } if (fCapsLock) { ui->capsLabel->setText(tr("Warning: The Caps Lock key is on!")); } else { ui->capsLabel->clear(); } } return QWidget::event(event); } bool AskPassphraseDialog::eventFilter(QObject *object, QEvent *event) { /* Detect Caps Lock. * There is no good OS-independent way to check a key state in Qt, but we * can detect Caps Lock by checking for the following condition: * Shift key is down and the result is a lower case character, or * Shift key is not down and the result is an upper case character. */ if (event->type() == QEvent::KeyPress) { QKeyEvent *ke = static_cast<QKeyEvent *>(event); QString str = ke->text(); if (str.length() != 0) { const QChar *psz = str.unicode(); bool fShift = (ke->modifiers() & Qt::ShiftModifier) != 0; if ((fShift && psz->isLower()) || (!fShift && psz->isUpper())) { fCapsLock = true; ui->capsLabel->setText(tr("Warning: The Caps Lock key is on!")); } else if (psz->isLetter()) { fCapsLock = false; ui->capsLabel->clear(); } } } return QDialog::eventFilter(object, event); }
4e966a908401a5ae5bbcd4e340f7cdc34b58172f
86a70b4a86a9751ea19c248c047c22546b743cc5
/include/cgi/cgi_serial.hpp
f9edf9bdf2db329720d01996a0842ba875fd24c6
[]
no_license
mkuhn/blast-matrix
05b9b8a274b5d8eaa220ec89df6741ffbc8c62d6
915ba9ac3a81549c53b314a059188c937993efd8
refs/heads/master
2020-12-22T10:51:47.040589
2012-10-24T09:14:24
2012-10-24T09:14:24
236,756,103
1
0
null
null
null
null
UTF-8
C++
false
false
7,814
hpp
#ifndef CGI___CGI_SERIAL__HPP #define CGI___CGI_SERIAL__HPP /* $Id: cgi_serial.hpp 143697 2008-10-21 19:34:42Z grichenk $ * =========================================================================== * * PUBLIC DOMAIN NOTICE * National Center for Biotechnology Information * * This software/database is a "United States Government Work" under the * terms of the United States Copyright Act. It was written as part of * the author's official duties as a United States Government employee and * thus cannot be copyrighted. This software/database is freely available * to the public for use. The National Library of Medicine and the U.S. * Government have not placed any restriction on its use or reproduction. * * Although all reasonable efforts have been taken to ensure the accuracy * and reliability of the software and data, the NLM and the U.S. * Government do not and cannot warrant the performance or results that * may be obtained by using this software or data. The NLM and the U.S. * Government disclaim all warranties, express or implied, including * warranties of performance, merchantability or fitness for any particular * purpose. * * Please cite the author in any work or product based on this material. * * =========================================================================== * * Author: Maxim Didneko * */ /// @file cont_serial.hpp #include <corelib/ncbistd.hpp> #include <corelib/ncbistre.hpp> #include <corelib/ncbistr.hpp> #include <cgi/ncbicgi.hpp> #include <vector> BEGIN_NCBI_SCOPE /////////////////////////////////////////////////////// /// /// template<typename TElem> CContElemConverter /// /// The helper class for storing/retrieving a call to/from a string /// template<typename TElem> class CContElemConverter { public: static TElem FromString(const string& str) { return TElem(str); } static string ToString (const TElem& elem) { return string(elem); } }; /////////////////////////////////////////////////////// /// /// template<> CContElemConverter<string> /// /// The specialization of CContElemConverter for the string class. /// template<> class CContElemConverter<string> { public: static const string& FromString(const string& str) { return str; } static const string& ToString (const string& str) { return str; } }; /////////////////////////////////////////////////////// /// /// template<> CContElemConverter<CCgiEntry> /// /// The specialization of CContElemConverter for the CCgiEntry class. /// template<> class NCBI_XCGI_EXPORT CContElemConverter<CCgiEntry> { public: static CCgiEntry FromString(const string& str); static string ToString (const CCgiEntry& elem); }; /////////////////////////////////////////////////////// /// /// COStreamHelper /// /// The helper class for storing a data into to a stream /// in the form /// data_size data /// class COStreamHelper { public: COStreamHelper(CNcbiOstream& os) : m_Ostream(os), m_str(NULL) {} ~COStreamHelper() { try { flush(); } catch (...) {} } operator CNcbiOstream&() { return x_GetStrm(); } template<typename T> COStreamHelper& operator<<(const T& t) { x_GetStrm() << t; return *this; } void flush(bool write_empty_data = false) { if (!m_str && !write_empty_data ) return; try { x_GetStrm() << ends; m_Ostream << m_str->pcount() << ' ' << m_str->str(); } catch (...) { x_Clear(); throw; } x_Clear(); } private: CNcbiOstream& x_GetStrm() { if (!m_str) m_str = new CNcbiOstrstream; return *m_str; } void x_Clear() { if (m_str) m_str->freeze(false); delete m_str; m_str = NULL; } CNcbiOstream& m_Ostream; CNcbiOstrstream* m_str; }; /////////////////////////////////////////////////////// /// /// Read a string from a stream. The string is following /// by its size /// inline string ReadStringFromStream(CNcbiIstream& is) { string str; if (!is.good() || is.eof()) return str; size_t size; is >> size; if (!is.good() || is.eof()) return str; if (size > 0) { AutoPtr<char, ArrayDeleter<char> > buf(new char[size]); is.read(buf.get(), size); size_t count = is.gcount(); if (count > 0) str.append(buf.get()+1, count-1); } return str; } /////////////////////////////////////////////////////// /// /// Write a map to a stream /// template<typename TMap> CNcbiOstream& WriteMap(CNcbiOstream& os, const TMap& cont) { typedef CContElemConverter<typename TMap::key_type> TKeyConverter; typedef CContElemConverter<typename TMap::mapped_type> TValueConverter; COStreamHelper ostr(os); ITERATE(typename TMap, it, cont) { if (it != cont.begin()) ostr << '&'; ostr << NStr::URLEncode(TKeyConverter::ToString(it->first)) << '=' << NStr::URLEncode(TValueConverter::ToString(it->second)); } ostr.flush(true); return os; } /////////////////////////////////////////////////////// /// /// Read a map from a stream /// template<typename TMap> CNcbiIstream& ReadMap(CNcbiIstream& is, TMap& cont) { typedef CContElemConverter<typename TMap::key_type> TKeyConverter; typedef CContElemConverter<typename TMap::mapped_type> TValueConverter; string str = ReadStringFromStream(is); vector<string> pairs; NStr::Tokenize(str, "&", pairs); cont.clear(); ITERATE(vector<string>, it, pairs) { string key; string value; NStr::SplitInTwo(*it, "=", key, value); cont.insert(typename TMap::value_type( TKeyConverter::FromString(NStr::URLDecode(key)), TValueConverter::FromString(NStr::URLDecode(value))) ); } return is; } /////////////////////////////////////////////////////// /// /// Write a container to a stream /// template<typename TCont> CNcbiOstream& WriteContainer(CNcbiOstream& os, const TCont& cont) { typedef CContElemConverter<typename TCont::value_type> TValueConverter; COStreamHelper ostr(os); ITERATE(typename TCont, it, cont) { if (it != cont.begin()) ostr << '&'; ostr << NStr::URLEncode(TValueConverter::ToString(*it)); } ostr.flush(true); return os; } /////////////////////////////////////////////////////// /// /// Read a container from a stream /// template<typename TCont> CNcbiIstream& ReadContainer(CNcbiIstream& is, TCont& cont) { typedef CContElemConverter<typename TCont::value_type> TValueConverter; string str = ReadStringFromStream(is); vector<string> vstrings; NStr::Tokenize(str, "&", vstrings); cont.clear(); ITERATE(vector<string>, it, vstrings) { cont.push_back( TValueConverter::FromString(NStr::URLDecode(*it))); } return is; } /////////////////////////////////////////////////////// /// /// Write cgi cookeis to a stream /// NCBI_XCGI_EXPORT extern CNcbiOstream& WriteCgiCookies(CNcbiOstream& os, const CCgiCookies& cont); /////////////////////////////////////////////////////// /// /// Read cgi cookeis from a stream /// NCBI_XCGI_EXPORT extern CNcbiIstream& ReadCgiCookies(CNcbiIstream& is, CCgiCookies& cont); /////////////////////////////////////////////////////// /// /// Write an environment to a stream /// NCBI_XCGI_EXPORT extern CNcbiOstream& WriteEnvironment(CNcbiOstream& os, const CNcbiEnvironment& cont); /////////////////////////////////////////////////////// /// /// Write an environment from a stream /// NCBI_XCGI_EXPORT extern CNcbiIstream& ReadEnvironment(CNcbiIstream& is, CNcbiEnvironment& cont); END_NCBI_SCOPE #endif /* CGI___CGI_SERIAL__HPP */
[ "mkuhn@localhost" ]
mkuhn@localhost
07e4d90d892e7c4e58df63c74c2e920eb49f488f
f3393f5012b4040daea3ccde488bbe3604f8dabc
/foamfiles/counterFlowFlame2D/case_25/system/controlDict
e8239e6041f63c307b48b28d31c9f4d436930eb1
[ "MIT" ]
permissive
SoftwareDevEngResearch/StoveOpt
baa2c250ea3de010def3b9df090e7b716d31c08f
f40029aaaed9cba6526f8998a8e5512898d3b571
refs/heads/master
2020-05-14T22:13:16.605256
2019-06-15T10:59:31
2019-06-15T10:59:31
181,973,861
0
1
MIT
2019-06-16T21:17:56
2019-04-17T21:54:44
C++
UTF-8
C++
false
false
1,941
/*--------------------------------*- C++ -*----------------------------------*\ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org \\ / A nd | Version: 6 \\/ M anipulation | \*---------------------------------------------------------------------------*/ FoamFile { version 2.0; format ascii; class dictionary; location "system"; object controlDict; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // application reactingFoam; startFrom startTime; startTime 0; stopAt endTime; endTime 10; deltaT 1e-3; writeControl adjustableRunTime; writeInterval 0.5; purgeWrite 0; writeFormat ascii; writePrecision 6; writeCompression off; timeFormat general; timePrecision 6; runTimeModifiable true; adjustTimeStep yes; maxCo 0.4; functions { probes { // Where to load it from functionObjectLibs ( "libsampling.so" ); type probes; // Name of the directory for probe data name probes; // Write at same frequency as fields outputControl outputTime; outputInterval 1; // Fields to be probed fields ( T //-Fields you want to see ); probeLocations ( (0.0 -0.07 0.5) (0.0 -0.04 0.5) (0.0 -0.07 0.3) (0 -0.07 0.33) (0 -0.04 0.3) (0.0 -0.04 0.33) (0 0.0 0.33) (0.0 0.0 0.3) (0 0.1 0.33) (0.0 0.1 0.3) (0 0.14 0.3) (0.0 0.14 0.33) (0.0 0.17 0.3) (0 0.17 0.33) (0.0 0.14 0.5) (0.0 0.14 0.33) );
bdde7b05bf3fea066a82dd79e280d3b375e1106c
717a4b78bd60186cca1c814b381d1cc401c6ea05
/imageCompareApp/textedit.cpp
3d04ca57571313bfac804c0a717f6f10f467110d
[]
no_license
flegall2014/ImageCompare
2e521b5b146e00c554c9ea457af63cd2a9312f46
4f521178b2889364b0f6763949b34de5d15c81dd
refs/heads/master
2021-01-10T11:43:10.211390
2016-03-13T18:38:28
2016-03-13T18:38:28
53,799,426
0
0
null
null
null
null
UTF-8
C++
false
false
6,213
cpp
#include "textedit.h" TextEdit::TextEdit(QWidget *parent) : QPlainTextEdit(parent), c(0) { lineNumberArea = new LineNumberArea(this); connect(this, SIGNAL(blockCountChanged(int)), this, SLOT(updateLineNumberAreaWidth(int))); connect(this, SIGNAL(updateRequest(QRect,int)), this, SLOT(updateLineNumberArea(QRect,int))); connect(this, SIGNAL(cursorPositionChanged()), this, SLOT(highlightCurrentLine())); updateLineNumberAreaWidth(0); highlightCurrentLine(); } TextEdit::~TextEdit() { delete lineNumberArea; } void TextEdit::setCompleter(QCompleter *completer) { if (c) QObject::disconnect(c, 0, this, 0); c = completer; if (!c) return; c->setWidget(this); c->setCompletionMode(QCompleter::PopupCompletion); c->setCaseSensitivity(Qt::CaseInsensitive); QObject::connect(c, SIGNAL(activated(QString)), this, SLOT(insertCompletion(QString))); } QCompleter *TextEdit::completer() const { return c; } void TextEdit::insertCompletion(const QString& completion) { if (c->widget() != this) return; QTextCursor tc = textCursor(); int extra = completion.length() - c->completionPrefix().length(); tc.movePosition(QTextCursor::Left); tc.movePosition(QTextCursor::EndOfWord); tc.insertText(completion.right(extra)); setTextCursor(tc); } QString TextEdit::textUnderCursor() const { QTextCursor tc = textCursor(); tc.select(QTextCursor::WordUnderCursor); return tc.selectedText(); } void TextEdit::focusInEvent(QFocusEvent *e) { if (c) c->setWidget(this); QPlainTextEdit::focusInEvent(e); } void TextEdit::keyPressEvent(QKeyEvent *e) { if (c && c->popup()->isVisible()) { // The following keys are forwarded by the completer to the widget switch (e->key()) { case Qt::Key_Enter: case Qt::Key_Return: case Qt::Key_Escape: case Qt::Key_Tab: case Qt::Key_Backtab: e->ignore(); return; // let the completer do default behavior default: break; } } bool isShortcut = ((e->modifiers() & Qt::ControlModifier) && e->key() == Qt::Key_Space); // CTRL+E if (!c || !isShortcut) // do not process the shortcut when we have a completer QPlainTextEdit::keyPressEvent(e); const bool ctrlOrShift = e->modifiers() & (Qt::ControlModifier | Qt::ShiftModifier); if (!c || (ctrlOrShift && e->text().isEmpty())) return; static QString eow("~!@#$%^&*()_+{}|:\"<>?,./;'[]\\-="); // end of word bool hasModifier = (e->modifiers() != Qt::NoModifier) && !ctrlOrShift; QString completionPrefix = textUnderCursor(); if (!isShortcut && (hasModifier || e->text().isEmpty()|| completionPrefix.length() < 3 || eow.contains(e->text().right(1)))) { c->popup()->hide(); return; } if (completionPrefix != c->completionPrefix()) { c->setCompletionPrefix(completionPrefix); c->popup()->setCurrentIndex(c->completionModel()->index(0, 0)); } QRect cr = cursorRect(); cr.setWidth(c->popup()->sizeHintForColumn(0) + c->popup()->verticalScrollBar()->sizeHint().width()); c->complete(cr); // popup it up! } int TextEdit::lineNumberAreaWidth() { int digits = 1; int max = qMax(1, blockCount()); while (max >= 10) { max /= 10; ++digits; } int space = 3 + fontMetrics().width(QLatin1Char('9')) * digits; return space; } void TextEdit::updateLineNumberAreaWidth(int /* newBlockCount */) { setViewportMargins(lineNumberAreaWidth(), 0, 0, 0); } void TextEdit::updateLineNumberArea(const QRect &rect, int dy) { if (dy) lineNumberArea->scroll(0, dy); else lineNumberArea->update(0, rect.y(), lineNumberArea->width(), rect.height()); if (rect.contains(viewport()->rect())) updateLineNumberAreaWidth(0); } void TextEdit::findText(const QString key) { QList<QTextEdit::ExtraSelection> extraSelections; this->moveCursor(QTextCursor::Start); while ( this->find(key) ) { QTextEdit::ExtraSelection extra; extra.cursor = this->textCursor(); extra.format.setFontUnderline(true); extra.format.setBackground(QBrush(Qt::green)); extraSelections.append(extra); } QTextCursor textCursor = this->textCursor(); textCursor.clearSelection(); this->setTextCursor(textCursor); this->setExtraSelections(extraSelections); } void TextEdit::resizeEvent(QResizeEvent *e) { QPlainTextEdit::resizeEvent(e); QRect cr = contentsRect(); lineNumberArea->setGeometry(QRect(cr.left(), cr.top(), lineNumberAreaWidth(), cr.height())); } void TextEdit::highlightCurrentLine() { QList<QTextEdit::ExtraSelection> extraSelections; if (!isReadOnly()) { QTextEdit::ExtraSelection selection; QColor lineColor = QColor(Qt::yellow).lighter(160); selection.format.setBackground(lineColor); selection.format.setProperty(QTextFormat::FullWidthSelection, true); selection.cursor = textCursor(); selection.cursor.clearSelection(); extraSelections.append(selection); } setExtraSelections(extraSelections); } void TextEdit::lineNumberAreaPaintEvent(QPaintEvent *event) { QPainter painter(lineNumberArea); painter.fillRect(event->rect(), Qt::lightGray); QTextBlock block = firstVisibleBlock(); int blockNumber = block.blockNumber(); int top = (int) blockBoundingGeometry(block).translated(contentOffset()).top(); int bottom = top + (int) blockBoundingRect(block).height(); while (block.isValid() && top <= event->rect().bottom()) { if (block.isVisible() && bottom >= event->rect().top()) { QString number = QString::number(blockNumber + 1); painter.setPen(Qt::black); painter.drawText(0, top, lineNumberArea->width(), fontMetrics().height(), Qt::AlignRight, number); } block = block.next(); top = bottom; bottom = top + (int) blockBoundingRect(block).height(); ++blockNumber; } }
6fc887f7e67a2c4970a79d59df61f1ef91ad8b69
00d1068f924ac403873b012712bc53b7d4ff414d
/Exercise1/main.cpp
5b3f93fb3b3bae1c79c3bddd2366736022e5f6b8
[]
no_license
philip-long/cpp_formation
6e7ddfd6d4a6edab41e1298ac534b7f5c53c448b
7a15528ca0b261b9a6b28e01b7bd6c8048e6fd11
refs/heads/master
2021-01-13T16:35:16.604355
2018-07-19T18:01:06
2018-07-19T18:01:06
79,135,263
0
0
null
null
null
null
UTF-8
C++
false
false
455
cpp
#include <iostream> #include "Date.h" #include "Operation.h" #include "Compte.h" using namespace std; int main(int argc, char *argv[]) { /* Operation o(100); cout << o.toString() << endl; Operation o2(1000, Operation::typeOperation::debit); cout << o2.toString() << endl; */ Compte *c1 = new Compte(100); c1->editerReleve(); c1->crediter(100); c1->debiter(62); c1->debiter(6); c1->editerReleve(); delete c1; }
86fc9d1dd9b7865fd2229ea6342d9cc1103dbd98
9f520bcbde8a70e14d5870fd9a88c0989a8fcd61
/pitzDaily/545/alphak
54511d4958d12c5400135062a6776e91bda3ac9a
[]
no_license
asAmrita/adjoinShapOptimization
6d47c89fb14d090941da706bd7c39004f515cfea
079cbec87529be37f81cca3ea8b28c50b9ceb8c5
refs/heads/master
2020-08-06T21:32:45.429939
2019-10-06T09:58:20
2019-10-06T09:58:20
213,144,901
1
0
null
null
null
null
UTF-8
C++
false
false
68,573
/*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | | \\ / O peration | Version: v1806 | | \\ / A nd | Web: www.OpenFOAM.com | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ FoamFile { version 2.0; format ascii; class volScalarField; location "545"; object alphak; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // dimensions [0 0 -1 0 0 0 0]; internalField nonuniform List<scalar> 6400 ( 0.877667409366 1.38699956879 2.18507594355 2.68503243269 3.16490192392 3.65330925684 4.3011278086 5.03212978305 5.40587880297 6.00876673098 7.22268647254 8.02034876488 8.67643385596 9.42968729946 10.3850450855 11.3837255046 12.2525264917 13.0687128244 13.755733288 14.1318550044 14.2681852131 14.5148290638 15.087965978 15.9830476977 16.97440895 17.8549779569 18.558421957 19.2033370027 19.8977765043 20.6564167496 21.4242597338 21.9947806864 22.2917239604 22.4465339029 22.4941679712 22.412261162 22.506784124 22.8636570023 22.8734069949 22.6397465191 22.8052401631 23.5106010875 24.230153106 24.6026794731 24.6872038266 24.5744976013 24.3336225938 24.0142647563 23.6292543751 23.1987993099 22.6234207486 21.6519811041 20.3900606322 18.8893253348 17.639926546 16.7341156421 15.3783983963 13.2029073244 10.8899992658 9.19776085398 7.43002222812 5.59675944154 3.67956502071 4.57864101182 8.54304722062 13.4748600357 16.4742312213 16.1985385977 14.2375094655 12.6648552411 11.8438522263 12.0890046735 12.6652545688 12.570199574 14.6367195145 14.085905229 15.965573923 9.86816702913 12.868648474 4.81077462837 3.13865483505 2.49809973984 3.10125453724 4.34696140028 4.22787785109 4.09342024384 4.28999920163 4.71695701442 5.33035202265 6.11504670956 7.06860980768 8.01918441753 8.85333017005 9.65061564402 10.4606818208 11.3900248633 12.3653842112 13.3018140615 14.3170441711 14.5132279157 14.4427507314 14.6491668835 15.1791559069 16.0533594307 17.1945858572 18.0061402418 18.6738499698 19.3635036139 20.0769828625 20.803209108 21.5359716675 22.2147556903 22.5078107972 22.6605698246 22.7497102205 22.5562493004 22.71178468 23.0917150258 23.0355913826 22.6310237326 22.7596647973 24.1746544699 25.2822641479 25.5439349658 25.5573075632 25.3365926224 24.9559243339 24.5385999775 23.9410261508 23.3038548071 22.8190636803 22.520319444 21.5326252574 19.1144387516 18.019520259 16.82333964 14.716818401 12.6033681727 10.596858198 8.6232046213 6.8415936024 5.98179012229 4.08743768072 4.9804837894 8.66445277984 14.5150065158 18.2774266897 17.0201793842 14.8803024423 12.9944757652 12.3406688781 12.8016591295 13.9359334694 13.3815627244 13.2501217494 12.7394386548 11.551348741 9.7181988454 8.17159907157 4.25665488697 3.21114505694 2.81044534057 3.32268225001 3.58370379232 4.08858075312 4.51133814213 4.49246951471 4.6264667844 5.23737959513 6.09335775108 7.05258168693 8.02292233089 8.90491072845 9.70791575061 10.3730448983 11.2113097994 13.8868629244 15.9006114087 16.2909786763 15.6477407883 14.2519026212 14.2869736346 15.3155642019 16.2446978291 17.1023476802 17.9936839488 18.7825363351 19.4751503705 20.1674501068 20.8939375475 21.5865227176 22.3710855864 22.6688600487 22.5502391773 23.0267586849 22.8477847288 22.6097450204 23.2302011009 23.2086984127 22.8556341722 22.9966933139 23.6960628069 24.4046974976 24.7831695072 24.8925725371 24.8231365606 24.6157994098 24.2914360294 23.852730972 23.3236575231 22.7071299958 21.8915597568 20.7497926931 19.5786310263 18.4474617357 16.6610492252 14.6223034243 12.6071125726 10.6435006093 8.78426427665 7.17761800301 5.67495765148 4.66968653912 6.29714523223 11.0312476409 15.5074843888 17.7099276747 17.8437219286 16.2893142998 14.6590627272 14.016256664 13.9630244676 13.3348705613 12.7666934819 12.7583055453 12.4263756308 11.4513826121 9.83193913455 7.40006131676 7.58156769099 3.1940468682 5.4823064867 3.6178608805 3.72278386016 4.40872730467 11.8526251871 10.2315383672 5.21754651291 5.21601227261 6.09617998992 7.0774363041 8.06577615805 8.92336644106 9.75419486656 11.4796952253 13.5984947988 15.2647645548 15.6533622591 14.5416260515 13.6880694281 13.9890085679 14.5407550164 15.276586253 16.2111922573 17.1925753565 18.1229110267 18.9437523188 19.6110334532 20.331154908 20.9734202484 21.8248496937 22.3586940679 22.9978805202 22.8949111288 22.5170700558 22.9520341643 22.8123509128 22.6906696506 22.8679570731 23.0355691834 23.3256984056 23.8664238335 24.4384650582 24.8120578308 24.9610426244 24.9285038334 24.749651794 24.4464849241 24.0286950578 23.5048108087 22.86134082 22.0427727621 21.0134375203 19.836267023 18.4483628388 16.7022037878 14.7174929892 12.7163014498 10.8115343255 9.09268877766 7.66691193971 6.63001199869 6.4008071651 7.5301853261 10.4320245376 15.9080936804 19.4134590487 19.6023036925 17.9599355988 15.63141886 14.0651074884 13.3186329958 13.5191980528 14.9361475992 14.8791021114 13.5612171112 13.4185933631 16.7000323244 13.1068618137 11.1282970444 5.62394152251 7.53904409343 4.34935081521 4.66691115685 6.5364897263 11.7433760925 8.16901706908 5.64686719601 5.73675624383 6.31986220489 7.22444145944 8.22845829374 9.64638559546 11.967702627 12.9911786685 13.3660396619 13.3583297303 13.1255831708 13.1901765166 13.7412717097 14.1247247558 14.5822532283 15.3688918953 16.3184587396 17.3202471336 18.2863964807 19.0706593976 19.8831353208 20.4503525422 21.3204070248 21.8638843102 23.0698345469 22.9207157345 22.4919622311 22.6689273901 22.4008547776 22.4848986842 22.7280011119 22.999209389 23.2625509288 23.5915247909 24.0506257014 24.5338486805 24.8903802263 25.0642154716 25.063586488 24.912904898 24.6339433385 24.2393402527 23.7312557117 23.09311941 22.291789041 21.3051472934 20.1217854854 18.6650437877 16.886461466 14.926826404 12.9940746745 11.2324725835 9.75683598752 8.67938069273 8.12292253929 8.30963389421 8.71020601818 10.6199894376 15.4067059321 19.4869670324 20.9053946369 19.7598728335 17.0178433043 14.5699837485 14.2770971223 16.5444370238 17.4186922226 16.3828321314 15.4657368466 18.111418763 21.1178613671 16.4378702049 15.5544544592 9.92425915925 9.08409408688 5.41510401494 5.99442802725 12.0235509843 11.4900273625 6.50860256505 6.22903813268 6.35544580697 6.66965106751 7.48036362791 10.1310284518 13.3690542734 13.8005298009 13.4394154669 12.498560654 12.1084701852 12.4368050085 13.3660251684 13.7211312318 14.006604982 14.6522653373 15.5183012741 16.5057137502 17.4339592721 18.413357013 19.4819692952 19.9889080846 21.0339977965 21.3652071627 22.8368238581 22.8290950882 23.6476083316 22.7636368294 22.0309119427 22.095967406 22.4604688858 22.8424487424 23.181882916 23.4956971336 23.8449525674 24.2630336549 24.6901788384 25.0272378471 25.2138944559 25.2386607005 25.1148320739 24.8630541108 24.49778892 24.0187715281 23.408579392 22.6384737169 21.6759385689 20.4764633249 18.9836550029 17.2196387837 15.3473232172 13.5667260124 12.025049743 10.8395807323 10.0900044339 9.91933488517 10.5615049661 9.69583705004 12.3927090094 17.2891456471 20.7787306005 22.1689304602 21.2722667882 17.925729171 15.7587920908 17.5737305985 19.7845273042 19.265227905 18.2690837968 18.3430009728 22.893671634 24.4709080061 19.4752842647 19.275995444 12.0362506178 8.90728842414 6.58557823915 6.17685604377 11.9568807413 8.32786199841 6.70030987079 6.81043377248 6.92903572381 7.61620779924 8.09065509992 13.1318863363 13.8017265374 13.8309303782 12.4601136197 11.4288673413 11.685879355 13.00890438 13.3461306523 13.4155124557 14.023053046 14.7694579735 15.6375695252 16.6229371501 17.7565707182 18.8471620745 19.5068965563 20.8885149267 21.1019901991 22.7069834429 22.5451838257 23.602513915 23.0509282654 22.5123924462 21.8283110076 22.0276165173 22.532640799 23.0006141628 23.3835044795 23.7316708467 24.0994516601 24.5004913187 24.8957540519 25.2174780593 25.4112903744 25.4562468122 25.3590654701 25.1397484896 24.8133618567 24.3775170196 23.8115806775 23.0816021659 22.1427432406 20.9448350501 19.4664735976 17.7824432376 16.0697003917 14.5085462062 13.2050952137 12.2078966621 11.6111959654 11.4571376464 11.2737948205 11.2854121934 13.8427968796 19.8837506734 22.171953597 22.5092555539 21.4656960426 19.217053537 18.9709821812 21.5325502032 21.974174062 21.1416186619 20.5564163284 22.5191781794 25.2510152989 26.701181186 22.1232632509 20.9858735226 11.7354716392 8.52471291289 7.71490787722 12.1008357138 12.043055033 7.29924811677 7.33930863758 7.47666222281 7.58273601347 8.14247534429 12.8977810212 13.8299511521 13.8990581724 13.3981020737 11.2553614323 10.9925893543 12.5640982546 13.1626610717 12.9661853802 13.2901612502 14.0699722343 14.9573809441 15.8519551374 16.8964646661 17.8581677857 19.2269921895 19.6124612356 20.9023163579 22.4433722145 22.8399385227 22.2220612342 23.0458193805 23.1490968429 21.9013576823 21.8041319594 22.1698639706 22.6772340446 23.1718316567 23.5946343077 23.9763484385 24.3637419214 24.7638814118 25.1448172276 25.4570658055 25.655794877 25.718595731 25.6501330069 25.470413692 25.193920521 24.8152499455 24.3086910545 23.6324325774 22.7348644166 21.5771828375 20.1783044132 18.6498830575 17.1570127708 15.810970236 14.6229851525 13.6294620277 13.0001559869 12.7636824923 12.7589048144 13.1035072607 13.1899266717 19.9584036763 23.9462282522 23.9511005877 23.3702853795 22.433697988 23.2651383604 24.6221738769 23.9420411334 23.2651385737 23.4791250008 25.7954252612 26.454157922 27.0216442183 24.1428049196 22.0063782444 10.9887453146 8.41600269031 8.37641622134 13.0685009517 10.9810627876 7.88587115174 8.03124885555 8.29716733981 9.52698971595 8.23550043551 13.671595968 14.3407725023 13.9320632777 12.1304954111 10.8559249531 11.1323069686 12.6522886269 12.8658656592 12.8489734591 13.3186553564 14.0751234208 15.0484472466 16.0508951477 17.517781957 18.7577769428 19.1846546055 21.1291856249 20.7807465412 22.6613778619 22.2127636479 23.4670066905 22.3358553568 21.9310243734 21.8048514325 21.9732729719 22.367644808 22.8562784912 23.3573947987 23.8156502194 24.2352130092 24.646252245 25.0542133087 25.4331843574 25.7430270694 25.9470004563 26.0279006126 25.9927134361 25.8612367061 25.6461116404 25.3390010176 24.9091761299 24.3083892084 23.4857394203 22.424116052 21.1795759006 19.8753313452 18.615240084 17.3785275402 16.099334533 14.976908077 14.4057685974 14.4728686061 14.79254399 14.9901127731 14.8200561237 16.5594029727 24.0813116363 25.7564714645 25.7514769139 26.3846786311 27.4260602086 27.0621538465 26.0469830779 25.8528487218 26.8446180435 28.0229385487 27.8504753431 27.2200598302 26.1930687528 24.8187629776 10.4213755616 8.82750237183 9.53296453521 13.1272829307 8.96043833829 8.89981524332 8.72925968464 8.99054702817 12.1373504265 10.843310451 14.5057334564 14.6018762982 13.9911456921 11.409963913 10.8772838064 12.4905867879 12.8921687422 12.6127458658 12.8168858252 13.4793399297 14.2096744441 15.1278288103 15.9902926407 17.6845273249 19.8360936513 19.1255897213 21.0792944528 22.3287991717 22.9111482677 23.469175471 22.6555084902 22.6255477004 21.6195005297 21.712574982 22.1394141246 22.5859369479 23.0614096822 23.5599535834 24.0459086661 24.5070061449 24.9506373751 25.3748870704 25.7595771638 26.0731144095 26.2859151217 26.3872976507 26.3905093199 26.3167374665 26.1753562043 25.9550815575 25.6226709708 25.1277614266 24.4273812615 23.5307451305 22.5186479398 21.4822136489 20.3828781969 19.028201084 17.5095238226 16.4416871285 16.3039245405 16.8761676654 17.3956129559 17.5143427398 17.2031492179 15.8915819025 15.9556870997 27.451378505 30.2810246164 31.2398866116 31.0445794247 29.5784208363 28.6423394667 28.9272826801 30.0778314187 30.3939993142 30.1171892665 29.7944400198 30.118134542 30.2945812665 10.3633261065 9.64527272727 12.9718721429 13.2665021203 9.02956070579 9.64839841207 9.42096679712 9.92377961804 11.6109892648 14.3624916674 15.3188661047 14.8562221193 14.2134547446 11.3951699707 11.0283346377 13.0178507816 12.9871158285 12.5833536508 12.8453289382 13.6204310725 14.5849467112 15.4895569574 16.180291124 17.3135744805 20.010672082 21.191352254 20.6760734167 22.4632936565 21.7127059619 23.5033152694 23.7766160793 22.5657636614 21.5816754532 21.8243656337 22.3371435731 22.8153994812 23.2906905657 23.7867269254 24.2886463392 24.7894517881 25.2759693549 25.7268928057 26.1244223012 26.4468443545 26.6728796172 26.800068539 26.8484085242 26.8406395591 26.7840657468 26.6662810732 26.4549443278 26.1036279352 25.584858403 24.933565124 24.2254206309 23.4351694966 22.274490343 20.5992031003 19.1342233652 18.6058375311 19.2440924388 20.3522221735 20.9936773517 21.014516389 20.3703032314 18.7954694026 16.3767300382 17.3024542461 31.6314366665 36.8469629481 35.428711364 32.9185593065 32.0463781895 32.5296664861 33.3174607852 33.6340437931 33.8968555321 34.3632203517 34.9484176871 35.6070244539 10.6846309546 10.499252543 14.6040770988 13.9472793627 12.0121727217 10.8592106363 10.334409811 11.3879335551 11.0499763998 15.3220608473 15.9527073464 15.1826195044 14.2756392337 11.9912298627 11.7910937703 13.4872700917 13.001270671 12.6623348779 12.9652119786 13.6673905981 14.7392321879 15.950498959 17.6643660956 17.4575572161 19.5059781874 21.5759487722 20.5531259061 22.7386225531 23.5191888375 22.6398434806 22.8169254124 21.8596747723 21.8794254114 22.1558212672 22.5922146357 23.0696924196 23.5501782369 24.0475960245 24.5521997696 25.0776241441 25.6148555763 26.1117404926 26.5307736911 26.8646915062 27.108945208 27.2693910569 27.3703826148 27.4354033451 27.4716611447 27.4692873579 27.4016407405 27.2367661569 26.972550934 26.6528143918 26.2761913922 25.5541411904 24.0525370383 22.3666794831 21.6014154842 22.0382327205 23.6453210066 25.1735859985 25.8908208292 25.9401159601 25.2166402449 23.3828431325 20.2272205065 15.9082177854 26.5281957134 37.4514626363 40.3438569476 37.4409525497 36.6114100493 37.0190960778 37.6380767864 37.9960809113 38.8828121142 39.5959848973 39.544075748 39.7487970939 11.2654838424 11.1379119891 14.3323520374 14.4157145307 14.4193195637 11.9741043361 11.3803730176 14.2690175733 11.3937995572 16.1791416447 16.4356652514 15.5198468669 14.3407275562 12.5850563646 14.4510167273 14.5484712689 13.1777205487 12.8772740499 13.2179673867 13.8152781547 14.7038123746 15.9388958715 18.9761530799 19.9186790728 18.9782811771 21.6529476668 22.5646388365 22.3006048949 23.4905684854 23.8048195633 23.1862895465 21.8880565275 22.0856767465 22.4907134159 22.9026245804 23.3561988046 23.8264879905 24.3399875287 24.8665176577 25.3962458586 25.9610236998 26.513099847 26.9760654698 27.3307781955 27.5968041661 27.7978888202 27.9596047862 28.1017614053 28.2326406951 28.3499098542 28.4426627123 28.5108563911 28.5833645185 28.6640027714 28.5334628557 27.5401887978 25.8569871851 25.3618377837 26.2226122854 27.9623645207 30.4240553376 31.9933522107 32.1207109337 31.8612959203 30.260722682 27.6630420957 24.3258603576 17.787015459 18.378975557 32.5745453608 39.7736554705 40.891754911 39.4608411734 40.6215554739 41.7717542034 43.2502303851 44.5548309452 45.0770739706 45.0572951354 45.2431353138 11.9059795349 11.8246728644 11.4811758669 14.728901468 14.9364638969 12.7217880679 12.3242948531 15.238090978 12.0277958311 17.05973991 16.8686735907 15.8708789372 14.5186533664 12.8844645856 15.6144345645 15.0966669583 13.5934970724 13.2652946602 13.5669993859 14.1328917522 14.7937739361 15.8376838771 19.5031651103 20.9902202229 19.3229124111 21.7067811256 23.0944672195 21.7554905444 23.1246054171 23.3380681307 22.1046288755 22.2432178514 22.5380954505 22.8760359339 23.244817174 23.696861489 24.1598274244 24.6411423356 25.1931414575 25.7659480049 26.3482962504 26.9331567678 27.4455693678 27.8394705925 28.1392396102 28.3896881492 28.6182061253 28.8352307377 29.053373487 29.2827608427 29.5363142407 29.8825378319 30.3751592924 30.8833886447 30.6989996141 29.1667262554 28.4535039466 27.0083936607 25.38990509 25.0959988244 24.5029733693 20.7239493451 12.1217003845 4.49564534959 0.35675607923 0.1004909897 1.1828545601 10.946540183 20.5071748961 21.5901282505 44.4449585069 48.8115368106 48.220375063 43.7257873045 40.7331265704 43.9781180087 49.1528256902 50.4938845045 51.8509030797 52.363323619 12.7259130256 12.8139915111 15.3613439904 15.355246684 15.3666568789 13.3569230916 13.3552957381 16.0639869708 13.026664193 17.8185664955 17.2796666505 16.2437902282 14.7768519913 13.2666695654 15.8862046153 15.2692818973 14.0085322649 13.7096382447 13.9478839738 14.4483615235 15.0507724951 15.8713570419 18.8897215818 21.8066888854 21.9394196325 21.0601566074 23.313126665 24.0671796984 21.9058070772 21.7399551019 22.0413934789 22.4810873913 22.8917692761 23.2610938015 23.6466353973 24.0618312056 24.5228816478 25.0189128156 25.5442320207 26.1483056363 26.7796894488 27.3954862204 27.943003496 28.3802013196 28.7318644452 29.0447784987 29.3447328587 29.6369192093 29.9213870505 30.2175536135 30.6137842674 31.2717338354 32.2399352002 33.0577609305 32.3935996782 29.3610233892 21.3188245857 0.014942267086 1.64349442796e-05 3.08096452683e-07 5.22244600714e-09 1.51098320517e-11 4.29388444013e-14 7.43263269388e-19 5.81382734527e-19 1.41146358811e-18 9.51438053129e-18 4.45648272141e-17 1.64622694182e-16 1.04615149508e-15 8.19113267375e-16 7.1062529381e-14 4.04464530345e-11 4.06573158528e-09 3.08520346707e-07 7.10447807502e-05 1.19590722142 53.8783939363 58.0102669816 59.7547843057 13.4945326603 13.6844629862 16.9687741193 16.0018865352 15.4485443283 14.0013490696 14.3578586338 16.7538051221 16.7272783428 18.7578799532 17.7484918139 16.7069539686 15.1159393927 13.7951848922 16.1746755152 15.38412904 14.4116508875 14.1634714848 14.332114 14.7533179985 15.3271324117 16.1251585121 18.3560129698 22.0706845184 23.3215599945 20.7519590988 22.8509275417 24.1203440459 23.7877089147 22.2117079335 22.1429808135 22.7105714426 23.2556165758 23.6990273325 24.0334031765 24.4556528778 24.905305988 25.4167698315 25.9571530195 26.5639335111 27.2386328574 27.9042527717 28.4777825164 28.93941158 29.3520666865 29.7794307339 30.1907560964 30.5288826223 30.7757544449 31.07846148 31.6200975185 32.5543137933 33.9551622273 34.9411521354 28.5271393998 0.0221143979321 8.26293431964e-09 3.34608964296e-11 9.67634958861e-13 1.40869912483e-14 1.14453827028e-17 1.90977178683e-20 1.34620689711e-21 0 0 0 0 0 0 0 0 1.87234421835e-25 6.31502942874e-23 9.4459379857e-21 5.48023072152e-18 7.65453737682e-15 4.14512762469e-10 6.29487669663e-06 22.8993821528 62.0283818618 14.1222457666 14.3343294587 19.1327571017 16.497349308 15.2745849602 14.5749782251 15.0752331158 16.7805215082 18.3161286349 19.8416913643 18.3735585508 17.3027490046 15.7037523483 14.6203738721 16.6701929172 15.6546404455 14.8962382601 14.6686989129 14.7564324099 15.0948827012 15.5999154604 16.3405388578 18.1394138536 21.9476675352 24.3176418436 23.503478446 22.3245430555 23.4877248669 23.5059392246 22.1560807612 22.6019798815 23.2030062449 23.7977161633 24.1915040475 24.5419015117 24.8843434908 25.3467740816 25.8426633854 26.4066468573 27.0305229406 27.7210740321 28.4378787778 29.0868694395 29.5742311997 30.0352448038 30.5829169402 31.1180883525 31.464405169 31.6283748167 31.9009284265 32.5208412203 33.5329098037 35.0267971681 28.9477677942 5.47180673254e-05 1.19628347353e-11 3.92328892132e-15 1.58641600621e-16 2.16303046809e-18 5.93161739278e-21 0 0 0 0 0 0 0 0 0 0 0 0 0 2.41251531149e-24 2.39735862734e-23 5.25552954402e-22 2.54833360228e-20 1.41514812419e-16 1.1779177976e-07 2.27062668631e-12 14.6123533327 14.813249763 21.2033305239 16.8749626361 15.3668252827 15.1111970444 15.8795437188 16.0976282738 19.2683790266 20.6170518718 18.9827700032 17.9149361607 16.4945556259 16.5316270649 17.3629857973 16.1685525636 15.5784145371 15.3732098282 15.2893920037 15.5241226593 15.9259855845 16.5911189243 18.1177813371 21.8145330261 24.733758065 25.1605755713 22.0376682526 22.3522168881 22.170686361 22.2807867361 22.9085835005 23.7110473912 24.303981157 24.7236931569 25.0889778513 25.5144489087 25.8527708056 26.3370320367 26.8971083175 27.5185426326 28.274599952 29.0543168254 29.7444393685 30.1952851424 30.6579675275 31.8734769739 33.5412697516 34.0616194995 33.0993299549 33.0646692442 33.5943001947 34.5749064838 27.4312116797 6.33051818246e-06 9.54092016627e-11 4.28020679682e-22 4.32520199235e-19 7.05753770074e-21 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 3.7272605203e-23 2.52403926132e-22 4.65453766358e-20 93.844152603 15.046496034 15.2135264548 21.0230976734 16.2708517968 15.5540925264 15.5757764876 16.7949560572 16.0705248188 20.0712800445 21.3433036006 19.5668842069 18.4867831081 17.1062886619 18.7847711708 18.3355246729 16.8878798927 16.3656847738 16.4507217802 16.0459995484 16.1232724425 16.3520420192 16.8804105711 18.2399922384 21.6676808384 24.6066908093 26.2719992846 24.8417606455 23.7791741267 23.2302218731 22.5582499412 23.2237572909 24.3777600535 24.7501892653 25.2548717493 25.9041081392 26.1192287926 26.456732458 26.940206146 27.51083961 28.1295365733 28.8232776616 29.650433659 30.4776207891 31.3605340948 32.4545680661 34.0518663972 35.3133591441 35.1975234114 35.0266103149 35.5213186481 36.4557951647 31.6869044118 2.87887265783e-05 2.62783584543e-10 3.45382370026e-14 4.69095458587e-16 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1.14687205345e-22 8.34754978087e-12 15.5548941578 15.6999614087 20.6438549383 15.9166082121 15.8443863955 15.9547313068 17.5802767386 16.5258112145 20.763955897 22.0571861609 20.1518353073 19.0670496763 17.6240023802 19.5265110808 19.2377169894 17.6818869835 17.1412850292 17.3400719475 16.9544054008 16.945634277 16.982445409 17.2143003097 18.5235802692 21.6502956943 24.3341541187 26.6120417077 26.0580947635 24.2750715061 22.571603218 23.0832887614 23.7735186325 24.886400379 25.6612376782 26.2804764869 26.753145263 26.8275962685 27.1434139732 27.6409270077 28.2201951954 28.8655475888 29.5589646643 30.4603383797 31.6369692673 33.1970710048 34.2313191756 34.5393644892 35.1574058422 35.59650429 37.3098123114 39.438953528 38.0621673119 0.000262321283487 3.48312584983e-10 6.00647194884e-14 1.23195832848e-16 2.98280809356e-18 1.00122742883e-20 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1.92735705844e-23 2.5500694291e-23 16.3119780791 16.457703144 20.2932799963 16.1933439583 16.4088203601 16.4363653355 17.5655508044 17.2568574853 21.2570835191 22.7364328959 20.7747577901 19.7014486313 18.2679249296 20.2073904745 20.0564671604 18.5746621492 17.9827092282 18.2104865992 17.8396161271 17.9160343998 17.8947567783 17.7111601669 19.0026401189 21.8204027059 24.210531608 26.7138044286 26.6047440922 24.9689663616 23.0478364281 23.3174657973 24.4356375201 25.0235132202 25.6571497724 26.4996251318 27.7038204626 27.8774617646 28.1035875926 28.4461818832 28.9821989535 29.7053121136 30.5104400386 31.5425083877 33.5019157546 35.2784943814 35.4159605675 35.5164581935 36.5926500993 39.7180683979 43.811117411 42.4298444003 7.49460076609e-05 1.24498477468e-11 5.15203813282e-16 1.68918422038e-19 1.05987250973e-21 2.14827568486e-21 3.29894981898e-22 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1.42456616628e-24 6.46853636865e-24 17.4555731506 17.5588663986 20.5643236194 17.1404018224 17.5861665818 17.2956164298 17.8579134645 18.6002650156 21.2807556949 23.241971084 21.4652879817 20.4116065377 19.0235367289 20.9821289189 20.9047861772 19.6356063128 19.0163902906 19.2338136393 18.7328096332 18.9875832985 19.1302942563 18.4442296158 19.5471577531 22.177791344 24.2765026861 26.5749614484 26.8537139368 25.5956339081 25.1365868386 24.20588301 24.8727158463 25.9124607043 27.1619631633 27.1006262161 27.9179692515 28.9433856092 29.1684547185 29.5963326028 30.0167923758 30.6335874115 31.5826905372 33.5254682122 36.2708385518 37.1179497755 36.7999070786 37.8974182734 42.4115225533 49.1837826564 48.5258988864 2.69582068921e-06 1.88621913774e-13 1.76104275571e-18 1.20496350655e-20 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 19.0564141299 18.9192240754 21.3662488174 19.0595354942 19.5745850412 18.5715886947 18.7995148003 20.5500368529 21.4844259602 23.8584250682 22.2781917173 21.2083553217 19.8672231478 21.7949826381 21.7487865754 20.8074323358 20.5427399646 20.5762718137 19.7186251611 20.1604880035 20.6756862384 19.504982765 19.9704284496 22.6199306776 24.538587518 26.4478283724 27.0417746621 25.7455238564 26.3382718347 25.8271400122 25.9833708895 25.6036623639 26.8329317908 28.4022655732 28.8982102353 29.6605257799 30.2367138307 30.6853501372 31.270551063 31.9074272589 33.3962235535 36.6745843573 38.9598684147 39.2299495818 39.8472770175 43.7118944493 51.7483882856 51.2101473005 3.82396315346e-08 1.68329463658e-15 2.94275431165e-18 1.34744967822e-20 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 20.7564792495 20.2017783473 22.244156791 21.6117559531 21.3116745822 20.0596865041 19.8459636664 21.7041654014 20.6915086036 24.3388427264 23.1959790664 22.0842333874 20.7903249015 22.6229558668 22.5346355555 21.7873941526 22.6750318293 22.1994567739 20.832860381 21.4650860732 22.0456366724 20.8766459142 20.1244262822 22.6237094059 24.7312899639 26.3604499427 27.1212985041 25.8431830237 26.7327473258 27.1386914857 27.3479295368 26.4000600363 27.1295602909 28.3146409023 29.8570257241 30.9137463287 31.543651174 31.952962049 32.5103118797 33.6486241603 36.6841315001 40.2017440624 41.8799081132 42.7004035848 45.2637737861 51.1684181982 48.4699973546 14.3605023158 4.53241662322e-15 6.56162931557e-18 2.29800917117e-20 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 21.6103343927 21.1137561963 22.8152053344 22.6850147803 22.4039839897 21.4774883812 21.0654094567 23.1100339728 21.7542300504 24.9547726931 24.1251343642 23.0077804326 21.7880191841 23.484624896 23.3368137835 22.6144887567 23.6623238603 23.3255184145 21.928142671 22.7614137632 22.8055850371 21.7097973957 21.1919983135 21.4119927617 24.2584205387 25.8935664537 26.9354329573 25.843606693 26.8273130913 27.7047203 28.4677464387 28.2822132301 27.4654991352 28.3961542934 30.1252965405 31.8223074034 32.9693621492 33.6523219201 34.2238406039 36.7305823383 40.7405473674 43.7804364084 45.1868155509 46.8599247286 50.7703184039 44.5136542428 17.955103352 2.39440978869e-14 2.15688503929e-17 6.14292025588e-20 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 21.7354864446 21.706564754 23.1832166993 22.936622041 23.1167525095 22.5909727482 22.1382862996 24.4944350035 23.4747782963 25.7527622715 25.1161627347 23.9660315824 22.8554544581 24.3951525044 24.2126325511 23.5778806745 24.489371542 24.3151052496 23.0840992279 23.8132129824 22.6078442413 22.491202862 22.2638635315 22.5389619999 23.3849981532 24.3785104861 26.1368392419 25.6904635237 26.415928364 27.7710510327 28.9605809683 29.6770367294 29.0453901871 29.2233562211 30.3427908502 32.0073423377 33.8879993295 35.4305697868 36.8942277065 40.6932129158 44.6799309929 47.1098636919 48.0894433897 49.5658023134 43.7621168033 21.6658228982 1.62399451046e-13 7.49206035056e-17 1.67829160357e-19 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 22.0319343552 22.1447040773 23.5169788374 22.0936570976 23.4472731466 23.2271500874 22.8783197093 25.1442217036 24.3660791063 26.5781616822 26.1511780894 24.9312611123 24.0000487286 25.3419207587 25.1347677117 24.6777535688 25.4041684786 25.4149269622 24.3620954776 25.2445261452 23.9830807804 24.1615948839 23.5455562598 23.8502321023 25.227112653 25.85174635 25.8157157088 25.474260952 25.9837072291 27.7570941134 29.0096915036 29.9731093644 30.4587261394 30.3652777566 31.7643412581 32.7997161418 34.6590736429 37.1127684715 40.2473236135 44.7764240075 48.2622386205 49.7361503463 48.6153979461 43.9253497257 36.3848944662 20.7786320278 6.28678422546e-16 1.43121719191e-18 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 22.7866265906 22.8640188189 23.8755671939 22.5539930352 23.7452011178 23.602392842 23.4173202979 25.3941080126 25.0059355741 27.2048361292 27.1699544768 25.8452665168 25.2088449128 26.2810369886 26.0241079764 25.7473241936 26.2884686005 26.6009863459 25.6859665072 26.6848848459 25.7796565814 26.2538018187 26.0086488461 24.8509404587 25.988275122 26.9726878957 27.0941920134 25.3678406846 25.4881419315 27.704945707 29.2030923765 29.6717418746 30.3102803408 30.7618971594 32.1542983883 33.4852284063 35.5641835983 38.8509827116 43.7836173103 48.8706630539 51.548860695 51.2490818765 47.3473052323 39.6449948511 23.7883486209 7.14811926592e-15 9.97328404453e-18 4.04418885336e-20 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 23.7323720747 24.7511541317 24.3897139524 23.5707457486 24.3280400521 24.0392331024 23.9402988545 25.6175771528 25.5932691182 27.4910296942 28.1599910408 26.6697541234 26.2870650278 27.0609232631 26.8708574392 26.5688754849 26.6276781987 27.6851784851 27.0762244861 27.9478791914 27.7532249467 27.6125304145 27.4527364185 27.0638801858 26.3609020019 27.139745471 28.0865231145 24.9450954036 25.0599180203 27.079690857 29.2982985131 30.2909649105 31.1157844152 30.8665679076 32.096636958 33.8104341061 36.1421183756 40.4787446164 47.2694085322 52.7320414364 54.1814167659 49.2204805458 45.7461483598 40.3000128231 23.2369461812 6.75998239484e-17 1.72531010271e-19 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 24.4630656439 25.516570031 25.1428458117 24.4962748126 25.0711832925 24.6531857312 24.5320829923 25.9229906685 26.1646218405 27.519020286 29.0465160648 27.4641867177 26.9601431403 27.7142018203 27.7865568223 27.3203259872 26.9113030041 28.468413321 28.5010814382 29.0546269022 29.1156557818 29.2574355466 28.0664005485 28.0503978883 27.5957391225 28.7932119194 29.4668666416 26.8052921149 24.7281523952 26.1641188371 28.6932209416 30.5407683418 31.4262832554 31.5195702018 31.8656165637 33.7256835838 36.1953448075 41.7612411525 50.5637910202 56.6006417167 54.9770014443 48.3157633529 40.935350431 27.566916824 2.31772297145e-15 1.99320864379e-18 6.69831300388e-21 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 25.0103283474 25.9468470826 25.8012554863 25.1617527599 25.7962299384 25.3949103795 25.1982505585 26.3848680488 26.7798087271 27.1955250159 29.6713730178 28.3079164129 27.4560035854 27.7725465233 28.7144948182 28.2029431666 27.5395093783 29.1264701225 29.3154644029 29.9700553242 30.1355759835 30.556139978 30.6789331011 30.6465765431 30.2734939942 29.8615242101 30.8984451608 28.7421602192 24.9207413132 25.4213320201 27.0125303837 29.4362344979 31.2803816058 32.7364548849 32.5055034943 33.1484431599 35.4210033167 42.0020096717 53.5515199393 59.3573048001 54.3855496478 52.8165748839 44.1754458529 26.4391185616 2.85585115043e-17 7.80845181571e-20 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 25.5252249133 26.3392532263 26.3404812276 25.6436557455 26.4280325317 26.2154660732 25.8662833436 26.9500040454 27.5875912696 26.7821335231 30.0747613235 29.2401549863 28.1388628272 27.4763183121 29.5198179131 29.1478670519 28.4756183652 29.9483413928 29.9380502041 30.4466283436 31.1960262686 30.595094012 32.0794345822 32.5528251545 32.530563566 32.5254934344 32.8122245161 31.8177882513 27.121956145 25.2539415777 26.1795146302 27.6292432035 29.8301817242 31.4591423753 33.442497129 33.4327589085 34.4145007962 39.4810522814 57.2389557721 61.2060150489 50.3983208626 46.5415843344 41.5442111511 20.4538706854 9.68938815898e-19 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 26.0082231359 26.6957894675 26.4412578011 25.998253084 26.9462788763 26.965166604 26.4327900153 27.0779116309 28.6125963664 27.7787541455 30.3853340158 30.2403595093 29.0752743175 28.2481275389 30.3115568306 30.0909197693 29.695227632 31.0075217987 30.8706924614 30.4972554076 32.3291512567 32.0009617322 33.1677970338 33.6802851527 34.1157211642 34.6795306509 35.2203606754 35.2637037983 32.7449583206 26.8637238779 26.3241199558 27.2350539474 29.3850619356 30.471017187 32.2044806874 33.8002848835 34.5312020574 35.4168185023 54.5631209554 61.1742147102 55.2879873675 39.8451516743 29.7005074623 4.84747045686e-17 7.97694358396e-20 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 26.4315286382 26.9907831143 26.4400237962 26.493829342 27.4593168663 27.4589198563 26.9543111448 27.0712098062 29.1496454765 28.8207239652 30.3742934578 31.247267517 30.056284029 29.5365293609 31.1275328896 30.9860113842 31.0297841528 32.0125393703 32.1309283064 31.7219380497 33.3774821428 33.5567947058 34.3847720575 34.5489309573 35.7238116485 36.2855982504 37.4093205957 38.4490877375 38.9009554347 34.4682148139 28.5395780604 28.665756562 28.6147611984 30.7028551354 32.0835784359 33.2741531357 34.2427017937 34.4379857503 35.9777402991 54.61771949 60.4944877051 48.4468657517 30.3848355956 1.9838406426e-18 2.4299111601e-21 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 26.8663742535 27.0065386667 27.1926274533 27.6836996152 28.0746655355 27.9701601607 27.5709706687 27.5386846444 29.194344154 29.516870774 30.2244430447 32.0983123095 30.9402886631 30.5878645136 31.7033511005 31.8496007288 31.6875064755 32.6004829459 33.323967645 33.2699892887 34.3941299109 34.711296061 35.3816523985 36.2942892074 37.1282199212 37.078266351 38.8217344733 40.2545204039 41.8209307139 42.9011193037 37.8771126321 31.5270722799 30.5863863531 30.3981878551 31.0764140843 31.9884678081 32.7431744087 33.052987705 32.1024951258 35.8574452899 47.1356698762 45.2984234545 21.2097246823 1.48260155157e-19 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 27.3122021178 27.4062487431 28.7738258125 28.7141143334 28.5907979481 28.4504008841 28.2629410106 28.1945669343 29.4555032176 30.2682540842 29.7623632159 32.4649739249 31.8214720189 31.0559173 31.5469582147 32.7235287951 32.2278764384 32.1544165097 34.1385292875 34.115983525 35.0708259841 35.95309108 35.5279856642 37.6977392582 38.4380983785 39.4308637138 40.441055784 41.6733761119 43.4440076877 45.3904796616 46.5871617836 42.4903234856 37.4817947072 34.033837398 33.0810666849 33.1548868019 34.204610851 35.1040626547 35.269226444 36.9911044209 33.9519956796 33.47876973 7.21287672049e-18 1.87434432696e-20 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 5.68590062864e-25 27.6425322609 27.8396178641 28.0531342405 28.8237809154 28.8180205611 28.8139051903 28.905711171 28.7242900536 29.7823275714 30.9204652673 30.3099735572 32.2928196165 32.8767781514 31.7063518702 31.182464896 33.4058629808 33.0906294359 32.8253610992 34.7195293531 34.8807192014 34.8695221214 37.21396799 37.1021999733 38.5474874007 39.271636592 41.030313265 41.86956437 43.0945370884 44.8213166857 46.7165084648 48.5319365611 50.755564743 49.2779978732 46.4929073359 44.8046144477 44.5096690338 44.9379416219 45.7654418273 47.6959288853 55.3287359685 35.1035239708 35.5777911591 6.03888841045e-19 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1.42456616628e-24 27.8927473243 28.1228403224 27.996887865 28.8425045458 29.1859291243 29.1866823433 29.3261373116 29.0517968739 29.6013606279 31.1935471175 30.9720424202 31.7570591048 33.8569548553 32.6954229972 32.226576863 33.8056485508 34.0972370762 33.8773248314 35.1277689218 35.9968064529 36.0244419228 37.9089480048 38.3672877986 39.3073859286 40.7221666304 41.8599318613 43.1893621285 44.6797877434 46.0960189349 48.157055798 49.5943789807 52.542562289 54.5105128607 56.5186633172 56.013720432 56.1686595641 56.4288088563 58.5197808867 62.3772084122 66.8642840695 64.320413931 36.6616051849 8.1603681712e-20 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1.42456616628e-24 1.42456616628e-24 28.1770638825 28.4406584505 28.872316612 29.7152495476 29.8479987962 29.6038971011 29.5843333338 29.3002117901 29.5023374042 31.0430134742 31.639985233 30.9167086731 33.6992931394 33.8284793745 32.9249077828 33.4065189909 35.0311476309 34.598864567 34.7013177149 36.7582852727 36.9522653395 38.3498007007 39.5689099957 39.3768109464 41.6497556165 42.0950093448 44.574422282 45.551029132 46.8712106275 49.1643614382 51.0181133181 52.9640450655 54.9442963419 57.2147748199 58.6733265949 59.3086558434 60.3195791076 62.2126523675 64.1594998507 65.1144009629 62.6857967209 19.6997402328 1.13578899893e-20 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6.95277122598e-25 1.42456616628e-24 1.42456616628e-24 28.4442390229 28.6802594679 29.7030224436 30.7057389297 30.1823438412 29.8790810316 29.7817435916 29.5684902933 29.6238314486 30.9109088769 32.0396308609 31.7290469523 32.790226017 35.0075084586 33.7732760505 33.3759738394 35.5268006324 35.5464188464 35.3887738803 37.2147859339 37.85433844 38.1771031756 40.4629469777 40.7202915472 42.2829684425 43.5992294793 44.9952521003 46.1124784017 47.810107995 49.3685278223 51.2231818195 52.9322361901 54.6935749784 56.7254446581 58.483206886 59.7193203355 60.3944829371 60.641707098 59.7593141899 58.651106847 49.197658152 2.92995443434e-19 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 8.65578087219e-25 1.42456616628e-24 2.28396445934e-23 2.41000631789e-23 28.6669098229 28.8184372138 29.45716034 30.135770512 30.1555988202 29.9661933812 29.8874849377 29.8374342807 29.6979362645 30.4133576171 31.8585636199 32.4151978821 31.7685253014 34.5328900785 34.9515344732 34.0081013526 34.8323814945 36.4480079212 36.1422543805 36.7321534668 38.7515492881 38.8872272076 40.7412883735 41.9473080294 41.8060793544 44.1645043117 45.4166874276 47.1011906778 48.2023221789 49.5331961676 51.8027447877 53.2941589316 55.0240533727 56.8418980324 58.0804576417 59.7812801603 60.5764515005 60.9902621418 61.472394285 56.6391443533 46.4491863935 9.00349905052e-20 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1.77286178575e-23 5.98420577646e-23 8.91899906775e-23 28.8944318434 28.975851154 29.4460520918 28.6022898822 29.7565232758 29.9272610851 29.8892053189 29.9506478301 29.6191294577 29.980043364 31.4310083086 32.733268089 32.6997303647 33.4045117973 35.7826421305 35.0906835454 34.7395727587 36.9255665331 37.3284782139 37.0188574257 39.2315337102 39.9621508818 40.2247562081 42.1542555221 42.9303864434 44.3210212482 46.1390562539 47.364610091 48.9330399886 50.5311343072 52.1813476181 53.7238784789 55.6619686627 57.5418204039 59.1865859749 60.4772756546 62.2213452166 63.7478692116 66.075720711 54.9570713763 44.1051718876 2.67038321993e-20 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 8.0715018446e-24 2.89158491327e-23 4.06529012066e-22 2.75668255232e-18 28.9704273754 29.0600932963 29.9454682278 29.1107623586 29.5296463015 29.7966867964 29.8127501843 29.8565211845 29.593942198 29.7210812452 30.6506578436 32.2727043524 33.4596628973 33.3663407761 34.8625881811 36.5023802468 35.5494470762 35.4499633178 38.0365007817 37.6660621334 37.9356056049 40.3507483915 40.6840647185 42.2474645409 43.5413075109 44.3222875071 46.2111743848 47.640332767 49.4519584066 50.6216914037 52.4468830127 54.824142503 57.0256846345 58.8826636926 60.8329291872 63.0086327375 64.7841402736 65.7701997437 70.7504717503 53.8936361164 42.3281419774 7.11920141315e-22 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 5.0930878798e-24 1.69300231858e-23 1.62430765277e-21 4.70838976239e-19 2.27355776547e-09 28.7519644932 28.8439472997 29.6797588782 29.8551506566 28.9268374397 29.5794385985 29.7254156586 29.8123314977 29.8123687661 29.6120086673 30.0180021037 31.5158153532 33.0781526326 33.9346139625 33.7356583362 36.3311621272 37.0108020773 36.0068815509 37.8377999117 38.6677100782 38.4044252203 40.3535336348 41.4474357229 42.4333402328 43.8351619917 45.2752115068 46.3855271144 48.5075266765 49.5178028206 50.7060840714 53.5970839788 55.8547700584 58.1306672007 60.1289959737 63.0248775712 65.44338681 67.9345128811 69.4364669622 76.1374839968 48.4736943224 40.4509608771 4.89152262045e-23 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1.63679624183e-23 2.02690299798e-21 4.66115425411e-19 1.75041528971e-14 0.000354908385264 28.5720289555 28.6453348209 28.7062671913 30.0364115558 28.9213922356 29.4596098745 29.7473728634 29.8701421882 30.0449899218 29.7063918908 29.9198185448 30.4035144295 32.2924520058 33.9395110581 34.1328859432 34.4178816052 36.9151581364 37.0442463119 36.934442543 38.8395495397 39.447301918 39.996825669 41.7036634689 42.8653564727 44.1083158398 45.4152295652 46.9946075556 48.4404510401 49.8496576496 51.9552237377 54.1686988679 56.4915779614 59.1380479459 62.206703311 65.8869670212 69.8939608076 72.8835217707 76.7045988809 86.309585784 48.4585330972 53.0593891667 1.18986373753e-22 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 5.0930878798e-24 1.20823976494e-21 2.72112987098e-19 4.02810069853e-15 1.00834943275e-05 70.7676104251 28.8058907996 28.887607759 28.908019099 30.5792276434 30.8911866815 30.1283064508 30.0471690433 30.0623558744 30.1758094014 30.0740669289 29.9525426761 30.4114343601 31.3902953282 33.1845449414 34.634507902 34.4547187593 35.7837255963 37.4528122589 37.5564560507 37.7139746703 39.7369143655 40.662325279 41.3325876129 43.0288129627 44.3014346788 45.4437571773 47.0192771852 48.5620633897 51.0183553743 53.1287031288 55.9358085565 59.1235041182 61.8085129571 65.230751798 69.4164317329 73.5595468821 79.9867078206 90.4620279171 99.9985565832 99.5126612439 66.0308439117 1.18986373753e-22 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2.53829588055e-22 8.31443179036e-20 3.97583047146e-16 9.58919292069e-09 71.8562531619 77.6663890877 29.2251784882 29.2942701637 29.7098846641 30.6651744977 31.5343731442 31.1549137213 30.9263075633 30.5652578038 30.4408543558 30.5351017954 30.1321563474 30.4670052695 30.6749742468 32.116545197 33.7687462304 35.059177206 35.2192398378 36.9988502764 38.0265723449 38.278960728 38.5009317285 40.6566464729 41.7758730933 42.8208220601 44.1992771244 45.9601791971 47.3999438107 49.9992957101 52.0307654665 55.0919373223 57.3970418995 60.177903769 63.1844802968 66.9534709738 70.7213046626 76.056394633 85.5320426457 97.6447105128 99.9999999952 99.9998779365 46.0579190329 3.19441516368e-25 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1.27593066238e-23 1.18316834585e-20 3.09596496763e-17 8.25249089209e-12 44.0748549194 68.1989408483 70.3365749946 29.3694355569 29.3204275534 29.8860263958 29.9956204033 31.1088069016 32.2365248896 32.559902675 31.464128037 30.8486897708 30.7020123757 30.5808578439 30.2128584551 30.7769794399 30.8691321263 32.2431634079 34.2505311477 35.5207192415 35.8676582616 37.5829947301 38.6331503948 39.1153094697 39.4815301935 41.6461556394 42.829151936 44.1738062485 46.1707542457 48.3472327519 50.3620097618 52.812682913 54.8812539915 57.0761207185 60.3346786044 64.3471763243 67.74481938 71.1173140478 77.4964608575 83.4636940162 89.6929756899 99.9969260645 16.8916588908 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2.46362404892e-22 1.30048745114e-18 5.99103592225e-14 0.000316419447957 60.1433043943 60.4238554894 60.1676802662 29.287045351 28.9235039304 29.0463163006 29.2720066546 29.8319994246 31.570177422 33.0960961558 31.9989361143 31.1892768842 30.7981280507 30.7492159431 30.3548058034 30.7570816735 30.97106881 31.5455047404 32.570790721 34.9977234883 36.2089168922 36.5939509047 38.2014453856 39.273840382 40.0219099351 40.5469740862 42.6451124546 44.4570427013 46.1974677524 48.0668135598 50.0144697273 52.449435445 54.6734503028 58.6445915622 61.762981197 64.6877912128 67.4213979867 71.5074487586 75.4105725512 77.6215272929 73.2200418104 67.2965116768 6.32203469744e-12 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1.8119701082e-20 5.08521098422e-16 6.08622442282e-09 51.7202799373 53.2679344926 51.2815170965 49.9101798318 29.3271263161 28.4233810173 28.3457978378 28.5496949482 28.960158674 30.0881811887 31.7400941736 32.1629241871 31.3243224451 30.8497488635 30.6590817568 30.6989103617 30.2309006386 30.9159211124 31.0581016094 32.5153846022 33.6826473494 35.6918455509 36.9200576988 37.466311026 38.7852609064 40.0821398596 41.2033525688 42.2332638528 44.4575874284 46.4871230434 47.8127270204 50.5344637873 52.8961966248 56.7804655729 58.9914651073 61.3238177605 64.0444653298 67.541451383 72.0181020718 76.9153969604 81.6016449885 87.7576265808 86.9666232551 76.8014399492 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1.36354141277e-23 1.98728081e-18 1.97629845653e-12 31.7496932347 51.1234568895 47.6178453988 42.1354393315 41.3350893109 29.4615634104 28.0300195177 27.8206286859 27.8625135992 28.1757154549 28.8718585303 30.331507459 31.9834918114 31.4889304561 30.883019986 30.5729794919 30.5133880448 30.534642263 30.2647202837 31.3112053398 31.4130006018 33.0309073945 34.0658751461 36.099467298 37.4360777643 38.6008556946 39.0395992444 41.2762517827 42.745108688 44.472396164 46.4908292931 48.7099163966 51.1624979915 54.7584994705 56.5679656339 58.1131753041 61.7354470892 65.2421742721 69.3077791392 74.095011248 79.2661204267 86.2035013939 99.8226366296 30.9716044161 2.20600601899e-06 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1.64944620135e-22 4.42405731146e-16 0.00128373007874 52.1867735144 46.9411474952 41.307148267 36.3108676423 34.5084558562 28.8916823651 27.7463714565 27.3920635043 27.3911026781 27.5177244908 27.9823466206 28.5404691986 30.6951064071 31.6576070815 31.0089550926 30.5329775301 30.3351793337 30.3964314221 30.4201660276 31.0873031993 31.4708640613 31.5870905421 33.5480392839 34.7073764031 35.8571260716 38.3455061722 39.5112980697 40.7525480698 42.7524262346 44.6459904548 46.5742397691 49.1806630077 52.2018085228 54.0492867897 55.3380266171 59.2864507497 62.5059430263 65.9399734129 69.7821295631 73.8196263096 78.0774641292 82.8947345167 78.3657612282 7.9332813468e-08 4.40483006671e-07 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1.94650141642e-19 1.14775861351e-10 54.2384349476 53.4822789908 43.8942415365 36.5415669045 32.8243631876 32.0357561025 27.9997032842 27.5423886854 27.0987171867 27.0670089581 27.1097161356 27.2790803076 28.04242422 28.8287953934 30.7941457924 31.1204971193 30.5683978109 30.2279726192 30.1458257885 30.3505470609 30.2594061591 31.1495097561 31.5660485851 32.8205822178 34.0486557925 35.5387864875 37.1022617009 39.4099510109 40.8872136763 42.6680949659 44.3823235154 47.1348243936 49.414121674 51.7293731633 53.1853127545 56.9074283918 59.934587213 63.3526315978 66.7343973451 70.087855616 73.0108277265 73.6201912446 73.1510790049 56.9845971654 1.11327802515e-06 0.195914475171 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 3.69677712196e-24 1.45104614306e-16 49.0072716195 60.0203703628 50.8255938166 42.1880999249 35.5097689356 31.7813271536 31.2902222783 27.4559679854 27.1917524866 26.8887538909 26.723513276 26.7180685595 26.7399662332 27.0237977107 28.0848184253 28.8175802566 30.6676878679 30.8058445425 30.2908995076 30.0232392673 30.0121752306 30.162859207 30.222354445 31.5033716894 31.9761539699 33.3964086715 34.3224808818 36.8361918826 39.0739173634 40.7811418512 42.3273616686 44.3466238817 46.8557372995 49.9269870508 51.5670600315 54.9414120214 57.7153030266 61.1602080163 63.8947698449 66.6635684748 69.0752047643 70.1215117057 69.5899878348 68.5267905771 52.119124987 1.474868559e-06 61.1003093699 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1.15296389796e-22 0.000175450318877 62.7722878259 56.6665741007 48.4206596773 41.3722947566 36.1041171591 33.2086082018 33.2834178048 27.3979823416 26.748947456 26.5978285215 26.2716372519 26.1341171848 26.0510457545 26.0551701936 26.617840553 27.7762578444 28.7392486343 30.7426188349 30.6410600545 30.167382322 29.9624009402 30.009471136 30.2982088339 30.4919394487 31.8170930909 32.4742489716 34.4240086433 36.0924115151 38.6549927819 40.5058231371 42.1686519772 44.4288893778 47.3884263584 49.8528244679 53.1431436856 55.7215847097 58.8833519677 61.5298399137 64.5547725115 67.0324950681 68.8697265082 69.3816178776 69.6427587584 69.5902423931 58.6550814261 5.39002328694e-06 91.0167778665 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 4.89592789324e-18 55.3909283786 61.1115968456 53.4201688252 46.9043367247 41.4599757494 37.537716647 35.3248404056 33.8753620382 27.4485607003 26.3111590403 25.9709023191 25.5473598134 25.2285684548 25.0834956046 25.055141669 25.2262285962 26.4709127913 27.2245026091 28.7419218641 30.4459746122 30.6030311868 30.2597626712 30.0639772885 30.2089620243 30.6629219938 31.0363885603 32.6222828587 33.7555935626 36.0294577203 38.1139156949 40.2399399705 42.5612662203 44.782294584 47.5314412593 50.9908504801 53.7143700033 56.8418231488 59.4831212823 62.8617705814 65.1066205759 67.0324509258 68.8756949735 70.5475302412 71.4699790116 69.337794987 60.0018993776 9.14300658209e-05 99.9970745641 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 8.14453201147e-24 47.8248335546 63.7855819431 58.7118450136 51.9273136748 46.8073384066 42.7939940251 39.8070263113 38.1894895109 37.2842588814 26.3601921041 25.1022941187 24.4635883997 24.1875615125 23.9247179356 23.8146646241 23.8644925236 24.0422315783 24.7356395153 26.1505602956 26.9264769354 28.6780244357 30.0182369124 30.4712173636 30.3897232107 30.3414398543 30.7031048714 31.3430430792 32.0311214746 33.9170728217 35.6016538799 38.1541249896 40.5729410946 42.8789429309 45.3108596321 48.3944607779 51.122169505 54.7336323102 57.3599957278 60.623530135 63.1045673369 65.9293612965 67.9700080853 70.8421983896 72.8451247387 71.7655567815 72.339410429 69.5271115627 0.00136250295471 100 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 5.85123981969 65.7293404521 62.9773465386 57.3516267778 52.0509242756 48.182887461 46.3352694827 44.7510548623 43.0613186185 42.754812263 24.273522862 22.3527960128 22.3301102801 22.3957367545 22.3881865294 22.4426385756 22.6071273404 22.891386379 23.2876283313 24.9337639228 26.117391482 26.875767484 26.7774519616 29.6962005545 30.3398811819 30.8037150668 30.9807898485 31.4243190013 32.3505358768 33.4682496348 35.6682200435 37.7899719701 40.635514932 43.243986664 45.5712152517 48.6039591399 52.1608391583 55.0719669225 58.3812100604 61.0847203085 64.6060535739 66.9519710923 69.8972766829 74.1916604722 75.230775654 76.7646864274 78.7100708036 77.9388380054 0.00295066631253 100 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 5.56680267997e-23 61.4317820221 63.3183790276 60.9789993862 56.9400957365 53.4516541431 51.2603631107 50.8694786372 52.3162719506 49.4827516086 51.4926035241 22.7122779301 21.0206697419 20.8827217096 20.9437559644 21.1088505057 21.2892793717 21.5461916644 21.8814518426 22.3009208233 22.8948435123 24.7220119843 26.4404942975 26.7596236343 27.3052917859 28.7561304419 30.5383539796 31.4866697432 31.6837208185 32.7021026277 33.8383905707 35.3310934025 38.0690016673 41.0170286207 43.5419902508 46.1138753117 49.3201989325 52.215198339 55.9472634762 58.655231824 62.0048627329 65.053345609 69.0241780488 73.3980679379 76.2713043512 78.461747434 80.8704871728 80.4637850255 80.3486062902 0.00799139750727 100 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 56.954376714 60.048808071 61.7901892738 60.2205973675 57.5715575317 55.4437869945 54.2033152777 53.7361310076 56.1814435258 54.7022847433 53.9123277074 21.9226435687 20.6823009272 20.1764579968 20.2072153114 20.4285134329 20.6182677011 20.8377852473 21.1372528159 21.5070552779 21.9327835668 22.7559424682 24.7878323723 27.2459009268 27.6475140292 28.2029539931 29.3980287953 31.0540746507 32.2913140276 33.6694040323 34.2078318377 35.8915990556 38.2217645676 41.1699590386 43.8055599476 46.1959312578 49.3204130415 52.9663130776 55.8172595183 59.2299325195 62.4196458477 67.7206910353 71.8109193144 76.0931954855 79.2493280191 82.0497594516 82.2882303798 83.7405830092 83.2124894416 0.0138103782116 100 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 3.51457687338e-17 69.4304101345 64.1758008065 62.5304482958 60.8974162632 58.9284177947 57.4285695465 56.4345926296 55.772099915 56.9162906847 56.5029393979 54.7866442785 20.1579071698 20.1338851375 19.7004041557 20.0849524278 20.3695492334 20.4480512219 20.5103500195 20.6532244902 20.9242226674 21.2963226549 21.8092689448 22.8371090916 25.0745665707 28.2432719394 29.1875920802 29.4357337378 30.453133796 31.8361584053 33.3568791344 35.0163486921 36.9796613732 38.4291520498 41.2178955003 43.9074823638 46.51614512 49.7132696309 52.7646427498 56.5319284612 59.4801831674 65.2356283186 71.0713544347 74.8091665527 78.5509226174 82.9437476402 84.7263344208 86.3689239555 87.5803653899 84.9433776824 0.00976561177968 100 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 62.4932300304 61.4660392753 64.2579205491 63.1167969715 62.047800573 60.5899264355 59.4154136831 58.5230727093 57.8568670805 58.6802465037 57.9506051104 56.4422263632 17.933913492 18.8774182839 19.392577946 20.3824778442 20.5613455991 20.5229377268 20.4056052697 20.3818608142 20.4787297621 20.7575353661 21.1709323834 21.7663490767 23.0907066749 25.3771950697 28.4633364504 29.6646326301 30.909817295 31.5818145296 32.9630789773 34.5842198098 36.8260906949 38.9456742074 41.1756686859 43.9047414619 46.6034986577 49.7418146291 53.495427114 56.4639754223 62.3683659464 68.7990392169 72.3568659351 77.0932892116 81.6289015673 85.0944532513 87.8932109284 91.3198931277 90.1827060995 88.4052924527 11.3298458839 100 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.0740536811711 79.5796826942 70.9212676167 67.3733554907 65.0303383111 63.6428725295 62.3343628827 61.3071925363 60.5086888579 59.9283033461 60.3254401586 59.3772041486 58.8516138754 17.1142259476 17.7987933807 19.2280902788 19.9091960362 20.0300129336 20.1276288295 20.2543227516 20.1981684029 20.1782200185 20.2990098885 20.6152485811 21.0912395503 21.7907015356 23.5995049362 25.4678780277 28.978691025 30.792682295 31.7665749122 33.2486729676 34.6822496182 36.7366015356 38.7679877274 41.2386387318 43.8850488902 46.7634640987 50.5690862413 53.7765982489 59.0335799387 64.9039277988 69.1853916946 73.7946210599 78.5116787063 84.0027131875 88.5784383158 93.354893148 95.6776667733 97.3698874514 99.7039389513 67.5843682064 100 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 81.4912964952 75.4802293834 72.0237416467 68.3851454209 66.1923430832 64.6264886472 63.4091677103 62.4590459988 61.7784808911 61.3590401901 61.0352835226 60.1700827582 60.1996904735 16.7419155624 17.0330880039 18.2011772778 19.07005774 19.2779605349 19.4536712677 19.6435476619 19.845215872 19.9596179764 19.9905750406 20.1740318383 20.5611969602 21.1954320714 22.1463984661 24.898355189 28.108121106 29.4210144216 31.6673250461 33.5614140995 34.7188567224 36.3807959836 38.586873654 41.4134881815 43.8693617675 47.5309500546 51.018970448 55.1635858587 60.1429822515 65.2432966007 69.9741542502 74.4125936012 81.2390436542 87.0978153808 94.0400475771 98.0215240512 99.7099482556 99.9934059576 99.9897500301 95.1028043255 95.710021639 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2.94546734815e-09 65.5130073688 71.313850164 69.928701529 68.0140120879 66.3095151386 64.4584621466 63.171436801 62.0918100601 61.2939389639 61.2384495735 60.5594727317 59.4918090302 60.1015662567 16.1614298709 16.1955194249 16.7646463482 18.2645332889 18.5722136957 18.7854496467 18.9979679842 19.2348999764 19.4949104641 19.7825641864 19.8796599945 20.1717339222 20.7313102255 21.6318302124 22.9798597305 25.5186526553 29.2959430219 31.3026100312 32.3103250666 34.8416618494 37.0783849682 38.7477653391 40.844796627 44.4971135995 48.3358007676 51.162626101 55.6653658757 61.1548548661 65.9290158356 70.0493996404 76.9442680151 84.3059700605 90.990226281 97.1469602985 99.6994840729 99.9980245797 99.9999994841 99.9999980649 0.338087804974 0.0173783652186 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 84.3044330007 72.3957456171 71.2923568294 68.9165673858 67.5946020097 65.4865528576 63.4184378903 61.8457664759 60.4753237878 59.3154959943 58.3816466145 57.9712522904 57.6103114797 59.0281167548 15.3699301688 15.3117964058 15.5559874211 17.592908237 17.9583868515 18.1836184982 18.396874266 18.624655678 18.8873028191 19.1913064735 19.5694669686 19.9088284646 20.3499052584 21.0805123301 22.1311004682 23.744390502 27.0678666985 30.3358072305 32.3364539026 34.9280311542 35.7646936241 38.5545041198 42.2855773951 45.5539998599 47.5822644868 52.1672044581 57.2134278188 61.0770471688 66.0530555627 72.4860200804 79.7630449878 85.7155602021 92.9800864527 98.2464476704 99.9974119556 99.9999998831 99.9999999994 99.9999941024 2.81676086238e-06 4.87672721881 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1.28058008127e-21 79.5795105853 75.0361553492 71.8738894723 69.2011614531 67.0690145093 65.0685077561 62.195603065 60.3123652324 58.791954075 57.5994344614 56.7257465783 56.5246506949 55.8203244384 56.8396247136 14.607755508 14.5424977961 14.6677531696 16.9728789593 17.3786085314 17.6234603758 17.8298921258 18.0387251461 18.2732030462 18.5620556533 18.9410123938 19.4367262853 20.100272915 20.7486785892 21.6290922255 22.9919722778 24.8246172917 28.1779347772 31.8815990745 33.8447692055 36.1206237922 39.4945603576 42.8616332299 44.2101170311 48.475797004 53.2070279157 56.751333603 61.5496934621 67.6274838521 73.079799536 80.1308363416 87.5341850767 94.5394238925 99.9041055059 99.9999971442 99.9999999997 99.9999999999 99.8967472512 6.62746992546e-11 100 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 90.834283065 70.5145314687 75.2864199892 72.5339540777 69.8130679554 67.1282571098 64.3752634655 61.2408087487 59.0794012224 57.4399906293 56.2098581745 55.5059223883 55.4552654229 54.4698054033 53.6679200518 13.7746635594 14.0655978494 13.9110624625 15.9337569519 16.7949883157 17.0852475997 17.292366419 17.4752248705 17.6736172234 17.933769829 18.2940438302 18.792863964 19.4373070786 20.2819664429 21.4529516267 22.8375296783 24.2263873479 26.0755274035 29.3495701517 32.9955536757 35.8421322799 38.9048508827 41.0483045359 44.1602605747 49.4215888415 53.2798164893 56.1212747601 61.1530519965 67.218135116 74.7005469864 81.7212580318 87.9882058922 95.6307390285 99.9960550175 99.9999999956 100 100 99.2990886903 1.75841565998e-10 100 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 99.9991806406 88.7377489622 80.6126783122 75.4048287621 71.6680801992 67.5615953844 63.8456574629 60.7646258976 58.4070353282 56.6429872263 55.3064495557 54.6699150624 54.3251460784 53.315839234 52.6244013954 12.7157294328 13.6758694758 12.9190385944 14.7312733186 16.2332501078 16.4220961639 16.4990001269 16.5452112739 16.6443067991 16.8539391621 17.2069123022 17.7335042489 18.4645481582 19.4725912465 20.8395617215 22.474258851 24.1915786445 26.0215981817 27.7968565625 29.8497683603 33.4442434044 36.972638819 39.7785823237 43.9028227854 48.697348015 52.1801738382 55.9055082764 61.7791557322 68.504249751 73.7578277286 81.0588149749 89.7494793334 97.8027117214 99.9995823864 100 100 100 99.9852623769 0.000228007059458 100 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 54.81493799 74.2485131743 87.4986423702 82.7538226099 78.0832709579 72.6894969282 68.8510048009 64.0746925 60.8857889889 58.3141374389 56.4269793108 55.1800849846 54.9783396477 53.5839417614 52.5204079425 51.9800189188 11.1652059985 12.7279227238 11.557132544 13.9665646483 14.8110120454 14.3028889106 13.6844193076 13.2954013416 13.2240714777 13.4873910137 14.0777438272 14.9955829277 16.2416606093 17.9121658226 20.1569536662 22.4138468671 23.896575989 25.3502466578 27.0334075817 29.1545196428 31.3812297078 33.8561808536 37.4888716639 42.9285511288 47.8996710161 52.1287731305 54.7367495508 59.9422360674 66.2435087778 74.1769467963 83.2615384691 91.4334212411 97.2018031675 99.9999996795 100 100 100 99.9999999999 0.00289681340508 100 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 100 99.999686173 93.7486547334 86.7497346189 80.8694236505 74.8655508109 69.3100784964 64.9336176315 61.2651706456 58.3243981807 56.2225821999 54.9317370514 54.2679239717 52.7029881308 51.8909198587 52.415162097 9.68219495251 10.6521042685 10.0343371277 12.6005791938 12.0086655402 11.5665710921 10.8825775964 10.7699392947 11.1855843309 11.9786109054 13.0818654032 14.4509220118 16.0343850937 17.8160481455 19.6646695376 21.2466886128 22.5778250005 24.0451239904 26.1231216426 28.9155581021 31.0775518667 33.4328337453 36.4728958215 40.6271586935 44.820837598 47.9856074045 51.8462173587 58.7988366331 66.3308856754 75.6596649561 84.2474710669 89.7849466115 98.1478009765 100 100 100 100 100 0.0429214839475 100 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2.59448069991e-22 81.6619467339 99.7939399144 96.4050998933 89.615458469 82.011533847 76.5625062626 70.1880248566 65.3964125704 61.3301177206 57.9153724648 55.4158700848 53.9672892897 52.5207158563 51.2244977995 50.2470961046 51.605646257 9.39869328427 8.66258738129 8.94091180701 13.0237266039 11.8561473721 10.1017439304 9.27150554257 9.63216669408 10.5581251551 11.7835387091 13.2295839714 14.8717875071 16.6172185995 18.4723283403 20.3626799909 21.6022727462 22.784415568 24.2437946439 26.0322364095 27.84615379 29.7958684009 32.3514142449 35.4231878624 39.0739466262 42.0279311597 45.0142350482 49.7857517379 56.908575768 65.9053944459 74.9581492028 82.5117964159 89.2488838632 99.3146497117 100 100 100 100 100 0.171751677966 100 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 99.9591267656 92.3879544423 99.9852985137 99.624684167 93.5553308158 84.9146503212 76.9430177715 70.6964091137 65.311650735 60.8645837954 57.1813159375 54.2411768842 52.1186754189 50.0046878363 48.5965533104 47.5049411117 49.2368496245 10.8648635464 8.3379578349 8.41831682995 13.3545892479 11.9419403434 8.18028976724 8.28378077293 9.4362040289 11.0153296761 12.8573062847 14.9590504212 16.906905462 18.0463990986 19.1911570313 20.3307657281 21.4483623494 22.666494108 24.0528436747 25.5746331688 27.1357756577 28.8120145787 30.8452694825 33.5846056435 36.8849583547 40.5482086181 43.4239153809 48.7795578799 55.4577688745 63.0464158593 71.9546648867 80.6008436229 89.3100151607 98.9384800586 100 100 100 100 100 7.33217434305 100 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 100 100 99.9999999977 99.9999328482 98.225619184 89.0440519928 79.4236694866 71.3721271689 64.9572289109 60.1176479821 56.1866288235 51.8481367713 48.8151137486 46.5882547903 45.3340178019 44.3809571291 45.8977175357 11.4883318213 8.42580411878 7.66980660612 8.24636104583 7.32675645902 7.65704593457 9.19867449808 11.3826001544 14.0394682808 15.2439648989 16.212923892 17.1709015363 18.1594177878 19.2461118668 20.3999847941 21.6190636398 22.9121885766 24.2370978422 25.5237711092 26.7335764685 28.0859106613 29.9456256684 32.5053860351 35.0689197914 37.6907095595 41.0847903155 46.3080565066 53.1417281797 61.2317892083 69.6228555539 76.602886392 85.4895984587 96.1120993719 99.9584949078 100 100 100 100 28.5155724381 100 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1.29205192822e-21 99.9994878776 100 100 99.999999901 99.9915949217 92.8664446143 82.64307842 72.9486624687 64.8687342403 58.7401344605 54.1695297738 50.2497618788 46.9775887146 43.7280835731 41.4821620369 41.3203165152 41.7054579574 9.35481819664 7.95185693171 6.80645804505 6.83109775573 8.26019907115 10.7360353352 13.1044904397 13.9487682068 14.7730668597 15.6199218962 16.5495721089 17.5468920107 18.6282612657 19.8135327158 21.1150401556 22.5150658745 23.9250126573 25.1220402684 25.6701897206 26.2321091179 26.9802530429 28.0991851191 29.7256817885 31.8820767895 34.4430557437 37.8826481293 43.1708888085 50.1551311055 57.7521786044 64.6476485534 72.3286284813 83.0505993838 89.9673886108 95.7556331635 99.9996077398 100 100 100 80.3015422998 100 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 100 100 100 100 99.9999999999 99.9999976238 97.8274432464 85.9425764243 74.9453604164 65.1202014561 57.4010850056 51.8009422549 47.1165651134 43.6363444343 40.8342884362 37.0514016384 37.5947636458 37.0192079072 7.19455706955 7.79252036979 6.34119104547 6.37250618074 10.7484242299 12.9898730534 13.7264791321 14.5176194197 15.3921915077 16.3407910459 17.3580254334 18.4477385233 19.6240197137 20.9211463919 22.4025283647 23.5444260887 23.8957747187 24.2031695577 24.4484294259 24.616247844 24.8256223194 25.2873818457 26.3069480784 28.0500000726 30.2149215134 33.2546242287 38.3276581823 45.4972470807 52.3491298225 58.4993676597 65.9552334414 76.2397258767 80.8321836156 87.0395544497 97.8938226149 99.9999999786 100 100 98.6859916002 100 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 100 100 100 100 100 99.9999999987 99.9982520289 90.0186894438 77.3485619934 66.291698994 56.8337982318 50.1409483183 44.3702273367 39.7879990863 36.7493961274 32.7856750595 32.5660894255 33.7219650931 6.20594640069 8.66930907209 6.08798786562 6.06400823613 12.7289781318 13.7986506073 14.6506701449 15.6050025812 16.5945950087 17.6188767918 18.6723337559 19.7448971051 20.8300077862 22.01152796 22.8780641391 23.070726197 23.2184703643 23.3918968461 23.3652182416 23.0294834664 22.371102385 21.7036655348 21.5612707283 22.9294518776 24.4938233895 26.3300796827 31.202740574 38.953499954 45.4074647608 50.184701915 56.1517070062 66.9249593916 65.9076491084 73.0662935238 85.152496184 99.9801103322 100 100 100 100 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2.9967804027e-22 100 100 100 100 100 100 99.9999983926 94.8665805302 80.2082303341 67.8717681221 56.8131398339 48.52533802 42.759310703 37.0687223952 32.140975352 27.9253863803 28.6705022697 33.7712004809 3.47426711821 4.30940540859 5.4510939512 8.12218386818 14.3051317479 15.4425204303 16.5105151762 17.6196572579 18.757862023 19.8392463537 20.8129579187 21.6268867524 22.361209774 22.6632601751 22.8258617967 22.7927404252 22.7619813437 22.7108963578 22.3410817403 21.2298808551 19.3600415191 16.864157231 17.7304850568 19.6468379278 19.0327717278 17.8495608845 21.5573132046 30.9213345621 40.2949553367 39.3559253373 43.8744806996 50.2045849709 50.3409528782 43.9139486426 67.0194290368 83.4424691934 99.9996755264 99.9999999999 100 100 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 100 100 100 100 100 100 100 99.9999999885 98.649149023 82.6473989727 68.8368785339 57.0538974015 47.6857362683 40.812020758 35.5561300801 31.1544510655 27.7844403867 28.7011689044 27.5780198385 2.51325431068 3.39097754079 6.86300021083 6.37016753502 15.4007339495 17.4552038458 19.0740545988 20.2324369952 21.3632199262 21.8168413126 22.3033699974 22.782678492 23.1737291572 23.4709196448 23.6095901754 23.289427661 23.3300260088 23.031239664 21.2287329815 18.7056243981 15.1425029433 7.73950147734 1.77039351068 1.34684168597 1.36607683842 0.697292110726 0.325642615686 0.227641534486 1.70235360713 23.736754668 0.169034132406 41.5952039724 6.21521542684 41.0311229036 8.56926177927 54.9284548744 41.5153164181 99.6761124826 99.9999999999 100 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 4.85183634865e-24 100 100 100 100 100 100 100 99.9999999996 99.9715185334 83.4289578712 69.2816692275 58.183696105 48.5656452075 40.9632134473 35.5112834449 30.9441331082 26.7548446673 24.3750964638 17.86196991 1.57514324113 7.14330771544 6.92801774856 5.83765157467 6.02545223372 8.48434946957 13.6442128371 15.2182508534 16.6023449728 18.2259958775 20.0300746522 21.7160438468 22.6069381602 22.1797930171 19.9356546507 15.5218875411 12.5209926534 12.5379923268 9.47750809733 5.95644898056 3.91580924542 2.33189499643 1.16076523972 0.627678712638 0.507594062653 0.322821013629 0.156022918798 0.0651210273929 0.0461262177851 0.0167329264456 0.0151126441713 0.000813492614234 0.203516898149 1.48483343141e-06 0.219519465268 1.05530733331e-09 1.78667202549 2.29578382924e-15 1.45134427529e-14 100 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 8.0715018446e-24 100 0.00356458780217 100 100 100 100 100 100 99.9957513728 82.5258567585 67.5157468308 57.0502635152 47.8185394424 39.670339033 33.185515374 28.0819913749 24.1365769065 21.8146049269 12.4910586133 ) ; boundaryField { frontAndBack { type empty; } upperWall { type calculated; value uniform 0; } lowerWall { type calculated; value uniform 0; } inlet { type calculated; value uniform 2.88474648672e-21; } outlet { type calculated; value nonuniform List<scalar> 20 ( 1.66125208867e-23 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1.42456616628e-24 3.22902462108e-23 ) ; } } // ************************************************************************* //
22b10a60c8a4093543e1dd3bb064cdd86596a06f
297497957c531d81ba286bc91253fbbb78b4d8be
/third_party/libwebrtc/net/dcsctp/packet/chunk_validators.cc
2dd1edb2d89da7d670ce7a45ce127ca097c9f378
[ "BSD-3-Clause", "LicenseRef-scancode-unknown-license-reference" ]
permissive
marco-c/gecko-dev-comments-removed
7a9dd34045b07e6b22f0c636c0a836b9e639f9d3
61942784fb157763e65608e5a29b3729b0aa66fa
refs/heads/master
2023-08-09T18:55:25.895853
2023-08-01T00:40:39
2023-08-01T00:40:39
211,297,481
0
0
NOASSERTION
2019-09-29T01:27:49
2019-09-27T10:44:24
C++
UTF-8
C++
false
false
2,011
cc
#include "net/dcsctp/packet/chunk_validators.h" #include <algorithm> #include <utility> #include <vector> #include "net/dcsctp/packet/chunk/sack_chunk.h" #include "rtc_base/logging.h" namespace dcsctp { SackChunk ChunkValidators::Clean(SackChunk&& sack) { if (Validate(sack)) { return std::move(sack); } RTC_DLOG(LS_WARNING) << "Received SACK is malformed; cleaning it"; std::vector<SackChunk::GapAckBlock> gap_ack_blocks; gap_ack_blocks.reserve(sack.gap_ack_blocks().size()); for (const SackChunk::GapAckBlock& gap_ack_block : sack.gap_ack_blocks()) { if (gap_ack_block.end > gap_ack_block.start) { gap_ack_blocks.emplace_back(gap_ack_block); } } if (gap_ack_blocks.size() <= 1) { return SackChunk(sack.cumulative_tsn_ack(), sack.a_rwnd(), std::move(gap_ack_blocks), sack.duplicate_tsns()); } absl::c_sort(gap_ack_blocks, [&](const SackChunk::GapAckBlock& a, const SackChunk::GapAckBlock& b) { return a.start < b.start; }); std::vector<SackChunk::GapAckBlock> merged; merged.reserve(gap_ack_blocks.size()); merged.push_back(gap_ack_blocks[0]); for (size_t i = 1; i < gap_ack_blocks.size(); ++i) { if (merged.back().end + 1 >= gap_ack_blocks[i].start) { merged.back().end = std::max(merged.back().end, gap_ack_blocks[i].end); } else { merged.push_back(gap_ack_blocks[i]); } } return SackChunk(sack.cumulative_tsn_ack(), sack.a_rwnd(), std::move(merged), sack.duplicate_tsns()); } bool ChunkValidators::Validate(const SackChunk& sack) { if (sack.gap_ack_blocks().empty()) { return true; } uint16_t prev_end = 0; for (const SackChunk::GapAckBlock& gap_ack_block : sack.gap_ack_blocks()) { if (gap_ack_block.end < gap_ack_block.start) { return false; } if (gap_ack_block.start <= (prev_end + 1)) { return false; } prev_end = gap_ack_block.end; } return true; } }
60f8378d31fee58e460041b51fce4ee53a512320
1c42215c5558211f02557ef1edd711d067ec78b6
/src/LiftItems/ZenGin/Gothic_II_Classic/API/zBuffer.h
f1ef65677b1e89ed903362a3c20542b78ae55389
[]
no_license
UnresolvedExternal/Union_AlterDamage
fd5891c3a62896a3e2049e9fea2b3da9721c57c9
88b1ae773ea8e5c3762d2a5fd23b3ca7fae5c3b2
refs/heads/master
2023-07-26T13:52:00.230498
2023-07-11T17:49:13
2023-07-11T17:49:13
200,260,609
5
1
null
null
null
null
UTF-8
C++
false
false
5,866
h
// Supported with union (c) 2018 Union team #ifndef __ZBUFFER_H__VER2__ #define __ZBUFFER_H__VER2__ namespace Gothic_II_Classic { enum zTBufferMode { READ, WRITE, READWRITE }; class zCBuffer { public: zTBufferMode mode; unsigned char* buffer; unsigned long pos_byte; unsigned long pos_bit; unsigned long maxsize_byte; unsigned long maxsize_bit; unsigned long size_byte; unsigned long size_bit; unsigned char vobNr; bool allocated; bool bits_written; bool buffer_error; void zCBuffer_OnInit() zCall( 0x004404C0 ); void zCBuffer_OnInit( unsigned long const& ) zCall( 0x00440540 ); void zCBuffer_OnInit( void*, unsigned long const& ) zCall( 0x004405C0 ); void zCBuffer_OnInit( zCBuffer const& ) zCall( 0x004414C0 ); zCBuffer() zInit( zCBuffer_OnInit() ); zCBuffer( unsigned long const& a0 ) zInit( zCBuffer_OnInit( a0 )); zCBuffer( void* a0, unsigned long const& a1 ) zInit( zCBuffer_OnInit( a0, a1 )); void Init() zCall( 0x00440610 ); zTBufferMode SetMode( zTBufferMode ) zCall( 0x00440670 ); void Reset() zCall( 0x00440680 ); void Resize( unsigned long ) zCall( 0x004406A0 ); unsigned long Write( void const*, unsigned long ) zCall( 0x00440730 ); unsigned long WriteBits( void const*, unsigned long ) zCall( 0x00440750 ); unsigned long WriteBool( int, int ) zCall( 0x004408D0 ); unsigned long WriteByte( unsigned char, int ) zCall( 0x004408F0 ); unsigned long WriteWord( unsigned short, int ) zCall( 0x00440910 ); unsigned long WriteDWord( unsigned long, int ) zCall( 0x00440930 ); unsigned long WriteReal( float, int ) zCall( 0x00440950 ); unsigned long WriteInt( int, int ) zCall( 0x00440970 ); unsigned long WriteFloat( float, int ) zCall( 0x00440990 ); unsigned long WriteFloatPacked0_16( float ) zCall( 0x004409B0 ); unsigned long WriteFloatPacked0_8( float ) zCall( 0x004409E0 ); unsigned long WriteFloatPacked8_8( float ) zCall( 0x00440A10 ); unsigned long WriteString( zSTRING ) zCall( 0x00440A80 ); void CompleteByte() zCall( 0x00440B00 ); unsigned long Read( void*, unsigned long ) zCall( 0x00440B30 ); unsigned long ReadBits( void*, unsigned long ) zCall( 0x00440B50 ); int ReadBool( int ) zCall( 0x00440C10 ); unsigned char ReadByte( int ) zCall( 0x00440C30 ); unsigned short ReadWord( int ) zCall( 0x00440C50 ); unsigned long ReadDWord( int ) zCall( 0x00440C80 ); float ReadReal( int ) zCall( 0x00440CB0 ); int ReadInt( int ) zCall( 0x00440CD0 ); float ReadFloat( int ) zCall( 0x00440CF0 ); float ReadFloatPacked0_16() zCall( 0x00440D10 ); float ReadFloatPacked0_8() zCall( 0x00440D40 ); float ReadFloatPacked8_8() zCall( 0x00440D70 ); zSTRING ReadString() zCall( 0x00440DA0 ); void SetPos( unsigned long const& ) zCall( 0x00440F80 ); void SetBitPos( unsigned long const& ) zCall( 0x00440FA0 ); unsigned long SetPosRel( int ) zCall( 0x00440FC0 ); unsigned long SetBitPosRel( int ) zCall( 0x00440FE0 ); void SetPosBegin() zCall( 0x00441000 ); void SetPosEnd() zCall( 0x00441010 ); unsigned long GetPos() const zCall( 0x00441030 ); unsigned long GetBitPos() const zCall( 0x00441040 ); unsigned long GetMaxSize() const zCall( 0x00441050 ); unsigned long GetBitMaxSize() const zCall( 0x00441060 ); unsigned long GetSize() const zCall( 0x00441070 ); unsigned long GetBitSize() const zCall( 0x00441080 ); unsigned long GetRestSize() const zCall( 0x00441090 ); unsigned long GetBitRestSize() const zCall( 0x004410A0 ); unsigned char* GetBuffer() const zCall( 0x004410B0 ); unsigned char* GetCursor() const zCall( 0x004410C0 ); void SkipByte() zCall( 0x004410D0 ); int GetBitSizeToNextByte() const zCall( 0x00441100 ); bool HasError() const zCall( 0x00441110 ); unsigned long WriteObject( zCObject*& ) zCall( 0x00441150 ); unsigned long ReadObject( zCObject*& ) zCall( 0x004412D0 ); zCBuffer( zCBuffer const& a0 ) zInit( zCBuffer_OnInit( a0 )); zCBuffer& operator =( zCBuffer const& ) zCall( 0x00441510 ); void CopyFrom( zCBuffer const& ) zCall( 0x00441530 ); void ByteFreq_Analyse() zCall( 0x004415D0 ); static void ByteFreq_Reset() zCall( 0x004415B0 ); static void ByteFreq_Print() zCall( 0x00441600 ); virtual ~zCBuffer() zCall( 0x00440640 ); }; } // namespace Gothic_II_Classic #endif // __ZBUFFER_H__VER2__
4b1ab700ec1c9923e42b666254c37053bbf0c32f
791f8916c6ad22b665e798c03ae68833fb5e4849
/codeforces/1015/E.cc
89bf786a3f8b9d02965162dac34d87705ef62425
[]
no_license
zzJinux/cmpt-prog
89079f56495944a51015f94f0fec18db05102b9e
37df0f4be72fac07e1d60dc3071017bd49bf1ed8
refs/heads/master
2020-03-28T20:57:26.095993
2019-12-03T06:09:57
2019-12-03T06:09:57
149,117,177
0
0
null
null
null
null
UTF-8
C++
false
false
1,542
cc
#include <cstdio> #include <vector> #include <algorithm> using namespace std; int n, m; char map[1000][1001]; int hray[1000][1000]; int vray[1000][1000]; struct Ray { int x, y, s; }; vector<Ray> rayvec; int main() { int i, j, k; scanf("%d %d", &n, &m); for(i=0; i<n; ++i) scanf("%s", map[i]); for(i=0; i<n; ++i) { j=0; while(j<m) { while(j<m && map[i][j] == '.') ++j; int jj, cnt=0; for(jj=j; jj<m && map[i][jj] == '*'; ++cnt, ++jj); int kL = (jj-j+1)/2; for(k=0; k<kL; ++k) hray[i][j+k]=k+1; for(k=kL; k<jj-j; ++k) hray[i][j+k]=jj-j-k; j = jj; } } for(j=0; j<m; ++j) { i=0; while(i<n) { while(i<n && map[i][j] == '.') ++i; int ii, cnt=0; for(ii=i; ii<n && map[ii][j] == '*'; ++cnt, ++ii); int kL = (ii-i+1)/2; for(k=0; k<kL; ++k) vray[i+k][j]=k+1; for(k=kL; k<ii-i; ++k) vray[i+k][j]=ii-i-k; i = ii; } } for(i=0; i<n; ++i) { for(j=0; j<m; ++j) { int raysz = min(hray[i][j], vray[i][j]); if(raysz < 2) continue; map[i][j] = '.'; for(k=1; k<=raysz-1; ++k) { map[i+k][j] = '.'; map[i-k][j] = '.'; map[i][j+k] = '.'; map[i][j-k] = '.'; } rayvec.push_back({i+1, j+1, raysz-1}); } } for(i=0; i<n; ++i) { for(j=0; j<m; ++j) { if(map[i][j] == '*') { puts("-1"); return 0; } } } printf("%zd\n", rayvec.size()); for(Ray ray: rayvec) { printf("%d %d %d\n", ray.x, ray.y, ray.s); } return 0; }
2c9967ffe403b096535f6e96fb7e600e6e1e46fa
f04a8e7251afb4f16b452f1f0a3b17d6b2cf24dc
/multikulti/multikulti.cpp
2577120375a0cbaaf5352db3167013bd7bc401f0
[ "MIT" ]
permissive
M4XM77R/multikulti
3d7a6eef27f0bebdf13900f5c719ef0726b50073
91b4879a2a0ae31536fdbeeae1ad484faccf8dde
refs/heads/master
2023-08-29T07:20:25.543022
2021-10-22T14:16:19
2021-10-22T14:16:19
418,208,698
0
0
null
null
null
null
UTF-8
C++
false
false
622
cpp
#include <iostream> #include <math.h> #include "Donut.h" #include "prime.h" #include "IntTest.h" #include "euler.h" #include "Calc.h" int main() { system("title Super cool app"); char Input = ' '; std::cout << "What do you want to do:\n(1)Donuts\n(2)Primes\n(3)Int Test\n(4)Eulers number approx.\n(5)Calc\n(q)Quit\n\n\nInput: "; std::cin >> Input; switch (Input) { case('1'): donut(); break; case('2'): primeCheck(); break; case('3'): IntTest(); break; case('4'): Euler(); break; case('5'): Calc(); break; case('q'): default: break; } system("pause"); return 0; }
0c7277843089dc61e815d9404ea83c116cae3f8a
eab329dd608035ac69c7737b4a1f525efd51114b
/demo/Demo.cpp
6c9daa0283204348aa890ba5e4c0dc4cc4fa45be
[]
no_license
lineCode/Flexium
a8c8c07de3015928b0df757487f3002bb3268bab
4e38d4a9f6b37d39eeca28e8d96d4b23f6197ba6
refs/heads/master
2021-05-30T03:30:33.109035
2015-03-29T00:33:38
2015-03-29T00:33:38
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,679
cpp
#include <Flexium/World.hpp> #include <Flexium/Object.hpp> #include <Flexium/Window.hpp> #include <Flexium/Sprite.hpp> #include <Flexium/Input.hpp> #include <Flexium/Audio.hpp> #include <Flexium/Text.hpp> #include <Flexium/FlexiumUtility.hpp> #include <Flexium/Console.hpp> using namespace flx; class ObjectDemo : public Object { private: Vector velocity; int anim_frame; bool anim; public: ObjectDemo(): velocity(4, 4), anim(false) {}; virtual void onCreate() { setDimensionsToSprite("image"); } virtual void onUpdate() { bool bounced = false; position += velocity; if (position.x < 0) { velocity.x = 4; bounced = true; } if (position.x > 800) { velocity.x = -4; bounced = true; } if (position.y < 0) { velocity.y = 4; bounced = true; } if (position.y > 400) { velocity.y = -4; bounced = true; } if (bounced) { Audio::play("sound"); } if (Input::keyPressed(Input::Key::Space)) { velocity *= 4; anim = !anim; } anim_frame++; } virtual void onDraw() { Sprite::draw(position, "image"); Sprite::draw(30, 100, anim ? "animation" : "animation2", anim_frame / 4); Text::draw(30, 30, "Flexium minimalistic demo. Try pressing space.", "font", 32, sf::Color::White); } }; int main() { Window::WindowSettings ws; ws.title = "Flexium Demo"; Window::initiate(ws); Window::setFrameRateLimit(60); Sprite::loadMapping("spritesheet.xml"); Audio::loadMapping("soundsheet.xml"); Text::loadMapping("fontsheet.xml"); World w; w.instanceAdd(new Debugger()); w.instanceAdd(new ConsoleInGame()); w.instanceAdd(new ObjectDemo()); while (w.simulate()); }
0e6020405ed394e8a1a99a73766bdf50ec666af9
7903d6d74572e9ee82d9ca07e2af7852204ecaa3
/app/src/main/jni/ndnrtc-wrapper.hpp
480bc143a0ec667e4d1ba09bb7e6a07405710b3c
[]
no_license
peurpdapeurp/ndnpttv2
2c3948f1a62c5d64e1570a6a30d67fa4a12b53d6
a55c56b6048924649ef67ec4dd9f4118af409d31
refs/heads/master
2022-02-19T07:41:08.773848
2019-08-05T14:43:23
2019-08-05T14:43:23
197,838,004
0
0
null
null
null
null
UTF-8
C++
false
false
543
hpp
/* DO NOT EDIT THIS FILE - it is machine generated */ #include <jni.h> /* Header for class net_named_data_nfd_service_NfdService */ #ifndef _Included_com_example_nrtpttv2_MainActivity #define _Included_com_example_nrtpttv2_MainActivity #ifdef __cplusplus extern "C" { #endif /* * Class: com_example_nrtpttv2_MainActivity * Method: startNdnRtc * Signature: (Ljava/lang/Map;)V */ JNIEXPORT void JNICALL Java_com_example_nrtpttv2_MainActivity_startNdnRtc(JNIEnv*, jclass, jobject); #ifdef __cplusplus } #endif #endif
4785bf4c7ee0fb5be57ba7aff36b37c08a867a15
6e57bdc0a6cd18f9f546559875256c4570256c45
/frameworks/base/core/jni/android/graphics/SkDrmStream.h
d2e6ddc286e54da7ade4579b2a28abd2bf5690a2
[ "Apache-2.0", "LicenseRef-scancode-unicode" ]
permissive
dongdong331/test
969d6e945f7f21a5819cd1d5f536d12c552e825c
2ba7bcea4f9d9715cbb1c4e69271f7b185a0786e
refs/heads/master
2023-03-07T06:56:55.210503
2020-12-07T04:15:33
2020-12-07T04:15:33
134,398,935
2
1
null
2022-11-21T07:53:41
2018-05-22T10:26:42
null
UTF-8
C++
false
false
1,212
h
/* * Copyright 2006 The Android Open Source Project * * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ #ifndef SkDrmStream_DEFINED #define SkDrmStream_DEFINED #include "SkData.h" #include "SkRefCnt.h" #include "SkScalar.h" #include "SkStream.h" #include <memory.h> namespace android { class DrmManagerClientImpl; class DecryptHandleWrapper; }; using android::DrmManagerClientImpl; using android::DecryptHandleWrapper; //////////////////////////////////////////////////////////////////////////////////////// #include <stdio.h> class SkDrmStream : public SkStreamRewindable { int mUniqueId; off64_t mOffset; DrmManagerClientImpl* mClient; DecryptHandleWrapper* mHandleWrapper; bool mEof; public: SkDrmStream(int uniqueId, DrmManagerClientImpl*, DecryptHandleWrapper*); virtual ~SkDrmStream(); virtual bool rewind() override ; virtual size_t read(void* buffer, size_t size) override ; // virtual const char* getFileName() override { return NULL; } virtual bool isAtEnd() const override { return mEof; } private: SkStreamRewindable* onDuplicate() const override { return NULL; } }; #endif
42f9fcb883c55ecc6fd865232da965184313079b
3cb5766b32ec181661eb6fe61bde45036bf16dec
/week_2/week_2/week2Define.h
a834810f05ceb169cea53de2809b5e8845f7c637
[]
no_license
guihunkun/LearnCPlusPlus
e1525d0c1a5770dd7e007088d21eff1d8d0927ef
64f9d9f5da449b1686d6df1f3c11ade975a477c3
refs/heads/master
2021-07-05T01:06:31.249160
2021-04-26T09:15:33
2021-04-26T09:15:33
227,984,690
1
0
null
null
null
null
UTF-8
C++
false
false
618
h
// // week2Define.h // week_2 // // Created by 曲晓昆 on 2019/11/18. // Copyright © 2019 曲晓昆. All rights reserved. // #ifndef week2Define_h #define week2Define_h #include <string> #include <vector> using namespace std; #define MAX_INT1 (INT_MAX) const int MAX_INT2 = INT_MAX; enum EDA2 {argus, aether, rce, fpd, qa}; struct Personal { string name; vector<int> tel; //int tel[11]; Personal(string na, vector<int>& phone); void printTel(); }; vector<int> intVect; struct Point { int x,y; Point(int _x = 0, int _y = 0); void printPoint(); }; #endif /* week2Define_h */
17f0776458b7604e08b32275c966bfdde9d1738c
b30ce2bde2534904932266f67d93444360d21db2
/Arduino/libraries/ros_lib/vector_map_msgs/WallArray.h
3492c65e435a128a3055b06bd2591d3b56481606
[]
no_license
MaxDeSantis/pid_ball_balancer_cbs
ee987b00474ec69d09ddc5f74bf9b9a3bc08f722
5266c1802631bdfce0425fbba75240a5f29c1c71
refs/heads/main
2023-04-07T15:12:24.028858
2021-04-18T16:44:02
2021-04-18T16:44:02
339,237,652
1
0
null
null
null
null
UTF-8
C++
false
false
2,263
h
#ifndef _ROS_vector_map_msgs_WallArray_h #define _ROS_vector_map_msgs_WallArray_h #include <stdint.h> #include <string.h> #include <stdlib.h> #include "ros/msg.h" #include "std_msgs/Header.h" #include "vector_map_msgs/Wall.h" namespace vector_map_msgs { class WallArray : public ros::Msg { public: typedef std_msgs::Header _header_type; _header_type header; uint32_t data_length; typedef vector_map_msgs::Wall _data_type; _data_type st_data; _data_type * data; WallArray(): header(), data_length(0), data(NULL) { } virtual int serialize(unsigned char *outbuffer) const { int offset = 0; offset += this->header.serialize(outbuffer + offset); *(outbuffer + offset + 0) = (this->data_length >> (8 * 0)) & 0xFF; *(outbuffer + offset + 1) = (this->data_length >> (8 * 1)) & 0xFF; *(outbuffer + offset + 2) = (this->data_length >> (8 * 2)) & 0xFF; *(outbuffer + offset + 3) = (this->data_length >> (8 * 3)) & 0xFF; offset += sizeof(this->data_length); for( uint32_t i = 0; i < data_length; i++){ offset += this->data[i].serialize(outbuffer + offset); } return offset; } virtual int deserialize(unsigned char *inbuffer) { int offset = 0; offset += this->header.deserialize(inbuffer + offset); uint32_t data_lengthT = ((uint32_t) (*(inbuffer + offset))); data_lengthT |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); data_lengthT |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); data_lengthT |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); offset += sizeof(this->data_length); if(data_lengthT > data_length) this->data = (vector_map_msgs::Wall*)realloc(this->data, data_lengthT * sizeof(vector_map_msgs::Wall)); data_length = data_lengthT; for( uint32_t i = 0; i < data_length; i++){ offset += this->st_data.deserialize(inbuffer + offset); memcpy( &(this->data[i]), &(this->st_data), sizeof(vector_map_msgs::Wall)); } return offset; } const char * getType(){ return "vector_map_msgs/WallArray"; }; const char * getMD5(){ return "62d7f260c71b469b058ab28f3bce2ded"; }; }; } #endif
415cf7adf816d780ad4ef9cde497ce31c211af60
fdaa9b0627b4bbbb3d9cb50c5336fb3d2760023e
/src/rpc/misc.cpp
99bf7b3fb733bc7b825c63b686d9de401e11cb12
[ "MIT" ]
permissive
coppercurrency/copper
ff7f8583f467a4a3c3ed87ffb4179f5be276c5a8
a5e9d15ef68231bc28ce0a394b1e967a6cf0b1dd
refs/heads/master
2020-04-15T21:11:34.735457
2019-01-10T16:06:03
2019-01-10T16:06:03
165,024,201
0
1
null
null
null
null
UTF-8
C++
false
false
31,286
cpp
// Copyright (c) 2010 Satoshi Nakamoto // Copyright (c) 2009-2016 The Bitcoin Core developers // Copyright (c) 2017 The Copper Core developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #include "base58.h" #include "chain.h" #include "clientversion.h" #include "core_io.h" #include "crypto/ripemd160.h" #include "init.h" #include "validation.h" #include "httpserver.h" #include "net.h" #include "netbase.h" #include "rpc/blockchain.h" #include "rpc/server.h" #include "timedata.h" #include "util.h" #include "utilstrencodings.h" #ifdef ENABLE_WALLET #include "wallet/rpcwallet.h" #include "wallet/wallet.h" #include "wallet/walletdb.h" #endif #include "warnings.h" #include <stdint.h> #ifdef HAVE_MALLOC_INFO #include <malloc.h> #endif #include <univalue.h> /** * @note Do not add or change anything in the information returned by this * method. `getinfo` exists for backwards-compatibility only. It combines * information from wildly different sources in the program, which is a mess, * and is thus planned to be deprecated eventually. * * Based on the source of the information, new information should be added to: * - `getblockchaininfo`, * - `getnetworkinfo` or * - `getwalletinfo` * * Or alternatively, create a specific query method for the information. **/ UniValue getinfo(const JSONRPCRequest& request) { if (request.fHelp || request.params.size() != 0) throw std::runtime_error( "getinfo\n" "\nDEPRECATED. Returns an object containing various state info.\n" "\nResult:\n" "{\n" " \"deprecation-warning\": \"...\" (string) warning that the getinfo command is deprecated and will be removed in 0.16\n" " \"version\": xxxxx, (numeric) the server version\n" " \"protocolversion\": xxxxx, (numeric) the protocol version\n" " \"walletversion\": xxxxx, (numeric) the wallet version\n" " \"balance\": xxxxxxx, (numeric) the total bitcoin balance of the wallet\n" " \"blocks\": xxxxxx, (numeric) the current number of blocks processed in the server\n" " \"timeoffset\": xxxxx, (numeric) the time offset\n" " \"connections\": xxxxx, (numeric) the number of connections\n" " \"proxy\": \"host:port\", (string, optional) the proxy used by the server\n" " \"difficulty\": xxxxxx, (numeric) the current difficulty\n" " \"testnet\": true|false, (boolean) if the server is using testnet or not\n" " \"keypoololdest\": xxxxxx, (numeric) the timestamp (seconds since Unix epoch) of the oldest pre-generated key in the key pool\n" " \"keypoolsize\": xxxx, (numeric) how many new keys are pre-generated\n" " \"unlocked_until\": ttt, (numeric) the timestamp in seconds since epoch (midnight Jan 1 1970 GMT) that the wallet is unlocked for transfers, or 0 if the wallet is locked\n" " \"paytxfee\": x.xxxx, (numeric) the transaction fee set in " + CURRENCY_UNIT + "/kB\n" " \"relayfee\": x.xxxx, (numeric) minimum relay fee for transactions in " + CURRENCY_UNIT + "/kB\n" " \"errors\": \"...\" (string) any error messages\n" "}\n" "\nExamples:\n" + HelpExampleCli("getinfo", "") + HelpExampleRpc("getinfo", "") ); #ifdef ENABLE_WALLET CWallet * const pwallet = GetWalletForJSONRPCRequest(request); LOCK2(cs_main, pwallet ? &pwallet->cs_wallet : nullptr); #else LOCK(cs_main); #endif proxyType proxy; GetProxy(NET_IPV4, proxy); UniValue obj(UniValue::VOBJ); obj.push_back(Pair("deprecation-warning", "WARNING: getinfo is deprecated and will be fully removed in 0.16." " Projects should transition to using getblockchaininfo, getnetworkinfo, and getwalletinfo before upgrading to 0.16")); obj.push_back(Pair("version", CLIENT_VERSION)); obj.push_back(Pair("protocolversion", PROTOCOL_VERSION)); #ifdef ENABLE_WALLET if (pwallet) { obj.push_back(Pair("walletversion", pwallet->GetVersion())); obj.push_back(Pair("balance", ValueFromAmount(pwallet->GetBalance()))); } #endif obj.push_back(Pair("blocks", (int)chainActive.Height())); obj.push_back(Pair("timeoffset", GetTimeOffset())); if(g_connman) obj.push_back(Pair("connections", (int)g_connman->GetNodeCount(CConnman::CONNECTIONS_ALL))); obj.push_back(Pair("proxy", (proxy.IsValid() ? proxy.proxy.ToStringIPPort() : std::string()))); obj.push_back(Pair("difficulty", (double)GetDifficulty())); obj.push_back(Pair("testnet", Params().NetworkIDString() == CBaseChainParams::TESTNET)); #ifdef ENABLE_WALLET if (pwallet) { obj.push_back(Pair("keypoololdest", pwallet->GetOldestKeyPoolTime())); obj.push_back(Pair("keypoolsize", (int)pwallet->GetKeyPoolSize())); } if (pwallet && pwallet->IsCrypted()) { obj.push_back(Pair("unlocked_until", pwallet->nRelockTime)); } obj.push_back(Pair("paytxfee", ValueFromAmount(payTxFee.GetFeePerK()))); #endif obj.push_back(Pair("relayfee", ValueFromAmount(::minRelayTxFee.GetFeePerK()))); obj.push_back(Pair("errors", GetWarnings("statusbar"))); return obj; } #ifdef ENABLE_WALLET class DescribeAddressVisitor : public boost::static_visitor<UniValue> { public: CWallet * const pwallet; explicit DescribeAddressVisitor(CWallet *_pwallet) : pwallet(_pwallet) {} UniValue operator()(const CNoDestination &dest) const { return UniValue(UniValue::VOBJ); } UniValue operator()(const CKeyID &keyID) const { UniValue obj(UniValue::VOBJ); CPubKey vchPubKey; obj.push_back(Pair("isscript", false)); obj.push_back(Pair("iswitness", false)); if (pwallet && pwallet->GetPubKey(keyID, vchPubKey)) { obj.push_back(Pair("pubkey", HexStr(vchPubKey))); obj.push_back(Pair("iscompressed", vchPubKey.IsCompressed())); } return obj; } UniValue operator()(const CScriptID &scriptID) const { UniValue obj(UniValue::VOBJ); CScript subscript; obj.push_back(Pair("isscript", true)); obj.push_back(Pair("iswitness", false)); if (pwallet && pwallet->GetCScript(scriptID, subscript)) { std::vector<CTxDestination> addresses; txnouttype whichType; int nRequired; ExtractDestinations(subscript, whichType, addresses, nRequired); obj.push_back(Pair("script", GetTxnOutputType(whichType))); obj.push_back(Pair("hex", HexStr(subscript.begin(), subscript.end()))); UniValue a(UniValue::VARR); for (const CTxDestination& addr : addresses) { a.push_back(EncodeDestination(addr)); } obj.push_back(Pair("addresses", a)); if (whichType == TX_MULTISIG) obj.push_back(Pair("sigsrequired", nRequired)); } return obj; } UniValue operator()(const WitnessV0KeyHash& id) const { UniValue obj(UniValue::VOBJ); CPubKey pubkey; obj.push_back(Pair("isscript", false)); obj.push_back(Pair("iswitness", true)); obj.push_back(Pair("witness_version", 0)); obj.push_back(Pair("witness_program", HexStr(id.begin(), id.end()))); if (pwallet && pwallet->GetPubKey(CKeyID(id), pubkey)) { obj.push_back(Pair("pubkey", HexStr(pubkey))); } return obj; } UniValue operator()(const WitnessV0ScriptHash& id) const { UniValue obj(UniValue::VOBJ); CScript subscript; obj.push_back(Pair("isscript", true)); obj.push_back(Pair("iswitness", true)); obj.push_back(Pair("witness_version", 0)); obj.push_back(Pair("witness_program", HexStr(id.begin(), id.end()))); CRIPEMD160 hasher; uint160 hash; hasher.Write(id.begin(), 32).Finalize(hash.begin()); if (pwallet && pwallet->GetCScript(CScriptID(hash), subscript)) { obj.push_back(Pair("hex", HexStr(subscript.begin(), subscript.end()))); } return obj; } UniValue operator()(const WitnessUnknown& id) const { UniValue obj(UniValue::VOBJ); CScript subscript; obj.push_back(Pair("iswitness", true)); obj.push_back(Pair("witness_version", (int)id.version)); obj.push_back(Pair("witness_program", HexStr(id.program, id.program + id.length))); return obj; } }; #endif UniValue validateaddress(const JSONRPCRequest& request) { if (request.fHelp || request.params.size() != 1) throw std::runtime_error( "validateaddress \"address\"\n" "\nReturn information about the given copper address.\n" "\nArguments:\n" "1. \"address\" (string, required) The copper address to validate\n" "\nResult:\n" "{\n" " \"isvalid\" : true|false, (boolean) If the address is valid or not. If not, this is the only property returned.\n" " \"address\" : \"address\", (string) The copper address validated\n" " \"scriptPubKey\" : \"hex\", (string) The hex encoded scriptPubKey generated by the address\n" " \"ismine\" : true|false, (boolean) If the address is yours or not\n" " \"iswatchonly\" : true|false, (boolean) If the address is watchonly\n" " \"isscript\" : true|false, (boolean) If the key is a script\n" " \"script\" : \"type\" (string, optional) The output script type. Possible types: nonstandard, pubkey, pubkeyhash, scripthash, multisig, nulldata, witness_v0_keyhash, witness_v0_scripthash\n" " \"hex\" : \"hex\", (string, optional) The redeemscript for the p2sh address\n" " \"addresses\" (string, optional) Array of addresses associated with the known redeemscript\n" " [\n" " \"address\"\n" " ,...\n" " ]\n" " \"sigsrequired\" : xxxxx (numeric, optional) Number of signatures required to spend multisig output\n" " \"pubkey\" : \"publickeyhex\", (string) The hex value of the raw public key\n" " \"iscompressed\" : true|false, (boolean) If the address is compressed\n" " \"account\" : \"account\" (string) DEPRECATED. The account associated with the address, \"\" is the default account\n" " \"timestamp\" : timestamp, (number, optional) The creation time of the key if available in seconds since epoch (Jan 1 1970 GMT)\n" " \"hdkeypath\" : \"keypath\" (string, optional) The HD keypath if the key is HD and available\n" " \"hdmasterkeyid\" : \"<hash160>\" (string, optional) The Hash160 of the HD master pubkey\n" "}\n" "\nExamples:\n" + HelpExampleCli("validateaddress", "\"1PSSGeFHDnKNxiEyFrD1wcEaHr9hrQDDWc\"") + HelpExampleRpc("validateaddress", "\"1PSSGeFHDnKNxiEyFrD1wcEaHr9hrQDDWc\"") ); #ifdef ENABLE_WALLET CWallet * const pwallet = GetWalletForJSONRPCRequest(request); LOCK2(cs_main, pwallet ? &pwallet->cs_wallet : nullptr); #else LOCK(cs_main); #endif CTxDestination dest = DecodeDestination(request.params[0].get_str()); bool isValid = IsValidDestination(dest); UniValue ret(UniValue::VOBJ); ret.push_back(Pair("isvalid", isValid)); if (isValid) { std::string currentAddress = EncodeDestination(dest); ret.push_back(Pair("address", currentAddress)); CScript scriptPubKey = GetScriptForDestination(dest); ret.push_back(Pair("scriptPubKey", HexStr(scriptPubKey.begin(), scriptPubKey.end()))); #ifdef ENABLE_WALLET isminetype mine = pwallet ? IsMine(*pwallet, dest) : ISMINE_NO; ret.push_back(Pair("ismine", bool(mine & ISMINE_SPENDABLE))); ret.push_back(Pair("iswatchonly", bool(mine & ISMINE_WATCH_ONLY))); UniValue detail = boost::apply_visitor(DescribeAddressVisitor(pwallet), dest); ret.pushKVs(detail); if (pwallet && pwallet->mapAddressBook.count(dest)) { ret.push_back(Pair("account", pwallet->mapAddressBook[dest].name)); } if (pwallet) { const auto& meta = pwallet->mapKeyMetadata; const CKeyID *keyID = boost::get<CKeyID>(&dest); auto it = keyID ? meta.find(*keyID) : meta.end(); if (it == meta.end()) { it = meta.find(CScriptID(scriptPubKey)); } if (it != meta.end()) { ret.push_back(Pair("timestamp", it->second.nCreateTime)); if (!it->second.hdKeypath.empty()) { ret.push_back(Pair("hdkeypath", it->second.hdKeypath)); ret.push_back(Pair("hdmasterkeyid", it->second.hdMasterKeyID.GetHex())); } } } #endif } return ret; } // Needed even with !ENABLE_WALLET, to pass (ignored) pointers around class CWallet; /** * Used by addmultisigaddress / createmultisig: */ CScript _createmultisig_redeemScript(CWallet * const pwallet, const UniValue& params) { int nRequired = params[0].get_int(); const UniValue& keys = params[1].get_array(); // Gather public keys if (nRequired < 1) throw std::runtime_error("a multisignature address must require at least one key to redeem"); if ((int)keys.size() < nRequired) throw std::runtime_error( strprintf("not enough keys supplied " "(got %u keys, but need at least %d to redeem)", keys.size(), nRequired)); if (keys.size() > 16) throw std::runtime_error("Number of addresses involved in the multisignature address creation > 16\nReduce the number"); std::vector<CPubKey> pubkeys; pubkeys.resize(keys.size()); for (unsigned int i = 0; i < keys.size(); i++) { const std::string& ks = keys[i].get_str(); #ifdef ENABLE_WALLET // Case 1: Copper address and we have full public key: CTxDestination dest = DecodeDestination(ks); if (pwallet && IsValidDestination(dest)) { const CKeyID *keyID = boost::get<CKeyID>(&dest); if (!keyID) { throw std::runtime_error(strprintf("%s does not refer to a key", ks)); } CPubKey vchPubKey; if (!pwallet->GetPubKey(*keyID, vchPubKey)) { throw std::runtime_error(strprintf("no full public key for address %s", ks)); } if (!vchPubKey.IsFullyValid()) throw std::runtime_error(" Invalid public key: "+ks); pubkeys[i] = vchPubKey; } // Case 2: hex public key else #endif if (IsHex(ks)) { CPubKey vchPubKey(ParseHex(ks)); if (!vchPubKey.IsFullyValid()) throw std::runtime_error(" Invalid public key: "+ks); pubkeys[i] = vchPubKey; } else { throw std::runtime_error(" Invalid public key: "+ks); } } CScript result = GetScriptForMultisig(nRequired, pubkeys); if (result.size() > MAX_SCRIPT_ELEMENT_SIZE) throw std::runtime_error( strprintf("redeemScript exceeds size limit: %d > %d", result.size(), MAX_SCRIPT_ELEMENT_SIZE)); return result; } UniValue createmultisig(const JSONRPCRequest& request) { #ifdef ENABLE_WALLET CWallet * const pwallet = GetWalletForJSONRPCRequest(request); #else CWallet * const pwallet = nullptr; #endif if (request.fHelp || request.params.size() < 2 || request.params.size() > 2) { std::string msg = "createmultisig nrequired [\"key\",...]\n" "\nCreates a multi-signature address with n signature of m keys required.\n" "It returns a json object with the address and redeemScript.\n" "\nArguments:\n" "1. nrequired (numeric, required) The number of required signatures out of the n keys or addresses.\n" "2. \"keys\" (string, required) A json array of keys which are copper addresses or hex-encoded public keys\n" " [\n" " \"key\" (string) copper address or hex-encoded public key\n" " ,...\n" " ]\n" "\nResult:\n" "{\n" " \"address\":\"multisigaddress\", (string) The value of the new multisig address.\n" " \"redeemScript\":\"script\" (string) The string value of the hex-encoded redemption script.\n" "}\n" "\nExamples:\n" "\nCreate a multisig address from 2 addresses\n" + HelpExampleCli("createmultisig", "2 \"[\\\"16sSauSf5pF2UkUwvKGq4qjNRzBZYqgEL5\\\",\\\"171sgjn4YtPu27adkKGrdDwzRTxnRkBfKV\\\"]\"") + "\nAs a json rpc call\n" + HelpExampleRpc("createmultisig", "2, \"[\\\"16sSauSf5pF2UkUwvKGq4qjNRzBZYqgEL5\\\",\\\"171sgjn4YtPu27adkKGrdDwzRTxnRkBfKV\\\"]\"") ; throw std::runtime_error(msg); } // Construct using pay-to-script-hash: CScript inner = _createmultisig_redeemScript(pwallet, request.params); CScriptID innerID(inner); UniValue result(UniValue::VOBJ); result.push_back(Pair("address", EncodeDestination(innerID))); result.push_back(Pair("redeemScript", HexStr(inner.begin(), inner.end()))); return result; } UniValue verifymessage(const JSONRPCRequest& request) { if (request.fHelp || request.params.size() != 3) throw std::runtime_error( "verifymessage \"address\" \"signature\" \"message\"\n" "\nVerify a signed message\n" "\nArguments:\n" "1. \"address\" (string, required) The copper address to use for the signature.\n" "2. \"signature\" (string, required) The signature provided by the signer in base 64 encoding (see signmessage).\n" "3. \"message\" (string, required) The message that was signed.\n" "\nResult:\n" "true|false (boolean) If the signature is verified or not.\n" "\nExamples:\n" "\nUnlock the wallet for 30 seconds\n" + HelpExampleCli("walletpassphrase", "\"mypassphrase\" 30") + "\nCreate the signature\n" + HelpExampleCli("signmessage", "\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XX\" \"my message\"") + "\nVerify the signature\n" + HelpExampleCli("verifymessage", "\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XX\" \"signature\" \"my message\"") + "\nAs json rpc\n" + HelpExampleRpc("verifymessage", "\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XX\", \"signature\", \"my message\"") ); LOCK(cs_main); std::string strAddress = request.params[0].get_str(); std::string strSign = request.params[1].get_str(); std::string strMessage = request.params[2].get_str(); CTxDestination destination = DecodeDestination(strAddress); if (!IsValidDestination(destination)) { throw JSONRPCError(RPC_TYPE_ERROR, "Invalid address"); } const CKeyID *keyID = boost::get<CKeyID>(&destination); if (!keyID) { throw JSONRPCError(RPC_TYPE_ERROR, "Address does not refer to key"); } bool fInvalid = false; std::vector<unsigned char> vchSig = DecodeBase64(strSign.c_str(), &fInvalid); if (fInvalid) throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Malformed base64 encoding"); CHashWriter ss(SER_GETHASH, 0); ss << strMessageMagic; ss << strMessage; CPubKey pubkey; if (!pubkey.RecoverCompact(ss.GetHash(), vchSig)) return false; return (pubkey.GetID() == *keyID); } UniValue signmessagewithprivkey(const JSONRPCRequest& request) { if (request.fHelp || request.params.size() != 2) throw std::runtime_error( "signmessagewithprivkey \"privkey\" \"message\"\n" "\nSign a message with the private key of an address\n" "\nArguments:\n" "1. \"privkey\" (string, required) The private key to sign the message with.\n" "2. \"message\" (string, required) The message to create a signature of.\n" "\nResult:\n" "\"signature\" (string) The signature of the message encoded in base 64\n" "\nExamples:\n" "\nCreate the signature\n" + HelpExampleCli("signmessagewithprivkey", "\"privkey\" \"my message\"") + "\nVerify the signature\n" + HelpExampleCli("verifymessage", "\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XX\" \"signature\" \"my message\"") + "\nAs json rpc\n" + HelpExampleRpc("signmessagewithprivkey", "\"privkey\", \"my message\"") ); std::string strPrivkey = request.params[0].get_str(); std::string strMessage = request.params[1].get_str(); CCopperSecret vchSecret; bool fGood = vchSecret.SetString(strPrivkey); if (!fGood) throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid private key"); CKey key = vchSecret.GetKey(); if (!key.IsValid()) throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Private key outside allowed range"); CHashWriter ss(SER_GETHASH, 0); ss << strMessageMagic; ss << strMessage; std::vector<unsigned char> vchSig; if (!key.SignCompact(ss.GetHash(), vchSig)) throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Sign failed"); return EncodeBase64(vchSig.data(), vchSig.size()); } UniValue setmocktime(const JSONRPCRequest& request) { if (request.fHelp || request.params.size() != 1) throw std::runtime_error( "setmocktime timestamp\n" "\nSet the local time to given timestamp (-regtest only)\n" "\nArguments:\n" "1. timestamp (integer, required) Unix seconds-since-epoch timestamp\n" " Pass 0 to go back to using the system time." ); if (!Params().MineBlocksOnDemand()) throw std::runtime_error("setmocktime for regression testing (-regtest mode) only"); // For now, don't change mocktime if we're in the middle of validation, as // this could have an effect on mempool time-based eviction, as well as // IsCurrentForFeeEstimation() and IsInitialBlockDownload(). // TODO: figure out the right way to synchronize around mocktime, and // ensure all call sites of GetTime() are accessing this safely. LOCK(cs_main); RPCTypeCheck(request.params, {UniValue::VNUM}); SetMockTime(request.params[0].get_int64()); return NullUniValue; } static UniValue RPCLockedMemoryInfo() { LockedPool::Stats stats = LockedPoolManager::Instance().stats(); UniValue obj(UniValue::VOBJ); obj.push_back(Pair("used", uint64_t(stats.used))); obj.push_back(Pair("free", uint64_t(stats.free))); obj.push_back(Pair("total", uint64_t(stats.total))); obj.push_back(Pair("locked", uint64_t(stats.locked))); obj.push_back(Pair("chunks_used", uint64_t(stats.chunks_used))); obj.push_back(Pair("chunks_free", uint64_t(stats.chunks_free))); return obj; } #ifdef HAVE_MALLOC_INFO static std::string RPCMallocInfo() { char *ptr = nullptr; size_t size = 0; FILE *f = open_memstream(&ptr, &size); if (f) { malloc_info(0, f); fclose(f); if (ptr) { std::string rv(ptr, size); free(ptr); return rv; } } return ""; } #endif UniValue getmemoryinfo(const JSONRPCRequest& request) { /* Please, avoid using the word "pool" here in the RPC interface or help, * as users will undoubtedly confuse it with the other "memory pool" */ if (request.fHelp || request.params.size() > 1) throw std::runtime_error( "getmemoryinfo (\"mode\")\n" "Returns an object containing information about memory usage.\n" "Arguments:\n" "1. \"mode\" determines what kind of information is returned. This argument is optional, the default mode is \"stats\".\n" " - \"stats\" returns general statistics about memory usage in the daemon.\n" " - \"mallocinfo\" returns an XML string describing low-level heap state (only available if compiled with glibc 2.10+).\n" "\nResult (mode \"stats\"):\n" "{\n" " \"locked\": { (json object) Information about locked memory manager\n" " \"used\": xxxxx, (numeric) Number of bytes used\n" " \"free\": xxxxx, (numeric) Number of bytes available in current arenas\n" " \"total\": xxxxxxx, (numeric) Total number of bytes managed\n" " \"locked\": xxxxxx, (numeric) Amount of bytes that succeeded locking. If this number is smaller than total, locking pages failed at some point and key data could be swapped to disk.\n" " \"chunks_used\": xxxxx, (numeric) Number allocated chunks\n" " \"chunks_free\": xxxxx, (numeric) Number unused chunks\n" " }\n" "}\n" "\nResult (mode \"mallocinfo\"):\n" "\"<malloc version=\"1\">...\"\n" "\nExamples:\n" + HelpExampleCli("getmemoryinfo", "") + HelpExampleRpc("getmemoryinfo", "") ); std::string mode = request.params[0].isNull() ? "stats" : request.params[0].get_str(); if (mode == "stats") { UniValue obj(UniValue::VOBJ); obj.push_back(Pair("locked", RPCLockedMemoryInfo())); return obj; } else if (mode == "mallocinfo") { #ifdef HAVE_MALLOC_INFO return RPCMallocInfo(); #else throw JSONRPCError(RPC_INVALID_PARAMETER, "mallocinfo is only available when compiled with glibc 2.10+"); #endif } else { throw JSONRPCError(RPC_INVALID_PARAMETER, "unknown mode " + mode); } } uint32_t getCategoryMask(UniValue cats) { cats = cats.get_array(); uint32_t mask = 0; for (unsigned int i = 0; i < cats.size(); ++i) { uint32_t flag = 0; std::string cat = cats[i].get_str(); if (!GetLogCategory(&flag, &cat)) { throw JSONRPCError(RPC_INVALID_PARAMETER, "unknown logging category " + cat); } mask |= flag; } return mask; } UniValue logging(const JSONRPCRequest& request) { if (request.fHelp || request.params.size() > 2) { throw std::runtime_error( "logging [include,...] <exclude>\n" "Gets and sets the logging configuration.\n" "When called without an argument, returns the list of categories that are currently being debug logged.\n" "When called with arguments, adds or removes categories from debug logging.\n" "The valid logging categories are: " + ListLogCategories() + "\n" "libevent logging is configured on startup and cannot be modified by this RPC during runtime." "Arguments:\n" "1. \"include\" (array of strings) add debug logging for these categories.\n" "2. \"exclude\" (array of strings) remove debug logging for these categories.\n" "\nResult: <categories> (string): a list of the logging categories that are active.\n" "\nExamples:\n" + HelpExampleCli("logging", "\"[\\\"all\\\"]\" \"[\\\"http\\\"]\"") + HelpExampleRpc("logging", "[\"all\"], \"[libevent]\"") ); } uint32_t originalLogCategories = logCategories; if (request.params[0].isArray()) { logCategories |= getCategoryMask(request.params[0]); } if (request.params[1].isArray()) { logCategories &= ~getCategoryMask(request.params[1]); } // Update libevent logging if BCLog::LIBEVENT has changed. // If the library version doesn't allow it, UpdateHTTPServerLogging() returns false, // in which case we should clear the BCLog::LIBEVENT flag. // Throw an error if the user has explicitly asked to change only the libevent // flag and it failed. uint32_t changedLogCategories = originalLogCategories ^ logCategories; if (changedLogCategories & BCLog::LIBEVENT) { if (!UpdateHTTPServerLogging(logCategories & BCLog::LIBEVENT)) { logCategories &= ~BCLog::LIBEVENT; if (changedLogCategories == BCLog::LIBEVENT) { throw JSONRPCError(RPC_INVALID_PARAMETER, "libevent logging cannot be updated when using libevent before v2.1.1."); } } } UniValue result(UniValue::VOBJ); std::vector<CLogCategoryActive> vLogCatActive = ListActiveLogCategories(); for (const auto& logCatActive : vLogCatActive) { result.pushKV(logCatActive.category, logCatActive.active); } return result; } UniValue echo(const JSONRPCRequest& request) { if (request.fHelp) throw std::runtime_error( "echo|echojson \"message\" ...\n" "\nSimply echo back the input arguments. This command is for testing.\n" "\nThe difference between echo and echojson is that echojson has argument conversion enabled in the client-side table in" "copper-cli and the GUI. There is no server-side difference." ); return request.params; } static const CRPCCommand commands[] = { // category name actor (function) argNames // --------------------- ------------------------ ----------------------- ---------- { "control", "getinfo", &getinfo, {} }, /* uses wallet if enabled */ { "control", "getmemoryinfo", &getmemoryinfo, {"mode"} }, { "util", "validateaddress", &validateaddress, {"address"} }, /* uses wallet if enabled */ { "util", "createmultisig", &createmultisig, {"nrequired","keys"} }, { "util", "verifymessage", &verifymessage, {"address","signature","message"} }, { "util", "signmessagewithprivkey", &signmessagewithprivkey, {"privkey","message"} }, /* Not shown in help */ { "hidden", "setmocktime", &setmocktime, {"timestamp"}}, { "hidden", "echo", &echo, {"arg0","arg1","arg2","arg3","arg4","arg5","arg6","arg7","arg8","arg9"}}, { "hidden", "echojson", &echo, {"arg0","arg1","arg2","arg3","arg4","arg5","arg6","arg7","arg8","arg9"}}, { "hidden", "logging", &logging, {"include", "exclude"}}, }; void RegisterMiscRPCCommands(CRPCTable &t) { for (unsigned int vcidx = 0; vcidx < ARRAYLEN(commands); vcidx++) t.appendCommand(commands[vcidx].name, &commands[vcidx]); }
905a431635c0f2f6cef37a61ac635c88ed3b5d91
fd91abeed800e16de57307ff3edd41f7bf51eeae
/大数/test.cpp
676395b8744d3b9a1e6858f497f449cac3e7d7e1
[]
no_license
whh89989/BigData
aa4ac25445c5097cb8d5cb3fbaa31acbcf227be6
e0215cc3dcfcb68b470c7a5a2e4fee7997a82b15
refs/heads/master
2021-01-21T23:53:23.531568
2017-09-02T08:12:14
2017-09-02T08:25:35
102,182,458
0
0
null
null
null
null
UTF-8
C++
false
false
150
cpp
#include "BigData.h" int main() { BigData bd1("9223372036854775809"); BigData bd2(234); cout << bd1 / bd2 << endl; system("pause"); return 0; }
dda168a7fe4ecd52b92fa1c98ca946d3754e72e5
ce4ef7a507b33baecca7272341c47e5fa8c278b7
/Dynamic Programming/min steps to one.cpp
29d6f1ac8282c2926f7705ce83d996f4cef7f8c6
[]
no_license
HarshitDhingra/Competitive-Programming
55fdac6045c1de0427315cc6fed609d3fd8f1559
867fb40018433816c90765be0154f17598912768
refs/heads/master
2023-01-31T12:32:38.094462
2020-12-12T16:20:28
2020-12-12T16:20:28
275,234,207
1
0
null
null
null
null
UTF-8
C++
false
false
1,123
cpp
#include <bits/stdc++.h> using namespace std; int min_steps_top_down(int n, int dp[]) { if (n == 1) return 0; if (dp[n] != 0) return dp[n]; int ans1 = INT_MAX, ans2 = INT_MAX, ans3 = INT_MAX; if (n % 2 == 0) { ans1 = min_steps_top_down(n / 2, dp); } if (n % 3 == 0) { ans2 = min_steps_top_down(n / 3, dp); } ans3 = min_steps_top_down(n - 1, dp); int ans = 1 + min(ans1, min(ans2, ans3)); dp[n] = ans; return ans; } int min_steps_top_down_botto_up(int n) { int dp[1000]; dp[1] = 0; for (int i = 2; i <= n; i++) { int ans1, ans2, ans3; ans1 = ans2 = ans3 = INT_MAX; if (i % 2 == 0) { ans1 = dp[i / 2]; } if (i % 3 == 0) { ans2 = dp[i / 3]; } ans3 = dp[i - 1]; dp[i] = 1 + min(ans1, min(ans2, ans3)); } return dp[n]; } int main() { int dp[1000] = {0}; int n; cin >> n; cout << min_steps_top_down(n, dp) << endl; cout << min_steps_top_down_botto_up(n); }
1d988c3954ad8e794222f84b64f29844ecf7e62e
4173c7b56a29f2b61b7ac703b7b914fd4f968115
/audioPlayer/src/testApp.cpp
c483aef72ca4590d0419ea62310783a5178ee3ef
[]
no_license
lukesturgeon/ReflextionToolkit
95e667f8089993c8a733297bdceca0c1148d2e41
02d7e7b99b92a222395a49ee5f11ba1196cb8093
refs/heads/master
2021-01-22T01:00:05.084353
2013-12-29T20:59:56
2013-12-29T20:59:56
15,492,057
1
0
null
null
null
null
UTF-8
C++
false
false
3,625
cpp
#include "testApp.h" //-------------------------------------------------------------- void testApp::setup() { ofSetFrameRate(30.0f); ofSetCircleResolution(100.0f); ofSetLineWidth(3.0f); ofNoFill(); // load the background background.loadImage("images/1280x720_background.png"); // load the fonts ofTrueTypeFont::setGlobalDpi(72); futuraLight48.loadFont("fonts/FuturaStd-Light.ttf", 48); // the fft needs to be smoothed out, so we create an array of floats nBandsToGet = 64; fftVolume = 0.0f; fftSmoothed = new float[nBandsToGet]; for (int i = 0; i < nBandsToGet; i++){ fftSmoothed[i] = 0.0f; } // calculate the total length once (we don't need to keep re-calculating this) int totalTime = 60000 / 1000; totalSeconds = totalTime % 60; totalTime /= 60; totalMinutes = totalTime % 60; // load the audio track audio.loadSound("sound/final_reflection_1min.mp3"); audio.setVolume(1.0f); audio.play(); } //-------------------------------------------------------------- void testApp::update(){ // update the OF sound engine ofSoundUpdate(); float all = 0.0f; // request values from FFT float * val = ofSoundGetSpectrum(nBandsToGet); for (int i = 0; i < nBandsToGet; i++){ // let the smoothed calue sink to zero: fftSmoothed[i] *= 0.96f; // take the max, either the smoothed or the incoming: if (fftSmoothed[i] < val[i]) fftSmoothed[i] = val[i]; all += fftSmoothed[i]; } // save one number that sums up the entire spectrum fftVolume = all * 0.5f; } //-------------------------------------------------------------- void testApp::draw(){ background.draw(0.0f,0.0f); // draw the circles float offset = fftVolume * 30.0f; /*ofEllipse(ofGetWidth()*0.5f, ofGetHeight() * 0.5f, 400.0f + offset, 400.0f + offset);*/ // calculate the current time int currentTime = audio.getPositionMS() / 1000; int currentSeconds = currentTime % 60; currentTime /= 60; int currentMinutes = currentTime % 60; // draw the current time string s = nf(currentMinutes, 2) + ":" + nf(currentSeconds, 2) + "/" + nf(totalMinutes,2) + ":" + nf(totalSeconds,2); ofRectangle rect = futuraLight48.getStringBoundingBox(s, 0, 0); futuraLight48.drawString(s, (int)(ofGetWidth()*0.5f - (rect.width*0.5f) ), (ofGetHeight()*0.5f)+18.0f); cout << audio.getPositionMS() << endl; } //-------------------------------------------------------------- string testApp::nf(int number, int digits) { string format = "%0" + ofToString(digits) + "d"; char buffer[100]; sprintf(buffer, format.c_str(), number); return (string)buffer; } //-------------------------------------------------------------- void testApp::keyPressed(int key){ } //-------------------------------------------------------------- void testApp::keyReleased(int key){ } //-------------------------------------------------------------- void testApp::mouseMoved(int x, int y ){ } //-------------------------------------------------------------- void testApp::mouseDragged(int x, int y, int button){ } //-------------------------------------------------------------- void testApp::mousePressed(int x, int y, int button){ } //-------------------------------------------------------------- void testApp::mouseReleased(int x, int y, int button){ } //-------------------------------------------------------------- void testApp::windowResized(int w, int h){ } //-------------------------------------------------------------- void testApp::gotMessage(ofMessage msg){ } //-------------------------------------------------------------- void testApp::dragEvent(ofDragInfo dragInfo){ }
[ "lukesturgeon@unknown-00:26:bb:18:45:d7.home" ]
lukesturgeon@unknown-00:26:bb:18:45:d7.home
baeecd62b08558008c356dfdf8ef9f0063ac496d
96b671705ba09a3aedd9abc3377e5604a33ba542
/ddraw/IDirect3DVertexBufferX.cpp
719a0a8aa52f7bfcfae06fef0bab84f67bc27d64
[ "Zlib" ]
permissive
AirwavesMan/dxwrapper
13b1701d727bc69713c3c9781f22f72bcdb482bf
b0ad9aea3855c98fa8cf930c8cb71dfd603be3a2
refs/heads/master
2020-11-29T23:47:20.027870
2019-12-16T03:50:06
2019-12-16T03:50:06
230,242,369
1
0
NOASSERTION
2019-12-26T10:14:31
2019-12-26T10:14:30
null
UTF-8
C++
false
false
5,437
cpp
/** * Copyright (C) 2019 Elisha Riedlinger * * This software is provided 'as-is', without any express or implied warranty. In no event will the * authors be held liable for any damages arising from the use of this software. * Permission is granted to anyone to use this software for any purpose, including commercial * applications, and to alter it and redistribute it freely, subject to the following restrictions: * * 1. The origin of this software must not be misrepresented; you must not claim that you wrote the * original software. If you use this software in a product, an acknowledgment in the product * documentation would be appreciated but is not required. * 2. Altered source versions must be plainly marked as such, and must not be misrepresented as * being the original software. * 3. This notice may not be removed or altered from any source distribution. */ #include "ddraw.h" HRESULT m_IDirect3DVertexBufferX::QueryInterface(REFIID riid, LPVOID * ppvObj, DWORD DirectXVersion) { Logging::LogDebug() << __FUNCTION__ << " (" << this << ")"; if (ProxyDirectXVersion == 9) { if ((riid == IID_IDirect3DVertexBuffer || riid == IID_IDirect3DVertexBuffer7 || riid == IID_IUnknown) && ppvObj) { AddRef(); *ppvObj = this; return D3D_OK; } } return ProxyQueryInterface(ProxyInterface, riid, ppvObj, GetWrapperType(DirectXVersion), WrapperInterface); } void *m_IDirect3DVertexBufferX::GetWrapperInterfaceX(DWORD DirectXVersion) { switch (DirectXVersion) { case 1: if (!UniqueProxyInterface.get()) { UniqueProxyInterface = std::make_unique<m_IDirect3DVertexBuffer>(this); } return UniqueProxyInterface.get(); case 7: if (!UniqueProxyInterface7.get()) { UniqueProxyInterface7 = std::make_unique<m_IDirect3DVertexBuffer7>(this); } return UniqueProxyInterface7.get(); default: LOG_LIMIT(100, __FUNCTION__ << " Error: wrapper interface version not found: " << DirectXVersion); return nullptr; } } ULONG m_IDirect3DVertexBufferX::AddRef() { Logging::LogDebug() << __FUNCTION__ << " (" << this << ")"; if (ProxyDirectXVersion == 9) { return InterlockedIncrement(&RefCount); } return ProxyInterface->AddRef(); } ULONG m_IDirect3DVertexBufferX::Release() { Logging::LogDebug() << __FUNCTION__ << " (" << this << ")"; LONG ref; if (ProxyDirectXVersion == 9) { ref = InterlockedDecrement(&RefCount); } else { ref = ProxyInterface->Release(); } if (ref == 0) { if (WrapperInterface) { WrapperInterface->DeleteMe(); } else { delete this; } } return ref; } HRESULT m_IDirect3DVertexBufferX::Lock(DWORD dwFlags, LPVOID * lplpData, LPDWORD lpdwSize) { Logging::LogDebug() << __FUNCTION__ << " (" << this << ")"; if (ProxyDirectXVersion == 9) { LOG_LIMIT(100, __FUNCTION__ << " Not Implemented"); return DDERR_UNSUPPORTED; } return ProxyInterface->Lock(dwFlags, lplpData, lpdwSize); } HRESULT m_IDirect3DVertexBufferX::Unlock() { Logging::LogDebug() << __FUNCTION__ << " (" << this << ")"; if (ProxyDirectXVersion == 9) { LOG_LIMIT(100, __FUNCTION__ << " Not Implemented"); return DDERR_UNSUPPORTED; } return ProxyInterface->Unlock(); } HRESULT m_IDirect3DVertexBufferX::ProcessVertices(DWORD dwVertexOp, DWORD dwDestIndex, DWORD dwCount, LPDIRECT3DVERTEXBUFFER7 lpSrcBuffer, DWORD dwSrcIndex, LPDIRECT3DDEVICE7 lpD3DDevice, DWORD dwFlags) { Logging::LogDebug() << __FUNCTION__ << " (" << this << ")"; if (ProxyDirectXVersion == 9) { LOG_LIMIT(100, __FUNCTION__ << " Not Implemented"); return DDERR_UNSUPPORTED; } if (lpSrcBuffer) { lpSrcBuffer = static_cast<m_IDirect3DVertexBuffer7 *>(lpSrcBuffer)->GetProxyInterface(); } if (lpD3DDevice) { lpD3DDevice = static_cast<m_IDirect3DDevice7 *>(lpD3DDevice)->GetProxyInterface(); } return ProxyInterface->ProcessVertices(dwVertexOp, dwDestIndex, dwCount, lpSrcBuffer, dwSrcIndex, lpD3DDevice, dwFlags); } HRESULT m_IDirect3DVertexBufferX::GetVertexBufferDesc(LPD3DVERTEXBUFFERDESC lpVBDesc) { Logging::LogDebug() << __FUNCTION__ << " (" << this << ")"; if (ProxyDirectXVersion == 9) { LOG_LIMIT(100, __FUNCTION__ << " Not Implemented"); return DDERR_UNSUPPORTED; } return ProxyInterface->GetVertexBufferDesc(lpVBDesc); } HRESULT m_IDirect3DVertexBufferX::Optimize(LPDIRECT3DDEVICE7 lpD3DDevice, DWORD dwFlags) { Logging::LogDebug() << __FUNCTION__ << " (" << this << ")"; if (ProxyDirectXVersion == 9) { LOG_LIMIT(100, __FUNCTION__ << " Not Implemented"); return DDERR_UNSUPPORTED; } if (lpD3DDevice) { lpD3DDevice = static_cast<m_IDirect3DDevice7 *>(lpD3DDevice)->GetProxyInterface(); } return ProxyInterface->Optimize(lpD3DDevice, dwFlags); } HRESULT m_IDirect3DVertexBufferX::ProcessVerticesStrided(DWORD dwVertexOp, DWORD dwDestIndex, DWORD dwCount, LPD3DDRAWPRIMITIVESTRIDEDDATA lpVertexArray, DWORD dwSrcIndex, LPDIRECT3DDEVICE7 lpD3DDevice, DWORD dwFlags) { Logging::LogDebug() << __FUNCTION__ << " (" << this << ")"; if (lpD3DDevice) { lpD3DDevice = static_cast<m_IDirect3DDevice7 *>(lpD3DDevice)->GetProxyInterface(); } switch (ProxyDirectXVersion) { case 1: return DDERR_GENERIC; case 7: return ProxyInterface->ProcessVerticesStrided(dwVertexOp, dwDestIndex, dwCount, lpVertexArray, dwSrcIndex, lpD3DDevice, dwFlags); case 9: LOG_LIMIT(100, __FUNCTION__ << " Not Implemented"); return DDERR_UNSUPPORTED; default: return DDERR_GENERIC; } }
e0db3db4c385a5de431abc64713f1d8c55558ef3
91a882547e393d4c4946a6c2c99186b5f72122dd
/Source/XPSP1/NT/multimedia/directx/dxvb/dx7vb/dplaylobby3obj.cpp
7697f2a369ed223a282fc78fb10e2525d4959dd9
[]
no_license
IAmAnubhavSaini/cryptoAlgorithm-nt5src
94f9b46f101b983954ac6e453d0cf8d02aa76fc7
d9e1cdeec650b9d6d3ce63f9f0abe50dabfaf9e2
refs/heads/master
2023-09-02T10:14:14.795579
2021-11-20T13:47:06
2021-11-20T13:47:06
null
0
0
null
null
null
null
UTF-8
C++
false
false
23,810
cpp
//+------------------------------------------------------------------------- // // Microsoft Windows // // Copyright (C) Microsoft Corporation, 1998 - 1999 // // File: dplaylobby3obj.cpp // //-------------------------------------------------------------------------- // _dxj_DirectPlayLobbyObj.cp\p : Implementation of C_dxj_DirectPlayLobbyObject // DHF begin - entire file #include "stdafx.h" #include "Direct.h" #include "dms.h" #include "dplay.h" #include "dplobby.h" #include "dxglob7obj.h" #include "dPlayLobby3Obj.h" #include "dPlay4Obj.h" #include "DPAddressObj.h" #include "DPLConnectionObj.h" #include "DPEnumLocalApplications.h" //#include "dpEnumAddressObj.h" //#include "dpEnumAddressTypesObj.h" #include "dpmsgObj.h" #include "string.h" typedef HRESULT (__stdcall *DIRECTPLAYLOBBYCREATE)(LPGUID, LPDIRECTPLAYLOBBY *, IUnknown *, LPVOID, DWORD ); extern DIRECTPLAYLOBBYCREATE pDirectPlayLobbyCreate; typedef HRESULT (__stdcall *DIRECTPLAYENUMERATE)( LPDPENUMDPCALLBACK, LPVOID ); extern DIRECTPLAYENUMERATE pDirectPlayEnumerate; extern HRESULT BSTRtoPPGUID(LPGUID*,BSTR); extern HRESULT BSTRtoGUID(LPGUID,BSTR); extern BSTR GUIDtoBSTR(LPGUID); extern void *g_dxj_DirectPlay4; extern HINSTANCE g_hDPlay; BSTR DPLGUIDtoBSTR(LPGUID pGuid); HRESULT DPLBSTRtoGUID(LPGUID pGuid,BSTR str); C_dxj_DirectPlayLobby3Object::C_dxj_DirectPlayLobby3Object() { m__dxj_DirectPlayLobby3 = NULL; #pragma message("DirectPlayLobby3 should be in object list") } C_dxj_DirectPlayLobby3Object::~C_dxj_DirectPlayLobby3Object() { if(m__dxj_DirectPlayLobby3) { m__dxj_DirectPlayLobby3->Release(); m__dxj_DirectPlayLobby3 = NULL; } } GETSET_OBJECT(_dxj_DirectPlayLobby3); // /*** I_dxj_DirectPlayLobby methods ***/ // ////////////////////////////////////////////////////////////////////////// STDMETHODIMP C_dxj_DirectPlayLobby3Object::connect(long flags, I_dxj_DirectPlay4 **val) { LPDIRECTPLAY2 dp=NULL; LPDIRECTPLAY4 dp4=NULL; HRESULT hr; hr= m__dxj_DirectPlayLobby3->Connect((DWORD) flags, &dp, NULL); if FAILED(hr) return hr; hr= dp->QueryInterface(IID_IDirectPlay4,(void**)&dp4); dp->Release(); if FAILED(hr) return hr; INTERNAL_CREATE(_dxj_DirectPlay4, dp4, val) return hr; } ////////////////////////////////////////////////////////////////////////// STDMETHODIMP C_dxj_DirectPlayLobby3Object::getConnectionSettings( /* [in] */ long AppID, /* [out]*/ I_dxj_DPLConnection **con){ DWORD dataSize = 0; LPVOID data; HRESULT hr; if (!con) return E_INVALIDARG; hr= m__dxj_DirectPlayLobby3->GetConnectionSettings((DWORD)AppID, NULL, &dataSize); //fix for bug 23385 if (hr!=DPERR_BUFFERTOOSMALL) return hr; *con=NULL; //Andrewke- //we now pass pack null if there are no connection settings. //will this ever happen? if (dataSize==0) return S_OK; data = alloca(dataSize); hr = m__dxj_DirectPlayLobby3->GetConnectionSettings((DWORD)AppID, (LPVOID)data, &dataSize); if FAILED(hr){ return E_OUTOFMEMORY; } I_dxj_DPLConnection *dplConnection=NULL; INTERNAL_CREATE_STRUCT(_dxj_DPLConnection,(&dplConnection)); if (dplConnection==NULL){ return E_OUTOFMEMORY; } hr=dplConnection->setConnectionStruct((long)PtrToLong(data)); //NOTE SUNDOWN issue if FAILED(hr){ return hr; } *con=dplConnection; return S_OK; } ////////////////////////////////////////////////////////////////////////// STDMETHODIMP C_dxj_DirectPlayLobby3Object::receiveLobbyMessage( /* [in] */ long appID, /* [out] */ long *messageFlags, /* [out] */ I_dxj_DirectPlayMessage **msg) { HRESULT hr; DWORD dwSize=0; void *pData=NULL; BOOL fCont=TRUE; if (!msg) return E_INVALIDARG; if (!messageFlags) return E_INVALIDARG; hr= m__dxj_DirectPlayLobby3->ReceiveLobbyMessage (0, appID, (DWORD*)messageFlags, (void*)NULL, (LPDWORD)&dwSize); if (hr == DPERR_NOMESSAGES ) { *msg=NULL; return S_OK; } if (hr!=DPERR_BUFFERTOOSMALL) return hr; hr=C_dxj_DirectPlayMessageObject::create((DWORD)0,dwSize,&pData,msg); if FAILED(hr) return hr; hr= m__dxj_DirectPlayLobby3->ReceiveLobbyMessage (0, appID, (DWORD*)messageFlags, (void*)pData, (LPDWORD)&dwSize); if FAILED(hr) { if (*msg) (*msg)->Release(); *msg=NULL; return hr; } return hr; } ////////////////////////////////////////////////////////////////////////// STDMETHODIMP C_dxj_DirectPlayLobby3Object::receiveLobbyMessageSize( /* [in] */ long appID, /* [out] */ long *messageFlags, /* [out] */ long __RPC_FAR *dataSize) { *dataSize = 0; HRESULT hr = m__dxj_DirectPlayLobby3->ReceiveLobbyMessage (0, appID, (DWORD*)messageFlags, NULL, (LPDWORD)dataSize); if (hr==DPERR_BUFFERTOOSMALL) hr=S_OK; return hr; } ////////////////////////////////////////////////////////////////////////// // Launch a DirectPlay application. ////////////////////////////////////////////////////////////////////////// STDMETHODIMP C_dxj_DirectPlayLobby3Object::runApplication( I_dxj_DPLConnection *conn, long hReceiveEvent , long *appId ) { if (!appId) return E_INVALIDARG; if (!conn) return E_INVALIDARG; void *lpConnection=NULL; HRESULT hr; *appId=0; hr=conn->getConnectionStruct((long*)&lpConnection); if FAILED(hr) return hr; hr = m__dxj_DirectPlayLobby3->RunApplication (0, (DWORD*)appId, (DPLCONNECTION*)lpConnection, (void*)hReceiveEvent); return hr; } ///////////////////////////////////////////////////////////////////////////// STDMETHODIMP C_dxj_DirectPlayLobby3Object::sendLobbyMessage( /* [in] */ long flags, /* [in] */ long appID, /* [in] */ I_dxj_DirectPlayMessage *msg) { //if (!ISSAFEARRAY1D(ppData,(DWORD)dataSize)) return E_INVALIDARG; HRESULT hr; if (!msg) return E_INVALIDARG; void *pData=NULL; DWORD dataSize=0; msg->AddRef(); msg->getPointer((long*)&pData); msg->getMessageSize((long*)&dataSize); __try { hr = m__dxj_DirectPlayLobby3->SendLobbyMessage ((DWORD)flags, (DWORD)appID, pData, (DWORD)dataSize); } __except(1,1){ msg->Release(); return E_INVALIDARG; } msg->Release(); return hr; } ///////////////////////////////////////////////////////////////////////////// STDMETHODIMP C_dxj_DirectPlayLobby3Object::setConnectionSettings ( long appID, I_dxj_DPLConnection *con) { void *lpConnection=NULL; HRESULT hr; if (!con) return E_INVALIDARG; hr=con->getConnectionStruct((long*)&lpConnection); if FAILED(hr) return hr; hr = m__dxj_DirectPlayLobby3->SetConnectionSettings (0, (DWORD)appID, (DPLCONNECTION*)lpConnection); return hr; } ////////////////////////////////////////////////////////////////////////// STDMETHODIMP C_dxj_DirectPlayLobby3Object::setLobbyMessageEvent( /* [in] */ long appId, /* [in] */ long hReceiveEvent) { HRESULT hr = m__dxj_DirectPlayLobby3->SetLobbyMessageEvent(0, (long)appId, (HANDLE)hReceiveEvent); return hr; } STDMETHODIMP C_dxj_DirectPlayLobby3Object::getDPEnumLocalApplications( ///* [in] */ long flags, /* [retval][out] */ I_dxj_DPEnumLocalApplications __RPC_FAR *__RPC_FAR *retVal) { HRESULT hr; hr=C_dxj_DPEnumLocalApplicationsObject::create(m__dxj_DirectPlayLobby3,0,retVal); return hr; } STDMETHODIMP C_dxj_DirectPlayLobby3Object::waitForConnectionSettings( /* [in] */ long flags) { HRESULT hr = m__dxj_DirectPlayLobby3->WaitForConnectionSettings((DWORD)flags); return hr; } STDMETHODIMP C_dxj_DirectPlayLobby3Object::unregisterApplication(// long flags, BSTR guid) { GUID g; HRESULT hr; hr=DPLBSTRtoGUID(&g,guid); if FAILED(hr) return E_INVALIDARG; hr =m__dxj_DirectPlayLobby3->UnregisterApplication((DWORD) 0, g); return hr; } STDMETHODIMP C_dxj_DirectPlayLobby3Object::registerApplication(// long flags, DpApplicationDesc2 *appDesc) { HRESULT hr; DPAPPLICATIONDESC2 desc; if (!appDesc->strGuid) return E_INVALIDARG; ZeroMemory(&desc,sizeof(DPAPPLICATIONDESC2)); desc.dwSize=sizeof(DPAPPLICATIONDESC2); desc.dwFlags=(DWORD)appDesc->lFlags; desc.lpszApplicationName=appDesc->strApplicationName; desc.lpszFilename=appDesc->strFilename; desc.lpszCommandLine=appDesc->strCommandLine; desc.lpszPath=appDesc->strPath; desc.lpszCurrentDirectory=appDesc->strCurrentDirectory; desc.lpszDescriptionW=appDesc->strDescription; desc.lpszAppLauncherName=appDesc->strAppLauncherName; hr=DPLBSTRtoGUID(&desc.guidApplication,appDesc->strGuid); if FAILED(hr) return E_INVALIDARG; hr =m__dxj_DirectPlayLobby3->RegisterApplication((DWORD) 0, &desc); return hr; } STDMETHODIMP C_dxj_DirectPlayLobby3Object::createConnectionData( I_dxj_DPLConnection __RPC_FAR *__RPC_FAR *ret) { INTERNAL_CREATE_STRUCT(_dxj_DPLConnection,ret); return S_OK; } STDMETHODIMP C_dxj_DirectPlayLobby3Object::createMessage( I_dxj_DirectPlayMessage __RPC_FAR *__RPC_FAR *ret) { HRESULT hr; hr= C_dxj_DirectPlayMessageObject::create(1,0,NULL,ret); return hr; } //CONSIDER - why pass int - more appopriate to pass in short STDMETHODIMP C_dxj_DirectPlayLobby3Object::createINetAddress( /* [in] */ BSTR addr, /* [in] */ int port, /* [retval][out] */ I_dxj_DPAddress __RPC_FAR *__RPC_FAR *ret) { DPCOMPOUNDADDRESSELEMENT elem[3]; DWORD dwSize=0; LPVOID pAddress=NULL; HRESULT hr; I_dxj_DPAddress *pDPAddress= NULL; WORD wport=(WORD)port; DWORD dwElements=2; if (!addr) return E_INVALIDARG; elem[0].guidDataType=DPAID_ServiceProvider; elem[0].dwDataSize =sizeof(GUID); elem[0].lpData = (void*) &DPSPGUID_TCPIP; elem[1].guidDataType=DPAID_INetW; elem[1].dwDataSize =SysStringByteLen(addr)+sizeof(WCHAR); elem[1].lpData = (void*) addr; elem[2].guidDataType=DPAID_INetPort; elem[2].dwDataSize =sizeof(WORD); elem[2].lpData = &wport; if (port) dwElements=3; hr=m__dxj_DirectPlayLobby3->CreateCompoundAddress(elem,dwElements,NULL,&dwSize); if (hr!=DPERR_BUFFERTOOSMALL) return hr; pAddress=malloc(dwSize); if (!pAddress) return E_OUTOFMEMORY; hr=m__dxj_DirectPlayLobby3->CreateCompoundAddress(elem,dwElements,pAddress,&dwSize); if FAILED(hr) { free(pAddress); return hr; } INTERNAL_CREATE_STRUCT(_dxj_DPAddress,(&pDPAddress)); if (pDPAddress==NULL) { free(pAddress); return E_OUTOFMEMORY; } pDPAddress->setAddress((long)PtrToLong(pAddress),(long)dwSize); //NOTE SUNDOWN issue need to use PtrToLong free(pAddress); *ret=pDPAddress; return hr; } STDMETHODIMP C_dxj_DirectPlayLobby3Object::createComPortAddress( /* [in] */ long port, /* [in] */ long baudRate, /* [in] */ long stopBits, /* [in] */ long parity, /* [in] */ long flowcontrol, /* [retval][out] */ I_dxj_DPAddress __RPC_FAR *__RPC_FAR *ret) { DPCOMPORTADDRESS cpa; cpa.dwBaudRate =(DWORD)baudRate; cpa.dwComPort =(DWORD)port; cpa.dwFlowControl =(DWORD)flowcontrol; cpa.dwStopBits =(DWORD)stopBits; cpa.dwParity =(DWORD)parity; DPCOMPOUNDADDRESSELEMENT elem[2]; DWORD dwSize=0; LPVOID pAddress=NULL; HRESULT hr; I_dxj_DPAddress *pDPAddress= NULL; elem[0].guidDataType=DPAID_ServiceProvider; elem[0].dwDataSize =sizeof(GUID); elem[0].lpData = (void*) &DPSPGUID_SERIAL; elem[1].guidDataType=DPAID_ComPort; elem[1].dwDataSize =sizeof(DPCOMPORTADDRESS); elem[1].lpData = (void*) &cpa; hr=m__dxj_DirectPlayLobby3->CreateCompoundAddress(elem,2,NULL,&dwSize); if (hr!=DPERR_BUFFERTOOSMALL) return hr; pAddress=malloc(dwSize); if (!pAddress) return E_OUTOFMEMORY; hr=m__dxj_DirectPlayLobby3->CreateCompoundAddress(elem,2,pAddress,&dwSize); if FAILED(hr) { free(pAddress); return hr; } INTERNAL_CREATE_STRUCT(_dxj_DPAddress,(&pDPAddress)); if (pDPAddress==NULL) { free(pAddress); return E_OUTOFMEMORY; } pDPAddress->setAddress((long)PtrToLong(pAddress),(long)dwSize); //NOTE SUNDOWN issue free(pAddress); *ret=pDPAddress; return hr; } STDMETHODIMP C_dxj_DirectPlayLobby3Object::createLobbyProviderAddress( /* [in] */ BSTR guid, /* [retval][out] */ I_dxj_DPAddress __RPC_FAR *__RPC_FAR *ret) { DPCOMPOUNDADDRESSELEMENT elem[2]; DWORD dwSize=0; LPVOID pAddress=NULL; HRESULT hr; I_dxj_DPAddress *pDPAddress= NULL; GUID lobbyGuid; if (!guid) return E_INVALIDARG; hr=DPLBSTRtoGUID(&lobbyGuid,guid); if FAILED(hr) return E_INVALIDARG; elem[0].guidDataType=DPAID_LobbyProvider; elem[0].dwDataSize =sizeof(GUID); elem[0].lpData = (void*) &lobbyGuid; hr=m__dxj_DirectPlayLobby3->CreateCompoundAddress(elem,1,NULL,&dwSize); if (hr!=DPERR_BUFFERTOOSMALL) return hr; pAddress=malloc(dwSize); if (!pAddress) return E_OUTOFMEMORY; hr=m__dxj_DirectPlayLobby3->CreateCompoundAddress(elem,1,pAddress,&dwSize); if FAILED(hr) { free(pAddress); return hr; } INTERNAL_CREATE_STRUCT(_dxj_DPAddress,(&pDPAddress)); if (pDPAddress==NULL) { free(pAddress); return E_OUTOFMEMORY; } pDPAddress->setAddress((long)PtrToLong(pAddress),(long)dwSize); //NOTE SUNDOWN free(pAddress); *ret=pDPAddress; return hr; } STDMETHODIMP C_dxj_DirectPlayLobby3Object::createServiceProviderAddress( /* [in] */ BSTR guid, /* [retval][out] */ I_dxj_DPAddress __RPC_FAR *__RPC_FAR *ret) { DPCOMPOUNDADDRESSELEMENT elem[1]; DWORD dwSize=0; LPVOID pAddress=NULL; HRESULT hr; I_dxj_DPAddress *pDPAddress= NULL; GUID SPGuid; if (!guid) return E_INVALIDARG; hr=DPLBSTRtoGUID(&SPGuid,guid); if FAILED(hr) return E_INVALIDARG; elem[0].guidDataType=DPAID_ServiceProvider; elem[0].dwDataSize =sizeof(GUID); elem[0].lpData = (void*) &SPGuid; hr=m__dxj_DirectPlayLobby3->CreateCompoundAddress(elem,1,NULL,&dwSize); if (hr!=DPERR_BUFFERTOOSMALL) return hr; pAddress=malloc(dwSize); if (!pAddress) return E_OUTOFMEMORY; hr=m__dxj_DirectPlayLobby3->CreateCompoundAddress(elem,1,pAddress,&dwSize); if FAILED(hr) { free(pAddress); return hr; } INTERNAL_CREATE_STRUCT(_dxj_DPAddress,(&pDPAddress)); if (pDPAddress==NULL) { free(pAddress); return E_OUTOFMEMORY; } pDPAddress->setAddress((long)PtrToLong(pAddress),(long)dwSize); //NOTE SUNDOWN free(pAddress); *ret=pDPAddress; return hr; } STDMETHODIMP C_dxj_DirectPlayLobby3Object::createModemAddress( /* [in] */ BSTR modem, /* [in] */ BSTR phone, /* [retval][out] */ I_dxj_DPAddress __RPC_FAR *__RPC_FAR *ret) { DPCOMPOUNDADDRESSELEMENT elem[3]; DWORD dwSize=0; DWORD i =1; LPVOID pAddress=NULL; HRESULT hr; I_dxj_DPAddress *pDPAddress= NULL; if (!phone) return E_INVALIDARG; if (!modem) return E_INVALIDARG; elem[0].guidDataType=DPAID_ServiceProvider; elem[0].dwDataSize =sizeof(GUID); elem[0].lpData = (void*) &DPSPGUID_MODEM; if (modem[0]!=0) { elem[i].guidDataType=DPAID_ModemW; elem[i].dwDataSize =SysStringByteLen(modem)+sizeof(WCHAR); elem[i].lpData = (void*) modem; i++; } if (phone[0]!=0) { elem[i].guidDataType=DPAID_PhoneW; elem[i].dwDataSize =SysStringByteLen(phone)+sizeof(WCHAR); elem[i].lpData = (void*) phone; i++; } hr=m__dxj_DirectPlayLobby3->CreateCompoundAddress(elem,i,NULL,&dwSize); if (hr!=DPERR_BUFFERTOOSMALL) return hr; pAddress=malloc(dwSize); if (!pAddress) return E_OUTOFMEMORY; hr=m__dxj_DirectPlayLobby3->CreateCompoundAddress(elem,i,pAddress,&dwSize); if FAILED(hr) { free(pAddress); return hr; } INTERNAL_CREATE_STRUCT(_dxj_DPAddress,(&pDPAddress)); if (pDPAddress==NULL) { free(pAddress); return E_OUTOFMEMORY; } pDPAddress->setAddress((long)PtrToLong(pAddress),(long)dwSize); //NOTE SUNDOWN free(pAddress); *ret=pDPAddress; return hr; } STDMETHODIMP C_dxj_DirectPlayLobby3Object::createIPXAddress( /* [retval][out] */ I_dxj_DPAddress __RPC_FAR *__RPC_FAR *ret) { DPCOMPOUNDADDRESSELEMENT elem[1]; DWORD dwSize=0; LPVOID pAddress=NULL; HRESULT hr; I_dxj_DPAddress *pDPAddress= NULL; GUID SPGuid=DPSPGUID_IPX; elem[0].guidDataType=DPAID_ServiceProvider; elem[0].dwDataSize =sizeof(GUID); elem[0].lpData = (void*) &SPGuid; hr=m__dxj_DirectPlayLobby3->CreateCompoundAddress(elem,1,NULL,&dwSize); if (hr!=DPERR_BUFFERTOOSMALL) return hr; pAddress=malloc(dwSize); if (!pAddress) return E_OUTOFMEMORY; hr=m__dxj_DirectPlayLobby3->CreateCompoundAddress(elem,1,pAddress,&dwSize); if FAILED(hr) { free(pAddress); return hr; } INTERNAL_CREATE_STRUCT(_dxj_DPAddress,(&pDPAddress)); if (pDPAddress==NULL) { free(pAddress); return E_OUTOFMEMORY; } pDPAddress->setAddress((long)PtrToLong(pAddress),(long)dwSize); //NOTE SUNDOWN free(pAddress); *ret=pDPAddress; return hr; } STDMETHODIMP C_dxj_DirectPlayLobby3Object::createCustomAddress( /* [in] */ long size, /* [in] */ void __RPC_FAR *data, /* [retval][out] */ I_dxj_DPAddress __RPC_FAR *__RPC_FAR *ret) { return E_NOTIMPL; } STDMETHODIMP C_dxj_DirectPlayLobby3Object::getModemName( /* [in] */ long index, /* [retval][out] */ BSTR *name) { USES_CONVERSION; LPDIRECTPLAY4 dp=NULL; LPDIRECTPLAY lpDP=NULL; GUID guid=DPSPGUID_MODEM; HRESULT hr; DIRECTPLAYCREATE pDirectPlayCreate = NULL; DWORD dwSize=0; DWORD dwAt=0; void *pData=NULL; LPWSTR pszwName=NULL; char *szLast=NULL; DWORD dwCount; DWORD i; BOOL bZero; pDirectPlayCreate=(DIRECTPLAYCREATE)GetProcAddress( g_hDPlay, "DirectPlayCreate" ); if (pDirectPlayCreate == NULL ) return E_NOINTERFACE; // create a DirectPlay1 interface hr = (pDirectPlayCreate)(&guid, &lpDP, NULL); if FAILED(hr) goto cleanup; // now get Dplay4 interface hr = lpDP->QueryInterface(IID_IDirectPlay4,(LPVOID *)&dp); lpDP->Release(); lpDP=NULL; if FAILED(hr) goto cleanup; hr=dp->GetPlayerAddress(0,NULL,&dwSize); if (dwSize<=0) { hr=E_INVALIDARG; goto cleanup; } pData=malloc(dwSize); if (!pData){ hr= E_OUTOFMEMORY; goto cleanup; } hr=dp->GetPlayerAddress(0,pData,&dwSize); if FAILED(hr) goto cleanup; if (dwSize<=80) { hr=E_INVALIDARG; goto cleanup; } //Get String count bZero=FALSE; dwCount=0; for( i=80;i<dwSize;i++){ if (((char*)pData)[i]==0){ if (bZero) break; dwCount++; bZero=TRUE; } else { bZero=FALSE; } } if (((DWORD)index > dwCount) || (index <=0)){ hr=E_INVALIDARG; goto cleanup; } szLast=& (((char*)pData)[80]); dwAt=0; for ( i=80;i<dwSize;i++){ if (((char*)pData)[i]==0){ if ((DWORD)(index-1)==dwAt) break; dwAt++; szLast=&( ( (char*)pData)[i+1]); } } if (i>dwSize) { hr=E_INVALIDARG; goto cleanup; } pszwName = T2W(szLast); *name=SysAllocString(pszwName); cleanup: if (pData) free(pData); if (dp) dp->Release(); return hr; } STDMETHODIMP C_dxj_DirectPlayLobby3Object::getModemCount( /* [retval][out] */ long __RPC_FAR *count) { LPDIRECTPLAY4 dp=NULL; LPDIRECTPLAY lpDP=NULL; GUID guid=DPSPGUID_MODEM; HRESULT hr; DIRECTPLAYCREATE pDirectPlayCreate = NULL; DWORD dwSize=0; void *pData=NULL; DWORD dwCount; DWORD i; BOOL bZero; if (!count) return E_INVALIDARG; pDirectPlayCreate=(DIRECTPLAYCREATE)GetProcAddress( g_hDPlay, "DirectPlayCreate" ); if (pDirectPlayCreate == NULL ) return E_NOINTERFACE; // create a DirectPlay1 interface hr = (pDirectPlayCreate)(&guid, &lpDP, NULL); if (hr==DPERR_UNAVAILABLE) { hr = S_OK; *count=0; goto cleanup; } if FAILED(hr) goto cleanup; // now get Dplay4 interface hr = lpDP->QueryInterface(IID_IDirectPlay4,(LPVOID *)&dp); lpDP->Release(); lpDP=NULL; if FAILED(hr) goto cleanup; hr=dp->GetPlayerAddress(0,NULL,&dwSize); if (dwSize<=0) { hr=E_INVALIDARG; goto cleanup; } pData=malloc(dwSize); if (!pData){ hr= E_OUTOFMEMORY; goto cleanup; } hr=dp->GetPlayerAddress(0,pData,&dwSize); if (hr==DPERR_UNAVAILABLE) { hr = S_OK; *count=0; goto cleanup; } if FAILED(hr) goto cleanup; if (dwSize<=80) { hr=E_INVALIDARG; goto cleanup; } //Get String count bZero=FALSE; dwCount=0; for( i=80;i<dwSize;i++){ if (((char*)pData)[i]==0){ if (bZero) break; dwCount++; bZero=TRUE; } else { bZero=FALSE; } } *count=(long)dwCount; cleanup: if (pData) free(pData); if (dp) dp->Release(); return hr; } #define GUIDS_EQUAL(g2,g) (\ (g.Data1==g2->Data1) && \ (g.Data2==g2->Data2) && \ (g.Data3==g2->Data3) && \ (g.Data4[0]==g2->Data4[0]) && \ (g.Data4[1]==g2->Data4[1]) && \ (g.Data4[2]==g2->Data4[2]) && \ (g.Data4[3]==g2->Data4[3]) && \ (g.Data4[4]==g2->Data4[4]) && \ (g.Data4[5]==g2->Data4[5]) && \ (g.Data4[6]==g2->Data4[6]) && \ (g.Data4[7]==g2->Data4[7]) ) HRESULT DPLBSTRtoGUID(LPGUID pGuid,BSTR str) { HRESULT hr; if( 0==_wcsicmp(str,L"dpaid_comport")){ memcpy(pGuid,&DPAID_ComPort,sizeof(GUID)); } else if( 0==_wcsicmp(str,L"dpaid_inet")){ memcpy(pGuid,&DPAID_INet,sizeof(GUID)); } else if( 0==_wcsicmp(str,L"dpaid_inetport")){ memcpy(pGuid,&DPAID_INetPort,sizeof(GUID)); } else if( 0==_wcsicmp(str,L"dpaid_lobbyprovider")){ memcpy(pGuid,&DPAID_LobbyProvider,sizeof(GUID)); } else if( 0==_wcsicmp(str,L"dpaid_modem")){ memcpy(pGuid,&DPAID_Modem,sizeof(GUID)); } else if( 0==_wcsicmp(str,L"dpaid_phone")){ memcpy(pGuid,&DPAID_Phone,sizeof(GUID)); } else if( 0==_wcsicmp(str,L"dpaid_serviceprovider")){ memcpy(pGuid,&DPAID_ServiceProvider,sizeof(GUID)); } else if( 0==_wcsicmp(str,L"dpaid_totalsize")){ memcpy(pGuid,&DPAID_TotalSize,sizeof(GUID)); } else if( 0==_wcsicmp(str,L"dpspguid_modem")){ memcpy(pGuid,&DPSPGUID_MODEM,sizeof(GUID)); } else if( 0==_wcsicmp(str,L"dpspguid_ipx")){ memcpy(pGuid,&DPSPGUID_IPX,sizeof(GUID)); } else if( 0==_wcsicmp(str,L"dpspguid_tcpip")){ memcpy(pGuid,&DPSPGUID_TCPIP,sizeof(GUID)); } else if( 0==_wcsicmp(str,L"dpspguid_serial")){ memcpy(pGuid,&DPSPGUID_SERIAL,sizeof(GUID)); } else { hr=BSTRtoGUID(pGuid,str); return hr; } return S_OK; } HRESULT DPLBSTRtoPPGUID(LPGUID *ppGuid,BSTR str) { if ((!str) || (str[0]==0)){ ppGuid=NULL; return S_OK; } return DPLBSTRtoGUID(*ppGuid,str); } BSTR DPLGUIDtoBSTR(LPGUID pGuid) { WCHAR *pOut=NULL; if( GUIDS_EQUAL(pGuid,DPAID_ComPort)){ pOut=L"DPAID_ComPort"; } else if( GUIDS_EQUAL(pGuid,DPAID_INet)){ pOut=L"DPAID_INet"; } else if( GUIDS_EQUAL(pGuid,DPAID_INetPort)){ pOut=L"DPAID_INetPort"; } else if( GUIDS_EQUAL(pGuid,DPAID_LobbyProvider)){ pOut=L"DPAID_LobbyProvider"; } else if( GUIDS_EQUAL(pGuid,DPAID_Modem)){ pOut=L"DPAID_Modem"; } else if( GUIDS_EQUAL(pGuid,DPAID_Phone)){ pOut=L"DPAID_Phone"; } else if( GUIDS_EQUAL(pGuid,DPAID_ServiceProvider)){ pOut=L"DPAID_ServiceProvider"; } else if( GUIDS_EQUAL(pGuid,DPAID_TotalSize)){ pOut=L"DPAID_TotalSize"; } else if( GUIDS_EQUAL(pGuid,DPSPGUID_MODEM)){ pOut=L"DPSPGUID_MODEM"; } else if( GUIDS_EQUAL(pGuid,DPSPGUID_IPX)){ pOut=L"DPSPGUID_IPX"; } else if( GUIDS_EQUAL(pGuid,DPSPGUID_TCPIP)){ pOut=L"DPSPGUID_TCPIP"; } else if( GUIDS_EQUAL(pGuid,DPSPGUID_SERIAL)){ pOut=L"DPSPGUID_SERIAL"; } if (pOut) { return SysAllocString(pOut); } else { return GUIDtoBSTR(pGuid); } }
5fa62daafd1b69365494bc55f99c33a44447debb
e0264425151ec739030174f54195f1eaf518d397
/cpp/lib/fps_json/document.h
74f01e7304b8729d7fa4080a2772f1bfdec49599
[ "Unlicense" ]
permissive
blakewoolbright/fps_platform
b72f6c4dd41ce716f1ccf4a52f4bb73bf8da2aa9
cd81f799432cfc3700c2dfda4e01fc6c154d53f9
refs/heads/master
2021-03-27T19:15:29.024142
2020-04-13T16:46:20
2020-04-13T16:46:20
47,855,943
0
0
null
null
null
null
UTF-8
C++
false
false
2,423
h
#ifndef FPS__JSON__DOCUMENT__H #define FPS__JSON__DOCUMENT__H #include <boost/property_tree/ptree.hpp> #include <boost/property_tree/json_parser.hpp> #include <boost/iterator/iterator_facade.hpp> #include <type_traits> #include "fps_json/value.h" namespace fps { namespace json { //---------------------------------------------------------------------------- // TODO: Rethink this design... It feels forced. The terminology is from // the jsoncpp library, and the implementation is boost property tree... // // TODO: Is boost::property_tree the best choice here? I like it's design, // but the fact that it isn't strongly typed makes it unsuitable for // the schema implementation being prototyped in the schema/ subdir. //---------------------------------------------------------------------------- class Document { private : //-------------------------------------------------------------------------- typedef detail::tree_t tree_t ; typedef tree_t::iterator iterator ; typedef tree_t::const_iterator const_iterator ; //-------------------------------------------------------------------------- tree_t tree_ ; Value root_ ; mutable std::string err_text_ ; public : //-------------------------------------------------------------------------- Document() ; ~Document() ; //-------------------------------------------------------------------------- inline const std::string & error_msg() const { return err_text_ ; } inline bool empty() const { return root_.empty() ; } //-------------------------------------------------------------------------- inline const Value & root() const { return root_ ; } inline Value & root() { return root_ ; } //-------------------------------------------------------------------------- inline Value find( const std::string & key ) const { return root_.find( key ) ; } //-------------------------------------------------------------------------- std::string serialize() const ; bool deserialize( const std::string & json_data ) ; //-------------------------------------------------------------------------- bool load( const std::string & input_file ) ; bool save( const std::string & output_file ) const ; } ; }} #endif
733e48f43af670d4dd18067cc8a01427f435747c
aa17990e7d426e05b21514dda09920f55bfaf0b8
/legacy/VertexArray.cpp
f93e9c82da43176f0971ceccec9eb990b629abab
[]
no_license
Mckay15/Graphics
152268c2c51ec439876a7a341dc2e7210b976fb4
5fadda6dafc930af8ded19022f505b445d609ce4
refs/heads/master
2020-04-03T20:32:17.861153
2019-01-18T13:17:29
2019-01-18T13:17:29
155,548,276
0
0
null
null
null
null
UTF-8
C++
false
false
6,930
cpp
#include "VertexArray.h" #include "VertexBuffer.h" #include <fstream> #include <iostream> void VertexArray::SplitStringWhitespace(std::string& input, std::vector<std::string>& output) { std::string curr; output.clear(); for (size_t i = 0; i < input.length(); i++) { if (input.at(i) == ' ' || input.at(i) == '\r' || input.at(i) == '\n' || input.at(i) == '\t') { if (curr.length() > 0) { output.push_back(curr); curr = ""; } } else { curr += input.at(i); } } if (curr.length() > 0) { output.push_back(curr); } } void VertexArray::SplitString(std::string& input, char splitter, std::vector<std::string>& output) { std::string curr; output.clear(); for (size_t i = 0; i < input.length(); i++) { if (input.at(i) == splitter) { output.push_back(curr); curr = ""; } else { curr += input.at(i); } } if (curr.length() > 0) { output.push_back(curr); } } VertexArray::VertexArray(std::string path) : dirty(false) { glGenVertexArrays(1, &id); if (!id) { throw std::exception(); } buffers.resize(10); std::ifstream file(path.c_str()); if (!file.is_open()) { throw std::exception(); } std::string line; std::vector<std::string> splitLine; std::vector<glm::vec3> positions; std::vector<glm::vec2> texCoords; std::vector<glm::vec3> normals; std::vector<glm::vec3> tangent; std::vector<glm::vec3> BiTangent; VertexBuffer *positionBuffer = NULL; VertexBuffer *texCoordBuffer = NULL; VertexBuffer *normalBuffer = NULL; VertexBuffer *tangentBuffer = NULL; VertexBuffer *BiTangentBuffer = NULL; while (!file.eof()) { std::getline(file, line); if (line.length() < 1) continue; SplitStringWhitespace(line, splitLine); if (splitLine.size() < 1) continue; if (splitLine.at(0) == "v") { if (!positionBuffer) positionBuffer = new VertexBuffer(); positions.push_back(glm::vec3( atof(splitLine.at(1).c_str()), atof(splitLine.at(2).c_str()), atof(splitLine.at(3).c_str()))); /*V1 = atof(splitLine.at(1).c_str()); V2 = atof(splitLine.at(2).c_str()); V3 = atof(splitLine.at(3).c_str());*/ } else if (splitLine.at(0) == "vt") { if (!texCoordBuffer) texCoordBuffer = new VertexBuffer(); texCoords.push_back(glm::vec2( atof(splitLine.at(1).c_str()), 1.0f - atof(splitLine.at(2).c_str()))); /*U = atof(splitLine.at(1).c_str()); V = 1.0f - atof(splitLine.at(2).c_str());*/ } else if (splitLine.at(0) == "vn") { if (!normalBuffer) normalBuffer = new VertexBuffer(); normals.push_back(glm::vec3( atof(splitLine.at(1).c_str()), atof(splitLine.at(2).c_str()), atof(splitLine.at(3).c_str()))); } else if (splitLine.at(0) == "f") { std::vector<std::string> subsplit; SplitString(splitLine.at(1), '/', subsplit); positionBuffer->add(positions.at(atoi(subsplit.at(0).c_str()) - 1)); if (texCoordBuffer) texCoordBuffer->add(texCoords.at(atoi(subsplit.at(1).c_str()) - 1)); if (normalBuffer) normalBuffer->add(normals.at(atoi(subsplit.at(2).c_str()) - 1)); SplitString(splitLine.at(2), '/', subsplit); positionBuffer->add(positions.at(atoi(subsplit.at(0).c_str()) - 1)); if (texCoordBuffer) texCoordBuffer->add(texCoords.at(atoi(subsplit.at(1).c_str()) - 1)); if (normalBuffer) normalBuffer->add(normals.at(atoi(subsplit.at(2).c_str()) - 1)); SplitString(splitLine.at(3), '/', subsplit); positionBuffer->add(positions.at(atoi(subsplit.at(0).c_str()) - 1)); if (texCoordBuffer) texCoordBuffer->add(texCoords.at(atoi(subsplit.at(1).c_str()) - 1)); if (normalBuffer) normalBuffer->add(normals.at(atoi(subsplit.at(2).c_str()) - 1)); if (splitLine.size() < 5) continue; SplitString(splitLine.at(3), '/', subsplit); positionBuffer->add(positions.at(atoi(subsplit.at(0).c_str()) - 1)); if (texCoordBuffer) texCoordBuffer->add(texCoords.at(atoi(subsplit.at(1).c_str()) - 1)); if (normalBuffer) normalBuffer->add(normals.at(atoi(subsplit.at(2).c_str()) - 1)); SplitString(splitLine.at(4), '/', subsplit); positionBuffer->add(positions.at(atoi(subsplit.at(0).c_str()) - 1)); if (texCoordBuffer) texCoordBuffer->add(texCoords.at(atoi(subsplit.at(1).c_str()) - 1)); if (normalBuffer) normalBuffer->add(normals.at(atoi(subsplit.at(2).c_str()) - 1)); SplitString(splitLine.at(1), '/', subsplit); positionBuffer->add(positions.at(atoi(subsplit.at(0).c_str()) - 1)); if (texCoordBuffer) texCoordBuffer->add(texCoords.at(atoi(subsplit.at(1).c_str()) - 1)); if (normalBuffer) normalBuffer->add(normals.at(atoi(subsplit.at(2).c_str()) - 1)); } } SetBuffer("in_Position", positionBuffer); //for (int x = 0; x < positions.size(); x += 3) //{ // V1 = positions[x]; // V2 = positions[x + 1]; // V3 = positions[x + 2]; // for TBN, needs to be revised, goes out of scoop for most models but fortunely is not required in this project // UV1 = texCoords[x]; // UV2 = texCoords[x + 1]; // UV3 = texCoords[x + 2]; // glm::vec3 deltaPos1 = V2 - V1; // glm::vec3 deltaPos2 = V3 - V1; // glm::vec2 deltaUV1 = UV2 - UV1; // glm::vec2 deltaUV2 = UV3 - UV1; // float r = 1.0f / (deltaUV1.x * deltaUV2.y - deltaUV1.y * deltaUV2.x); // glm::vec3 Tangent = (deltaPos1 * deltaUV2.y - deltaPos2 * deltaUV1.y)*r; // glm::vec3 Bi = (deltaPos2 * deltaUV1.x - deltaPos1 * deltaUV2.x)*r; // tangent.push_back(Tangent); // BiTangent.push_back(Bi); //} if (texCoordBuffer) SetBuffer("in_TexCoord", texCoordBuffer); if (normalBuffer) SetBuffer("in_Normal", normalBuffer); if (tangentBuffer) SetBuffer("in_Tangent", tangentBuffer); if (BiTangentBuffer) SetBuffer("in_BiTangent", BiTangentBuffer); } void VertexArray::SetBuffer(std::string attribute, VertexBuffer* buffer) { if (attribute == "in_Position") { buffers.at(0) = buffer; } else if (attribute == "in_TexCoord") { buffers.at(1) = buffer; } else if (attribute == "in_Normal") { buffers.at(2) = buffer; } else if (attribute == "in_Tangent") { buffers.at(3) = buffer; } else if (attribute == "in_BiTangent") { buffers.at(4) = buffer; } else { throw std::exception(); } dirty = true; } int VertexArray::GetVertexCount() { if (!buffers.at(0)) { throw std::exception(); } return buffers.at(0)->GetDataSize() / buffers.at(0)->GetComponet(); } GLuint VertexArray::GetId() { if (dirty) { glBindVertexArray(id); for (int i = 0; i < buffers.size(); i++) { if (buffers.at(i)) { glBindBuffer(GL_ARRAY_BUFFER, buffers.at(i)->GetId()); glVertexAttribPointer(i, buffers.at(i)->GetComponet(), GL_FLOAT, GL_FALSE, buffers.at(i)->GetComponet() * sizeof(GLfloat), (void *)0); glEnableVertexAttribArray(i); } else { glDisableVertexAttribArray(i); } } } return id; } VertexArray::VertexArray() { dirty = false; buffers.resize(10); glGenVertexArrays(1, &id); if (!id) { throw std::exception(); } } VertexArray::~VertexArray() { }
31168fdeb31a0c59c0daa50962b35e20d1c75861
e15e5b5a233626242b47c6aa3763424583017226
/AVLTree.h
29ef94b19dca128a6205ec3f72d16e3db267e922
[]
no_license
andrewwongucsd/-cpp-Hitachi-Data-System
4de4377abf2c960d4887705018e37811dacdc705
e3083d64dadef024eebc5dc73d4abc0c375d191c
refs/heads/master
2021-01-20T12:04:42.466950
2015-01-14T22:00:10
2015-01-14T22:00:10
null
0
0
null
null
null
null
UTF-8
C++
false
false
975
h
#ifndef AVLTREE_H #define AVLTREE_H #include <cstdio> /* * Namespace called AVL */ namespace AVL { /* * AVL Node */ struct AVLNode { int elem; // Element int height; // Height AVLNode *left; // left Node AVLNode *right; // right Node AVLNode(int e) : elem(e), height(0), left(0), right(0) {} // constructor ~AVLNode() {delete left; delete right;} // destructor }; bool find(const AVLNode *tree, int elem); AVLNode *insert(AVLNode *tree, int elem); } /* * AVLTree with the only root * function: AVLTree{AVLNode as the root, AVLNode(s)} */ class AVLTree { private: AVL::AVLNode *root; // Namespace(AVL)'s AVLNode called dereference root; public: AVLTree() : root(0) {} // root set to 0 as empty tree when constructed. ~AVLTree() {delete root;} // destructed the root. bool find(int elem) const {return AVL::find(root, elem);} void insert(int elem) {root = AVL::insert(root, elem);} }; #endif // AVLTREE_H
ff5d6448851d56fabcf2ee4df2b162a114992fb2
a8eae37e89059ca27e20e6f979de9dffb8c8c8ac
/Calculando expressoes parte1.cpp
ecdf0172db7a21d71514afbc6d5e8e740cedab34
[]
no_license
josineidess/Questoes-da-plataforma-LOP
47a4785ee45a86c6ea191797c8cecc4ca5a6078b
92b9122a9d844abf77f5688d203527c6b69b8afc
refs/heads/master
2022-12-07T01:00:18.667838
2020-08-12T08:09:23
2020-08-12T08:09:23
null
0
0
null
null
null
null
UTF-8
C++
false
false
132
cpp
#include <iostream> using namespace std; float a = 1.5; int c = 2; int d =3; int main() { cout << a * (c+d); return 0; }
9adb0d5a069ff32a62571ac95e853e441bc56342
f8e24957ffd5d978ef23c3482805f6757482ec50
/Algorithms/Tracking/CovarianceTracking/hue_feature_extractor.cpp
737580aec64e8a1bb98d30d79e850afe81a2220c
[]
no_license
pinkslot/myf4k
e6ddd7e4f0b95044fa87735f74ddfad7714b6108
99da4003e4110d8a80aa1734486f10d7ad9ec008
refs/heads/master
2021-01-19T20:18:15.480572
2014-05-21T14:19:11
2014-05-21T14:19:11
19,774,478
2
1
null
null
null
null
UTF-8
C++
false
false
1,524
cpp
// Class for feature extraction from an image matrix, where each feature is the set of the pixel's color channel values. // Naming conventions: // - W: image width // - H: image height // - d: feature number #include "hue_feature_extractor.h" using namespace cv; namespace alg { // Returns a (WH)xd matrix, i.e. a matrix where each row is a feature vector. // The input image type is supposed to be CV_8UC3. Mat HueFeatureExtractor::computeFeatureSet(const Mat& img, const Mat& mask) { // Compute the number of pixels to be considered int num_features = 0; for(int i=0; i<mask.rows; i++) { for(int j=0; j<mask.cols; j++) { if(mask.at<bool>(i,j)) num_features++; } } // Create feature matrix; each row represents a feature vector Mat feature_matrix(num_features, featureNumber(), CV_64F); // Counter for the next feature vector to write int feature_counter = 0; // Convert to HSV Mat img_hsv; cvtColor(img, img_hsv, CV_BGR2HSV); // Compute features: hue for(int i=0; i<img_hsv.rows; i++) { // Set the feature vector to the pixel's RGB value for(int j=0; j<img_hsv.cols; j++) { if(mask.at<bool>(i,j)) { // Get the (i,j) pixel Vec3b pixel = img_hsv.at<Vec3b>(i, j); // Set the feature matrix values, normalizing in [0,1] feature_matrix.at<double>(feature_counter, 0) = ((double)pixel[0])/10.0; // Increment the number of feature vectors feature_counter++; } } } // Return feature matrix return feature_matrix; } }
4d160d76cff479ee497fd0fe61b6f78998dc1259
d283b8205b71a8afd806501bc1832a97204514c0
/src/fs_base_rmdir.hpp
918750ff27262ae19bbead693800819d6fba4678
[ "ISC" ]
permissive
yatesco/mergerfs
d923ee23a7499802c2cce6d92305344f57f36240
c7c5b073898b338308d783384c918a713c90a83d
refs/heads/master
2021-01-12T15:23:39.875015
2016-10-20T20:52:32
2016-10-20T20:52:32
71,768,104
0
0
null
2016-10-24T08:28:27
2016-10-24T08:28:26
null
UTF-8
C++
false
false
960
hpp
/* ISC License Copyright (c) 2016, Antonio SJ Musumeci <[email protected]> Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #include <string> #include <unistd.h> namespace fs { static inline int rmdir(const std::string &path) { return ::rmdir(path.c_str()); } }
82a917f10066e1c982069da03e41b42896fb9d4b
656853d6def3b4a78ad371af62f93eaa61f40b9a
/include/smtl/distinct.h
5bc7d8216690f9b0969b987369fa4d7301b6a771
[]
no_license
mikenz1000/smtl
27927b281ededd3f232952c0b4b840e090ac75b7
db2141b203f36c122dcaffc19fe8def8ed5608cb
refs/heads/master
2023-07-11T07:46:45.835079
2021-08-22T20:40:56
2021-08-22T20:40:56
398,792,543
0
0
null
2021-08-22T20:21:18
2021-08-22T12:18:27
C++
UTF-8
C++
false
false
856
h
#ifndef SMTL_UNIQUE_H #define SMTL_UNIQUE_H #include "vector.h" namespace smtl { template<typename Input, typename output=vector<>> struct distinct; // template to remove first if a duplicate template<typename T, T first, T... remaining, T... output> struct distinct<vector<first, first, remaining...>, vector<output...>> { using value = typename distinct<vector<remaining...>, vector<output..., first>>::value; }; // stopping condition template<typename T, T... output> struct distinct<vector<>, vector<output...>> { using value = vector<output...>; }; // template to recurse normally template<typename T, T first, T... remaining, T... output> struct distinct<vector<first, remaining...>, vector<output...>> { using value = typename distinct<vector<remaining...>, vector<output..., first>>::value; }; } #endif //SMTL_UNIQUE_H
08cb6e996a6f105cae3eb427c7a769bdb89a8a31
1d018b9c15c617467aa8c2d7f2f8baf1f0882b92
/of_v0.7.4_vs2010_release/apps/myApps/Bicicletorama/src/arduino/Arduino.h
225c6bb1c3fa8e197cff9229076b4f6621514324
[ "MIT" ]
permissive
Bicicletorama/Game
46e0749edc4cfde34698519e05588189eec93253
f29b9fe6a19d170ca48d854e1a03e74ae61b3c75
refs/heads/master
2020-08-05T03:23:56.623569
2013-12-09T01:00:03
2013-12-09T01:00:03
13,182,913
1
1
null
2013-11-12T04:18:29
2013-09-28T23:48:58
C
UTF-8
C++
false
false
364
h
#pragma once #include "ofMain.h" #include "Configuration.h" class Arduino : public ofSerial { public: void setup(); void update(); bool connected; int getImpulse(int playerID); float getDirection(int playerID); private: string buffer; int impulse[TOTAL_PLAYERS]; float direction[TOTAL_PLAYERS]; };
5739c5aac9bfe288b8693652667111a51b2fc073
e5bbefc732d1fbb06820a53594ebd2ea9cf051c2
/sasassss.cpp
33370614d6ffe0b013785b07df1fba09d2aa0683
[]
no_license
Sarthakshah30/Codeforces
20632f9b31e7c8a27c78a2bf0d5fbfbc13c0fd25
664bee5e710aebeba0bd9c4528b91008369965f0
refs/heads/master
2021-01-20T07:51:46.043250
2017-07-14T10:22:05
2017-07-14T10:22:05
90,054,397
0
0
null
null
null
null
UTF-8
C++
false
false
588
cpp
#include<iostream> #include<cstring> using namespace std; int a[1000010]; long long cnt[1000010]; int main(){ int n; cin>>n; long long int sum=0; for(int i = 0 ; i < n ; i++){ cin>>a[i]; sum+=a[i]; } if(sum%3!=0){ cout<<0<<endl; } else{ sum/=3; long long s=0; for(int i = n-1 ; i>=0 ; i--){ s+=a[i]; if(s==sum) cnt[i]=1; } for(int i = n-2 ; i>=0 ; i--) cnt[i]+=cnt[i+1]; long long ans=0; s=0; for(int i = 0 ; i+2<n ; i++){ s+=a[i]; if(s==sum){ ans+=cnt[i+2]; } } cout<<ans<<endl; } }
0364e9e9ae4eedc46f9bfb0ee6afb3ec74c697d6
b162de01d1ca9a8a2a720e877961a3c85c9a1c1c
/241.different-ways-to-add-parentheses.cpp
ad947141256519f4078bc09b37c25182516d9b15
[]
no_license
richnakasato/lc
91d5ff40a1a3970856c76c1a53d7b21d88a3429c
f55a2decefcf075914ead4d9649d514209d17a34
refs/heads/master
2023-01-19T09:55:08.040324
2020-11-19T03:13:51
2020-11-19T03:13:51
114,937,686
0
0
null
null
null
null
UTF-8
C++
false
false
882
cpp
/* * [241] Different Ways to Add Parentheses * * https://leetcode.com/problems/different-ways-to-add-parentheses/description/ * * algorithms * Medium (48.10%) * Total Accepted: 65.1K * Total Submissions: 135.4K * Testcase Example: '"2-1-1"' * * Given a string of numbers and operators, return all possible results from * computing all the different possible ways to group numbers and operators. * The valid operators are +, - and *. * * Example 1: * * * Input: "2-1-1" * Output: [0, 2] * Explanation: * ((2-1)-1) = 0 * (2-(1-1)) = 2 * * Example 2: * * * Input: "2*3-4*5" * Output: [-34, -14, -10, -10, 10] * Explanation: * (2*(3-(4*5))) = -34 * ((2*3)-(4*5)) = -14 * ((2*(3-4))*5) = -10 * (2*((3-4)*5)) = -10 * (((2*3)-4)*5) = 10 * */ class Solution { public: vector<int> diffWaysToCompute(string input) { } };
7920c17efa180d2591b692f6708d9eb99eb1d658
b17cc0b4428608c15610a1eb133a4d0e94c1ac18
/LinkedList/LinkedList Cycle.cpp
b3b710849528252fac42755cddcb477d5f2262c5
[]
no_license
viveky1794/LeetCode-Problems
afbefa7ff790e44141e11b3c333605e866d12e18
8e5b32c274aeba6d6f2a8b19836756ae79a02299
refs/heads/master
2022-12-11T04:37:22.990379
2020-09-04T20:29:28
2020-09-04T20:29:28
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,015
cpp
/* Given a linked list, determine if it has a cycle in it. To represent a cycle in the given linked list, we use an integer pos which represents the position (0-indexed) in the linked list where tail connects to. If pos is -1, then there is no cycle in the linked list. Example 1: Input: head = [3,2,0,-4], pos = 1 Output: true Explanation: There is a cycle in the linked list, where tail connects to the second node. */ /** * 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,*fast; slow = head; fast = head; while(fast && fast->next) { slow = slow->next; fast = fast->next->next; if(slow == fast) { return true; } } return false; } };
6a85a668d9965afbcbb0886320616b0c71c13acd
65964baaae2c631c0b73716886d0eeae2013838b
/convert_sorted_array_to_binary_search_tree/convert_sorted_array_to_binary_search_tree.cpp
57876a0185f10e71f4b40867f75a6386a4b1d376
[]
no_license
try-your-best/leetcode
d3a5f53bee8e917b11f12c3f21b34fd11a7eafb3
859ff86a138d667a839adec0d352e39ae88a15da
refs/heads/master
2016-09-15T20:33:30.394740
2014-10-13T14:42:28
2014-10-13T14:42:28
null
0
0
null
null
null
null
UTF-8
C++
false
false
801
cpp
/* 思路:每次取数组的中间节点! */ /** * Definition for binary tree * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x), left(NULL), right(NULL) {} * }; */ class Solution { public: TreeNode* transform(vector<int> &num, int start, int end) { if(start <= end) { int middle = (start+end)/2; TreeNode* pNode = new TreeNode(num[middle]); pNode->left = transform(num, start, middle-1); pNode->right = transform(num, middle+1, end); return pNode; } return NULL; } TreeNode *sortedArrayToBST(vector<int> &num) { if(num.empty()) return NULL; return transform(num, 0, num.size()-1); } };
d6aed312ac9617c4c1d19f105d6a0b8c96a71b18
c78c28c60df30fab5e66253bfa6681a87765abd1
/wizd_String.cpp
e29d4775c9a838fd7754638494a970a86fd29208
[ "MIT" ]
permissive
keelanstuart/TinyJS
92c2935c518f6efe4168023efd20f5ad3c947ffd
83a08f1b05a113db32c45ee0469198c7188a6b85
refs/heads/master
2022-03-28T08:51:24.733912
2020-01-11T22:10:08
2020-01-11T22:10:08
null
0
0
null
null
null
null
SHIFT_JIS
C++
false
false
64,117
cpp
#define _CRT_SECURE_NO_WARNINGS #define _CRT_NONSTDC_NO_DEPRECATE #pragma comment(lib, "shlwapi.lib") #include <stdio.h> #include <string.h> #include <malloc.h> #include <fcntl.h> #include <sys/stat.h> //#include <dirent.h> #include <assert.h> #include <sys/types.h> #include <vector> #include <algorithm> #include <windows.h> #ifdef linux #include <unistd.h> #include <netdb.h> #include <stdlib.h> #include <stdarg.h> #include <ctype.h> #else #include <process.h> //#include <dir.h> #include <Shlwapi.h> #include <direct.h> #include <io.h> #endif #include <time.h> #include "wizd_String.h" #include "define.h" //linux/windows共用オープン //追加: O_CREAT | O_APPEND | O_WRONLY(またはO_RDWR) | (O_BINARY) , S_IREAD | S_IWRITE //新規: O_CREAT | O_TRUNC | O_WRONLY(またはO_RDWR) | (O_BINARY) , S_IREAD | S_IWRITE //読込: O_RDONLY | (O_BINARY) int myopen(const char* filename, int amode, int option) { #ifdef linux if (option != 0) { return open(filename, amode, option); } else { return open(filename, amode); } #else char work[1024]; strcpy(work, filename); int ptr = 0; while (work[ptr]) { if (work[ptr] == '/') { work[ptr] = '\\'; } ptr++; } if (option != 0) { return _open(work, amode, option); } else { return _open(work, amode); } #endif } // ************************************************************************** // fdから、1行(CRLFか、LF単独が現れるまで)受信 // CRLFは削除する。 // 受信したサイズをreturnする。 // ************************************************************************** int readLine(int fd, char* line_buf_p, int line_max) { char byte_buf; int line_len = 0; int recv_len; // 1行受信実行 while (1) { recv_len = read(fd, &byte_buf, 1); if (recv_len != 1) { // 受信失敗チェック return (-1); } // CR/LFチェック if (byte_buf == '\r') { continue; } else if (byte_buf == '\n') { *line_buf_p = 0; break; } // バッファにセット *line_buf_p++ = byte_buf; // 受信バッファサイズチェック if (++line_len >= line_max) { // バッファオーバーフロー検知 return (-1); } } return line_len; } #ifndef strrstr //********************************************************* // strrstr() // 文字列 から 文字列 を検索する。 // 最後 に現れた文字列の先頭を指す ポインタ を返す。 // 文字列が見つからない場合は null を返す。 // pattern が 空文字列 の場合は常に 文字列終端 を返す。 // 文字列終端文字 '\0' は検索対象とならない。 // 半角英字 の 大文字と小文字 を区別する。 // // const char *string // 検索対象となる文字列 // // const char *pattern // 文字列から検索する文字列 // //********************************************************* char* // 文字列へのポインタ strrstr(const char* string, const char* pattern) { // 文字列終端に達するまで検索を繰り返す。 const char* last = NULL; for (const char* p = string; ; p++) { if (0 == *p) { return (char*)last; } p = strstr(p, pattern); if (p == NULL) { break; } last = p; } return (char*)last; }//strrstr #endif //--------------------------------------------------------------------------- //source //--------------------------------------------------------------------------- const int wString::npos = (int)(-1); //--------------------------------------------------------------------------- //通常コンストラクタ wString::wString(void) { //初期化 len = 0; total = 1; String = (char*)new char[1]; *String = 0; } //--------------------------------------------------------------------------- //通常コンストラクタ wString::wString(int mylen) { //初期化 if (mylen < 0) mylen = 0; len = 0; //末尾0の分 total = mylen + 1; String = (char*)new char[mylen + 1]; *String = 0; } //--------------------------------------------------------------------------- //文字列コンストラクタ wString::wString(const char* str) { //初期化 len = strlen(str); if (len) { total = len + 1; String = (char*)new char[total]; //strcpy(String, str); strcpy_s(String, total, str); } else { total = 1; String = (char*)new char[1]; String[0] = 0; } } //--------------------------------------------------------------------------- //コピーコンストラクタ wString::wString(const wString& str) { //初期化 len = str.len; if (str.len) { total = str.total; String = new char[str.total]; memcpy(String, str.String, str.total); //*String = 0; } else { total = 1; String = (char*)new char[1]; String[0] = 0; } } //--------------------------------------------------------------------------- //デストラクタ wString::~wString() { delete[] String; } //--------------------------------------------------------------------------- //ディープコピーメソッド //void wString::copy(wString* dst,const wString* src) //{ // src->myrealloc(src->total); // memcpy( dst->String, src->String, src->total); // dst->len = src->len; //} //--------------------------------------------------------------------------- //ディープコピーメソッド //void wString::copy(wString* dst,const wString& src) //{ // dst->myrealloc(src.total); // memcpy( dst->String, src.String, src.total); // dst->len = src.len; //} //--------------------------------------------------------------------------- wString wString::operator+(const wString& str) const { wString temp(*this); temp += str; return temp; } //--------------------------------------------------------------------------- wString wString::operator+(const char* str) const { wString temp(*this); temp += str; return temp; } //--------------------------------------------------------------------------- wString operator+(const char* str1, const wString str2) { wString temp(str1); temp += str2; return temp; } //--------------------------------------------------------------------------- void wString::operator+=(const wString& str) { unsigned int newLen = len + str.len; myrealloc(newLen + 1); memcpy(String + len, str.String, str.len); String[newLen] = 0; len = newLen; return; } //--------------------------------------------------------------------------- void wString::operator+=(const char* str) { unsigned int slen = strlen(str); unsigned int newLen = slen + len; myrealloc(newLen); strcpy(String + len, str); len = newLen; return; } //--------------------------------------------------------------------------- void wString::operator+=(const char ch) { int tmpl = ((len >> 4) + 1) << 4; myrealloc(tmpl); String[len++] = ch; String[len] = 0; return; } //--------------------------------------------------------------------------- bool wString::operator==(const wString& str) const { if (len != str.len) { return false; } return(strncmp(String, str.String, len) == 0); } //--------------------------------------------------------------------------- bool wString::operator==(const char* str) const { unsigned int mylen = strlen(str); if (len != mylen) { return false; } return(strncmp(String, str, len) == 0); } //--------------------------------------------------------------------------- bool wString::operator!=(const wString& str) const { if (len != str.len) { return true; } return(strncmp(String, str.String, len) != 0); } //--------------------------------------------------------------------------- bool wString::operator!=(const char* str) const { if (len != strlen(str)) { return true; } return(strncmp(String, str, len) != 0); } //--------------------------------------------------------------------------- bool wString::operator>=(const wString& str) const { unsigned int maxlen = (len > str.len) ? len : str.len; return(strncmp(String, str.String, maxlen) >= 0); } //--------------------------------------------------------------------------- bool wString::operator>=(const char* str) const { unsigned int mylen = strlen(str); unsigned int maxlen = (len > mylen) ? len : mylen; return(strncmp(String, str, maxlen) >= 0); } //--------------------------------------------------------------------------- bool wString::operator<=(const wString& str) const { unsigned int maxlen = (len > str.len) ? len : str.len; return(strncmp(String, str.String, maxlen) <= 0); } //--------------------------------------------------------------------------- bool wString::operator<=(const char* str) const { unsigned int mylen = strlen(str); unsigned int maxlen = (len > mylen) ? len : mylen; return(strncmp(String, str, maxlen) <= 0); } //--------------------------------------------------------------------------- bool wString::operator>(const wString& str) const { unsigned int maxlen = (len > str.len) ? len : str.len; return(strncmp(String, str.String, maxlen) > 0); } //--------------------------------------------------------------------------- bool wString::operator>(const char* str) const { unsigned int mylen = strlen(str); unsigned int maxlen = (len > mylen) ? len : mylen; return(strncmp(String, str, maxlen) > 0); } //--------------------------------------------------------------------------- bool wString::operator<(const wString& str) const { unsigned int maxlen = (len > str.len) ? len : str.len; return(strncmp(String, str.String, maxlen) < 0); } //--------------------------------------------------------------------------- bool wString::operator<(const char* str) const { unsigned int mylen = strlen(str); unsigned int maxlen = (len > mylen) ? len : mylen; return(strncmp(String, str, maxlen) < 0); } //--------------------------------------------------------------------------- void wString::operator=(const wString& str) { myrealloc(str.total); memcpy(String, str.String, str.total); len = str.len; return; } //--------------------------------------------------------------------------- void wString::operator=(const char* str) { int newLen = strlen(str); myrealloc(newLen); strcpy(String, str); len = newLen; return; } //--------------------------------------------------------------------------- void wString::operator=(const int num) { this->sprintf("%d", num); return; } //--------------------------------------------------------------------------- void wString::operator=(const double num) { this->sprintf("%f", num); return; } //--------------------------------------------------------------------------- char wString::operator[](unsigned int index) const { if (index < len) { return String[index]; } else { perror("out bound"); return -1; } } //--------------------------------------------------------------------------- char wString::at(unsigned int index) const { if (index < len) { return String[index]; } else { perror("out bound"); return -1; } } //--------------------------------------------------------------------------- wString& wString::SetLength(const unsigned int num) { myrealloc(num); return *this; } //--------------------------------------------------------------------------- // 比較 //--------------------------------------------------------------------------- int wString::compare(const wString& str) const { return strcmp(String, str.String); } //--------------------------------------------------------------------------- // 比較 //--------------------------------------------------------------------------- int wString::compare(const char* str) const { return strcmp(String, str); } //--------------------------------------------------------------------------- // クリア //--------------------------------------------------------------------------- void wString::clear(void) { len = 0; if (*String) { *String = 0; } } //--------------------------------------------------------------------------- // 部分文字列 //--------------------------------------------------------------------------- wString wString::SubString(int start, int mylen) const { if (start + mylen > (int)len) mylen = (int)len - start; wString temp(mylen); if (mylen > 0) { memcpy(temp.String, String + start, mylen); temp.String[mylen] = 0; //長さ不定。数えなおす temp.len = mylen; } return temp; } //--------------------------------------------------------------------------- // substr //--------------------------------------------------------------------------- wString wString::substr(int start, int mylen) const { if (mylen < 0) mylen = len; if (start + mylen > (int)len) mylen = (int)len - start; wString temp(mylen); if (mylen > 0) { memcpy(temp.String, String + start, mylen); temp.String[mylen] = 0; //長さ不定。数えなおす temp.len = mylen; } return temp; } //--------------------------------------------------------------------------- // 位置 //--------------------------------------------------------------------------- int wString::find(const wString& str, size_t index) const { char* ptr = strstr(String + index, str.String); if (ptr == NULL) { return npos; } else { return (size_t)(ptr - String); } } //--------------------------------------------------------------------------- // 位置 //--------------------------------------------------------------------------- int wString::find(const char* str, size_t index) const { char* ptr = strstr(String + index, str); if (ptr == NULL) { return npos; } else { return (size_t)(ptr - String); } } //--------------------------------------------------------------------------- // 位置 //--------------------------------------------------------------------------- int wString::find(char ch, size_t index) const { char* ptr = strchr(String + index, ch); if (ptr == NULL) { return npos; } else { return (size_t)(ptr - String); } } //--------------------------------------------------------------------------- // 行末からの検索 //--------------------------------------------------------------------------- int wString::rfind(const wString& str, size_t index) const { char* ptr = strrstr(String + index, str.String); if (ptr == NULL) { return npos; } else { return (size_t)(ptr - String); } } //--------------------------------------------------------------------------- // 行末からの検索 // str:文字列 // index:開始位置(省略可能) //--------------------------------------------------------------------------- int wString::rfind(const char* str, size_t index) const { char* ptr = strrstr(String + index, str); if (ptr == NULL) { return npos; } else { return (size_t)(ptr - String); } } //--------------------------------------------------------------------------- // 行末からの検索 // ch:char // index:開始位置(省略可能) //--------------------------------------------------------------------------- int wString::rfind(char ch, size_t index) const { char* ptr = strrchr(String + index, ch); if (ptr == NULL) { return npos; } else { return (size_t)(ptr - String); } } //--------------------------------------------------------------------------- // 位置 //--------------------------------------------------------------------------- //int wString::Pos(const char* pattern) //{ // char* ptr = strstr(String,pattern); // if( ptr == NULL ){ // return npos; // }else{ // return (int)(ptr-String); // } //} //--------------------------------------------------------------------------- // 位置 //--------------------------------------------------------------------------- int wString::Pos(const char* pattern, int pos) const { char* ptr = strstr(String + pos, pattern); if (ptr == NULL) { return npos; } else { return (int)(ptr - String); } } //--------------------------------------------------------------------------- // 位置 //--------------------------------------------------------------------------- //int wString::Pos(wString& pattern, int pos) //{ // return // char* ptr = strstr(String+pos,pattern.c_str()); // if( ptr == NULL ){ // return npos; // }else{ // return (int)(ptr-String); // } //} //--------------------------------------------------------------------------- // 位置 //--------------------------------------------------------------------------- int wString::Pos(const wString& pattern, int pos) const { return Pos(pattern.String, pos); } //--------------------------------------------------------------------------- // Size //--------------------------------------------------------------------------- size_t wString::size(void) const { return (size_t)len; } //--------------------------------------------------------------------------- // Size //--------------------------------------------------------------------------- size_t wString::length(void) const { return (size_t)len; } //--------------------------------------------------------------------------- // ファイル読み込み //--------------------------------------------------------------------------- void wString::LoadFromFile(const wString& str) { LoadFromFile(str.String); } //--------------------------------------------------------------------------- // ファイル読み込み //--------------------------------------------------------------------------- int wString::LoadFromFile(const char* FileName) { long flen; int handle; if (strncmp(FileName, "http://", 7) == 0) { wString tmp; //tmp = wString::HTTPGet((char*)FileName,0); *this = tmp; } else { #ifdef linux handle = open(FileName, O_RDONLY | S_IREAD); #else handle = myopen(FileName, O_RDONLY | O_BINARY, S_IREAD); #endif if (handle < 0) { return -1; } flen = lseek(handle, 0, SEEK_END); lseek(handle, 0, SEEK_SET); SetLength(flen + 1); len = read(handle, String, flen); close(handle); String[len] = 0; //\0がある場合を考えればstrlenとってはいけない //len = strlen(String); } return 0; } //--------------------------------------------------------------------------- // ファイル読み込み //--------------------------------------------------------------------------- void wString::LoadFromCSV(const wString& str) { LoadFromCSV(str.String); } int isNumber(char* str) { for (int i = strlen(str) - 1; i >= 0; i--) { if ((!isdigit(str[i])) && str[i] != '.') { return 0; } } return 1; } //--------------------------------------------------------------------------- // ファイル読み込み //--------------------------------------------------------------------------- void wString::LoadFromCSV(const char* FileName) { int fd; char s[1024]; char t[1024]; int ret; int first = 1; fd = myopen(FileName, O_RDONLY | O_BINARY, S_IREAD); if (fd < 0) { printf("%sファイルが開けません\n", FileName); return; } *this = "["; //1行目はタイトル while (true) { ret = readLine(fd, s, sizeof(s)); if (ret < 0) break; //分解する char* p = strtok(s, ","); int ptr = 0; if (p) { if (isNumber(p)) { ptr += ::sprintf(t + ptr, "%s", p); } else { ptr += ::sprintf(t + ptr, "\"%s\"", p); } } while ((p = strtok(NULL, ",")) != 0) { if (isNumber(p)) { ptr += ::sprintf(t + ptr, ",%s", p); } else { ptr += ::sprintf(t + ptr, ",\"%s\"", p); } } if (first) { first = 0; } else { *this += ","; } *this += wString("[") + t + "]"; } *this += "]"; close(fd); return; } //--------------------------------------------------------------------------- // ファイル書き込み //--------------------------------------------------------------------------- int wString::SaveToFile(const wString& str) { return SaveToFile(str.String); } //--------------------------------------------------------------------------- // ファイル書き込み //--------------------------------------------------------------------------- int wString::SaveToFile(const char* FileName) { #ifdef linux int handle = myopen(FileName, O_CREAT | O_TRUNC | O_RDWR, S_IREAD | S_IWRITE); #else int handle = myopen(FileName, O_CREAT | O_TRUNC | O_RDWR | O_BINARY, S_IREAD | S_IWRITE); #endif if (handle < 0) { return handle; } write(handle, String, len); close(handle); return 0; } //--------------------------------------------------------------------------- // トリム //--------------------------------------------------------------------------- wString wString::Trim(void) { wString temp(*this); if (temp.len) { //先頭の空白等を抜く while (temp.len && *temp.String <= ' ') { #ifdef linux char* src = temp.String; char* dst = src + 1; while (*src) { *src++ = *dst++; } #else strcpy((char*)temp.String, (char*)(temp.String + 1)); #endif temp.len--; } //末尾の空白等を抜く while (temp.len && temp.String[temp.len - 1] <= ' ') { temp.String[--temp.len] = 0; } } return temp; } //--------------------------------------------------------------------------- // トリム //--------------------------------------------------------------------------- wString wString::RTrim(void) { wString temp(*this); if (temp.len) { //末尾の空白等を抜く while (temp.len && temp.String[temp.len - 1] <= ' ') { temp.String[--temp.len] = 0; } } return temp; } //--------------------------------------------------------------------------- // sentence文字列の行末に、cut_charがあったとき、削除 //--------------------------------------------------------------------------- void wString::Rtrimch(char* sentence, char cut_char) { if (sentence == NULL || *sentence == 0) return; char* source_p; int length, i; length = strlen(sentence); // 文字列長Get source_p = sentence; source_p += length; // ワークポインタを文字列の最後にセット。 for (i = 0; i < length; i++) { // 文字列の数だけ繰り返し。 source_p--; // 一文字ずつ前へ。 if (*source_p == cut_char) { // 削除キャラ ヒットした場合削除 *source_p = '\0'; } else { // 違うキャラが出てきたところで終了。 break; } } return; } //--------------------------------------------------------------------------- // トリム //--------------------------------------------------------------------------- wString wString::LTrim(void) { wString temp(*this); if (temp.len) { //先頭の空白等を抜く while (temp.len && *temp.String <= ' ') { char* src = temp.String; char* dst = src + 1; while (*src) { *src++ = *dst++; } temp.len--; } } return temp; } #if 1 //-------------------------------------------------------------------- wString wString::FileStats(const char* str, int mode) { struct stat stat_buf; wString buf; if (stat(str, &stat_buf) == 0 && mode == 0) { /* ファイル情報を表示 */ buf.sprintf("{\"permission\":\"%o\",\"size\":%d,\"date\":\"%s\"}", stat_buf.st_mode, stat_buf.st_size, ctime(&stat_buf.st_mtime)); //printf("デバイスID : %d\n",stat_buf.st_dev); //printf("inode番号 : %d\n",stat_buf.st_ino); //printf("アクセス保護 : %o\n",stat_buf.st_mode ); //printf("ハードリンクの数 : %d\n",stat_buf.st_nlink); //printf("所有者のユーザID : %d\n",stat_buf.st_uid); //printf("所有者のグループID : %d\n",stat_buf.st_gid); //printf("デバイスID(特殊ファイルの場合) : %d\n",stat_buf.st_rdev); //printf("容量(バイト単位) : %d\n",stat_buf.st_size); //printf("ファイルシステムのブロックサイズ : %d\n",stat_buf.st_blksize); //printf("割り当てられたブロック数 : %d\n",stat_buf.st_blocks); //printf("最終アクセス時刻 : %s",ctime(&stat_buf.st_atime)); //printf("最終修正時刻 : %s",ctime(&stat_buf.st_mtime)); //printf("最終状態変更時刻 : %s",ctime(&stat_buf.st_ctime)); } else { //date if (mode == 1) { //char s[128] = {0}; //time_t timer; //struct tm *timeptr; //timer = time(NULL); //timeptr = localtime(&stat_buf.st_mtime); //strftime(s, 128, "%Y/%m/%d %H:%M:%S", timeptr); buf.sprintf("%d", stat_buf.st_mtime); } } return buf; } //--------------------------------------------------------------------------- wString wString::FileStats(const wString& str, int mode) { return FileStats(str.String, mode); } #endif //--------------------------------------------------------------------------- int wString::FileExists(const char* str) { int flag = 0; #ifdef linux struct stat send_filestat; int result = stat(str, &send_filestat); if ((result == 0) && (S_ISREG(send_filestat.st_mode) == 1)) { flag = 1; } #else WIN32_FIND_DATAA fd = { 0 }; HANDLE hFound = FindFirstFileA(str, &fd); flag = (hFound != INVALID_HANDLE_VALUE) ? 1 : 0; FindClose(hFound); //return retval; //flag = PathFileExists((char*)str); #endif return flag; } //--------------------------------------------------------------------------- int wString::FileExists(const wString& str) { return FileExists(str.String); } //--------------------------------------------------------------------------- //パス部分を抽出 wString wString::ExtractFileDir(wString& str) { //todo SJIS/EUC対応するように wString temp(str); int ptr = temp.LastDelimiter(DELIMITER); temp.len = ptr; temp.String[ptr] = 0; return temp; } //--------------------------------------------------------------------------- int wString::CreateDir(const wString& str) { int flag = 0; #ifdef linux //0x777ではちゃんとフォルダできない flag = (mkdir(str.String, 0777) != -1); #else char work[2048]; strcpy(work, str.c_str()); WindowsFileName(work); if (!DirectoryExists(work)) { flag = (_mkdir(work) != -1); } #endif return flag; } //--------------------------------------------------------------------------- // TStringList対策 // 行数を返す //--------------------------------------------------------------------------- //void wString::ResetLength(unsigned int num) //{ // assert(total>(unsigned int)num); // String[num] = 0; // len = num; //} //--------------------------------------------------------------------------- char* wString::c_str(void) const { return String; } //--------------------------------------------------------------------------- int wString::Length(void) const { return len; } //--------------------------------------------------------------------------- int wString::Total(void) const { return total; } //--------------------------------------------------------------------------- int wString::LastDelimiter(const char* delim) const { int pos = -1; int dlen = strlen(delim); for (int i = len - dlen; i > 0; i--) { if (strncmp(String + i, delim, dlen) == 0) { pos = i; break; } } return pos; } //--------------------------------------------------------------------------- bool wString::RenameFile(const wString& src, const wString& dst) { if (rename(src.c_str(), dst.c_str()) >= 0) { return true; } else { return false; } } //--------------------------------------------------------------------------- unsigned long wString::FileSizeByName(char* str) { unsigned long pos; int handle; #ifdef linux handle = open(str, 0); #else handle = open(str, O_BINARY); #endif pos = lseek(handle, 0, SEEK_END); close(handle); return pos; } //--------------------------------------------------------------------------- unsigned long wString::FileSizeByName(wString& str) { return FileSizeByName(str.String); } //--------------------------------------------------------------------------- wString wString::ExtractFileName(const char* str, const char* delim) { wString tmp(str); return ExtractFileName(tmp, delim); } //--------------------------------------------------------------------------- wString wString::ExtractFileName(const wString& str, const char* delim) { int pos = str.LastDelimiter(delim); return str.substr(pos + 1); } //--------------------------------------------------------------------------- wString wString::ExtractFileExt(const wString& str) { int pos = str.LastDelimiter("."); return str.substr(pos + 1); } //--------------------------------------------------------------------------- wString wString::ChangeFileExt(wString& str, const char* ext) { int pos = str.LastDelimiter("."); return str.substr(0, pos + 1) + ext; } //--------------------------------------------------------------------------- int wString::DeleteFile(const wString& str) { int flag = 0; #ifdef linux flag = (unlink(str.String) == 0); #else char work[2048]; strcpy(work, str.c_str()); WindowsFileName(work); if (FileExists(work)) { if (unlink(work) == 0) { flag = 1; } } #endif return flag; } //--------------------------------------------------------------------------- int wString::DirectoryExists(const char* str) { int flag = 0; #ifdef linux struct stat send_filestat; int result = stat(str, &send_filestat); if ((result == 0) && (S_ISDIR(send_filestat.st_mode) == 1)) { flag = 1; } #else flag = PathIsDirectory((LPCTSTR)str); #endif return flag; } //--------------------------------------------------------------------------- int wString::DirectoryExists(const wString& str) { return DirectoryExists(str.String); } /********************************************************************************/ // sentence文字列内のkey文字列をrep文字列で置換する。 // sentence:元文字列 // slen:元文字列の長さ // p:置換前の位置 // klen:置換前の長さ // rep:置換後文字列 /********************************************************************************/ void wString::replace_character_len(const char* sentence, int slen, const char* p, int klen, const char* rep) { char* str; int rlen = strlen((char*)rep); int num; if (klen == rlen) { memcpy((void*)p, rep, rlen); //前詰め置換そのままコピーすればいい } else if (klen > rlen) { num = klen - rlen; strcpy((char*)p, (char*)(p + num)); memcpy((void*)p, rep, rlen); //置換文字が長いので後詰めする } else { num = rlen - klen; //pからrlen-klenだけのばす for (str = (char*)(sentence + slen + num); str > p + num; str--) { *str = *(str - num); } memcpy((void*)p, rep, rlen); } return; } //--------------------------------------------------------------------------- // フォルダのファイルを数える // 引数 wString Path: // 戻値 ファイルリスト。ほっておいていいが、コピーしてほしい wString wString::EnumFolderjson(const wString& Path) { //DIR *dir; //struct dirent *ent; wString temp; //wString Path2; //std::vector<wString> list; //Path2 = Path; ////Directoryオープン //if ((dir = opendir(Path.String)) != NULL){ // //ファイルリスト // while ((ent = readdir(dir)) != NULL){ // if( strcmp(ent->d_name,"." ) != 0 && // strcmp(ent->d_name,"..") != 0 ){ // list.push_back("\""+Path2+DELIMITER+ent->d_name+"\""); // } // } // closedir(dir); // // //sort // if( list.size()>0){ // for( unsigned int ii = 0 ; ii < list.size()-1; ii++){ // for( unsigned int jj = ii+1 ; jj < list.size(); jj++){ // if( strcmp(list[ii].c_str(),list[jj].c_str())> 0 ){ // std::swap(list[ii],list[jj]); // } // } // } // } temp = "["; // for( unsigned int i = 0 ; i < list.size() ; i++ ){ // if( i ) temp += ","; // temp += list[i]; // } // temp += "]"; //}else{ // perror("ディレクトリのオープンエラー"); // exit(1); //} return temp; } //--------------------------------------------------------------------------- // フォルダのファイルを数える // 引数 wString Path: // 戻値 ファイルリスト。ほっておいていいが、コピーしてほしい wString wString::EnumFolder(const wString& Path) { wString temp; #ifdef linux struct dirent** namelist; int n; wString Path2; Path2 = Path; int first = 1; n = scandir(Path.String, &namelist, NULL, alphasort); if (n < 0) { temp = ""; } else { temp = "["; for (int i = 0; i < n; i++) { if (first) { first = 0; } else { temp += ","; } temp += "\"" + Path2 + DELIMITER + namelist[i]->d_name + "\""; free(namelist[i]); } temp += "]"; free(namelist); } #else //DIR *dir; //struct dirent *ent; //wString temp; //wString Path2; //std::vector<wString> list; //Path2 = Path; ////Directoryオープン //if ((dir = opendir(Path.String)) != NULL){ // //ファイルリスト // while ((ent = readdir(dir)) != NULL){ // if( strcmp(ent->d_name,"." ) != 0 && // strcmp(ent->d_name,"..") != 0 ){ // list.push_back( Path2+DELIMITER+ent->d_name ); // } // } // closedir(dir); // if( list.size()>0){ // for( unsigned int ii = 0 ; ii < list.size()-1; ii++){ // for( unsigned int jj = ii+1 ; jj < list.size(); jj++){ // if( strcmp(list[ii].c_str(),list[jj].c_str())> 0 ){ // std::swap(list[ii],list[jj]); // } // } // } // } // for( unsigned int i = 0 ; i < list.size() ; i++ ){ // temp.Add(list[i]); // } //}else{ // perror("ディレクトリのオープンエラー"); // exit(1); //} #endif return temp; } #ifndef va_copy int wString::vtsprintf(const char* fmt, va_list arg) { int len = 0; int size = 0; int zeroflag, width; while (*fmt) { if (*fmt == '%') { /* % に関する処理 */ zeroflag = width = 0; fmt++; if (*fmt == '0') { fmt++; zeroflag = 1; } while ((*fmt >= '0') && (*fmt <= '9')) { width *= 10; width += *(fmt++) - '0'; } /* printf ("zerof = %d,width = %d\n",zeroflag,width); */ //lluもluもuも同じ while (*fmt == 'l' || *fmt == 'z') { *fmt++; } switch (*fmt) { case 'd': /* 10進数 */ size = tsprintf_decimal(va_arg(arg, signed long), zeroflag, width); break; case 'u': /* 10進数 */ size = tsprintf_decimalu(va_arg(arg, unsigned long), zeroflag, width); break; case 'o': /* 8進数 */ size = tsprintf_octadecimal(va_arg(arg, unsigned long), zeroflag, width); break; case 'x': /* 16進数 0-f */ size = tsprintf_hexadecimal(va_arg(arg, unsigned long), 0, zeroflag, width); break; case 'X': /* 16進数 0-F */ size = tsprintf_hexadecimal(va_arg(arg, unsigned long), 1, zeroflag, width); break; case 'c': /* キャラクター */ size = tsprintf_char(va_arg(arg, int)); break; case 's': /* ASCIIZ文字列 */ size = tsprintf_string(va_arg(arg, char*)); break; default: /* コントロールコード以外の文字 */ /* %%(%に対応)はここで対応される */ len++; *this += *fmt; break; } len += size; fmt++; } else { *this += *(fmt++); len++; } } va_end(arg); return (len); } /* 数値 => 10進文字列変換 */ int wString::tsprintf_decimal(signed long val, int zerof, int width) { //末尾0を保証 char tmp[22] = { 0 }; char* ptmp = tmp + 20; int len = 0; int minus = 0; if (!val) { /* 指定値が0の場合 */ *(ptmp--) = '0'; len++; } else { /* マイナスの値の場合には2の補数を取る */ if (val < 0) { val = ~val; val++; minus = 1; } while (val && len < 19) { /* バッファアンダーフロー対策 */ //if (len >= 19){ // break; //} *ptmp = (char)((val % 10) + '0'); val /= 10; ptmp--; len++; } } /* 符号、桁合わせに関する処理 */ if (zerof) { if (minus) { width--; } while (len < width) { *(ptmp--) = '0'; len++; } if (minus) { *(ptmp--) = '-'; len++; } } else { if (minus) { *(ptmp--) = '-'; len++; } while (len < width) { *(ptmp--) = ' '; len++; } } *this += (ptmp + 1); return (len); } /* 数値 => 10進文字列変換 */ int wString::tsprintf_decimalu(unsigned long val, int zerof, int width) { char tmp[22] = { 0 }; char* ptmp = tmp + 20; int len = 0; int minus = 0; if (!val) { /* 指定値が0の場合 */ *(ptmp--) = '0'; len++; } else { while (val) { /* バッファアンダーフロー対策 */ if (len >= 19) { break; } *ptmp = (char)((val % 10) + '0'); val /= 10; ptmp--; len++; } } /* 符号、桁合わせに関する処理 */ if (zerof) { if (minus) { width--; } while (len < width) { *(ptmp--) = '0'; len++; } if (minus) { *(ptmp--) = '-'; len++; } } else { while (len < width) { *(ptmp--) = ' '; len++; } } *this += (ptmp + 1); return (len); } /* 数値 => 8進文字列変換 */ int wString::tsprintf_octadecimal(unsigned long val, int zerof, int width) { char tmp[22] = { 0 }; char* ptmp = tmp + 20; int len = 0; int minus = 0; if (!val) { /* 指定値が0の場合 */ *(ptmp--) = '0'; len++; } else { while (val) { /* バッファアンダーフロー対策 */ if (len >= 19) { break; } *ptmp = (char)((val % 8) + '0'); val /= 8; ptmp--; len++; } } /* 符号、桁合わせに関する処理 */ if (zerof) { if (minus) { width--; } while (len < width) { *(ptmp--) = '0'; len++; } if (minus) { *(ptmp--) = '-'; len++; } } else { while (len < width) { *(ptmp--) = ' '; len++; } } *this += (ptmp + 1); return (len); } /* 数値 => 16進文字列変換 */ int wString::tsprintf_hexadecimal(unsigned long val, int capital, int zerof, int width) { char tmp[22] = { 0 }; char* ptmp = tmp + 20; int len = 0; char str_a; /* A〜Fを大文字にするか小文字にするか切り替える */ if (capital) { str_a = 'A'; } else { str_a = 'a'; } if (!val) { /* 指定値が0の場合 */ *(ptmp--) = '0'; len++; } else { while (val) { /* バッファアンダーフロー対策 */ if (len >= 18) { break; } *ptmp = (char)(val % 16); if (*ptmp > 9) { *ptmp += (char)(str_a - 10); } else { *ptmp += '0'; } val >>= 4; /* 16で割る */ ptmp--; len++; } } while (len < width) { *(ptmp--) = zerof ? '0' : ' '; len++; } *this += (ptmp + 1); return(len); } /* 数値 => 1文字キャラクタ変換 */ int wString::tsprintf_char(int ch) { *this += (char)ch; return(1); } /* 数値 => ASCIIZ文字列変換 */ int wString::tsprintf_string(char* str) { *this += str; return(strlen(str)); } #endif //--------------------------------------------------------------------------- //wString 可変引数 int wString::sprintf(const char* format, ...) { #ifndef va_copy String[0] = 0; len = 0; va_list ap; va_start(ap, format); vtsprintf(format, ap); va_end(ap); return len; #else int stat; //可変引数を2つ作る va_list ap1, ap2; va_start(ap1, format); va_copy(ap2, ap1); //最初はダミーで文字列長をシミュレート stat = vsnprintf(String, 0, format, ap1); SetLength(stat + 1); //実際に出力 stat = vsprintf(String, format, ap2); va_end(ap1); va_end(ap2); len = stat; return stat; #endif } //--------------------------------------------------------------------------- //wString 可変引数 int wString::cat_sprintf(const char* format, ...) { #ifndef va_copy int status; va_list ap; va_start(ap, format); status = this->vtsprintf(format, ap); va_end(ap); return status; #else int stat; //可変引数を2つ作る va_list ap1, ap2; va_start(ap1, format); va_copy(ap2, ap1); //最初はダミーで文字列長をシミュレート stat = vsnprintf(String, 0, format, ap1); SetLength(stat + len + 1); //実際に出力 stat = vsprintf(String + len, format, ap2); va_end(ap1); va_end(ap2); len += stat; return stat; #endif } //--------------------------------------------------------------------------- //文字列をデリミタで切って、デリミタ後の文字を返す //引数 //wString str :入力文字列 //const char* delimstr :切断文字列 //戻り値 //wString :切断後の文字列 //見つからない場合は長さ0の文字列 wString wString::strsplit(const char* delimstr) { wString tmp; int delimlen = strlen(delimstr); int pos = Pos(delimstr); if (pos != npos) { tmp = substr(pos + delimlen); } return tmp; } //--------------------------------------------------------------------------- // //--------------------------------------------------------------------------- void wString::myrealloc(const int newsize) { if (len >= total) { printf("not good %d %d", len, total); exit(1); } if ((int)total <= newsize) { total = newsize + 1; char* tmp = new char[total]; memcpy(tmp, String, len); tmp[len] = 0; delete[] String; String = tmp; } else { //指定サイズが元より小さいので何もしない } } //--------------------------------------------------------------------------- //HTML特殊文字に変換 wString wString::htmlspecialchars(void) { wString temp; // 引数チェック char* ptr = String; for (unsigned int is = 0; is < len; is++) { switch (*ptr) { case '&':temp += "&amp;"; break; case '\"':temp += "&quot;"; break; //case '\'':temp += "&#39;";break; case '<':temp += "&lt;"; break; case '>':temp += "&gt;"; break; default:temp += *ptr; break; } ptr++; } return temp; } //--------------------------------------------------------------------------- // ************************************************************************** // URIエンコードを行います. // 機能 : URIデコードを行う // 書式 : int uri_encode // (char* dst,size_t dst_len,const char* src,int src_len); // 引数 : dst 変換した文字の書き出し先. // dst_len 変換した文字の書き出し先の最大長. // src 変換元の文字. // src_len 変換元の文字の長さ. // 返値 : エンコードした文字の数(そのままも含む) // ************************************************************************** wString wString::uri_encode(void) { unsigned int is; wString dst; char work[8]; // 引数チェック for (is = 0; is < len; is++) { /* ' '(space) はちと特別扱いにしないとまずい */ if (String[is] == ' ') { dst += "%20"; /* エンコードしない文字全員集合 */ // }else if ( strchr("!$()*,-./:;?@[]^_`{}~", String[is]) != NULL ){ } else if (strchr("!$()*,-.:;/?@[]^_`{}~", String[is]) != NULL) { dst += String[is]; /* アルファベットと数字はエンコードせずそのまま */ } else if (isalnum(String[is])) { dst += String[is]; } /* \マークはエンコード */ else if (String[is] == '\\') { dst += "%5c"; /* それ以外はすべてエンコード */ } else { ::sprintf(work, "%%%2X", (unsigned char)String[is]); dst += work; } } return dst; } int wString::FileCopy(const char* fname_r, const char* fname_w) { int fpr; int fpw; int size; unsigned char buf[8000]; fpr = myopen(fname_r, O_RDONLY | O_BINARY, S_IREAD); if (fpr < 0) { return -1; } fpw = myopen(fname_w, O_CREAT | O_TRUNC | O_WRONLY | O_BINARY, S_IREAD | S_IWRITE); if (fpw < 0) { close(fpr); return -1; } while (1) { size = read(fpr, buf, sizeof(buf)); if (size <= 0) { break; } write(fpw, buf, size); } close(fpr); close(fpw); return 0; } //--------------------------------------------------------------------------- //QUOTE,ESCAPE,NULLを保護する wString wString::addSlashes(void) { wString tmp; for (unsigned int i = 0; i < len; i++) { if (String[i] == '\'' || String[i] == '\"' || String[i] == '\\' || String[i] == 0) { tmp += '\\'; } tmp += String[i]; } return tmp; } // ************************************************************************** // URIデコードを行います. // 機能 : URIデコードを行う // 引数 : dst 変換した文字の書き出し先. // dst_len 変換した文字の書き出し先の最大長. // src 変換元の文字. // src_len 変換元の文字の長さ. // 返値 : デコードした文字の数(そのままも含む) // ************************************************************************** unsigned char htoc(unsigned char x) { if ('0' <= x && x <= '9') return (unsigned char)(x - '0'); if ('a' <= x && x <= 'f') return (unsigned char)(x - 'a' + 10); if ('A' <= x && x <= 'F') return (unsigned char)(x - 'A' + 10); return 0; } wString wString::uri_decode() { size_t i; unsigned char code; wString dst; // ================= // メインループ // ================= for (i = 0; i < len && String[i] != '\0'; i++) { if (String[i] == '%') { if (i + 2 >= len) { break; } code = (unsigned char)(htoc(String[++i]) << 4); code += htoc(String[++i]); dst += code; } else if (String[i] == '+') { dst += ' '; } else { dst += String[i]; } } return dst; } #ifdef WEB void wString::headerInit(size_t content_length, int expire, const char* mime_type) { sprintf("%s", HTTP_OK); cat_sprintf("%s", HTTP_CONNECTION); cat_sprintf(HTTP_SERVER_NAME, SERVER_NAME); cat_sprintf(HTTP_CONTENT_TYPE, mime_type); //Date time_t timer; time(&timer); struct tm* utc; utc = gmtime(&timer); char work[80]; char you[7][4] = { "Sun", "Mon","Tue", "Wed", "Thu", "Fri", "Sat" }; char mon[12][4] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" }; ::sprintf(work, "%s, %d %s %d %02d:%02d:%02d", you[utc->tm_wday], utc->tm_mday, mon[utc->tm_mon], utc->tm_year + 1900, utc->tm_hour, utc->tm_min, utc->tm_sec); this->cat_sprintf("Date: %s GMT\r\n", work); //expire if (expire) { timer += 60 * 60; utc = gmtime(&timer); ::sprintf(work, "%s, %d %s %d %02d:%02d:%02d", you[utc->tm_wday], utc->tm_mday, mon[utc->tm_mon], utc->tm_year + 1900, utc->tm_hour, utc->tm_min, utc->tm_sec); this->cat_sprintf("Expires: %s GMT\r\n", work); } if (content_length) { this->cat_sprintf(HTTP_CONTENT_LENGTH, content_length); } } void wString::headerPrint(int socket, int endflag) { send(socket, String, len, 0); if (endflag) { send(socket, HTTP_END, strlen(HTTP_END), 0); } } wString wString::headerPrintMem(void) { return *this + HTTP_END; } int wString::header(const char* str, int flag, int status) { char head[80] = { 0 }; char body[80] = { 0 }; if (*str) { if (!flag) { Add(str); return 0; } //if( strncmp( str, "HTTP/", 5) == 0 ){ // memcpy( head, str,5); // head[5]=0; // strcpy( body, str+5); //}else{ for (size_t i = 0; i < strlen(str); i++) { if (str[i] == ' ') { memcpy(head, str, i + 1); head[i + 1] = 0; strcpy(body, str + i + 1); break; } } //} if (*head && *body) { if (strcmp(head, "Location: ") == 0) { if (status == 301) { header("HTTP/1.0 301 Moved Permanetry", true); } else { header("HTTP/1.0 302 Found", true); } } int count = getLines(); wString str2; str2.sprintf("%s%s", head, body); //あれば入れ替え for (int i = 0; i < count; i++) { wString tmp = GetListString(i); if (strncmp(tmp.c_str(), head, strlen(head)) == 0) { SetListString(str2.c_str(), i); return 0; } } //なければ追加 Add(str2); return 0; } } return 1; } /********************************************************************************/ // 日本語文字コード変換。 // (libnkfのラッパー関数) // // サポートされている形式は以下の通り。 // in_flag: CODE_AUTO, CODE_SJIS, CODE_EUC, CODE_UTF8, CODE_UTF16 // out_flag: CODE_SJIS, CODE_EUC /********************************************************************************/ void wString::convert_language_code(const unsigned char* in, size_t len, int in_flag, int out_flag) { unsigned char nkf_option[8]; unsigned char* out; out = (unsigned char*)(new char[len * 3]); memset(nkf_option, '\0', sizeof(nkf_option)); //===================================================================== // in_flag, out_flagをみて、libnkfへのオプションを組み立てる。 //===================================================================== switch (in_flag) { case CODE_SJIS: strncpy((char*)nkf_option, "S", sizeof(nkf_option)); break; case CODE_EUC: strncpy((char*)nkf_option, "E", sizeof(nkf_option)); break; case CODE_UTF8: strncpy((char*)nkf_option, "W", sizeof(nkf_option)); break; case CODE_UTF16: strncpy((char*)nkf_option, "W16", sizeof(nkf_option)); break; case CODE_AUTO: default: strncpy((char*)nkf_option, "", sizeof(nkf_option)); break; } switch (out_flag) { case CODE_EUC: strncat((char*)nkf_option, "e", sizeof(nkf_option) - strlen((char*)nkf_option)); break; case CODE_SJIS: strncat((char*)nkf_option, "s", sizeof(nkf_option) - strlen((char*)nkf_option)); break; case CODE_UTF8: default: strncat((char*)nkf_option, "w", sizeof(nkf_option) - strlen((char*)nkf_option)); break; } //================================================= // libnkf 実行 //================================================= nkf((const char*)in, (char*)out, len, (const char*)nkf_option); strcpy((char*)in, (char*)out); delete[]out; //memcpy((char*)in,(char*)out,len); return; } /********************************************************************************/ // 日本語文字コード変換。 // (libnkfのラッパー関数) // // サポートされている形式は以下の通り。 // in_flag: CODE_AUTO, CODE_SJIS, CODE_EUC, CODE_UTF8, CODE_UTF16 // out_flag: CODE_SJIS, CODE_EUC /********************************************************************************/ wString wString::nkfcnv(const wString& option) { wString ptr(len * 3); //================================================= // libnkf 実行 //================================================= nkf((const char*)String, (char*)ptr.c_str(), len * 3, (const char*)option.c_str()); ptr.len = strlen(ptr.c_str()); return ptr; } #endif //--------------------------------------------------------------------------- void wString::Add(const char* str) { *this += str; *this += "\r\n"; } //--------------------------------------------------------------------------- void wString::Add(const wString& str) { *this += str; *this += "\r\n"; } //--------------------------------------------------------------------------- // TStringList対策 // 行数を返す //--------------------------------------------------------------------------- int wString::getLines(void) { int count = 0; char* ptr = String; while (*ptr) { if (*ptr == '\r') { ptr++; continue; } if (*ptr++ == '\n') { count++; } } return count; } //---------------- ----------------------------------------------------------- // TStringList対策 // 行数を返す // リエントラントでないことに注意 // 戻り値は使い捨て //---------------- ----------------------------------------------------------- bool wString::SetListString(wString& src, int pos) { bool flag; flag = SetListString(src.String, pos); return flag; } //---------------- ----------------------------------------------------------- // TStringList対策 // pos行目(0start)にdstを挿入 //---------------- ----------------------------------------------------------- bool wString::SetListString(const char* dst, int pos) { //行数が多い std::vector<wString> work; int count = 0; int ptr = 0; int last = 0; int cchar = 0; while (String[ptr]) { switch (String[ptr]) { case '\r': ptr++; cchar++; continue; case '\n': ptr++; cchar++; count++; work.push_back(substr(last, ptr - last - cchar)); cchar = 0; last = ptr; break; default: cchar = 0; ptr++; } } //行末にcrlfがなかった場合に対応 if (ptr - last - cchar) { count++; work.push_back(substr(last, ptr - last - cchar)); } //要素追加 if (0 <= pos && pos <= count) { work[pos] = dst; //元を消す clear(); for (size_t i = 0; i < work.size(); i++) { *this += work[i] + "\r\n"; } return true; } else { //なにもしない return false; } } //--------------------------------------------------------------------------- // TStringList対策 // pos行目の文字列を返す wString wString::GetListString(int pos) { int lcount = 0; int ptr = 0; int curptr = 0; int lstptr; int spcnt = 0;//\r\nまたは\nの文字数 while (String[ptr]) { if (String[ptr] == '\r') { ptr++; spcnt++; continue; } if (String[ptr++] == '\n') { lstptr = curptr; curptr = ptr; spcnt++; if (lcount++ == pos) { return substr(lstptr, curptr - lstptr - spcnt); } } spcnt = 0; } return wString(); } #if 0 //--------------------------------------------------------------------------- //HTTPより文字列データを取得 //引数 // char* src :URL // off_t offset :読み込みオフセット //戻り値 // wString& :読み込んだ文字列。失敗したときは長さ0 //--------------------------------------------------------------------------- wString wString::HTTPGet(const char* url, off_t offset) { int recv_len; //読み取り長さ wString buf; wString ptr; wString host; //ホスト名 wString target; //ファイル名 int work1; int work2; int work3; SOCKET server_socket; //サーバーソケット int server_port = HTTP_SERVER_PORT; //出力ファイルの設定 // ================ // 実体転送開始 // ================ //buf = (char*)malloc(HTTP_BUF_SIZE); //ptr = buf; //準備 //アドレスから、ホスト名とターゲットを取得 ptr.SetLength(HTTP_STR_BUF_SIZE + 1); buf = url; //ptr = 0; work1 = buf.Pos("://") + 3; work2 = buf.Pos("/", work1); work3 = buf.Pos(":", work1); target = buf.SubString(work2, buf.len - work2); if (work3 >= 0) { host = buf.SubString(work1, work3 - work1); server_port = atoi(buf.c_str() + work3 + 1); } else { host = buf.SubString(work1, work2 - work1); } //ソケット作成と接続 server_socket = sock_connect(host.String, server_port); if (!SERROR(server_socket)) { //HTTP1.0 GET発行 ptr.sprintf("GET %s HTTP/1.0\r\n" "Accept: */*\r\n" "User-Agent: %s%s\r\nHost: %s\r\nRange: bytes=%llu-\r\nConnection: close\r\n\r\n", target.String, //"Mozilla/4.0 (compatible; MSIE 5.5; Windows 98)", USERAGENT, MACADDR, host.String, offset); //ptr.len = strlen(ptr.String); //サーバに繋がった if (send(server_socket, ptr.String, ptr.len, 0) != SOCKET_ERROR) { //初回分からヘッダを削除 recv_len = recv(server_socket, ptr.String, ptr.Total() - 1, 0); ptr.String[recv_len] = 0; ptr.len = recv_len; //見つからない work1 = atoi(ptr.String + (ptr.Pos(" ") + 1)); if (work1 < 200 || 300 <= work1) { sClose(server_socket); return wString(); } //content_length = atoi(buf.String+buf.Pos("Content-Length:" )+16); //\r\n\r\nを探す work1 = ptr.Pos(HTTP_DELIMITER) + 4;//sizeof( HTTP_DELIMITER );//実体の先頭 recv_len -= work1; buf = ptr.SubString(work1, recv_len); //転送する while (loop_flag) { recv_len = recv(server_socket, ptr.String, ptr.Total() - 1, 0); if (recv_len <= 0) { break; } //エラーにならない。 ptr.len = recv_len; ptr.String[recv_len] = 0; buf += ptr; } } else { sClose(server_socket); return wString(); } sClose(server_socket); } else { return wString(); } wString tmp(buf); //終了 return tmp; } //--------------------------------------------------------------------------- /* ソケットを作成し、相手に接続するラッパ. 失敗 = -1 */ //static int sock_connect(char *host, int port) //--------------------------------------------------------------------------- SOCKET wString::sock_connect(const wString& host, const int port) { return sock_connect(host.String, port); } //--------------------------------------------------------------------------- SOCKET wString::sock_connect(const char* host, const int port) { // int sock; SOCKET sock; struct sockaddr_in sockadd = { 0 }; //SOCKET構造体 struct hostent* hent; debug_log_output("sock_connect: %s:%d", host, port); //SOCKET作成 if (SERROR(sock = socket(PF_INET, SOCK_STREAM, 0))) { debug_log_output("sock_connect_error:"); return INVALID_SOCKET; } //debug_log_output("sock: %d", sock); if (NULL == (hent = gethostbyname(host))) { sClose(sock); return INVALID_SOCKET; } debug_log_output("hent: %p", hent); //ソケット構造体へアドレス設定 memcpy(&sockadd.sin_addr, hent->h_addr, hent->h_length); //ソケット構造体へポート設定 sockadd.sin_port = htons((u_short)port); //IPV4アドレスファミリを設定 sockadd.sin_family = AF_INET; //接続 if (SERROR(connect(sock, (struct sockaddr*) & sockadd, sizeof(sockadd)))) { sClose(sock); return INVALID_SOCKET; } return sock; } //--------------------------------------------------------------------------- // 2004/11/17 Add start // アクセス可能かチェックする //形式はwww.make-it.co.jp/index.html //2005/12/03 引数を壊していたので修正 bool wString::checkUrl(const wString& url) { wString buf; int recv_len; bool access_flag = false; wString host_name; wString file_path; int ptr; //前処理 ptr = url.Pos("/"); // はじめに出てきた"/"の前後で分断 host_name = url.SubString(0, ptr); file_path = url.SubString(ptr, url.Length() - ptr); //見つからなかった時 if (file_path.Length() == 0) { file_path = "/"; } SOCKET server_socket = sock_connect(host_name.c_str(), HTTP_SERVER_PORT);//( PF_INET , SOCK_STREAM , 0 ); if (!SERROR(server_socket)) { buf.sprintf("HEAD %s HTTP/1.0\r\n" "User%cAgent: " USERAGENT "\r\n" "Host: %s\r\n" "Connection: close\r\n" "\r\n", file_path.c_str(), '-', host_name.c_str() ); int dd = send(server_socket, buf.c_str(), buf.Length(), 0); if (dd != SOCKET_ERROR) { buf.SetLength(1024); recv_len = recv(server_socket, buf.c_str(), buf.Total() - 1, 0); buf.ResetLength(recv_len); //見つからない ptr = atoi(buf.String + (buf.Pos(" ") + 1)); // 受信データありならば(ファイル有り)、データを解析する。 if (200 <= ptr && ptr < 300) { access_flag = true; } } sClose(server_socket); } return access_flag; } //--------------------------------------------------------------------------- //目標のサイズ取得 int wString::HTTPSize(const wString& url) { int recv_len; //読み取り長さ wString buf; int work1; int work2; int work3; wString host; wString target; int content_length = -1; SOCKET server_socket; //サーバーソケット int server_port = HTTP_SERVER_PORT; //出力ファイルの設定 // ================ // 実体転送開始 // ================ //準備 //アドレスから、ホスト名とターゲットを取得 work2 = url.Pos("://") + 3; work1 = url.Pos("/", work2); work3 = url.Pos(":", work1); target = url.SubString(work1, url.Length() - work1); if (work3 >= 0) { host = url.SubString(work2, work3 - work2); server_port = atoi(url.c_str() + work3 + 1); } else { host = url.SubString(work2, work1 - work2); } //strcpy( target, work1); //*work1 = 0; //strcpy( host, work2 ); //ソケット作成と接続 server_socket = sock_connect(host.c_str(), server_port); if (!SERROR(server_socket)) { //HTTP1.0 GET発行 buf.sprintf("HEAD %s HTTP/1.0\r\n" "Accept: */*\r\n" "User-Agent: %s%s\r\n" "Host: %s\r\n" // "%s", "Connection: close\r\n\r\n", target.uri_encode().c_str(), //"Mozilla/4.0 (compatible; MSIE 5.5; Windows 98)", USERAGENT, MACADDR, host.c_str() // GetAuthorization(void), ); //サーバに繋がった if (send(server_socket, buf.c_str(), buf.Length(), 0) != SOCKET_ERROR) { //初回分からヘッダを削除 buf.SetLength(HTTP_STR_BUF_SIZE); recv_len = recv(server_socket, buf.c_str(), buf.Total() - 1, 0); //\r\n\r\nを探す buf.ResetLength(recv_len); //糸止め work1 = atoi(buf.String + (buf.Pos(" ") + 1)); int pos = buf.Pos("Content-Length:"); if (pos >= 0) { if (200 <= work1 && work1 < 300) { //コンテンツ長さ TODO Content-Lengthがない場合 content_length = atoi(buf.c_str() + pos + 16); } } else if (work1 == 302) { //Location:----\r\n work1 = buf.Pos("Location:"); if (work1) { int num = buf.Pos("\r\n", work1) - work1 - 10; buf = buf.SubString(work1 + 10, num); content_length = HTTPSize(buf); } } } sClose(server_socket); } //終了 return content_length; } #endif //--------------------------------------------------------------------------- // linux用ファイル名に変換 //--------------------------------------------------------------------------- char* wString::WindowsFileName(char* FileName) { #ifdef linux return FileName; #else char* work = FileName; int ptr = 0; while (work[ptr]) { if (work[ptr] == '/') { work[ptr] = '\\'; } ptr++; } return work; #endif } //--------------------------------------------------------------------------- // Linux用ファイル名に変換 //--------------------------------------------------------------------------- char* wString::LinuxFileName(char* FileName) { #ifdef linux return FileName; #else char* work = FileName; int ptr = 0; while (work[ptr]) { if (work[ptr] == '\\') { work[ptr] = '/'; } ptr++; } return work; #endif } #if 0 //--------------------------------------------------------------------------- // Linux用ファイル名に変換 //--------------------------------------------------------------------------- char* wString::GetLocalAddress(void) { #ifdef linux //TODO linux番の自IP/ホスト名を設定すること return (char*)"neon.cx"; #else //ホスト名を取得する char hostname[256]; if (gethostname(hostname, sizeof(hostname)) != 0) { return 0; } //puts(hostname); //ホスト名からIPアドレスを取得する HOSTENT* hostend = gethostbyname(hostname); if (hostend == NULL) { return 0; } IN_ADDR inaddr; memcpy(&inaddr, hostend->h_addr_list[0], 4); static char ip[256]; strcpy(ip, inet_ntoa(inaddr)); return ip; #endif } #endif //--------------------------------------------------------------------------- size_t wString::copy(char* str, size_t slen, size_t index) const { strncpy(str, String + index, slen); str[slen] = 0; return slen; } wString& wString::replace(size_t index, size_t slen, const wString& repstr) { size_t rlen = repstr.len; //同じ if (slen == rlen) { memcpy((void*)(String + index), (void*)repstr.String, rlen); //前詰め置換そのままコピーすればいい } else if (slen > rlen) { size_t num = slen - rlen; char* p = String + index; char* q = p + num; while (*q) { *p++ = *q++; } memcpy((void*)(String + index), (void*)(repstr.String), rlen); len -= num; String[len] = 0; //置換文字が長いので後詰めする } else { size_t num = rlen - slen; myrealloc(len + num + 1); for (char* p = (char*)(String + len + num); p > String + index + num; p--) { *p = *(p - num); } memcpy((void*)(String + index), (void*)(repstr.String), rlen); len += num; String[len] = 0; } return *this; }
e3db69667fe4944e7ff5fb01f114abad0b53c5af
35f877b04c9ab7aa183ba7a8c141e0078239bac4
/scalopus_interface/include_consumer/scalopus_interface/trace_event_provider.h
c81ca0cea53af0cdc7dcb8418af6b2361d8512a2
[ "JSON", "BSD-3-Clause", "MIT", "BSD-2-Clause" ]
permissive
iwanders/scalopus
dcbe7269cf4c2609bc2bed76ba4939dd92f77e1a
df247bdbbb30db8d83691f01035bf363ab00b62c
refs/heads/master
2022-11-15T19:54:57.704011
2022-11-08T14:35:44
2022-11-08T14:41:39
166,896,226
64
7
BSD-3-Clause
2022-11-08T14:41:40
2019-01-21T23:46:26
C++
UTF-8
C++
false
false
2,217
h
/* Copyright (c) 2018-2019, Ivor Wanders 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 the author nor the names of contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef SCALOPUS_INTERFACE_TRACE_EVENT_PROVIDER_H #define SCALOPUS_INTERFACE_TRACE_EVENT_PROVIDER_H #include "scalopus_interface/trace_event_source.h" namespace scalopus { /** * @brief This is the abstract base class for a data provider that's used in the catapult backend. * It can create Trace Event Sources that are used by a session. */ class TraceEventProvider { public: using Ptr = std::shared_ptr<TraceEventProvider>; /** * @brief Create a trace event source from this provider. */ virtual TraceEventSource::Ptr makeSource() = 0; virtual ~TraceEventProvider() = default; }; } // namespace scalopus #endif // SCALOPUS_INTERFACE_TRACE_EVENT_PROVIDER_H
c6ee048bc7d62951ae2f2df7739608d21f16d0d7
3e804af6c775a446f8e7560a00d7394c28c1f266
/src/xgui/debuga/dbg_brkpoints.h
7e9536ec8b607b8fe9f5d298f69fa90f12d8b8b4
[ "MIT" ]
permissive
nihirash/Xpeccy
1c64cb791a309ee801c4f9249f8ed1f9a2369374
a739428d82205a9e22cf0c0a8d982817bb441e44
refs/heads/master
2022-11-12T12:58:34.769923
2020-06-21T17:09:53
2020-06-21T17:09:53
269,768,412
1
1
NOASSERTION
2020-06-07T12:23:45
2020-06-05T20:29:56
C
UTF-8
C++
false
false
1,346
h
#ifndef X_DBG_BREAKS_H #define X_DBG_BREAKS_H #include <QAbstractTableModel> #include <QModelIndex> #include <QMouseEvent> #include <QTableView> #include <QKeyEvent> #include <QVariant> #include <QDialog> #include "xgui/xgui.h" #include "ui_brkmanager.h" #include "xcore/xcore.h" class xBreakListModel : public QAbstractTableModel { Q_OBJECT public: xBreakListModel(QObject* = NULL); void update(); void updateCell(int, int); private: int rowCount(const QModelIndex& = QModelIndex()) const; int columnCount(const QModelIndex& = QModelIndex()) const; QVariant data(const QModelIndex&, int) const; QVariant headerData(int, Qt::Orientation, int = Qt::DisplayRole) const; void sort(int, Qt::SortOrder); }; class xBreakTable : public QTableView { Q_OBJECT public: xBreakTable(QWidget* = NULL); public slots: void update(); signals: void rqDisasm(); void rqDasmDump(); private: xBreakListModel* model; private slots: void onCellClick(QModelIndex); void onDoubleClick(QModelIndex); protected: void keyPressEvent(QKeyEvent*); }; class xBrkManager : public QDialog { Q_OBJECT public: xBrkManager(QWidget* = NULL); void edit(xBrkPoint*); private: Ui::BrkManager ui; xBrkPoint obrk; private slots: void confirm(); void chaType(int); signals: void completed(xBrkPoint, xBrkPoint); }; #endif
9c372be7a25d5b47766a0ec5fc13adb363fe98f8
26df6604faf41197c9ced34c3df13839be6e74d4
/src/org/apache/poi/sl/usermodel/TextParagraph.hpp
5d61be4806b01fd30378d62dfad32f61009746cd
[ "Apache-2.0" ]
permissive
pebble2015/cpoi
58b4b1e38a7769b13ccfb2973270d15d490de07f
6dcc0c5e13e3e722b4ef9fd0baffbf62bf71ead6
refs/heads/master
2021-07-09T09:02:41.986901
2017-10-08T12:12:56
2017-10-08T12:12:56
105,988,119
0
0
null
null
null
null
UTF-8
C++
false
false
1,895
hpp
// Generated from /POI/java/org/apache/poi/sl/usermodel/TextParagraph.java #pragma once #include <fwd-POI.hpp> #include <java/lang/fwd-POI.hpp> #include <java/util/fwd-POI.hpp> #include <org/apache/poi/sl/usermodel/fwd-POI.hpp> #include <java/lang/Iterable.hpp> struct poi::sl::usermodel::TextParagraph : public virtual ::java::lang::Iterable { virtual ::java::lang::Double* getSpaceBefore() = 0; virtual void setSpaceBefore(::java::lang::Double* spaceBefore) = 0; virtual ::java::lang::Double* getSpaceAfter() = 0; virtual void setSpaceAfter(::java::lang::Double* spaceAfter) = 0; virtual ::java::lang::Double* getLeftMargin() = 0; virtual void setLeftMargin(::java::lang::Double* leftMargin) = 0; virtual ::java::lang::Double* getRightMargin() = 0; virtual void setRightMargin(::java::lang::Double* rightMargin) = 0; virtual ::java::lang::Double* getIndent() = 0; virtual void setIndent(::java::lang::Double* indent) = 0; virtual int32_t getIndentLevel() = 0; virtual void setIndentLevel(int32_t level) = 0; virtual ::java::lang::Double* getLineSpacing() = 0; virtual void setLineSpacing(::java::lang::Double* lineSpacing) = 0; virtual ::java::lang::String* getDefaultFontFamily() = 0; virtual ::java::lang::Double* getDefaultFontSize() = 0; virtual TextParagraph_TextAlign* getTextAlign() = 0; virtual void setTextAlign(TextParagraph_TextAlign* align) = 0; virtual TextParagraph_FontAlign* getFontAlign() = 0; virtual TextParagraph_BulletStyle* getBulletStyle() = 0; virtual void setBulletStyle(::java::lang::ObjectArray*/*...*/ styles) = 0; virtual ::java::lang::Double* getDefaultTabSize() = 0; virtual TextShape* getParentShape() = 0; virtual ::java::util::List* getTextRuns() = 0; virtual bool isHeaderOrFooter() = 0; // Generated static ::java::lang::Class *class_(); };
383588585039d3bbc45d4cad1ff1f4cfb745948a
5a86421f61da5c7faf7443defb06423f18565332
/searchcore/src/vespa/searchcore/proton/server/ireplaypackethandler.h
01307750606fe1ead1db5c041503cf70155a7785
[ "LicenseRef-scancode-unknown-license-reference", "Apache-2.0" ]
permissive
t1707/vespa
1d62116f4345dbc5020dbfcab1fc2934e82e5d68
9f4859e9996ac9913ce80ed9b209f683507fe157
refs/heads/master
2021-04-03T06:24:10.556834
2018-03-08T17:02:09
2018-03-08T17:02:09
124,473,863
0
0
Apache-2.0
2018-03-15T06:06:27
2018-03-09T02:07:53
Java
UTF-8
C++
false
false
1,484
h
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #pragma once #include <vespa/searchcore/proton/feedoperation/operations.h> namespace proton { /** * Interface used to handle the various feed operations during * replay of the transaction log. */ struct IReplayPacketHandler { virtual ~IReplayPacketHandler() {} virtual void replay(const PutOperation &op) = 0; virtual void replay(const RemoveOperation &op) = 0; virtual void replay(const UpdateOperation &op) = 0; virtual void replay(const NoopOperation &op) = 0; virtual void replay(const NewConfigOperation &op) = 0; virtual void replay(const WipeHistoryOperation &op) = 0; virtual void replay(const DeleteBucketOperation &op) = 0; virtual void replay(const SplitBucketOperation &op) = 0; virtual void replay(const JoinBucketsOperation &op) = 0; virtual void replay(const PruneRemovedDocumentsOperation &op) = 0; virtual void replay(const SpoolerReplayStartOperation &op) = 0; virtual void replay(const SpoolerReplayCompleteOperation &op) = 0; virtual void replay(const MoveOperation &op) = 0; virtual void replay(const CreateBucketOperation &op) = 0; virtual void replay(const CompactLidSpaceOperation &op) = 0; virtual NewConfigOperation::IStreamHandler &getNewConfigStreamHandler() = 0; virtual document::DocumentTypeRepo &getDeserializeRepo() = 0; }; } // namespace proton
9608c229616ea1d7136235485f8aa84b9d247893
713cd2bdf8a8110efb438109128306648dc8fea7
/src/rpcdump.cpp
9a1c4c74e495843f3c585b0091f25c2cc886546f
[ "MIT" ]
permissive
resqs/RESQ-Chain
e4769fc994368a26f068e12260787c7dd029e0e0
ff7f001265fb6153f006d795286f5e6fb1f02f47
refs/heads/master
2021-01-04T11:42:00.972957
2019-03-19T10:14:33
2019-03-19T10:14:33
null
0
0
null
null
null
null
UTF-8
C++
false
false
20,054
cpp
// Copyright (c) 2009-2014 The Bitcoin developers // Copyright (c) 2014-2015 The Dash developers // Copyright (c) 2015-2018 The PIVX developers // Copyright (c) 2019 The RESQ developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #include "bip38.h" #include "init.h" #include "main.h" #include "rpc/server.h" #include "script/script.h" #include "script/standard.h" #include "sync.h" #include "util.h" #include "utilstrencodings.h" #include "utiltime.h" #include "wallet.h" #include <fstream> #include <secp256k1.h> #include <stdint.h> #include <boost/algorithm/string.hpp> #include <boost/date_time/posix_time/posix_time.hpp> #include <openssl/aes.h> #include <openssl/sha.h> #include <univalue.h> using namespace std; void EnsureWalletIsUnlocked(bool fAllowAnonOnly); std::string static EncodeDumpTime(int64_t nTime) { return DateTimeStrFormat("%Y-%m-%dT%H:%M:%SZ", nTime); } int64_t static DecodeDumpTime(const std::string& str) { static const boost::posix_time::ptime epoch = boost::posix_time::from_time_t(0); static const std::locale loc(std::locale::classic(), new boost::posix_time::time_input_facet("%Y-%m-%dT%H:%M:%SZ")); std::istringstream iss(str); iss.imbue(loc); boost::posix_time::ptime ptime(boost::date_time::not_a_date_time); iss >> ptime; if (ptime.is_not_a_date_time()) return 0; return (ptime - epoch).total_seconds(); } std::string static EncodeDumpString(const std::string& str) { std::stringstream ret; BOOST_FOREACH (unsigned char c, str) { if (c <= 32 || c >= 128 || c == '%') { ret << '%' << HexStr(&c, &c + 1); } else { ret << c; } } return ret.str(); } std::string DecodeDumpString(const std::string& str) { std::stringstream ret; for (unsigned int pos = 0; pos < str.length(); pos++) { unsigned char c = str[pos]; if (c == '%' && pos + 2 < str.length()) { c = (((str[pos + 1] >> 6) * 9 + ((str[pos + 1] - '0') & 15)) << 4) | ((str[pos + 2] >> 6) * 9 + ((str[pos + 2] - '0') & 15)); pos += 2; } ret << c; } return ret.str(); } UniValue importprivkey(const UniValue& params, bool fHelp) { if (fHelp || params.size() < 1 || params.size() > 3) throw runtime_error( "importprivkey \"resqprivkey\" ( \"label\" rescan )\n" "\nAdds a private key (as returned by dumpprivkey) to your wallet.\n" + HelpRequiringPassphrase() + "\n" "\nArguments:\n" "1. \"resqprivkey\" (string, required) The private key (see dumpprivkey)\n" "2. \"label\" (string, optional, default=\"\") An optional label\n" "3. rescan (boolean, optional, default=true) Rescan the wallet for transactions\n" "\nNote: This call can take minutes to complete if rescan is true.\n" "\nExamples:\n" "\nDump a private key\n" + HelpExampleCli("dumpprivkey", "\"myaddress\"") + "\nImport the private key with rescan\n" + HelpExampleCli("importprivkey", "\"mykey\"") + "\nImport using a label and without rescan\n" + HelpExampleCli("importprivkey", "\"mykey\" \"testing\" false") + "\nAs a JSON-RPC call\n" + HelpExampleRpc("importprivkey", "\"mykey\", \"testing\", false")); LOCK2(cs_main, pwalletMain->cs_wallet); EnsureWalletIsUnlocked(); string strSecret = params[0].get_str(); string strLabel = ""; if (params.size() > 1) strLabel = params[1].get_str(); // Whether to perform rescan after import bool fRescan = true; if (params.size() > 2) fRescan = params[2].get_bool(); CBitcoinSecret vchSecret; bool fGood = vchSecret.SetString(strSecret); if (!fGood) throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid private key encoding"); CKey key = vchSecret.GetKey(); if (!key.IsValid()) throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Private key outside allowed range"); CPubKey pubkey = key.GetPubKey(); assert(key.VerifyPubKey(pubkey)); CKeyID vchAddress = pubkey.GetID(); { pwalletMain->MarkDirty(); pwalletMain->SetAddressBook(vchAddress, strLabel, "receive"); // Don't throw error in case a key is already there if (pwalletMain->HaveKey(vchAddress)) return NullUniValue; pwalletMain->mapKeyMetadata[vchAddress].nCreateTime = 1; if (!pwalletMain->AddKeyPubKey(key, pubkey)) throw JSONRPCError(RPC_WALLET_ERROR, "Error adding key to wallet"); // whenever a key is imported, we need to scan the whole chain pwalletMain->nTimeFirstKey = 1; // 0 would be considered 'no value' if (fRescan) { pwalletMain->ScanForWalletTransactions(chainActive.Genesis(), true); } } return NullUniValue; } UniValue importaddress(const UniValue& params, bool fHelp) { if (fHelp || params.size() < 1 || params.size() > 3) throw runtime_error( "importaddress \"address\" ( \"label\" rescan )\n" "\nAdds an address or script (in hex) that can be watched as if it were in your wallet but cannot be used to spend.\n" "\nArguments:\n" "1. \"address\" (string, required) The address\n" "2. \"label\" (string, optional, default=\"\") An optional label\n" "3. rescan (boolean, optional, default=true) Rescan the wallet for transactions\n" "\nNote: This call can take minutes to complete if rescan is true.\n" "\nExamples:\n" "\nImport an address with rescan\n" + HelpExampleCli("importaddress", "\"myaddress\"") + "\nImport using a label without rescan\n" + HelpExampleCli("importaddress", "\"myaddress\" \"testing\" false") + "\nAs a JSON-RPC call\n" + HelpExampleRpc("importaddress", "\"myaddress\", \"testing\", false")); LOCK2(cs_main, pwalletMain->cs_wallet); CScript script; CBitcoinAddress address(params[0].get_str()); if (address.IsValid()) { script = GetScriptForDestination(address.Get()); } else if (IsHex(params[0].get_str())) { std::vector<unsigned char> data(ParseHex(params[0].get_str())); script = CScript(data.begin(), data.end()); } else { throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid RESQ address or script"); } string strLabel = ""; if (params.size() > 1) strLabel = params[1].get_str(); // Whether to perform rescan after import bool fRescan = true; if (params.size() > 2) fRescan = params[2].get_bool(); { if (::IsMine(*pwalletMain, script) == ISMINE_SPENDABLE) throw JSONRPCError(RPC_WALLET_ERROR, "The wallet already contains the private key for this address or script"); // add to address book or update label if (address.IsValid()) pwalletMain->SetAddressBook(address.Get(), strLabel, "receive"); // Don't throw error in case an address is already there if (pwalletMain->HaveWatchOnly(script)) return NullUniValue; pwalletMain->MarkDirty(); if (!pwalletMain->AddWatchOnly(script)) throw JSONRPCError(RPC_WALLET_ERROR, "Error adding address to wallet"); if (fRescan) { pwalletMain->ScanForWalletTransactions(chainActive.Genesis(), true); pwalletMain->ReacceptWalletTransactions(); } } return NullUniValue; } UniValue importwallet(const UniValue& params, bool fHelp) { if (fHelp || params.size() != 1) throw runtime_error( "importwallet \"filename\"\n" "\nImports keys from a wallet dump file (see dumpwallet).\n" + HelpRequiringPassphrase() + "\n" "\nArguments:\n" "1. \"filename\" (string, required) The wallet file\n" "\nExamples:\n" "\nDump the wallet\n" + HelpExampleCli("dumpwallet", "\"test\"") + "\nImport the wallet\n" + HelpExampleCli("importwallet", "\"test\"") + "\nImport using the json rpc call\n" + HelpExampleRpc("importwallet", "\"test\"")); LOCK2(cs_main, pwalletMain->cs_wallet); EnsureWalletIsUnlocked(); ifstream file; file.open(params[0].get_str().c_str(), std::ios::in | std::ios::ate); if (!file.is_open()) throw JSONRPCError(RPC_INVALID_PARAMETER, "Cannot open wallet dump file"); int64_t nTimeBegin = chainActive.Tip()->GetBlockTime(); bool fGood = true; int64_t nFilesize = std::max((int64_t)1, (int64_t)file.tellg()); file.seekg(0, file.beg); pwalletMain->ShowProgress(_("Importing..."), 0); // show progress dialog in GUI while (file.good()) { pwalletMain->ShowProgress("", std::max(1, std::min(99, (int)(((double)file.tellg() / (double)nFilesize) * 100)))); std::string line; std::getline(file, line); if (line.empty() || line[0] == '#') continue; std::vector<std::string> vstr; boost::split(vstr, line, boost::is_any_of(" ")); if (vstr.size() < 2) continue; CBitcoinSecret vchSecret; if (!vchSecret.SetString(vstr[0])) continue; CKey key = vchSecret.GetKey(); CPubKey pubkey = key.GetPubKey(); assert(key.VerifyPubKey(pubkey)); CKeyID keyid = pubkey.GetID(); if (pwalletMain->HaveKey(keyid)) { LogPrintf("Skipping import of %s (key already present)\n", CBitcoinAddress(keyid).ToString()); continue; } int64_t nTime = DecodeDumpTime(vstr[1]); std::string strLabel; bool fLabel = true; for (unsigned int nStr = 2; nStr < vstr.size(); nStr++) { if (boost::algorithm::starts_with(vstr[nStr], "#")) break; if (vstr[nStr] == "change=1") fLabel = false; if (vstr[nStr] == "reserve=1") fLabel = false; if (boost::algorithm::starts_with(vstr[nStr], "label=")) { strLabel = DecodeDumpString(vstr[nStr].substr(6)); fLabel = true; } } LogPrintf("Importing %s...\n", CBitcoinAddress(keyid).ToString()); if (!pwalletMain->AddKeyPubKey(key, pubkey)) { fGood = false; continue; } pwalletMain->mapKeyMetadata[keyid].nCreateTime = nTime; if (fLabel) pwalletMain->SetAddressBook(keyid, strLabel, "receive"); nTimeBegin = std::min(nTimeBegin, nTime); } file.close(); pwalletMain->ShowProgress("", 100); // hide progress dialog in GUI CBlockIndex* pindex = chainActive.Tip(); while (pindex && pindex->pprev && pindex->GetBlockTime() > nTimeBegin - 7200) pindex = pindex->pprev; if (!pwalletMain->nTimeFirstKey || nTimeBegin < pwalletMain->nTimeFirstKey) pwalletMain->nTimeFirstKey = nTimeBegin; LogPrintf("Rescanning last %i blocks\n", chainActive.Height() - pindex->nHeight + 1); pwalletMain->ScanForWalletTransactions(pindex); pwalletMain->MarkDirty(); if (!fGood) throw JSONRPCError(RPC_WALLET_ERROR, "Error adding some keys to wallet"); return NullUniValue; } UniValue dumpprivkey(const UniValue& params, bool fHelp) { if (fHelp || params.size() != 1) throw runtime_error( "dumpprivkey \"resqaddress\"\n" "\nReveals the private key corresponding to 'resqaddress'.\n" "Then the importprivkey can be used with this output\n" + HelpRequiringPassphrase() + "\n" "\nArguments:\n" "1. \"resqaddress\" (string, required) The resq address for the private key\n" "\nResult:\n" "\"key\" (string) The private key\n" "\nExamples:\n" + HelpExampleCli("dumpprivkey", "\"myaddress\"") + HelpExampleCli("importprivkey", "\"mykey\"") + HelpExampleRpc("dumpprivkey", "\"myaddress\"")); LOCK2(cs_main, pwalletMain->cs_wallet); EnsureWalletIsUnlocked(); string strAddress = params[0].get_str(); CBitcoinAddress address; if (!address.SetString(strAddress)) throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid RESQ address"); CKeyID keyID; if (!address.GetKeyID(keyID)) throw JSONRPCError(RPC_TYPE_ERROR, "Address does not refer to a key"); CKey vchSecret; if (!pwalletMain->GetKey(keyID, vchSecret)) throw JSONRPCError(RPC_WALLET_ERROR, "Private key for address " + strAddress + " is not known"); return CBitcoinSecret(vchSecret).ToString(); } UniValue dumpwallet(const UniValue& params, bool fHelp) { if (fHelp || params.size() != 1) throw runtime_error( "dumpwallet \"filename\"\n" "\nDumps all wallet keys in a human-readable format.\n" + HelpRequiringPassphrase() + "\n" "\nArguments:\n" "1. \"filename\" (string, required) The filename\n" "\nExamples:\n" + HelpExampleCli("dumpwallet", "\"test\"") + HelpExampleRpc("dumpwallet", "\"test\"")); LOCK2(cs_main, pwalletMain->cs_wallet); EnsureWalletIsUnlocked(); ofstream file; file.open(params[0].get_str().c_str()); if (!file.is_open()) throw JSONRPCError(RPC_INVALID_PARAMETER, "Cannot open wallet dump file"); std::map<CKeyID, int64_t> mapKeyBirth; std::set<CKeyID> setKeyPool; pwalletMain->GetKeyBirthTimes(mapKeyBirth); pwalletMain->GetAllReserveKeys(setKeyPool); // sort time/key pairs std::vector<std::pair<int64_t, CKeyID> > vKeyBirth; for (std::map<CKeyID, int64_t>::const_iterator it = mapKeyBirth.begin(); it != mapKeyBirth.end(); it++) { vKeyBirth.push_back(std::make_pair(it->second, it->first)); } mapKeyBirth.clear(); std::sort(vKeyBirth.begin(), vKeyBirth.end()); // produce output file << strprintf("# Wallet dump created by RESQ %s (%s)\n", CLIENT_BUILD, CLIENT_DATE); file << strprintf("# * Created on %s\n", EncodeDumpTime(GetTime())); file << strprintf("# * Best block at time of backup was %i (%s),\n", chainActive.Height(), chainActive.Tip()->GetBlockHash().ToString()); file << strprintf("# mined on %s\n", EncodeDumpTime(chainActive.Tip()->GetBlockTime())); file << "\n"; for (std::vector<std::pair<int64_t, CKeyID> >::const_iterator it = vKeyBirth.begin(); it != vKeyBirth.end(); it++) { const CKeyID& keyid = it->second; std::string strTime = EncodeDumpTime(it->first); std::string strAddr = CBitcoinAddress(keyid).ToString(); CKey key; if (pwalletMain->GetKey(keyid, key)) { if (pwalletMain->mapAddressBook.count(keyid)) { file << strprintf("%s %s label=%s # addr=%s\n", CBitcoinSecret(key).ToString(), strTime, EncodeDumpString(pwalletMain->mapAddressBook[keyid].name), strAddr); } else if (setKeyPool.count(keyid)) { file << strprintf("%s %s reserve=1 # addr=%s\n", CBitcoinSecret(key).ToString(), strTime, strAddr); } else { file << strprintf("%s %s change=1 # addr=%s\n", CBitcoinSecret(key).ToString(), strTime, strAddr); } } } file << "\n"; file << "# End of dump\n"; file.close(); return NullUniValue; } UniValue bip38encrypt(const UniValue& params, bool fHelp) { if (fHelp || params.size() != 2) throw runtime_error( "bip38encrypt \"resqaddress\" \"passphrase\"\n" "\nEncrypts a private key corresponding to 'resqaddress'.\n" + HelpRequiringPassphrase() + "\n" "\nArguments:\n" "1. \"resqaddress\" (string, required) The resq address for the private key (you must hold the key already)\n" "2. \"passphrase\" (string, required) The passphrase you want the private key to be encrypted with - Valid special chars: !#$%&'()*+,-./:;<=>?`{|}~ \n" "\nResult:\n" "\"key\" (string) The encrypted private key\n" "\nExamples:\n" + HelpExampleCli("bip38encrypt", "\"DMJRSsuU9zfyrvxVaAEFQqK4MxZg6vgeS6\" \"mypasphrase\"") + HelpExampleRpc("bip38encrypt", "\"DMJRSsuU9zfyrvxVaAEFQqK4MxZg6vgeS6\" \"mypasphrase\"")); LOCK2(cs_main, pwalletMain->cs_wallet); EnsureWalletIsUnlocked(); string strAddress = params[0].get_str(); string strPassphrase = params[1].get_str(); CBitcoinAddress address; if (!address.SetString(strAddress)) throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid RESQ address"); CKeyID keyID; if (!address.GetKeyID(keyID)) throw JSONRPCError(RPC_TYPE_ERROR, "Address does not refer to a key"); CKey vchSecret; if (!pwalletMain->GetKey(keyID, vchSecret)) throw JSONRPCError(RPC_WALLET_ERROR, "Private key for address " + strAddress + " is not known"); uint256 privKey = vchSecret.GetPrivKey_256(); string encryptedOut = BIP38_Encrypt(strAddress, strPassphrase, privKey, vchSecret.IsCompressed()); UniValue result(UniValue::VOBJ); result.push_back(Pair("Addess", strAddress)); result.push_back(Pair("Encrypted Key", encryptedOut)); return result; } UniValue bip38decrypt(const UniValue& params, bool fHelp) { if (fHelp || params.size() != 2) throw runtime_error( "bip38decrypt \"resqaddress\" \"passphrase\"\n" "\nDecrypts and then imports password protected private key.\n" + HelpRequiringPassphrase() + "\n" "\nArguments:\n" "1. \"encryptedkey\" (string, required) The encrypted private key\n" "2. \"passphrase\" (string, required) The passphrase you want the private key to be encrypted with\n" "\nResult:\n" "\"key\" (string) The decrypted private key\n" "\nExamples:\n" + HelpExampleCli("bip38decrypt", "\"encryptedkey\" \"mypassphrase\"") + HelpExampleRpc("bip38decrypt", "\"encryptedkey\" \"mypassphrase\"")); LOCK2(cs_main, pwalletMain->cs_wallet); EnsureWalletIsUnlocked(); /** Collect private key and passphrase **/ string strKey = params[0].get_str(); string strPassphrase = params[1].get_str(); uint256 privKey; bool fCompressed; if (!BIP38_Decrypt(strPassphrase, strKey, privKey, fCompressed)) throw JSONRPCError(RPC_WALLET_ERROR, "Failed To Decrypt"); UniValue result(UniValue::VOBJ); result.push_back(Pair("privatekey", HexStr(privKey))); CKey key; key.Set(privKey.begin(), privKey.end(), fCompressed); if (!key.IsValid()) throw JSONRPCError(RPC_WALLET_ERROR, "Private Key Not Valid"); CPubKey pubkey = key.GetPubKey(); pubkey.IsCompressed(); assert(key.VerifyPubKey(pubkey)); result.push_back(Pair("Address", CBitcoinAddress(pubkey.GetID()).ToString())); CKeyID vchAddress = pubkey.GetID(); { pwalletMain->MarkDirty(); pwalletMain->SetAddressBook(vchAddress, "", "receive"); // Don't throw error in case a key is already there if (pwalletMain->HaveKey(vchAddress)) throw JSONRPCError(RPC_WALLET_ERROR, "Key already held by wallet"); pwalletMain->mapKeyMetadata[vchAddress].nCreateTime = 1; if (!pwalletMain->AddKeyPubKey(key, pubkey)) throw JSONRPCError(RPC_WALLET_ERROR, "Error adding key to wallet"); // whenever a key is imported, we need to scan the whole chain pwalletMain->nTimeFirstKey = 1; // 0 would be considered 'no value' pwalletMain->ScanForWalletTransactions(chainActive.Genesis(), true); } return result; }
[ "PaulH-RESQ" ]
PaulH-RESQ
6624c3cc868a69038468423e4b6959e0c2903b34
ae529c02ab6fbc10e24b56bdc709327462c880f1
/test/hello/hello_test.hpp
08354c29135e23d8f9f31bcede4a8537ec93735c
[]
no_license
yuta1402/tdc-subprograms
da82f3a9db7c657a21152c0a1c0d6bae971ec7bc
d300d5401292dbd3a7d88a203619199789142347
refs/heads/master
2020-09-05T00:48:38.866126
2019-11-06T07:40:02
2019-11-06T07:40:02
219,937,612
0
0
null
null
null
null
UTF-8
C++
false
false
216
hpp
#include "test.hpp" #include "hs/hello.hpp" void get_hello_test() { hs::Hello h; auto s = h.getHello(); eassert(s == "Hello, world", "s == %s", s.c_str()); } void hello_test() { get_hello_test(); }
f30179ddff8489f99a0e33f09f072eef62ce7095
1a8f8db68258056f2641d6a7df657f0678806843
/SaveProcessor.cpp
04c74fd3295568db95e8ecf78bd682fa17102115
[]
no_license
mdifferent/sanyu_rpg_cocos2dx
bf6d8b4d4b04e830e84676772a1344caecf128c1
98c1fb24fa11c3c625d4104fb66d76e6f19bee31
refs/heads/master
2020-12-24T16:59:53.172599
2014-11-10T02:35:16
2014-11-10T02:35:16
18,980,902
2
0
null
null
null
null
UTF-8
C++
false
false
5,893
cpp
#include "SaveProcessor.h" const int MAX_XML_KEY_LEN = 20; SaveProcessor::SaveProcessor(void) { } SaveProcessor::~SaveProcessor(void) { } XMLElement *SaveProcessor::findNthSaveData(const int iSaveNo) { tinyxml2::XMLDocument m_doc; if (m_doc.LoadFile(SAVE_FILE_PATH)!= XML_NO_ERROR) { CCLOG("Load save file failed!"); return NULL; } XMLElement *pRoot = m_doc.FirstChildElement("Root"); XMLElement *pSaveData = pRoot->FirstChildElement("SaveData"); bool bRecordFound = false; //Find record, according to pos attribute while(pSaveData) { int iPos = 0; pSaveData->QueryIntAttribute("pos", &iPos); if (iSaveNo == iPos) { return pSaveData; } else pSaveData = pSaveData->NextSiblingElement("SaveData"); } return NULL; } map<int,PlayerData*> *SaveProcessor::loadPlayerData(const int iSaveNo) { //tinyxml2::XMLDocument saveDoc; XMLElement *pSaveData = findNthSaveData(iSaveNo); if (!pSaveData) { CCLOG("Couldn't find save data No.%d",iSaveNo); return NULL; } map<int,PlayerData*> *dataSet = new map<int,PlayerData*>(); int i=1; //Get every player data XMLElement *pPlayerElement = pSaveData->FirstChildElement("Player"); while(pPlayerElement) { PlayerData *pData = new PlayerData(pPlayerElement->Attribute("name")); //Get every property of each player XMLElement *pPropertyElement = pPlayerElement->FirstChildElement(); PLAYER_PROP_TYPE ePro = MAX_HP; while(pPropertyElement) { int iValue = atoi(pPropertyElement->GetText()); pData->setProperty(ePro,iValue); ePro = (PLAYER_PROP_TYPE)(ePro+1); pPropertyElement = pPropertyElement->NextSiblingElement(); } //Get items XMLElement *pItemElement = pPlayerElement->FirstChildElement("ItemList")->FirstChildElement("Item"); while(pItemElement) { int iItemId = pItemElement->IntAttribute("id"); //string sItemName = string(pItemElement->Attribute("id")); int iItemCount = atoi(pItemElement->GetText()); pData->getItem(iItemId,iItemCount); pItemElement = pItemElement->NextSiblingElement("Item"); } //Get skills XMLElement *pSkillElement = pPlayerElement->FirstChildElement("SkillList")->FirstChildElement("Skill"); while (pSkillElement) { int iSkillId = pSkillElement->IntAttribute("id"); int iSkillLevel = atoi(pSkillElement->GetText()); if (iSkillLevel > 0) pData->learnSkill(iSkillId,iSkillLevel); pSkillElement = pSkillElement->NextSiblingElement("Skill"); } dataSet->insert(std::make_pair<int,PlayerData*>(i++,pData)); pPlayerElement = pPlayerElement->NextSiblingElement("Player"); } return dataSet; } bool SaveProcessor::savePlayerDataSet(const int iSaveNo, map<int,PlayerData*> *pData) { if (!pData || iSaveNo<1) { CCLOG("Save data parameter error!"); return false; } /* XMLElement *pSaveData = findNthSaveData(iSaveNo); if (pSaveData)//Update exsiting save { map<int,PlayerData*>::iterator it = pData->begin(); while (it != pData->end()) //Every playerdata in memory, since not delete player data in file { XMLElement *pPlayerElement = pSaveData->FirstChildElement("Player"); bool isFoundInFile = false; while (pPlayerElement) { string sNameinFile = pPlayerElement->Attribute("name"); if (it->second->getPlayerName() == sNameinFile) { isFoundInFile = true; //Update properties XMLElement *pPropertyElement = pPlayerElement->FirstChildElement(); PLAYER_PROP_TYPE ePro = MAX_HP; while(pPropertyElement) { int iValue = it->second->getProperty(ePro); char cValue[10] = {0}; _itoa(iValue,cValue,10); pPropertyElement->SetValue(cValue); ePro = (PLAYER_PROP_TYPE)(ePro+1); pPropertyElement = pPropertyElement->NextSiblingElement(); } //Refresh items : delete all original ones and write all new into file. XMLElement *pItemListElement = pPlayerElement->FirstChildElement("ItemList"); pItemListElement->DeleteChildren(); map<string,int>::iterator itemIt = it->second->getItemList()->begin(); while(itemIt != it->second->getItemList()->end()) { XMLElement *pNewItemNode = m_doc.NewElement("Item"); pNewItemNode->SetAttribute("name",itemIt->first.c_str()); char cValue[10] = {0}; _itoa(itemIt->second,cValue,10); pNewItemNode->SetValue(cValue); pItemListElement->InsertEndChild(pNewItemNode); itemIt++; } //Refresh skill : delete all original ones and write all new into file. XMLElement *pSkillListElement = pPlayerElement->FirstChildElement("SkillList"); pSkillListElement->DeleteChildren(); map<string,int>::iterator skillIt = it->second->getSkillList()->begin(); while(skillIt != it->second->getSkillList()->end()) { XMLElement *pNewSkillNode = m_doc.NewElement("Skill"); pNewSkillNode->SetAttribute("name",itemIt->first.c_str()); char cValue[10] = {0}; _itoa(itemIt->second,cValue,10); pNewSkillNode->SetValue(cValue); pSkillListElement->InsertEndChild(pNewSkillNode); skillIt++; } break; } else pPlayerElement = pPlayerElement->NextSiblingElement("Player"); } if (!isFoundInFile) { XMLElement *pNewPlayerNode = m_doc.NewElement("Player"); string sPlayerName = it->second->getPlayerName(); pNewPlayerNode->SetAttribute("name",sPlayerName.c_str()); char cValue[10]; XMLElement *pNewMaxHPNode = m_doc.NewElement("MaxHP"); _itoa(it->second->getPropertyList()->at(MAX_HP),cValue,10); pNewMaxHPNode->SetValue(cValue); pNewPlayerNode->InsertEndChild(pNewMaxHPNode); XMLElement *pNewHPNode = m_doc.NewElement("HP"); _itoa(it->second->getPropertyList()->at(CURRENT_HP),cValue,10); pNewHPNode->SetValue(cValue); pNewPlayerNode->InsertEndChild(pNewHPNode); } it++; } } else //Create new save { //TODO: Build new Save data node and write to file } */ return true; }
97e9198b1fe83e959f7fa332c2adcbb65f9edeef
4f4d5fb91b80c1f69966bd29c0fbd83890417371
/Projects/Project2/main.cpp
a1e39cae05a181889b6d8fd019af166c8b2cf143
[]
no_license
Huffmajo/CS162
62b3bda16c7fa054a7658f72dbe043c85caa3fb7
60d7063d8826cf939ac42bb53b2163f2e45f3635
refs/heads/master
2021-09-16T05:13:46.134720
2018-06-16T22:38:13
2018-06-16T22:38:13
137,614,621
0
0
null
null
null
null
UTF-8
C++
false
false
757
cpp
/********************************************************************* ** Program name: Zoo Tycoon ** Author: Joel Huffman ** Date: 2/02/2018 ** Description: You're the owner of your very own zoo. Choose which ** animals to purchase and try to keep from going bankrupt. Random ** events happen daily that could be positive or negative. Your animals ** can even have babies once they reach adulthood. *********************************************************************/ #include "Zoo.hpp" #include "Tiger.hpp" #include "utils.hpp" #include <iostream> #include <time.h> using std::cout; int main() { //seed random number generator srand(time(NULL)); Zoo x; Zoo* ptrZoo = &x; menu(ptrZoo); return 0; }
9d09e0c7e3bb2a044b89a6e38cdd6ad126bf8ab3
359ea589f68f7b574755867844ff6746f941cb8c
/src/Stain.cpp
b4f669b177efb85ffc3fdb40583120c1896cb85a
[]
no_license
SimpleDrunk/Snake
52cdb66e6ea1182b537a2000145a2c4cd58b492f
0f95070d5c01b198c3dcf3c8102e2958fe0b5495
refs/heads/master
2016-09-05T16:26:24.858850
2013-09-09T06:56:30
2013-09-09T06:56:30
null
0
0
null
null
null
null
UTF-8
C++
false
false
136
cpp
#include "Stain.h" Stain::Stain(int _x, int _y, int _type) { this->x = _x; this->y = _y; this->type = _type; } Stain::~Stain() { }
4e5d1bb812e11d1da80f2bbc4887b574e60dc3fa
30d86944adba5d7d54dc7714ee91925152f17091
/otros_aed/Estructuras de Datos I/BinHeap/main.cpp
9d3d02dc86aa8645fcccb025626999b113693871
[]
no_license
luigy-mach/aed
835209bedebc575235ee881935c68fc4c7073a23
008a6b9d12c58985730acef1a7990c6e2a1147ab
refs/heads/master
2021-05-04T21:14:13.727062
2018-02-03T16:49:50
2018-02-03T16:49:50
119,912,383
0
0
null
null
null
null
UTF-8
C++
false
false
3,059
cpp
#include <iostream> /*#include "binomial.h" #include "garbageCollector.h" #include "garbage.h"*/ #include "binomial.h" using namespace std; int main() { /*garbagecollector * w= new garbagecollector<Persona>(); Persona *p = (per)w->New(sizeof(Persona));*/ binomial<int> * H = binomial<int>::Init(); H=H->MAKE_BINOMIAL_HEAP(); nodoB<int> * np1 = new nodoB<int>(5); nodoB<int> * np2 = new nodoB<int>(3); nodoB<int> * np3 = new nodoB<int>(15); H->BINOMIAL_HEAP_INSERT(np1); H->BINOMIAL_HEAP_INSERT(np2); H->BINOMIAL_HEAP_INSERT(np3); //H->BINOMIAL_HEAP_DELETE(H,np3); //H->BINOMIAL_HEAP_DECREASE_KEY(H,np3,10); //cout<<H->getHead()->getSibling()->getChild()->getKey(); //cout<<heap->; //cout<<H->getHead()->getKey(); cout<<H->BINOMIAL_HEAP_EXTRACT_MIN(H)->getKey(); //cout<<H->BINOMIAL_HEAP_EXTRACT_MIN(H)->getKey(); } /*binomial<int> * H =binomial<int>::Init(); H=H->MAKE_BINOMIAL_HEAP(); nodoB<int> * np1 = new nodoB<int>(5); nodoB<int> * np2 = new nodoB<int>(3); nodoB<int> * np3 = new nodoB<int>(15); H=H->BINOMIAL_HEAP_INSERT(H,np1); H=H->BINOMIAL_HEAP_INSERT(H,np2); H=H->BINOMIAL_HEAP_INSERT(H,np3); //H->BINOMIAL_HEAP_DELETE(H,np2); //H->BINOMIAL_HEAP_DECREASE_KEY(H,np3,10); //cout<<H->getHead()->getSibling()->getChild()->getKey(); //cout<<heap->; //cout<<H->getHead()->getKey(); cout<<H->BINOMIAL_HEAP_EXTRACT_MIN(H)->getKey()<<endl; cout<<H->BINOMIAL_HEAP_EXTRACT_MIN(H)->getKey(); //binomial<garbage*> *bin=new binomial<garbage*>(); */ /* int main() { binomial<int> * H = new binomial<int>(); H=H->MAKE_BINOMIAL_HEAP(); nodoB<int> * np1 = new nodoB<int>(5); nodoB<int> * np2 = new nodoB<int>(3); nodoB<int> * np3 = new nodoB<int>(15); H=H->BINOMIAL_HEAP_INSERT(H,np1); H=H->BINOMIAL_HEAP_INSERT(H,np2); H=H->BINOMIAL_HEAP_INSERT(H,np3); //H->BINOMIAL_HEAP_DELETE(H,np3); //H->BINOMIAL_HEAP_DECREASE_KEY(H,np3,10); //cout<<H->getHead()->getSibling()->getChild()->getKey(); //cout<<heap->; //cout<<H->getHead()->getKey(); cout<<H->BINOMIAL_HEAP_EXTRACT_MIN(H)->getKey(); //cout<<H->BINOMIAL_HEAP_EXTRACT_MIN(H)->getKey(); } */ /* #include "nodo.h" #include <map> typedef map<int,string> T_mapa; //typedef map<long int, Nodo*> T_mapa; //typedef map<long int, string> T_mapa; int main() { T_mapa m; m.insert(pair<int,string>(10,"carlos")); m.insert(pair<int,string>(2,"eddy")); m.insert(pair<int,string>(50,"alal")); m.insert(pair<int,string>(15,"jose")); m.insert(pair<int,string>(34,"juan")); cout << m[10] << endl; /*string data[] = {"carlos","juan","maria","rosa"}; T_mapa m; m.insert(pair<long int,string>((long int)&(data[0]),data[0])); m.insert(pair<long int,string>((long int)&(data[1]),data[1])); m.insert(pair<long int,string>((long int)&(data[2]),data[2])); m.insert(pair<long int,string>((long int)&(data[3]),data[3])); cout << m[(long int)(&data[1])] <<endl; return 0; } */
cb3309777e84ae7481e4ec565f0de9d04cb94808
91438445e5ad0e16691c5c7be33d35b8ba2d6ae3
/Eligibility for voting( If else).cpp
41d364c03fde65eaa8d2bc3a9b4c7cb5929e39aa
[]
no_license
Aswin6112/Checking-eligibility-to-Vote-using-if-else
880a3e0197cca94b58a9e3b31a242fcf9d2f9c11
9059cba61efab873ecde216ff2cddb77e87d285d
refs/heads/main
2023-07-30T05:10:10.447532
2021-09-20T13:09:34
2021-09-20T13:09:34
408,447,251
0
0
null
null
null
null
UTF-8
C++
false
false
370
cpp
#include<iostream> using namespace std; int main() { int age; int a; cout<<"Enter Your Age \n"<<"Your Age: "; cin>>age; if(age>=18) { cout<<"\nYou are eligible to vote"; } else { a=18-age; cout<<"\nOops ! You are not eligible to vote right now.\n"; cout<<"You have to wait for "<<a<<" more years to vote." ; } return 0; }
f69abe83ac4c6ecb25cdd49a95ba2f36bb7f49f6
e76ea38dbe5774fccaf14e1a0090d9275cdaee08
/src/chrome/test/base/view_event_test_base.cc
ac4d8acd7129c9fe95bb19f4478d2085776838b5
[ "BSD-3-Clause" ]
permissive
eurogiciel-oss/Tizen_Crosswalk
efc424807a5434df1d5c9e8ed51364974643707d
a68aed6e29bd157c95564e7af2e3a26191813e51
refs/heads/master
2021-01-18T19:19:04.527505
2014-02-06T13:43:21
2014-02-06T13:43:21
16,070,101
1
3
null
null
null
null
UTF-8
C++
false
false
7,240
cc
// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "chrome/test/base/view_event_test_base.h" #include "base/bind.h" #include "base/bind_helpers.h" #include "base/message_loop/message_loop.h" #include "base/strings/string_number_conversions.h" #include "chrome/test/base/interactive_test_utils.h" #include "chrome/test/base/ui_test_utils.h" #include "content/public/browser/browser_thread.h" #include "ui/base/ime/input_method_initializer.h" #include "ui/base/test/ui_controls.h" #include "ui/compositor/test/context_factories_for_test.h" #include "ui/message_center/message_center.h" #include "ui/views/view.h" #include "ui/views/widget/desktop_aura/desktop_screen.h" #include "ui/views/widget/widget.h" #if defined(USE_ASH) #include "ash/shell.h" #include "ash/test/test_session_state_delegate.h" #include "ash/test/test_shell_delegate.h" #endif #if defined(USE_AURA) #include "ui/aura/client/event_client.h" #include "ui/aura/env.h" #include "ui/aura/root_window.h" #include "ui/aura/test/aura_test_helper.h" #endif #if defined(OS_CHROMEOS) #include "chromeos/audio/cras_audio_handler.h" #include "chromeos/network/network_handler.h" #endif namespace { // View subclass that allows you to specify the preferred size. class TestView : public views::View { public: TestView() {} void SetPreferredSize(const gfx::Size& size) { preferred_size_ = size; PreferredSizeChanged(); } virtual gfx::Size GetPreferredSize() OVERRIDE { if (!preferred_size_.IsEmpty()) return preferred_size_; return View::GetPreferredSize(); } virtual void Layout() OVERRIDE { View* child_view = child_at(0); child_view->SetBounds(0, 0, width(), height()); } private: gfx::Size preferred_size_; DISALLOW_COPY_AND_ASSIGN(TestView); }; // Delay in background thread before posting mouse move. const int kMouseMoveDelayMS = 200; } // namespace ViewEventTestBase::ViewEventTestBase() : window_(NULL), content_view_(NULL) { } void ViewEventTestBase::Done() { base::MessageLoop::current()->Quit(); #if defined(OS_WIN) && !defined(USE_AURA) // We need to post a message to tickle the Dispatcher getting called and // exiting out of the nested loop. Without this the quit never runs. if (window_) PostMessage(window_->GetNativeWindow(), WM_USER, 0, 0); #endif // If we're in a nested message loop, as is the case with menus, we // need to quit twice. The second quit does that for us. Finish all // pending UI events before posting closure because events it may be // executed before UI events are executed. ui_controls::RunClosureAfterAllPendingUIEvents( base::MessageLoop::QuitClosure()); } void ViewEventTestBase::SetUp() { views::ViewsDelegate::views_delegate = &views_delegate_; ui::InitializeInputMethodForTesting(); gfx::NativeView context = NULL; #if defined(USE_ASH) // The ContextFactory must exist before any Compositors are created. bool allow_test_contexts = true; ui::InitializeContextFactoryForTests(allow_test_contexts); #if defined(OS_WIN) // http://crbug.com/154081 use ash::Shell code path below on win_ash bots when // interactive_ui_tests is brought up on that platform. gfx::Screen::SetScreenInstance( gfx::SCREEN_TYPE_NATIVE, views::CreateDesktopScreen()); #else // !OS_WIN // Ash Shell can't just live on its own without a browser process, we need to // also create the message center. message_center::MessageCenter::Initialize(); #if defined(OS_CHROMEOS) chromeos::CrasAudioHandler::InitializeForTesting(); chromeos::NetworkHandler::Initialize(); #endif // OS_CHROMEOS ash::test::TestShellDelegate* shell_delegate = new ash::test::TestShellDelegate(); ash::Shell::CreateInstance(shell_delegate); shell_delegate->test_session_state_delegate() ->SetActiveUserSessionStarted(true); context = ash::Shell::GetPrimaryRootWindow(); #endif // !OS_WIN aura::Env::CreateInstance(); #elif defined(USE_AURA) // Instead of using the ash shell, use an AuraTestHelper to create and manage // the test screen. aura_test_helper_.reset( new aura::test::AuraTestHelper(base::MessageLoopForUI::current())); aura_test_helper_->SetUp(); context = aura_test_helper_->root_window(); #endif // !USE_ASH && USE_AURA window_ = views::Widget::CreateWindowWithContext(this, context); } void ViewEventTestBase::TearDown() { if (window_) { #if defined(OS_WIN) && !defined(USE_AURA) DestroyWindow(window_->GetNativeWindow()); #else window_->Close(); content::RunAllPendingInMessageLoop(); #endif window_ = NULL; } #if defined(USE_ASH) #if !defined(OS_WIN) ash::Shell::DeleteInstance(); #if defined(OS_CHROMEOS) chromeos::NetworkHandler::Shutdown(); chromeos::CrasAudioHandler::Shutdown(); #endif // Ash Shell can't just live on its own without a browser process, we need to // also shut down the message center. message_center::MessageCenter::Shutdown(); #endif // !OS_WIN aura::Env::DeleteInstance(); ui::TerminateContextFactoryForTests(); #elif defined(USE_AURA) aura_test_helper_->TearDown(); #endif // !USE_ASH && USE_AURA ui::ShutdownInputMethodForTesting(); views::ViewsDelegate::views_delegate = NULL; } bool ViewEventTestBase::CanResize() const { return true; } views::View* ViewEventTestBase::GetContentsView() { if (!content_view_) { // Wrap the real view (as returned by CreateContentsView) in a View so // that we can customize the preferred size. TestView* test_view = new TestView(); test_view->SetPreferredSize(GetPreferredSize()); test_view->AddChildView(CreateContentsView()); content_view_ = test_view; } return content_view_; } const views::Widget* ViewEventTestBase::GetWidget() const { return content_view_->GetWidget(); } views::Widget* ViewEventTestBase::GetWidget() { return content_view_->GetWidget(); } ViewEventTestBase::~ViewEventTestBase() { } void ViewEventTestBase::StartMessageLoopAndRunTest() { ASSERT_TRUE( ui_test_utils::ShowAndFocusNativeWindow(window_->GetNativeWindow())); // Flush any pending events to make sure we start with a clean slate. content::RunAllPendingInMessageLoop(); // Schedule a task that starts the test. Need to do this as we're going to // run the message loop. base::MessageLoop::current()->PostTask( FROM_HERE, base::Bind(&ViewEventTestBase::DoTestOnMessageLoop, this)); content::RunMessageLoop(); } gfx::Size ViewEventTestBase::GetPreferredSize() { return gfx::Size(); } void ViewEventTestBase::ScheduleMouseMoveInBackground(int x, int y) { if (!dnd_thread_.get()) { dnd_thread_.reset(new base::Thread("mouse-move-thread")); dnd_thread_->Start(); } dnd_thread_->message_loop()->PostDelayedTask( FROM_HERE, base::Bind(base::IgnoreResult(&ui_controls::SendMouseMove), x, y), base::TimeDelta::FromMilliseconds(kMouseMoveDelayMS)); } void ViewEventTestBase::StopBackgroundThread() { dnd_thread_.reset(NULL); } void ViewEventTestBase::RunTestMethod(const base::Closure& task) { StopBackgroundThread(); task.Run(); if (HasFatalFailure()) Done(); }
486ee2daa4f9511991a71ba6105a651c7edbbbb3
e9304808e6050fd66ebd1007976e6ed50c016534
/include/gfx/gfxbuffer.h
eff2a78c6f8bc15eaabc8dfb7d99ec8dca7e9f4d
[ "MIT" ]
permissive
Sirithang/BaldrEngine
da31a62cd77cf7e85771bcd4488fdfb0d9d8ce2e
226b836f599ade59b6e3bc92f8a3177eb281aabb
refs/heads/master
2021-01-17T15:18:24.273973
2014-04-06T16:39:30
2014-04-06T16:39:30
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,267
h
#pragma once #include "core/constants.h" #include "gfx/gfxdevice.h" #include "core/objectmanager.h" namespace gfx { enum GFXBufferType { VERTEX_BUFFER = 0x1, INDEX_BUFFER = 0x2, CONSTANT_BUFFER = 0x3 }; enum GFXBufferUsage { DEFAULT = 0x0, IMMUTABLE = 0x1, DYNAMIC = 0x2 }; struct GFXBuffer : ManagedObject { GFXBufferType _type; GFXBufferUsage _usage; //total size. e.g. if contains 10 elem of 4 byte, size == 40 uint32 _size; //the user have the responsability of accessing that buffer right. void* _data; }; namespace gfxbuffer { extern ObjectManager<GFXBuffer, MAX_BUFFER_OBJECT> _gManager; ID create(GFXBufferType type, GFXBufferUsage usage, void* data, uint32 initialSize, bool localStorage = false); void destroy(ID buffer); void bind(ID buffer); void update(ID buffer, void* data, uint32 size); namespace impl { //as there is a 1:1 called between impl & generic, the ID will always match. //unmatching ID is a sign of major frell up. extern void (*createImpl)(GFXBufferType type, GFXBufferUsage usage, void* data, uint32 initialSize); extern void (*destroyImpl)(ID buffer); extern void (*bindImpl)(ID buffer); extern void (*updateImpl)(ID buffer, void* data, uint32 size); } } }
657e955751bb8b61773c63a24b6cc3ff73fdbcf1
f50981b3dd5ab2fedbf69f78e1e7c1dcc3657555
/tablemodel.cpp
9177347beb455b5824f46fe3cb6f37fd6da4b6af
[]
no_license
owkss/metrological-calculations
1fb68cb759655d7a1c15d329158f7bdf53dc0267
d010715da12bb8d842e183e76e27cc4d72df00cc
refs/heads/master
2022-06-22T09:44:11.910189
2020-05-11T11:08:52
2020-05-11T11:08:52
262,978,479
0
0
null
null
null
null
UTF-8
C++
false
false
10,270
cpp
#include "tablemodel.h" #include <QtMath> #include <QBrush> TableModel::TableModel(QObject *parent) : QAbstractTableModel(parent) { createGrubbsTable(); } int TableModel::rowCount(const QModelIndex &parent) const { Q_UNUSED(parent) return values.size(); } int TableModel::columnCount(const QModelIndex &parent) const { Q_UNUSED(parent) return N_COLUMNS; } QVariant TableModel::data(const QModelIndex &index, int role) const { if (!index.isValid()) return QVariant(); QString show; switch(role) { case Qt::DisplayRole: switch (index.column()) { case LIM: show = QString("±%1 %").arg(values.at(index.row()).limit); return show; case PRES: return values.at(index.row()).preset; case MEAS: return values.at(index.row()).measure; case ERR: show = QString("%1 %").arg(values.at(index.row()).error); return show; case ABS: return values.at(index.row()).abs; case AVRG: return values.at(index.row()).average; case DEV: return values.at(index.row()).deviation; case DISP: return values.at(index.row()).dispersion; case GRUBBS: return values.at(index.row()).grubbs; default: return QVariant(); } case Qt::EditRole: switch (index.column()) { case LIM: return values.at(index.row()).limit; case PRES: return values.at(index.row()).preset; case MEAS: return values.at(index.row()).measure; case ERR: return values.at(index.row()).error; case ABS: return values.at(index.row()).abs; case AVRG: return values.at(index.row()).average; case DEV: return values.at(index.row()).deviation; case DISP: return values.at(index.row()).dispersion; case GRUBBS: return values.at(index.row()).grubbs; default: return QVariant(); } case Qt::TextAlignmentRole: return Qt::AlignCenter; case Qt::BackgroundRole: switch(index.column()) { case ERR: if ((values.at(index.row()).error >= values.at(index.row()).limit) || (values.at(index.row()).error <= (-1.0 * values.at(index.row()).limit))) return QBrush(Qt::red); break; case GRUBBS: if ((values.at(index.row()).measures >= 3) && (values.at(index.row()).grubbs >= c_grubbs[values.at(index.row()).measures])) return QBrush(Qt::red); break; } break; case Qt::ToolTipRole: switch(index.column()) { case LIM: show = QString("U=%1dB; P=%2dB\nU=%3dB; P=%4dB") .arg(20*log10(1.0 + ((-1.0 * values.at(index.row()).limit) / 100.0))) .arg(10*log10(1.0 + ((-1.0 * values.at(index.row()).limit) / 100.0))) .arg(20*log10(1.0 + (values.at(index.row()).limit / 100.0))) .arg(10*log10(1.0 + (values.at(index.row()).limit / 100.0))); return show; case MEAS: show = QString(tr("Δ: %1 - %2")) .arg(values.at(index.row()).preset - (values.at(index.row()).preset * values.at(index.row()).limit / 100)) .arg(values.at(index.row()).preset + (values.at(index.row()).preset * values.at(index.row()).limit / 100)); return show; case ERR: show = QString("δU=%1dB; δP=%2dB") .arg(20*log10(1 + (values.at(index.row()).error / 100))) .arg(10*log10(1 + (values.at(index.row()).error / 100))); return show; case AVRG: show = QString(tr("Оценка величины: %1")) .arg(values.at(index.row()).deviation / qSqrt(values.at(index.row()).measures)); return show; case GRUBBS: if ((values.at(index.row()).measures >= 3) && (index.column() == GRUBBS)) { show = QString("G(%1) = %2") .arg(values.at(index.row()).measures) .arg(c_grubbs[values.at(index.row()).measures]); return show; } } } return QVariant(); } bool TableModel::setData(const QModelIndex &index, const QVariant &_value, int role) { if (index.isValid() && role == Qt::EditRole) { switch (index.column()) { case LIM: values[index.row()].limit = abs(_value.toDouble()); break; case PRES: values[index.row()].preset = _value.toDouble(); break; case MEAS: values[index.row()].measure = _value.toDouble(); break; case ERR: values[index.row()].error = _value.toDouble(); break; case ABS: values[index.row()].abs = _value.toDouble(); break; case AVRG: values[index.row()].average = _value.toDouble(); break; case DEV: values[index.row()].deviation = _value.toDouble(); break; case DISP: values[index.row()].dispersion = _value.toDouble(); break; case GRUBBS: values[index.row()].grubbs = _value.toDouble(); break; default: return false; } emit dataChanged(index, index, {role}); return true; } return false; } QVariant TableModel::headerData(int section, Qt::Orientation orientation, int role) const { if (role != Qt::DisplayRole) return QVariant(); if (orientation == Qt::Horizontal) { switch (section) { case LIM: return tr("Доп. предел"); case PRES: return tr("Уст. значение"); case MEAS: return tr("Изм. значение"); case ERR: return tr("Отн. погр-ть"); case ABS: return tr("Абс. погр-ть"); case AVRG: return tr("Среднее арифм."); case DEV: return tr("Среднеквадр. откл-е"); case DISP: return tr("Дисперсия"); case GRUBBS: return tr("Критерий Граббса"); default: return QVariant(); } } if (orientation == Qt::Vertical) { return section + 1; } return QVariant(); } Qt::ItemFlags TableModel::flags(const QModelIndex &index) const { if (!index.isValid()) return Qt::ItemIsEnabled; switch(index.column()) { case LIM: case PRES: case MEAS: return QAbstractTableModel::flags(index) | Qt::ItemIsEditable; default: return QAbstractTableModel::flags(index) | Qt::ItemIsEnabled; } } void TableModel::setMeasuresCount(const int row, const int count) { values[row].measures = count; } int TableModel::getMeasuresCount(const int row) { return values.at(row).measures; } void TableModel::setLimit(const int row, const double lim) { values[row].limit = lim; } double TableModel::getLimit(const int row) { return values.at(row).limit; } bool TableModel::insertRows(int row, int count, const QModelIndex &parent) { if (count < 1 || row < 0) return false; beginInsertRows(parent, row, row + count - 1); for (int i(0); i < count; ++i) values.insert(row + i, Columns()); endInsertRows(); return true; } bool TableModel::removeRows(int row, int count, const QModelIndex &parent) { beginRemoveRows(parent, row - count + 1, row); for (int i(0); i < count; ++i) values.remove(row - i); endRemoveRows(); return true; } bool TableModel::clear() { return removeRows(rowCount() - 1, rowCount()) ? true : false; } void TableModel::createGrubbsTable() { c_grubbs[3] = 1.155; c_grubbs[4] = 1.481; c_grubbs[5] = 1.715; c_grubbs[6] = 1.887; c_grubbs[7] = 2.020; c_grubbs[8] = 2.1260; c_grubbs[9] = 2.215; c_grubbs[10] = 2.290; c_grubbs[11] = 2.355; c_grubbs[12] = 2.412; c_grubbs[13] = 2.462; c_grubbs[14] = 2.507; c_grubbs[15] = 2.549; c_grubbs[16] = 2.585; c_grubbs[17] = 2.620; c_grubbs[18] = 2.651; c_grubbs[19] = 2.681; c_grubbs[20] = 2.709; c_grubbs[21] = 2.733; c_grubbs[22] = 2.758; c_grubbs[23] = 2.781; c_grubbs[24] = 2.876; c_grubbs[25] = 2.822; c_grubbs[26] = 2.841; c_grubbs[27] = 2.859; c_grubbs[28] = 2.876; c_grubbs[29] = 2.893; c_grubbs[30] = 2.908; } bool Columns::operator==(const Columns &c) { return qFuzzyCompare(this->limit, c.limit) && qFuzzyCompare(this->preset, c.preset) && qFuzzyCompare(this->measure, c.measure) && qFuzzyCompare(this->error, c.error) && qFuzzyCompare(this->abs, c.abs) && qFuzzyCompare(this->average, c.average) && qFuzzyCompare(this->deviation, c.deviation) && qFuzzyCompare(this->dispersion, c.dispersion) && qFuzzyCompare(this->grubbs, c.grubbs); } bool Columns::operator<(const Columns &c) { if (this->preset < c.preset && this->measure < c.measure && this->error < c.error && this->abs < c.abs && this->average < c.average && this->deviation < c.deviation && this->dispersion < c.dispersion && this->grubbs < c.grubbs) return true; else return false; }
943c04feed458a3b099337541e268671f1865e10
7fa4b0bbe1fb3f52027ebcbe82679df39c1a3da9
/src/wbem/performance/PerformanceMetricFactory.h
5e65d0e63d39bed53cfc426c9a97d7d5333ca62f
[ "BSD-3-Clause" ]
permissive
nkothapa/IXPDIMMSW
1c0f985cbae8709c2a3d8dcbbaed1341ed2be704
3fd90f97425b0efe767ae8f4ba2c14df8dca1e47
refs/heads/master
2021-01-14T10:52:16.837065
2016-05-10T10:46:04
2016-05-10T10:46:04
null
0
0
null
null
null
null
UTF-8
C++
false
false
5,468
h
/* * Copyright (c) 2015 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. */ /* * This file contains the provider for the PerformanceMetric instances * which represent the current value of an NVM DIMM performance metric. */ #ifndef _WBEM_PERFORMANCE_METRIC_FACTORY_H_ #define _WBEM_PERFORMANCE_METRIC_FACTORY_H_ #include <string> #include <framework_interface/NvmInstanceFactory.h> #include "PerformanceMetricCommon.h" namespace wbem { namespace performance { /*! * Creation name associated with an instance of a performance metric class. */ static const std::string PERFORMANCE_METRIC_CREATIONCLASSNAME = std::string(NVM_WBEM_PREFIX) + "PerformanceMetric"; /*! * Provider Factory for NVDIMMSensor */ class NVM_API PerformanceMetricFactory : public framework_interface::NvmInstanceFactory { public: /*! * Initialize a new PerformanceMetric */ PerformanceMetricFactory() throw (framework::Exception); /*! * Clean up the PerformanceMetric */ ~PerformanceMetricFactory(); /*! * Implementation of the standard CIM method to retrieve a specific instance * @param[in] path * The object path of the instance to retrieve. * @param[in] attributes * The attributes to retrieve. * @throw Exception if unable to retrieve the host information. * @todo Should throw an exception if the object path doesn't match * the results of getHostName. * @return The instance. */ framework::Instance* getInstance(framework::ObjectPath &path, framework::attribute_names_t &attributes) throw (framework::Exception); /*! * Implementation of the standard CIM method to retrieve a list of * object paths. * @return The object path. */ framework::instance_names_t* getInstanceNames() throw (framework::Exception); /*! * Utility function to find a substring that matches a defined metric type string * @param[in] str * the string to parse. * @return metric value code for the string found (METRIC_UNDEFINED, if not found). */ static metric_type getTypeFromInstanceIdName(const std::string &str); /*! * Utility function to convert a metric type code back into a text string. * @param[in] metric * the metric_type being requested * @param[in] suffix * optional suffix string to append to the result. * @return formatted element name string optionally suffixed with "suffix". */ static std::string getInstanceIdNameFromType (metric_type metric, const std::string &suffix = "") throw(wbem::framework::Exception); /*! * Test to see if to instances are associated. * @param[in] associationClass * Pointer to the association class * @param[in] pAntInstance * Pointer to the antecedent instance * @param pDepInstance * Pointer to the dependent instance * @return true if there is a antecedent/dependent relationship. */ bool isAssociated(const std::string &associationClass, framework::Instance* pAntInstance, framework::Instance* pDepInstance); /*! * Splits Performance Metrics InstanceID into the metric type and device uid. * @param[in] instanceId * The Attribute containing the instance id to parse. * @param[out] deviceUid * If successfully parsed, the uid for the device. * @param[out] metric * If successful, the enumerated type code for the metric type requested. * @return false on fail, true on success. */ static bool splitInstanceID(const framework::Attribute& instanceId, std::string &deviceUid, metric_type& metric); private: void populateAttributeList(framework::attribute_names_t &attributes) throw (framework::Exception); static NVM_UINT64 getValueForDeviceMetric(const NVM_UID deviceUid, const enum metric_type metricType) throw (framework::Exception); static std::string getMetricElementNameFromType(const metric_type type) throw (framework::Exception); static std::string getDeviceSerialNumber(const NVM_UID uid) throw (framework::Exception); }; } // performance } // wbem #endif //_WBEM_PERFORMANCE_METRIC_FACTORY_H_
b4e00f3d64b4b35785d8fb9e0c7078980f35f7d8
50d567884eba32fa3d9657218aad352055f023b4
/tGui/tObject/tObject.cpp
88a965e6f229aaa32403c25a66031a6a7120f5fd
[]
no_license
iincity/tGui_v3
a0ed72ec85a3601f2e22ad92e0312382bf7100f5
e454e2bd1f0be53b53da6204dca0ade5d70b0486
refs/heads/master
2020-04-09T07:23:46.487362
2018-04-08T08:08:43
2018-04-08T08:08:43
null
0
0
null
null
null
null
GB18030
C++
false
false
2,782
cpp
#include "tObject/tObject.h" //-----------------------------OBJECT------------------------- tObject::tObject(const char* n , tObject* obj ) { name = NULL; setName(n); parents = obj; if (obj) obj->addChild(this); childList = NULL; connections = NULL; } tObject::~tObject() { destroyChild(this); delete childList; if (connections) { connections->setAutoDelete(true); connections->clear(); } if (name) delete name; } void tObject::setName(const char* str) { if(!name) name = new tString(str); else name->setStr(str); } void tObject::regist(tObject* obj) { obj->addChild(this); this->setParent(obj); } void tObject::logout(tObject* obj) { obj->remChild(this); this->setParent(nullptr); } tLNode<tObject*> * tObject::unlink(tObject* obj) { if (getChildList()) return getChildList()->unlink(obj); return NULL; } void tObject::relink(tLNode<tObject*> * node) { if(getChildList()) getChildList()->relink(node); } void tObject::addChild(tObject* child) { if (!childList) childList = new tObjList(); //检查 if((childList->find(child)) < 0) childList->append(child); } void tObject::remChild(tObject* child) { if (!childList) return; //检查--有没有孩子 destroyChild(child); //删除 childList->remove(child); } void tObject::destroyChild(tObject* obj) { if (obj->childList) { destroyChild(obj->childList->getLast()); delete(obj->childList->getLast()); obj->childList->removeLast(); } } bool tObject::connect(func sig, tObject* receiver, func slot) { if (!connections) connections = new tConnectList(); int32 num = connections->find(sig);//这边要先遍历一次之前是否还有信号 if (num >= 0)//存在 {//这边要先遍历一次之前是否还有槽 tFuncList* funclist = connections->at(num)->slotList; tObjList* objlist = connections->at(num)->recvList; if (funclist->find(slot) < 0) { funclist->append(slot); objlist->append(receiver); } } else//不存在 { connection* con = new connection(sig, receiver, slot); if (!con) return false; connections->append(con); } return true; } bool tObject::disconnect(func sig, tObject* receiver, func slot) { if (!connections) return true; int32 num = connections->find(sig); if (num >= 0)//存在 { tFuncList* funclist = connections->at(num)->slotList; tObjList* objlist = connections->at(num)->recvList; funclist->remove(slot); objlist->remove(receiver); } return true; } void tObject::callSlot(func sig, int32 d1, int32 d2) { if (getConnections()) { int num = getConnections()->find(sig); if (num >= 0) getConnections()->at(num)->active(d1,d2); } }
5afc577fcd871bcc871eeb2cfd422662d2a1f3ea
dd4dd96a601c3d0cc5472764a1ce2b7ec7d2a51a
/BOJ/15684_makeladder.cpp
7ed266e6df65ea30481a24c816dd0d0f89c75152
[]
no_license
Bambia/Algorithm
23c56beba9c763ba3fc40b62d14d8773915f47a3
52b0ec5f00647fc39c4cd8a60419d011828cacc2
refs/heads/master
2022-02-26T19:36:39.377541
2019-11-16T12:59:42
2019-11-16T12:59:42
178,593,942
0
0
null
null
null
null
UTF-8
C++
false
false
1,385
cpp
#include <stdio.h> using namespace std; struct POINT{ int x,y; }; int ret=4; int M,N,H; int map[31][31]; bool check(){ for(int i=1; i<=N; i++){ int pos =i; for(int j=1; j<=H; j++){ if(map[j][pos]== 1){ //오른쪽에 사다리가 있으면 pos++; } else if(map[j][pos-1]== 1){ //왼쪽에 사다리가 있으면 pos--; } } if(pos!=i){ // printf("check fail\n"); return false; } } //printf("check success\n"); return true; } void dfs(int idx, int x, int y){ if(idx >=ret) return ; if(check()){ //printf("check success return current idx \n"); ret = idx; return; } if (idx == 3) return; for(int i =y; i<=H; i++){ for(int j=x; j<N; j++){ if(map[i][j] ==0 && map[i][j-1] ==0 && map[i][j+1] ==0){ //printf("make ladder\n"); map[i][j] = 1; dfs(idx+1,j,i); map[i][j] = 0; } } x=1; } } int main(void){ scanf("%d %d %d",&N,&M,&H); int a,b; for(int i=0; i<M; i++){ scanf("%d %d",&a,&b); map[a][b]=1; } ret = 4; dfs(0,1,1); if(ret >3) ret = -1; printf("%d",ret); return 0; }
c517a8dd445981ef6bed5ec9882d83faf275e55d
948a6bbb8ef60a97c4350bf1fbccbc972bbfcb4f
/thirdparty-Tokyo/Woll2Woll/InfoPowerTokyo/include/19.0/windows/Vcl.wwrichobjinfo.hpp
8e82fab443f70e6f9fe64580bb8ea6e2cccce144
[]
no_license
hotsoft/components
504c6935b892c74796a8cbec91736185507ed149
2d41768ff68c0c6535a1ee40f3e8abc90cb19c9b
refs/heads/master
2023-09-03T22:46:13.153273
2023-08-18T13:16:19
2023-08-18T13:16:19
14,142,719
5
1
null
null
null
null
UTF-8
C++
false
false
4,577
hpp
// CodeGear C++Builder // Copyright (c) 1995, 2016 by Embarcadero Technologies, Inc. // All rights reserved // (DO NOT EDIT: machine generated header) 'vcl.wwrichobjinfo.pas' rev: 32.00 (Windows) #ifndef Vcl_WwrichobjinfoHPP #define Vcl_WwrichobjinfoHPP #pragma delphiheader begin #pragma option push #pragma option -w- // All warnings off #pragma option -Vx // Zero-length empty class member #pragma pack(push,8) #include <System.hpp> #include <SysInit.hpp> #include <Winapi.Windows.hpp> #include <Winapi.Messages.hpp> #include <System.SysUtils.hpp> #include <System.Classes.hpp> #include <Vcl.Controls.hpp> #include <System.Win.ComObj.hpp> #include <Vcl.Forms.hpp> #include <Winapi.RichEdit.hpp> #include <vcl.wwrichole.hpp> #include <Vcl.OleCtnrs.hpp> #include <Winapi.ActiveX.hpp> #include <Winapi.OleDlg.hpp> #include <Vcl.OleConst.hpp> #include <vcl.wwriched.hpp> //-- user supplied ----------------------------------------------------------- namespace Vcl { namespace Wwrichobjinfo { //-- forward type declarations ----------------------------------------------- class DELPHICLASS TwwOleUIObjInfo; class DELPHICLASS TwwOleUILinkInfo; //-- type declarations ------------------------------------------------------- #pragma pack(push,4) class PASCALIMPLEMENTATION TwwOleUIObjInfo : public System::TInterfacedObject { typedef System::TInterfacedObject inherited; private: Vcl::Wwriched::TwwCustomRichEdit* FRichEdit; Vcl::Wwrichole::TREOBJECT FReObject; public: __fastcall TwwOleUIObjInfo(Vcl::Wwriched::TwwCustomRichEdit* RichEdit, const Vcl::Wwrichole::TREOBJECT &ReObject); HRESULT __stdcall GetObjectInfo(int dwObject, int &dwObjSize, System::WideChar * &lpszLabel, System::WideChar * &lpszType, System::WideChar * &lpszShortType, System::WideChar * &lpszLocation); HRESULT __stdcall GetConvertInfo(int dwObject, GUID &ClassID, System::Word &wFormat, GUID &ConvertDefaultClassID, System::PGUID &lpClsidExclude, int &cClsidExclude); HRESULT __stdcall ConvertObject(int dwObject, const GUID &clsidNew); HRESULT __stdcall GetViewInfo(int dwObject, NativeUInt &hMetaPict, int &dvAspect, int &nCurrentScale); HRESULT __stdcall SetViewInfo(int dwObject, NativeUInt hMetaPict, int dvAspect, int nCurrentScale, System::LongBool bRelativeToOrig); public: /* TObject.Destroy */ inline __fastcall virtual ~TwwOleUIObjInfo(void) { } private: void *__IOleUIObjInfo; // IOleUIObjInfo public: operator IOleUIObjInfo*(void) { return (IOleUIObjInfo*)&__IOleUIObjInfo; } }; #pragma pack(pop) #pragma pack(push,4) class PASCALIMPLEMENTATION TwwOleUILinkInfo : public System::TInterfacedObject { typedef System::TInterfacedObject inherited; private: Vcl::Wwrichole::TREOBJECT FReObject; Vcl::Wwriched::TwwCustomRichEdit* FRichEdit; _di_IOleLink FOleLink; public: __fastcall TwwOleUILinkInfo(Vcl::Wwriched::TwwCustomRichEdit* RichEdit, const Vcl::Wwrichole::TREOBJECT &ReObject); int __stdcall GetNextLink(int dwLink); HRESULT __stdcall SetLinkUpdateOptions(int dwLink, int dwUpdateOpt); HRESULT __stdcall GetLinkUpdateOptions(int dwLink, int &dwUpdateOpt); HRESULT __stdcall SetLinkSource(int dwLink, System::WideChar * pszDisplayName, int lenFileName, int &chEaten, System::LongBool fValidateSource); HRESULT __stdcall GetLinkSource(int dwLink, System::WideChar * &pszDisplayName, int &lenFileName, System::WideChar * &pszFullLinkType, System::WideChar * &pszShortLinkType, System::LongBool &fSourceAvailable, System::LongBool &fIsSelected); HRESULT __stdcall OpenLinkSource(int dwLink); HRESULT __stdcall UpdateLink(int dwLink, System::LongBool fErrorMessage, System::LongBool fErrorAction); HRESULT __stdcall CancelLink(int dwLink); HRESULT __stdcall GetLastUpdate(int dwLink, _FILETIME &LastUpdate); public: /* TObject.Destroy */ inline __fastcall virtual ~TwwOleUILinkInfo(void) { } private: void *__IOleUILinkInfo; // IOleUILinkInfo public: operator IOleUILinkInfo*(void) { return (IOleUILinkInfo*)&__IOleUILinkInfo; } }; #pragma pack(pop) //-- var, const, procedure --------------------------------------------------- } /* namespace Wwrichobjinfo */ } /* namespace Vcl */ #if !defined(DELPHIHEADER_NO_IMPLICIT_NAMESPACE_USE) && !defined(NO_USING_NAMESPACE_VCL_WWRICHOBJINFO) using namespace Vcl::Wwrichobjinfo; #endif #if !defined(DELPHIHEADER_NO_IMPLICIT_NAMESPACE_USE) && !defined(NO_USING_NAMESPACE_VCL) using namespace Vcl; #endif #pragma pack(pop) #pragma option pop #pragma delphiheader end. //-- end unit ---------------------------------------------------------------- #endif // Vcl_WwrichobjinfoHPP
a16e7cd905b3e5521d6068c29f2daccd22173456
db55b589cced4d4db4511f86edadc3209716f7ae
/ZynqSrc/NeuronD/main.cpp
25b971e3dcae332d70440bcf19dcda709aa1e249
[]
no_license
kimbjerge/neuronDataCollector
3480fa703068e97163290010ef033882f8d46e6c
dd5460f0b34d29b4383ba4589a1357be30992bf3
refs/heads/master
2020-04-08T17:04:54.154727
2019-06-28T12:20:25
2019-06-28T12:20:25
159,549,464
0
1
null
2020-01-08T08:08:06
2018-11-28T18:51:53
C
UTF-8
C++
false
false
3,570
cpp
/* * main.cpp * * Created on: 20. July 2018 * Author: Kim Bjerge */ #include <defsNet.h> //#include "NeuronChannels.h" #include "CliCmdTemplates.h" #include "DataUDPThread.h" #include "CliTCPThread.h" #include "UserThread.h" #include "TestDataGenerator.h" #include "TestDataSDCard.h" #include "TemplateMatch.h" #include "Config.h" #include "FileSDCard.h" #include "TestIO.h" // main_hpp.c in directory hpp calls main_full in directory Full_Demo (A UART Cli interface to FreeRTOS) int main_hpp( void ); //TestDataGenerator testDataGenerator; //DataUDPThread dataThread(&testDataGenerator); char fileList[20000]; FileSDCard filesSDCard((char *)"0:/"); void TestSDCard(void) { filesSDCard.list(fileList, sizeof(fileList)); printf(fileList); filesSDCard.rename((char*)"KIM.TXT", (char*)"KBE.TXT"); filesSDCard.list(fileList, sizeof(fileList)); printf(fileList); filesSDCard.del((char*)"KBE.TXT"); filesSDCard.list(fileList, sizeof(fileList)); printf(fileList); } TestDataSDCard testDataSDCard; DataUDPThread dataThread(&testDataSDCard); // Task to upload data using UDP Config config; TemplateMatch mTemplateMatch(&testDataSDCard); // Task to perform neural template matching CliCommand cliCommand(&mTemplateMatch, &dataThread, &testDataSDCard); // Task to handle user command line interface (CLI) over sockets CliTCPThread cliThread; // Task to create and wait for socket connection static int16_t *GenSamples(void) { return testDataSDCard.GenerateSamples(); } int main() { //init_net_server(echo_tcp_thread, 0); //init_net_server(demo_udp_thread, 0); //init_net_server(dataThread.threadMapper, &dataThread); printf("-------------------------------------------------------------\r\n"); printf("Neuron Real Time Template Matching Algorithm Version %d.%d\r\n", VERSION_HI, VERSION_LO); printf("Loads data from SD card of 32 channels and max. 6 templates\r\n"); printf("Template max. size of width 9 channels and 17 in length \r\n"); printf("Performs 60 taps FIR filtering and NXCOR template matching\r\n"); printf("Maximum 60 seconds of samples will be used from DATA.bin\r\n"); printf("-------------------------------------------------------------\r\n"); testDataSDCard.setFuncToGenSamples(&GenSamples); // Add function to get sample data when stored to SD card printf("Read template configuration from CONFIG.txt\r\n"); config.loadConfig("CONFIG.txt"); config.loadTemplateConfig(); printf("Read FIR coefficients from FIR.txt\r\n"); config.loadCoeff("FIR.txt"); config.loadCoeffBin("FIR.bin"); printf("Reading test samples from DATA.bin\r\n"); testDataSDCard.readFile((char *)"DATA.bin"); mTemplateMatch.Init(&config, testDataSDCard.getNumSamples()); // Use number of data samples read from file #if 0 mTemplateMatch.runThread(Thread::PRIORITY_NORMAL, "TemplateMatch"); #else // Initialize network and command CLI telnet interface cliThread.addCommand(&cliCommand); init_net_server(cliThread.threadMapper, &cliThread); #endif //UserThread mUserThread(Thread::PRIORITY_NORMAL, "UserControlThread"); // Initialize HPP and FreeRTOS CLI using UART with neural spike processing demos //main_hpp(); /* Start FreeRTOS, the tasks running. */ vTaskStartScheduler(); /* If all is well, the scheduler will now be running, and the following line will never be reached. If the following line does execute, then there was insufficient FreeRTOS heap memory available for the idle and/or timer tasks to be created. See the memory management section on the FreeRTOS web site for more details. */ for( ;; ); }
cd5c2c9d987dd3eccda9948165c937470ce6bb41
393320d4dc9463ae7047390e4afe6f3e25fd70b9
/tek2/C++/Pool/cpp_d14m/ex00/Banana.cpp
ccde8673368111a60bee3f46ea5d62214945f538
[]
no_license
Lime5005/epitech-1
d1c4f3739716173c8083ea4e6a04260d6dc92775
cb25df1fa5d540624b9e7fd58de6e458cd5cc250
refs/heads/master
2023-02-09T07:38:57.850357
2019-10-14T15:03:44
2019-10-14T15:03:44
null
0
0
null
null
null
null
UTF-8
C++
false
false
440
cpp
/* ** Banana.cpp for cpp_d14m in /home/gogo/rendu/tek2/cpp_d14m/ex00/Banana.cpp ** ** Made by Gauthier CLER ** Login <[email protected]> ** ** Started on Tue Jan 17 10:20:01 2017 Gauthier CLER ** Last update Tue Jan 17 10:20:01 2017 Gauthier CLER */ #include "Banana.h" Banana::Banana() { this->setName("banana"); this->setVitamins(5); } Banana::~Banana() { } std::string Banana::getName() const{ return this->_name; }
0d806d01eb50f7a8d142a217b1bec1e98c74facc
ed5926ae512e238af0f14655a3187d7e7fbf7ef7
/chromium/chrome/browser/browser_features.h
12de2bca3565fc95dd82d03a3a8615e98e14798d
[ "BSD-3-Clause" ]
permissive
slimsag/mega
82595cd443d466f39836e24e28fc86d3f2f1aefd
37ef02d1818ae263956b7c8bc702b85cdbc83d20
refs/heads/master
2023-08-16T22:36:25.860917
2023-08-15T23:40:31
2023-08-15T23:40:31
41,717,977
5
1
null
null
null
null
UTF-8
C++
false
false
4,769
h
// Copyright 2018 The Chromium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // This file defines the browser-specific base::FeatureList features that are // not shared with other process types. #ifndef CHROME_BROWSER_BROWSER_FEATURES_H_ #define CHROME_BROWSER_BROWSER_FEATURES_H_ #include "base/feature_list.h" #include "base/metrics/field_trial_params.h" #include "build/build_config.h" #include "build/chromeos_buildflags.h" namespace features { // All features in alphabetical order. The features should be documented // alongside the definition of their values in the .cc file. BASE_DECLARE_FEATURE(kClosedTabCache); BASE_DECLARE_FEATURE(kDestroyProfileOnBrowserClose); BASE_DECLARE_FEATURE(kDestroySystemProfiles); BASE_DECLARE_FEATURE(kDevToolsTabTarget); BASE_DECLARE_FEATURE(kNukeProfileBeforeCreateMultiAsync); BASE_DECLARE_FEATURE(kPromoBrowserCommands); extern const char kBrowserCommandIdParam[]; #if BUILDFLAG(IS_CHROMEOS_ASH) BASE_DECLARE_FEATURE(kQuickSettingsPWANotifications); #endif #if BUILDFLAG(IS_CHROMEOS) BASE_DECLARE_FEATURE(kDoubleTapToZoomInTabletMode); #endif #if BUILDFLAG(IS_MAC) BASE_DECLARE_FEATURE(kEnableUniveralLinks); #endif #if !BUILDFLAG(IS_ANDROID) BASE_DECLARE_FEATURE(kCopyLinkToText); BASE_DECLARE_FEATURE(kMuteNotificationSnoozeAction); #endif BASE_DECLARE_FEATURE(kSandboxExternalProtocolBlocked); BASE_DECLARE_FEATURE(kSandboxExternalProtocolBlockedWarning); BASE_DECLARE_FEATURE(kTriggerNetworkDataMigration); #if BUILDFLAG(IS_CHROMEOS) BASE_DECLARE_FEATURE(kTabCaptureBlueBorderCrOS); #endif BASE_DECLARE_FEATURE(kWebUsbDeviceDetection); BASE_DECLARE_FEATURE(kCertificateTransparencyAskBeforeEnabling); BASE_DECLARE_FEATURE(kLargeFaviconFromGoogle); extern const base::FeatureParam<int> kLargeFaviconFromGoogleSizeInDip; BASE_DECLARE_FEATURE(kRestartNetworkServiceUnsandboxedForFailedLaunch); BASE_DECLARE_FEATURE(kKeyPinningComponentUpdater); #if BUILDFLAG(IS_WIN) BASE_DECLARE_FEATURE(kAppBoundEncryptionMetrics); BASE_DECLARE_FEATURE(kLockProfileCookieDatabase); #endif BASE_DECLARE_FEATURE(kFlexOrgManagementDisclosure); BASE_DECLARE_FEATURE(kFedCmWithoutThirdPartyCookies); BASE_DECLARE_FEATURE(kIncomingCallNotifications); // This flag is used for enabling Omnibox triggered prerendering. See // crbug.com/1166085 for more details of Omnibox triggered prerendering. BASE_DECLARE_FEATURE(kOmniboxTriggerForPrerender2); // This flag is used for enabling Bookmark triggered prerendering. See // crbug.com/1422819 for more details of Bookmark triggered prerendering. BASE_DECLARE_FEATURE(kBookmarkTriggerForPrerender2); // This flag is used for enabling New Tab Page triggered prerendering. See // crbug.com/1462832 for more details of New Tab Page triggered prerendering. BASE_DECLARE_FEATURE(kNewTabPageTriggerForPrerender2); // This parameter is used to set a time threshold for triggering onMouseHover // prerender. For example, if the value is 300, the New Tab Page prerender // will start after 300ms after mouseHover duration is over 300ms. const base::FeatureParam<int> kNewTabPagePrerenderStartDelayOnMouseHoverByMiliSeconds{ &features::kNewTabPageTriggerForPrerender2, "prerender_start_delay_on_mouse_hover_ms", 300}; // This flag controls whether to trigger prerendering when the default search // engine suggests to prerender a search result. BASE_DECLARE_FEATURE(kSupportSearchSuggestionForPrerender2); enum class SearchSuggestionPrerenderImplementationType { kUsePrefetch, kIgnorePrefetch, }; extern const base::FeatureParam<SearchSuggestionPrerenderImplementationType> kSearchSuggestionPrerenderImplementationTypeParam; // Indicates whether to make search prefetch response shareable to prerender. // When allowing this, prerender can only copy the cache but cannot take over // the ownership. enum class SearchPreloadShareableCacheType { kEnabled, kDisabled, }; extern const base::FeatureParam<SearchPreloadShareableCacheType> kSearchPreloadShareableCacheTypeParam; // Disables prerendering on the default search engine predictor. This is useful // in comparing the impact of the SupportSearchSuggestionForPrerender2 feature // during its rollout. Once that rollout is complete, this feature should be // removed and instead we should add a new long-term holdback to // PreloadingConfig. BASE_DECLARE_FEATURE(kPrerenderDSEHoldback); // This is used to enable an experiment for modifying confidence cutoff of // prerender and preconnect for autocomplete action predictor. BASE_DECLARE_FEATURE(kAutocompleteActionPredictorConfidenceCutoff); BASE_DECLARE_FEATURE(kOmniboxTriggerForNoStatePrefetch); } // namespace features #endif // CHROME_BROWSER_BROWSER_FEATURES_H_
3414f9c5204dc0dd8b73db4831962151dc343f8c
8f7a7230ebab1205770b64691c5273c320792460
/build-gamesystem-Desktop_Qt_5_14_2_MinGW_64_bit-Debug/ui_testinfodialog.h
e7b7cb87d1693f02af9b1539542670a22cc4783d
[]
no_license
GameRushGo/Terminal-Test
1b479c1485d62ffbb97f0cda68a90a2274cef529
02341e11077844a34c33c238bf219e47bb92e3e3
refs/heads/master
2021-05-20T01:36:48.487300
2020-05-29T23:55:57
2020-05-29T23:55:57
252,129,625
0
0
null
null
null
null
UTF-8
C++
false
false
6,698
h
/******************************************************************************** ** Form generated from reading UI file 'testinfodialog.ui' ** ** Created by: Qt User Interface Compiler version 5.14.2 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ #ifndef UI_TESTINFODIALOG_H #define UI_TESTINFODIALOG_H #include <QtCore/QVariant> #include <QtWidgets/QApplication> #include <QtWidgets/QDialog> #include <QtWidgets/QHBoxLayout> #include <QtWidgets/QHeaderView> #include <QtWidgets/QPushButton> #include <QtWidgets/QTableWidget> #include <QtWidgets/QWidget> QT_BEGIN_NAMESPACE class Ui_TestInfoDialog { public: QTableWidget *tableWidget; QWidget *layoutWidget; QHBoxLayout *horizontalLayout; QPushButton *pushButton; QPushButton *pushButton_2; QPushButton *pushButton_3; QPushButton *pushButton_4; void setupUi(QDialog *TestInfoDialog) { if (TestInfoDialog->objectName().isEmpty()) TestInfoDialog->setObjectName(QString::fromUtf8("TestInfoDialog")); TestInfoDialog->resize(1028, 473); tableWidget = new QTableWidget(TestInfoDialog); if (tableWidget->columnCount() < 9) tableWidget->setColumnCount(9); QTableWidgetItem *__qtablewidgetitem = new QTableWidgetItem(); tableWidget->setHorizontalHeaderItem(0, __qtablewidgetitem); QTableWidgetItem *__qtablewidgetitem1 = new QTableWidgetItem(); tableWidget->setHorizontalHeaderItem(1, __qtablewidgetitem1); QTableWidgetItem *__qtablewidgetitem2 = new QTableWidgetItem(); tableWidget->setHorizontalHeaderItem(2, __qtablewidgetitem2); QTableWidgetItem *__qtablewidgetitem3 = new QTableWidgetItem(); tableWidget->setHorizontalHeaderItem(3, __qtablewidgetitem3); QTableWidgetItem *__qtablewidgetitem4 = new QTableWidgetItem(); tableWidget->setHorizontalHeaderItem(4, __qtablewidgetitem4); QTableWidgetItem *__qtablewidgetitem5 = new QTableWidgetItem(); tableWidget->setHorizontalHeaderItem(5, __qtablewidgetitem5); QTableWidgetItem *__qtablewidgetitem6 = new QTableWidgetItem(); tableWidget->setHorizontalHeaderItem(6, __qtablewidgetitem6); QTableWidgetItem *__qtablewidgetitem7 = new QTableWidgetItem(); tableWidget->setHorizontalHeaderItem(7, __qtablewidgetitem7); QTableWidgetItem *__qtablewidgetitem8 = new QTableWidgetItem(); tableWidget->setHorizontalHeaderItem(8, __qtablewidgetitem8); tableWidget->setObjectName(QString::fromUtf8("tableWidget")); tableWidget->setGeometry(QRect(30, 20, 911, 321)); layoutWidget = new QWidget(TestInfoDialog); layoutWidget->setObjectName(QString::fromUtf8("layoutWidget")); layoutWidget->setGeometry(QRect(330, 370, 320, 25)); horizontalLayout = new QHBoxLayout(layoutWidget); horizontalLayout->setObjectName(QString::fromUtf8("horizontalLayout")); horizontalLayout->setContentsMargins(0, 0, 0, 0); pushButton = new QPushButton(layoutWidget); pushButton->setObjectName(QString::fromUtf8("pushButton")); horizontalLayout->addWidget(pushButton); pushButton_2 = new QPushButton(layoutWidget); pushButton_2->setObjectName(QString::fromUtf8("pushButton_2")); horizontalLayout->addWidget(pushButton_2); pushButton_3 = new QPushButton(layoutWidget); pushButton_3->setObjectName(QString::fromUtf8("pushButton_3")); horizontalLayout->addWidget(pushButton_3); pushButton_4 = new QPushButton(layoutWidget); pushButton_4->setObjectName(QString::fromUtf8("pushButton_4")); horizontalLayout->addWidget(pushButton_4); retranslateUi(TestInfoDialog); QMetaObject::connectSlotsByName(TestInfoDialog); } // setupUi void retranslateUi(QDialog *TestInfoDialog) { TestInfoDialog->setWindowTitle(QCoreApplication::translate("TestInfoDialog", "\350\242\253\350\257\225\344\277\241\346\201\257", nullptr)); QTableWidgetItem *___qtablewidgetitem = tableWidget->horizontalHeaderItem(0); ___qtablewidgetitem->setText(QCoreApplication::translate("TestInfoDialog", "\347\273\204", nullptr)); QTableWidgetItem *___qtablewidgetitem1 = tableWidget->horizontalHeaderItem(1); ___qtablewidgetitem1->setText(QCoreApplication::translate("TestInfoDialog", "\347\240\224\347\251\266", nullptr)); QTableWidgetItem *___qtablewidgetitem2 = tableWidget->horizontalHeaderItem(2); ___qtablewidgetitem2->setText(QCoreApplication::translate("TestInfoDialog", "\345\247\223\345\220\215", nullptr)); QTableWidgetItem *___qtablewidgetitem3 = tableWidget->horizontalHeaderItem(3); ___qtablewidgetitem3->setText(QCoreApplication::translate("TestInfoDialog", "\350\272\253\344\273\275\350\257\201\345\217\267", nullptr)); QTableWidgetItem *___qtablewidgetitem4 = tableWidget->horizontalHeaderItem(4); ___qtablewidgetitem4->setText(QCoreApplication::translate("TestInfoDialog", "\350\201\224\347\263\273\347\224\265\350\257\235", nullptr)); QTableWidgetItem *___qtablewidgetitem5 = tableWidget->horizontalHeaderItem(5); ___qtablewidgetitem5->setText(QCoreApplication::translate("TestInfoDialog", "\350\201\224\347\263\273\346\226\271\345\274\217", nullptr)); QTableWidgetItem *___qtablewidgetitem6 = tableWidget->horizontalHeaderItem(6); ___qtablewidgetitem6->setText(QCoreApplication::translate("TestInfoDialog", "\347\217\255\347\272\247", nullptr)); QTableWidgetItem *___qtablewidgetitem7 = tableWidget->horizontalHeaderItem(7); ___qtablewidgetitem7->setText(QCoreApplication::translate("TestInfoDialog", "\344\275\223\351\207\215", nullptr)); QTableWidgetItem *___qtablewidgetitem8 = tableWidget->horizontalHeaderItem(8); ___qtablewidgetitem8->setText(QCoreApplication::translate("TestInfoDialog", "\350\247\206\345\212\233", nullptr)); pushButton->setText(QCoreApplication::translate("TestInfoDialog", "\346\226\260\345\242\236", nullptr)); pushButton_2->setText(QCoreApplication::translate("TestInfoDialog", "\344\277\256\346\224\271", nullptr)); pushButton_3->setText(QCoreApplication::translate("TestInfoDialog", "\345\210\240\351\231\244", nullptr)); pushButton_4->setText(QCoreApplication::translate("TestInfoDialog", "\347\241\256\345\256\232", nullptr)); } // retranslateUi }; namespace Ui { class TestInfoDialog: public Ui_TestInfoDialog {}; } // namespace Ui QT_END_NAMESPACE #endif // UI_TESTINFODIALOG_H
752aece2b7f018a4377f83efd36568946f9a6b35
97cb1e6cd69c700fca2b55f0ecfa53213c98d2cf
/src/main.cpp
078c32e0e5883ca963791457f7d31cf6dea51d5b
[]
no_license
brenthaas/glow_bed
78e4bc14b7b83aa2b096bd5b9430c7a5d136ad7b
fe70130fba11f377717028db1e620511feb93ab8
refs/heads/master
2021-04-28T04:59:28.165398
2018-02-20T07:58:56
2018-02-20T07:58:56
122,169,829
0
0
null
null
null
null
UTF-8
C++
false
false
3,510
cpp
// NeoPixelFunRandomChange // This example will randomly select a number pixels and then // start an animation to blend them from their current color to // randomly selected a color // #include <NeoPixelBus.h> #include <NeoPixelAnimator.h> #define BUTTON_PIN 5 #define DEBOUNCE_DELAY 100 // in ms const uint16_t PixelCount = 300; // make sure to set this to the number of pixels in your strip // const uint8_t PixelPin = 2; // make sure to set this to the correct pin, ignored for Esp8266 // NeoPixelBus<NeoGrbFeature, Neo800KbpsMethod> strip(PixelCount, PixelPin); // For Esp8266, the Pin is omitted and it uses GPIO3 due to DMA hardware use. // There are other Esp8266 alternative methods that provide more pin options, but also have // other side effects. NeoPixelBus<NeoGrbFeature, Neo800KbpsMethod> strip(PixelCount); // // NeoEsp8266Uart800KbpsMethod uses GPI02 instead NeoPixelAnimator animations(PixelCount); // NeoPixel animation management object // what is stored for state is specific to the need, in this case, the colors. // Basically what ever you need inside the animation update function struct MyAnimationState { RgbColor StartingColor; RgbColor EndingColor; }; // one entry per pixel to match the animation timing manager MyAnimationState animationState[PixelCount]; void SetRandomSeed() { uint32_t seed; // random works best with a seed that can use 31 bits // analogRead on a unconnected pin tends toward less than four bits seed = analogRead(0); delay(1); for (int shifts = 3; shifts < 31; shifts += 3) { seed ^= analogRead(0) << shifts; delay(1); } // Serial.println(seed); randomSeed(seed); } // simple blend function void BlendAnimUpdate(const AnimationParam& param) { // this gets called for each animation on every time step // progress will start at 0.0 and end at 1.0 // we use the blend function on the RgbColor to mix // color based on the progress given to us in the animation RgbColor updatedColor = RgbColor::LinearBlend( animationState[param.index].StartingColor, animationState[param.index].EndingColor, param.progress); // apply the color to the strip strip.SetPixelColor(param.index, updatedColor); } void PickRandom(float luminance) { // pick random count of pixels to animate uint16_t count = random(PixelCount); while (count > 0) { // pick a random pixel uint16_t pixel = random(PixelCount); // pick random time and random color // we use HslColor object as it allows us to easily pick a color // with the same saturation and luminance uint16_t time = random(100, 400); animationState[pixel].StartingColor = strip.GetPixelColor(pixel); animationState[pixel].EndingColor = HslColor(random(360) / 360.0f, 1.0f, luminance); animations.StartAnimation(pixel, time, BlendAnimUpdate); count--; } } void setup() { strip.Begin(); strip.Show(); SetRandomSeed(); } void loop() { if (animations.IsAnimating()) { // the normal loop just needs these two to run the active animations animations.UpdateAnimations(); strip.Show(); } else { // no animations runnning, start some // PickRandom(0.2f); // 0.0 = black, 0.25 is normal, 0.5 is bright } }
d3992bebeff51d923296054210c4c19f70c638eb
52c55243b1d89568ee0eb89f4bab9b35b430e609
/CharList.cpp
d1524640183104845fa6496f7b1506e0b4764ed7
[]
no_license
bclarkx2/Hangman
3dbee508c3593cd798e2b7715f34b58628237a28
463ad38e7dc1f3b6f94e44ae33204760fafae8ac
refs/heads/master
2016-08-11T22:07:15.979009
2015-12-30T17:28:49
2015-12-30T17:28:49
44,405,573
0
0
null
null
null
null
UTF-8
C++
false
false
3,430
cpp
#include "CharList.h" CharList::CharList(void) { } /*******Get/set Methods*********/ vector<CharInList> CharList::getList() { return list; } void CharList::setList(vector<CharInList> newList) { list = newList; } /********Class functions*******/ //none /******Member functions********/ /** * Compares two lists of characters. Goes to each character and compares the char/bool tuple. * Returns true if they match for every character. */ bool CharList::equals(CharList c) { for(int i = 0; i < c.getList().size(); i++) { if(!getList()[i].equals(c.getList()[i])) { return false; } } return true; } /** * A CharList is defined only if its list field stores a vector of charInList objects */ bool CharList::isDefined() { return !getList().empty(); } /** * Makes the CharList blank. Every character is set to not present. */ void CharList::initialize() { vector<CharInList> newList = vector<CharInList>(); //Brand new charInList vector for(int i = ASCIIstart; i <= ASCIIend; i++) { //Add a charInList for every ASCII character CharInList cin = CharInList(static_cast<char>(i), false); newList.push_back(cin); } setList(newList); } /** * Sets the CharList to reflect a given phrase. Wipes out previous information */ void CharList::initialize(vector<string> phrase) { //Set blank initialize(); update(phrase); } /** * Adds characters from the phrase to the CharList. Does not wipe out previous information */ void CharList::update(vector<string> phrase) { vector<CharInList> cList = getList(); //Update the vector for the new phrase for(int i = 0; i < phrase.size(); i++){ //Cycle through all words in phrase string s = phrase[i]; //Current string in phrase for(int j = 0; j < s.size(); j++) { //Access each character in the string char currentChar = s[j]; //Char value under consideration int currentIntValueOfChar = static_cast<int>(currentChar); //Int value of that char int currentIndexOnCharList = currentIntValueOfChar - ASCIIstart; //Index in the charList cList[currentIndexOnCharList].setIsPresent(true); //Since we are looking at a manifestation of that char, it is obviously present in the phrase } } setList(cList); } /** * Identifies if a given character is marked as present in the CharList * c the character to be checked * returns a bool indicating whether the character is in fact present */ bool CharList::contains(char c) { int n = static_cast<int>(c) - ASCIIstart; return getList()[static_cast<int>(n)].getIsPresent(); } /** * Takes a character and marks it as present in the CharList * c the character to the be marked present */ void CharList::add(char c) { int n = static_cast<int>(c); if(n <= ASCIIend && n >= ASCIIstart) { vector<CharInList> cList = getList(); int m = n - ASCIIstart; cList[static_cast<int>(m)].setIsPresent(true); setList(cList); } }
81a1e7033d6d966a6e9e624c11469361a364abee
bdaa913efe6ab15f5002377f764ae0e657a12908
/src/griddock/bMC.cpp
63fd4e4197b3cb2cc93c3df9575eedfd172bd4db
[]
no_license
molecularmodelinglaboratory/snapp-cracle-popp
1ecf8e90a95ac1b30b79840001fe07d9037635e1
cd14d44bc45819c004d5a204fa9cdc3084af5c50
refs/heads/master
2016-09-10T14:31:17.552661
2011-06-14T14:33:16
2011-06-14T14:33:16
null
0
0
null
null
null
null
UTF-8
C++
false
false
14,966
cpp
#include <deque> #include <list> #include <fstream> #include <sstream> #include <string.h> #include <stdio.h> #include "bMC.h" #include "bCalc.h" #include "bHex.h" #include "bDelTess.h" #include "bGrid.h" #include "bPoints.h" #include "bSort.h" #include "bList.h" using namespace std; using namespace bStd; bMC::bMC( bGrid* g, bPoints* s, bConf* p ) : orgGrd_(g), orgSrc_(s), orgPep_(p), havePerturbSchema_(false), perturbSchema_(NULL), perturbDone_(NULL), numOpt_(0), threshold_(0.0), numIter_(1000) { this->perturbRangeMin_[0] = -2; this->perturbRangeMin_[1] = -2; this->perturbRangeMin_[2] = -2; this->perturbRangeMax_[0] = 2; this->perturbRangeMax_[1] = 2; this->perturbRangeMax_[2] = 2; this->currPnt_ = 0; this->currPtb_ = 0; //~ if( c == NULL ) { myList_ = true; this->conf_ = new bList; } //~ this->confSc_ = NULL; //~ this->confOr_ = NULL; } bMC::bMC( const bMC& rhs ) : orgGrd_(NULL), orgSrc_(NULL), orgPep_(NULL), havePerturbSchema_(false), perturbSchema_(NULL), perturbDone_(NULL), numOpt_(0) { this->orgGrd_ = rhs.orgGrd_; this->orgSrc_ = rhs.orgSrc_; this->orgPep_ = rhs.orgPep_; //~ this->confSc_ = new float[ this->conf_->size() ]; //~ this->confOr_ = new int[ this->conf_->size() ]; //~ for( uint i=0; i < this->conf_->size(); ++i ) { //~ this->confSc_[i] = rhs.confSc_[i]; //~ this->confOr_[i] = rhs.confOr_[i]; //~ } } bMC::~bMC() { if( this->perturbSchema_ != NULL ) { for( int i=0; i < this->numOpt_; ++i ) { if( this->perturbSchema_[i] != NULL ) { delete [] this->perturbSchema_[i]; this->perturbSchema_[i] = NULL; } } delete [] this->perturbSchema_; this->perturbSchema_ = NULL; } if( this->perturbDone_ != NULL ) { for( int i=0; i < this->orgPep_->pp_->numPnts_; ++i ) { if( this->perturbDone_[i] != NULL ) { delete this->perturbDone_[i]; this->perturbDone_[i] = NULL; } } delete [] this->perturbDone_; this->perturbDone_ = NULL; } //~ if( this->confSc_ != NULL ) { delete [] this->confSc_; this->confSc_ = NULL; } //~ if( this->confOr_ != NULL ) { delete [] this->confOr_; this->confOr_ = NULL; } //~ this->gpnts.clear(); this->orgGrd_ = NULL; this->orgSrc_ = NULL; this->orgPep_ = NULL; } void bMC::clear() { //~ if( this->perturbSchema_ != NULL ) { //~ for( int i=0; i < this->numOpt_; ++i ) { //~ if( this->perturbSchema_[i] != NULL ) { //~ delete [] this->perturbSchema_[i]; //~ this->perturbSchema_[i] = NULL; //~ } //~ } //~ delete [] this->perturbSchema_; //~ this->perturbSchema_ = NULL; //~ } //~ if( this->confSc_ != NULL ) { delete [] this->confSc_; this->confSc_ = NULL; } //~ if( this->confOr_ != NULL ) { delete [] this->confOr_; this->confOr_ = NULL; } for( int i=0; i < this->orgPep_->pp_->numPnts_; ++i ) { this->perturbDone_[i]->erase(); } this->orgGrd_ = NULL; this->orgSrc_ = NULL; this->orgPep_ = NULL; } void bMC::setup( const bGrid &grd, const bPoints &src, bConf &pep ) { this->orgGrd_ = &grd; this->orgSrc_ = &src; this->orgPep_ = &pep; //~ pep.print(); return; } bool bMC::metropolis() { //~ this->orgPep_->pp_->print(); const bPoints* sor = this->orgSrc_; bPoints* pep = this->orgPep_->pp_; int num = this->orgPep_->pp_->numPnts_; float scr = this->orgPep_->sc_; bList* conf = this->orgPep_->new_chld(); this->perturbTested_ = 0; ushort allTested = (1 >> num) - 1; // Declare and initialize the original set //~ bConf clean; //~ *clean.pp_ = *pep; // Setup stock bPoints* nearby = new bPoints; pep->findNearbyPoints( *sor, *nearby, true ); bPoints* dtsrc[2] = { nearby, pep }; bDelTess** dtstock = new bDelTess*[ num ]; for( int i=0; i < num; ++i ) { dtstock[i] = new bDelTess; dtstock[i]->tessellate_l1o( dtsrc, 2, 2, i ); //~ dtstock[i]->verify(); //~ dtstock[i]->findEdges(); //~ char name[32]; sprintf( name, "p%d", i); //~ char color[32] = "red"; //~ FILE *op = fopen("d2.py", "a"); //~ dtstock[i]->pymolDelTess( op, name, color ); //~ fclose(op); //~ printf("size: %d | %d | %d\n", dtstock[i]->src_[0]->numPnts_,dtstock[i]->src_[1]->numPnts_,dtstock[i]->src_[2]->numPnts_); } //~ exit(1); // Setup Perturb int min[3] = { -3, -3, -3 }, max[3] = { 3, 3, 3 }; this->setupPerturb( min, max ); // Perform set number of iterations this->numIter_ = this->numOpt_; this->numIter_ *= num; // temporary!! this->numIter_ *= .2; //~ numIter_ = 26; //~ bList conf; int ppt = 0; bool valid = false; for( uint i=0; i < this->numIter_; ++i ) { bConf* curr = new bConf( *(pep) ); // Perturb if( (ppt = this->perturb( *curr )) != -1) { // Copy and finish tessellation //~ printf("point: %d\n",ppt); //~ printf("[%d] size: %d | %d | %d\n", ppt, dtstock[ppt]->src_[0]->numPnts_,dtstock[ppt]->src_[1]->numPnts_,dtstock[ppt]->src_[2]->numPnts_); bDelTess dt( *(dtstock[ ppt ]) ); valid = dt.tessellate_l1o_fin( curr->pp_, 2, 2 ); //~ dt.score(); //~ conf->print(); //~ curr->print(); //~ char name[32]; sprintf( name, "pf%d_%d",ppt,i); //~ char color[32] = "red"; //~ FILE *op = fopen("d2.py", "a"); //~ dt.verify(); //~ dt.isVerified_ = true; //~ dt.findEdges(); //~ dt.pymolDelTess( op, name, color ); //~ dtstock[ppt]->verify(); //~ dtstock[ppt]->findEdges(); //~ dtstock[ppt]->pymolDelTess( op, name, color ); //~ fclose(op); // Test and score if( !valid ) { --i; continue; } else { if( dt.score() > scr ) { curr->sc_ = dt.score(); conf->push_back( curr ); } //~ else { printf("score too low: %.2f < %.2f\n",dt.score(), scr); } } } else if( this->perturbTested_ != allTested ) { break; } else { --i; } curr = NULL; } //~ conf->print(); printf("done bMC...%d | %d\n",conf->num(),conf->cap()); bool done = false; if( !conf->empty() ) { conf->sort(); done = true; } for( int i=0; i < num; ++i ) { delete dtstock[i]; dtstock[i] = NULL; } delete [] dtstock; dtstock = NULL; pep = NULL; conf = NULL; sor = NULL; //~ conf->print(); //~ printf("%.2f\t%.2f\n", (*conf)[0].sc_, (*conf)[1].sc_); //~ printf("%u\t%u\n%u\n%u\n\n", &(*conf)[0], &(*conf)[1], conf->beg(),conf->end()); return done;// > 0 ? true : false; } void bMC::setupPerturb( const int min[3], const int max[3] ) { int num = this->orgPep_->pp_->numPnts_; // Calculate the range & the total number of options int range[3] = { max[0] - min[0], max[1] - min[1], max[2] - min[2] }; ++range[0]; ++range[1]; ++range[2]; this->numOpt_ = range[0]; this->numOpt_ *= range[1]; this->numOpt_ *= range[2]; --this->numOpt_; // Setup the perturbation matrix this->perturbSchema_ = new int* [this->numOpt_]; int x = 0; for( int i=min[0]; i <= max[0]; ++i ) { for( int k=min[1]; k <= max[1]; ++k ) { for( int m=min[2]; m <= max[2]; ++m ) { if( i == 0 && k == 0 && m == 0 ) continue; this->perturbSchema_[x] = new int [3]; this->perturbSchema_[x][0] = i; this->perturbSchema_[x][1] = k; this->perturbSchema_[x][2] = m; ++x; } } } // Setup the perturbation checklist this->perturbDone_ = new bHex* [num]; for( int i=0; i < num; ++i ) { this->perturbDone_[i] = new bHex( this->numOpt_ ); } this->currPnt_ = 0; this->currPtb_ = 0; // Save the variables this->perturbRangeMin_[0] = min[0]; this->perturbRangeMin_[1] = min[1]; this->perturbRangeMin_[2] = min[2]; this->perturbRangeMax_[0] = max[0]; this->perturbRangeMax_[1] = max[1]; this->perturbRangeMax_[2] = max[2]; this->numOpt_ = x; this->havePerturbSchema_ = true; return; } int bMC::perturb( bConf &mod ) { if( !this->havePerturbSchema_ ) { this->setupPerturb( this->perturbRangeMin_, this->perturbRangeMax_); } //~ printf("\nPertub:\n"); //~ for( uint i=0; i < perturbDone_.size(); ++i ) { //~ printf("\t[%u]\t",i); //~ if( perturbDone_[i].empty() ) { printf("\n"); continue; } //~ for( list<ushort>::iterator it = perturbDone_[i].begin(); it != perturbDone_[i].end(); ++it ) { //~ printf("%u\t",*it); //~ } //~ printf("\n"); //~ } float ptrb[3] = { 0.0, 0.0, 0.0 }; bPoints* mpt = mod.pp_; int whichPnt = 0; ushort whichPtb = 0; bool valid = false; int numAttempts = 0; //~ printf("perturb [%lu] ", this->perturbDone_.size()); //~ printf("[%lu]", this->perturbDone_[currPnt_].size()); //~ printf("num [%d] [%d]\n", mpt->numPnts_, this->numOpt_); do { // Randomly choose the point and perturbation //~ printf("num: %d\n", mpt->numPnts_); whichPnt = bCalc::getRandomNumber( mpt->numPnts_ ); whichPtb = bCalc::getRandomNumber( this->numOpt_ ); // Deterministic //~ whichPnt = this->currPnt_; //~ whichPtb = this->currPtb_; //~ printf("[%u ~ %u]\t[%u ~ %u]\n", whichPnt, currPnt_, whichPtb, currPtb_); //~ mpt->print(); //~ printf("size of perturb: %d, [ %d ]\n", this->perturbDone_.size(), whichPnt); // Check that the perturbation hasn't been done before if( !(*(this->perturbDone_[ whichPnt ]) & whichPtb) ) { //~ printf("No elements [%u]\t",whichPnt); valid = true; *(this->perturbDone_[ whichPnt ]) |= whichPtb; } //~ else { //~ printf("Elements [%u, %lu]\t",whichPnt,this->perturbDone_[whichPnt].size()); //~ it = this->perturbDone_[ whichPnt ].begin(); //~ int cnt = 0; //~ while( *it < whichPtb && it != this->perturbDone_[ whichPnt ].end() ) { ++it; }//printf("%u > %u\n",*it, whichPtb); if( ++cnt > 10 ) exit(1); } //~ if( *it != whichPtb ) { //~ valid = true; //~ this->perturbDone_[ whichPnt ].insert( it, whichPtb ); //~ } //~ } if( valid ) { //~ printf("Doing : [%u, %u]\n", whichPnt, whichPtb); int wpX = whichPnt; wpX *= 3; ptrb[0] = mpt->pnts_[wpX]; ++wpX; ptrb[1] = mpt->pnts_[wpX]; ++wpX; ptrb[2] = mpt->pnts_[wpX]; ptrb[0] += this->perturbSchema_[ whichPtb ][0]; ptrb[1] += this->perturbSchema_[ whichPtb ][1]; ptrb[2] += this->perturbSchema_[ whichPtb ][2]; valid = this->orgGrd_->isaGridPoint( ptrb ); } //~ else { //~ printf("Already done: [%u, %u]\n", whichPnt, whichPtb); //~ } // Deterministic //~ if( !valid ) { //~ ++this->currPtb_; //~ if( this->currPtb_ == this->numOpt_ ) { ++this->currPnt_; this->currPtb_ = 0;} //~ if( this->currPnt_ == mpt->numPnts_ ) break; //~ } if( ++numAttempts > 600 ) { break; } } while( !valid ); if( valid ) { int wpX = whichPnt; wpX *= 3; mpt->pnts_[wpX] = ptrb[0]; ++wpX; mpt->pnts_[wpX] = ptrb[1]; ++wpX; mpt->pnts_[wpX] = ptrb[2]; //~ whichPnt /= 3; } else { this->perturbTested_ |= ( 1 >> whichPnt ); whichPnt = -1; } //~ printf("perturb: %d | %d [ %d, %d, %d ]\n",whichPnt, whichPtb, perturbSchema_[ whichPtb ][0], perturbSchema_[ whichPtb ][1], perturbSchema_[ whichPtb ][2] ); //~ printf("num: %d\n",mod.numPnts_); // Deterministic //~ ++this->currPtb_; //~ if( this->currPtb_ == this->numOpt_ ) { ++this->currPnt_; this->currPtb_ = 0; } //~ printf("\n"); return whichPnt; } //~ void bMC::pymol( FILE* op, char name[], char color[] ) { //~ printf("here\n"); //~ uint size = this->conf_->size() < 5 ? this->conf_->size() : 5; //~ uint len = strlen( name ); len += 5; //~ // Setup color gradient //~ char* gradient[size]; //~ float red = 1.0; //~ float grn = 0.0; //~ float inc = 1.0 / size; //~ for( uint i=0; i < size; ++i ) { //~ gradient[i] = new char[ len ]; //~ memset( gradient[i], '\0', len ); //~ sprintf( gradient[i], "%s%04u", name, i ); //~ fprintf( op, "cmd.set_color(\"%s\", [1.00, %.4f, 0.0])\n",gradient[i],grn ); //~ grn += inc; //~ } //~ char nameFull[32]; //~ char scr[7]; //~ memset( nameFull, '\0', 32 ); //~ bConf* it = this->conf_->beg(); //~ bConf* bk = this->conf_->end(); //~ for( uint i=0; it != bk && i < size; ++i, it=it->next() ) { //~ sprintf( nameFull, "%s_conf%02u", name, i ); //~ sprintf( scr, "%.2f", it->sc_ ); //~ it->pp_->setToNormalSpace(); //~ it->pp_->pymolConnectedPseudoatoms( op, nameFull, gradient[i], 1, scr ); //~ } //~ } /******************************************************* bMC_MetTable */ bMC_MetTable::bMC_MetTable() : delt_(NULL), prob_(NULL) {} bMC_MetTable::~bMC_MetTable() { if( this->delt_ != NULL ) { delete [] this->delt_; this->delt_ = NULL; } if( this->prob_ != NULL ) { delete [] this->prob_; this->prob_ = NULL; } } float bMC_MetTable::operator[]( float find ) { if( this->delt_ == NULL || this->prob_ == NULL ) { throw "[bMC::MT] Please identify a Metropolis table"; } ushort end = this->size_; ushort med = end; med >>= 1; ushort beg = 0; ushort at = end; bool found = false; for( uint i=0; i < 4 && (beg != med || end != med); ++i ) { if( this->delt_[med] > find ) { beg = med; med >>= 1; med += beg; } else if( this->delt_[med] < find ) { end = med; med >>= 1; } else { at = med; i = 2; found = true;} } for( ushort i=beg; i < end && !found; ++i ) { if( find <= this->delt_[i] ) { at = i; found = true; } } //~ if( at > 0 ) { --at; } return this->prob_[at]; } void bMC_MetTable::read( char file[] ) { // open the file ifstream ip; ip.open(file, ifstream::in); if(!ip) { return; } // Read in data deque<string> data; string bffr; uint i = 0; for( i = 0; getline( ip, bffr ); ++i ) { data.push_back(bffr); } ip.close(); // Resize data structures if( this->delt_ != NULL ) { delete [] this->delt_; this->delt_ = NULL; } if( this->prob_ != NULL ) { delete [] this->prob_; this->prob_ = NULL; } this->delt_ = new float[i]; this->prob_ = new float[i]; // loop through each line and save the coordinates for( i = 0; i < data.size(); ++i ) { istringstream ss(data[i]); ss >> this->delt_[i]; ss >> this->prob_[i]; } return; }
3d6cba161e5d3066d459a42dc0d0f1ec04707f11
ea35c4e6a3754b86c236ad67829aff5bca7338e5
/ultrasound/ultrasound/test.cpp
f02aa51c0e5fa2f3fb092cbb731007bdc6f6201a
[]
no_license
arbiben/opensource_ultrasound
3e9047659a639943af49ee47948eceeee2e0952a
d5983948f3c410fad744426c8c06e1eddfc92c77
refs/heads/master
2020-03-31T10:36:56.476665
2018-12-09T02:33:47
2018-12-09T02:33:47
152,141,221
0
0
null
null
null
null
UTF-8
C++
false
false
4,341
cpp
// // test.cpp // ultrasound // // Created by Ben Arbib on 11/2/18. // Copyright © 2018 Ben Arbib. All rights reserved. // #include "test.hpp" #include <GLUT/glut.h> #include <OpenGL/OpenGL.h> #include <math.h> #include <stdio.h> // ---------------------------------------------------------- // Global Variables // ---------------------------------------------------------- // For rotate cube double rotate_y = 0; double rotate_x = 0; // For moving probe double step = -0.02; double height = 0;    // For dragging the view static float c=M_PI/180.0f; static int du=90,oldmy=-1,oldmx=-1; //du - angle wrt y axis, y is up in OpenGL static float r=1.5f,h=0.0f;    void display(void) { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glLoadIdentity(); gluLookAt(r*cos(c*du), h, r*sin(c*du), 0, 0, 0, 0, 1, 0); glPushMatrix(); glTranslatef(0, height, 0); // Probe - Straight Line glBegin(GL_LINES); glLineWidth(3.0); glColor3f(1.0, 0.0, 0.0); glVertex3f(-0.7, 0.0, 0.0); glVertex3f(0.7, 0.0, 0.0); glEnd(); glPopMatrix(); glPushMatrix(); // Rotate when user changes rotate_x and rotate_y glRotatef( rotate_x, 1.0, 0.0, 0.0 ); glRotatef( rotate_y, 0.0, 1.0, 0.0 ); // Yellow side - FRONT glBegin(GL_POLYGON); glColor3f( 1.0, 1.0, 0.0 ); glVertex3f( 0.3, -0.3, -0.3 ); glVertex3f( 0.3, 0.3, -0.3 ); glVertex3f( -0.3, 0.3, -0.3 ); glVertex3f( -0.3, -0.3, -0.3 ); glEnd(); // White side - BACK glBegin(GL_POLYGON); glColor3f( 1.0, 1.0, 1.0 ); glVertex3f( 0.3, -0.3, 0.3 ); glVertex3f( 0.3, 0.3, 0.3 ); glVertex3f( -0.3, 0.3, 0.3 ); glVertex3f( -0.3, -0.3, 0.3 ); glEnd(); // Purple side - RIGHT glBegin(GL_POLYGON); glColor3f( 1.0, 0.0, 1.0 ); glVertex3f( 0.3, -0.3, -0.3 ); glVertex3f( 0.3, 0.3, -0.3 ); glVertex3f( 0.3, 0.3, 0.3 ); glVertex3f( 0.3, -0.3, 0.3 ); glEnd(); // Green side - LEFT glBegin(GL_POLYGON); glColor3f( 0.0, 1.0, 0.0 ); glVertex3f( -0.3, -0.3, 0.3 ); glVertex3f( -0.3, 0.3, 0.3 ); glVertex3f( -0.3, 0.3, -0.3 ); glVertex3f( -0.3, -0.3, -0.3 ); glEnd(); // Blue side - TOP glBegin(GL_POLYGON); glColor3f( 0.0, 0.0, 1.0 ); glVertex3f( 0.3, 0.3, 0.3 ); glVertex3f( 0.3, 0.3, -0.3 ); glVertex3f( -0.3, 0.3, -0.3 ); glVertex3f( -0.3, 0.3, 0.3 ); glEnd(); // Red side - BOTTOM glBegin(GL_POLYGON); glColor3f( 1.0, 0.0, 0.0 ); glVertex3f( 0.3, -0.3, -0.3 ); glVertex3f( 0.3, -0.3, 0.3 ); glVertex3f( -0.3, -0.3, 0.3 ); glVertex3f( -0.3, -0.3, -0.3 ); glEnd(); glPopMatrix(); glFlush(); glutSwapBuffers(); } // Mouse click action: record old coordinate when click void Mouse(int button, int state, int x, int y) { if(state == GLUT_DOWN) oldmx = x,oldmy = y; } // Mouse move action void onMouseMove(int x,int y) { du += x - oldmx; // move left-right h +=0.03f*(y-oldmy); // move up-down if(h>1.0f) h=1.0f; // limit watch point's y axis else if(h<-1.0f) h=-1.0f; oldmx=x,oldmy=y; } void init() { glEnable(GL_DEPTH_TEST); } void reshape(int w,int h) { glViewport( 0, 0, w, h ); glMatrixMode( GL_PROJECTION ); glLoadIdentity(); gluPerspective(75.0f, (float)w/h, 1.0f, 1000.0f); glMatrixMode( GL_MODELVIEW ); } void selfMoving() { // Rotate cube rotate_y = (int)(rotate_y + 1) % 360; // Move probe height = height + step; if(height < -0.3) step = -step; if(height > 0.3) step = -step; // Render to display glutPostRedisplay(); } int main(int argc, char *argv[]) { glutInit(&argc, argv); glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH ); glutInitWindowPosition(100, 100); glutInitWindowSize(400, 400); glutCreateWindow("ScanCube"); init(); glutReshapeFunc( reshape ); glutDisplayFunc(display); glutIdleFunc(selfMoving); glutMouseFunc(Mouse); glutMotionFunc(onMouseMove); glutMainLoop(); return 0; }
79dda1c2ae6de43f1d0003b0f3dde98d6d7cf23e
323204c5216c0e2a4c4c7644cd7a4ee9911daf95
/Core/C++/InCreator.h
8b3f5d4caad254026a02a37bdaad31cb2fd6ad96
[]
no_license
RukiPomidory/SmartHome
2f3b9fd627aba0d23529f8c4d1d7fb5e6f7a5607
0d0d82375843835326395736308f956c2692b460
refs/heads/master
2020-04-05T19:20:24.180151
2019-02-22T04:59:40
2019-02-22T04:59:40
157,129,815
0
1
null
null
null
null
UTF-8
C++
false
false
183
h
#ifndef IN_CREATOR_H #define IN_CREATOR_H #include "Creator.h" #include "Device.h" class InCreator : public Creator<Device> { public: InCreator(); Device Create(); }; #endif
d6536eda533ea6584bd5da4910c605b902eda29a
72ef24612bbaf6785bd4fcfe864e2c9342bff2ca
/SQF/dayz_code/Configs/CfgWeapons/Melee/Crossbow.hpp
6599aa57028ae4e52b3625b0fb8407a95f6e8da4
[]
no_license
KahnSoft/DayZ-Epoch
6aa52fcc9f08aaef642c91c127bf8a7fc90fa59f
de5cab5130e05e9cdc881b6e2f30005b354ac938
refs/heads/master
2021-01-22T10:33:34.851506
2013-12-12T15:54:43
2013-12-12T15:54:43
15,141,842
2
0
null
null
null
null
UTF-8
C++
false
false
76
hpp
class Crossbow_DZ : Crossbow { magazines[] = { "WoodenArrow" }; };
02d4d753a4eb7d1b58e40fa1792ae77cc6bceb28
d0a9dc3ebb21ab8217246f39c06a22a7c5d74869
/alcohol en proximity sesor/alcohol_en_proximity_sesor.ino
77fcc97f93f7358e7aad3be5466269a96ac7269d
[]
no_license
nekocentral/hu-iot-group-combo-1
96b9aff08e2194521bf629275ec3ed6b1693f5f4
d478301e735f032d00d9ae07fd0417d608204fb6
refs/heads/master
2023-01-07T00:44:52.122276
2020-11-06T11:18:35
2020-11-06T11:18:35
294,438,232
2
3
null
2020-10-27T20:57:14
2020-09-10T14:46:06
Python
UTF-8
C++
false
false
5,740
ino
#define LED 2 #define BUTTON 3 //pins for proximity sensor #define TRIG 12 #define ECHO 13 //pin for alcohol sensor #define ALC A1 unsigned long time; int WARMUP = 900; //set warmup to 15 minutes for warming up of the alcohol sensor. int buttonState = 0; // variable for reading the pushbutton status int debug = 0; //set debug flag. float alc_min = 0.0; float alc_max = 0.0; float alc_treshold = 0.0; void setup() { //Assinging inputs and outputs pinMode(LED, OUTPUT); pinMode(BUTTON, INPUT_PULLUP); pinMode(TRIG, OUTPUT); pinMode(ECHO, INPUT); pinMode(ALC, INPUT); Serial.begin(9600); if (debug == 1) { Serial.println("DEBUG MODE"); } } void calibrate() { Serial.println("callibarating"); //to calibreate the sensor digitalWrite(LED, HIGH);//tun on led to let user know it is calibrating Serial.println("Setteling for 5 seconds."); delay(5000);//let sensor settle before reading. Serial.println("Reading alc sensor..."); alc_min = readAlcohol(); //read value of sensor to set the minimum Serial.println("Alcohol minimum:"); Serial.print(alc_min); digitalWrite(LED, LOW); delay(200); //blink led 3 times to led user know to hold 90% alc in front of the sensor and push the button digitalWrite(LED, HIGH); delay(200); digitalWrite(LED, LOW); delay(200); digitalWrite(LED, HIGH); delay(200); digitalWrite(LED, LOW); delay(200); digitalWrite(LED, HIGH); delay(200); digitalWrite(LED, LOW); delay(200); Serial.println("Waiting on button press..."); int z = 0; while(z==0) { //wait until button is pressed. buttonState = digitalRead(BUTTON); //set button state to variable if (buttonState == LOW) { Serial.println("button pressed"); digitalWrite(LED, HIGH);//tun on led to let user know it is calibrating. delay(3000); alc_max = readAlcohol(); //set value to max_alc. Serial.println("alcmax:"); Serial.print(alc_max); delay(200); digitalWrite(LED, LOW); z=1; } } Serial.println("tresh formule:"); Serial.println("max - min"); Serial.println(alc_max); Serial.println(alc_min); Serial.println(alc_max-alc_min); Serial.println("*10"); Serial.println((alc_max-alc_min)*10); Serial.println("/33"); Serial.println(((alc_max-alc_min)*10)/30); alc_treshold = ((((alc_max - alc_min) * 10) / 33)+alc_min); Serial.println("treshhold: "); Serial.print(alc_treshold); //Blink led 2 times to let user know calibrating is finshed. digitalWrite(LED, HIGH); delay(200); digitalWrite(LED, LOW); delay(200); digitalWrite(LED, HIGH); delay(200); digitalWrite(LED, LOW); } int readAlcohol() { int val = 0; int val1; int val2; int val3; int val4; int val5; val1 = analogRead(ALC); delay(10); val2 = analogRead(ALC); delay(10); val3 = analogRead(ALC); delay(10); val4 = analogRead(ALC); delay(10); val5 = analogRead(ALC); val = (val1 + val2 + val3 + val4 + val5) / 5; return val; } int readDistance(){ //to read distance senor. long duration, distanceCm; digitalWrite(TRIG, LOW); delayMicroseconds(2); digitalWrite(TRIG, HIGH); delayMicroseconds(10); digitalWrite(TRIG, LOW); duration = pulseIn(ECHO,HIGH); // convert the time into a distance distanceCm = duration / 29.1 / 2 ; if (distanceCm <= 0) { Serial.println("Out of range"); } return distanceCm; } void loop() { delay(100); time = millis() / 1000; if (debug == 1) { delay(500); int WARMUP_DEBUG = 1; if (time < WARMUP_DEBUG){ //flash led until warmup is finished. (15 minutes) digitalWrite(LED, HIGH); delay(200); digitalWrite(LED, LOW); delay(200); Serial.println("Warming up, Time:"); Serial.println(time); }else if (time == WARMUP_DEBUG){ //keep led on for 2 seconds to let user know warmup is finished. digitalWrite(LED, HIGH); delay(2000); digitalWrite(LED, LOW); delay(200); } else { Serial.println("distance: "); Serial.println(readDistance()); Serial.println("alcohol: "); Serial.println(readAlcohol()); } }else{ delay(300); if (time < WARMUP) { //warming up the alcohol sensor. //flash led until warmup is finished. (15 minutes) digitalWrite(LED, HIGH); delay(200); digitalWrite(LED, LOW); delay(200); Serial.println("Warming up, Time:"); Serial.println(time); } else if (time == WARMUP) { //keep led on for 2 seconds to let user know warmup is finished. digitalWrite(LED, HIGH); delay(2000); digitalWrite(LED, LOW); delay(200); } else { if (alc_max == 0.0) { calibrate(); } buttonState = digitalRead(BUTTON); //set button state to variable. if (buttonState == LOW) { //check if button is pressed. calibrate(); } //to read distance senor. int dis = readDistance(); Serial.println("distance: "); Serial.print(dis); if(dis <= 10){ Serial.println("disatance below 5"); Serial.println("treshhold: "); Serial.print(alc_treshold); Serial.println("alcohol: "); Serial.print(readAlcohol()); if (readAlcohol()>= alc_treshold){ Serial.println("alcohol above treshold"); digitalWrite(LED, HIGH);//turn on led to inform the user they may enter. delay(5000); digitalWrite(LED, LOW); delay(200); } } } } }
1750591b9a6739c07b318926b17286d475167738
2f812153f5790ab057d0f6f9b11f230400df8edd
/src/core/DeviceInfo.h
c2b8d1780f5c6593a27e43088177232c49f4fdc6
[ "Apache-2.0" ]
permissive
webosce/wam
8c8193b7c939611be059d1dded8ef1b2a9158051
535780dd1d79eee6c17c7f5e5f8288c736f13fed
refs/heads/webosce
2023-06-22T03:27:56.559931
2018-09-08T06:14:58
2018-09-20T14:20:47
145,513,310
0
2
Apache-2.0
2023-09-06T09:57:03
2018-08-21T05:52:13
C++
UTF-8
C++
false
false
1,275
h
// Copyright (c) 2014-2018 LG Electronics, Inc. // // 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. // // SPDX-License-Identifier: Apache-2.0 #ifndef DEVICEINFO_H #define DEVICEINFO_H #include <QMap> #include <QString> class DeviceInfo { public: virtual ~DeviceInfo() {} virtual bool getDisplayWidth(int& value); virtual void setDisplayWidth(int value); virtual bool getDisplayHeight(int& value); virtual void setDisplayHeight(int value); virtual bool getSystemLanguage(QString& value); virtual void setSystemLanguage(QString value); virtual bool getDeviceInfo(QString name, QString& value); virtual void setDeviceInfo(QString name, QString value); private: QMap<QString, QString> m_deviceInfo; }; #endif /* DEVICEINFO_H */
7b2e2b59f4aed5a4c924cd7bed1e83d3e144b779
babfdb15f1686976c3ae63f3cd90f1a4aa614523
/TGESI/tp_hrbf/CODE_HRBF/src/fileloaders/objfileparser.h
890f9e4bb83b1ac0a151d1def9101607149d5ccb
[]
no_license
Exoria/Fac
71ea5f6f1a0290903dabde1dccffce7d9a8bda5f
9c44c63010a4d78cecdb2a45afe3fef538c976ed
refs/heads/master
2021-03-12T22:49:35.384063
2014-12-03T10:45:55
2014-12-03T10:45:55
25,067,671
0
1
null
null
null
null
UTF-8
C++
false
false
31,708
h
/*************************************************************************** * Copyright (C) 2012 by Mathias Paulin * * [email protected] * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ #ifndef OBJFILEPARSER_H #define OBJFILEPARSER_H #include <cstddef> #include <tr1/tuple> #include <fstream> #include <istream> #include <string> #include <tr1/functional> namespace loaders { namespace obj_mtl { /** @ingroup OBJ-MTL * @{ */ typedef std::size_t size_type; typedef int index_type; typedef float float_type; typedef std::tr1::tuple<index_type, index_type> index_2_tuple_type; typedef std::tr1::tuple<index_type, index_type, index_type> index_3_tuple_type; typedef std::tr1::tuple<float_type, float_type, float_type> float_3_tuple_type; /** @} */ /** @ingroup OBJ-MTL * Class to parse MTL file. */ class mtl_parser { public: typedef std::tr1::function < void (std::size_t, const std::string&) > info_callback_type; typedef std::tr1::function < void (std::size_t, const std::string&) > warning_callback_type; typedef std::tr1::function < void (std::size_t, const std::string&) > error_callback_type; typedef std::tr1::function < void (const std::string&) > material_name_callback_type; typedef std::tr1::function < void (float_type, float_type, float_type) > material_Ka_callback_type; typedef std::tr1::function < void (float_type, float_type, float_type) > material_Kd_callback_type; typedef std::tr1::function < void (float_type, float_type, float_type) > material_Ks_callback_type; typedef std::tr1::function < void (float_type, float_type, float_type) > material_Tf_callback_type; typedef std::tr1::function < void (index_type) > material_Illum_callback_type; typedef std::tr1::function < void (const std::string&) > material_dissolve_callback_type; typedef std::tr1::function < void (float_type) > material_shininess_callback_type; typedef std::tr1::function < void (float_type) > material_sharpness_callback_type; typedef std::tr1::function < void (float_type) > material_ior_callback_type; typedef std::tr1::function < void (const std::string&) > material_map_Ka_callback_type; typedef std::tr1::function < void (const std::string&) > material_map_Kd_callback_type; typedef std::tr1::function < void (const std::string&) > material_map_Ks_callback_type; typedef std::tr1::function < void (const std::string&) > material_map_Ns_callback_type; typedef std::tr1::function < void (const std::string&) > material_map_d_callback_type; typedef std::tr1::function < void (const std::string&) > material_dispmap_callback_type; typedef std::tr1::function < void (const std::string&) > material_decalmap_callback_type; typedef std::tr1::function < void (const std::string&) > material_bumpmap_callback_type; typedef std::tr1::function < void (const std::string&) > material_reflmap_callback_type; typedef std::tr1::function < void (const std::string&) > material_normalmap_callback_type; typedef std::tr1::function < void (const std::string&) > comment_callback_type; typedef int flags_type; typedef enum { parse_blank_lines_as_comment = 1 << 0, texture_filenameonly = 1 << 1 } ParseOptions; mtl_parser (flags_type flags = 0); void info_callback (const info_callback_type& info_callback); void warning_callback (const warning_callback_type& warning_callback); void error_callback (const error_callback_type& error_callback); void material_name_callback (const material_name_callback_type &name_callback); void material_Ka_callback (const material_Ka_callback_type& Ka_callback); void material_Kd_callback (const material_Kd_callback_type& Kd_callback); void material_Ks_callback (const material_Ks_callback_type& Ks_callback); void material_Tf_callback (const material_Tf_callback_type& Tf_callback); void material_Illum_callback (const material_Illum_callback_type& Illum_callback); void material_dissolve_callback (const material_dissolve_callback_type& dissolve_callback); void material_shininess_callback (const material_shininess_callback_type& shininess_callback); void material_sharpness_callback (const material_sharpness_callback_type& sharpness_callback); void material_ior_callback (const material_ior_callback_type& ior_callback); void material_map_Ka_callback (const material_map_Ka_callback_type& map_Ka_callback); void material_map_Kd_callback (const material_map_Kd_callback_type& map_Kd_callback); void material_map_Ks_callback (const material_map_Ks_callback_type& map_Ks_callback); void material_map_Ns_callback (const material_map_Ns_callback_type& map_Ns_callback); void material_map_d_callback (const material_map_d_callback_type& map_d_callback); void material_dispmap_callback (const material_dispmap_callback_type& dispmap_callback); void material_decalmap_callback (const material_decalmap_callback_type& decalmap_callback); void material_bumpmap_callback (const material_bumpmap_callback_type& bumpmap_callback); void material_reflmap_callback (const material_reflmap_callback_type& reflmap_callback); void material_normalmap_callback (const material_normalmap_callback_type& normalmap_callback); void comment_callback (const comment_callback_type& comment_callback); bool parse (std::istream& istream); bool parse (const std::string& filename); private: flags_type flags_; info_callback_type info_callback_; warning_callback_type warning_callback_; error_callback_type error_callback_; material_name_callback_type material_name_callback_; material_Ka_callback_type material_Ka_callback_; material_Kd_callback_type material_Kd_callback_; material_Ks_callback_type material_Ks_callback_; material_Tf_callback_type material_Tf_callback_; material_Illum_callback_type material_Illum_callback_; material_dissolve_callback_type material_dissolve_callback_; material_shininess_callback_type material_shininess_callback_; material_sharpness_callback_type material_sharpness_callback_; material_ior_callback_type material_ior_callback_; material_map_Ka_callback_type material_map_Ka_callback_; material_map_Kd_callback_type material_map_Kd_callback_; material_map_Ks_callback_type material_map_Ks_callback_; material_map_Ns_callback_type material_map_Ns_callback_; material_map_d_callback_type material_map_d_callback_; material_dispmap_callback_type material_dispmap_callback_; material_decalmap_callback_type material_decalmap_callback_; material_bumpmap_callback_type material_bumpmap_callback_; material_reflmap_callback_type material_reflmap_callback_; material_normalmap_callback_type material_normalmap_callback_; comment_callback_type comment_callback_; }; /** @ingroup OBJ-MTL * Class to parse OBJ file. */ class obj_parser { public: typedef std::tr1::function < void (std::size_t, const std::string&) > info_callback_type; typedef std::tr1::function < void (std::size_t, const std::string&) > warning_callback_type; typedef std::tr1::function < void (std::size_t, const std::string&) > error_callback_type; typedef std::tr1::function < void (float_type, float_type, float_type) > geometric_vertex_callback_type; typedef std::tr1::function < void (float_type, float_type) > texture_vertex_callback_type; typedef std::tr1::function < void (float_type, float_type, float_type) > vertex_normal_callback_type; typedef std::tr1::function < void (index_type, index_type, index_type) > triangular_face_geometric_vertices_callback_type; typedef std::tr1::function < void (const index_2_tuple_type&, const index_2_tuple_type&, const index_2_tuple_type&) > triangular_face_geometric_vertices_texture_vertices_callback_type; typedef std::tr1::function < void (const index_2_tuple_type&, const index_2_tuple_type&, const index_2_tuple_type&) > triangular_face_geometric_vertices_vertex_normals_callback_type; typedef std::tr1::function < void (const index_3_tuple_type&, const index_3_tuple_type&, const index_3_tuple_type&) > triangular_face_geometric_vertices_texture_vertices_vertex_normals_callback_type; typedef std::tr1::function < void (index_type, index_type, index_type, index_type) > quadrilateral_face_geometric_vertices_callback_type; typedef std::tr1::function < void (const index_2_tuple_type&, const index_2_tuple_type&, const index_2_tuple_type&, const index_2_tuple_type&) > quadrilateral_face_geometric_vertices_texture_vertices_callback_type; typedef std::tr1::function < void (const index_2_tuple_type&, const index_2_tuple_type&, const index_2_tuple_type&, const index_2_tuple_type&) > quadrilateral_face_geometric_vertices_vertex_normals_callback_type; typedef std::tr1::function < void (const index_3_tuple_type&, const index_3_tuple_type&, const index_3_tuple_type&, const index_3_tuple_type&) > quadrilateral_face_geometric_vertices_texture_vertices_vertex_normals_callback_type; typedef std::tr1::function < void (index_type, index_type, index_type) > polygonal_face_geometric_vertices_begin_callback_type; typedef std::tr1::function < void (index_type) > polygonal_face_geometric_vertices_vertex_callback_type; typedef std::tr1::function < void () > polygonal_face_geometric_vertices_end_callback_type; typedef std::tr1::function < void (const index_2_tuple_type&, const index_2_tuple_type&, const index_2_tuple_type&) > polygonal_face_geometric_vertices_texture_vertices_begin_callback_type; typedef std::tr1::function < void (const index_2_tuple_type&) > polygonal_face_geometric_vertices_texture_vertices_vertex_callback_type; typedef std::tr1::function < void () > polygonal_face_geometric_vertices_texture_vertices_end_callback_type; typedef std::tr1::function < void (const index_2_tuple_type&, const index_2_tuple_type&, const index_2_tuple_type&) > polygonal_face_geometric_vertices_vertex_normals_begin_callback_type; typedef std::tr1::function < void (const index_2_tuple_type&) > polygonal_face_geometric_vertices_vertex_normals_vertex_callback_type; typedef std::tr1::function < void () > polygonal_face_geometric_vertices_vertex_normals_end_callback_type; typedef std::tr1::function < void (const index_3_tuple_type&, const index_3_tuple_type&, const index_3_tuple_type&) > polygonal_face_geometric_vertices_texture_vertices_vertex_normals_begin_callback_type; typedef std::tr1::function < void (const index_3_tuple_type&) > polygonal_face_geometric_vertices_texture_vertices_vertex_normals_vertex_callback_type; typedef std::tr1::function < void () > polygonal_face_geometric_vertices_texture_vertices_vertex_normals_end_callback_type; typedef std::tr1::function < void (const std::string&) > group_name_callback_type; typedef std::tr1::function < void (size_type) > smoothing_group_callback_type; typedef std::tr1::function < void (const std::string&) > object_name_callback_type; typedef std::tr1::function < void (const std::string&) > material_library_callback_type; typedef std::tr1::function < void (const std::string&) > material_name_callback_type; typedef std::tr1::function < void (const std::string&) > comment_callback_type; typedef int flags_type; typedef enum { parse_blank_lines_as_comment = 1 << 0, triangulate_faces = 1 << 1, translate_negative_indices = 1 << 2 } ParseOptions; obj_parser (flags_type flags = 0); void info_callback (const info_callback_type& info_callback); void warning_callback (const warning_callback_type& warning_callback); void error_callback (const error_callback_type& error_callback); void geometric_vertex_callback (const geometric_vertex_callback_type& geometric_vertex_callback); void texture_vertex_callback (const texture_vertex_callback_type& texture_vertex_callback); void vertex_normal_callback (const vertex_normal_callback_type& vertex_normal_callback); void face_callbacks (const triangular_face_geometric_vertices_callback_type& triangular_face_geometric_vertices_callback, const triangular_face_geometric_vertices_texture_vertices_callback_type& triangular_face_geometric_vertices_texture_vertices_callback, const triangular_face_geometric_vertices_vertex_normals_callback_type& triangular_face_geometric_vertices_vertex_normals_callback, const triangular_face_geometric_vertices_texture_vertices_vertex_normals_callback_type& triangular_face_geometric_vertices_texture_vertices_vertex_normals_callback, const quadrilateral_face_geometric_vertices_callback_type& quadrilateral_face_geometric_vertices_callback, const quadrilateral_face_geometric_vertices_texture_vertices_callback_type& quadrilateral_face_geometric_vertices_texture_vertices_callback, const quadrilateral_face_geometric_vertices_vertex_normals_callback_type& quadrilateral_face_geometric_vertices_vertex_normals_callback, const quadrilateral_face_geometric_vertices_texture_vertices_vertex_normals_callback_type& quadrilateral_face_geometric_vertices_texture_vertices_vertex_normals_callback); /*, const polygonal_face_geometric_vertices_begin_callback_type& polygonal_face_geometric_vertices_begin_callback, const polygonal_face_geometric_vertices_vertex_callback_type& polygonal_face_geometric_vertices_vertex_callback, const polygonal_face_geometric_vertices_end_callback_type& polygonal_face_geometric_vertices_end_callback, const polygonal_face_geometric_vertices_texture_vertices_begin_callback_type& polygonal_face_geometric_vertices_texture_vertices_begin_callback, const polygonal_face_geometric_vertices_texture_vertices_vertex_callback_type& polygonal_face_geometric_vertices_texture_vertices_vertex_callback, const polygonal_face_geometric_vertices_texture_vertices_end_callback_type& polygonal_face_geometric_vertices_texture_vertices_end_callback, const polygonal_face_geometric_vertices_vertex_normals_begin_callback_type& polygonal_face_geometric_vertices_vertex_normals_begin_callback, const polygonal_face_geometric_vertices_vertex_normals_vertex_callback_type& polygonal_face_geometric_vertices_vertex_normals_vertex_callback, const polygonal_face_geometric_vertices_vertex_normals_end_callback_type& polygonal_face_geometric_vertices_vertex_normals_end_callback, const polygonal_face_geometric_vertices_texture_vertices_vertex_normals_begin_callback_type& polygonal_face_geometric_vertices_texture_vertices_vertex_normals_begin_callback, const polygonal_face_geometric_vertices_texture_vertices_vertex_normals_vertex_callback_type& polygonal_face_geometric_vertices_texture_vertices_vertex_normals_vertex_callback, const polygonal_face_geometric_vertices_texture_vertices_vertex_normals_end_callback_type& polygonal_face_geometric_vertices_texture_vertices_vertex_normals_end_callback);*/ void group_name_callback (const group_name_callback_type& group_name_callback); void smoothing_group_callback (const smoothing_group_callback_type& smoothing_group_callback); void object_name_callback (const object_name_callback_type& object_name_callback); void material_library_callback (const material_library_callback_type& material_library_callback); void material_name_callback (const material_name_callback_type& material_name_callback); void comment_callback (const comment_callback_type& comment_callback); bool parse (std::istream& istream); bool parse (const std::string& filename); private: flags_type flags_; info_callback_type info_callback_; warning_callback_type warning_callback_; error_callback_type error_callback_; geometric_vertex_callback_type geometric_vertex_callback_; texture_vertex_callback_type texture_vertex_callback_; vertex_normal_callback_type vertex_normal_callback_; triangular_face_geometric_vertices_callback_type triangular_face_geometric_vertices_callback_; triangular_face_geometric_vertices_texture_vertices_callback_type triangular_face_geometric_vertices_texture_vertices_callback_; triangular_face_geometric_vertices_vertex_normals_callback_type triangular_face_geometric_vertices_vertex_normals_callback_; triangular_face_geometric_vertices_texture_vertices_vertex_normals_callback_type triangular_face_geometric_vertices_texture_vertices_vertex_normals_callback_; quadrilateral_face_geometric_vertices_callback_type quadrilateral_face_geometric_vertices_callback_; quadrilateral_face_geometric_vertices_texture_vertices_callback_type quadrilateral_face_geometric_vertices_texture_vertices_callback_; quadrilateral_face_geometric_vertices_vertex_normals_callback_type quadrilateral_face_geometric_vertices_vertex_normals_callback_; quadrilateral_face_geometric_vertices_texture_vertices_vertex_normals_callback_type quadrilateral_face_geometric_vertices_texture_vertices_vertex_normals_callback_; polygonal_face_geometric_vertices_begin_callback_type polygonal_face_geometric_vertices_begin_callback_; polygonal_face_geometric_vertices_vertex_callback_type polygonal_face_geometric_vertices_vertex_callback_; polygonal_face_geometric_vertices_end_callback_type polygonal_face_geometric_vertices_end_callback_; polygonal_face_geometric_vertices_texture_vertices_begin_callback_type polygonal_face_geometric_vertices_texture_vertices_begin_callback_; polygonal_face_geometric_vertices_texture_vertices_vertex_callback_type polygonal_face_geometric_vertices_texture_vertices_vertex_callback_; polygonal_face_geometric_vertices_texture_vertices_end_callback_type polygonal_face_geometric_vertices_texture_vertices_end_callback_; polygonal_face_geometric_vertices_vertex_normals_begin_callback_type polygonal_face_geometric_vertices_vertex_normals_begin_callback_; polygonal_face_geometric_vertices_vertex_normals_vertex_callback_type polygonal_face_geometric_vertices_vertex_normals_vertex_callback_; polygonal_face_geometric_vertices_vertex_normals_end_callback_type polygonal_face_geometric_vertices_vertex_normals_end_callback_; polygonal_face_geometric_vertices_texture_vertices_vertex_normals_begin_callback_type polygonal_face_geometric_vertices_texture_vertices_vertex_normals_begin_callback_; polygonal_face_geometric_vertices_texture_vertices_vertex_normals_vertex_callback_type polygonal_face_geometric_vertices_texture_vertices_vertex_normals_vertex_callback_; polygonal_face_geometric_vertices_texture_vertices_vertex_normals_end_callback_type polygonal_face_geometric_vertices_texture_vertices_vertex_normals_end_callback_; group_name_callback_type group_name_callback_; smoothing_group_callback_type smoothing_group_callback_; object_name_callback_type object_name_callback_; material_library_callback_type material_library_callback_; material_name_callback_type material_name_callback_; comment_callback_type comment_callback_; }; } // namespace obj inline obj_mtl::obj_parser::obj_parser (flags_type flags) : flags_ (flags) { } inline bool obj_mtl::obj_parser::parse (const std::string& filename) { std::ifstream ifstream (filename.c_str()); return parse (ifstream); } inline void obj_mtl::obj_parser::info_callback (const info_callback_type& info_callback) { info_callback_ = info_callback; } inline void obj_mtl::obj_parser::warning_callback (const warning_callback_type& warning_callback) { warning_callback_ = warning_callback; } inline void obj_mtl::obj_parser::error_callback (const error_callback_type& error_callback) { error_callback_ = error_callback; } inline void obj_mtl::obj_parser::geometric_vertex_callback (const geometric_vertex_callback_type& geometric_vertex_callback) { geometric_vertex_callback_ = geometric_vertex_callback; } inline void obj_mtl::obj_parser::texture_vertex_callback (const texture_vertex_callback_type& texture_vertex_callback) { texture_vertex_callback_ = texture_vertex_callback; } inline void obj_mtl::obj_parser::vertex_normal_callback (const vertex_normal_callback_type& vertex_normal_callback) { vertex_normal_callback_ = vertex_normal_callback; } inline void obj_mtl::obj_parser::face_callbacks (const triangular_face_geometric_vertices_callback_type& triangular_face_geometric_vertices_callback, const triangular_face_geometric_vertices_texture_vertices_callback_type& triangular_face_geometric_vertices_texture_vertices_callback, const triangular_face_geometric_vertices_vertex_normals_callback_type& triangular_face_geometric_vertices_vertex_normals_callback, const triangular_face_geometric_vertices_texture_vertices_vertex_normals_callback_type& triangular_face_geometric_vertices_texture_vertices_vertex_normals_callback, const quadrilateral_face_geometric_vertices_callback_type& quadrilateral_face_geometric_vertices_callback, const quadrilateral_face_geometric_vertices_texture_vertices_callback_type& quadrilateral_face_geometric_vertices_texture_vertices_callback, const quadrilateral_face_geometric_vertices_vertex_normals_callback_type& quadrilateral_face_geometric_vertices_vertex_normals_callback, const quadrilateral_face_geometric_vertices_texture_vertices_vertex_normals_callback_type& quadrilateral_face_geometric_vertices_texture_vertices_vertex_normals_callback/*, const polygonal_face_geometric_vertices_begin_callback_type& polygonal_face_geometric_vertices_begin_callback, const polygonal_face_geometric_vertices_vertex_callback_type& polygonal_face_geometric_vertices_vertex_callback, const polygonal_face_geometric_vertices_end_callback_type& polygonal_face_geometric_vertices_end_callback, const polygonal_face_geometric_vertices_texture_vertices_begin_callback_type& polygonal_face_geometric_vertices_texture_vertices_begin_callback, const polygonal_face_geometric_vertices_texture_vertices_vertex_callback_type& polygonal_face_geometric_vertices_texture_vertices_vertex_callback, const polygonal_face_geometric_vertices_texture_vertices_end_callback_type& polygonal_face_geometric_vertices_texture_vertices_end_callback, const polygonal_face_geometric_vertices_vertex_normals_begin_callback_type& polygonal_face_geometric_vertices_vertex_normals_begin_callback, const polygonal_face_geometric_vertices_vertex_normals_vertex_callback_type& polygonal_face_geometric_vertices_vertex_normals_vertex_callback, const polygonal_face_geometric_vertices_vertex_normals_end_callback_type& polygonal_face_geometric_vertices_vertex_normals_end_callback, const polygonal_face_geometric_vertices_texture_vertices_vertex_normals_begin_callback_type& polygonal_face_geometric_vertices_texture_vertices_vertex_normals_begin_callback, const polygonal_face_geometric_vertices_texture_vertices_vertex_normals_vertex_callback_type& polygonal_face_geometric_vertices_texture_vertices_vertex_normals_vertex_callback, const polygonal_face_geometric_vertices_texture_vertices_vertex_normals_end_callback_type& polygonal_face_geometric_vertices_texture_vertices_vertex_normals_end_callback*/) { triangular_face_geometric_vertices_callback_ = triangular_face_geometric_vertices_callback; triangular_face_geometric_vertices_texture_vertices_callback_ = triangular_face_geometric_vertices_texture_vertices_callback; triangular_face_geometric_vertices_vertex_normals_callback_ = triangular_face_geometric_vertices_vertex_normals_callback; triangular_face_geometric_vertices_texture_vertices_vertex_normals_callback_ = triangular_face_geometric_vertices_texture_vertices_vertex_normals_callback; quadrilateral_face_geometric_vertices_callback_ = quadrilateral_face_geometric_vertices_callback; quadrilateral_face_geometric_vertices_texture_vertices_callback_ = quadrilateral_face_geometric_vertices_texture_vertices_callback; quadrilateral_face_geometric_vertices_vertex_normals_callback_ = quadrilateral_face_geometric_vertices_vertex_normals_callback; quadrilateral_face_geometric_vertices_texture_vertices_vertex_normals_callback_ = quadrilateral_face_geometric_vertices_texture_vertices_vertex_normals_callback; /* polygonal_face_geometric_vertices_begin_callback_ = polygonal_face_geometric_vertices_begin_callback; polygonal_face_geometric_vertices_vertex_callback_ = polygonal_face_geometric_vertices_vertex_callback; polygonal_face_geometric_vertices_end_callback_ = polygonal_face_geometric_vertices_end_callback; polygonal_face_geometric_vertices_texture_vertices_begin_callback_ = polygonal_face_geometric_vertices_texture_vertices_begin_callback; polygonal_face_geometric_vertices_texture_vertices_vertex_callback_ = polygonal_face_geometric_vertices_texture_vertices_vertex_callback; polygonal_face_geometric_vertices_texture_vertices_end_callback_ = polygonal_face_geometric_vertices_texture_vertices_end_callback; polygonal_face_geometric_vertices_vertex_normals_begin_callback_ = polygonal_face_geometric_vertices_vertex_normals_begin_callback; polygonal_face_geometric_vertices_vertex_normals_vertex_callback_ = polygonal_face_geometric_vertices_vertex_normals_vertex_callback; polygonal_face_geometric_vertices_vertex_normals_end_callback_ = polygonal_face_geometric_vertices_vertex_normals_end_callback; polygonal_face_geometric_vertices_texture_vertices_vertex_normals_begin_callback_ = polygonal_face_geometric_vertices_texture_vertices_vertex_normals_begin_callback; polygonal_face_geometric_vertices_texture_vertices_vertex_normals_vertex_callback_ = polygonal_face_geometric_vertices_texture_vertices_vertex_normals_vertex_callback; polygonal_face_geometric_vertices_texture_vertices_vertex_normals_end_callback_ = polygonal_face_geometric_vertices_texture_vertices_vertex_normals_end_callback;*/ } inline void obj_mtl::obj_parser::group_name_callback (const group_name_callback_type& group_name_callback) { group_name_callback_ = group_name_callback; } inline void obj_mtl::obj_parser::smoothing_group_callback (const smoothing_group_callback_type& smoothing_group_callback) { smoothing_group_callback_ = smoothing_group_callback; } inline void obj_mtl::obj_parser::object_name_callback (const object_name_callback_type& object_name_callback) { object_name_callback_ = object_name_callback; } inline void obj_mtl::obj_parser::material_library_callback (const material_library_callback_type& material_library_callback) { material_library_callback_ = material_library_callback; } inline void obj_mtl::obj_parser::material_name_callback (const material_name_callback_type& material_name_callback) { material_name_callback_ = material_name_callback; } inline void obj_mtl::obj_parser::comment_callback (const comment_callback_type& comment_callback) { comment_callback_ = comment_callback; } inline void obj_mtl::mtl_parser::info_callback (const info_callback_type& info_callback) { info_callback_ = info_callback; } inline void obj_mtl::mtl_parser::warning_callback (const warning_callback_type& warning_callback) { warning_callback_ = warning_callback; } inline void obj_mtl::mtl_parser::error_callback (const error_callback_type& error_callback) { error_callback_ = error_callback; } inline void obj_mtl::mtl_parser::material_name_callback (const material_name_callback_type &name_callback) { material_name_callback_ = name_callback; } inline void obj_mtl::mtl_parser::material_Ka_callback (const material_Ka_callback_type& Ka_callback) { material_Ka_callback_ = Ka_callback; } inline void obj_mtl::mtl_parser::material_Kd_callback (const material_Kd_callback_type& Kd_callback) { material_Kd_callback_ = Kd_callback; } inline void obj_mtl::mtl_parser::material_Ks_callback (const material_Ks_callback_type& Ks_callback) { material_Ks_callback_ = Ks_callback; } inline void obj_mtl::mtl_parser::material_Tf_callback (const material_Tf_callback_type& Tf_callback) { material_Tf_callback_ = Tf_callback; } inline void obj_mtl::mtl_parser::material_Illum_callback (const material_Illum_callback_type& Illum_callback) { material_Illum_callback_ = Illum_callback; } inline void obj_mtl::mtl_parser::material_dissolve_callback (const material_dissolve_callback_type& dissolve_callback) { material_dissolve_callback_ = dissolve_callback; } inline void obj_mtl::mtl_parser::material_shininess_callback (const material_shininess_callback_type& shininess_callback) { material_shininess_callback_ = shininess_callback; } inline void obj_mtl::mtl_parser::material_sharpness_callback (const material_sharpness_callback_type& sharpness_callback) { material_sharpness_callback_ = sharpness_callback; } inline void obj_mtl::mtl_parser::material_ior_callback (const material_ior_callback_type& ior_callback) { material_ior_callback_ = ior_callback; } inline void obj_mtl::mtl_parser::material_map_Ka_callback (const material_map_Ka_callback_type& map_Ka_callback) { material_map_Ka_callback_ = map_Ka_callback; } inline void obj_mtl::mtl_parser::material_map_Kd_callback (const material_map_Kd_callback_type& map_Kd_callback) { material_map_Kd_callback_ = map_Kd_callback; } inline void obj_mtl::mtl_parser::material_map_Ks_callback (const material_map_Ks_callback_type& map_Ks_callback) { material_map_Ks_callback_ = map_Ks_callback; } inline void obj_mtl::mtl_parser::material_map_Ns_callback (const material_map_Ns_callback_type& map_Ns_callback) { material_map_Ns_callback_ = map_Ns_callback; } inline void obj_mtl::mtl_parser::material_map_d_callback (const material_map_d_callback_type& map_d_callback) { material_map_d_callback_ = map_d_callback; } inline void obj_mtl::mtl_parser::material_dispmap_callback (const material_dispmap_callback_type& dispmap_callback) { material_dispmap_callback_ = dispmap_callback; } inline void obj_mtl::mtl_parser::material_decalmap_callback (const material_decalmap_callback_type& decalmap_callback) { material_decalmap_callback_ = decalmap_callback; } inline void obj_mtl::mtl_parser::material_bumpmap_callback (const material_bumpmap_callback_type& bumpmap_callback) { material_bumpmap_callback_ = bumpmap_callback; } inline void obj_mtl::mtl_parser::material_reflmap_callback (const material_reflmap_callback_type& reflmap_callback) { material_reflmap_callback_ = reflmap_callback; } inline void obj_mtl::mtl_parser::material_normalmap_callback (const material_normalmap_callback_type& normalmap_callback) { material_normalmap_callback_ = normalmap_callback; } inline bool obj_mtl::mtl_parser::parse (const std::string& filename) { std::ifstream ifstream (filename.c_str()); return parse (ifstream); } inline obj_mtl::mtl_parser::mtl_parser (flags_type flags) : flags_ (flags) { } } // end namespace loaders #endif
b227c19aee06778e2fcd302e286a7252dc077ad9
72c73048d4b2d1dcf788a9cf9482610c78a96427
/include/Fitter.h
86c2044fe2954c6ddf6890bab00a8403c32724f3
[]
no_license
AlexandreGoettel/JUST
424a05761a48bf0ebb8445569e0078b4dd34b93e
dc8efd9df4d9d98e22a8016fff4e580b972d13c0
refs/heads/master
2023-06-29T10:42:03.148574
2021-08-06T11:16:32
2021-08-06T11:16:32
393,353,440
0
0
null
null
null
null
UTF-8
C++
false
false
2,607
h
//! @file include/NuFitContainer.h //! @brief Declaration of class to fit MC PDFs //! @author Alexandre Göttel //! @date 2021-03-18 #ifndef NuFitContainer_H_ #define NuFitContainer_H_ //============================================================================ // Standard includes #include <vector> // ROOT includes #include "TMinuit.h" // Project includes #include "FitResults.h" #include "DataReader.h" #include "ToyDataGenerator.h" //============================================================================ // Method definitions namespace NuFitter { namespace MCFit { class NuFitContainer { public: // Constructors and assigment operators NuFitContainer() = default; NuFitContainer(NuFitPDFs*&); // constructor ~NuFitContainer(); // destructor NuFitContainer(const NuFitContainer&) = delete; // copy constructor NuFitContainer(NuFitContainer&&) = delete; // move constructor NuFitContainer &operator=(const NuFitContainer&) = delete; // copy assignment NuFitContainer &operator=(NuFitContainer&&) = delete; // move assignment public: // Minuit functions template <class T> T NLL_poisson(T, T); template <class T> T NLL_MUST(T, T); template <typename L> double NLL(L, int, const double*); std::vector<std::vector<double>> fitFunction(unsigned int, const double*); double getChiSquare(int, const double*); public: // Member variables unsigned int n_params, n_fixed; std::vector<double> efficiencies; std::vector<std::vector<paramData>> paramVector, paramVector_fixed; private: std::vector<std::vector<double>> pdf_vectors, data_vector, fitValFixed; template <class T> bool InFitRange(T, T); std::vector<std::vector<double>> convertToVec(NuFitData*&); public: void setData(NuFitData*&); }; class MinuitManager { public: // Constructors and assigment operators MinuitManager(); // constructor ~MinuitManager(); // destructor MinuitManager(const MinuitManager&) = delete; // copy constructor MinuitManager(MinuitManager&&) = delete; // move constructor MinuitManager &operator=(const MinuitManager&) = delete; // copy assignment MinuitManager &operator=(MinuitManager&&) = delete; // move assignment public: // Member variables TMinuit *gMinuit = nullptr; int errorflag, errorflag_cov; public: // Functions void initMinuit(); void callMinuit(); void resetMinuit(); NuFitResults *getResults(); private: double arglist[2]; }; NuFitResults* Fit(NuFitData*&, NuFitPDFs*&); std::vector<NuFitResults*> Fit(NuFitToyData*&, NuFitPDFs*&); void fcn(int&, double*, double&, double*, int); } // namespace MCFit } // namespace NuFitter #endif
c9c3f90852b3e30e0108312583f2b275aefd38aa
efd8f23fdf1b48cc8d9954430b8ceae8aebe91f0
/C++/hellocpp/task/task1/WorkManager.h
bc0b142f1842122c21335059eaed066e2601e739
[ "Apache-2.0" ]
permissive
jiaoqiyuan/Tests
43f900ec57acbefa718d44a4da8017d859715ab3
6cae196e874970e1439d155455ab9ee0565d1de3
refs/heads/master
2023-03-31T17:43:04.171421
2023-03-23T15:28:34
2023-03-23T15:28:34
184,008,691
0
0
null
null
null
null
UTF-8
C++
false
false
327
h
// // Created by Administrator on 2020/9/15. // #ifndef HELLOCPP_WORKMANAGER_H #define HELLOCPP_WORKMANAGER_H #include <iostream> using namespace std; class WorkManager { public: WorkManager(); ~WorkManager(); static void show_menu(); // 显示菜单 }; #endif //HELLOCPP_WORKMANAGER_H
015bef23dedfdd8cc928440dda231fb8bc4eed0b
ceb533bd35b2a45019618ca1f82c10e6cf3d0406
/src/RiotArchiveFile.cpp
39292284f3dc45a7d535e918cbbfd7adb19ec48d
[]
no_license
DrInfiniteExplorer/RiotFiles
b027b61cf0e7a79aa290fe8ae5c983ca3acbe895
61e83505f56313b300d133df5e8418f016d9f405
refs/heads/master
2021-01-02T22:50:13.634305
2014-02-17T22:55:17
2014-02-17T22:55:17
14,600,226
0
0
null
null
null
null
UTF-8
C++
false
false
21,186
cpp
#include "RiotFiles\RiotArchiveFile.h" #include "RiotFiles\MMFile.h" #include "zlib\zlib.h" #include <algorithm> #include <iostream> #include <fstream> #include <ShlObj.h> #define STRINGIZE_UGH(X) #X #define STRINGIZE(X) STRINGIZE_UGH(X) #define RAFenforce(cond, msg) if(!(cond)) { throw RiotArchiveFileException(std::string(__FILE__ " " STRINGIZE(__LINE__) ": ") + (msg)); } bool compare(const std::string& a, const std::string& b) { if (a.size() != b.size()) return false; for (unsigned int i = 0; i < a.size(); i++) { if (tolower(a[i]) != tolower(b[i])) { return false; } } return true; } RiotArchiveFile::RiotArchiveFile(){ } RiotArchiveFile::RiotArchiveFile(const std::string& path) { load(path); } RiotArchiveFile::~RiotArchiveFile() { } void RiotArchiveFile::createEmptyFile(const std::string& path) { auto totalSize = sizeof(RAF::Header_t) + sizeof(RAF::TableOfContents_t) + sizeof(RAF::FileListHeader_t) + sizeof(RAF::FileListEntry_t) + sizeof(StringTable::HEADER) + sizeof(StringTable::ENTRY); std::unique_ptr<MMFile> newDir; newDir.reset(new MMFile(path, MMOpenMode::readWrite, totalSize)); RAF::Header_t* header; newDir->get(header, 0); header->mMagic = RAF::MagicNumber; header->mVersion = RAF::Version; RAF::TableOfContents_t* TOC; newDir->get(TOC, sizeof(RAF::Header_t)); TOC->mMgrIndex = 0; //? :P TOC->mFileListOffset = sizeof(RAF::Header_t) + sizeof(RAF::TableOfContents_t); TOC->mStringTableOffset = sizeof(RAF::Header_t) + sizeof(RAF::TableOfContents_t) + sizeof(RAF::FileListHeader_t) + sizeof(RAF::FileListEntry_t); RAF::FileListHeader_t* fileHeader; newDir->get(fileHeader, TOC->mFileListOffset); fileHeader->mCount = 0; StringTable::HEADER* stringHeader; newDir->get(stringHeader, TOC->mStringTableOffset); stringHeader->m_Count = 0; stringHeader->m_Size = 0; std::unique_ptr<MMFile> arcDir; arcDir.reset(new MMFile(path + ".dat", MMOpenMode::readWrite, 1)); } bool RiotArchiveFile::couldBeRAF(const std::string& path) { WIN32_FILE_ATTRIBUTE_DATA fileData; if (!GetFileAttributesEx(path.c_str(), GetFileExInfoStandard, &fileData)) { return false; } if (__int64(fileData.nFileSizeLow) + __int64(fileData.nFileSizeHigh) < RAF::MinDirectorySize) { return false; } std::unique_ptr<MMFile> directoryFile; directoryFile.reset(new MMFile(path, MMOpenMode::read, 0)); RAF::Header_t* header; directoryFile->get(header, 0); if (header->mMagic != RAF::MagicNumber) { return false; } if (header->mVersion != RAF::Version) { return false; } return true; } void RiotArchiveFile::load(const std::string& archivePath) { directoryFile.reset(new MMFile(archivePath, MMOpenMode::read, 0)); directoryFile->get(header, 0); RAFenforce(header->mMagic == RAF::MagicNumber, "Bad magic number found in archive: " + archivePath); RAFenforce(header->mVersion == RAF::Version, "Bad version number found in archive: " + archivePath); directoryFile->get(TOC, sizeof(RAF::Header_t)); directoryFile->get(fileListHeader, TOC->mFileListOffset); directoryFile->get(stringListHeader, TOC->mStringTableOffset); RAFenforce(fileListHeader->mCount == stringListHeader->m_Count, "Number of files and number of strings not matching, cant handle this crap!"); directoryFile->get(fileListEntries, TOC->mFileListOffset + sizeof(RAF::FileListHeader_t)); directoryFile->get(stringListEntries, TOC->mStringTableOffset + sizeof(StringTable::HEADER)); if (fileListHeader->mCount) { auto arcPath = archivePath + ".dat"; WIN32_FILE_ATTRIBUTE_DATA arcData; RAFenforce(GetFileAttributesEx(arcPath.c_str(), GetFileExInfoStandard, &arcData), "Could not obtain size of .dat file!"); } path = archivePath; } void RiotArchiveFile::dispose() { directoryFile.reset(); archiveFile.reset(); } void RiotArchiveFile::closeArchiveFile() const { archiveFile.reset(nullptr); } std::string RiotArchiveFile::getFileName(size_t fileIdx) const { RAFenforce(fileIdx < fileListHeader->mCount, "Bad fileIdx supplied to getFileName"); auto entry = fileListEntries + fileIdx; return getString(entry->mFileNameStringTableIndex); } std::string RiotArchiveFile::getString(size_t stringIdx) const { RAFenforce(stringIdx < stringListHeader->m_Count, "Bad stringIdx supplied to getString"); auto entry = stringListEntries + stringIdx; char* basePtr = (char*)stringListHeader; return std::string(basePtr + entry->m_Offset); } const std::string getZLibError(int error) { switch (error) { case Z_OK: return "Z_OK: No error"; case Z_STREAM_END: return "Z_STREAM_END: The stream ended"; case Z_NEED_DICT: return "Z_NEED_DICT: Needs a dictionary"; case Z_ERRNO: return "Z_ERRNO: No idea"; case Z_STREAM_ERROR: return "Z_STREAM_ERROR: No idea"; case Z_DATA_ERROR: return "Z_DATA_ERROR: No idea"; case Z_MEM_ERROR: return "Z_MEM_ERROR: No idea"; case Z_BUF_ERROR: return "Z_BUF_ERROR: Check you're z_stream!"; case Z_VERSION_ERROR: return "Z_VERSION_ERROR: Mismatching version!"; default: return "Unrecognized ZLib-error"; } return "No no"; } bool RiotArchiveFile::hasFile(const std::string& _path) const { auto path = sanitize(_path); for (size_t i = 0; i < fileListHeader->mCount; i++) { auto name = getFileName(i); if (compare(path, name)) { return true; } } return false; } size_t RiotArchiveFile::getFileIndex(const std::string& _path) const { // Can probably be accelerated by grabbing hash of path, looking // in the file header until a match is found and then // linearly search until found auto path = sanitize(_path); for (size_t i = 0; i < fileListHeader->mCount; i++) { auto name = getFileName(i); if (compare(path, name)) { return i; } } throw RiotArchiveFileException("Could not find file in archive: " + path); } size_t RiotArchiveFile::getFileSize(size_t fileIdx) const { return fileListEntries[fileIdx].mSize; } void RiotArchiveFile::openArchive() const { if (archiveFile) { return; } auto arcPath = path + ".dat"; WIN32_FILE_ATTRIBUTE_DATA arcData; RAFenforce(GetFileAttributesEx(arcPath.c_str(), GetFileExInfoStandard, &arcData), "Could not obtain size of .dat file!" + arcPath); archiveFile.reset(new MMFile(arcPath, MMOpenMode::read, 0)); } std::vector<char> RiotArchiveFile::getFileContents(size_t fileIdx) const { RAFenforce(fileIdx < fileListHeader->mCount, "Bad fileIdx supplied to getFileName"); auto entry = fileListEntries + fileIdx; openArchive(); byte* srcPtr; archiveFile->get(srcPtr, entry->mOffset); std::vector<char> outBuff; z_stream stream; ZeroMemory(&stream, sizeof(stream)); inflateInit(&stream); stream.avail_in = entry->mSize; stream.next_in = srcPtr; byte tmp[4000]; bool doneAny = false; do { stream.avail_out = sizeof(tmp); stream.next_out = tmp; auto err = inflate(&stream, Z_NO_FLUSH); if (err && err != Z_STREAM_END) { if (!doneAny) { outBuff.insert(outBuff.end(), srcPtr, srcPtr + entry->mSize); inflateEnd(&stream); return outBuff; } } RAFenforce(!err || err == Z_STREAM_END, "Error in deflate: " + getZLibError(err)); auto written = sizeof(tmp)-stream.avail_out; outBuff.insert(outBuff.end(), tmp, tmp + written); doneAny = true; } while (!stream.avail_out); inflateEnd(&stream); return outBuff; } void makePath(std::string path, bool hasFilePart = false) { std::replace(path.begin(), path.end(), '/', '\\'); if (hasFilePart) { path = path.substr(0, path.find_last_of('\\')); } auto shError = SHCreateDirectoryEx(NULL, path.c_str(), NULL); RAFenforce(shError == ERROR_SUCCESS || shError == ERROR_ALREADY_EXISTS, "Could not create output directory while extracting file: " + path); } void RiotArchiveFile::extractFile(size_t fileIdx, const std::string& outPath) const { auto content = getFileContents(fileIdx); makePath(outPath, true); std::ofstream outStream(outPath, std::ios::binary); RAFenforce(outStream.is_open(), "Failed to open file " + outPath); outStream.write(content.data(), content.size()); } void RiotArchiveFile::unpackArchive(const std::string& outPath) const { auto totalFiles = this->getFileCount(); for (size_t fileIdx = 0; fileIdx < totalFiles; fileIdx++) { auto fileName = this->getFileName(fileIdx); this->extractFile(fileIdx, outPath + "\\" + fileName); } } std::string RiotArchiveFile::sanitize(const std::string& _path) { auto path = _path; std::replace(path.begin(), path.end(), '\\', '/'); if (path[0] == '/') return path.substr(1); return path; } unsigned int RiotArchiveFile::hashString(std::string str) { unsigned int hash = 0; unsigned int tmp; for (auto ch : str) { hash = (hash << 4) + tolower(ch); tmp = hash & 0xf0000000; if (tmp) { hash = hash ^ (tmp >> 24); hash = hash ^tmp; } } return hash; } void RiotArchiveFile::removeFile(const std::string& _archivePath) { auto archivePath = sanitize(_archivePath); for (const auto& it : addList) { if (compare(it.first, archivePath)) { addList.erase(it.first); break; } } for (const auto& item : removeList) { if (compare(item, archivePath)) { return; } } if (!hasFile(archivePath)) { return; } removeList.insert(archivePath); } void RiotArchiveFile::addFile(const std::string& _archivePath, const std::string& filePath) { auto archivePath = sanitize(_archivePath); removeFile(archivePath); addList[archivePath] = AddInfo{ filePath, archivePath }; } unsigned int compress(const std::string& filePath, FILE* out) { auto inFile = new MMFile(filePath, MMOpenMode::read, 0); char* data = (char*)inFile->getPtr(); z_stream stream; ZeroMemory(&stream, sizeof(stream)); deflateInit(&stream, 9); stream.avail_in = (unsigned int)inFile->getSize(); stream.next_in = (Bytef*)data; char buff[4000]; unsigned int written = 0; do { stream.avail_out = sizeof(buff); stream.next_out = (Bytef*)buff; auto err = deflate(&stream, Z_FINISH); if (err && err != Z_STREAM_END) { //throw new ZlibException(err); throw new RiotArchiveFileException("Error in deflate: " + getZLibError(err)); } int toWrite = sizeof(buff) - stream.avail_out; fwrite(buff, 1, toWrite, out); written += toWrite; } while (stream.avail_out == 0); deflateEnd(&stream); delete inFile; return written; } // Load old file // for each in old file: // If not removed: // Copy file and make new offsets, add to list of things // // For each new file: // Compress // Add offsets to list of things // // Sort list of things // Also weirdness checks? // // Make new directory void RiotArchiveFile::apply() { if (addList.empty() && removeList.empty()) { return; } openArchive(); //int fileCountDiff = (int)addList.size() - (int)removeList.size(); //unsigned int finalFileCount = fileListHeader->mCount + fileCountDiff; std::set<unsigned int> toRemoveId; for(const auto& removePath : removeList) { auto fileIndex = getFileIndex(removePath); toRemoveId.insert((unsigned int)fileIndex); } FILE* archiveOut = nullptr; fopen_s(&archiveOut, (path + ".tmp.dat").c_str(), "wb"); RAFenforce(archiveOut, "Could not create file:" + (path + ".tmp.dat")); std::vector<NewFileEntry> newArchiveFiles; for (unsigned int fileIdx = 0; fileIdx < fileListHeader->mCount; fileIdx++) { if (toRemoveId.find(fileIdx) != toRemoveId.end()) { continue; } auto onlyEarlier = [&](unsigned int a[2]) { return a[0] < fileListEntries[fileIdx].mOffset; }; RAF::FileListEntry_t entry = fileListEntries[fileIdx]; if (entry.mSize) { auto size = entry.mSize; auto src = (char*)archiveFile->getPtr() + entry.mOffset; auto offset = ftell(archiveOut); fwrite(src, 1, size, archiveOut); auto archivePath = getFileName(fileIdx); auto entry = NewFileEntry(archivePath); entry.offset = offset; entry.size = size; newArchiveFiles.push_back(entry); } } for (auto& toAdd : addList) { auto offset = ftell(archiveOut); auto sourcePath = toAdd.second.sourcePath; auto size = compress(sourcePath, archiveOut); auto entry = NewFileEntry(toAdd.second.archivePath); entry.offset = offset; entry.size = size; newArchiveFiles.push_back(entry); } auto sortByHash = [](const NewFileEntry& a, const NewFileEntry& b) { if (a.hash < b.hash) { return true; } else if (a.hash == b.hash) { return a.archivePath < b.archivePath; } return false; }; std::sort(newArchiveFiles.begin(), newArchiveFiles.end(), sortByHash); // Now make directory file! auto exists = [](const std::string& path) { auto attribs = GetFileAttributes(path.c_str()); return attribs != INVALID_FILE_ATTRIBUTES; }; auto remove = [](const std::string& path) { DeleteFileA(path.c_str()); }; auto rename = [&](const std::string& from, const std::string& to) { RAFenforce(exists(from), "Cant rename file, does not exist: " + from); RAFenforce(MoveFileExA(from.c_str(), to.c_str(), MOVEFILE_REPLACE_EXISTING), "Could not rename file " + from + " to " + to); }; FILE* outFile = nullptr; fopen_s(&outFile, (path + ".tmp").c_str(), "wb"); fwrite(header, sizeof(*header), 1, outFile); // Later fseek to sizeof(RAF::Header_t) and write real TOC fwrite(TOC, sizeof(*TOC), 1, outFile); auto disc = std::string("RAF File created by RAF Packer for Total Commander"); fwrite(disc.c_str(), 1, disc.size(), outFile); auto fileHeaderOffset = ftell(outFile); RAF::FileListHeader_t flHeader; flHeader.mCount = (unsigned long) newArchiveFiles.size(); fwrite(&flHeader, sizeof(flHeader), 1, outFile); for (unsigned int fileIdx = 0; fileIdx < newArchiveFiles.size(); fileIdx++) { const auto& file = newArchiveFiles[fileIdx]; RAF::FileListEntry_t entry; entry.mHash = file.hash; entry.mOffset = file.offset; entry.mSize = file.size; // TODO: Dont use this, create a list of the archivenames, sort it, map index. entry.mFileNameStringTableIndex = fileIdx; fwrite(&entry, sizeof(entry), 1, outFile); } auto stringListOffset = ftell(outFile); StringTable::HEADER slHeader; slHeader.m_Size = 0; slHeader.m_Count = (unsigned int) newArchiveFiles.size(); fwrite(&slHeader, sizeof(slHeader), 1, outFile); auto totalSize = sizeof(slHeader) + sizeof(StringTable::ENTRY) * newArchiveFiles.size(); for (const auto& file : newArchiveFiles) { StringTable::ENTRY entry; entry.m_Offset = (unsigned int) totalSize; entry.m_Size = (unsigned int) file.archivePath.length() + 1; fwrite(&entry, sizeof(entry), 1, outFile); totalSize += entry.m_Size; } for (const auto& file : newArchiveFiles) { fwrite(file.archivePath.c_str(), 1, file.archivePath.size(), outFile); fwrite("\0", 1, 1, outFile); // heh string is \0\0 lololol } slHeader.m_Size = (unsigned int) totalSize; fseek(outFile, stringListOffset, SEEK_SET); fwrite(&slHeader, sizeof(slHeader), 1, outFile); fseek(outFile, sizeof(RAF::Header_t), SEEK_SET); RAF::TableOfContents_t newToc; newToc.mMgrIndex = 0; newToc.mFileListOffset = fileHeaderOffset; newToc.mStringTableOffset = stringListOffset; fwrite(&newToc, sizeof(newToc), 1, outFile); fclose(archiveOut); fclose(outFile); // Because path is reset in dispose auto origPath = path; dispose(); //rename(origPath, origPath + ".old"); //rename(origPath + ".dat", origPath + ".old.dat"); rename(origPath +".tmp", origPath); rename(origPath +".tmp.dat", origPath + ".dat"); addList.clear(); removeList.clear(); load(origPath); } RiotArchiveFileCollection::RiotArchiveFileCollection(bool buildIndex) : buildIndex(buildIndex) { } void RiotArchiveFileCollection::dispose() { for (auto archive : archives) { archive->dispose(); delete archive; } archives.clear(); archivesNamed.clear(); } void RiotArchiveFileCollection::closeArchiveFile() const { std::cout << "Unmapping " << archives.size() << " archives" << std::endl; for (auto archive : archives) { archive->closeArchiveFile(); } } size_t RiotArchiveFileCollection::getFileCount() const { size_t counter = 0; for (auto archive : archives) { counter += archive->getFileCount(); } return counter; } size_t RiotArchiveFileCollection::getStringCount() const { size_t counter = 0; for (auto archive : archives) { counter += archive->getStringCount(); } return counter; }; std::string RiotArchiveFileCollection::getFileName(size_t fileIdx) const { for (auto archive : archives) { auto fileCount = archive->getFileCount(); if (fileIdx >= fileCount) { fileIdx -= fileCount; continue; } return archive->getFileName(fileIdx); } throw RiotArchiveFileException("RiotArchiveFileCollection::getFileName bad fileIdx"); } std::string RiotArchiveFileCollection::getString(size_t stringIdx) const { for (auto archive : archives) { auto stringCount = archive->getStringCount();; if (stringIdx >= stringCount) { stringIdx -= stringCount; continue; } return archive->getString(stringIdx); } throw RiotArchiveFileException("RiotArchiveFileCollection::getString bad stringIdx"); } bool RiotArchiveFileCollection::hasFile(const std::string& path) const { for (auto archive : archives) { if (archive->hasFile(path)) { return true; } } return false; } size_t RiotArchiveFileCollection::getFileIndex(const std::string& path) const { size_t count = 0; for (auto archive : archives) { size_t fileCount = archive->getFileCount(); if (archive->hasFile(path)) { return count + archive->getFileIndex(path); } else { count += fileCount; } } throw RiotArchiveFileException("RiotArchiveFileCollection: Could not find file in archive: " + path); } std::vector<char> RiotArchiveFileCollection::getFileContents(size_t fileIdx) const { for (auto archive : archives) { auto fileCount = archive->getFileCount(); if (fileIdx >= fileCount) { fileIdx -= fileCount; continue; } return archive->getFileContents(fileIdx);; } throw RiotArchiveFileException("RiotArchiveFileCollection::getFileContents bad fileIdx"); } void RiotArchiveFileCollection::extractFile(size_t fileIdx, const std::string& outPath) const { for (auto archive : archives) { auto fileCount = archive->getFileCount(); if (fileIdx >= fileCount) { fileIdx -= fileCount; continue; } archive->extractFile(fileIdx, outPath); return; } throw RiotArchiveFileException("RiotArchiveFileCollection::extractFile bad fileIdx"); } void RiotArchiveFileCollection::unpackArchive(const std::string& outPath) const { auto totalFiles = getFileCount(); for (ptrdiff_t fileIdx = totalFiles-1; fileIdx >= 0; fileIdx--) { auto fileName = getFileName(fileIdx); auto outFilePath = outPath + "\\" + fileName; try { makePath(outFilePath, true); auto attribs = GetFileAttributes(outFilePath.c_str()); if (attribs == INVALID_FILE_ATTRIBUTES) { extractFile(fileIdx, outFilePath); } } catch (const std::runtime_error& e) { if (std::string(e.what()).find("not map view of file")) { closeArchiveFile(); extractFile(fileIdx, outFilePath); } else { //std::cout << e.what() << std::endl; throw e; } } } } void RiotArchiveFileCollection::addArchive(const std::string& path) { if (archivesNamed.find(path) != archivesNamed.end()) { return; } auto archive = new RiotArchiveFile(path); archives.push_back(archive); archivesNamed[path] = archive; }
0150ea8e1c9ed748dbb887f31a9e0766aa3f562e
d4da977bb5f060d6b4edebfdf32b98ee91561b16
/Note/集训队作业/2015/作业2/wangyisong_王逸松/解题报告/UR4C/Algorithm_5.cpp
59308db16467093ba3c81dc40a66b216fb0bfc79
[]
no_license
lychees/ACM-Training
37f9087f636d9e4eead6c82c7570e743d82cf68e
29fb126ad987c21fa204c56f41632e65151c6c23
refs/heads/master
2023-08-05T11:21:22.362564
2023-07-21T17:49:53
2023-07-21T17:49:53
42,499,880
100
22
null
null
null
null
UTF-8
C++
false
false
4,265
cpp
#include <stdio.h> #include <algorithm> #define if if ( #define then ) #define do ) #define for for ( #define while while ( #define begin { #define end } char ch; inline void read(int &x) begin x=0;ch=getchar(); while ch<=32 do ch=getchar(); while ch>32 do x=x*10+ch-48,ch=getchar(); end; template <class T> inline void swap(T &a,T &b){T t=a;a=b;b=t;} #define MAXN 500005 #define MAXNODE (MAXN*22) #define MAXHSIZE (MAXN+500005) int n,k; int w[MAXN]; int fa[MAXN],h[MAXN]; int pt[MAXN][20]; struct edge begin edge *next; int y; end *se[MAXN],e[MAXN],*etot=e; inline void addedge(int x,int y) begin *++etot=(edge){se[x],y}; se[x]=etot; end; int d1[MAXN],dfstot; inline void dfs(int x) begin d1[x]=++dfstot; edge *te=se[x]; while te do begin dfs(te->y); te=te->next; end; end; inline void pre() begin int i,j; for i=1;i<=19;i++ do begin for j=1;j<=n;j++ do pt[j][i]=pt[pt[j][i-1]][i-1]; end; for i=2;i<=n;i++ do begin addedge(fa[i],i); end; dfs(1); end; inline int jump(int x,int d) begin int i=0,j=1; while j<=d do ++i,j<<=1; while d do begin --i;j>>=1; if j<=d then d-=j,x=pt[x][i]; end; return x; end; inline int getlca(int x,int y) begin if h[x]>h[y] then x=jump(x,h[x]-h[y]); else y=jump(y,h[y]-h[x]); if x==y then return x; int i; for i=19;i>=0;i-- do begin if pt[x][i]^pt[y][i] then begin x=pt[x][i];y=pt[y][i]; end; end; return fa[x]; end; struct segnode begin segnode *s[2]; int cnt; end; segnode _seg[MAXNODE],*_segtot=_seg; inline segnode * newsegnode() begin *++_segtot=(segnode){{_seg,_seg},0}; return _segtot; end; inline segnode * insert(segnode *b,int val) begin segnode *ret=newsegnode(),*a=ret; int i,t; for i=19;i>=0;i-- do begin t=(val>>i)&1; a->s[t^1]=b->s[t^1]; a=a->s[t]=newsegnode(); b=b->s[t]; a->cnt=b->cnt+1; end; return ret; end; segnode *root[MAXN]; int wid[MAXN],rank[MAXN]; inline bool cmpw(int i,int j) begin return w[i]<w[j]; end; inline void init_seg() begin *_seg=(segnode){{_seg,_seg},0}; int i; root[0]=_seg; for i=1;i<=n;i++ do begin wid[i]=i; end; std::sort(wid+1,wid+n+1,cmpw); for i=1;i<=n;i++ do begin rank[wid[i]]=i; end; for i=1;i<=n;i++ do begin root[i]=insert(root[fa[i]],rank[i]); end; end; struct segtree begin segnode *A,*B,*C,*a,*b,*c; inline segtree go(int t) begin return (segtree){A->s[t],B->s[t],C->s[t],a->s[t],b->s[t],c->s[t]}; end; inline int cnt() begin return A->cnt+B->cnt+C->cnt-a->cnt-b->cnt-c->cnt; end; end; segtree seg[MAXN]; int cnt[MAXN]; inline void get(int id) begin int x,y,z; read(x);read(y);read(z); if d1[x]>d1[y] then swap(x,y); if d1[x]>d1[z] then swap(x,z); if d1[y]>d1[z] then swap(y,z); int l1=getlca(x,y),l2=getlca(y,z); if h[l1]<=h[l2] then begin seg[id]=(segtree){root[x],root[y],root[z],root[l1],root[l2],root[fa[l1]]}; end else begin seg[id]=(segtree){root[x],root[y],root[z],root[l1],root[l2],root[fa[l2]]}; end; cnt[id]=seg[id].go(0).cnt()+seg[id].go(1).cnt(); end; inline int getkth(segtree a,int k) begin int i,ret=0; for i=19;i>=0;i-- do begin segtree t=a.go(0); int tmp=t.cnt(); if tmp<k then begin k-=tmp; ret|=1<<i; a=a.go(1); end else begin a=t; end; end; return ret; end; struct data begin int w; int id; int from; int pos; end; inline bool operator < (const data &a,const data &b) begin return !(a.w<b.w); end; data _H[MAXHSIZE]; int hsize; inline void push(data x) begin _H[++hsize]=x; std::push_heap(_H+1,_H+hsize+1); end; inline void pop() begin std::pop_heap(_H+1,_H+(hsize--)+1); end; inline void solve() begin int i; for i=1;i<=n;i++ do begin _H[i]=(data){w[i],i,i,cnt[i]}; end; hsize=n; std::make_heap(_H+1,_H+n+1); while k-- do begin data t=_H[1]; pop(); int W=t.w; printf("%d\n",W); int id=t.id; int from=t.from; int pos=t.pos; int id1=wid[getkth(seg[id],1)]; push((data){W+w[id1],id1,id,1}); if pos<cnt[from] then begin id1=wid[getkth(seg[from],pos+1)]; push((data){W+w[id1]-w[id],id1,from,pos+1}); end; end; end; int main() begin read(n);read(k); int i; for i=1;i<=n;i++ do read(w[i]); for i=2;i<=n;i++ do begin read(fa[i]);h[i]=h[fa[i]]+1; pt[i][0]=fa[i]; end; pre(); init_seg(); for i=1;i<=n;i++ do begin get(i); end; solve(); end
4b86fa68cab9f8198dd2ebd2e4d4cad702bde081
ede32e50c83fe7370401696b32a27f144518f292
/Source/Player.h
57589434619e39b1bbc6ae718a68a7941febe6ae
[]
no_license
FlipskiZ/Self-Learning-Game-AI
4d45ce3e78c16c0df17f256e2da8793c0ba7c604
f66c080f628745697a17b8f49d709d3f3eacaa9f
refs/heads/master
2021-01-10T17:21:50.107065
2015-11-22T20:13:26
2015-11-22T20:13:26
46,632,848
0
0
null
null
null
null
UTF-8
C++
false
false
224
h
#ifndef PLAYER_H #define PLAYER_H #include "LivingEntity.h" class Player : public LivingEntity{ public: Player(); void update(); void draw(); protected: private: }; #endif // PLAYER_H
2df4b4f62450ee141ca6cb76d57f916039b9368c
f2d4f26ec0b03f6345c4896da1e7690abd6cc3e0
/10-19/18-4sum/18.cpp
37d31957c649873d79f7cc1de84afd1811af0104
[]
no_license
imbaya2466/leetcode
2a9bd251bcf66bbfc1bd146c398a556b748680d5
4145f18ad526d792557de63e965553e0ff504dbb
refs/heads/master
2020-04-29T10:39:45.413136
2019-06-18T13:19:40
2019-06-18T13:19:40
176,069,620
0
0
null
null
null
null
GB18030
C++
false
false
1,742
cpp
#include <bits/stdc++.h> using namespace std; class Solution { public: vector<vector<int> > fourSum(vector<int>& num, int target) { vector<vector<int> > res; //排序 std::sort(num.begin(), num.end()); for (int i = 0; i < num.size(); i++) { for(int j=i+1;j<num.size();j++){ //依次为基准 int targetn = target-(num[i]+num[j]); int front = j + 1; int back = num.size() - 1; while (front < back) { int sum = num[front] + num[back]; // -8 -6 -3 -2 3 5 6 //该贪心保证了有一定选择到,不会发生你所担心的 //当 sum小于基准目标,递增小的 if (sum < targetn) front++; //sum大于基准目标,递增大的 else if (sum > targetn) back--; else { vector<int> triplet(4, 0); triplet[0] = num[i]; triplet[1] = num[j]; triplet[2] = num[front]; triplet[3] = num[back]; res.push_back(triplet); //左++后右必不匹配,因此一次动俩个没有问题 do{front++;}while(num[front]==num[front-1]&&front<back); do{back--;}while(num[back]==num[back+1]&&front<back); } } //跳过重复数字 // Processing duplicates of Number 1 while (j + 1 < num.size() && num[j + 1] == num[j]) j++; } while (i + 1 < num.size() && num[i + 1] == num[i]) i++; } return res; } }; int main() { Solution a; vector<int> s={1,0,-1,0,-2,2}; a.fourSum(s,0); }
[ "yaoayang@yaoayang-PC1" ]
yaoayang@yaoayang-PC1
9424a90c6a4585e5c2fe36eae1e8737d1f712e51
b932c07a65eab1f5eec89907e351dfc056a44997
/Sources/BomberMan/Game/Players/Human/Human.cpp
a52a06f8272d6dc7e434590a8933e65f71e80fbd
[]
no_license
SachsA/Bomberman
bc9922d9f731441b43a7f4e51dcf983f5d1b2a13
29b286bfa7769d1f4b7d7a32228466e34a7a86ae
refs/heads/master
2020-03-21T07:58:46.917494
2019-12-02T16:25:50
2019-12-02T16:25:50
138,311,749
1
3
null
null
null
null
UTF-8
C++
false
false
1,194
cpp
// // EPITECH PROJECT, 2018 // cpp_indie_studio // File description: // Character.cpp // #include "Human.hpp" Human::Human(std::string name, int id, irr::core::vector2df pos, Character& character, std::vector<irr::EKEY_CODE> controls, GameGfx::EventReceiver& receiver, irr::core::vector3df& rotation) : APlayer(name, id, HUMAN, pos, character, rotation), _controls(controls), _receiver(receiver) { } enum Action Human::play() { for (auto control : _controls) { if (_receiver.IsKeyDown(control)) { switch (control) { case irr::KEY_KEY_A: case irr::KEY_RSHIFT: case irr::KEY_KEY_I: case irr::KEY_KEY_T: return PLACE_BOMB; case irr::KEY_KEY_Z: case irr::KEY_UP: case irr::KEY_KEY_O: case irr::KEY_KEY_Y: return MOVE_UP; case irr::KEY_KEY_S: case irr::KEY_DOWN: case irr::KEY_KEY_L: case irr::KEY_KEY_H: return MOVE_DOWN; case irr::KEY_KEY_Q: case irr::KEY_LEFT: case irr::KEY_KEY_K: case irr::KEY_KEY_G: return MOVE_LEFT; case irr::KEY_KEY_D: case irr::KEY_RIGHT: case irr::KEY_KEY_M: case irr::KEY_KEY_J: return MOVE_RIGHT; default: return NO; } } } return NO; }
e7f2f406e75a10a59b9b6802d67347c5c491662b
187447bd8b2bd4851f45efbbebad55056df9df83
/fakes/my_service_using_dependency_test.hpp
f1885c05b667a1d19a8f1667016eba21cfb652ac
[]
no_license
FreeBugs/cmake_conan_gtest
86e27ec03e217032786bef369ba3eec518eccfe0
bb854536043140876bc1dce88fbd39533c61e8d6
refs/heads/main
2023-02-11T04:50:58.341580
2021-01-06T09:27:10
2021-01-06T09:27:10
320,560,359
0
0
null
null
null
null
UTF-8
C++
false
false
1,334
hpp
#pragma once #include <gtest/gtest.h> #include <gmock/gmock.h> #include <deque> #include <map> #include "my_service_using_dependency.hpp" class dependency_to_fake_mock { public: MOCK_METHOD(std::string, get_firstname,()); MOCK_METHOD(std::string, get_lastname, ()); MOCK_METHOD(long, calculate, (const int)); }; class dependency_to_fake_mock_repo { public: ~dependency_to_fake_mock_repo() = default; void add_mock_to_use(dependency_to_fake_mock* dependency_to_fake_mock_) { free_mock_.push_back(dependency_to_fake_mock_); } dependency_to_fake_mock& getMock(dependency_to_fake* original) { // TODO: use more sophisticated way to add mock to map... if (! used_mock_[original]) { used_mock_[original] = free_mock_.front(); free_mock_.pop_front(); } return *used_mock_[original]; } static dependency_to_fake_mock_repo& getInstance() { static dependency_to_fake_mock_repo instance; return instance; } private: dependency_to_fake_mock_repo() = default; std::map<dependency_to_fake*, dependency_to_fake_mock*> used_mock_; std::deque<dependency_to_fake_mock*> free_mock_; }; class myservice_using_dependency_test:public ::testing::Test { protected: my_service_using_dependency object_under_test; };
201870ad1861ec53ef8f5cfacb60d60ea255a036
0eff74b05b60098333ad66cf801bdd93becc9ea4
/second/download/CMake/CMake-gumtree/Kitware_CMake_repos_basic_block_block_2003.cpp
3d7fa40740b0a607585a4920b4b583299339bf31
[]
no_license
niuxu18/logTracker-old
97543445ea7e414ed40bdc681239365d33418975
f2b060f13a0295387fe02187543db124916eb446
refs/heads/master
2021-09-13T21:39:37.686481
2017-12-11T03:36:34
2017-12-11T03:36:34
null
0
0
null
null
null
null
UTF-8
C++
false
false
180
cpp
(strlen(environ[in]) > len && environ[in][len] == '=' && strncmp(env.c_str(), environ[in], len) == 0) { ++in; } else { environ[out++] = environ[in++]; }
3670d2e83492e382b724da72aaa3b6dad2c257ac
2042acc09c0e4400a9eee551ff4551f2e9ef4e51
/dsp/SndFileLoader.h
86bc832c170d0932c365fbdc78dc66e0b65e496b
[]
no_license
yangjw902/thesis-src
dc49482d88ea42682b89ae766f9f4620490f2668
6ef87de0db3ff782e333e1b7bea7aec4a5d04968
refs/heads/master
2022-04-11T23:16:48.637127
2020-03-14T02:49:27
2020-03-14T02:49:27
null
0
0
null
null
null
null
UTF-8
C++
false
false
469
h
#pragma once #include "SignalProcessor.h" #include <sndfile.h> #include <stdlib.h> class SndFileLoader : public SignalProcessor { private: SNDFILE* file; const char* filename; SF_INFO info; float* reals; float* imags; public: SndFileLoader(AbstractSignalProcessor* p, BitMask channels_to_process, const char* filename); ~SndFileLoader(); SF_INFO get_info(); int init(size_t max_buffer_size, size_t channels); void process_buffer(SignalBuffer_t* buffer); };