text
stringlengths 8
6.88M
|
|---|
/* -*- Mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
**
** Copyright (C) 2000-2012 Opera Software ASA. All rights reserved.
**
** This file is part of the Opera web browser. It may not be distributed
** under any circumstances.
**
** Yngve Pettersen
**
*/
#include "core/pch.h"
#if defined(_NATIVE_SSL_SUPPORT_)
#include "modules/libssl/sslbase.h"
#include "modules/libssl/protocol/sslstat.h"
#include "modules/libssl/ssl_api.h"
#include "modules/libssl/options/cipher_description.h"
#include "modules/libssl/certs/certhandler.h"
#include "modules/url/url2.h"
#include "modules/url/url_sn.h"
#include "modules/url/url_man.h"
#include "modules/url/protocols/http1.h"
#include "modules/hardcore/mem/mem_man.h"
#ifdef _SECURE_INFO_SUPPORT
#include "modules/util/htmlify.h"
#endif
#ifdef _SECURE_INFO_SUPPORT
void SSL_SessionStateRecord::SetUpSessionInformation(SSL_Port_Sessions *server_info)
{
URL url = urlManager->GetNewOperaURL();
if (url.IsEmpty())
return;
#if defined LIBSSL_COMPRESS_CERT_INFO
url.SetAttribute(URL::KCompressCacheContent, TRUE);
#endif
CertificateInfoDocument doc(url, this, server_info);
OP_STATUS op_err = doc.GenerateData();
if(OpStatus::IsFatal(op_err))
g_memory_manager->RaiseCondition(op_err);
}
OP_STATUS PrintCertToURL(URL &target, SSL_Certificate_st &certificate, Str::LocaleString description);
OP_STATUS SSL_SessionStateRecord::CertificateInfoDocument::WriteLocaleString(const OpStringC &prefix, Str::LocaleString id, const OpStringC &postfix)
{
OpString tr;
m_url.WriteDocumentData(URL::KNormal, prefix);
RETURN_IF_ERROR(SetLangString(id, tr));
OP_ASSERT(tr.HasContent()); // Language string missing - check LNG file
m_url.WriteDocumentData(URL::KNormal, tr.CStr());
m_url.WriteDocumentData(URL::KNormal, postfix);
return OpStatus::OK;
}
OP_STATUS SSL_SessionStateRecord::CertificateInfoDocument::GenerateData()
{
RETURN_IF_ERROR(OpenDocument(Str::S_MSG_SSL_TEXT_SECINFO, PrefsCollectionFiles::StyleCertificateInfoPanelFile, FALSE));
RETURN_IF_ERROR(OpenBody());
m_url.SetAttribute(URL::KLoadStatus, URL_LOADING);
RETURN_IF_ERROR(WriteLocaleString( UNI_L("<securityinformation>\n<h1>"), Str::S_MSG_SSL_TEXT_SECINFO, UNI_L(": <secureserver><url>")));
OpStringC server_name(m_server_info->GetServerName()->UniName());
OpStringC8 server_name8(m_server_info->GetServerName()->Name());
m_url.WriteDocumentData(URL::KHTMLify, server_name);
m_url.WriteDocumentDataUniSprintf(UNI_L("</url>:<port>%d</port></secureserver></h1>\r\n"),m_server_info->Port());
RETURN_IF_ERROR(WriteLocaleString(UNI_L("<table>\r\n<tr><th>"), Str::S_MSG_SSL_TEXT_SECPROTO, UNI_L("</th><td><protocol>")));
m_url.WriteDocumentData(URL::KHTMLify, m_session->security_cipher_string);
m_url.WriteDocumentData(URL::KNormal, UNI_L("</protocol></td></tr>\r\n"));
if(m_session->Matched_name.HasContent())
{
RETURN_IF_ERROR(WriteLocaleString(UNI_L("<tr><th>"), Str::S_MSG_SSL_TEXT_VALIDATED_SERVERNAME, UNI_L("</th><td><certificate_servername>")));
m_url.WriteDocumentData(URL::KHTMLify, m_session->Matched_name);
m_url.WriteDocumentData(URL::KNormal, UNI_L("</certificate_servername>"));
if(m_session->Matched_name.CompareI(server_name) != 0)
{
m_url.WriteDocumentData(URL::KNormal, UNI_L(" (<servername>"));
m_url.WriteDocumentData(URL::KHTMLify, server_name);
m_url.WriteDocumentData(URL::KNormal, UNI_L("</servername>"));
if(server_name.CompareI(server_name8) != 0)
{
m_url.WriteDocumentData(URL::KNormal, UNI_L(", "));
m_url.WriteDocumentData(URL::KNormal, UNI_L("<uniservername>"));
OpString name16;
LEAVE_IF_ERROR(name16.Set(server_name8));
m_url.WriteDocumentData(URL::KHTMLify, name16);
m_url.WriteDocumentData(URL::KNormal, UNI_L("</uniservername>"));
}
m_url.WriteDocumentData(URL::KNormal, UNI_L(")"));
}
m_url.WriteDocumentData(URL::KNormal, UNI_L("</td></tr>\r\n"));
}
unsigned long name_count =m_session->CertificateNames.Count();
unsigned long name_i;
if(name_count > 0)
{
RETURN_IF_ERROR(WriteLocaleString(UNI_L("<tr><th>"), Str::S_MSG_SSL_TEXT_ISSUED_TO, UNI_L("</th><td><issued_to>")));
m_url.WriteDocumentData(URL::KHTMLify, m_session->CertificateNames[0]);
m_url.WriteDocumentData(URL::KNormal, UNI_L("</issued_to></td></tr>\r\n"));
}
for(name_i = 1; name_i < name_count; name_i++)
{
RETURN_IF_ERROR(WriteLocaleString(UNI_L("<tr><th>"), Str::S_MSG_SSL_TEXT_ISSUED_BY, UNI_L("</th><td><issued_by>")));
m_url.WriteDocumentData(URL::KHTMLify, m_session->CertificateNames[name_i]);
m_url.WriteDocumentData(URL::KNormal, UNI_L("</issued_by></td></tr>\r\n"));
}
m_url.WriteDocumentData(URL::KNormal, UNI_L("</table>\r\n"));
if(m_session->UserConfirmed!=NO_INTERACTION)
{
if(m_session->UserConfirmed==PERMANENTLY_CONFIRMED)
m_url.WriteDocumentData(URL::KNormal, UNI_L("<permanentlyconfirmed>"));
else
m_url.WriteDocumentData(URL::KNormal, UNI_L("<userconfirmedcertificate>"));
if ((m_session->certificate_status & SSL_CERT_ANONYMOUS_CONNECTION) != 0)
m_url.WriteDocumentData(URL::KNormal, UNI_L("<Anonymous_Connection/>"));
if((m_session->certificate_status & SSL_CERT_NO_ISSUER) != 0 || (
m_session->certificate_status & SSL_CERT_UNKNOWN_ROOT) != 0)
m_url.WriteDocumentData(URL::KNormal, UNI_L("<unknownca/>"));
if((m_session->certificate_status & SSL_CERT_INCORRECT_ISSUER) != 0)
m_url.WriteDocumentData(URL::KNormal, UNI_L("<Bad_CA_Flags/>"));
if ((m_session->certificate_status & SSL_CERT_NOT_YET_VALID) != 0)
{
m_url.WriteDocumentData(URL::KNormal, UNI_L("<CertNotYetValid/>"));
}
else if((m_session->certificate_status & SSL_CERT_EXPIRED) != 0)
{
m_url.WriteDocumentData(URL::KNormal, UNI_L("<Certexpired/>"));
}
if((m_session->certificate_status & SSL_CERT_WARN_MASK) == SSL_CERT_WARN)
m_url.WriteDocumentData(URL::KNormal, UNI_L("<ConfiguredWarning/>"));
if ((m_session->certificate_status & SSL_CERT_AUTHENTICATION_ONLY) != 0)
m_url.WriteDocumentData(URL::KNormal, UNI_L("<AuthenticationOnly_NoEncryption/>"));
if ((m_session->certificate_status & SSL_CERT_LOW_ENCRYPTION) != 0)
m_url.WriteDocumentData(URL::KNormal, UNI_L("<LowEncryptionlevel/>\r\n"));
if((m_session->certificate_status & SSL_CERT_NAME_MISMATCH) != 0)
m_url.WriteDocumentData(URL::KNormal, UNI_L("<ServernameMismatch/>\r\n"));
if(m_session->UserConfirmed==PERMANENTLY_CONFIRMED)
m_url.WriteDocumentData(URL::KNormal, UNI_L("</permanentlyconfirmed>"));
else
m_url.WriteDocumentData(URL::KNormal, UNI_L("</userconfirmedcertificate>\r\n"));
#if !defined LIBOPEAY_DISABLE_MD5_PARTIAL
if((m_session->certificate_status & SSL_USED_MD5) != 0)
m_url.WriteDocumentData(URL::KNormal, UNI_L("<WarningMd5/>\r\n"));
#endif
#if !defined LIBOPEAY_DISABLE_SHA1_PARTIAL
if((m_session->certificate_status & SSL_USED_SHA1) != 0)
m_url.WriteDocumentData(URL::KNormal, UNI_L("<WarningSha1/>\r\n"));
#endif
}
if(m_session->low_security_reason & SECURITY_LOW_REASON_UNABLE_TO_OCSP_VALIDATE)
m_url.WriteDocumentData(URL::KNormal, UNI_L("<OcspRequestFailed/>\r\n"));
if(m_session->low_security_reason & SECURITY_LOW_REASON_OCSP_FAILED)
{
m_url.WriteDocumentData(URL::KNormal, UNI_L("<OcspResponseFailed reason=\""));
m_url.WriteDocumentData(URL::KHTMLify, m_session->ocsp_fail_reason);
m_url.WriteDocumentData(URL::KNormal, UNI_L("\"/>\r\n"));
}
if(m_session->low_security_reason & (SECURITY_LOW_REASON_UNABLE_TO_CRL_VALIDATE | SECURITY_LOW_REASON_CRL_FAILED))
m_url.WriteDocumentData(URL::KNormal, UNI_L("<CrlFailed/>\r\n"));
#ifdef SSL_CHECK_EXT_VALIDATION_POLICY
if(m_session->extended_validation)
{
m_url.WriteDocumentData(URL::KNormal, UNI_L("<ExtendedValidationCert/>\r\n"));
}
#endif
if(!m_session->renegotiation_extension_supported)
{
m_url.WriteDocumentData(URL::KNormal, UNI_L("<RenegExtensionUnsupported/>\r\n"));
}
m_url.WriteDocumentData(URL::KNormal, UNI_L("<servercertchain>\r\n"));
if(m_session->Site_Certificate.Count())
RETURN_IF_ERROR(PrintCertToURL(m_url, m_session->Site_Certificate, Str::S_MSG_SSL_TEXT_SERVERCERT));
m_url.WriteDocumentData(URL::KNormal, UNI_L("</servercertchain>\r\n<validatedcertchain>\r\n"));
if(m_session->Validated_Site_Certificate.Count())
RETURN_IF_ERROR(PrintCertToURL(m_url, m_session->Validated_Site_Certificate,Str::S_MSG_SSL_TEXT_VALIDATEDCERT));
m_url.WriteDocumentData(URL::KNormal, UNI_L("</validatedcertchain>\r\n<clientcertchain>\r\n"));
if(m_session->Client_Certificate.Count())
RETURN_IF_ERROR(PrintCertToURL(m_url,m_session->Client_Certificate,Str::S_MSG_SSL_TEXT_CLIENTCERT));
m_url.WriteDocumentData(URL::KNormal, UNI_L("</clientcertchain>\n</securityinformation>\n")); // My version
RETURN_IF_ERROR(CloseDocument());
m_url.SetAttribute(URL::KLoadStatus, URL_LOADED);
m_session->session_information = OP_NEW(URL, (m_url));
if(m_session->session_information == NULL)
{
return OpStatus::ERR_NO_MEMORY;
}
m_session->session_information_lock.SetURL(*m_session->session_information);
return OpStatus::OK;
}
OP_STATUS PrintCertToURL(URL &target, SSL_Certificate_st &certificate, Str::LocaleString description)
{
OpAutoPtr<SSL_CertificateHandler> server_cert(g_ssl_api->CreateCertificateHandler());
if(server_cert.get() == NULL)
return OpStatus::ERR_NO_MEMORY;
server_cert->LoadCertificate(certificate);
if(server_cert->Error())
return server_cert->GetOPStatus();
uint24 i;
for(i = 0; i< server_cert->CertificateCount(); i++)
{
RETURN_IF_ERROR(server_cert->GetCertificateInfo(i, target, description));
}
return OpStatus::OK;
}
#endif
#endif
|
#include "GamePch.h"
#include "AI_PositionCarrier.h"
void AI_PositionCarrier::Init( hg::Entity* entity )
{
hg::Entity* player = hg::Entity::FindByTag(SID(Player));
Vector3 playerPos = player->GetPosition();
hg::Entity* boss = hg::Entity::FindByName(SID(FinalBossRadial));
const float top = 81.0f;
const float middle = 70.0f;
const float bottom = 57.0f;
const float left = 209.0f;
const float right = 227.0f;
const float offset = 3.0f;
const float centerDivider = 218.0f;
const float topCenterSpot = 221.0f;
Vector3 bossPos = boss->GetPosition();
if (playerPos.z < bottom - offset)
bossPos.z = bottom;
else if (playerPos.z < middle - offset)
bossPos.z = middle;
else
{
bossPos.z = top;
bossPos.x = topCenterSpot;
boss->GetTransform()->SetPosition( bossPos );
return;
}
if (playerPos.x < centerDivider)
bossPos.x = left;
else
bossPos.x = right;
boss->GetTransform()->SetPosition( bossPos );
}
Hourglass::IBehavior::Result AI_PositionCarrier::Update( Hourglass::Entity* entity )
{
return IBehavior::kSUCCESS;
}
Hourglass::IBehavior* AI_PositionCarrier::MakeCopy() const
{
AI_PositionCarrier* copy = (AI_PositionCarrier*)IBehavior::Create( SID(AI_PositionCarrier) );
// TODO: copy data members for assembled behaviors
return copy;
}
|
#include <iostream>
using namespace std;
class Car {
private:
int fuelGauge;
public:
Car(int fuel) :fuelGauge(fuel) {}
void showCarState()const {
cout << "잔여 연료량: " << fuelGauge << endl;
}
};
class Truck : public Car {
private:
int freightWeight;
public:
Truck(int fuel, int weight) :Car(fuel), freightWeight(weight) {}
void showTructState() const {
showCarState();
cout << "화물의 무게: " << freightWeight << endl;
}
};
int main() {
//dynamic_cast : 유도 클래스의 포인터 -> 기초클래스의 포인터
//static_cast : dynamic_cast 추가로 기초->유도도 가능하게, but 책임은 너가.
//속도는 static_cast가 더 빠름
Car * c1 = new Truck(100, 20);
Truck * d1 = static_cast<Truck*>(c1);
Car * c2 = new Car(10);
Truck * d2 = static_cast<Truck*>(c2); //허용하면 안되지만
Truck * t1 = new Truck(10, 200);
Car * d3 = dynamic_cast<Car*>(t1);
return 0;
}
|
// Copyright (c) 2011-2017 The Cryptonote developers
// Copyright (c) 2017-2018 The Circle Foundation & Conceal Devs
// Copyright (c) 2018-2023 Conceal Network & Conceal Devs
//
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include "ILogger.h"
namespace logging {
const std::string BLUE = "\x1F""BLUE\x1F";
const std::string GREEN = "\x1F""GREEN\x1F";
const std::string RED = "\x1F""RED\x1F";
const std::string YELLOW = "\x1F""YELLOW\x1F";
const std::string WHITE = "\x1F""WHITE\x1F";
const std::string CYAN = "\x1F""CYAN\x1F";
const std::string MAGENTA = "\x1F""MAGENTA\x1F";
const std::string BRIGHT_BLUE = "\x1F""BRIGHT_BLUE\x1F";
const std::string BRIGHT_GREEN = "\x1F""BRIGHT_GREEN\x1F";
const std::string BRIGHT_RED = "\x1F""BRIGHT_RED\x1F";
const std::string BRIGHT_YELLOW = "\x1F""BRIGHT_YELLOW\x1F";
const std::string BRIGHT_WHITE = "\x1F""BRIGHT_WHITE\x1F";
const std::string BRIGHT_CYAN = "\x1F""BRIGHT_CYAN\x1F";
const std::string BRIGHT_MAGENTA = "\x1F""BRIGHT_MAGENTA\x1F";
const std::string DEFAULT = "\x1F""DEFAULT\x1F";
const char ILogger::COLOR_DELIMETER = '\x1F';
const std::array<std::string, 6> ILogger::LEVEL_NAMES = {
{"FATAL",
"ERROR",
"WARNING",
"INFO",
"DEBUG",
"TRACE"}
};
}
|
#include "InvalidTargetFinder.h"
#include "CLArguments.h"
#include <fstream>
#include <iostream>
#include "Helpers.h"
InvalidTargetFinder::InvalidTargetFinder()
{
//ctor
}
InvalidTargetFinder::~InvalidTargetFinder()
{
//dtor
}
void InvalidTargetFinder::Go()
{
if(cppag::CLArguments::GetSingleton().NumArguments() < 1)
{
Error("Too few arguments.");
return;
}
std::ifstream file(cppag::CLArguments::GetSingleton().GetArgument(0).c_str());
if(file.fail())
{
Error("Could not open file.");
return;
}
std::string content;
while(!file.eof())
{
content += file.get();
}
file.close();
content = Helpers::ToLower(content);
Extract(content, "\"targetname\" \"", mTargetnames);
Extract(content, "\"target\" \"", mTargets);
Extract(content, "\"target2\" \"", mTargets);
Extract(content, "\"target3\" \"", mTargets);
Extract(content, "\"target4\" \"", mTargets);
Extract(content, "\"opentarget\" \"", mTargets);
Extract(content, "\"closetarget\" \"", mTargets);
Extract(content, "\"npc_target\" \"", mTargets);
for(std::set<std::string>::iterator it = mTargets.begin(); it != mTargets.end(); ++it)
{
if(mTargetnames.find(*it) == mTargetnames.end()) std::cout<<"Lacking targetname \""<<*it<<"\"!"<<std::endl;
}
std::cout<<"Press Enter to exit";
std::fflush(stdin);
std::getchar();
}
void InvalidTargetFinder::Extract(std::string content, const std::string& search, std::set<std::string>& output)
{
std::string::size_type match;
while( (match = content.find(search)) != std::string::npos)
{
content.erase(0, match + search.size());
match = content.find("\"");
if(match == std::string::npos) return;
output.insert(content.substr(0, match));
//std::cout<<"added \""<<content.substr(0, match)<<"\""<<std::endl;
content.erase(0, match);
}
}
void InvalidTargetFinder::Error(const std::string& message)
{
std::cout<<"Error: "<<message<<" Ask Wonko if necessary."<<std::endl;
std::cout<<"Press Enter to exit";
std::fflush(stdin);
std::getchar();
}
|
#include <iostream>
#include <arrow/api.h>
#include <arrow/io/api.h>
#include <arrow/ipc/api.h>
int main() {
auto read_options = arrow::ipc::IpcReadOptions::Defaults();
read_options.use_threads = false;
auto input_file = arrow::io::ReadableFile::Open("hello.arrow").ValueOrDie();
auto reader = arrow::ipc::RecordBatchStreamReader::Open(input_file, read_options).ValueOrDie();
std::shared_ptr<arrow::Table> table;
reader->ReadAll(&table);
std::cout << table->num_rows() << "\n";
}
|
#ifndef IDENSITYCUBEGENERATOR_H
#define IDENSITYCUBEGENERATOR_H
#include "UberCube.h"
#include "Ogre.h"
class IDensityCubeGenerator
{
public:
virtual void GenerateDensityCube(UberCube* uberCube, Ogre::Vector3 source, Ogre::Vector3 destination) = 0;
};
#endif
|
#ifndef SHADER_H
#define SHADER_H
#include <string>
#include <GL/glew.h>
#include <mesh.h>
#include <transform.h>
#include <camera.h>
#include <glm/gtc/type_ptr.hpp>
// Shader helper function declarations
std::string LoadShader(const std::string& fileName);
void CheckShaderError(GLuint shader, GLuint flag, bool isProgram, const std::string& errorMessage);
GLuint CreateShader(const std::string& text, GLenum type);
class Shader
{
public:
Shader(const std::string& filename, Camera* cam);
void Bind();
Camera* GetCam() {return m_cam;}
virtual ~Shader();
protected:
static const unsigned int NUM_SHADERS = 2;
GLuint m_program;
GLuint m_shaders[NUM_SHADERS];
Camera* m_cam;
private:
};
class GUI_Shader : public Shader
{
public:
GUI_Shader(const std::string filename, Camera* cam);
void SetBorderProps(float b_width, glm::vec4 b_color, glm::vec2 size);
void SetProjectionMat(glm::vec4 ortho_rect);
private:
enum
{
PROJMAT_U,
BORDERWIDTH_U,
BORDERCOLOR_U,
ASPECT_U,
NUM_UNIFORMS
};
GLuint m_uniforms[NUM_UNIFORMS];
Camera* m_cam;
glm::mat4 m_uiRect;
};
class GUI_RectBoundShader : public Shader
{
public:
GUI_RectBoundShader(const std::string filename, Camera* cam);
void SetBorderProps(float b_width, glm::vec4 b_color, glm::vec2 size);
void SetProjectionMat(glm::vec4 ortho_rect);
void SetBoundRect (glm::vec4 b_rect) {
this->Bind();
glUniform4fv(m_uniforms[BOUNDRECT_U], 1, glm::value_ptr(b_rect));
}
private:
enum
{
PROJMAT_U,
BORDERWIDTH_U,
BORDERCOLOR_U,
ASPECT_U,
BOUNDRECT_U,
NUM_UNIFORMS
};
GLuint m_uniforms[NUM_UNIFORMS];
Camera* m_cam;
glm::mat4 m_uiRect;
};
class TextShader : public Shader
{
public:
TextShader(const std::string filename, Camera* cam);
void Update(Camera* cam, glm::vec4 col);
private:
enum // basic shader enum
{
// vertex shader uniform handles
PROJMAT_U,
COLOR_U,
NUM_UNIFORMS
};
GLuint m_uniforms[NUM_UNIFORMS];
glm::mat4 m_uiRect;
};
class BasicShader : public Shader
{
public:
BasicShader(const std::string& filename, Camera* cam);
void Update(const Transform* transform);
protected:
private:
enum // basic shader enum
{
// Vertex shader uniform handles
MODEL_U, // model transform matrix
PROJMAT_U, // model view proj matrix
// Fragment shader uniform handles
CAMPOS_U, // camera pos in worldspace
LIGHTPOS_U, // lightpos in worldspace
LIGHTCOL_U, // light color
MATEMIS_U, // material emmisive
MATDIFFUSE_U,// material diffuse
MATSPEC_U, // materal specular
MATSHINE_U, // material shiniess
MATAMBI_U, // global ambiance
NUM_UNIFORMS
};
GLuint m_uniforms[NUM_UNIFORMS];
};
#endif
|
/**
* \file xmlparser.cpp implementation of xml parser functions
*
* See LICENSE for copyright information.
*/
#include <string.h>
#include "xmlparser.hpp"
#include <expat.h>
using std::string;
using xmlpp::parser;
using xmlpp::delegate;
using xmlpp::Attr;
static void XMLParser_xmlSAX2StartElement (void *ctx,
const XML_Char *fullname,
const XML_Char **atts)
{
if (ctx) {
((delegate*)ctx)->onStartElement(fullname,atts);
}
}
static void XMLParser_xmlSAX2EndElement(void *ctx,const XML_Char *name)
{
if (ctx) {
((delegate*)ctx)->onEndElement(name);
}
}
static void XMLParser_OnCharacterData(void * ctx, const char * pBuf, int len)
{
if (ctx) {
((delegate*)ctx)->onCharacterData(pBuf,len);
}
}
static void XMLParser_CommentHandler(void * ctx, const XML_Char *data)
{
if (ctx) {
((delegate*)ctx)->onComment(data);
}
}
static void XMLParser_XmlDeclHandler(void * ctx,
const XML_Char *version,
const XML_Char *encoding,
int standalone)
{
if (ctx) {
((delegate*)ctx)->onXmlDecl(version,encoding, standalone);
}
}
static void XMLParser_EntityDeclHandler(void * ctx,
const XML_Char *entityName,
int is_parameter_entity,
const XML_Char *value,
int value_length,
const XML_Char *base,
const XML_Char *systemId,
const XML_Char *publicId,
const XML_Char *notationName)
{
if (ctx) {
((delegate*)ctx)->onEntityDecl(entityName,
is_parameter_entity,
value, value_length,
base,
systemId,
publicId,
notationName);
}
}
static void XMLParser_StartCdataSectionHandler(void * ctx)
{
if (ctx) {
((delegate*)ctx)->onStartCdataSection();
}
}
static void XMLParser_EndCdataSectionHandler(void * ctx)
{
if (ctx) {
((delegate*)ctx)->onEndCdataSection();
}
}
static void XMLParser_StartNamespaceDeclHandler(void * ctx,
const XML_Char *prefix,
const XML_Char *uri)
{
if (ctx) {
((delegate*)ctx)->onStartNamespace(prefix,uri);
}
}
static void XMLParser_EndNamespaceDeclHandler(void * ctx,const XML_Char *prefix)
{
if (ctx) {
((delegate*)ctx)->onEndNamespace(prefix);
}
}
static void XMLParser_ProcessingInstruction(void * ctx,
const XML_Char* target,
const XML_Char* data)
{
if (ctx) {
((delegate*)ctx)->onProcessingInstruction(target,data);
}
}
static void XMLParser_UnparsedEntityDecl(void * ctx,
const XML_Char* entityName,
const XML_Char* base,
const XML_Char* systemId,
const XML_Char* publicId,
const XML_Char* notationName)
{
if (ctx) {
((delegate*)ctx)->onUnparsedEntityDecl(entityName,
base,
systemId,
publicId,
notationName);
}
}
static void XMLParser_NotationDecl(void * ctx,const XML_Char* notationName,
const XML_Char* base,
const XML_Char* systemId,
const XML_Char* publicId)
{
if (ctx) {
((delegate*)ctx)->onNotationDecl(notationName,
base,
systemId,
publicId);
}
}
static void XMLParser_AttlistDecl(void * ctx,const XML_Char *elname,
const XML_Char *attname,
const XML_Char *att_type,
const XML_Char *dflt,
int isrequired)
{
if (ctx) {
((delegate*)ctx)->onAttlistDecl(elname,
attname,
att_type,
dflt,
isrequired);
}
}
static void XMLParser_StartDoctypeDecl(void * ctx,const XML_Char *doctypeName,
const XML_Char *sysid,
const XML_Char *pubid,
int has_internal_subset)
{
if (ctx) {
((delegate*)ctx)->onStartDoctypeDecl(doctypeName,
sysid,
pubid,
has_internal_subset);
}
}
static void XMLParser_EndDoctypeDecl(void * ctx)
{
if (ctx) {
((delegate*)ctx)->onEndDoctypeDecl();
}
}
static void XMLParser_ElementDecl(void * ctx, const XML_Char *name, XML_Content *model)
{
if (ctx) {
((delegate*)ctx)->onElementDecl(name,model);
}
}
static void XMLParser_SkippedEntity(void * ctx,const XML_Char *entityName,
int is_parameter_entity)
{
if (ctx) {
((delegate*)ctx)->onSkippedEntity(entityName,is_parameter_entity);
}
}
parser::parser(delegate& delegate) {
m_parser = XML_ParserCreateNS("UTF-8",':');
XML_SetUserData(m_parser, &delegate);
XML_SetElementHandler(m_parser,
XMLParser_xmlSAX2StartElement,
XMLParser_xmlSAX2EndElement);
XML_SetCharacterDataHandler(m_parser, XMLParser_OnCharacterData);
XML_SetCommentHandler(m_parser, XMLParser_CommentHandler);
XML_SetXmlDeclHandler(m_parser,XMLParser_XmlDeclHandler);
XML_SetEntityDeclHandler(m_parser, XMLParser_EntityDeclHandler);
XML_SetCdataSectionHandler(m_parser,
XMLParser_StartCdataSectionHandler,
XMLParser_EndCdataSectionHandler);
XML_SetNamespaceDeclHandler(m_parser,
XMLParser_StartNamespaceDeclHandler,
XMLParser_EndNamespaceDeclHandler);
XML_SetProcessingInstructionHandler(m_parser,
XMLParser_ProcessingInstruction);
// TODO OBSOLete replace by XML_EntityDeclHandler
XML_SetUnparsedEntityDeclHandler(m_parser,XMLParser_UnparsedEntityDecl);
XML_SetNotationDeclHandler(m_parser,XMLParser_NotationDecl);
XML_SetAttlistDeclHandler(m_parser, XMLParser_AttlistDecl);
XML_SetDoctypeDeclHandler(m_parser,
XMLParser_StartDoctypeDecl,
XMLParser_EndDoctypeDecl);
XML_SetElementDeclHandler(m_parser,XMLParser_ElementDecl);
XML_SetSkippedEntityHandler(m_parser,XMLParser_SkippedEntity);
}
parser::~parser()
{
XML_ParserFree(m_parser);
}
parser::status_t parser::parse(const char* buffer, int len, bool isFinal)
{ return (status_t)XML_Parse(m_parser,buffer, len, isFinal); }
xmlpp::parser::result parser::parseString(const char* pszString, delegate& delegate)
{
result res = result::READ_ERROR;
if (pszString==nullptr) {
res = result::INVALID_INPUT;
}
else if (nullptr == (&delegate)) {
res = result::NO_DELEGATE;
} else {
parser p(delegate);
const char* pBuf = pszString;
size_t len = strlen(pszString);
if (p.parse(pBuf,static_cast<int>(len), true)==status_t::ERROR) {
/* handle parse error */
res = result::PARSE_ERROR;
delegate.onParseError(XML_GetCurrentLineNumber(p.m_parser),
XML_GetCurrentColumnNumber(p.m_parser),
XML_GetCurrentByteIndex(p.m_parser),
xmlpp::Error(XML_GetErrorCode(p.m_parser)));
} else {
res = result::OK;
}
}
return res;
}
xmlpp::parser::result parser::parseFile(const std::string& filename, delegate& delegate) {
result res = result::READ_ERROR;
if (nullptr == (&delegate)) {
res = result::NO_DELEGATE;
} else {
const size_t BUFF_SIZE = 255;
FILE* docfd = fopen(filename.c_str(), "r");
if (!docfd) {
res = result::ERROR_OPEN_FILE;
// Logger::error("cant open ", filename);
} else {
parser p(delegate);
char buff[BUFF_SIZE];
for (;;) {
size_t bytes_read;
bytes_read = fread(buff, 1, BUFF_SIZE, docfd);
if (p.parse(buff, static_cast<int>(bytes_read), bytes_read == 0)==status_t::ERROR) {
/* handle parse error */
res = result::PARSE_ERROR;
delegate.onParseError(XML_GetCurrentLineNumber(p.m_parser),
XML_GetCurrentColumnNumber(p.m_parser),
XML_GetCurrentByteIndex(p.m_parser),
Error(XML_GetErrorCode(p.m_parser)));
break;
}
if (bytes_read == 0) {
res = std::feof(docfd) ? result::OK : result::READ_ERROR;
break;
}
}
fclose(docfd);
}
}
return res;
}
parser::error_t parser::errorcode() const
{ return (error_t)XML_GetErrorCode(m_parser); }
int parser::current_line_number() const
{ return XML_GetCurrentLineNumber(m_parser); }
int parser::current_column_number() const
{ return XML_GetCurrentColumnNumber(m_parser); }
const XML_Char* parser::xmlGetAttrValue(const XML_Char** attrs,
const XML_Char* key)
{
if (attrs!=NULL)
{
for (size_t i = 0; attrs[i]!=NULL;i+=2)
{
if (!strcmp(attrs[i],key))
{
return attrs[i+1];
}
}
}
return NULL;
}
std::string Attr::getValue(const char* key)
{
const XML_Char* value = parser::xmlGetAttrValue(this->attrs_,key);
return value==nullptr ? "" : std::string(value);
}
|
#ifndef VIEW_HPP
#define VIEW_HPP
#include <iostream> // std::cout
#include <string> // std::string
#include <limits>
#include "Game.hpp"
#include "StringCards.hpp"
template <typename T> class View {
private :
public :
// CONSTRUCTEURS ================================================ //
View(){
if ( ! std::is_base_of<Game, T>::value ) { // if (T not instanceof Game)
throw invalid_argument("Le type <T> n'hérite pas de Game");
exit(0);
}
}
View(const View<T>&){} // Copie
// DESTRUCTEUR ================================================== //
virtual ~View(){}
// AFFECTATION ================================================== //
View& operator=(const View&){}
// AFFICHAGE ===================================================== //
void showGame(const T& game){
std::cout << game << std::endl;
}
void showClassement(const T& game){
std::cout << game.classement() << std::endl;
}
void showDeck(const Deck& deck){
std::cout << deck << std::endl;
}
void showCard(const Card& card){
std::cout << card << std::endl;
}
void showHiddenCard(){
std::cout << StringCards::french_card(0) << std::endl;
}
void showPlayer(const Player& player){
std::cout << player << std::endl;
}
void showPlayers(const T& game){
for (unsigned int i=0; i<game.getPlayers().size(); i++){
std::cout << game.getPlayers()[i]->toString() << std::endl;
}
}
void showTeam(const Team& team){
std::cout << team << std::endl;
}
void showTeams(const T& game){
std::cout << game.teamsToString() << std::endl;
}
void showActions(const T& game){
std::vector<int> ap = game.actions_possibles();
for (unsigned int i=0; i<ap.size(); i++){
std::cout << i+1 ;
std::cout << " : " << game.getAllActions()[ap[i]] ;
//std::cout << " (id all_actions : " ;
//std::cout << ap[i] << ")"<< std::endl;
std::cout << endl;
}
}
void show_message(const std::string s){
std::cout << s << std::endl ;
}
// INTERACTIONS USER ============================================ //
string askName(){
string name;
std::cout << "Quel est le nom du joueur ? (veuillez l'écrire au clavier)" << std::endl;
std::cin >> name;
std::cout << "Le nom a été sauvegardé : " << name << std::endl;
std::cin.clear();
std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
return name;
}
bool askHuman(){
int human=0;
std::cout << "Le joueur est-il humain ou IA ?" << std::endl;
std::cout << "1 : Humain \t 2 : IA" << std::endl;
std::cin >> human;
std::cin.clear();
std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
while (human!=1 && human!=2){
clear();
std::cout << "(Veuillez taper soit 1 ou soit 2)" << std::endl;
std::cout << "Le joueur est-il humain ou IA ?" << std::endl;
std::cout << "1 : Humain \t 2 : IA" << std::endl;
std::cin >> human;
std::cin.clear();
std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
}
return human==1;
}
int askNbTeams(unsigned int min,unsigned int max){
unsigned int nb = 0;
std::cout << "Combien y a t-il d'équipes ? (entre " << min << " et " << max << ")" << std::endl;
if (min==1){
std::cout << "(Taper 1 pour qu'il n'y ait aucune équipe (jeu individuel))" << std::endl;
}
std::cin >> nb;
std::cin.clear();
std::cin.ignore( std::numeric_limits<std::streamsize>::max() , '\n');
while (nb<min || nb>max){
clear();
std::cout << "(Veuillez taper un nombre entre " << min << " et " << max << ")" << std::endl;
std::cout << "Combien y a t-il d'équipes ? (entre " << min << " et " << max << ")" << std::endl;
if (min==1){
std::cout << "(Taper 1 pour qu'il n'y ait aucune équipe (jeu individuel))" << std::endl;
}
std::cin >> nb;
std::cin.clear();
std::cin.ignore( std::numeric_limits<std::streamsize>::max() , '\n');
}
return nb;
}
int askTeam(const T& game){
unsigned int team_id = game.getTeams().size()+1;
std::cout << game.teamsToString() << std::endl;
std::cout << "Dans quelle équipe sera le joueur ? (taper le n° de l'équipe)" << std::endl;
std::cin >> team_id;
std::cin.clear();
std::cin.ignore( std::numeric_limits<std::streamsize>::max() , '\n');
while (team_id<1 || team_id>game.getTeams().size()){
clear();
std::cout << game.teamsToString() << std::endl;
std::cout << "(Veuillez taper un nombre entre " << 1 << " et " << game.getTeams().size() << ")" << std::endl;
std::cout << "Dans quelle équipe sera le joueur ? (taper le n° de l'équipe)" << std::endl;
std::cin >> team_id;
std::cin.clear();
std::cin.ignore( std::numeric_limits<std::streamsize>::max() , '\n');
}
return team_id-1;
}
int askNbPlayers(unsigned int min,unsigned int max){
unsigned int nb = 0;
std::cout << "Combien y a t-il de joueurs ? (entre " << min << " et " << max << ")" << std::endl;
std::cin >> nb;
std::cin.clear();
std::cin.ignore( std::numeric_limits<std::streamsize>::max() , '\n');
while (nb<min || nb>max){
clear();
std::cout << "(Veuillez taper un nombre entre " << min << " et " << max << ")" << std::endl;
std::cout << "Combien y a t-il de joueurs ? (entre " << min << " et " << max << ")" << std::endl;
std::cin >> nb;
std::cin.clear();
std::cin.ignore( std::numeric_limits<std::streamsize>::max() , '\n');
}
return nb;
}
int askAction(const T& game){
unsigned int nb = 0;
bool possible = false;
std::cin >> nb; // 0 1 ...
std::cin.clear();
std::cin.ignore( std::numeric_limits<std::streamsize>::max() , '\n');
if (nb>0 && nb<=game.actions_possibles().size()) possible = true;
while (!possible){
std::cout << "(Cette action est impossible...)" << std::endl;
std::cin >> nb;
std::cin.clear();
std::cin.ignore( std::numeric_limits<std::streamsize>::max() , '\n');
if (nb>0 && nb<=game.actions_possibles().size()) possible = true;
}
return game.actions_possibles()[nb-1];
}
void askFinirTour(const T& game){
int nb = 0;
while (nb!=1){
std::cout << "Continuer ? (Taper 1 pour continuer)." << std::endl;
std::cin >> nb;
std::cin.clear();
std::cin.ignore( std::numeric_limits<std::streamsize>::max() , '\n');
}
}
void clear(){
for (int i=0; i<100; i++){
std::cout << "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n";
}
}
};
#endif
|
#include "Version_test.h"
#ifndef ACCOUNT_H
#define ACCOUNT_H
#include <string>
class Account {
public:
#if defined(DEFAULT_FCNS) && defined(IN_CLASS_INITS)
Account() = default;
#else
Account(): amount(0.0) { }
#endif
Account(const std::string &s, double amt):
owner(s), amount(amt) { }
void calculate() { amount += amount * interestRate; }
double balance() { return amount; }
public:
static double rate() { return interestRate; }
static void rate(double);
private:
std::string owner;
#ifdef IN_CLASS_INITS
double amount = 0.0;
#else
double amount;
#endif
static double interestRate;
static double initRate() { return .0225; }
// const std::string accountType_for_test;
static const std::string accountType;
#ifdef CONSTEXPR_VARS
static constexpr int period = 30; // period is a constant expression
#else
static const int period = 30; // period is a constant expression
#endif
// double daily_tbl[period];
};
#endif
|
#ifndef COMPARISON_H
#define COMPARISON_H
#include "review.h"
#include "product.h"
#include "datastore2.h"
#include <cstring>
using namespace std;
struct productNameComp {
bool operator()(const Product* lhs,const Product* rhs) {
return lhs->getName() < rhs->getName();
}
};
struct productReviewComp {
DataStore2* ds;
productReviewComp(DataStore2*& _ds) {
ds = _ds;
}
bool operator()(Product* lhs, Product* rhs) {
if (ds->getReviews(lhs).empty() && ds->getReviews(rhs).empty()) {
return 1;
}
else if (ds->getReviews(lhs).empty()) {
return 0;
}
else if (ds->getReviews(rhs).empty()) {
return 1;
}
double lAvg = 0, rAvg = 0, rCounter = 0, lCounter = 0;
for (unsigned int i=0; i<ds->getReviews(lhs).size(); i++) {
lAvg += ds->getReviews(lhs)[i]->rating;
lCounter++;
}
lAvg = lAvg/lCounter;
for (unsigned int i=0; i<ds->getReviews(rhs).size(); i++) {
rAvg += ds->getReviews(rhs)[i]->rating;
rCounter++;
}
rAvg = rAvg/rCounter;
if (lAvg == rAvg) {
return lCounter >= rCounter;
}
return lAvg > rAvg;
}
};
struct productPriceComp {
bool operator()(const Product* lhs,const Product* rhs) {
return lhs->getPrice() > rhs->getPrice();
}
};
struct reviewDateComp {
bool operator()(const Review* lhs, const Review* rhs) {
return lhs->date > rhs->date;
}
};
#endif
|
#include<iostream>
#include<map>
#include<bits/stdc++.h>
using namespace std;
int main()
{
map<int,vector<int> > Map;
/*Map.insert({0,3});
Map.insert({0,2});
Map.insert({2,3});*/
Map[0].push_back(3);
Map[-1].push_back(4);
Map[0].push_back(3);
//Map.insert(0,push_back(4));
map<int,vector<int> > :: iterator itr;
for(itr=Map.begin();itr!=Map.end();itr++)
{
cout<<itr->first<<" ";
}
}
|
// This file was generated based on /Users/r0xstation/18app/src/.uno/ux13/app18.unoproj.g.uno.
// WARNING: Changes might be lost if you edit this file directly.
#include <_root.app18_accessor_ButtonEntryMyCoupon_ShopPlace.h>
#include <_root.ButtonEntryMyCoupon.h>
#include <Uno.Bool.h>
#include <Uno.Object.h>
#include <Uno.String.h>
#include <Uno.Type.h>
#include <Uno.UX.IPropertyListener.h>
#include <Uno.UX.PropertyObject.h>
#include <Uno.UX.Selector.h>
static uString* STRINGS[1];
static uType* TYPES[3];
namespace g{
// internal sealed class app18_accessor_ButtonEntryMyCoupon_ShopPlace :161
// {
// static generated app18_accessor_ButtonEntryMyCoupon_ShopPlace() :161
static void app18_accessor_ButtonEntryMyCoupon_ShopPlace__cctor__fn(uType* __type)
{
::g::Uno::UX::Selector_typeof()->Init();
app18_accessor_ButtonEntryMyCoupon_ShopPlace::Singleton_ = app18_accessor_ButtonEntryMyCoupon_ShopPlace::New1();
app18_accessor_ButtonEntryMyCoupon_ShopPlace::_name_ = ::g::Uno::UX::Selector__op_Implicit(::STRINGS[0/*"ShopPlace"*/]);
}
static void app18_accessor_ButtonEntryMyCoupon_ShopPlace_build(uType* type)
{
::STRINGS[0] = uString::Const("ShopPlace");
::TYPES[0] = ::g::ButtonEntryMyCoupon_typeof();
::TYPES[1] = ::g::Uno::String_typeof();
::TYPES[2] = ::g::Uno::Type_typeof();
type->SetFields(0,
::g::Uno::UX::Selector_typeof(), (uintptr_t)&app18_accessor_ButtonEntryMyCoupon_ShopPlace::_name_, uFieldFlagsStatic,
::g::Uno::UX::PropertyAccessor_typeof(), (uintptr_t)&app18_accessor_ButtonEntryMyCoupon_ShopPlace::Singleton_, uFieldFlagsStatic);
}
::g::Uno::UX::PropertyAccessor_type* app18_accessor_ButtonEntryMyCoupon_ShopPlace_typeof()
{
static uSStrong< ::g::Uno::UX::PropertyAccessor_type*> type;
if (type != NULL) return type;
uTypeOptions options;
options.BaseDefinition = ::g::Uno::UX::PropertyAccessor_typeof();
options.FieldCount = 2;
options.ObjectSize = sizeof(app18_accessor_ButtonEntryMyCoupon_ShopPlace);
options.TypeSize = sizeof(::g::Uno::UX::PropertyAccessor_type);
type = (::g::Uno::UX::PropertyAccessor_type*)uClassType::New("app18_accessor_ButtonEntryMyCoupon_ShopPlace", options);
type->fp_build_ = app18_accessor_ButtonEntryMyCoupon_ShopPlace_build;
type->fp_ctor_ = (void*)app18_accessor_ButtonEntryMyCoupon_ShopPlace__New1_fn;
type->fp_cctor_ = app18_accessor_ButtonEntryMyCoupon_ShopPlace__cctor__fn;
type->fp_GetAsObject = (void(*)(::g::Uno::UX::PropertyAccessor*, ::g::Uno::UX::PropertyObject*, uObject**))app18_accessor_ButtonEntryMyCoupon_ShopPlace__GetAsObject_fn;
type->fp_get_Name = (void(*)(::g::Uno::UX::PropertyAccessor*, ::g::Uno::UX::Selector*))app18_accessor_ButtonEntryMyCoupon_ShopPlace__get_Name_fn;
type->fp_get_PropertyType = (void(*)(::g::Uno::UX::PropertyAccessor*, uType**))app18_accessor_ButtonEntryMyCoupon_ShopPlace__get_PropertyType_fn;
type->fp_SetAsObject = (void(*)(::g::Uno::UX::PropertyAccessor*, ::g::Uno::UX::PropertyObject*, uObject*, uObject*))app18_accessor_ButtonEntryMyCoupon_ShopPlace__SetAsObject_fn;
type->fp_get_SupportsOriginSetter = (void(*)(::g::Uno::UX::PropertyAccessor*, bool*))app18_accessor_ButtonEntryMyCoupon_ShopPlace__get_SupportsOriginSetter_fn;
return type;
}
// public generated app18_accessor_ButtonEntryMyCoupon_ShopPlace() :161
void app18_accessor_ButtonEntryMyCoupon_ShopPlace__ctor_1_fn(app18_accessor_ButtonEntryMyCoupon_ShopPlace* __this)
{
__this->ctor_1();
}
// public override sealed object GetAsObject(Uno.UX.PropertyObject obj) :167
void app18_accessor_ButtonEntryMyCoupon_ShopPlace__GetAsObject_fn(app18_accessor_ButtonEntryMyCoupon_ShopPlace* __this, ::g::Uno::UX::PropertyObject* obj, uObject** __retval)
{
return *__retval = uPtr(uCast< ::g::ButtonEntryMyCoupon*>(obj, ::TYPES[0/*ButtonEntryMyCoupon*/]))->ShopPlace(), void();
}
// public override sealed Uno.UX.Selector get_Name() :164
void app18_accessor_ButtonEntryMyCoupon_ShopPlace__get_Name_fn(app18_accessor_ButtonEntryMyCoupon_ShopPlace* __this, ::g::Uno::UX::Selector* __retval)
{
return *__retval = app18_accessor_ButtonEntryMyCoupon_ShopPlace::_name_, void();
}
// public generated app18_accessor_ButtonEntryMyCoupon_ShopPlace New() :161
void app18_accessor_ButtonEntryMyCoupon_ShopPlace__New1_fn(app18_accessor_ButtonEntryMyCoupon_ShopPlace** __retval)
{
*__retval = app18_accessor_ButtonEntryMyCoupon_ShopPlace::New1();
}
// public override sealed Uno.Type get_PropertyType() :166
void app18_accessor_ButtonEntryMyCoupon_ShopPlace__get_PropertyType_fn(app18_accessor_ButtonEntryMyCoupon_ShopPlace* __this, uType** __retval)
{
return *__retval = ::TYPES[1/*string*/], void();
}
// public override sealed void SetAsObject(Uno.UX.PropertyObject obj, object v, Uno.UX.IPropertyListener origin) :168
void app18_accessor_ButtonEntryMyCoupon_ShopPlace__SetAsObject_fn(app18_accessor_ButtonEntryMyCoupon_ShopPlace* __this, ::g::Uno::UX::PropertyObject* obj, uObject* v, uObject* origin)
{
uPtr(uCast< ::g::ButtonEntryMyCoupon*>(obj, ::TYPES[0/*ButtonEntryMyCoupon*/]))->SetShopPlace(uCast<uString*>(v, ::TYPES[1/*string*/]), origin);
}
// public override sealed bool get_SupportsOriginSetter() :169
void app18_accessor_ButtonEntryMyCoupon_ShopPlace__get_SupportsOriginSetter_fn(app18_accessor_ButtonEntryMyCoupon_ShopPlace* __this, bool* __retval)
{
return *__retval = true, void();
}
::g::Uno::UX::Selector app18_accessor_ButtonEntryMyCoupon_ShopPlace::_name_;
uSStrong< ::g::Uno::UX::PropertyAccessor*> app18_accessor_ButtonEntryMyCoupon_ShopPlace::Singleton_;
// public generated app18_accessor_ButtonEntryMyCoupon_ShopPlace() [instance] :161
void app18_accessor_ButtonEntryMyCoupon_ShopPlace::ctor_1()
{
ctor_();
}
// public generated app18_accessor_ButtonEntryMyCoupon_ShopPlace New() [static] :161
app18_accessor_ButtonEntryMyCoupon_ShopPlace* app18_accessor_ButtonEntryMyCoupon_ShopPlace::New1()
{
app18_accessor_ButtonEntryMyCoupon_ShopPlace* obj1 = (app18_accessor_ButtonEntryMyCoupon_ShopPlace*)uNew(app18_accessor_ButtonEntryMyCoupon_ShopPlace_typeof());
obj1->ctor_1();
return obj1;
}
// }
} // ::g
|
/* -*- Mode: c++; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*-
**
** Copyright (C) 1995-2011 Opera Software ASA. All rights reserved.
**
** This file is part of the Opera web browser.
** It may not be distributed under any circumstances.
*/
#ifndef DOM_EXTENSIONS_CONTEXTS_H
#define DOM_EXTENSIONS_CONTEXTS_H
#ifdef EXTENSION_SUPPORT
#include "modules/dom/src/domobj.h"
#include "modules/dom/src/extensions/domextensionsupport.h"
class DOM_ExtensionContext;
class DOM_ExtensionSpeedDialContext;
class DOM_ExtensionMenuContext;
/** DOM_ExtensionContexts is the opera.contexts.* collection object available to background page/processes. */
class DOM_ExtensionContexts
: public DOM_Object
{
public:
static OP_STATUS Make(DOM_ExtensionContexts *&new_obj, DOM_ExtensionSupport *extension_support, DOM_Runtime *origining_runtime);
void BeforeDestroy();
/** The platform provides a set of predefined contexts that UIItems can be added to.
TOOLBAR (opera.contexts.toolbar) is the only context of this type supported so far. */
enum ContextType {
CONTEXT_UNKNOWN = 0,
CONTEXT_TOOLBAR,
CONTEXT_PAGE,
CONTEXT_SELECTION,
CONTEXT_LINK,
CONTEXT_EDITABLE,
CONTEXT_IMAGE,
CONTEXT_VIDEO,
CONTEXT_AUDIO,
CONTEXT_MENU
};
/* from DOM_Object */
virtual ES_GetState GetName(OpAtom property_name, ES_Value *value, ES_Runtime *origining_runtime);
virtual ES_PutState PutName(OpAtom property_name, ES_Value *value, ES_Runtime *origining_runtime);
virtual void GCTrace();
virtual BOOL IsA(int type) { return type == DOM_TYPE_EXTENSION_CONTEXTS || DOM_Object::IsA(type); }
#ifdef DOM_EXTENSIONS_CONTEXT_MENU_API_SUPPORT
DOM_ExtensionMenuContext *GetMenuContext();
#endif // DOM_EXTENSIONS_CONTEXT_MENU_API_SUPPORT
private:
DOM_ExtensionContexts(DOM_ExtensionSupport *extension_support)
: m_toolbar(NULL),
m_speeddial(NULL),
#ifdef DOM_EXTENSIONS_CONTEXT_MENU_API_SUPPORT
m_menu(NULL),
#endif // DOM_EXTENSIONS_CONTEXT_MENU_API_SUPPORT
m_extension_support(extension_support)
{
}
DOM_ExtensionContext *m_toolbar;
DOM_ExtensionSpeedDialContext *m_speeddial;
#ifdef DOM_EXTENSIONS_CONTEXT_MENU_API_SUPPORT
DOM_ExtensionMenuContext *m_menu;
#endif // DOM_EXTENSIONS_CONTEXT_MENU_API_SUPPORT
OpSmartPointerWithDelete<DOM_ExtensionSupport> m_extension_support;
};
#endif // EXTENSION_SUPPORT
#endif // DOM_EXTENSIONS_CONTEXTS_H
|
#include "stdafx.h"
#include "Prof-UIS.h"
#include "CUIExtPageNavigatorWnd.h"
extern "C" __declspec(dllexport) HWND WINAPI UISalPageNavigatorCreate(HWND parentWindow, HWND messageWindow, UINT message, UINT controlID, int x, int y, int width, int height, DWORD windowStyle)
{
// access parent window
CWnd* parentWindowClass = NULL;
if (parentWindow != NULL)
{
parentWindowClass = CWnd::FromHandlePermanent(parentWindow);
}
// If requested, adjust size
if ((width == -1) || (height == -1))
{
// Calculate size of parent windows's client rect
RECT parentWindowRect;
::GetClientRect(parentWindow, &parentWindowRect);
// Adjust sizes
if (width == -1)
{
// Adjust start position and size
x = 0;
width = parentWindowRect.right - parentWindowRect.left;
}
if (height == -1)
{
// Adjust start position and size
y = 0;
height = parentWindowRect.bottom - parentWindowRect.top;
}
}
// create Page Navigator
CUIExtPageNavigatorWnd* pageNavigator = new CUIExtPageNavigatorWnd(messageWindow, message, controlID);
windowStyle = ((windowStyle == 0) ? WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN | WS_CLIPSIBLINGS : 0);
RECT rect;
rect.left = x;
rect.top = y;
rect.right = x + width;
rect.bottom = y + height;
pageNavigator->Create(parentWindowClass, rect, controlID, windowStyle, NULL);
return ((pageNavigator == NULL) ? NULL : pageNavigator->GetSafeHwnd());
}
extern "C" __declspec(dllexport) BOOL WINAPI UISalPageNavigatorEnableSplitter(HWND pageNavigatorWindow, BOOL enable, BOOL update)
{
// access page navigator
CUIExtPageNavigatorWnd* extPageNavigator = (CUIExtPageNavigatorWnd*)CUIExtPageNavigatorWnd::FromHandlePermanent(pageNavigatorWindow);
if (extPageNavigator != NULL)
{
return extPageNavigator->EnableSplitter(enable, update);
}
return FALSE;
}
extern "C" __declspec(dllexport) int WINAPI UISalPageNavigatorHitTest(HWND pageNavigatorWindow, int x, int y)
{
// access page navigator
CUIExtPageNavigatorWnd* extPageNavigator = (CUIExtPageNavigatorWnd*)CUIExtPageNavigatorWnd::FromHandlePermanent(pageNavigatorWindow);
if (extPageNavigator != NULL)
{
POINT ptHitTest;
ptHitTest.x = x;
ptHitTest.y = y;
return extPageNavigator->HitTest(ptHitTest);
}
return __EPNWH_NOWHERE;
}
extern "C" __declspec(dllexport) HANDLE WINAPI UISalPageNavigatorHitTestItem(HWND pageNavigatorWindow, int x, int y)
{
// access page navigator
CUIExtPageNavigatorWnd* extPageNavigator = (CUIExtPageNavigatorWnd*)CUIExtPageNavigatorWnd::FromHandlePermanent(pageNavigatorWindow);
if (extPageNavigator != NULL)
{
POINT ptHitTest;
ptHitTest.x = x;
ptHitTest.y = y;
return (HANDLE)extPageNavigator->HitTestItem(ptHitTest);
}
return NULL;
}
extern "C" __declspec(dllexport) BOOL WINAPI UISalPageNavigatorIsSplitterEnabled(HWND pageNavigatorWindow)
{
// access page navigator
CUIExtPageNavigatorWnd* extPageNavigator = (CUIExtPageNavigatorWnd*)CUIExtPageNavigatorWnd::FromHandlePermanent(pageNavigatorWindow);
if (extPageNavigator != NULL)
{
return extPageNavigator->IsSplitterEnabled();
}
return FALSE;
}
extern "C" __declspec(dllexport) BOOL WINAPI UISalPageNavigatorIsSplitterVisible(HWND pageNavigatorWindow)
{
// access page navigator
CUIExtPageNavigatorWnd* extPageNavigator = (CUIExtPageNavigatorWnd*)CUIExtPageNavigatorWnd::FromHandlePermanent(pageNavigatorWindow);
if (extPageNavigator != NULL)
{
return extPageNavigator->IsSplitterVisible();
}
return FALSE;
}
extern "C" __declspec(dllexport) BOOL WINAPI UISalPageNavigatorItemEnabledGet(HWND pageNavigatorWindow, int itemIndex)
{
// access page navigator
CUIExtPageNavigatorWnd* extPageNavigator = (CUIExtPageNavigatorWnd*)CUIExtPageNavigatorWnd::FromHandlePermanent(pageNavigatorWindow);
if (extPageNavigator != NULL)
{
return extPageNavigator->ItemEnabledGet((LONG)itemIndex);
}
return FALSE;
}
extern "C" __declspec(dllexport) BOOL WINAPI UISalPageNavigatorItemEnabledSet(HWND pageNavigatorWindow, int itemIndex, BOOL enabled, BOOL persistent, BOOL update)
{
// variables
BOOL previousEnabledState = FALSE;
// access page navigator
CUIExtPageNavigatorWnd* extPageNavigator = (CUIExtPageNavigatorWnd*)CUIExtPageNavigatorWnd::FromHandlePermanent(pageNavigatorWindow);
if (extPageNavigator != NULL)
{
previousEnabledState = extPageNavigator->ItemEnabledGet((LONG)itemIndex);
extPageNavigator->ItemEnabledSet((LONG)itemIndex, enabled, persistent, update);
}
return previousEnabledState;
}
extern "C" __declspec(dllexport) HANDLE WINAPI UISalPageNavigatorItemFindParam(HWND pageNavigatorWindow, LPARAM lParam, int itemIndexStart)
{
// variables
HANDLE itemHandle = NULL;
// access page navigator
CUIExtPageNavigatorWnd* extPageNavigator = (CUIExtPageNavigatorWnd*)CUIExtPageNavigatorWnd::FromHandlePermanent(pageNavigatorWindow);
if (extPageNavigator != NULL)
{
itemHandle = (HANDLE)extPageNavigator->ItemFind(lParam, (LONG)itemIndexStart);
}
return itemHandle;
}
extern "C" __declspec(dllexport) HANDLE WINAPI UISalPageNavigatorItemFindText(HWND pageNavigatorWindow, LPCWSTR text, int itemIndexStart)
{
// variables
HANDLE itemHandle = NULL;
// access page navigator
CUIExtPageNavigatorWnd* extPageNavigator = (CUIExtPageNavigatorWnd*)CUIExtPageNavigatorWnd::FromHandlePermanent(pageNavigatorWindow);
if (extPageNavigator != NULL)
{
itemHandle = (HANDLE)extPageNavigator->ItemFind(text, (LONG)itemIndexStart);
}
return itemHandle;
}
extern "C" __declspec(dllexport) int WINAPI UISalPageNavigatorItemGetCollapsedCount(HWND pageNavigatorWindow)
{
// variables
int collapsedCount = -1;
// access page navigator
CUIExtPageNavigatorWnd* extPageNavigator = (CUIExtPageNavigatorWnd*)CUIExtPageNavigatorWnd::FromHandlePermanent(pageNavigatorWindow);
if (extPageNavigator != NULL)
{
collapsedCount = extPageNavigator->ItemGetCollapsedCount();
}
return collapsedCount;
}
extern "C" __declspec(dllexport) int WINAPI UISalPageNavigatorItemGetCount(HWND pageNavigatorWindow)
{
// variables
int itemCount = -1;
// access page navigator
CUIExtPageNavigatorWnd* extPageNavigator = (CUIExtPageNavigatorWnd*)CUIExtPageNavigatorWnd::FromHandlePermanent(pageNavigatorWindow);
if (extPageNavigator != NULL)
{
itemCount = extPageNavigator->ItemGetCount();
}
return itemCount;
}
extern "C" __declspec(dllexport) int WINAPI UISalPageNavigatorItemGetEnabledCount(HWND pageNavigatorWindow)
{
// variables
int enabledCount = -1;
// access page navigator
CUIExtPageNavigatorWnd* extPageNavigator = (CUIExtPageNavigatorWnd*)CUIExtPageNavigatorWnd::FromHandlePermanent(pageNavigatorWindow);
if (extPageNavigator != NULL)
{
enabledCount = extPageNavigator->ItemGetEnabledCount();
}
return enabledCount;
} // extern "C" __declspec(dllexport) int WINAPI UISalPageNavigatorItemGetEnabledCount(HWND pageNavigatorWindow)
extern "C" __declspec(dllexport) int WINAPI UISalPageNavigatorItemGetExpandedCount(HWND pageNavigatorWindow)
{
// variables
int expandedCount = -1;
// access page navigator
CUIExtPageNavigatorWnd* extPageNavigator = (CUIExtPageNavigatorWnd*)CUIExtPageNavigatorWnd::FromHandlePermanent(pageNavigatorWindow);
if (extPageNavigator != NULL)
{
expandedCount = extPageNavigator->ItemGetExpandedCount();
}
return expandedCount;
}
extern "C" __declspec(dllexport) int WINAPI UISalPageNavigatorItemGetIndexOf(HWND pageNavigatorWindow, HANDLE itemHandle)
{
// variables
int itemIndex = -1;
// access page navigator
CUIExtPageNavigatorWnd* extPageNavigator = (CUIExtPageNavigatorWnd*)CUIExtPageNavigatorWnd::FromHandlePermanent(pageNavigatorWindow);
if (extPageNavigator != NULL)
{
itemIndex = extPageNavigator->ItemGetIndexOf((CUIExtPageNavigatorWnd::PAGE_ITEM_INFO*)itemHandle);
}
return itemIndex;
}
extern "C" __declspec(dllexport) HANDLE WINAPI UISalPageNavigatorItemGetPressed(HWND pageNavigatorWindow)
{
// variables
HANDLE itemPressed = NULL;
// access page navigator
CUIExtPageNavigatorWnd* extPageNavigator = (CUIExtPageNavigatorWnd*)CUIExtPageNavigatorWnd::FromHandlePermanent(pageNavigatorWindow);
if (extPageNavigator != NULL)
{
itemPressed = extPageNavigator->ItemGetPressed();
}
return itemPressed;
}
extern "C" __declspec(dllexport) int WINAPI UISalPageNavigatorItemGetVisibleCount(HWND pageNavigatorWindow)
{
// variables
int visibleCount = -1;
// access page navigator
CUIExtPageNavigatorWnd* extPageNavigator = (CUIExtPageNavigatorWnd*)CUIExtPageNavigatorWnd::FromHandlePermanent(pageNavigatorWindow);
if (extPageNavigator != NULL)
{
visibleCount = extPageNavigator->ItemGetVisibleCount();
}
return visibleCount;
}
extern "C" __declspec(dllexport) HANDLE WINAPI UISalPageNavigatorItemInsert(HWND pageNavigatorWindow, int index, LPCWSTR text, HICON iconExpanded, HICON iconCollapsed, DWORD data, BOOL update)
{
// variables
HANDLE itemHandle = NULL;
// access page navigator
CUIExtPageNavigatorWnd* extPageNavigator = (CUIExtPageNavigatorWnd*)CUIExtPageNavigatorWnd::FromHandlePermanent(pageNavigatorWindow);
if (extPageNavigator != NULL)
{
itemHandle = (HANDLE)extPageNavigator->ItemInsert((LONG)index, text, iconExpanded, iconCollapsed, data, update);
}
return itemHandle;
}
extern "C" __declspec(dllexport) BOOL WINAPI UISalPageNavigatorItemMove(HWND pageNavigatorWindow, int itemIndex, int itemNewIndex, BOOL persistent, BOOL update)
{
// variables
BOOL result = FALSE;
// access page navigator
CUIExtPageNavigatorWnd* extPageNavigator = (CUIExtPageNavigatorWnd*)CUIExtPageNavigatorWnd::FromHandlePermanent(pageNavigatorWindow);
if (extPageNavigator != NULL)
{
result = extPageNavigator->ItemMove((LONG)itemIndex, (LONG)itemNewIndex, persistent, update);
}
return result;
}
extern "C" __declspec(dllexport) void WINAPI UISalPageNavigatorItemRemove(HWND pageNavigatorWindow, int itemIndex, BOOL update)
{
// access page navigator
CUIExtPageNavigatorWnd* extPageNavigator = (CUIExtPageNavigatorWnd*)CUIExtPageNavigatorWnd::FromHandlePermanent(pageNavigatorWindow);
if (extPageNavigator != NULL)
{
extPageNavigator->ItemRemove((LONG)itemIndex, update);
}
return;
}
extern "C" __declspec(dllexport) void WINAPI UISalPageNavigatorItemRemoveAll(HWND pageNavigatorWindow, BOOL update)
{
// access page navigator
CUIExtPageNavigatorWnd* extPageNavigator = (CUIExtPageNavigatorWnd*)CUIExtPageNavigatorWnd::FromHandlePermanent(pageNavigatorWindow);
if (extPageNavigator != NULL)
{
extPageNavigator->ItemRemoveAll(update);
}
return;
}
extern "C" __declspec(dllexport) int WINAPI UISalPageNavigatorItemSetExpandedCount(HWND pageNavigatorWindow, int expandedCount)
{
// variables
int previousExpandedCount = -1;
// access page navigator
CUIExtPageNavigatorWnd* extPageNavigator = (CUIExtPageNavigatorWnd*)CUIExtPageNavigatorWnd::FromHandlePermanent(pageNavigatorWindow);
if (extPageNavigator != NULL)
{
previousExpandedCount = extPageNavigator->ItemGetExpandedCount();
extPageNavigator->ItemSetExpandedCount(expandedCount);
}
return previousExpandedCount;
}
extern "C" __declspec(dllexport) BOOL WINAPI UISalPageNavigatorItemsSwap(HWND pageNavigatorWindow, int itemIndex1, int itemIndex2, BOOL persistent, BOOL update)
{
// variables
BOOL result = FALSE;
// access page navigator
CUIExtPageNavigatorWnd* extPageNavigator = (CUIExtPageNavigatorWnd*)CUIExtPageNavigatorWnd::FromHandlePermanent(pageNavigatorWindow);
if (extPageNavigator != NULL)
{
result = extPageNavigator->ItemsSwap((LONG)itemIndex1, (LONG)itemIndex2, persistent, update);
}
return result;
}
extern "C" __declspec(dllexport) int WINAPI UISalPageNavigatorMinPageAreaHeightGet(HWND pageNavigatorWindow)
{
// variables
int minPageAreaHeight = -1;
// access page navigator
CUIExtPageNavigatorWnd* extPageNavigator = (CUIExtPageNavigatorWnd*)CUIExtPageNavigatorWnd::FromHandlePermanent(pageNavigatorWindow);
if (extPageNavigator != NULL)
{
minPageAreaHeight = extPageNavigator->MinPageAreaHeightGet();
}
return minPageAreaHeight;
}
extern "C" __declspec(dllexport) int WINAPI UISalPageNavigatorMinPageAreaHeightSet(HWND pageNavigatorWindow, int minPageAreaHeight)
{
// variables
int previousMinPageAreaHeight = -1;
// access page navigator
CUIExtPageNavigatorWnd* extPageNavigator = (CUIExtPageNavigatorWnd*)CUIExtPageNavigatorWnd::FromHandlePermanent(pageNavigatorWindow);
if (extPageNavigator != NULL)
{
previousMinPageAreaHeight = extPageNavigator->MinPageAreaHeightGet();
extPageNavigator->MinPageAreaHeightSet(minPageAreaHeight);
}
return previousMinPageAreaHeight;
}
extern "C" __declspec(dllexport) int WINAPI UISalPageNavigatorSelectionGet(HWND pageNavigatorWindow)
{
// variables
int selection = -1;
// access page navigator
CUIExtPageNavigatorWnd* extPageNavigator = (CUIExtPageNavigatorWnd*)CUIExtPageNavigatorWnd::FromHandlePermanent(pageNavigatorWindow);
if (extPageNavigator != NULL)
{
selection = extPageNavigator->SelectionGet();
}
return selection;
}
extern "C" __declspec(dllexport) int WINAPI UISalPageNavigatorSelectionSetIndex(HWND pageNavigatorWindow, int itemIndex)
{
// variables
int previousSelection = -1;
// access page navigator
CUIExtPageNavigatorWnd* extPageNavigator = (CUIExtPageNavigatorWnd*)CUIExtPageNavigatorWnd::FromHandlePermanent(pageNavigatorWindow);
if (extPageNavigator != NULL)
{
previousSelection = extPageNavigator->SelectionGet();
extPageNavigator->SelectionSet((LONG)itemIndex);
}
return previousSelection;
}
extern "C" __declspec(dllexport) int WINAPI UISalPageNavigatorSelectionSetHandle(HWND pageNavigatorWindow, HANDLE itemHandle)
{
// variables
int previousSelection = -1;
// access page navigator
CUIExtPageNavigatorWnd* extPageNavigator = (CUIExtPageNavigatorWnd*)CUIExtPageNavigatorWnd::FromHandlePermanent(pageNavigatorWindow);
if (extPageNavigator != NULL)
{
previousSelection = extPageNavigator->SelectionGet();
extPageNavigator->SelectionSet((CUIExtPageNavigatorWnd::PAGE_ITEM_INFO*)itemHandle);
}
return previousSelection;
}
extern "C" __declspec(dllexport) BOOL WINAPI UISalPageNavigatorShowSplitter(HWND pageNavigatorWindow, BOOL show, BOOL update)
{
// variables
BOOL previousVisible = FALSE;
// access page navigator
CUIExtPageNavigatorWnd* extPageNavigator = (CUIExtPageNavigatorWnd*)CUIExtPageNavigatorWnd::FromHandlePermanent(pageNavigatorWindow);
if (extPageNavigator != NULL)
{
previousVisible = extPageNavigator->ShowSplitter(show, update);
}
return previousVisible;
}
extern "C" __declspec(dllexport) BOOL WINAPI UISalPageNavigatorStateLoad(HWND pageNavigatorWindow, LPCWSTR company, LPCWSTR product, LPCWSTR profile, BOOL persistent, HKEY keyRoot)
{
// variables
BOOL result = FALSE;
// access page navigator
CUIExtPageNavigatorWnd* extPageNavigator = (CUIExtPageNavigatorWnd*)CUIExtPageNavigatorWnd::FromHandlePermanent(pageNavigatorWindow);
if (extPageNavigator != NULL)
{
result = extPageNavigator->StateLoad(company, product, profile, persistent, keyRoot);
}
return result;
}
extern "C" __declspec(dllexport) void WINAPI UISalPageNavigatorStateReset(HWND pageNavigatorWindow, BOOL persistent)
{
// access page navigator
CUIExtPageNavigatorWnd* extPageNavigator = (CUIExtPageNavigatorWnd*)CUIExtPageNavigatorWnd::FromHandlePermanent(pageNavigatorWindow);
if (extPageNavigator != NULL)
{
extPageNavigator->StateReset(persistent);
}
return;
}
extern "C" __declspec(dllexport) BOOL WINAPI UISalPageNavigatorStateSave(HWND pageNavigatorWindow, LPCWSTR company, LPCWSTR product, LPCWSTR profile, HKEY keyRoot)
{
// variables
BOOL result = FALSE;
// access page navigator
CUIExtPageNavigatorWnd* extPageNavigator = (CUIExtPageNavigatorWnd*)CUIExtPageNavigatorWnd::FromHandlePermanent(pageNavigatorWindow);
if (extPageNavigator != NULL)
{
result = extPageNavigator->StateSave(company, product, profile, keyRoot);
}
return result;
}
extern "C" __declspec(dllexport) void WINAPI UISalPageNavigatorUpdateWindow(HWND pageNavigatorWindow, BOOL update)
{
// access page navigator
CUIExtPageNavigatorWnd* extPageNavigator = (CUIExtPageNavigatorWnd*)CUIExtPageNavigatorWnd::FromHandlePermanent(pageNavigatorWindow);
if (extPageNavigator != NULL)
{
extPageNavigator->UpdatePageNavigatorWnd(update);
}
return;
}
extern "C" __declspec(dllexport) BOOL WINAPI UISalPageNavigatorShowConfigButton(HWND pageNavigatorWindow, BOOL show, BOOL update)
{
// variables
BOOL previousVisible = FALSE;
// access page navigator
CUIExtPageNavigatorWnd* extPageNavigator = (CUIExtPageNavigatorWnd*)CUIExtPageNavigatorWnd::FromHandlePermanent(pageNavigatorWindow);
if (extPageNavigator != NULL)
{
previousVisible = extPageNavigator->ShowConfigButton(show, update);
}
return previousVisible;
}
extern "C" __declspec(dllexport) BOOL WINAPI UISalPageNavigatorIsConfigButtonVisible(HWND pageNavigatorWindow)
{
// access page navigator
CUIExtPageNavigatorWnd* extPageNavigator = (CUIExtPageNavigatorWnd*)CUIExtPageNavigatorWnd::FromHandlePermanent(pageNavigatorWindow);
if (extPageNavigator != NULL)
{
return extPageNavigator->IsConfigButtonVisible();
}
return FALSE;
}
extern "C" __declspec(dllexport) HANDLE WINAPI UISalPageNavigatorItemPaneGetPressed(HWND pageNavigatorWindow)
{
// variables
HANDLE itemPressed = NULL;
// access page navigator
CUIExtPageNavigatorWnd* extPageNavigator = (CUIExtPageNavigatorWnd*)CUIExtPageNavigatorWnd::FromHandlePermanent(pageNavigatorWindow);
if (extPageNavigator != NULL)
{
itemPressed = (HANDLE)extPageNavigator->ItemPaneGetPressed();
}
return itemPressed;
}
extern "C" __declspec(dllexport) void WINAPI UISalPageNavigatorPageItemTextGet(HANDLE itemHandle, LPWSTR text, DWORD textSize)
{
// access page navigator item
CUIExtPageNavigatorWnd::PAGE_ITEM_INFO* pageItem = (CUIExtPageNavigatorWnd::PAGE_ITEM_INFO*)itemHandle;
// call the function
__EXT_MFC_SAFE_LPCTSTR itemText = pageItem->TextGet();
wcscpy_s(text, textSize, itemText);
return;
}
extern "C" __declspec(dllexport) void WINAPI UISalPageNavigatorPageItemTextSet(HANDLE itemHandle, LPCWSTR text)
{
// access page navigator item
CUIExtPageNavigatorWnd::PAGE_ITEM_INFO* pageItem = (CUIExtPageNavigatorWnd::PAGE_ITEM_INFO*)itemHandle;
// call the function
pageItem->TextSet(text);
return;
}
extern "C" __declspec(dllexport) LPARAM WINAPI UISalPageNavigatorPageItemLParamGet(HANDLE itemHandle)
{
// access page navigator item
CUIExtPageNavigatorWnd::PAGE_ITEM_INFO* pageItem = (CUIExtPageNavigatorWnd::PAGE_ITEM_INFO*)itemHandle;
// call the function
return pageItem->LParamGet();
}
extern "C" __declspec(dllexport) LPARAM WINAPI UISalPageNavigatorPageItemLParamSet(HANDLE itemHandle, LPARAM param)
{
// variables
LPARAM previousParam = 0;
// access page navigator item
CUIExtPageNavigatorWnd::PAGE_ITEM_INFO* pageItem = (CUIExtPageNavigatorWnd::PAGE_ITEM_INFO*)itemHandle;
// call the function
previousParam = pageItem->LParamGet();
pageItem->LParamSet(param);
return previousParam;
}
extern "C" __declspec(dllexport) void WINAPI UISalPageNavigatorPageItemTooltipGet(HANDLE itemHandle, LPWSTR tooltip, DWORD tooltipSize)
{
// access page navigator item
CUIExtPageNavigatorWnd::PAGE_ITEM_INFO* pageItem = (CUIExtPageNavigatorWnd::PAGE_ITEM_INFO*)itemHandle;
// call the function
__EXT_MFC_SAFE_LPCTSTR itemTooltip = pageItem->TooltipGet();
wcscpy_s(tooltip, tooltipSize, itemTooltip);
return;
}
extern "C" __declspec(dllexport) void WINAPI UISalPageNavigatorPageItemTooltipSet(HANDLE itemHandle, LPCWSTR tooltip)
{
// access page navigator item
CUIExtPageNavigatorWnd::PAGE_ITEM_INFO* pageItem = (CUIExtPageNavigatorWnd::PAGE_ITEM_INFO*)itemHandle;
// call the function
pageItem->TooltipSet(tooltip);
return;
}
extern "C" __declspec(dllexport) void WINAPI UISalPageNavigatorPageItemIconGetSize(HANDLE itemHandle, BOOL expanded, LONG* width, LONG* height)
{
// access page navigator item
CUIExtPageNavigatorWnd::PAGE_ITEM_INFO* pageItem = (CUIExtPageNavigatorWnd::PAGE_ITEM_INFO*)itemHandle;
// call the function
CSize size = pageItem->IconGetSize(expanded);
*width = size.cx;
*height = size.cy;
return;
}
extern "C" __declspec(dllexport) HICON WINAPI UISalPageNavigatorPageItemIconGetHandle(HANDLE itemHandle, BOOL expanded)
{
// access page navigator item
CUIExtPageNavigatorWnd::PAGE_ITEM_INFO* pageItem = (CUIExtPageNavigatorWnd::PAGE_ITEM_INFO*)itemHandle;
// call the function
CExtCmdIcon* iconPtr = pageItem->IconGetPtr(expanded);
return iconPtr->ExtractHICON();
}
extern "C" __declspec(dllexport) void WINAPI UISalPageNavigatorPageItemIconSet(HANDLE itemHandle, HICON icon, BOOL expanded)
{
// access page navigator item
CUIExtPageNavigatorWnd::PAGE_ITEM_INFO* pageItem = (CUIExtPageNavigatorWnd::PAGE_ITEM_INFO*)itemHandle;
// call the function
pageItem->IconSet(icon, expanded);
return;
}
extern "C" __declspec(dllexport) void WINAPI UISalPageNavigatorPageItemShow(HANDLE itemHandle)
{
// access page navigator item
CUIExtPageNavigatorWnd::PAGE_ITEM_INFO* pageItem = (CUIExtPageNavigatorWnd::PAGE_ITEM_INFO*)itemHandle;
// call the function
pageItem->Show();
return;
}
extern "C" __declspec(dllexport) void WINAPI UISalPageNavigatorPageItemHide(HANDLE itemHandle)
{
// access page navigator item
CUIExtPageNavigatorWnd::PAGE_ITEM_INFO* pageItem = (CUIExtPageNavigatorWnd::PAGE_ITEM_INFO*)itemHandle;
// call the function
pageItem->Hide();
return;
}
extern "C" __declspec(dllexport) void WINAPI UISalPageNavigatorPageItemVisibleSet(HANDLE itemHandle, BOOL visible)
{
// access page navigator item
CUIExtPageNavigatorWnd::PAGE_ITEM_INFO* pageItem = (CUIExtPageNavigatorWnd::PAGE_ITEM_INFO*)itemHandle;
// call the function
if (visible)
{
pageItem->Show();
}
else
{
pageItem->Hide();
}
return;
}
extern "C" __declspec(dllexport) BOOL WINAPI UISalPageNavigatorPageItemEnabledGet(HANDLE itemHandle)
{
// access page navigator item
CUIExtPageNavigatorWnd::PAGE_ITEM_INFO* pageItem = (CUIExtPageNavigatorWnd::PAGE_ITEM_INFO*)itemHandle;
// call the function
return pageItem->EnabledGet();
}
extern "C" __declspec(dllexport) BOOL WINAPI UISalPageNavigatorPageItemEnabledSet(HANDLE itemHandle, BOOL enabled, BOOL persistent)
{
// variables
BOOL previousEnabled = FALSE;
// access page navigator item
CUIExtPageNavigatorWnd::PAGE_ITEM_INFO* pageItem = (CUIExtPageNavigatorWnd::PAGE_ITEM_INFO*)itemHandle;
// call the function
previousEnabled = pageItem->EnabledGet();
pageItem->EnabledSet(enabled, persistent);
return previousEnabled;
}
extern "C" __declspec(dllexport) HANDLE WINAPI UISalPageNavigatorPageItemHitTestPane(HANDLE itemHandle, int x, int y)
{
// access page navigator item
CUIExtPageNavigatorWnd::PAGE_ITEM_INFO* pageItem = (CUIExtPageNavigatorWnd::PAGE_ITEM_INFO*)itemHandle;
// call the function
POINT point;
point.x = x;
point.y = y;
return (HANDLE)pageItem->HitTestPane(point);
}
extern "C" __declspec(dllexport) HANDLE WINAPI UISalPageNavigatorPageItemPaneInsert(HANDLE itemHandle, HWND paneWindow, int index, LPCWSTR text, int height, BOOL update)
{
// access page navigator item
CUIExtPageNavigatorWnd::PAGE_ITEM_INFO* pageItem = (CUIExtPageNavigatorWnd::PAGE_ITEM_INFO*)itemHandle;
// call the function
return (HANDLE)pageItem->PaneInsert(paneWindow, index, text, height, update);
}
extern "C" __declspec(dllexport) HANDLE WINAPI UISalPageNavigatorPageItemPaneGetHandle(HANDLE itemHandle, int index)
{
// access page navigator item
CUIExtPageNavigatorWnd::PAGE_ITEM_INFO* pageItem = (CUIExtPageNavigatorWnd::PAGE_ITEM_INFO*)itemHandle;
// call the function
return (HANDLE)pageItem->PaneGetInfo((LONG)index);
}
extern "C" __declspec(dllexport) int WINAPI UISalPageNavigatorPageItemPaneGetCount(HANDLE itemHandle)
{
// access page navigator item
CUIExtPageNavigatorWnd::PAGE_ITEM_INFO* pageItem = (CUIExtPageNavigatorWnd::PAGE_ITEM_INFO*)itemHandle;
// call the function
return (int)pageItem->PaneGetCount();
}
extern "C" __declspec(dllexport) BOOL WINAPI UISalPageNavigatorPageItemPaneRemove(HANDLE itemHandle, int index, BOOL update)
{
// access page navigator item
CUIExtPageNavigatorWnd::PAGE_ITEM_INFO* pageItem = (CUIExtPageNavigatorWnd::PAGE_ITEM_INFO*)itemHandle;
// call the function
return pageItem->PaneRemove((LONG)index, update);
}
extern "C" __declspec(dllexport) BOOL WINAPI UISalPageNavigatorPageItemPaneRemoveAll(HANDLE itemHandle, BOOL update)
{
// access page navigator item
CUIExtPageNavigatorWnd::PAGE_ITEM_INFO* pageItem = (CUIExtPageNavigatorWnd::PAGE_ITEM_INFO*)itemHandle;
// call the function
return pageItem->PaneRemoveAll(update);
}
extern "C" __declspec(dllexport) BOOL WINAPI UISalPageNavigatorPageItemPaneExpand(HANDLE itemHandle, int index, int expandType, BOOL update)
{
// access page navigator item
CUIExtPageNavigatorWnd::PAGE_ITEM_INFO* pageItem = (CUIExtPageNavigatorWnd::PAGE_ITEM_INFO*)itemHandle;
// call the function
return pageItem->PaneExpand((LONG)index, (CUIExtPageNavigatorWnd::ITEM_PANE_INFO::e_ExpandType_t)expandType, update);
}
extern "C" __declspec(dllexport) BOOL WINAPI UISalPageNavigatorPageItemPaneIsExpanded(HANDLE itemHandle, int index)
{
// access page navigator item
CUIExtPageNavigatorWnd::PAGE_ITEM_INFO* pageItem = (CUIExtPageNavigatorWnd::PAGE_ITEM_INFO*)itemHandle;
// call the function
return pageItem->PaneIsExpanded((LONG)index);
}
extern "C" __declspec(dllexport) BOOL WINAPI UISalPageNavigatorPageItemPaneExpandableGet(HANDLE itemHandle, int index)
{
// access page navigator item
CUIExtPageNavigatorWnd::PAGE_ITEM_INFO* pageItem = (CUIExtPageNavigatorWnd::PAGE_ITEM_INFO*)itemHandle;
// call the function
return pageItem->PaneExpandableGet((LONG)index);
}
extern "C" __declspec(dllexport) BOOL WINAPI UISalPageNavigatorPageItemPaneExpandableSet(HANDLE itemHandle, int index, BOOL expandable)
{
// variables
BOOL previousExpandable = FALSE;
// access page navigator item
CUIExtPageNavigatorWnd::PAGE_ITEM_INFO* pageItem = (CUIExtPageNavigatorWnd::PAGE_ITEM_INFO*)itemHandle;
// call the function
previousExpandable = pageItem->PaneExpandableGet((LONG)index);
pageItem->PaneExpandableSet((LONG)index, expandable);
return previousExpandable;
}
extern "C" __declspec(dllexport) HWND WINAPI UISalPageNavigatorPaneItemGetSafeHwnd(HANDLE paneItemHandle)
{
// access page navigator pane item
CUIExtPageNavigatorWnd::ITEM_PANE_INFO* paneItem = (CUIExtPageNavigatorWnd::ITEM_PANE_INFO*)paneItemHandle;
// call the function
return paneItem->GetSafeHwnd();
}
extern "C" __declspec(dllexport) void WINAPI UISalPageNavigatorPaneItemTextGet(HANDLE paneItemHandle, LPWSTR text, DWORD textSize)
{
// access page navigator pane item
CUIExtPageNavigatorWnd::ITEM_PANE_INFO* paneItem = (CUIExtPageNavigatorWnd::ITEM_PANE_INFO*)paneItemHandle;
// call the function
__EXT_MFC_SAFE_LPCTSTR itemText = paneItem->TextGet();
wcscpy_s(text, textSize, itemText);
return;
}
extern "C" __declspec(dllexport) void WINAPI UISalPageNavigatorPaneItemTextSet(HANDLE paneItemHandle, LPCWSTR text)
{
// access page navigator pane item
CUIExtPageNavigatorWnd::ITEM_PANE_INFO* paneItem = (CUIExtPageNavigatorWnd::ITEM_PANE_INFO*)paneItemHandle;
// call the function
paneItem->TextSet(text);
return;
}
extern "C" __declspec(dllexport) BOOL WINAPI UISalPageNavigatorPaneItemExpand(HANDLE paneItemHandle, int expandType, BOOL update)
{
// access page navigator pane item
CUIExtPageNavigatorWnd::ITEM_PANE_INFO* paneItem = (CUIExtPageNavigatorWnd::ITEM_PANE_INFO*)paneItemHandle;
// call the function
return paneItem->Expand((CUIExtPageNavigatorWnd::ITEM_PANE_INFO::e_ExpandType_t)expandType, update);
}
extern "C" __declspec(dllexport) BOOL WINAPI UISalPageNavigatorPaneItemIsExpanded(HANDLE paneItemHandle)
{
// access page navigator pane item
CUIExtPageNavigatorWnd::ITEM_PANE_INFO* paneItem = (CUIExtPageNavigatorWnd::ITEM_PANE_INFO*)paneItemHandle;
// call the function
return paneItem->IsExpanded();
}
extern "C" __declspec(dllexport) BOOL WINAPI UISalPageNavigatorPaneItemExpandableGet(HANDLE paneItemHandle)
{
// access page navigator pane item
CUIExtPageNavigatorWnd::ITEM_PANE_INFO* paneItem = (CUIExtPageNavigatorWnd::ITEM_PANE_INFO*)paneItemHandle;
// call the function
return paneItem->ExpandableGet();
}
extern "C" __declspec(dllexport) BOOL WINAPI UISalPageNavigatorPaneItemExpandableSet(HANDLE paneItemHandle, BOOL expandable)
{
// variables
BOOL previousExpandable = FALSE;
// access page navigator pane item
CUIExtPageNavigatorWnd::ITEM_PANE_INFO* paneItem = (CUIExtPageNavigatorWnd::ITEM_PANE_INFO*)paneItemHandle;
// call the function
previousExpandable = paneItem->ExpandableGet();
paneItem->ExpandableSet(expandable);
return previousExpandable;
}
extern "C" __declspec(dllexport) void WINAPI UISalPageNavigatorPaneItemRectGet(HANDLE paneItemHandle, LONG* x, LONG* y, LONG* width, LONG* height)
{
// access page navigator pane item
CUIExtPageNavigatorWnd::ITEM_PANE_INFO* paneItem = (CUIExtPageNavigatorWnd::ITEM_PANE_INFO*)paneItemHandle;
// call the function
CRect rect = paneItem->ItemRectGet();
*x = rect.left;
*y = rect.top;
*width = rect.right - rect.left;
*height = rect.bottom - rect.top;
return;
}
extern "C" __declspec(dllexport) void WINAPI UISalPageNavigatorPaneItemRectSet(HANDLE paneItemHandle, LONG x, LONG y, LONG width, LONG height)
{
// access page navigator pane item
CUIExtPageNavigatorWnd::ITEM_PANE_INFO* paneItem = (CUIExtPageNavigatorWnd::ITEM_PANE_INFO*)paneItemHandle;
// call the function
paneItem->ItemRectSet((int)x, (int)y, (int)(x + width), (int)(y + height));
return;
}
extern "C" __declspec(dllexport) void WINAPI UISalPageNavigatorPaneItemRectSetEmpty(HANDLE paneItemHandle)
{
// access page navigator pane item
CUIExtPageNavigatorWnd::ITEM_PANE_INFO* paneItem = (CUIExtPageNavigatorWnd::ITEM_PANE_INFO*)paneItemHandle;
// call the function
paneItem->ItemRectSetEmpty();
return;
}
extern "C" __declspec(dllexport) void WINAPI UISalPageNavigatorPaneItemCaptionRectGet(HANDLE paneItemHandle, LONG* x, LONG* y, LONG* width, LONG* height)
{
// access page navigator pane item
CUIExtPageNavigatorWnd::ITEM_PANE_INFO* paneItem = (CUIExtPageNavigatorWnd::ITEM_PANE_INFO*)paneItemHandle;
// call the function
CRect rect = paneItem->CaptionRectGet();
*x = rect.left;
*y = rect.top;
*width = rect.right - rect.left;
*height = rect.bottom - rect.top;
return;
}
extern "C" __declspec(dllexport) void WINAPI UISalPageNavigatorPaneItemCaptionRectSet(HANDLE paneItemHandle, LONG x, LONG y, LONG width, LONG height)
{
// access page navigator pane item
CUIExtPageNavigatorWnd::ITEM_PANE_INFO* paneItem = (CUIExtPageNavigatorWnd::ITEM_PANE_INFO*)paneItemHandle;
// call the function
paneItem->CaptionRectSet((int)x, (int)y, (int)(x + width), (int)(y + height));
return;
}
extern "C" __declspec(dllexport) void WINAPI UISalPageNavigatorPaneItemCaptionRectSetEmpty(HANDLE paneItemHandle)
{
// access page navigator pane item
CUIExtPageNavigatorWnd::ITEM_PANE_INFO* paneItem = (CUIExtPageNavigatorWnd::ITEM_PANE_INFO*)paneItemHandle;
// call the function
paneItem->CaptionRectSetEmpty();
return;
}
extern "C" __declspec(dllexport) int WINAPI UISalPageNavigatorPaneItemHeightGet(HANDLE paneItemHandle)
{
// access page navigator pane item
CUIExtPageNavigatorWnd::ITEM_PANE_INFO* paneItem = (CUIExtPageNavigatorWnd::ITEM_PANE_INFO*)paneItemHandle;
// call the function
return paneItem->HeightGet();
}
extern "C" __declspec(dllexport) int WINAPI UISalPageNavigatorPaneItemHeightSet(HANDLE paneItemHandle, int height)
{
// variables
int previousHeight = -1;
// access page navigator pane item
CUIExtPageNavigatorWnd::ITEM_PANE_INFO* paneItem = (CUIExtPageNavigatorWnd::ITEM_PANE_INFO*)paneItemHandle;
// call the function
previousHeight = paneItem->HeightGet();
paneItem->HeightSet(height);
return previousHeight;
}
extern "C" __declspec(dllexport) LPARAM WINAPI UISalPageNavigatorPaneItemLParamGet(HANDLE paneItemHandle)
{
// access page navigator pane item
CUIExtPageNavigatorWnd::ITEM_PANE_INFO* paneItem = (CUIExtPageNavigatorWnd::ITEM_PANE_INFO*)paneItemHandle;
// call the function
return paneItem->LParamGet();
}
extern "C" __declspec(dllexport) LPARAM WINAPI UISalPageNavigatorPaneItemLParamSet(HANDLE paneItemHandle, LPARAM param)
{
// variables
LPARAM previousParam = 0;
// access page navigator pane item
CUIExtPageNavigatorWnd::ITEM_PANE_INFO* paneItem = (CUIExtPageNavigatorWnd::ITEM_PANE_INFO*)paneItemHandle;
// call the function
previousParam = paneItem->LParamGet();
paneItem->LParamSet(param);
return previousParam;
}
|
#include "_pch.h"
#include "ViewObjPropList.h"
#include "whPGFileLinkProperty.h"
using namespace wh;
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
ViewObjPropList::ViewObjPropList(wxWindow* parent)
{
wxSizer *mainSz = new wxBoxSizer(wxVERTICAL);
mPanel = new wxPanel(parent, wxID_ANY);
mPG = new wxPropertyGrid(mPanel, wxID_ANY
, wxDefaultPosition, wxDefaultSize
, wxPG_SPLITTER_AUTO_CENTER);
mPG->CenterSplitter(true);
mainSz->Add(mPG, 1, wxALL | wxEXPAND, 0);
mPanel->SetSizer(mainSz);
mPanel->Layout();
}
//-----------------------------------------------------------------------------
ViewObjPropList::ViewObjPropList(const std::shared_ptr<IViewWindow>& parent)
:ViewObjPropList(parent->GetWnd())
{
}
//-----------------------------------------------------------------------------
wxWindow* ViewObjPropList::GetWnd()const
{
return mPanel;
}
//-----------------------------------------------------------------------------
//virtual
void ViewObjPropList::SetPropList(const PropValTable& rt, const IAct* act) //override;
{
bool visible = mPanel->IsShown();
//if (!visible)
// return;
auto p0 = GetTickCount();
mPG->Clear();
for (const auto& curr : rt)
{
wxPGProperty* pgp = nullptr;
const wxString& pgp_title = curr->GetProp().GetTitle();
const wxString pgp_name = wxString::Format("ObjProp_%s", curr->GetProp().GetId());
switch (curr->GetProp().GetType() )
{
case ftText: pgp = new wxLongStringProperty(pgp_title, pgp_name); break;
case ftName: pgp = new wxStringProperty(pgp_title, pgp_name); break;
case ftLong:
pgp = new wxStringProperty(pgp_title, pgp_name);
pgp->SetValidator(wxTextValidator(wxFILTER_NUMERIC));
break;
case ftDouble: pgp = new wxFloatProperty(pgp_title, pgp_name); break;
case ftDate: pgp = new wxStringProperty(pgp_title, pgp_name); break;
case ftLink: pgp = new whPGFileLinkProperty(pgp_title, pgp_name); break;
case ftFile: pgp = new wxStringProperty(pgp_title, pgp_name); break;
case ftJSON: pgp = new wxLongStringProperty(pgp_title, pgp_name); break;
default:break;
}
pgp->SetValueFromString(curr->GetValue());
pgp->SetFlagRecursively(wxPG_PROP_READONLY, true);
mPG->Append(pgp);
if (act)
{
const auto& propIdIdx = act->GetPropList().get<1>();
const auto it = propIdIdx.find(curr->GetProp().GetId());
if (propIdIdx.end() != it)
{
wxColour clr = act->GetColour().IsEmpty() ? *wxWHITE : act->GetColour();
pgp->SetBackgroundColour(clr);
}
}
}
//mPG->FitColumns();
mPG->Sort(); // wxPG_SORT_TOP_LEVEL_ONLY
wxLogMessage(wxString::Format("ViewObjPropList:\t%d\t SetPropList", GetTickCount() - p0));
}
//-----------------------------------------------------------------------------
void ViewObjPropList::OnCmd_Update(wxCommandEvent& evt)
{
wxBusyCursor busyCursor;
wxWindowUpdateLocker lock(mPanel);
sigUpdate();
}
//-----------------------------------------------------------------------------
//IViewWindow virtual
void ViewObjPropList::SetShow()//override
{
//OnCmd_Update();
}
//-----------------------------------------------------------------------------
|
/*
Copyright 2016 Vladimir Lysyy (mrbald@github)
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
#pragma once
#include <atomic>
#include <type_traits>
#include <immintrin.h>
namespace ufw {
#if __x86_64__
inline
#endif
namespace x86_64 {
inline void zzz() noexcept { _mm_pause(); }
}
namespace details {
inline constexpr size_t l1d_line_size = 64u;
template <class T, class S, bool CallCtor, bool CallDtor> struct lifecycle_tracker;
template <class T, class S> struct lifecycle_tracker<T, S, false, false> {
explicit lifecycle_tracker(S&) {}
};
template <class T, class S> struct lifecycle_tracker<T, S, true, false> {
explicit lifecycle_tracker(S& node) { new (&node) T; }
};
template <class T, class S> struct lifecycle_tracker<T, S, false, true> {
S& node_;
explicit lifecycle_tracker(S& node): node_(node) {}
~lifecycle_tracker() { reinterpret_cast<T&>(node_).~T(); }
};
} // namespace details
/**
A symmetric single-actor-per-station pipeline.
[(X-1)%N] <<== can consume from == [X%N] == can produce for ==>> [(X+1)%N]
* @tparam T data type
* @tparam C ring buffer capacity
* @tparam N number of stages (default = 2, an spsc queue)
* @tparam L first stage IDx (default = 0)
*/
template <class T, size_t C, size_t N = 2, size_t L = 0> struct pipeline {
static_assert(C <= std::numeric_limits<size_t>::max() && N >= 2 && L < N);
using value_type = T;
static constexpr auto CAP = C;
static constexpr auto STG = N;
static constexpr auto FIRST_STAGE_ID = L;
static constexpr auto LAST_STAGE_ID = (L - 1) + (STG * !L);
using node_t = std::aligned_storage_t<sizeof(T), alignof(T)>;
private:
static constexpr size_t CAUGHT_UP_BIT = 1ull << 63u;
struct stage { alignas(details::l1d_line_size) std::atomic<size_t> pos_ {CAUGHT_UP_BIT}; };
std::array<stage, STG> stages_;
std::array<node_t, CAP> nodes_;
size_t static mod_cap(size_t x) noexcept { return x - C * (x >= C); }
public:
pipeline() noexcept {
stages_[LAST_STAGE_ID].pos_ ^= CAUGHT_UP_BIT;
}
/**
* Callback signature: void(node_t*, size_t len, Args...)
* "V" is for ???
*/
template <size_t X, size_t BATCH_SIZE = CAP, class Func, class... Args>
size_t invokev(Func&& func, Args&&... args) noexcept {
static_assert(X >= 0 && X < STG && BATCH_SIZE <= CAP);
static_assert(std::is_nothrow_invocable_v<Func, node_t*, size_t, Args...>);
if (!BATCH_SIZE) return 0;
auto& cur_stage_pos_ = stages_[X].pos_;
auto& prev_stage_pos_ = stages_[(X - 1) + (STG * !X)].pos_;
auto const prev_stage_pos_masked = prev_stage_pos_.load(std::memory_order_acquire);
if (prev_stage_pos_masked & CAUGHT_UP_BIT)
return 0;
auto const cur_stage_pos_masked = cur_stage_pos_.load(std::memory_order_acquire);
auto const cur_stage_pos = cur_stage_pos_masked & ~CAUGHT_UP_BIT;
auto prev_stage_pos = prev_stage_pos_masked & ~CAUGHT_UP_BIT;
size_t const batch_size_possible = prev_stage_pos - cur_stage_pos + CAP * (prev_stage_pos <= cur_stage_pos);
size_t const batch_size = std::min(BATCH_SIZE, batch_size_possible);
if (cur_stage_pos + batch_size > CAP) {
func(&nodes_[cur_stage_pos], CAP - cur_stage_pos, std::forward<Args>(args)...);
func(&nodes_[0], batch_size - (CAP - cur_stage_pos), std::forward<Args>(args)...);
} else {
func(&nodes_[cur_stage_pos], batch_size, std::forward<Args>(args)...);
}
// raise caught-up bit if the previous stage has not made the progress
// and the current stage has consumed all values
if (batch_size == batch_size_possible)
prev_stage_pos_.compare_exchange_strong(prev_stage_pos,
prev_stage_pos | CAUGHT_UP_BIT,
std::memory_order_acq_rel, std::memory_order_relaxed);
// save unmasked value to release the consumer
cur_stage_pos_.store(mod_cap(cur_stage_pos + batch_size), std::memory_order_release);
return batch_size;
}
/**
* Callback signature: void(node_t&, Args...)
* "M" is for "multi"
*/
template <size_t X, size_t BATCH_SIZE = CAP, class Func, class... Args>
size_t invokem(Func&& func, Args&&... args) noexcept {
static_assert(std::is_nothrow_invocable_v<Func, node_t&, Args...>);
return invokev<X, BATCH_SIZE>([&func] (node_t* beg, size_t len, Args&&... args) noexcept -> decltype(auto) {
for (auto *ptr = beg, *end = beg + len; ptr < end; ++ptr)
func(*ptr, std::forward<Args>(args)...);
}, std::forward<Args>(args)...);
}
/**
* Callback signature: void (T&, Args...)
* Automatically constructs the T before the first stage invocation
* and destructs after the last stage invocation
*/
template <size_t X, size_t n = C, class Func, class... Args>
size_t invoke(Func&& func, Args&&... args) noexcept {
static_assert(std::is_nothrow_invocable_v<Func, T&, Args...>);
return invokem<X, n>([&func] (node_t& node, Args&&... args) noexcept -> decltype(auto) {
details::lifecycle_tracker<T, node_t,
X == FIRST_STAGE_ID && !std::is_trivially_constructible<T>::value,
X == LAST_STAGE_ID && !std::is_trivially_destructible<T>::value> _(node);
return func(reinterpret_cast<T&>(node), std::forward<Args>(args)...);
}, std::forward<Args>(args)...);
}
};
} // namespace ufw
|
#include "SDL.h"
#undef main
#include <iostream>
#include "Game.h"
#include "MainMenuState.h"
int main(int argc, char* argv[])
{
int const FPS = 60;
int const frameDelay = 1000 / FPS;
Uint32 frameStart;
int frameTime;
Game game;
game.init("Eight Minute Empire", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, WINDOW_X_SMALL, WINDOW_Y, SDL_WINDOW_SHOWN );
game.changeState(MainMenuState::Instance());
while (game.isRunning())
{
frameStart = SDL_GetTicks();
game.handleEvents();
game.update();
game.draw();
frameTime = SDL_GetTicks() - frameStart;
if (frameDelay > frameTime)
SDL_Delay(frameDelay - frameTime);
}
game.clean();
return 0;
}
|
#include<bits/stdc++.h>
#define FAST1 ios_base::sync_with_stdio(false);
#define FAST2 cin.tie(NULL);
using namespace std;
#define ll long long
#define pb push_back
ll dp[100005];
ll freq[100005];
int main(){
FAST1;
FAST2;
int n,mx=0;
cin>>n;
int a[n];
for(int i=0;i<n;i++){
cin>>a[i];
freq[a[i]]++;
mx=max(mx,a[i]);
}
dp[1]=freq[1];
for(int i=2;i<=mx;i++){
dp[i] = max((dp[i-2]+(freq[i]*i)),dp[i-1]);
}
cout<<dp[mx];
return 0;
}
|
#include <iostream>
#include <stdlib.h>
using namespace std;
int main(){
int n, m, resp;
cout<<"Ingrese el numero de columnas de la matriz: ";
cin>>n;
cout<<"Ingrese el numero de filas de la matriz: ";
cin>>m;
float matriz[n][m];
for (int i = 0; i < n; i++){
for (int j = 0; j < m; j++){
cout<<"Ingese un valor para ["<<i<<", "<<j<<"]: ";
cin>>matriz[i][j];
}
}
cout<<"Quieres editar un valor? 1-Si 2-No"<<endl;
cin>>resp;
while(resp!=1 && resp!=2){
cout<<"Incorrecto, insgresa de nuevo ";
cin>>resp;
}
if(resp==1){
int fil, col;
float val;
do{
cout<<"Ingrese la fila del elemento: ";
cin>>fil;
cout<<"Ingrese la columna del elemento: ";
cin>>col;
cout<<"Ingrese el nuevo valor: ";
cin>>val;
matriz[fil][col]=val;
cout<<"Quieres editar otro valor? 1-Si 2-No"<<endl;
cin>>resp;
while(resp!=1 && resp!=2){
cout<<"Incorrecto, insgresa de nuevo ";
cin>>resp;
}
}while(resp==1);
}
for (int i = 0; i < n; i++){
cout<<endl;
for (int j = 0; j < m; j++){
cout<<matriz[i][j]<<" ";
}
}
}
|
#pragma once
#include"ProductionManager.h"
#include"ParserState.h"
#include<iomanip>
#include"token.h"
#include<vector>
#include"SyntaxTree.h"
class BottomUpParser
{
public:
BottomUpParser(set<string>terminators, set<string> nonTerminators, vector<vector<string>> productions,string begin="S1",string end="$",string none="none");
virtual ~BottomUpParser();
virtual void buildParserGraph() = 0; //构造状态图
virtual void buildParserTable() = 0; //构造分析表
virtual void printPaserTable(const int width=4,const int height =1)const; //打印状态表
virtual void outPaserTableAsFile (ofstream& fout, const int width = 4, const int height = 1)const; //打印状态表
virtual void outProductionsAsFile(ofstream& fout); //打印产生式
virtual void outParserModel(ofstream& fout) {};
virtual bool scanTokenStream(vector<token> tokenstream , string analyze_report_dir );//从 tokenstream中进行语法分析,并且将分析报告(分析过程,语法树等)和分析模型(状态图,状态表输出到文件中)
vector<pair<string, int>> getOperations(int state, string input)const;
static void printStack(vector<int> state_stack, vector<string> string_stack, vector<token> input, int begin);
static void outputStackAsFile(ofstream& fout,vector<int> state_stack, vector<string> string_stack, vector<token> input ,int begin);
Production getProductionById(int p_id); //通过 id返回唯一的表达式
void sloveAmbiguousTable(vector< pair<int, pair<string, int>>> deleteOperations);
ATTRIBUTE_MEMBER_FUNC(set<string>, nonTerminators);
ATTRIBUTE_MEMBER_FUNC(set<string>, terminators);
ATTRIBUTE_READ_ONLY(string, end);
ATTRIBUTE_READ_ONLY(string, none);
ATTRIBUTE_READ_ONLY(string, begin);
protected:
string begin;
string end;
string none;
set<string>terminators; //终结符号,(包括$,一定) ,不应该重复,
set<string> nonTerminators; //非终结节点,具体表现为分析表的纵坐标的值不应该重复,
unordered_map<string,int> tableItems_map; //分析表的纵坐标和int 对应的字典
vector<string> tableItems; // 分析表的纵坐标, 和 map 互相映射
vector<string> production_base_head; // base_head 和 base_id互相映射
unordered_map<string, int> production_base_id;
vector<vector<string>> string_productions; //产生式
vector<vector<vector<std::pair<string,int>>>> parserTable; //分析表 pair第一个表示 类型 s 转移,r规约, int 表示目标
ProductionManager pm; //所有的节点都保存在pm中
};
|
/*
* Copyright (c) 2016-2021 Morwenn
* SPDX-License-Identifier: MIT
*/
#include <algorithm>
#include <forward_list>
#include <iterator>
#include <vector>
#include <catch2/catch.hpp>
#include <cpp-sort/probes/max.h>
#include <cpp-sort/utility/size.h>
#include <testing-tools/distributions.h>
#include <testing-tools/internal_compare.h>
TEST_CASE( "presortedness measure: max", "[probe][max]" )
{
using cppsort::probe::max;
SECTION( "simple test" )
{
std::forward_list<int> li = { 12, 28, 17, 59, 13, 10, 39, 21, 31, 30 };
CHECK( (max)(li) == 6 );
CHECK( (max)(li.begin(), li.end()) == 6 );
std::vector<internal_compare<int>> tricky(li.begin(), li.end());
CHECK( (max)(tricky, &internal_compare<int>::compare_to) == 6 );
}
SECTION( "upper bound" )
{
// The upper bound should correspond to the size of
// the input sequence minus one
std::forward_list<int> li = { 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 };
auto max_n = (max).max_for_size(cppsort::utility::size(li));
CHECK( max_n == 10 );
CHECK( (max)(li) == max_n );
CHECK( (max)(li.begin(), li.end()) == max_n );
}
SECTION( "regressions" )
{
std::vector<int> collection;
collection.reserve(100);
auto distribution = dist::ascending_sawtooth{};
distribution(std::back_inserter(collection), 100);
std::sort(collection.begin(), collection.end());
CHECK( (max)(collection) == 0 );
}
}
|
//wtp QuickSort
#include <iostream>
using namespace std;
int partition(int arr[], int start, int end)
{
int pivot = arr[end];
int pIndex = start;
for (int i = start; i < end; i++)
{
if (arr[i] < pivot)
{
int temp = arr[i];
arr[i] = arr[pIndex];
arr[pIndex] = temp;
pIndex++;
}
}
int temp = arr[end];
arr[end] = arr[pIndex];
arr[pIndex] = temp;
return pIndex;
}
void QuickSort(int arr[], int start, int end)
{
int p;
if (start < end)
{
p = partition(arr, start, end);
QuickSort(arr, start, (p - 1));
QuickSort(arr, (p + 1), end);
}
}
int main()
{
int myArray[5];
cout << "Enter the 5 Elements" << endl;
for (int i = 0; i < 5; i++)
{
cin >> myArray[i];
}
cout << "Before Sorting" << endl;
for (int j = 0; j < 5; j++)
{
cout << myArray[j] << " ";
}
QuickSort(myArray, 0, 4);
cout << endl;
cout << "After Sorting Sorting" << endl;
for (int j = 0; j < 5; j++)
{
cout << myArray[j] << " ";
}
return 0;
}
|
#include "chunk.h"
#include "world/world.h"
Chunk::Chunk(World *world, const VectorXZi &location) :
_world(world),
_location(location)
{
}
void Chunk::load()
{
if (_isLoaded) {
return;
}
for (int y = 0; y < CHUNK_HEIGHT; ++y)
for (int z = 0; z < CHUNK_SIZE; ++z)
for (int x = 0; x < CHUNK_SIZE; ++x)
{
if (y == 4) {
setBlock({x, y, z}, BlockId::GRASS);
} else if (y == 0) {
setBlock({x, y, z}, BlockId::STONE);
} else if (y < 4) {
setBlock({x, y, z}, BlockId::DIRT);
}
}
_isLoaded = true;
}
void Chunk::makeMesh()
{
ChunkMesh::Builder(*this, _chunkMesh).build();
_chunkMesh.bufferMesh();
_hasMesh = true;
}
ChunkBlock Chunk::getBlock(const Vector3i &position) const
{
if (inRange(position)) {
return _blocks[getIndex(position)];
} else {
return BlockId::AIR;
}
}
void Chunk::setBlock(const Vector3i &position, const ChunkBlock &block)
{
if (inRange(position)) {
_blocks[getIndex(position)] = block;
}
}
const ChunkMesh &Chunk::chunkMesh() const
{
return _chunkMesh;
}
const VectorXZi &Chunk::location() const
{
return _location;
}
bool Chunk::hasMesh() const
{
return _hasMesh;
}
bool Chunk::isLoaded() const
{
return _isLoaded;
}
bool Chunk::inRange(const Vector3i &position)
{
return !((position.x < 0 || position.x >= CHUNK_SIZE) ||
(position.y < 0 || position.y >= CHUNK_HEIGHT) ||
(position.z < 0 || position.z >= CHUNK_SIZE));
}
unsigned Chunk::getIndex(const Vector3i &position)
{
return static_cast<unsigned>(
position.y * CHUNK_AREA +
position.z * CHUNK_SIZE +
position.x
);
}
Vector3i Chunk::toWorldPosition(const Vector3i &position) const
{
return {
_location.x * CHUNK_SIZE + position.x,
position.y,
_location.z * CHUNK_SIZE + position.z,
};
}
|
/* -*- Mode: c++; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*-
*
* Copyright (C) 1995-2008 Opera Software AS. All rights reserved.
*
* This file is part of the Opera web browser. It may not be distributed
* under any circumstances.
*/
#include "core/pch.h"
#include "modules/pi/OpWindow.h"
#include "platforms/mac/pi/MacOpScreenInfo.h"
#include "platforms/mac/util/UTempRegion.h"
/////////////////////////////////////////////////////////////////////////////
OP_STATUS OpScreenInfo::Create(OpScreenInfo **newObj)
{
*newObj = new MacOpScreenInfo();
return *newObj ? OpStatus::OK : OpStatus::ERR_NO_MEMORY;
}
/////////////////////////////////////////////////////////////////////////////
PixMapHandle MacOpScreenInfo::GetMainDevicePixMap()
{
GDHandle gd = LMGetMainDevice();
if (gd)
return (*gd)->gdPMap;
return NULL;
}
/////////////////////////////////////////////////////////////////////////////
OP_STATUS MacOpScreenInfo::GetProperties(OpScreenProperties* properties, OpWindow* window, const OpPoint* point)
{
if (!properties)
return OpStatus::ERR_NO_MEMORY;
PixMapHandle pm = NULL;
GDHandle device = GetMainDevice();
// OP_ASSERT(window);
if (!window)
{
pm = GetMainDevicePixMap();
}
else
{
Rect bounds;
if (point)
{
bounds.top = point->y;
bounds.left = point->x;
bounds.bottom = point->y+1;
bounds.right = point->x+1;
}
else
{
INT32 x, y;
UINT32 w, h;
window->GetOuterPos(&x, &y);
window->GetOuterSize(&w, &h);
bounds.top = y;
bounds.left = x;
bounds.bottom = y + h;
bounds.right = x + w;
}
device = GetMaxDevice(&bounds);
if (!device)
device = GetMainDevice();
pm = (*device)->gdPMap;
}
// Set width and height
properties->width = (pm ? (*pm)->bounds.right - (*pm)->bounds.left : 640);
properties->height = (pm ? (*pm)->bounds.bottom - (*pm)->bounds.top : 480);
//#warning "Needs some work!"
// FIXME: Needs some work!
properties->horizontal_dpi = 96;
properties->vertical_dpi = 96;
properties->bits_per_pixel = (pm ? (*pm)->pixelSize : 32);
properties->number_of_bitplanes = 1;
if (pm)
{
Rect bounds = (*pm)->bounds;
properties->screen_rect.x = bounds.left;
properties->screen_rect.y = bounds.top;
properties->screen_rect.width = bounds.right - bounds.left;
properties->screen_rect.height = bounds.bottom - bounds.top;
GetAvailableWindowPositioningBounds(device, &bounds);
properties->workspace_rect.x = bounds.left;
properties->workspace_rect.y = bounds.top;
properties->workspace_rect.width = bounds.right - bounds.left;
properties->workspace_rect.height = bounds.bottom - bounds.top;
}
else
{
properties->screen_rect.x = properties->workspace_rect.x = 0;
properties->screen_rect.y = properties->workspace_rect.y = 0;
properties->screen_rect.width = properties->workspace_rect.width = properties->width;
properties->screen_rect.height = properties->workspace_rect.height = properties->height;
}
return OpStatus::OK;
}
/////////////////////////////////////////////////////////////////////////////
OP_STATUS MacOpScreenInfo::GetDPI(UINT32* horizontal, UINT32* vertical, OpWindow* window, const OpPoint* point)
{
//#warning "Needs some work!"
// FIXME: Needs some work!
*horizontal = 96;
*vertical = 96;
return OpStatus::OK;
}
/////////////////////////////////////////////////////////////////////////////
OP_STATUS MacOpScreenInfo::RegisterMainScreenProperties(OpScreenProperties& properties)
{
// Not required on Mac
return OpStatus::OK;
}
/////////////////////////////////////////////////////////////////////////////
UINT32 MacOpScreenInfo::GetBitmapAllocationSize(UINT32 width, UINT32 height,
BOOL transparent,
BOOL alpha,
INT32 indexed)
{
//#warning "Needs some work!"
// FIXME: Needs some work!
PixMapHandle pm = GetMainDevicePixMap();
int32 bpp = (pm ? (*pm)->pixelSize : 32);
return ((((width * bpp + 31) / 8) & ~3) * height);
}
/////////////////////////////////////////////////////////////////////////////
//---------------------------------------------------------------------
//OLD AND DEPRECATED
//---------------------------------------------------------------------
|
// Created on: 1997-12-15
// Created by: Philippe MANGIN
// Copyright (c) 1997-1999 Matra Datavision
// Copyright (c) 1999-2014 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _GeomFill_SectionPlacement_HeaderFile
#define _GeomFill_SectionPlacement_HeaderFile
#include <Standard.hxx>
#include <Standard_DefineAlloc.hxx>
#include <Standard_Handle.hxx>
#include <gp_Ax1.hxx>
#include <GeomAdaptor_Curve.hxx>
#include <Extrema_ExtPC.hxx>
#include <gp_Pnt.hxx>
class GeomFill_LocationLaw;
class Geom_Curve;
class Geom_Geometry;
class gp_Trsf;
class gp_Mat;
class gp_Vec;
//! To place section in sweep Function
class GeomFill_SectionPlacement
{
public:
DEFINE_STANDARD_ALLOC
Standard_EXPORT GeomFill_SectionPlacement(const Handle(GeomFill_LocationLaw)& L, const Handle(Geom_Geometry)& Section);
//! To change the section Law
Standard_EXPORT void SetLocation (const Handle(GeomFill_LocationLaw)& L);
Standard_EXPORT void Perform (const Standard_Real Tol);
Standard_EXPORT void Perform (const Handle(Adaptor3d_Curve)& Path, const Standard_Real Tol);
Standard_EXPORT void Perform (const Standard_Real ParamOnPath, const Standard_Real Tol);
Standard_EXPORT Standard_Boolean IsDone() const;
Standard_EXPORT Standard_Real ParameterOnPath() const;
Standard_EXPORT Standard_Real ParameterOnSection() const;
Standard_EXPORT Standard_Real Distance() const;
Standard_EXPORT Standard_Real Angle() const;
Standard_EXPORT gp_Trsf Transformation (const Standard_Boolean WithTranslation, const Standard_Boolean WithCorrection = Standard_False) const;
//! Compute the Section, in the coordinate system given by
//! the Location Law.
//! If <WithTranslation> contact between
//! <Section> and <Path> is forced.
Standard_EXPORT Handle(Geom_Curve) Section (const Standard_Boolean WithTranslation) const;
//! Compute the Section, in the coordinate system given by
//! the Location Law.
//! To have the Normal to section equal to the Location
//! Law Normal. If <WithTranslation> contact between
//! <Section> and <Path> is forced.
Standard_EXPORT Handle(Geom_Curve) ModifiedSection (const Standard_Boolean WithTranslation) const;
protected:
private:
Standard_EXPORT void SectionAxis (const gp_Mat& M, gp_Vec& T, gp_Vec& N, gp_Vec& BN) const;
Standard_EXPORT Standard_Boolean Choix (const Standard_Real Dist, const Standard_Real Angle) const;
Standard_Boolean done;
Standard_Boolean isplan;
gp_Ax1 TheAxe;
Standard_Real Gabarit;
Handle(GeomFill_LocationLaw) myLaw;
GeomAdaptor_Curve myAdpSection;
Handle(Geom_Curve) mySection;
Standard_Real SecParam;
Standard_Real PathParam;
Standard_Real Dist;
Standard_Real AngleMax;
Extrema_ExtPC myExt;
Standard_Boolean myIsPoint;
gp_Pnt myPoint;
};
#endif // _GeomFill_SectionPlacement_HeaderFile
|
#include <bits/stdc++.h>
using namespace std;
int main() {
long long n;
cin>>n;
long long arr[n];
for(long long i=0;i<n;i++)cin>>arr[i];
long long count=0,count2=0;
for(long long i=0;i<n;i++){
if(arr[i]==0)continue;
else{
i++;
count++;
count2++;
if(arr[i]==1){
count2++;
continue;
}
else continue;
}
}
cout <<count<<" "<<count2<<endl;
return 0;
}
|
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
using namespace std;
typedef long long ll;
#define INF 10e10
#define rep(i,n) for(int i=0; i<n; i++)
#define rep_r(i,n,m) for(int i=m; i<n; i++)
#define END cout << endl
#define MOD 1000000007
#define pb push_back
// 昇順sort
#define sorti(x) sort(x.begin(), x.end())
// 降順sort
#define sortd(x) sort(x.begin(), x.end(), std::greater<int>())
int main() {
ll a,b,c;
cin >> a >> b >> c;
if (!(a % 2 == 0 and b % 2 == 0 and c % 2 == 0)) {
cout << 0 << endl;
return 0;
}
if (a == b and b == c) {
cout << -1 << endl;
return 0;
}
ll ans = 0;
while (true) {
ll ta = b / 2 + c / 2;
ll tb = a / 2 + c / 2;
ll tc = a / 2 + b / 2;
if (ta % 2 == 0 and tb % 2 ==0 and tc % 2 == 0) {
ans += 1;
} else {
break;
}
a = ta; b = tb; c = tc;
}
cout << ans+1 << endl;
}
|
/*****************************************************************************************************************
* File Name : arrayRotation.h
* File Location : C:\Users\AVINASH\Desktop\CC++\Programming\src\sites\geeksforgeeks\arrays\page08\arrayRotation.h
* Created on : Jan 3, 2014 :: 6:48:44 PM
* Author : AVINASH
* Testing Status : TODO
* URL : TODO
*****************************************************************************************************************/
/************************************************ Namespaces ****************************************************/
using namespace std;
using namespace __gnu_cxx;
/************************************************ User Includes *************************************************/
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <ctime>
#include <list>
#include <map>
#include <set>
#include <bitset>
#include <functional>
#include <utility>
#include <iostream>
#include <fstream>
#include <sstream>
#include <string.h>
#include <hash_map>
#include <stack>
#include <queue>
#include <limits.h>
#include <programming/ds/tree.h>
#include <programming/ds/linkedlist.h>
#include <programming/utils/treeutils.h>
#include <programming/utils/llutils.h>
/************************************************ User defined constants *******************************************/
#define null NULL
/************************************************* Main code ******************************************************/
#ifndef ARRAYROTATION_H_
#define ARRAYROTATION_H_
void rotateArrayByOne(vector<int> userInput){
if(userInput.size() == 0 || userInput.size() == 1){
return;
}
int key = userInput[0];
for(unsigned int counter = 0;counter < userInput.size()-1;counter++){
userInput[counter] = userInput[counter+1];
}
userInput[userInput.size()-1] = key;
}
void rotateArray(vector<int> userInput,unsigned int rotateBy){
if(userInput.size() == 0|| userInput.size() == 1){
return;
}
for(unsigned int counter = 0;counter < rotateBy;counter++){
rotateArrayByOne(userInput);
}
}
void rotateArrayByNewArray(vector<int> userInput,unsigned int rotateBy){
if(userInput.size() == 0 || userInput.size() == 1){
return;
}
vector<int> rotatedArray;
unsigned int fillCounter = (userInput.size() - (rotateBy % userInput)) - 1;
for(unsigned int counter =0;counter < userInput.size();counter++){
rotatedArray[fillCounter % userInput.size()] = userInput[counter];
}
copy(rotatedArray.begin(),rotatedArray.end(),userInput.begin());
}
void rotationByJuggling(vector<int> userInput,unsigned int rotateBy){
if(userInput.size() == 0 || userInput.size() == 1){
return;
}
unsigned int gcd;
for(unsigned int counter = 0;counter < gcd;counter++){
}
}
void rotationByBlockswap(vector<int> userInput,unsigned int startIndex,unsigned int endIndex,unsigned int rotateBy){
}
#endif /* ARRAYROTATION_H_ */
/************************************************* Ensd code *******************************************************/
|
/* -*- Mode: c++; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4; c-file-style:"stroustrup" -*-
**
** Copyright (C) 2011-2012 Opera Software ASA. All rights reserved.
**
** This file is part of the Opera web browser. It may not be distributed
** under any circumstances.
*/
#ifndef VEGADISPATCHTABLE_H
#define VEGADISPATCHTABLE_H
#ifdef VEGA_SUPPORT
#if defined(VEGA_USE_ASM)
/** Collection of faster versions of common VEGA functions that rely on
* specific CPU features where possible and fall back to regular C++
* when not. */
class VEGADispatchTable
{
private:
/** Initialize the function pointers depending on available CPU features. */
void PopulateHooks();
public:
/** Create a dispatch table depending on available CPU architecture and features. */
VEGADispatchTable();
/*
* Compositing
*/
void (*CompOver_8888)(UINT32* dp, const UINT32* sp, unsigned len);
void (*CompConstOver_8888)(UINT32* dp, UINT32 s, unsigned len);
void (*CompConstOverMask_8888)(UINT32* dp, UINT32 s, const UINT8* mask, unsigned len);
void (*CompOverConstMask_8888)(UINT32* dp, const UINT32* sp, UINT32 mask, unsigned len);
/*
* Sampling using a `nearest (neighbor)' filter.
*/
void (*Sampler_NearestX_Opaque_8888)(UINT32* color, const UINT32* data,
unsigned cnt, INT32 csx, INT32 cdx);
void (*Sampler_NearestX_CompOver_8888)(UINT32* color, const UINT32* data,
unsigned cnt, INT32 csx, INT32 cdx);
void (*Sampler_NearestX_CompOverMask_8888)(UINT32* color, const UINT32* data, const UINT8* mask,
unsigned cnt, INT32 csx, INT32 cdx);
void (*Sampler_NearestX_CompOverConstMask_8888)(UINT32* color, const UINT32* data, UINT32 mask,
unsigned cnt, INT32 csx, INT32 cdx);
void (*Sampler_NearestXY_CompOver_8888)(UINT32* color, const UINT32* data,
unsigned count, unsigned dataPixelStride,
INT32 csx, INT32 cdx, INT32 csy, INT32 cdy);
void (*Sampler_NearestXY_CompOverMask_8888)(UINT32* color, const UINT32* data, const UINT8* mask,
unsigned count, unsigned dataPixelStride,
INT32 csx, INT32 cdx, INT32 csy, INT32 cdy);
/*
* Sampling using a `linear interpolation' filter.
*/
void (*Sampler_LerpX_8888)(UINT32* dst, const UINT32* src, INT32 csx, INT32 cdx, unsigned dstlen, unsigned srclen);
void (*Sampler_LerpY_8888)(UINT32* dst, const UINT32* src1, const UINT32* src2, INT32 frc_y, unsigned len);
void (*Sampler_LerpXY_Opaque_8888)(UINT32* color, const UINT32* data,
unsigned count, unsigned dataPixelStride,
INT32 csx, INT32 cdx, INT32 csy, INT32 cdy);
void (*Sampler_LerpXY_CompOver_8888)(UINT32* color, const UINT32* data,
unsigned count, unsigned dataPixelStride,
INT32 csx, INT32 cdx, INT32 csy, INT32 cdy);
void (*Sampler_LerpXY_CompOverMask_8888)(UINT32* color, const UINT32* data, const UINT8* mask,
unsigned count, unsigned dataPixelStride,
INT32 csx, INT32 cdx, INT32 csy, INT32 cdy);
/*
* Format conversion
*/
void (*ConvertFrom_BGRA8888)(UINT32* dst, const void* src, unsigned num);
void (*ConvertFrom_RGBA8888)(UINT32* dst, const void* src, unsigned num);
void (*ConvertFrom_ABGR8888)(UINT32* dst, const void* src, unsigned num);
void (*ConvertFrom_ARGB8888)(UINT32* dst, const void* src, unsigned num);
void (*ConvertFrom_BGRA4444)(UINT32* dst, const void* src, unsigned num);
void (*ConvertFrom_RGBA4444)(UINT32* dst, const void* src, unsigned num);
void (*ConvertFrom_ABGR4444)(UINT32* dst, const void* src, unsigned num);
void (*ConvertFrom_RGB565)(UINT32* dst, const void* src, unsigned num);
void (*ConvertFrom_BGR565)(UINT32* dst, const void* src, unsigned num);
void (*ConvertFrom_RGB888)(UINT32* dst, const void* src, unsigned num);
/*
* Data movement
*/
void (*StoreTo_8888)(UINT32* dst, UINT32 s, unsigned len);
void (*MoveFromTo_8888)(UINT32* dst, const UINT32* src, unsigned len);
private:
#ifdef VEGA_VERIFY_SIMD
bool VerifySSSE3();
#endif // VEGA_VERIFY_SIMD
};
#endif // VEGA_USE_ASM
#endif // VEGA_SUPPORT
#endif // VEGADISPATCHTABLE_H
|
//Phoenix_RK
/*
https://leetcode.com/problems/all-nodes-distance-k-in-binary-tree/
We are given a binary tree (with root node root), a target node, and an integer value K.
Return a list of the values of all nodes that have a distance K from the target node. The answer can be returned in any order.
Example 1:
Input: root = [3,5,1,6,2,0,8,null,null,7,4], target = 5, K = 2
Output: [7,4,1]
Explanation:
The nodes that are a distance 2 from the target node (with value 5)
have values 7, 4, and 1.
*/
/**
* Definition for a binary tree node.
* struct TreeNode {
* int val;
* TreeNode *left;
* TreeNode *right;
* TreeNode(int x) : val(x), left(NULL), right(NULL) {}
* };
*/
class Solution {
public:
map<int,int> seen;
void fillparent(TreeNode* parent,TreeNode *child,map<TreeNode* ,TreeNode*>&m)
{
if(child==NULL)
return;
m[child]=parent;
seen[child->val]=0;
fillparent(child,child->left,m);
fillparent(child,child->right,m);
}
vector<int> distanceK(TreeNode* root, TreeNode* target, int K)
{
vector<int> res;
map<TreeNode*,TreeNode*> m;
fillparent(NULL,root,m);
queue<TreeNode*> q;
q.push(target);
int level=0;
while(!q.empty())
{
int s=q.size();
while(s>0)
{
if(level==K)
{
TreeNode *f=q.front();
q.pop();
res.push_back(f->val);
}
else
{
TreeNode *f=q.front();
q.pop();
seen[f->val]=1;
if(f->left && !seen[f->left->val])
q.push(f->left);
if(f->right && !seen[f->right->val])
q.push(f->right);
if(m[f]!=NULL && !seen[m[f]->val])
q.push(m[f]);
}
s--;
}
level++;
}
return res;
}
};
|
#include "Fixed.hpp"
Fixed::Fixed() : _value(0)
{
std::cout << "Default constructor called\n";
}
Fixed::Fixed(const Fixed &toCopy)
{
std::cout << "Copy constructor called\n";
*this = toCopy;
}
Fixed &Fixed::operator=(const Fixed &toCopy)
{
std::cout << "Assignation operator called\n";
_value = toCopy.getRawBits();
return (*this);
}
int Fixed::getRawBits(void) const
{
std::cout << "getRawBits member function called\n";
return (_value);
}
void Fixed::setRawBits(int const raw)
{
std::cout << "setRawBits member function called\n";
_value = raw;
}
Fixed::~Fixed()
{
std::cout << "Destructor called\n";
}
|
/****************************************************************************
* *
* Author : lukasz.iwaszkiewicz@tiliae.eu *
* ~~~~~~~~ *
* License : see COPYING file for details. *
* ~~~~~~~~~ *
****************************************************************************/
#include <cstdarg>
#include <cstdio>
#include <SDL.h>
#include <stdint.h>
#include <Platform.h>
#include <common/dataSource/DataSource.h>
int printlogImpl (const char *format, ...)
{
va_list args;
va_start (args, format);
std::string fmt = format;
fmt += "\n";
int ret = vprintf (fmt.c_str (), args);
va_end (args);
return ret;
}
/****************************************************************************/
uint32_t getCurrentMs ()
{
return SDL_GetTicks ();
}
/****************************************************************************/
void delayMs (uint32_t ms)
{
SDL_Delay (ms);
}
/****************************************************************************/
Common::DataSource *newDataSource ()
{
return new Common::DataSource ();
}
/****************************************************************************/
void deleteDataSource (Common::DataSource *ds)
{
delete ds;
}
/****************************************************************************/
void quit ()
{
printlog ("Quit request by user");
exit (0);
}
|
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <algorithm>
#include "config.h"
#include "base.h"
void LOG(string message, unsigned char ll) {
if (LOG_LEVEL & ll) {
cerr << message << endl;
}
}
void displayBI(t_bint* a, t_size size) {
cerr << "0x" << hex;
for (; a[size - 1] == 0; size--) {
}
if (size == 0) {
cerr << "0";
return;
}
else {
cerr << (unsigned long long)a[size - 1];
size--;
for (; size > 0; size--) {
cerr << setfill('0') << setw(BLOCK_SIZE / 4)
<< (unsigned long long)a[size - 1];
}
}
}
void scanBI(t_bint* a, const char* aStr, t_size sizeA) {
t_size size = strlen(aStr);
t_size i;
const t_size ULONG_STR_SIZE = ULONG_SIZE * 2;
t_size loopEnd = size - BLOCKS_NUMBER * BLOCK_SIZE;
loopEnd = loopEnd > 0 ? loopEnd : 0 + size % ULONG_STR_SIZE;
char* currentNumber = new char[ULONG_STR_SIZE + 1];
memset(currentNumber, 0, ULONG_STR_SIZE + 1);
char* tmp; // Do not delete[]! Needed for strtoul
for (i = size - ULONG_STR_SIZE; i >= loopEnd; i -= ULONG_STR_SIZE,
(ULONG*)a++) {
memcpy(currentNumber, &aStr[i], ULONG_STR_SIZE);
*(ULONG*)a = strtoul(currentNumber, &tmp, 16);
}
memset(currentNumber, 0, ULONG_STR_SIZE + 1);
memcpy(currentNumber, &aStr[0], size % ULONG_STR_SIZE);
*(ULONG*)a = strtoul(currentNumber, &tmp, 16);
delete[] currentNumber;
}
unsigned char cmp(t_bint* a, t_bint b, t_size size) {
if (a[0] > b) {
return CMP_GREATER;
}
for (t_size i = 1; i < size; i++) {
if (a[i]) {
return CMP_GREATER;
}
}
if (a[0] == b) {
return CMP_EQUAL;
}
else if (a[0] < b) {
return CMP_LOWER;
}
else {
return CMP_GREATER;
}
}
unsigned char cmp(t_bint* a, t_bint* b, t_size size1, t_size size2) {
if (!size2) {
size2 = size1;
}
t_size i;
if (size1 > size2) {
for (i = size1 - 1; i >= size2; i--) {
if (a[i]) {
return CMP_GREATER;
}
}
}
else if (size2 > size1) {
for (i = size2 - 1; i >= size1; i--) {
if (b[i]) {
return CMP_LOWER;
}
}
}
else {
i = size1 - 1;
}
for (; i >= 0; i--) {
if (a[i] > b[i]) {
return CMP_GREATER;
}
else if (a[i] < b[i]) {
return CMP_LOWER;
}
}
return CMP_EQUAL;
}
void mov(t_bint* a, t_bint* b, t_size size) {
memcpy(a,b,size * sizeof(t_size));
}
t_size msw(t_bint* a, t_size size) {
while (--size >= 0) {
if (a[size] > 0) {
return size;
}
}
return -1;
}
t_size msb(t_bint* a, t_size size) {
t_size result = msw(a,size);
t_size i;
if (result == -1) {
return -1;
}
t_bint tmp = a[result];
result *= BLOCK_SIZE;
for (i = 0; i < BLOCK_SIZE; i++) {
tmp >>= 1;
if (!tmp) {
return result + i;
}
}
return -2;
}
bool isNull(t_bint* a, t_size size) {
if (size < 1) {
return true;
}
if (a == NULL) {
return true;
}
while (size-- > 0) {
if (a[size]) {
return false;
}
}
return true;
}
void setNull(t_bint* a, t_size size) {
memset(a,0,size * sizeof(t_bint));
}
|
/*
* Copyright (c) 2016-2017 Morwenn
* SPDX-License-Identifier: MIT
*/
#ifndef CPPSORT_DETAIL_MINMAX_ELEMENT_AND_IS_SORTED_H_
#define CPPSORT_DETAIL_MINMAX_ELEMENT_AND_IS_SORTED_H_
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <functional>
#include <iterator>
#include <cpp-sort/utility/as_function.h>
#include <cpp-sort/utility/functional.h>
#include "minmax_element.h"
namespace cppsort
{
namespace detail
{
template<
typename ForwardIterator,
typename Compare = std::less<>,
typename Projection = utility::identity
>
auto minmax_element_and_is_sorted(ForwardIterator first, ForwardIterator last,
Compare compare={}, Projection projection={})
-> decltype(auto)
{
auto&& comp = utility::as_function(compare);
auto&& proj = utility::as_function(projection);
// Function-local result type, only the names of the
// data members matter
struct result_type
{
ForwardIterator min;
ForwardIterator max;
bool is_sorted;
} result = { first, first, true };
// 0 or 1 elements
if (first == last) return result;
auto next = std::next(first);
if (next == last) return result;
// While it is sorted, the min and max are obvious
auto current = first;
while (not comp(proj(*next), proj(*current)))
{
++current;
++next;
// The range is fully sorted
if (next == last)
{
result.max = current;
return result;
}
}
// The range is not sorted, use a regular minmax_element algorithm
result.is_sorted = false;
result.min = first;
result.max = current;
auto tmp = minmax_element(next, last, compare, projection);
if (comp(proj(*tmp.first), proj(*result.min)))
{
result.min = tmp.first;
}
if (not comp(proj(*tmp.second), proj(*result.max)))
{
result.max = tmp.second;
}
return result;
}
}}
#endif // CPPSORT_DETAIL_MINMAX_ELEMENT_AND_IS_SORTED_H_
|
/*
Copyright (c) 2016-2022 Xavier Leclercq
Released under the MIT License
See https://github.com/ishiko-cpp/test-framework/blob/main/LICENSE.txt
*/
#include "TestSetupActionsTests.h"
#include "ProcessActionTests.h"
using namespace Ishiko;
TestSetupActionsTests::TestSetupActionsTests(const TestNumber& number, const TestContext& context)
: TestSequence(number, "TestSetupAction tests", context)
{
append<ProcessActionTests>();
}
|
#include "interface/graph/graphNode.h"
#include "labrender_graphNodeFactory.h"
#include <string>
constexpr int PassNodeId = 1;
#if 0
{ "name": "PostProcessAndBlit",
"type" : { "run": "PostProcess", "draw" : "quad" },
"depth" : { "test": "always", "write" : "no", "clear_buffer" : "no" },
"shader" : { "vertex_shader_path": "$(ASSET_ROOT)/pipelines/deferred/full-screen-quad-vsh.glsl",
"fragment_shader_path" : "$(ASSET_ROOT)/pipelines/deferred/full-screen-deferred-blit-fsh.glsl",
"uniforms" : [{ "name": "u_normalTexture", "type" : "sampler2d" }],
"varyings" : [{ "name": "v_texCoord", "type" : "vec2" }] },
"inputs" : [{ "buffer": "gbuffer",
"render_textures" : ["diffuse", "position", "normal"] }],
"outputs" : { "buffer": "visible" } }
#endif
namespace lab
{
using namespace std;
class PassNode : public GraphNode
{
friend class GraphNode;
protected:
typedef PassNode ThisClass;
PassNode() : GraphNode() {}
static const int TYPE = 1;
// No field values in this class
virtual const char* getTooltip() const override { return "labRender Pass"; }
virtual const char* getInfo() const override { return "labRender Pass"; }
virtual void getDefaultTitleBarColors(ImU32& defaultTitleTextColorOut,
ImU32& defaultTitleBgColorOut,
float& defaultTitleBgColorGradientOut) const override
{
// [Optional Override] customize Node Title Colors [default values: 0,0,-1.f => do not override == use default values from the Style()]
defaultTitleTextColorOut = IM_COL32(230, 180, 180, 255);
defaultTitleBgColorOut = IM_COL32(40, 55, 55, 200);
defaultTitleBgColorGradientOut = 0.025f;
}
virtual bool canBeCopied() const override { return false; }
public:
enum class PassType { Generic, Geometry, PostProcess };
PassType passType = PassType::Generic;
string passTypeName;
// create:
static ThisClass* Create(const ImVec2& pos)
{
ThisClass * node = new_node<ThisClass>();
node->init("Render Pass", pos, "in1;in2;in3", "out1;out2", TYPE);
node->set_passType(PassType::Generic);
return node;
}
void set_passType(PassType pt)
{
passType = pt;
switch (pt)
{
case PassType::Generic: passTypeName = "Generic Pass"; break;
case PassType::Geometry: passTypeName = "Geometry Pass"; break;
case PassType::PostProcess: passTypeName = "Post Processing Pass"; break;
}
}
virtual bool render(float /*nodeWidth*/) override
{
if (ImGui::BeginMenu(passTypeName.c_str()))
{
if (ImGui::MenuItem("Generic Pass"))
{
set_passType(PassType::Generic);
}
if (ImGui::MenuItem("Geometry Pass"))
{
set_passType(PassType::Geometry);
}
if (ImGui::MenuItem("Post Processing Pass"))
{
set_passType(PassType::PostProcess);
}
ImGui::EndMenu();
}
return false;
}
};
constexpr int renderNodes = 1;
static const char * node_names[renderNodes] = { "Pass" };
enum class RenderNodeTypes { Pass };
class LabRender_GraphNodeFactory::Detail
{
public:
};
LabRender_GraphNodeFactory::LabRender_GraphNodeFactory()
: _detail(new LabRender_GraphNodeFactory::Detail())
{}
LabRender_GraphNodeFactory::~LabRender_GraphNodeFactory()
{
delete _detail;
}
const char ** LabRender_GraphNodeFactory::node_type_names() { return &node_names[0]; }
size_t LabRender_GraphNodeFactory::node_type_name_count() const { return renderNodes; }
auto LabRender_GraphNodeFactory::node_factory() -> std::function <ImGui::Node * (int, const ImVec2&)>
{
LabRender_GraphNodeFactory * me = this;
return [me](int nt, const ImVec2 & pos) -> ImGui::Node *
{
switch ((RenderNodeTypes) nt) {
case RenderNodeTypes::Pass: return PassNode::Create(pos);
default: return nullptr;
}
return nullptr;
};
}
std::vector<std::pair<int, int>> LabRender_GraphNodeFactory::node_limits()
{
std::vector<std::pair<int, int>> ret;
//ret.push_back({ (int) RenderNodeTypes::Pass, 1 });
return ret;
}
} // lab
|
//---------------------------------------------------------------------------
#ifndef GetMemberProcH
#define GetMemberProcH
//---------------------------------------------------------------------------
#include "IProcess.h"
class GetMemberProc:public IProcess
{
virtual int doRequest(CDLSocketHandler* client, InputPacket* pPacket, Context* pt ) ;
virtual int doResponse(CDLSocketHandler* client, InputPacket* pPacket, Context* pt ) ;
};
#endif
|
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main() {
string str = "";
vector<string> v;
//vector<string>::iterator it;
cout << "Type: " << endl;
int number = 0;
string longest = "";
while ((cin >> str) && str != "stop") {
if (str.length() > longest.length()) {
longest = str;
}
v.push_back(str);
number++;
}
auto it = v.begin();
cout << "Longest string: " << longest << endl;
cout << "Number of strings: " << number << endl;
for (it; it != v.end(); it++) {
cout << *it << endl;
}
cout << "Size of vector: " << v.size() << endl;
cout << "Capacity of vector: " << v.capacity() << endl;
cout << "Sizeof of vector: " << sizeof(v) << endl;
return 0;
}
|
/*****************************************************************************************
* *
* owl *
* *
* Copyright (c) 2014 Jonas Strandstedt *
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
* software and associated documentation files (the "Software"), to deal in the Software *
* without restriction, including without limitation the rights to use, copy, modify, *
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
* permit persons to whom the Software is furnished to do so, subject to the following *
* conditions: *
* *
* The above copyright notice and this permission notice shall be included in all copies *
* or substantial portions of the Software. *
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
#ifndef __SOCKET_H__
#define __SOCKET_H__
#define OWL_SOCKET_BUFFER_SIZE 2048
typedef char SocketData_t;
// C includes
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cstdint>
// Unix includes
#ifdef __WIN32__
#include <winsock2.h>
#include <ws2tcpip.h>
#include <iphlpapi.h>
#include <stdio.h>
#else
#include <unistd.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <openssl/sha.h>
#endif
// C++11 includes
#include <thread>
#include <iostream>
#include <vector>
#include <string>
#include <mutex>
#include <functional>
namespace owl {
class TCPSocketConnection;
class TCPClient;
typedef std::function<void(TCPSocketConnection*)> OpenCallback_t;
typedef std::function<void(TCPSocketConnection*, int, const SocketData_t*)> ReadCallback_t;
typedef std::function<void(TCPSocketConnection*)> CloseCallback_t;
typedef std::function<void(int, const SocketData_t*)> ClientReadCallback_t;
typedef std::function<void(const TCPClient*)> ClientCloseCallback_t;
bool NetworkIsInitialized();
bool NetworkInitialize();
void NetworkDeinitialize();
}
#endif
|
// Created on: 1992-11-18
// Created by: Christian CAILLET
// Copyright (c) 1992-1999 Matra Datavision
// Copyright (c) 1999-2014 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _IFSelect_SelectAnyType_HeaderFile
#define _IFSelect_SelectAnyType_HeaderFile
#include <Standard.hxx>
#include <Standard_Type.hxx>
#include <IFSelect_SelectExtract.hxx>
#include <Standard_Type.hxx>
#include <Standard_Integer.hxx>
class Standard_Transient;
class Interface_InterfaceModel;
class IFSelect_SelectAnyType;
DEFINE_STANDARD_HANDLE(IFSelect_SelectAnyType, IFSelect_SelectExtract)
//! A SelectAnyType sorts the Entities of which the Type is Kind
//! of a given Type : this Type for Match is specific of each
//! class of SelectAnyType
class IFSelect_SelectAnyType : public IFSelect_SelectExtract
{
public:
//! Returns the Type which has to be matched for select
Standard_EXPORT virtual Handle(Standard_Type) TypeForMatch() const = 0;
//! Returns True for an Entity (model->Value(num)) which is kind
//! of the chosen type, given by the method TypeForMatch.
//! Criterium is IsKind.
Standard_EXPORT Standard_Boolean Sort (const Standard_Integer rank, const Handle(Standard_Transient)& ent, const Handle(Interface_InterfaceModel)& model) const Standard_OVERRIDE;
DEFINE_STANDARD_RTTIEXT(IFSelect_SelectAnyType,IFSelect_SelectExtract)
};
#endif // _IFSelect_SelectAnyType_HeaderFile
|
/* E. Zanotti
20151004
tp#01 Tipos de variables
*/
#include<iostream>
#include<string>
using namespace std;
int main()
{
unsigned a,b;
bool b1,b2;
char c1,c2;
double d1,d2;
string s1;
string s2;
cout<<"Ingrese dos numeros enteros..\n";
cin>>a;
cin>>b;
cout<<"Suma=";
cout<<a+b;
cout<<"\n";
cout<<"Resta=";
cout<<a-b;
cout<<"\n";
cout<<"Multiplicacion=";
cout<<a*b;
if(a>b)
cout<<"\nel valor A es mayor al de B..\n";
else
cout<<"\nel valor de B es mayor al de A..\n";
cout<<"\n";
cout<<"Ingrese dos datos de caracter double..\n";
cin>>d1;
cin>>d2;
cout<<"Resta=";
cout<<d1-d2;
cout<<"\n";
cout<<"Multiplicacion=";
cout<<d1*d2;
cout<<"\n";
cout<<"Suma=";
cout<<d1+d2;
cout<<"\n";
cout<<"Ingrese 1 como verdadero, 0 como falso..\n";
cin>>b1;
cout<<"Ingrese otro..\n";
cin>>b2;
cout<<"\n";
if(b1==b2)
cout<<"Verdadero";
else
cout<<"Falso";
cout<<"\nIngrese dos caracteres..\n";
cin>>c1;
cin>>c2;
if(c1==c2)
cout<<"Ambos caracteres son iguales..\n";
else
cout<<"Son distintos..\n";
cout<<"Ingrese una cadena de caracteres...\n";
cin>>s1;
cout<<"Ingrese otra cadena de caracteres.. \n";
cin>>s2;
cout<<"El tamaņo de la primera cadena es.."<<s1.size()<<" y el de la segunda es.."<<s2.size()<<"\n";
cout<<"Si las concatenamos..\n";
cout<<s1+s2;
}
|
#include "buttonworkerform.hpp"
#include "ui_buttonworkerform.h"
ButtonWorkerForm::ButtonWorkerForm(QWidget *parent) :
WorkerForm(parent),
ui(new Ui::ButtonWorkerForm)
{
ui->setupUi(this);
}
void ButtonWorkerForm::timerEvent(QTimerEvent *event)
{
ui->pushButton->setGeometry((ui->pushButton->x()+25) % width(), (ui->pushButton->y()+25) % height(), ui->pushButton->width(), ui->pushButton->height());
}
|
#include <stdio.h>
#include <GL/gl.h>
#include <GL/glut.h>
#include <vector>
#include <iostream>
#include <unistd.h>
//#include "PortalSpace2d2.h"
#include "Hyperbolic2d.h"
#include <Eigen/Core>
using Eigen::Matrix2d;
using Eigen::Vector2d;
//It might be a good idea to have a separate matrix for rotation and for the distortion of space, since rotation can be inverted by transposing, and if the distortion is just a function of the position the inverse could presumably be calculated easily, but their product would have to be calculated the hard way.
#define KEY_ESCAPE 27
Hyperbolic2d* space;
Hyperbolic2d::Point position;
double rotation;
//std::tr1::shared_ptr<Manifold> space;
//std::tr1::shared_ptr<Manifold::PointOfReference> por;
std::vector<Hyperbolic2d::Point> pointList;
Matrix2d rotate(double theta) {
Matrix2d out;
out << cos(theta), -sin(theta), sin(theta), cos(theta);
return out;
}
typedef struct {
int width;
int height;
char* title;
float field_of_view_angle;
float z_near;
float z_far;
} glutWindow;
glutWindow win;
void display()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Clear Screen and Depth Buffer
glLoadIdentity();
glTranslatef(0.0f,0.0f,-3.0f);
glPolygonMode( GL_FRONT_AND_BACK, GL_LINE );
//std::cout << "test\n" << std::flush;
/*
* Triangle code starts here
* 3 verteces, 3 colors.
*/
/*glBegin(GL_TRIANGLES);
glColor3f(0.0f,0.0f,1.0f);
glVertex3f( 0.0f, 1.0f, 0.0f);
glColor3f(0.0f,1.0f,0.0f);
glVertex3f(-1.0f,-1.0f, 0.0f);
glColor3f(1.0f,0.0f,0.0f);
glVertex3f( 1.0f,-1.0f, 0.0f);
glEnd();*/
/*glBegin(GL_TRIANGLES);
glColor3f(0.0f,0.0f,1.0f);
glVertex2f( 0.0f, 1.0f);
glColor3f(0.0f,1.0f,0.0f);
glVertex2f(-1.0f,-1.0f);
glColor3f(1.0f,0.0f,0.0f);
glVertex2f( 1.0f,-1.0f);
glEnd();*/
for(int i=0; i<pointList.size(); ++i) {
//::cout << "Point: (" << pointList[i].getCoordinates()[0] << ", " << pointList[i].getCoordinates()[1] << ")\n";
Vector2d point = position.vectorFromPoint(pointList[i]);
//std::cout << "Direction before rotation:\n" << point << "\n";
//std::cout << "Rotation:\n" << rotate(rotation) << "\n";
point = rotate(-rotation)*point;
//std::cout << "Direction after rotation:\n" << point << "\n";
glBegin(GL_POINTS);
glVertex2f(point[0], point[1]);
glEnd();
}
glutSwapBuffers();
usleep(30000);
}
void constructPointList() {
double theta = M_PI*(sqrt(5)-1);
Matrix2d m;
m << cos(theta), -sin(theta),
sin(theta), cos(theta);
m *= 1.05;
Vector2d v(0.1,0.);
for(int i=0; i<50; ++i) {
pointList.push_back(position.pointFromVector(v));
v = m*v;
}
}
void initialize ()
{
glMatrixMode(GL_PROJECTION); // select projection matrix
glViewport(0, 0, win.width, win.height); // set the viewport
glMatrixMode(GL_PROJECTION); // set matrix mode
glLoadIdentity(); // reset projection matrix
GLfloat aspect = (GLfloat) win.width / win.height;
gluPerspective(win.field_of_view_angle, aspect, win.z_near, win.z_far); // set up a perspective projection matrix
glMatrixMode(GL_MODELVIEW); // specify which matrix is the current matrix
glShadeModel( GL_SMOOTH );
glClearDepth( 1.0f ); // specify the clear value for the depth buffer
glEnable( GL_DEPTH_TEST );
glDepthFunc( GL_LEQUAL );
glHint( GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST ); // specify implementation-specific hints
glClearColor(0.0, 0.0, 0.0, 1.0); // specify clear values for the color buffers
//The part where the space is defined TODO
Hyperbolic2d* hyperbolic = new Hyperbolic2d();
space = hyperbolic;
constructPointList();
glColor3f(1.0f,1.0f,1.0f);
}
void move(double x, double y) {
std::pair<Hyperbolic2d::Point, double> pointAndRot = position.pointAndRotFromVector(rotate(rotation)*Vector2d(x,y));
position = pointAndRot.first;
rotation += pointAndRot.second;
}
void keyboard(unsigned char key, int mousePositionX, int mousePositionY)
{
//std::cout << key;
//std::cout.flush();
switch(key) {
case 'w':
move(0,0.1);
break;
case 'e':
rotation -= 0.1;
break;
case 'q':
rotation += 0.1;
break;
case 's':
move(0,-0.1);
break;
case 'a':
move(-0.1,0);
break;
case 'd':
move(0.1,0);
break;
case KEY_ESCAPE:
exit(0);
break;
default:
break;
}
}
int main(int argc, char **argv)
{
// set window values
win.width = 640;
win.height = 480;
win.title = (char*)"Manifold";
win.field_of_view_angle = 45;
win.z_near = 1.0f;
win.z_far = 500.0f;
// initialize and run program
glutInit(&argc, argv); // GLUT initialization
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH ); // Display Mode
glutInitWindowSize(win.width,win.height); // set window size
glutCreateWindow(win.title); // create Window
glutDisplayFunc(display); // register Display Function
glutIdleFunc( display ); // register Idle Function
glutKeyboardFunc( keyboard ); // register Keyboard Handler
initialize();
glutMainLoop(); // run GLUT mainloop
return 0;
}
|
#include <SDL2/SDL.h>
#include <SDL2/SDL_mixer.h>
#include "game.hpp"
Game::Game() : fullscreen(false) {
SDL_Init(SDL_INIT_EVERYTHING);
SDL_CreateWindowAndRenderer(640, 480, this->windowFlags(), &window, &renderer);
SDL_SetWindowTitle(window, "Pickin' Sticks");
Mix_OpenAudio(22050, MIX_DEFAULT_FORMAT, 2, 4096);
enterGameLoop();
cleanUpAndExit();
}
Uint32 Game::windowFlags() {
Uint32 windowFlags = 0;
if (fullscreen) {
windowFlags = windowFlags | SDL_WINDOW_FULLSCREEN_DESKTOP;
}
return windowFlags;
}
void Game::enterGameLoop() {
while ( event.type != SDL_QUIT )
{
SDL_PollEvent( &event );
}
}
void Game::cleanUpAndExit() {
SDL_DestroyWindow(window);
SDL_Quit();
}
|
#include <iostream>
#include "ListMap.hpp"
int main()
{
cs202::ListMap<int, int> map;
std::string command;
while (std::cin >> command) {
if (command == "put") {
int key;
std::cin >> key;
int val;
std::cin >> val;
map.put(key, val);
} else if (command == "get") {
int key;
std::cin >> key;
std::cout << map.get(key) << std::endl;
} else if (command == "has") {
int key;
std::cin >> key;
std::cout << map.has(key) << std::endl;
} else if (command == "remove") {
int key;
std::cin >> key;
map.remove(key);
} else {
break;
}
}
return 0;
}
|
#ifndef Renderer_h__
#define Renderer_h__
#include "../middleware/includes/gl/glew.h"
#include "../middleware/includes/gl/glfw3.h"
#include "Shaders/shader.hpp"
#include "Model.h"
#include <memory>
#include "FirstPersonCamera.h"
#include"KeyFrameAnimationShader.h"
#include"md2model.h"
#include "Model3D.h"
#include "ShaderProgram.h"
#include "Enemy.h"
#include "CollisionManager.h"
#include "House.h"
#include "Fruit.h"
#include "Player.h"
#include "Bullet.h"
#include "Tree.h"
#include "Gun.h"
#define PI 3.14159265359
class Renderer
{
ShaderProgram shader;
GLuint programID;
GLuint VPID;
GLuint ModelMatrixID;
GLuint TexID;
float Env_Size = 1000.0f;
float Env_Height = 200.0f;
float jmpCount= 0;
float jmpValue = 0.05;
bool jmpUp = 0;
bool jmpDown = 0;
float jmpDownWait = 0;
std::unique_ptr<Model> mySquare;
std::unique_ptr<Model> mySquare1;
std::unique_ptr<FirstPersonCamera> myCamera;
std::unique_ptr<Player> Hero;
//std::unique_ptr<Model3D> Gun;
std::unique_ptr<Model> myRoom, Cursor, Square;
glm::mat4 GunMat;
glm::mat4 floorM;
glm::mat4 RoomMat;
glm::mat4 CursorMat;
glm::mat4 R, T, S;
Texture * CursorTexture;
Texture * face1;
Texture * face2;
Texture * face3;
Texture * face4;
Texture * face5;
Texture * face6;
Texture * GameOverTexture;
Texture * YouWonTexture;
int ApplyTexOnlY ;
int EnemiesCount;
int TreesCnt;
int HouseCount;
int ZombieMinX;
int ZombieMaxX;
int TreeMinX;
int TreeMaxX;
int TreeMinZ;
int TreeMaxZ;
bool GameOver = 0;
bool YouWon = 0;
Model3D* staticModel;
Model3D* model3D;
vector<Bullet*>bullets;
vector< Fruit* > fruits;
vector < House * > Houses;
vector<Tree*> Trees;
vector<Enemy* > Enemies;
KeyFrameAnimationShader animatedModelShader;
vec3 ambientLight;
vec3 lightPosition;
vec3 eyePosition;
CollisionManager collisionManager;
public:
Renderer();
~Renderer();
bool coll;
void Initialize();
void InitRoom(std::unique_ptr<Model> &);
void InitCursor(std::unique_ptr<Model> &);
void InitSquare(std::unique_ptr<Model>&);
bool Draw();
void HandleKeyboardInput(int key, int action);
void HandleMouse(double deltaX, double deltaY);
void Update(double deltaTime);
void Cleanup();
int Randomize(int index, int now, float posX, float posZ);
void Tree_Coord(int i,int &x, int &z);
void MoveAnimatedModel(int index);
void HandleMouseClick(double MouseXPos, double MouseYPos);
};
#endif
|
#include <iostream>
#include <sstream>
#include <cstdlib>
#include <cstdio>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <list>
#include <map>
#include <set>
#include <climits>
#include <ctime>
#include <cmath>
#include <string>
#include <cctype>
#include <cstring>
#include<complex>
#include <algorithm>
using namespace std;
int main(){
int n;
while(cin>>n){
int x;
int ans=0;
for(int i=0;i<n;i++){
cin>>x;
ans^=x;
}
if(ans==0)
cout<<"No\n";
else
cout<<"Yes\n";
}
return 0;
}
|
#include <iostream>
#include <queue>
#include <tuple>
#include <vector>
using namespace std;
const int INF = 1 << 30;
const int dx[4] = {-1, 0, 0, 1};
const int dy[4] = {0, -1, 1, 0};
int main() {
int N, M, sx, sy, l, r;
cin >> N >> M >> sx >> sy >> l >> r;
--sx, --sy;
string S[N];
for (int x = 0; x < N; ++x) cin >> S[x];
int dp[N][M];
fill(dp[0], dp[N], INF);
priority_queue<pair<int, pair<int, int>>, vector<pair<int, pair<int, int>>>, greater<pair<int, pair<int, int>>>> que;
que.push(make_pair(0, make_pair(sx, sy)));
dp[sx][sy] = 0;
while (!que.empty()) {
int d = que.top().first;
int x, y;
tie(x, y) = que.top().second;
que.pop();
if (dp[x][y] > d) continue;
for (int i = 0; i < 4; ++i) {
int nx = x + dx[i], ny = y + dy[i];
int cost = d + max(0, dy[i]);
if (nx < 0 || N <= nx || ny < 0 || M <= ny || S[nx][ny] == '*' || dp[nx][ny] <= cost) continue;
dp[nx][ny] = cost;
que.push(make_pair(cost, make_pair(nx, ny)));
}
}
int ans = 0;
for (int x = 0; x < N; ++x) {
for (int y = 0; y < M; ++y) {
if (dp[x][y] <= r && sy + dp[x][y] - y <= l) ++ans;
}
}
cout << ans << endl;
return 0;
}
|
#include "Servo.h"
Servo loadServo;
// Servo positions, which depend on color input
int pos;
int pos_min = 90;
int pos_max;
// Getting incoming color from serial
String incoming = "";
int color; // 0 is blue, 1 is orange, 2 is yellow
void setup() {
Serial.begin(9600);
loadServo.attach(9);
loadServo.write(90);
Serial.println("Servo Begin");
}
void loop() {
if (Serial.available() > 0) {
//check for new data
incoming = Serial.readString();
color = incoming.toInt();
load(color);
}
}
void load(int color)
{
Serial.println("Colors Yay!");
if (color == 1) {
// Sweep from 90 to 0
pos_max = 0;
for (pos = pos_min; pos >= pos_max; pos -= 1)
{
loadServo.write(pos);
delay(10);
}
} else if (color == 2) {
// Sweep from 90 to 180
pos_max = 180;
for (pos = pos_min; pos <= pos_max; pos += 1)
{
loadServo.write(pos);
delay(10);
}
}
// Return to position of 90
loadServo.write(90);
}
|
//
// nehe27.h
// NeheGL
//
// Created by Andong Li on 10/6/13.
// Copyright (c) 2013 Andong Li. All rights reserved.
//
#ifndef __NeheGL__nehe27__
#define __NeheGL__nehe27__
#include <OpenGL/gl.h>
#include <OpenGL/glu.h>
#include <GLUT/glut.h>
#include "utils.h"
#include "SOIL.h"
#include <iostream>
#include <stdlib.h>
#include <stdio.h>
#include <cmath>
#include <ctime>
// Definition Of "INFINITY" For Calculating The Extension Vector For The Shadow Volume
#define INFINITY_SHADOW 100
typedef float GLvector4f[4]; // Typedef's For VMatMult Procedure
typedef float GLmatrix16f[16]; // Typedef's For VMatMult Procedure
// vertex in 3d-coordinate system
struct sPoint{
float x, y, z;
};
// plane equation
struct sPlaneEq{
float a, b, c, d;
};
// structure describing an object's face
struct sPlane{
unsigned int p[3];
sPoint normals[3];
unsigned int neigh[3];
sPlaneEq PlaneEq;
bool visible;
};
// object structure
struct glObject{
GLuint nPlanes, nPoints;
sPoint points[100];
sPlane planes[200];
};
class NEHE27{
public:
static GLvoid ReSizeGLScene(GLsizei width, GLsizei height);
static GLvoid InitGL();
static GLvoid DrawGLScene();
static GLvoid UpdateScene(int flag);
static GLvoid KeyboardFuction(unsigned char key, int x, int y);
static GLvoid KeyboardUpFuction(unsigned char key, int x, int y);
static GLvoid KeySpecialFuction(int key, int x, int y);
static GLvoid KeySpecialUpFuction(int key, int x, int y);
static const char* TITLE;
const static int EXPECT_FPS = 60; // expect FPS during rendering
const static int FPS_UPDATE_CAP = 100; // time period for updating FPS
private:
static GLfloat sleepTime; //delay time for limiting FPS
static void computeFPS();
static int frameCounter;
static int currentTime;
static int lastTime;
static char FPSstr[15];
static int ReadObject(const char *st, glObject *o);
static void SetConnectivity(glObject *o);
static void CalcPlane(glObject o, sPlane *plane);
static void DrawGLObject(glObject o);
static void CastShadow(glObject *o, float *lp);
static void VMatMult(GLmatrix16f M, GLvector4f v);
static int InitGLObjects();
static void DrawGLRoom();
static glObject obj;
static GLfloat xrot; // X Rotation
static GLfloat yrot; // Y Rotation
static GLfloat xspeed; // X Rotation Speed
static GLfloat yspeed; // Y Rotation Speed
static GLfloat LightPos[]; // Light Position
static GLfloat LightAmb[]; // Ambient Light Values
static GLfloat LightDif[]; // Diffuse Light Values
static GLfloat LightSpc[]; // Specular Light Values
static GLfloat MatAmb[]; // Material - Ambient Values
static GLfloat MatDif[]; // Material - Diffuse Values
static GLfloat MatSpc[]; // Material - Specular Values
static GLfloat MatShn[]; // Material - Shininess
static float ObjPos[]; // Object Position
static GLUquadricObj* q; // Quadratic For Drawing A Sphere
static GLfloat SpherePos[];
static bool keys[256];
static bool specialKeys[256];
};
#endif /* defined(__NeheGL__nehe27__) */
|
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <memory.h>
#include <math.h>
#include <string>
#include <string.h>
#include <queue>
#include <vector>
#include <set>
#include <deque>
#include <map>
#include <functional>
#include <numeric>
typedef long double LD;
typedef long long LL;
typedef unsigned long long ULL;
typedef unsigned int uint;
#define PI 3.1415926535897932384626433832795
#define sqr(x) ((x)*(x))
using namespace std;
#define N 111111
char s[111111];
int n;
int main() {
freopen("headshot.in", "r", stdin);
freopen("headshot.out", "w", stdout);
gets(s);
n = strlen(s);
int zeraft = 0;
int zer = 0;
for (int i = 0; i + 1 < n; i++) if (s[i] == '0' && s[i + 1] == '0') zeraft++;
if (s[n - 1] == '0' && s[0] == '0') zeraft++;
for (int i = 0; i < n; i++) if (s[i] == '0') zer++;
if (zeraft * n == zer * zer) {
puts("EQUAL");
}else
if (zeraft * n > zer * zer) {
puts("SHOOT");
}else {
puts("ROTATE");
}
return 0;
}
|
#pragma once
#include <iberbar/Renderer/RenderCommand.h>
#include <functional>
namespace iberbar
{
namespace Renderer
{
class __iberbarRendererApi__ CRenderCallbackCommand
: public CRenderCommand
{
public:
CRenderCallbackCommand();
void SetProc( std::function<void()> Func ) { m_Func = Func; }
void Execute() { if ( m_Func ) m_Func(); }
protected:
std::function<void()> m_Func;
};
}
}
|
//#include "stdafx.h"
#include "block.h"
Block::Block(float startX, float startY)
{
position.x = startX;
position.y = startY;
//block.setTexture(AssetManager::GetTexture("C:/Users/Alex/Desktop/IP Bomberman/Bomberman/Assets/block.png"));
}
|
#ifndef CUSTOMBUTTON_H
#define CUSTOMBUTTON_H
#include<QPushButton>
#include<QMouseEvent>
#include<QDebug>
class CustomButton : public QPushButton
{
Q_OBJECT
public:
CustomButton(QWidget *parent);
protected:
void mousePressEvent(QMouseEvent *event);
};
#endif // CUSTOMBUTTON_H
|
void Manual(){
if(control1 == 'B'){
digitalWrite(RELAY1, HIGH);
}
else if(control1 == 'b'){
digitalWrite(RELAY1, LOW);
}
else if(control1 == 'C'){
digitalWrite(RELAY2, HIGH);
}
else if(control1 == 'c'){
digitalWrite(RELAY2, LOW);
}
else if(control1 == 'D'){
digitalWrite(RELAY3, HIGH);
}
else if(control1 == 'd'){
digitalWrite(RELAY3, LOW);
}
else if(control1 == 'E'){
digitalWrite(RELAY4, HIGH);
}
else if(control1 == 'e'){
digitalWrite(RELAY4, LOW);
}
else if(control1 == 'F'){
digitalWrite(RELAY5,HIGH);
gservo.write(90);
}
else if(control1 == 'f'){
gservo.write(0);
delay(1000);
digitalWrite(RELAY5,LOW);
}
}
|
#include<iostream>
#include<vector>
using namespace std;
class Solution {
public:
int strStr(string haystack, string needle) {
int len1 = haystack.size(), len2 = needle.size();
int i = 0;
int j = 0;
vector<int> next;
//如果模式串和主串都为空,也匹配了,返回0
if (len1 == 0 && len2 == 0)
return 0;
//如果主串为空,模式串不为空,匹配不了返回-1
if (len1 == 0)
return -1;
//计算模式串的next值
get_next(needle, next);
//如果匹配成功模式串的下标j就等于len2循环结束,或者主串下标i等于len1结束循环
while (i < len1 && j < len2)
{
//当模式串下标j回溯到第一个字符的next值时,说明没有匹配成功,重新匹配j++=0模式串从头开始 i++主串从下一个字符开始
//或者当模式串字符等于主串字符haystack[i]=needle[j]时,继续看下一个字符是否匹配j++ i++
if (j == -1 || haystack[i] == needle[j])
{
i++;
j++;
}
//当模式串第j个字符与主串第i个字符不匹配时,i不回溯,j回溯到该字符下的next值即next[j],也就是j字符之前字符串的后缀与主串i字符之前后缀是相同的,又因为j字符之前字符串的前缀与后缀相同,所以j字符之前字符串的前缀与主串i字符之前后缀是相同的(算作已匹配),所以j回溯到相同前缀的下一个字符,也就是相同前缀的个数
else
j = next[j];
}
//最后如果模式串的下标j就等于len2,表示匹配成功,返回主串开始匹配字符的下标值i-j
if (j == len2)
return i - j;
else
return -1;
}
void get_next(string T, vector<int> &next)
{
int i, j; //j指向前缀下标,i指向后缀下标
i = 0; //i初始为0
j = -1; //j初始为-1
next.push_back(-1); //next数组第一个字符next值为-1,next[0]=-1
//循环扫描模式串,给模式串每个字符算出一个next数值,next值的含义是该字符之前的字符串中前缀和后缀相等的最长串的字符个数,也就是前缀串的下一个字符下标。
//当模式串第j个字符与主串第i个字符不匹配时,i不回溯,j回溯到该字符下的next值即next[j],也就是j字符之前字符串的后缀与主串i字符之前后缀是相同的,又因为j字符之前字符串的前缀与后缀相同,所以j字符之前字符串的前缀与主串i字符之前后缀是相同的(算作已匹配),所以j回溯到相同前缀的下一个字符,也就是相同前缀的个数
while (i < T.size())
{
//当j回溯到第一个字符的next值时,重新匹配j++=0前缀从头开始i++后缀从下一个字符开始
//或者当前缀字符等于后缀字符T[j]=T[i]时,继续看下一个字符是否匹配j++ i++,同时给下一个字符i的next值赋值,next等于i字符之前的字符串中前缀和后缀相等的最长串的字符个数,也就是前缀串的下一个字符下标即next[i]=j++
if (j == -1 || T[j] == T[i])
{
j++;
i++;
next.push_back(j);
}
//如果当前缀字符与后缀字符不相等,j通过next值回溯到适当位置,也就是回溯到j字符之前的字符串中前缀和后缀相等的最长串的字符个数
//也就是前缀串的下一个字符下标处,也就是j字符之前字符串的后缀与i字符之前后缀是相同的,又因为j字符之前字符串的前缀与后缀相同,所以j字符之前字符串的前缀与主串i字符之前后缀是相同的(算作已匹配),所以j回溯到相同前缀的下一个字符,也就是相同前缀的个数
else
j = next[j];
}
}
};
int main()
{
string haystack = "hello";
string needle = "lo";
Solution solute;
cout << solute.strStr(haystack, needle) << endl;
return 0;
}
|
/* -*- Mode: c++; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*-
**
** Copyright 2005-2012 Opera Software ASA. All rights reserved.
**
** This file is part of the Opera web browser. It may not be distributed
** under any circumstances.
**
** Peter Krefting
*/
#include "core/pch.h"
#ifdef WEBSERVER_SUPPORT
#include "modules/prefs/prefsmanager/collections/pc_webserver.h"
#include "modules/prefs/prefsmanager/collections/prefs_macros.h"
#include "modules/prefs/prefsmanager/collections/pc_webserver_c.inl"
PrefsCollectionWebserver *PrefsCollectionWebserver::CreateL(PrefsFile *reader)
{
if (g_opera->prefs_module.m_pcwebserver)
LEAVE(OpStatus::ERR);
g_opera->prefs_module.m_pcwebserver = OP_NEW_L(PrefsCollectionWebserver, (reader));
return g_opera->prefs_module.m_pcwebserver;
}
PrefsCollectionWebserver::~PrefsCollectionWebserver()
{
#ifdef PREFS_COVERAGE
CoverageReport(
m_stringprefdefault, PCWEBSERVER_NUMBEROFSTRINGPREFS,
m_integerprefdefault, PCWEBSERVER_NUMBEROFINTEGERPREFS);
#endif
g_opera->prefs_module.m_pcwebserver = NULL;
}
void PrefsCollectionWebserver::ReadAllPrefsL(PrefsModule::PrefsInitInfo *)
{
// Read everything
OpPrefsCollection::ReadAllPrefsL(
m_stringprefdefault, PCWEBSERVER_NUMBEROFSTRINGPREFS,
m_integerprefdefault, PCWEBSERVER_NUMBEROFINTEGERPREFS);
}
#ifdef PREFS_VALIDATE
void PrefsCollectionWebserver::CheckConditionsL(int which, int *value, const uni_char *)
{
// Check any post-read/pre-write conditions and adjust value accordingly
switch (static_cast<integerpref>(which))
{
case WebserverEnable:
case WebserverListenToAllNetworks:
case WebserverPort:
case WebserverBacklog:
case WebserverUploadRate:
#ifdef WEBSERVER_RENDEZVOUS_SUPPORT
case WebserverProxyPort:
#endif
case WebserverUsed:
case WebserverAlwaysOn:
case UseOperaAccount:
#ifdef UPNP_SUPPORT
case UPnPEnabled:
case UPnPServiceDiscoveryEnabled:
#endif
case RobotsTxtEnabled:
case ServiceDiscoveryEnabled:
break;
default:
// Unhandled preference! For clarity, all preferenes not needing to
// be checked should be put in an empty case something: break; clause
// above.
OP_ASSERT(!"Unhandled preference");
}
}
BOOL PrefsCollectionWebserver::CheckConditionsL(int which, const OpStringC &invalue,
OpString **outvalue, const uni_char *)
{
// Check any post-read/pre-write conditions and adjust value accordingly
switch (static_cast<stringpref>(which))
{
#ifdef WEBSERVER_RENDEZVOUS_SUPPORT
case WebserverProxyHost:
case WebserverDevice:
case WebserverUser:
case WebserverHashedPassword:
#endif // WEBSERVER_RENDEZVOUS_SUPPORT
#ifdef WEB_UPLOAD_SERVICE_LIST
case ServiceDiscoveryServer:
#endif
break;
default:
// Unhandled preference! For clarity, all preferenes not needing to
// be checked should be put in an empty case something: break; clause
// above.
OP_ASSERT(!"Unhandled preference");
}
// When FALSE is returned, no OpString is created for outvalue
return FALSE;
}
#endif // PREFS_VALIDATE
#endif // WEBSERVER_SUPPORT
|
/*==============================================================================
Project: Bulk Synchronous Farm (BSF)
Theme: BSF Skeleton
Module: Problem-Implementation.cpp (Implementation of the Problem)
Prefix: PI
Author: Nadezhda A. Ezhova
Supervisor: Leonid B. Sokolinsky
This source code is a part of BSF Skeleton
==============================================================================*/
#include "Problem-Include.h" // Problem "Include" Files
#include "Problem-bsfTypes.h" // Predefined BSF Problem Types
#include "Problem-Types.h" // Problem Types
#include "Problem-Data.h" // Problem Data
#include "Problem-Forwards.h" // Problem Function Forwards
#include "Problem-bsfParameters.h" // BSF Skeleton Parameters
using namespace std;
void PI_bsf_Init(bool* success) { // success=false if initialization is unsuccessful
cout << setprecision(PP_BSF_PRECISION);
//...
};
void PI_bsf_AssignListSize(int* listSize) {
};
void PI_bsf_CopyData(PT_bsf_data_T* dataIn, PT_bsf_data_T* dataOut) {
};
void PI_bsf_MapF(PT_bsf_mapElem_T* mapElem, PT_bsf_reduceElem_T* reduceElem, int index, PT_bsf_data_T* data,
int* success // 1 - reduceElem was produced successfully; 0 - otherwise
){
};
void PI_bsf_ReduceF(PT_bsf_reduceElem_T* x, PT_bsf_reduceElem_T* y, PT_bsf_reduceElem_T* z) { // z = x + y
};
void PI_bsf_ProcessResults(
bool* exit, // "true" if Stopping Criterion is satisfied, and "false" otherwise
PT_bsf_reduceElem_T* reduceResult,
int count, // Number of successfully produced Elrments of Reduce List
PT_bsf_data_T* data // Next Approximation
){
};
void PI_bsf_ParametersOutput(int numOfWorkers, PT_bsf_data_T data) {
};
void PI_bsf_IterOutput(PT_bsf_reduceElem_T* reduceResult, int count, PT_bsf_data_T data,
int iterCount, double elapsedTime) {
// static int counter = 0; // Iteration Counter
// counter++;
// cout << "------------------ " << counter << " ------------------" << endl;
};
void PI_bsf_ProblemOutput(PT_bsf_reduceElem_T* reduceResult, int count, PT_bsf_data_T data,
int iterCount, double t, double t_L, double t_s_L, double t_S, double t_r_L, double t_W,
double t_A_w, double t_A_m, double t_p) {// Output Function
};
void PI_bsf_SetInitApproximation(PT_bsf_data_T* data) {
};
void PI_bsf_SetMapSubList(PT_bsf_mapElem_T* subList, int count, int offset, bool* success) {
for (int j = 0; j < count; j++) {
};
};
//----------------------------- User functions -----------------------------
|
#pragma once
#include <complex>
#include <cmath>
#include <Image.h>
const int SIZE_FFT = 28;
const float PI2 = 6.28318530718f;
using namespace std::complex_literals;
// output onlt Frequency
static void FTransform(const Image& image, Image& result)
{
assert(image.IsSquare() && result.GetH() == image.GetH());
assert(result.GetH() == SIZE_FFT);
int N = image.GetH();
double normalizer = 1.f / N;
//actualy must by 28x28
double arr[SIZE_FFT][SIZE_FFT];
double maxMagnitude = 0;
for (int k = 0; k < N; ++k)
{
#pragma omp parallel
#pragma omp for
for (int l = 0; l < N; ++l)
{
std::complex<double> sum = 0;
for (int i = 0; i < N; ++i)
for (int j = 0; j < N; ++j)
{
double freq = double(image.Get(i, j));
double angle = PI2 * (double(k * i + l *j) / double(N));
sum += freq * std::exp(-1i * angle);
}
// abs from complex number return magnitude
sum *= normalizer;
double sq = abs(sum);
if (maxMagnitude < sq)
maxMagnitude = sq;
// set (0,0) of image in center
arr[(k + N / 2) % N][(l + N / 2) % N] = sq;
}
}
double coef = 255. / log(1 + fabs(maxMagnitude* 0.6));
for (int i = 0; i < SIZE_FFT; ++i)
{
for (int j = 0; j < SIZE_FFT; ++j)
{
double lg = coef * log(arr[i][j] * 0.6);
if (lg < 0.)
lg = 0.;
result.Set(i, j, lg);
}
}
}
|
#include<iostream>
#include<cstdio>
#include<map>
#include<vector>
#include<queue>
#include<string>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
int n;
string st[110];
bool cmp(string a,string b)
{
return a.size() < b.size();
}
void revense(string &a,string &b)
{
b = "";
for (int i = a.size()-1;i >= 0; i--)
b = b + a[i];
}
bool check(string &p1,string &p2)
{
for (int i = 1;i < n; i++)
if (st[i].find(p1) == string::npos && st[i].find(p2) == string::npos) return false;
return true;
}
int main()
{
int t;
cin >> t;
while (t--)
{
cin >> n;
for (int i = 0;i < n; i++)
cin >> st[i];
sort(st,st+n,cmp);
int ans = 0;
for (int len = st[0].size();len > 0; len--)
{
if (ans) break;
for (int loc = 0;loc + len <= st[0].size(); loc++)
{
string p1,p2;
p1 = st[0].substr(loc,len);
revense(p1,p2);
//cout << p1 << endl;
if (check(p1,p2))
{
ans = len;
break;
}
}
}
cout << ans << endl;
}
return 0;
}
|
/* -*- Mode: c++; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*-
*
* Copyright (C) 1995-2007 Opera Software AS. All rights reserved.
*
* This file is part of the Opera web browser.
* It may not be distributed under any circumstances.
*/
#ifndef DESKTOP_ACCESSIBILITY_EXTENSION_H
#define DESKTOP_ACCESSIBILITY_EXTENSION_H
#include "modules/pi/OpAccessibilityExtension.h"
class DesktopAccessibilityExtension :
public OpAccessibilityExtension
{
public:
static OP_STATUS Create(OpAccessibilityExtension** extension,
OpAccessibilityExtension* parent,
OpAccessibilityExtensionListener* listener,
ElementKind kind);
};
#endif // DESKTOP_ACCESSIBILITY_EXTENSION_H
|
#include "point.hpp"
#include "components/room.hpp"
#include "components/ai/ai.hpp"
#include "job/jobprovider.hpp"
#include "hydroponics/hydroponics.hpp"
#include "hydroponics/hydroponicsai.hpp"
#include <memory>
using namespace ecs;
using namespace job;
using namespace ai;
namespace hydroponics {
Ent* make_hydroponics_room(const Rect& r) {
Ent* e = new Ent;
e->emplace<Room>(r);
e->emplace<JobProvider>();
e->emplace<AI>(std::make_shared<HydroponicsAI>());
e->emplace_system<AISystem>();
e->emplace_system<JobProviderSystem>();
return e;
}
}
|
#ifndef EXC_HPP
#define EXC_HPP
#define REPORT { printf("Invalid\n"); return; }
#include "tokenscanner.hpp"
#include "tool.h"
#include "bookingSystem.h"
#include "vector.hpp"
#include <string>
using std::string;
/*UP_DATE 0516
nextToken()的返回值改成了String
保留了firstToken的返回值为string
*/
void EXECUTOR(ticketBookingSystem &B, const string &_log)
{
TokenScanner scanner;
scanner.setInput(_log);
if (!scanner.hasMoreTokens()) REPORT;
string firsttoken = scanner.firstToken();
//user
if (firsttoken == "register") //name password email phone
{
vector< std::pair<TYPE, String> > parameter;
if (!scanner.hasMoreTokens()) REPORT;
String tmp = scanner.nextToken();
parameter.push_back(std::make_pair(STRING, tmp));
if (!scanner.hasMoreTokens()) REPORT;
tmp = scanner.nextToken();
parameter.push_back(std::make_pair(STRING, tmp));
if (!scanner.hasMoreTokens()) REPORT;
tmp = scanner.nextToken();
parameter.push_back(std::make_pair(STRING, tmp));
if (!scanner.hasMoreTokens()) REPORT;
tmp = scanner.nextToken();
parameter.push_back(std::make_pair(STRING, tmp));
B.process(firsttoken, parameter);
}
else if (firsttoken == "login") //id password
{
vector< std::pair<TYPE, String> > parameter;
if (!scanner.hasMoreTokens()) REPORT;
String tmp = scanner.nextToken();
parameter.push_back(std::make_pair(_INT, tmp));//is id a number?
if (!scanner.hasMoreTokens()) REPORT;
tmp = scanner.nextToken();
parameter.push_back(std::make_pair(STRING, tmp));
B.process(firsttoken, parameter);
}
else if (firsttoken == "query_profile") //id
{
vector< std::pair<TYPE, String> > parameter;
if (!scanner.hasMoreTokens()) REPORT;
String tmp = scanner.nextToken();
parameter.push_back(std::make_pair(_INT, tmp));
B.process(firsttoken, parameter);
}
else if (firsttoken == "modify_profile") //id name password email phone
{
vector< std::pair<TYPE, String> > parameter;
if (!scanner.hasMoreTokens()) REPORT;
String tmp = scanner.nextToken();
parameter.push_back(std::make_pair(_INT, tmp));
if (!scanner.hasMoreTokens()) REPORT;
tmp = scanner.nextToken();
parameter.push_back(std::make_pair(STRING, tmp));
if (!scanner.hasMoreTokens()) REPORT;
tmp = scanner.nextToken();
parameter.push_back(std::make_pair(STRING, tmp));
if (!scanner.hasMoreTokens()) REPORT;
tmp = scanner.nextToken();
parameter.push_back(std::make_pair(STRING, tmp));
if (!scanner.hasMoreTokens()) REPORT;
tmp = scanner.nextToken();
parameter.push_back(std::make_pair(STRING, tmp));
B.process(firsttoken, parameter);
}
else if (firsttoken == "modify_privilege") //id1 id2 privilege
{
vector< std::pair<TYPE, String> > parameter;
if (!scanner.hasMoreTokens()) REPORT;
String tmp = scanner.nextToken();
parameter.push_back(std::make_pair(_INT, tmp));
if (!scanner.hasMoreTokens()) REPORT;
tmp = scanner.nextToken();
parameter.push_back(std::make_pair(_INT, tmp));
if (!scanner.hasMoreTokens()) REPORT;
tmp = scanner.nextToken();
//int privilege = scanner.isNumber(tmp);
//if (privilege == -1) Error;
parameter.push_back(std::make_pair(_INT, tmp));
B.process(firsttoken, parameter);
}
//ticket
else if (firsttoken == "query_ticket") //loc1 loc2 date catalog
{
vector< std::pair<TYPE, String> > parameter;
if (!scanner.hasMoreTokens()) REPORT;
String tmp = scanner.nextToken();
parameter.push_back(std::make_pair(STRING, tmp));
if (!scanner.hasMoreTokens()) REPORT;
tmp = scanner.nextToken();
parameter.push_back(std::make_pair(STRING, tmp));
if (!scanner.hasMoreTokens()) REPORT;
tmp = scanner.nextToken();
parameter.push_back(std::make_pair(_DATE, tmp));
if (!scanner.hasMoreTokens()) REPORT;
tmp = scanner.nextToken();
parameter.push_back(std::make_pair(STRING, tmp));
B.process(firsttoken, parameter);
}
else if (firsttoken == "query_transfer")//loc1 loc2 date catalog
{
vector< std::pair<TYPE, String> > parameter;
if (!scanner.hasMoreTokens()) REPORT;
String tmp = scanner.nextToken();
parameter.push_back(std::make_pair(STRING, tmp));
if (!scanner.hasMoreTokens()) REPORT;
tmp = scanner.nextToken();
parameter.push_back(std::make_pair(STRING, tmp));
if (!scanner.hasMoreTokens()) REPORT;
tmp = scanner.nextToken();
parameter.push_back(std::make_pair(_DATE, tmp));
if (!scanner.hasMoreTokens()) REPORT;
tmp = scanner.nextToken();
parameter.push_back(std::make_pair(STRING, tmp));
B.process(firsttoken, parameter);
}
else if (firsttoken == "buy_ticket") //id num train_id loc1 loc2 _DATE kind
{
vector< std::pair<TYPE, String> > parameter;
if (!scanner.hasMoreTokens()) REPORT;
String tmp = scanner.nextToken();
parameter.push_back(std::make_pair(_INT, tmp));
if (!scanner.hasMoreTokens()) REPORT;
tmp = scanner.nextToken();
//int num = scanner.isNumber(tmp);
//if (num == -1) Error;
parameter.push_back(std::make_pair(_INT, tmp));
if (!scanner.hasMoreTokens()) REPORT;
tmp = scanner.nextToken();
parameter.push_back(std::make_pair(STRING, tmp));
if (!scanner.hasMoreTokens()) REPORT;
tmp = scanner.nextToken();
parameter.push_back(std::make_pair(STRING, tmp));
if (!scanner.hasMoreTokens()) REPORT;
tmp = scanner.nextToken();
parameter.push_back(std::make_pair(STRING, tmp));
if (!scanner.hasMoreTokens()) REPORT;
tmp = scanner.nextToken();
parameter.push_back(std::make_pair(_DATE, tmp));
if (!scanner.hasMoreTokens()) REPORT;
tmp = scanner.nextToken();
parameter.push_back(std::make_pair(STRING, tmp));
B.process(firsttoken, parameter);
}
else if (firsttoken == "query_order") //id date catalog
{
vector< std::pair<TYPE, String> > parameter;
if (!scanner.hasMoreTokens()) REPORT;
String tmp = scanner.nextToken();
parameter.push_back(std::make_pair(_INT, tmp));
if (!scanner.hasMoreTokens()) REPORT;
tmp = scanner.nextToken();
parameter.push_back(std::make_pair(_DATE, tmp));
if (!scanner.hasMoreTokens()) REPORT;
tmp = scanner.nextToken();
parameter.push_back(std::make_pair(STRING, tmp));
B.process(firsttoken, parameter);
}
else if (firsttoken == "refund_ticket")//id num trian_id loc1 loc2 date kind
{
vector< std::pair<TYPE, String> > parameter;
if (!scanner.hasMoreTokens()) REPORT;
String tmp = scanner.nextToken();
parameter.push_back(std::make_pair(_INT, tmp));
if (!scanner.hasMoreTokens()) REPORT;
tmp = scanner.nextToken();
//int num = scanner.isNumber(tmp);
//if (num == -1) Error;
parameter.push_back(std::make_pair(_INT, tmp));
if (!scanner.hasMoreTokens()) REPORT;
tmp = scanner.nextToken();
parameter.push_back(std::make_pair(STRING, tmp));
if (!scanner.hasMoreTokens()) REPORT;
tmp = scanner.nextToken();
parameter.push_back(std::make_pair(STRING, tmp));
if (!scanner.hasMoreTokens()) REPORT;
tmp = scanner.nextToken();
parameter.push_back(std::make_pair(STRING, tmp));
if (!scanner.hasMoreTokens()) REPORT;
tmp = scanner.nextToken();
parameter.push_back(std::make_pair(_DATE, tmp));
if (!scanner.hasMoreTokens()) REPORT;
tmp = scanner.nextToken();
parameter.push_back(std::make_pair(STRING, tmp));
B.process(firsttoken, parameter);
}
//train
//train_id name catalog num(station) num(price) name_price
//station_name timearrive timestart timestopover priceofeachkind
else if (firsttoken == "add_train")
{
vector< std::pair<TYPE, String> > parameter;
if (!scanner.hasMoreTokens()) REPORT;
String tmp = scanner.nextToken();
parameter.push_back(std::make_pair(STRING, tmp));
if (!scanner.hasMoreTokens()) REPORT;
tmp = scanner.nextToken();
parameter.push_back(std::make_pair(STRING, tmp));
if (!scanner.hasMoreTokens()) REPORT;
tmp = scanner.nextToken();
parameter.push_back(std::make_pair(STRING, tmp));
if (!scanner.hasMoreTokens()) REPORT;
tmp = scanner.nextToken();
int num_station = tmp.asint();
parameter.push_back(std::make_pair(_INT, tmp));
if (!scanner.hasMoreTokens()) REPORT;
tmp = scanner.nextToken();
int num_price = tmp.asint();
parameter.push_back(std::make_pair(_INT, tmp));
for (int i = 1; i <= num_price; ++i)
{
if (!scanner.hasMoreTokens()) REPORT;
tmp = scanner.nextToken();
parameter.push_back(std::make_pair(STRING, tmp));
}
for (int _ = 1; _ <= num_station; ++_)
{
if (!scanner.hasMoreTokens()) REPORT;
tmp = scanner.nextToken();
parameter.push_back(std::make_pair(STRING, tmp));
if (!scanner.hasMoreTokens()) REPORT;
tmp = scanner.nextToken();
parameter.push_back(std::make_pair(TIME, tmp));
if (!scanner.hasMoreTokens()) REPORT;
tmp = scanner.nextToken();
parameter.push_back(std::make_pair(TIME, tmp));
if (!scanner.hasMoreTokens()) REPORT;
tmp = scanner.nextToken();
parameter.push_back(std::make_pair(TIME, tmp));
for (int i = 1; i <= num_price; ++i)
{
if (!scanner.hasMoreTokens()) REPORT;
tmp = scanner.nextToken();
parameter.push_back(std::make_pair(_DOUBLE, tmp));
}
}
B.process(firsttoken, parameter);
}
else if (firsttoken == "sale_train")//train_id
{
vector< std::pair<TYPE, String> > parameter;
if (!scanner.hasMoreTokens()) REPORT;
String tmp = scanner.nextToken();
parameter.push_back(std::make_pair(STRING, tmp));
B.process(firsttoken, parameter);
}
else if (firsttoken == "query_train")//train_id
{
vector< std::pair<TYPE, String> > parameter;
if (!scanner.hasMoreTokens()) REPORT;
String tmp = scanner.nextToken();
parameter.push_back(std::make_pair(STRING, tmp));
B.process(firsttoken, parameter);
}
else if (firsttoken == "delete_train")//train_id
{
vector< std::pair<TYPE, String> > parameter;
if (!scanner.hasMoreTokens()) REPORT;
String tmp = scanner.nextToken();
parameter.push_back(std::make_pair(STRING, tmp));
B.process(firsttoken, parameter);
}
//train_id name catalog num(station) num(price) name_price
//station_name timearrive timestart timestopover priceofeachkind
else if (firsttoken == "modify_train")
{
vector< std::pair<TYPE, String> > parameter;
if (!scanner.hasMoreTokens()) REPORT;
String tmp = scanner.nextToken();
parameter.push_back(std::make_pair(STRING, tmp));
if (!scanner.hasMoreTokens()) REPORT;
tmp = scanner.nextToken();
parameter.push_back(std::make_pair(STRING, tmp));
if (!scanner.hasMoreTokens()) REPORT;
tmp = scanner.nextToken();
parameter.push_back(std::make_pair(STRING, tmp));
if (!scanner.hasMoreTokens()) REPORT;
tmp = scanner.nextToken();
int num_station = tmp.asint();
parameter.push_back(std::make_pair(_INT, tmp));
if (!scanner.hasMoreTokens()) REPORT;
tmp = scanner.nextToken();
int num_price = tmp.asint();
parameter.push_back(std::make_pair(_INT, tmp));
for (int i = 1; i <= num_price; ++i)
{
if (!scanner.hasMoreTokens()) REPORT;
tmp = scanner.nextToken();
parameter.push_back(std::make_pair(STRING, tmp));
}
for (int _ = 1; _ <= num_station; ++_)
{
if (!scanner.hasMoreTokens()) REPORT;
tmp = scanner.nextToken();
parameter.push_back(std::make_pair(STRING, tmp));
if (!scanner.hasMoreTokens()) REPORT;
tmp = scanner.nextToken();
parameter.push_back(std::make_pair(TIME, tmp));
if (!scanner.hasMoreTokens()) REPORT;
tmp = scanner.nextToken();
parameter.push_back(std::make_pair(TIME, tmp));
if (!scanner.hasMoreTokens()) REPORT;
tmp = scanner.nextToken();
parameter.push_back(std::make_pair(TIME, tmp));
for (int i = 1; i <= num_price; ++i)
{
if (!scanner.hasMoreTokens()) REPORT;
tmp = scanner.nextToken();
parameter.push_back(std::make_pair(_DOUBLE, tmp));
}
}
B.process(firsttoken, parameter);
}
//manager
else if (firsttoken == "clean")
{
B.process(firsttoken, vector< std::pair<TYPE, String> >());
}
else if (firsttoken == "exit")
{
B.process(firsttoken, vector< std::pair<TYPE, String> >());
}
else REPORT;
};
#endif
|
#include "UnitCommand.h"
using namespace BroodWar::Api;
namespace BroodWar
{
namespace Api
{
namespace Client
{
UnitCommand::UnitCommand(BWAPIC::UnitCommand command)
{
instance = new BWAPIC::UnitCommand(command);
}
UnitCommand::~UnitCommand()
{
delete instance;
}
UnitCommand::!UnitCommand()
{
delete instance;
}
UnitCommand::UnitCommand()
{
instance = new BWAPIC::UnitCommand();
}
UnitCommandType UnitCommand::CommandType::get()
{
return EnumMapping::UnitCommandType->Managed(instance->type);
}
void UnitCommand::CommandType::set(UnitCommandType type)
{
instance->type = EnumMapping::UnitCommandType->Native(type);
}
int UnitCommand::UnitIndex::get()
{
return instance->unitIndex;
}
void UnitCommand::UnitIndex::set(int value)
{
instance->unitIndex = value;
}
int UnitCommand::TargetIndex::get()
{
return instance->targetIndex;
}
void UnitCommand::TargetIndex::set(int value)
{
instance->targetIndex = value;
}
int UnitCommand::X::get()
{
return instance->x;
}
void UnitCommand::X::set(int value)
{
instance->x = value;
}
int UnitCommand::Y::get()
{
return instance->y;
}
void UnitCommand::Y::set(int value)
{
instance->y = value;
}
int UnitCommand::Extra::get()
{
return instance->extra;
}
void UnitCommand::Extra::set(int value)
{
instance->extra = value;
}
}
}
}
|
#include <iostream>
#include <fstream>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <map>
#include <vector>
#include <algorithm>
#include <math.h>
#define pb push_back
using namespace std;
struct congviec {
int order;
float t, s, avg;
};
vector <congviec> cv;
void input() {
int n;
congviec temp;
scanf("%d", &n);
for (int i = 0; i < n; i++) {
temp.order = i + 1;
scanf("%f %f", &temp.t, &temp.s);
temp.avg = temp.s / temp.t;
cv.pb(temp);
}
}
bool cmp (congviec cv1, congviec cv2) {
if (cv1.avg > cv2.avg)
return 1;
return 0;
}
void solve() {
int len = cv.size();
sort(cv.begin(), cv.end(), cmp);
for (int i = 0; i < len; i++) {
printf("%d ", cv[i].order);
}
}
int main()
{
int ntest;
freopen("10026.inp", "r", stdin);
scanf("%d", &ntest);
for (int itest = 0; itest < ntest; itest++) {
input();
solve();
}
return 0;
}
|
#include <ExtraButton.h>
#define rPin 3
#define gPin 5
#define bPin 6
#define nextPin A5
#define lvlPin A4
ExtraButton nextBtn(nextPin);
ExtraButton levelBtn(lvlPin);
void setup() {
pinMode(rPin, OUTPUT);
analogWrite(rPin, 255);
pinMode(gPin, OUTPUT);
analogWrite(gPin, 255);
pinMode(bPin, OUTPUT);
analogWrite(bPin, 255);
}
int colors[] = {rPin, gPin, bPin};
int directions[] = {-1,-1,-1};
int lumen[] = {255,255,255};
int selectedColor = 0;
int speeds = 0;
void onClick(int btnPin){
selectedColor = (selectedColor+1)%3;
directions[selectedColor] = (lumen[selectedColor] > 125) ? -1 : 1;
}
void onRelease(int btnPin){
speeds = 0;
if (lumen[selectedColor] == 0 || lumen[selectedColor] == 255){
directions[selectedColor] *= -1;
}
}
void btnPressed(int btnPin){
lumen[selectedColor] = lumen[selectedColor]+(1+speeds++/2)*directions[selectedColor];
if (lumen[selectedColor] > 255){
lumen[selectedColor] = 255;
}else if(lumen[selectedColor] < 0){
lumen[selectedColor] = 0;
}
analogWrite(colors[selectedColor], lumen[selectedColor]);
}
void loop() {
nextBtn.onClick(*onClick);
levelBtn.onRelease(*onRelease);
levelBtn.whenPressed(*btnPressed,22);
delay(1);
}
|
#include <iostream>
#include <sstream>
#include <omp.h>
#include <vector>
#include <chrono>
int main(int argc, char** argv)
{
if(argc > 1)
{
std::stringstream ss;
ss << argv[1];
int numThreads;
ss >> numThreads;
omp_set_num_threads(numThreads);
}
#pragma omp parallel
{
#pragma omp for ordered
for (int n = 0; n < 10; ++n)
{
printf("u1 = %d\n",n);
#pragma omp ordered
printf("o = %d\n",n);
printf("u2 = %d\n",n);
}
}
return 0;
}
|
// Created on: 1998-08-04
// Created by: Christian CAILLET
// Copyright (c) 1998-1999 Matra Datavision
// Copyright (c) 1999-2014 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _StepAP214_AutoDesignReferencingItem_HeaderFile
#define _StepAP214_AutoDesignReferencingItem_HeaderFile
#include <Standard.hxx>
#include <Standard_DefineAlloc.hxx>
#include <Standard_Handle.hxx>
#include <StepData_SelectType.hxx>
#include <Standard_Integer.hxx>
class Standard_Transient;
class StepBasic_Approval;
class StepBasic_DocumentRelationship;
class StepRepr_ExternallyDefinedRepresentation;
class StepRepr_MappedItem;
class StepRepr_MaterialDesignation;
class StepVisual_PresentationArea;
class StepVisual_PresentationView;
class StepBasic_ProductCategory;
class StepBasic_ProductDefinition;
class StepBasic_ProductDefinitionRelationship;
class StepRepr_PropertyDefinition;
class StepRepr_Representation;
class StepRepr_RepresentationRelationship;
class StepRepr_ShapeAspect;
class StepAP214_AutoDesignReferencingItem : public StepData_SelectType
{
public:
DEFINE_STANDARD_ALLOC
//! Returns a AutoDesignReferencingItem SelectType
Standard_EXPORT StepAP214_AutoDesignReferencingItem();
//! Recognizes a AutoDesignReferencingItem Kind Entity that is :
//! 1 Approval from StepBasic,
//! 2 DocumentRelationship from StepBasic,
//! 3 ExternallyDefinedRepresentation from StepRepr,
//! 4 MappedItem from StepRepr,
//! 5 MaterialDesignation from StepRepr,
//! 6 PresentationArea from StepVisual,
//! 7 PresentationView from StepVisual,
//! 8 ProductCategory from StepBasic,
//! 9 ProductDefinition from StepBasic,
//! 10 ProductDefinitionRelationship from StepBasic,
//! 11 PropertyDefinition from StepBasic,
//! 12 Representation from StepRepr,
//! 13 RepresentationRelationship from StepRepr,
//! 14 ShapeAspect from StepRepr
//! 0 else
Standard_EXPORT Standard_Integer CaseNum (const Handle(Standard_Transient)& ent) const;
Standard_EXPORT Handle(StepBasic_Approval) Approval() const;
Standard_EXPORT Handle(StepBasic_DocumentRelationship) DocumentRelationship() const;
Standard_EXPORT Handle(StepRepr_ExternallyDefinedRepresentation) ExternallyDefinedRepresentation() const;
Standard_EXPORT Handle(StepRepr_MappedItem) MappedItem() const;
Standard_EXPORT Handle(StepRepr_MaterialDesignation) MaterialDesignation() const;
Standard_EXPORT Handle(StepVisual_PresentationArea) PresentationArea() const;
Standard_EXPORT Handle(StepVisual_PresentationView) PresentationView() const;
Standard_EXPORT Handle(StepBasic_ProductCategory) ProductCategory() const;
Standard_EXPORT Handle(StepBasic_ProductDefinition) ProductDefinition() const;
Standard_EXPORT Handle(StepBasic_ProductDefinitionRelationship) ProductDefinitionRelationship() const;
Standard_EXPORT Handle(StepRepr_PropertyDefinition) PropertyDefinition() const;
Standard_EXPORT Handle(StepRepr_Representation) Representation() const;
Standard_EXPORT Handle(StepRepr_RepresentationRelationship) RepresentationRelationship() const;
Standard_EXPORT Handle(StepRepr_ShapeAspect) ShapeAspect() const;
protected:
private:
};
#endif // _StepAP214_AutoDesignReferencingItem_HeaderFile
|
#ifndef _MSC_VER
# define winexport
#else
# ifdef autoexport_EXPORTS
# define winexport
# else
# define winexport __declspec(dllimport)
# endif
#endif
class Hello
{
public:
static winexport int Data;
void real();
static void operator delete[](void*);
static void operator delete(void*);
};
|
#include "HighScoreFileReader.h"
namespace fileio
{
HighScoreFileReader::HighScoreFileReader(string& file):file(file)
{
//ctor
}
HighScoreFileReader::~HighScoreFileReader()
{
//dtor
}
void HighScoreFileReader::loadFile()
{
string line;
ifstream myfile (this->file);
if (myfile.is_open())
{
while ( getline (myfile,line) )
{
size_t pos = 0;
string score;
string timeLimit;
string date;
for(int index=0; index<3; index++)
{
string token = "";
pos = line.find(",");
token = line.substr(0, pos);
if(index==0)
{
score = token;
}
else if(index==1)
{
timeLimit = token;
}
else
{
date = token;
}
line.erase(0, pos + 1);
}
try
{
int value = stoi(score);
HighScore newScore;
newScore.setHighScore(value);
newScore.setDate(date);
newScore.setTimeLimit(timeLimit);
this->scores.push_back(newScore);
}
catch(...)
{
}
}
myfile.close();
}
else cout << "Unable to open/find file: " << this->file << endl;
}
vector<HighScore> HighScoreFileReader::getScores()
{
return this->scores;
}
}
|
/*====================================================================
Copyright(c) 2018 Adam Rankin
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files(the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and / or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions :
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
====================================================================*/
// Local includes
#include "pch.h"
#include "InstancedEffectCommon.h"
// DirectXTK includes
#include <EffectCommon.h>
using namespace DirectX;
// Constant buffer layout. Must match the shader!
struct InstancedBasicEffectConstants
{
XMVECTOR diffuseColor;
XMVECTOR emissiveColor;
XMVECTOR specularColorAndPower;
XMVECTOR lightDirection[IEffectLights::MaxDirectionalLights];
XMVECTOR lightDiffuseColor[IEffectLights::MaxDirectionalLights];
XMVECTOR lightSpecularColor[IEffectLights::MaxDirectionalLights];
XMVECTOR eyePosition[2];
XMVECTOR fogColor;
XMVECTOR fogVector[2];
XMMATRIX world;
XMVECTOR worldInverseTranspose[3];
XMMATRIX worldViewProj[2];
};
static_assert((sizeof(InstancedBasicEffectConstants) % (sizeof(float) * 4)) == 0, "InstancedBasicEffectConstants size must be 16-byte aligned (16 bytes is the length of four floats).");
// Traits type describes our characteristics to the EffectBase template.
struct BasicEffectTraits
{
typedef InstancedBasicEffectConstants ConstantBufferType;
static const int VertexShaderCount = 20;
static const int GeometryShaderCount = 8;
static const int PixelShaderCount = 10;
static const int ShaderPermutationCount = 32;
};
//-------------------------------------------------------------------
// Vertex shaders
#include <InstancedBasicEffect_VSBasic_VPRT.inc>
#include <InstancedBasicEffect_VSBasicNoFog_VPRT.inc>
#include <InstancedBasicEffect_VSBasicVc_VPRT.inc>
#include <InstancedBasicEffect_VSBasicVcNoFog_VPRT.inc>
#include <InstancedBasicEffect_VSBasicTx_VPRT.inc>
#include <InstancedBasicEffect_VSBasicTxNoFog_VPRT.inc>
#include <InstancedBasicEffect_VSBasicTxVc_VPRT.inc>
#include <InstancedBasicEffect_VSBasicTxVcNoFog_VPRT.inc>
#include <InstancedBasicEffect_VSBasicVertexLighting_VPRT.inc>
#include <InstancedBasicEffect_VSBasicVertexLightingVc_VPRT.inc>
#include <InstancedBasicEffect_VSBasicVertexLightingTx_VPRT.inc>
#include <InstancedBasicEffect_VSBasicVertexLightingTxVc_VPRT.inc>
#include <InstancedBasicEffect_VSBasicOneLight_VPRT.inc>
#include <InstancedBasicEffect_VSBasicOneLightVc_VPRT.inc>
#include <InstancedBasicEffect_VSBasicOneLightTx_VPRT.inc>
#include <InstancedBasicEffect_VSBasicOneLightTxVc_VPRT.inc>
#include <InstancedBasicEffect_VSBasicPixelLighting_VPRT.inc>
#include <InstancedBasicEffect_VSBasicPixelLightingVc_VPRT.inc>
#include <InstancedBasicEffect_VSBasicPixelLightingTx_VPRT.inc>
#include <InstancedBasicEffect_VSBasicPixelLightingTxVc_VPRT.inc>
const ShaderBytecode InstancedEffectBase<BasicEffectTraits>::VPRTVertexShaderBytecode[] =
{
{ InstancedBasicEffect_VSBasicVPRT, sizeof(InstancedBasicEffect_VSBasicVPRT) },
{ InstancedBasicEffect_VSBasicNoFogVPRT, sizeof(InstancedBasicEffect_VSBasicNoFogVPRT) },
{ InstancedBasicEffect_VSBasicVcVPRT, sizeof(InstancedBasicEffect_VSBasicVcVPRT) },
{ InstancedBasicEffect_VSBasicVcNoFogVPRT, sizeof(InstancedBasicEffect_VSBasicVcNoFogVPRT) },
{ InstancedBasicEffect_VSBasicTxVPRT, sizeof(InstancedBasicEffect_VSBasicTxVPRT) },
{ InstancedBasicEffect_VSBasicTxNoFogVPRT, sizeof(InstancedBasicEffect_VSBasicTxNoFogVPRT) },
{ InstancedBasicEffect_VSBasicTxVcVPRT, sizeof(InstancedBasicEffect_VSBasicTxVcVPRT) },
{ InstancedBasicEffect_VSBasicTxVcNoFogVPRT, sizeof(InstancedBasicEffect_VSBasicTxVcNoFogVPRT) },
{ InstancedBasicEffect_VSBasicVertexLightingVPRT, sizeof(InstancedBasicEffect_VSBasicVertexLightingVPRT) },
{ InstancedBasicEffect_VSBasicVertexLightingVcVPRT, sizeof(InstancedBasicEffect_VSBasicVertexLightingVcVPRT) },
{ InstancedBasicEffect_VSBasicVertexLightingTxVPRT, sizeof(InstancedBasicEffect_VSBasicVertexLightingTxVPRT) },
{ InstancedBasicEffect_VSBasicVertexLightingTxVcVPRT, sizeof(InstancedBasicEffect_VSBasicVertexLightingTxVcVPRT) },
{ InstancedBasicEffect_VSBasicOneLightVPRT, sizeof(InstancedBasicEffect_VSBasicOneLightVPRT) },
{ InstancedBasicEffect_VSBasicOneLightVcVPRT, sizeof(InstancedBasicEffect_VSBasicOneLightVcVPRT) },
{ InstancedBasicEffect_VSBasicOneLightTxVPRT, sizeof(InstancedBasicEffect_VSBasicOneLightTxVPRT) },
{ InstancedBasicEffect_VSBasicOneLightTxVcVPRT, sizeof(InstancedBasicEffect_VSBasicOneLightTxVcVPRT) },
{ InstancedBasicEffect_VSBasicPixelLightingVPRT, sizeof(InstancedBasicEffect_VSBasicPixelLightingVPRT) },
{ InstancedBasicEffect_VSBasicPixelLightingVcVPRT, sizeof(InstancedBasicEffect_VSBasicPixelLightingVcVPRT) },
{ InstancedBasicEffect_VSBasicPixelLightingTxVPRT, sizeof(InstancedBasicEffect_VSBasicPixelLightingTxVPRT) },
{ InstancedBasicEffect_VSBasicPixelLightingTxVcVPRT, sizeof(InstancedBasicEffect_VSBasicPixelLightingTxVcVPRT) },
};
#include <InstancedBasicEffect_VSBasic.inc>
#include <InstancedBasicEffect_VSBasicNoFog.inc>
#include <InstancedBasicEffect_VSBasicVc.inc>
#include <InstancedBasicEffect_VSBasicVcNoFog.inc>
#include <InstancedBasicEffect_VSBasicTx.inc>
#include <InstancedBasicEffect_VSBasicTxNoFog.inc>
#include <InstancedBasicEffect_VSBasicTxVc.inc>
#include <InstancedBasicEffect_VSBasicTxVcNoFog.inc>
#include <InstancedBasicEffect_VSBasicVertexLighting.inc>
#include <InstancedBasicEffect_VSBasicVertexLightingVc.inc>
#include <InstancedBasicEffect_VSBasicVertexLightingTx.inc>
#include <InstancedBasicEffect_VSBasicVertexLightingTxVc.inc>
#include <InstancedBasicEffect_VSBasicOneLight.inc>
#include <InstancedBasicEffect_VSBasicOneLightVc.inc>
#include <InstancedBasicEffect_VSBasicOneLightTx.inc>
#include <InstancedBasicEffect_VSBasicOneLightTxVc.inc>
#include <InstancedBasicEffect_VSBasicPixelLighting.inc>
#include <InstancedBasicEffect_VSBasicPixelLightingVc.inc>
#include <InstancedBasicEffect_VSBasicPixelLightingTx.inc>
#include <InstancedBasicEffect_VSBasicPixelLightingTxVc.inc>
const ShaderBytecode InstancedEffectBase<BasicEffectTraits>::VertexShaderBytecode[] =
{
{ InstancedBasicEffect_VSBasic, sizeof(InstancedBasicEffect_VSBasic) },
{ InstancedBasicEffect_VSBasicNoFog, sizeof(InstancedBasicEffect_VSBasicNoFog) },
{ InstancedBasicEffect_VSBasicVc, sizeof(InstancedBasicEffect_VSBasicVc) },
{ InstancedBasicEffect_VSBasicVcNoFog, sizeof(InstancedBasicEffect_VSBasicVcNoFog) },
{ InstancedBasicEffect_VSBasicTx, sizeof(InstancedBasicEffect_VSBasicTx) },
{ InstancedBasicEffect_VSBasicTxNoFog, sizeof(InstancedBasicEffect_VSBasicTxNoFog) },
{ InstancedBasicEffect_VSBasicTxVc, sizeof(InstancedBasicEffect_VSBasicTxVc) },
{ InstancedBasicEffect_VSBasicTxVcNoFog, sizeof(InstancedBasicEffect_VSBasicTxVcNoFog) },
{ InstancedBasicEffect_VSBasicVertexLighting, sizeof(InstancedBasicEffect_VSBasicVertexLighting) },
{ InstancedBasicEffect_VSBasicVertexLightingVc, sizeof(InstancedBasicEffect_VSBasicVertexLightingVc) },
{ InstancedBasicEffect_VSBasicVertexLightingTx, sizeof(InstancedBasicEffect_VSBasicVertexLightingTx) },
{ InstancedBasicEffect_VSBasicVertexLightingTxVc, sizeof(InstancedBasicEffect_VSBasicVertexLightingTxVc) },
{ InstancedBasicEffect_VSBasicOneLight, sizeof(InstancedBasicEffect_VSBasicOneLight) },
{ InstancedBasicEffect_VSBasicOneLightVc, sizeof(InstancedBasicEffect_VSBasicOneLightVc) },
{ InstancedBasicEffect_VSBasicOneLightTx, sizeof(InstancedBasicEffect_VSBasicOneLightTx) },
{ InstancedBasicEffect_VSBasicOneLightTxVc, sizeof(InstancedBasicEffect_VSBasicOneLightTxVc) },
{ InstancedBasicEffect_VSBasicPixelLighting, sizeof(InstancedBasicEffect_VSBasicPixelLighting) },
{ InstancedBasicEffect_VSBasicPixelLightingVc, sizeof(InstancedBasicEffect_VSBasicPixelLightingVc) },
{ InstancedBasicEffect_VSBasicPixelLightingTx, sizeof(InstancedBasicEffect_VSBasicPixelLightingTx) },
{ InstancedBasicEffect_VSBasicPixelLightingTxVc, sizeof(InstancedBasicEffect_VSBasicPixelLightingTxVc) },
};
const int InstancedEffectBase<BasicEffectTraits>::VertexShaderIndices[] =
{
0, // basic
1, // no fog
2, // vertex color
3, // vertex color, no fog
4, // texture
5, // texture, no fog
6, // texture + vertex color
7, // texture + vertex color, no fog
8, // vertex lighting
8, // vertex lighting, no fog
9, // vertex lighting + vertex color
9, // vertex lighting + vertex color, no fog
10, // vertex lighting + texture
10, // vertex lighting + texture, no fog
11, // vertex lighting + texture + vertex color
11, // vertex lighting + texture + vertex color, no fog
12, // one light
12, // one light, no fog
13, // one light + vertex color
13, // one light + vertex color, no fog
14, // one light + texture
14, // one light + texture, no fog
15, // one light + texture + vertex color
15, // one light + texture + vertex color, no fog
16, // pixel lighting
16, // pixel lighting, no fog
17, // pixel lighting + vertex color
17, // pixel lighting + vertex color, no fog
18, // pixel lighting + texture
18, // pixel lighting + texture, no fog
19, // pixel lighting + texture + vertex color
19, // pixel lighting + texture + vertex color, no fog
};
//-------------------------------------------------------------------
// Geometry shaders
#include <PCCIGeometryShader.inc>
#include <PCCTIGeometryShader.inc>
#include <PCIGeometryShader.inc>
#include <PCTIGeometryShader.inc>
#include <PTIGeometryShader.inc>
#include <PPNCIGeometryShader.inc>
// Pixel lighting passthrough shaders
#include <PCT0T4IGeometryShader.inc>
#include <PCT0T1T2IGeometryShader.inc>
const ShaderBytecode InstancedEffectBase<BasicEffectTraits>::GeometryShaderBytecode[] =
{
{ PCCIGeometryShader, sizeof(PCCIGeometryShader) },
{ PCCTIGeometryShader, sizeof(PCCTIGeometryShader) },
{ PCIGeometryShader, sizeof(PCIGeometryShader) },
{ PCTIGeometryShader, sizeof(PCTIGeometryShader) },
{ PTIGeometryShader, sizeof(PTIGeometryShader) },
{ PPNCIGeometryShader, sizeof(PPNCIGeometryShader) },
{ PCT0T4IGeometryShader, sizeof(PCT0T4IGeometryShader) },
{ PCT0T1T2IGeometryShader, sizeof(PCT0T1T2IGeometryShader) },
};
const int InstancedEffectBase<BasicEffectTraits>::GeometryShaderIndices[] =
{
0, // basic
2, // no fog
0, // vertex color
2, // vertex color, no fog
1, // texture
3, // texture, no fog
1, // texture + vertex color
3, // texture + vertex color, no fog
0, // vertex lighting
0, // vertex lighting, no fog
0, // vertex lighting + vertex color
0, // vertex lighting + vertex color, no fog
1, // vertex lighting + texture
1, // vertex lighting + texture, no fog
1, // vertex lighting + texture + vertex color
1, // vertex lighting + texture + vertex color, no fog
0, // one light
0, // one light, no fog
0, // one light + vertex color
0, // one light + vertex color, no fog
1, // one light + texture
1, // one light + texture, no fog
1, // one light + texture + vertex color
1, // one light + texture + vertex color, no fog
5, // pixel lighting
5, // pixel lighting, no fog
5, // pixel lighting + vertex color
5, // pixel lighting + vertex color, no fog
6, // pixel lighting + texture
6, // pixel lighting + texture, no fog
6, // pixel lighting + texture + vertex color
6, // pixel lighting + texture + vertex color, no fog
};
//-------------------------------------------------------------------
// Pixel shaders
#include <InstancedBasicEffect_PSBasic.inc>
#include <InstancedBasicEffect_PSBasicNoFog.inc>
#include <InstancedBasicEffect_PSBasicTx.inc>
#include <InstancedBasicEffect_PSBasicTxNoFog.inc>
#include <InstancedBasicEffect_PSBasicVertexLighting.inc>
#include <InstancedBasicEffect_PSBasicVertexLightingNoFog.inc>
#include <InstancedBasicEffect_PSBasicVertexLightingTx.inc>
#include <InstancedBasicEffect_PSBasicVertexLightingTxNoFog.inc>
#include <InstancedBasicEffect_PSBasicPixelLighting.inc>
#include <InstancedBasicEffect_PSBasicPixelLightingTx.inc>
const ShaderBytecode InstancedEffectBase<BasicEffectTraits>::PixelShaderBytecode[] =
{
{ InstancedBasicEffect_PSBasic, sizeof(InstancedBasicEffect_PSBasic) },
{ InstancedBasicEffect_PSBasicNoFog, sizeof(InstancedBasicEffect_PSBasicNoFog) },
{ InstancedBasicEffect_PSBasicTx, sizeof(InstancedBasicEffect_PSBasicTx) },
{ InstancedBasicEffect_PSBasicTxNoFog, sizeof(InstancedBasicEffect_PSBasicTxNoFog) },
{ InstancedBasicEffect_PSBasicVertexLighting, sizeof(InstancedBasicEffect_PSBasicVertexLighting) },
{ InstancedBasicEffect_PSBasicVertexLightingNoFog, sizeof(InstancedBasicEffect_PSBasicVertexLightingNoFog) },
{ InstancedBasicEffect_PSBasicVertexLightingTx, sizeof(InstancedBasicEffect_PSBasicVertexLightingTx) },
{ InstancedBasicEffect_PSBasicVertexLightingTxNoFog, sizeof(InstancedBasicEffect_PSBasicVertexLightingTxNoFog) },
{ InstancedBasicEffect_PSBasicPixelLighting, sizeof(InstancedBasicEffect_PSBasicPixelLighting) },
{ InstancedBasicEffect_PSBasicPixelLightingTx, sizeof(InstancedBasicEffect_PSBasicPixelLightingTx) },
};
const int InstancedEffectBase<BasicEffectTraits>::PixelShaderIndices[] =
{
0, // basic
1, // no fog
0, // vertex color
1, // vertex color, no fog
2, // texture
3, // texture, no fog
2, // texture + vertex color
3, // texture + vertex color, no fog
4, // vertex lighting
5, // vertex lighting, no fog
4, // vertex lighting + vertex color
5, // vertex lighting + vertex color, no fog
6, // vertex lighting + texture
7, // vertex lighting + texture, no fog
6, // vertex lighting + texture + vertex color
7, // vertex lighting + texture + vertex color, no fog
4, // one light
5, // one light, no fog
4, // one light + vertex color
5, // one light + vertex color, no fog
6, // one light + texture
7, // one light + texture, no fog
6, // one light + texture + vertex color
7, // one light + texture + vertex color, no fog
8, // pixel lighting
8, // pixel lighting, no fog
8, // pixel lighting + vertex color
8, // pixel lighting + vertex color, no fog
9, // pixel lighting + texture
9, // pixel lighting + texture, no fog
9, // pixel lighting + texture + vertex color
9, // pixel lighting + texture + vertex color, no fog
};
// Global pool of per-device BasicEffect resources.
SharedResourcePool<ID3D11Device*, InstancedEffectBase<BasicEffectTraits>::DeviceResources> InstancedEffectBase<BasicEffectTraits>::deviceResourcesPool;
namespace DirectX
{
// Internal BasicInstancedLightingEffect implementation class.
class InstancedBasicEffect::Impl : public InstancedEffectBase<BasicEffectTraits>
{
public:
Impl(_In_ ID3D11Device* device);
bool lightingEnabled;
bool preferPerPixelLighting;
bool vertexColorEnabled;
bool textureEnabled;
StereoEffectLights lights;
int GetCurrentShaderPermutation() const;
void Apply(_In_ ID3D11DeviceContext* deviceContext);
};
// Constructor.
InstancedBasicEffect::Impl::Impl(_In_ ID3D11Device* device)
: InstancedEffectBase(device),
lightingEnabled(false),
preferPerPixelLighting(false),
vertexColorEnabled(false),
textureEnabled(false)
{
lights.InitializeConstants(constants.specularColorAndPower, constants.lightDirection, constants.lightDiffuseColor, constants.lightSpecularColor);
}
int InstancedBasicEffect::Impl::GetCurrentShaderPermutation() const
{
int permutation = 0;
// Use optimized shaders if fog is disabled.
if (!fog.enabled)
{
permutation += 1;
}
// Support vertex coloring?
if (vertexColorEnabled)
{
permutation += 2;
}
// Support texturing?
if (textureEnabled)
{
permutation += 4;
}
if (lightingEnabled)
{
if (preferPerPixelLighting)
{
// Do lighting in the pixel shader.
permutation += 24;
}
else if (!lights.lightEnabled[1] && !lights.lightEnabled[2])
{
// Use the only-bother-with-the-first-light shader optimization.
permutation += 16;
}
else
{
// Compute all three lights in the vertex shader.
permutation += 8;
}
}
return permutation;
}
// Sets our state onto the D3D device.
void InstancedBasicEffect::Impl::Apply(_In_ ID3D11DeviceContext* deviceContext)
{
matrices.SetConstants(dirtyFlags, constants.worldViewProj[0], constants.worldViewProj[1]);
fog.SetConstants(dirtyFlags, matrices.worldView[0], matrices.worldView[1], constants.fogVector[0], constants.fogVector[1]);
lights.SetConstants(dirtyFlags,
matrices,
constants.world,
constants.worldInverseTranspose,
constants.eyePosition[0],
constants.eyePosition[1],
constants.diffuseColor,
constants.emissiveColor,
lightingEnabled);
// Set the texture.
if (textureEnabled)
{
ID3D11ShaderResourceView* textures[1] = { texture.Get() };
deviceContext->PSSetShaderResources(0, 1, textures);
}
// Set shaders and constant buffers.
ApplyShaders(deviceContext, GetCurrentShaderPermutation());
}
// Public constructor.
InstancedBasicEffect::InstancedBasicEffect(_In_ ID3D11Device* device)
: pImpl(new Impl(device))
{
}
// Move constructor.
InstancedBasicEffect::InstancedBasicEffect(InstancedBasicEffect&& moveFrom)
: pImpl(std::move(moveFrom.pImpl))
{
}
// Move assignment.
InstancedBasicEffect& InstancedBasicEffect::operator= (InstancedBasicEffect&& moveFrom)
{
pImpl = std::move(moveFrom.pImpl);
return *this;
}
// Public destructor.
InstancedBasicEffect::~InstancedBasicEffect()
{
}
// IEffect methods.
void InstancedBasicEffect::Apply(_In_ ID3D11DeviceContext* deviceContext)
{
pImpl->Apply(deviceContext);
}
void InstancedBasicEffect::GetVertexShaderBytecode(_Out_ void const** pShaderByteCode, _Out_ size_t* pByteCodeLength)
{
pImpl->GetVertexShaderBytecode(pImpl->GetCurrentShaderPermutation(), pShaderByteCode, pByteCodeLength);
}
// Camera settings.
void XM_CALLCONV InstancedBasicEffect::SetWorld(FXMMATRIX value)
{
pImpl->matrices.world = value;
pImpl->dirtyFlags |= EffectDirtyFlags::WorldViewProj | EffectDirtyFlags::WorldInverseTranspose | EffectDirtyFlags::FogVector;
}
void XM_CALLCONV InstancedBasicEffect::SetView(FXMMATRIX leftView, CXMMATRIX rightView)
{
pImpl->matrices.view[0] = leftView;
pImpl->matrices.view[1] = rightView;
}
void XM_CALLCONV InstancedBasicEffect::SetProjection(FXMMATRIX leftProjection, CXMMATRIX rightProjection)
{
pImpl->matrices.projection[0] = leftProjection;
pImpl->matrices.projection[1] = rightProjection;
}
void XM_CALLCONV InstancedBasicEffect::SetMatrices(FXMMATRIX world, CXMMATRIX leftView, CXMMATRIX rightView, CXMMATRIX leftProjection, CXMMATRIX rightProjection)
{
pImpl->matrices.world = world;
pImpl->matrices.view[0] = leftView;
pImpl->matrices.view[1] = rightView;
pImpl->matrices.projection[0] = leftProjection;
pImpl->matrices.projection[1] = rightProjection;
pImpl->dirtyFlags |= EffectDirtyFlags::WorldViewProj | EffectDirtyFlags::WorldInverseTranspose | EffectDirtyFlags::EyePosition | EffectDirtyFlags::FogVector;
}
// Material settings.
void XM_CALLCONV InstancedBasicEffect::SetDiffuseColor(FXMVECTOR value)
{
pImpl->lights.diffuseColor = value;
pImpl->dirtyFlags |= EffectDirtyFlags::MaterialColor;
}
FXMVECTOR XM_CALLCONV InstancedBasicEffect::GetDiffuseColor() const
{
return pImpl->lights.diffuseColor;
}
void XM_CALLCONV InstancedBasicEffect::SetEmissiveColor(FXMVECTOR value)
{
pImpl->lights.emissiveColor = value;
pImpl->dirtyFlags |= EffectDirtyFlags::MaterialColor;
}
FXMVECTOR XM_CALLCONV InstancedBasicEffect::GetEmissiveColor() const
{
return pImpl->lights.emissiveColor;
}
void XM_CALLCONV InstancedBasicEffect::SetSpecularColor(FXMVECTOR value)
{
// Set xyz to new value, but preserve existing w (specular power).
pImpl->constants.specularColorAndPower = XMVectorSelect(pImpl->constants.specularColorAndPower, value, g_XMSelect1110);
pImpl->dirtyFlags |= EffectDirtyFlags::ConstantBuffer;
}
void InstancedBasicEffect::SetSpecularPower(float value)
{
// Set w to new value, but preserve existing xyz (specular color).
pImpl->constants.specularColorAndPower = XMVectorSetW(pImpl->constants.specularColorAndPower, value);
pImpl->dirtyFlags |= EffectDirtyFlags::ConstantBuffer;
}
void InstancedBasicEffect::DisableSpecular()
{
// Set specular color to black, power to 1
// Note: Don't use a power of 0 or the shader will generate strange highlights on non-specular materials
pImpl->constants.specularColorAndPower = g_XMIdentityR3;
pImpl->dirtyFlags |= EffectDirtyFlags::ConstantBuffer;
}
void InstancedBasicEffect::SetAlpha(float value)
{
pImpl->lights.alpha = value;
pImpl->dirtyFlags |= EffectDirtyFlags::MaterialColor;
}
float InstancedBasicEffect::GetAlpha() const
{
return pImpl->lights.alpha;
}
void XM_CALLCONV InstancedBasicEffect::SetColorAndAlpha(FXMVECTOR value)
{
pImpl->lights.diffuseColor = value;
pImpl->lights.alpha = XMVectorGetW(value);
pImpl->dirtyFlags |= EffectDirtyFlags::MaterialColor;
}
// Light settings.
void InstancedBasicEffect::SetLightingEnabled(bool value)
{
pImpl->lightingEnabled = value;
pImpl->dirtyFlags |= EffectDirtyFlags::MaterialColor;
}
void InstancedBasicEffect::SetPerPixelLighting(bool value)
{
pImpl->preferPerPixelLighting = value;
}
void XM_CALLCONV InstancedBasicEffect::SetAmbientLightColor(FXMVECTOR value)
{
pImpl->lights.ambientLightColor = value;
pImpl->dirtyFlags |= EffectDirtyFlags::MaterialColor;
}
void InstancedBasicEffect::SetLightEnabled(int whichLight, bool value)
{
pImpl->dirtyFlags |= pImpl->lights.SetLightEnabled(whichLight, value, pImpl->constants.lightDiffuseColor, pImpl->constants.lightSpecularColor);
}
void XM_CALLCONV InstancedBasicEffect::SetLightDirection(int whichLight, FXMVECTOR value)
{
EffectLights::ValidateLightIndex(whichLight);
pImpl->constants.lightDirection[whichLight] = value;
pImpl->dirtyFlags |= EffectDirtyFlags::ConstantBuffer;
}
void XM_CALLCONV InstancedBasicEffect::SetLightDiffuseColor(int whichLight, FXMVECTOR value)
{
pImpl->dirtyFlags |= pImpl->lights.SetLightDiffuseColor(whichLight, value, pImpl->constants.lightDiffuseColor);
}
void XM_CALLCONV InstancedBasicEffect::SetLightSpecularColor(int whichLight, FXMVECTOR value)
{
pImpl->dirtyFlags |= pImpl->lights.SetLightSpecularColor(whichLight, value, pImpl->constants.lightSpecularColor);
}
void InstancedBasicEffect::EnableDefaultLighting()
{
EffectLights::EnableDefaultLighting(this);
}
// Fog settings.
void InstancedBasicEffect::SetFogEnabled(bool value)
{
pImpl->fog.enabled = value;
pImpl->dirtyFlags |= EffectDirtyFlags::FogEnable;
}
void InstancedBasicEffect::SetFogStart(float value)
{
pImpl->fog.start = value;
pImpl->dirtyFlags |= EffectDirtyFlags::FogVector;
}
void InstancedBasicEffect::SetFogEnd(float value)
{
pImpl->fog.end = value;
pImpl->dirtyFlags |= EffectDirtyFlags::FogVector;
}
void XM_CALLCONV InstancedBasicEffect::SetFogColor(FXMVECTOR value)
{
pImpl->constants.fogColor = value;
pImpl->dirtyFlags |= EffectDirtyFlags::ConstantBuffer;
}
// Vertex color setting.
void InstancedBasicEffect::SetVertexColorEnabled(bool value)
{
pImpl->vertexColorEnabled = value;
}
// Texture settings.
void InstancedBasicEffect::SetTextureEnabled(bool value)
{
pImpl->textureEnabled = value;
}
void InstancedBasicEffect::SetTexture(_In_opt_ ID3D11ShaderResourceView* value)
{
pImpl->texture = value;
}
}
|
#include<bits/stdc++.h>
#define rep(i, s, n) for (int i = (s); i < (int)(n); i++)
#define INF ((1LL<<62)-(1LL<<31)) /*オーバーフローしない程度に大きい数*/
#define MOD 1000000007
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using pint = pair<int,int>;
const double PI = 3.14159265358979323846;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
int main(){
int N;
cin >> N;
vector<int>A(N);
rep(i,0,N)cin >> A[i];
int sum = 0;//いったん合計出す
rep(i,0,N)sum += A[i];
if(sum % 10 != 0){
cout << sum << endl;
return 0;
}
sort(A.begin(),A.end());
rep(i,0,N){
if((sum - A[i]) % 10 != 0){
cout << sum - A[i] << endl;
return 0;
}
}
cout << 0 << endl;
return 0;
}
|
/*
* Math functions which will be used in the procedure of generating MED points.
*/
# ifndef MATHFUNCTIONS_H_
# define MATHFUNCTIONS_H_
# include <RcppEigen.h>
# include <unordered_set>
// [[Rcpp::depends(RcppEigen)]]
// [[Rcpp::plugins(cpp11)]]
using namespace Rcpp;
using namespace RcppEigen;
using namespace Eigen;
using namespace std;
#define minTwo(a, b) (a<b? a:b)
#define MaxTwo(a, b) (a>b? a:b)
# define PI 3.1415926
/*
* assert a number is prime
*/
bool isPrime(int n);
/*
* find out the maximum prime number less than given n
*/
int reportMaxPrime(int n);
/*
* Fast Fourier Transform
*/
ComplexVector FFT(NumericVector& x);
/*
* Inverse transform of Fast Fourier Transform
*/
ComplexVector IFFT(ComplexVector& x);
/*
* Omega function
*/
double calOmega(double x);
/*
* Overloading Omega function
*/
VectorXd calOmega(VectorXd & x);
/*
* Overloading Omega function
*/
NumericVector calOmega(NumericVector & x);
/*
* Calculates x ^ a (mod n) using the well known “Russian peasant method”
*/
int POWMOD(int x, int a, int n);
/*
*
*/
int findPrimefactors(unordered_set<int> & s, int n);
/*
* find out all uniqual primes numbers fo factor the number
*/
VectorXd findFactorize(int n);
/*
* get all irreducible factors of an integer
*/
int generateOrp(int n);
/*
* return the index (c++, begin with 0) with minimum value
*/
int argMin(VectorXd & x);
/*
* return the index (c++, begin with 0) with maximum value
*/
int argMax(VectorXd & x);
/*
* get the element-wise minimum between two vectors
*/
VectorXd compareMin(VectorXd & x, VectorXd & y);
/*
* compute distances between two point lists
*/
MatrixXd fastPdist(MatrixXd & x, MatrixXd & y);
/*
* overloading distance function
*/
VectorXd fastPdist(MatrixXd & x, VectorXd & y);
/*
* compute quantiles of data
*/
VectorXd quantileCPP(VectorXd & x, VectorXd & q);
/*
* compute the variance-covariance matrix
*/
MatrixXd varCPP(MatrixXd & x);
/*
* permutation of sequence
*/
VectorXi sampleCPP(int dim);
/*
* extract sub-columns of matrix
*/
MatrixXd subMatCols(MatrixXd & x, VectorXi & ID);
/*
* extract sub-rows of matrix
*/
MatrixXd subMatRows(MatrixXd & x, VectorXi ID);
/*
* re-set diagonal values of matrix
*/
MatrixXd setDiagonal(MatrixXd & x, double y);
/*
* order function
*/
VectorXi orderCPP(VectorXd & x);
/*
* rbind matrixs
*/
MatrixXd bindMatByRows(MatrixXd & x, MatrixXd & y);
/*
* remove one row from matrix
*/
MatrixXd removeMatRow(MatrixXd & x, int RowID);
/*
* bind matrix and vector
*/
MatrixXd bindMatByRows(MatrixXd & x, VectorXd & y);
template<typename Derived>
MatrixXd bindMatByRows(MatrixXd & x, Eigen::MatrixBase<Derived> & y);
/*
* remove one column from matrix
*/
MatrixXd removeMatCol(MatrixXd & x, int ColID);
/*
* remove row and column
*/
MatrixXd removeMatRowCol(MatrixXd & x, int RowID, int ColID);
/*
* bind matixs by column
*/
MatrixXd bindMatByCols(MatrixXd & x, MatrixXd & y);
/*
* bind matix and vector by column
*/
MatrixXd bindMatByCols(MatrixXd & x, VectorXd & y);
template<typename Derived>
MatrixXd bindMatByCols(MatrixXd & x, Eigen::MatrixBase<Derived> & y);
/*
* extract sub-elements of one vector
*/
VectorXd subVectElements(const VectorXd & x, const VectorXi EleID);
/*
* bind vectors by row
*/
VectorXd bindVectorByRow(const VectorXd & x, const VectorXd & y);
# endif
|
// Created on: 2018-06-10
// Created by: Natalia Ermolaeva
// Copyright (c) 2018-2020 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _TopoDS_AlertAttribute_HeaderFile
#define _TopoDS_AlertAttribute_HeaderFile
#include <Message_AttributeStream.hxx>
#include <Message_Messenger.hxx>
#include <Message_Report.hxx>
#include <TopoDS_Shape.hxx>
class Message_Messenger;
//! Alert attribute object storing TopoDS shape in its field
class TopoDS_AlertAttribute : public Message_AttributeStream
{
DEFINE_STANDARD_RTTIEXT(TopoDS_AlertAttribute, Message_AttributeStream)
public:
//! Constructor with shape argument
Standard_EXPORT TopoDS_AlertAttribute (const TopoDS_Shape& theShape,
const TCollection_AsciiString& theName = TCollection_AsciiString());
//! Returns contained shape
const TopoDS_Shape& GetShape() const { return myShape; }
public:
//! Push shape information into messenger
Standard_EXPORT static void Send (const Handle(Message_Messenger)& theMessenger,
const TopoDS_Shape& theShape);
//! Dumps the content of me into the stream
Standard_EXPORT void DumpJson (Standard_OStream& theOStream,
Standard_Integer theDepth = -1) const Standard_OVERRIDE;
private:
TopoDS_Shape myShape;
};
inline const Handle(Message_Messenger)& operator<< (const Handle(Message_Messenger)& theMessenger,
const TopoDS_Shape& theShape)
{
TopoDS_AlertAttribute::Send (theMessenger, theShape);
return theMessenger;
}
#endif // _TopoDS_AlertAttribute_HeaderFile
|
#include <iostream>
using namespace std;
int main() {
int n;
cout << " Enter n" << endl;
cin >> n;
int candies[100];
cout <<" Enter candies" << endl;
for(int i= 0; i< n; i++){
cin >> candies[i];
}
int extraCandies, max=0;
cout << "Enter extracandies" << endl;
cin >> extraCandies;
for(int i=0; i< n; i++){
if(max < candies[i])
max = candies[i];
}
bool output[100];
for(int i = 0; i< n; i++){
if(candies[i] + extraCandies >= max){
output[i] = true;
cout << "True";}
else{
output[i]=false;
cout << "False";
}
}
return 0;
}
|
#pragma once
#include <vector>
using namespace std;
class ship
{
private:
vector<int> x;
vector<int> y;
int rotation;
vector<char> symbol;
int hp;
public:
ship(int, int, int, int);
int getX(int);
int getY(int);
int getRotation();
char getSymbol(int);
void setSymbol(int, char);
int getHP();
int getSize();
int takeHit(int, int);
};
|
// BSD 3-Clause License
//
// Copyright (c) 2020-2021, bodand
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// 1. Redistributions of source code must retain the above copyright notice, this
// list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// 3. Neither the name of the copyright holder nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#pragma once
// stdlib
#include <type_traits>
#include <utility>
/**
* Main namespace for universal
* utilities in the Info* libraries
*
* InfoUtils works with this namespace
*/
namespace info {
/**
* \brief Generalizes lambdas by allowing recursion
*
* A lambda construct wrapper allowing the creation of recursive lambdas.
*
* \note The first parameter must be an `auto` parameter representing the
* lambda itself. In Info project it is always called `self`.
*
* \warning Despite the lambda declaration having to contain a bonus parameter,
* it does not change the output lambda's interface. Therefore, it
* must not be passed when invoking the lambda.
*
* \note While lambda is used throughout this documentation, any functor suffices.
* Of course, other non-lambda objects don't really require this helper
* to allow for recursion.
*
* \tparam F The unspecified lambda type to allow recursion for
*
* \since 1.0
* \author bodand
*/
template<class F>
struct lambda {
/**
* \brief Calls the lambda with the passed arguments, plus itself for recursion
*
* Calls the lambda and passes this object with the other arguments
* passed, therefore, allowing recursion by calling the first parameter.
*
* The passed parameters are forwarded.
*
* \note If the invocation of the lambda is nothrow then this function
* is nothrow.
*
* \tparam ArgsT The types of the arguments
*
* \param args The arguments to pass to the lambda
*
* \return The return value of the lambda. May be void.
*/
template<class... ArgsT>
auto
operator()(ArgsT&&... args) noexcept(std::is_nothrow_invocable_v<F, ArgsT...>) {
return _fun(*this, std::forward<ArgsT>(args)...);
}
/**
* \brief Constructs a info::lambda object from any lambda type
*
* \param fun The lambda of unspecified type. This is the lambda upon
* which the power of recursion is to be bestowed
*/
lambda(F fun) noexcept
: _fun{fun} {};
private:
F _fun; ///< The real function object
};
}
|
#include "compiler/iterators.hpp"
#include "compiler/token_definitions.hpp"
#include <boost/test/unit_test.hpp>
#include <boost/spirit/home/lex/tokenize_and_parse.hpp>
#include <sstream>
#include <vector>
static bool tokenize( const std::string& source, std::vector< perseus::detail::token >& out_tokens )
{
std::stringstream stream( source );
perseus::detail::enhanced_istream_iterator begin, end;
std::tie( begin, end ) = perseus::detail::enhanced_iterators( stream );
return boost::spirit::lex::tokenize(
begin,
end,
perseus::detail::token_definitions{},
[ &out_tokens ]( const perseus::detail::token& t )
{
out_tokens.push_back( t );
return true; // continue tokenizing
}
);
}
BOOST_AUTO_TEST_SUITE( compiler )
BOOST_AUTO_TEST_SUITE( lexer )
BOOST_AUTO_TEST_CASE( basic )
{
std::vector< perseus::detail::token > result;
bool success = tokenize( u8R"(// a c\u00D6mment
some identifiers/*
and a long comment
*/)", result );
BOOST_CHECK( success );
BOOST_CHECK_EQUAL( result.size(), 6 );
BOOST_CHECK_EQUAL( result.at( 0 ).id(), perseus::detail::token_id::comment );
BOOST_CHECK_EQUAL( result.at( 1 ).id(), perseus::detail::token_id::whitespace );
BOOST_CHECK_EQUAL( result.at( 2 ).id(), perseus::detail::token_id::identifier );
BOOST_CHECK_EQUAL( result.at( 2 ).value().begin().get_position(), perseus::detail::file_position( 2, 2 ) );
BOOST_CHECK_EQUAL( std::string( result.at( 2 ).value().begin(), result.at( 2 ).value().end() ), "some" );
BOOST_CHECK_EQUAL( result.at( 3 ).id(), perseus::detail::token_id::whitespace );
BOOST_CHECK_EQUAL( result.at( 4 ).id(), perseus::detail::token_id::identifier );
BOOST_CHECK_EQUAL( result.at( 5 ).id(), perseus::detail::token_id::comment );
}
BOOST_AUTO_TEST_CASE( longest_match_if )
{
std::vector< perseus::detail::token > result;
bool success = tokenize( u8R"(iffy if)", result );
BOOST_CHECK( success );
BOOST_CHECK_EQUAL( result.size(), 3 );
BOOST_CHECK_EQUAL( result.at( 0 ).id(), perseus::detail::token_id::identifier );
BOOST_CHECK_EQUAL( result.at( 1 ).id(), perseus::detail::token_id::whitespace );
BOOST_CHECK_EQUAL( result.at( 2 ).id(), perseus::detail::token_id::if_ );
}
BOOST_AUTO_TEST_SUITE_END()
BOOST_AUTO_TEST_SUITE_END()
|
#include <Arduino.h>
#include <SPI.h>
#define CS_PIN 5
#define SCK_PIN 18
#define MISO_PIN 19
#define MOSI_PIN 23
#define LEN_ID 4
#define GET_CHIP_ID 0x9F
void chipInit();
void chipGetId();
byte chipId[4];
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
delay(3000);
chipInit();
chipGetId();
}
void loop() {
// put your main code here, to run repeatedly:
}
void chipInit(){
pinMode(CS_PIN, OUTPUT);
SPI.begin(SCK_PIN,MISO_PIN,MOSI_PIN,CS_PIN);
digitalWrite(CS_PIN, HIGH);
}
void chipGetId()
{
digitalWrite(CS_PIN,LOW);
SPI.transfer(GET_CHIP_ID);
//receive id
for (int i = 0; i <LEN_ID; i++)
{
chipId[i] = SPI.transfer(0);
}
digitalWrite(CS_PIN,HIGH);
Serial.print("Chip id: ");
for(int i=0;i<LEN_ID; i++)
{
Serial.print(chipId[i],HEX);
}
Serial.println();
}
|
#ifndef POINT_H
#define POINT_H
class Point {
public:
unsigned int r_index;
unsigned int c_index;
Point(unsigned int _r_index = 1, unsigned int _c_index = 1);
Point getNext(Point lowest, Point highest);
friend bool operator==(const Point& lhs, const Point& rhs){
return lhs.r_index == rhs.r_index && lhs.c_index == rhs.c_index;
}
friend bool operator!=(const Point& lhs, const Point& rhs){
return lhs.r_index != rhs.r_index && lhs.c_index != rhs.c_index;
}
friend bool operator<(const Point& lhs, const Point& rhs){
if(lhs.r_index < rhs.r_index) return true;
else if(lhs.r_index == rhs.r_index && lhs.c_index < rhs.c_index) return true;
else return false;
}
};
#endif
|
/********************************
Name: Saiteja Yagni
Class: CSCI 689/1
TA Name: Anthony Schroeder
Assignment: 04
Due Date: 02/18/2016
*********************************/
#include"process_data.h"//User defined header file whic contains the function prototype for the function that is used in this source file
#include<iostream>
#include<fstream>
/**********************************************************************************************************************************************************************
FUNCTION: process_data
ARGUMENTS: ifstream &inFile,ofstream &outFile
RETURN TYPE: void
NOTES: Thhis function takes stream references as arguments, and takes input character by character from ifstream and sends it to ofstream if they aren't in comments
**********************************************************************************************************************************************************************/
void process_data(ifstream &inFile,ofstream &outFile)
{
char value;//character variable declared to process input from inFile and place it in outFile
if(inFile.is_open()&&outFile.is_open())//if both the files are open then the control statement is executed
{
while(!inFile.eof())//This loop is exected untill end of file is reached
while(inFile.get(value))//It takes character by character from inFile
{
if(value=='/')//If the character is '/' then this control statement is executed as it is the begining of comments
{
inFile.get(value);//Takes the next character fro stream
while(value=='*')//If the next character is * then the loop is executed
{
inFile.get(value);//Takes the next character from the ifstream
while(!(value=='*'&&char(inFile.peek())=='/'))//Here peek is used to fetch the next character from the buffer
{//This loop is executed if the input char and next char aren't * and / respectively,that is untill end of comment is reached
inFile.get(value);
}
inFile.get(value);
inFile.get(value);
break;
}
if(value=='/')//If the next value is / then this control statement is executed, i.e single line comment is found
{
while(value!='\n')//This loop is executed untill new line character is found, after that it exits the control statement
{
inFile.get(value);
}
}
}
if(value=='"')//If the character is " then this control statement is parsed untill the next " is found
{
outFile<<value;
inFile.get(value);
while(value!='"')
{
outFile<<value;
inFile.get(value);
}
outFile<<value;
}
else
outFile<<value;//If the character is not the one mentioned above then the value is send to outFile
}
}
}
|
#include "update_app.h"
#include <QDebug>
#include <QMessageBox>
#include "utility/encryption.h"
#include <json.hpp>
#include "utility/raii.hpp"
#include "update_widget.h"
#include "utility/file.hpp"
using json = nlohmann::json;
APP_REGISTER(update_app)
bool update_app::run()
{
auto args = this->arguments ();
if (args.size () < 2)
{
QMessageBox::information (nullptr, "更新", "启动参数错误");
error_ = true;
return false;
}
auto base64_args = args[1].toStdString ();
std::string json_args = ::base64_to_binary (base64_args);
if (json_args.empty ())
{
QMessageBox::information (nullptr, "更新", "启动参数错误 (不符合base64格式)");
error_ = true;
return false;
}
try
{
auto json_data = json::parse (json_args);
auto w = new update_widget;
connect (w, &update_widget::error, [this] { error_ = true; });
start_program_ = json_data["exec"];
w->init (::move (json_data));
w->show ();
return true;
}
catch (const std::exception&)
{
QMessageBox::information (nullptr, "更新", "启动参数错误 (不符合json格式)");
error_ = true;
return false;
}
}
void update_app::at_exit()
{
qDebug () << "123";
if (!error_)
{
::system (("start " + start_program_).data ());
}
}
|
#include <stdio.h>
void selection_sort(int arr[], int num)
{
int temp = 0;
int min_index;
for(int i = 0; i < num; i++)
{
min_index = i;
for(int j = i + 1; j < num; j++)
{
if(arr[j] < arr[min_index])
{
min_index = j;
}
}
temp = arr[i];
arr[i] = arr[min_index];
arr[min_index] = temp;
}
}
main()
{
int arr[10] = {5, 4, 3, 2, 1, 6, 7, 8, 9, 10};
selection_sort(arr, 10);
for(int i=0; i < 10; i++)
{
printf("%d ", arr[i]);
}
getchar();
}
|
#include <iostream>
using namespace std;
int main()
{
int arr[10],n,c=0,i,xc;
cout<<"Enter the number of students";
cin>>n;
cout<<"\nEnter the no. of candies each student got";
for(i=0;i<n;i++)
{
cin>>arr[i];
}
i=0;
c=arr[i];
for(i=1;i<n;i++)
{
if(arr[i]>c)
c=arr[i];
}
cout<<"\nlargest number of candies is "<<c;
cout<<"\nExtra candies left\n";
cin>>xc;
for(i=0;i<n;i++)
{
if((xc+arr[i])>=c)
cout<<"true ";
else
cout<<"false ";
}
return 0;
}
|
#ifndef INFO_HPP
#define INFO_HPP
#include "util/camera.hpp"
namespace Screen {
int W = 960;
int H = 540;
}
namespace Cam {
bool lbutton_down = false;
f32 mouse_sensitivity = 0.5f;
bool firstMouse = true;
float lastx = Screen::W / 2.0f;
float lasty = Screen::H / 2.0f;
Camera instance;
f32 movement_speed = 1.0f;
}
namespace MC {
bool toggle_wireframe = false;
bool shifting = false;
bool Superman = false;
bool pressed_cursor = false, CURSOR_ON = false;
f32 deltaTime = 0.0f;
f32 lastFrame = 0.0f;
bool resizing = false;
}
#endif
|
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <memory.h>
#include <cmath>
#include <string>
#include <cstring>
#include <queue>
#include <vector>
#include <set>
#include <deque>
#include <map>
#include <functional>
#include <numeric>
#include <sstream>
#include <complex>
#include <assert.h>
typedef long double LD;
typedef long long LL;
typedef unsigned long long ULL;
typedef unsigned int uint;
#define PI 3.1415926535897932384626433832795
#define sqr(x) ((x)*(x))
using namespace std;
const int N = 222222;
const int MAX_NEWBIE = 666;
struct Tree {
int left, right;
LL sum, add;
LL cnt;
} T[N * 4];
vector<int> g[N];
int w[N], in[N], out[N], timer, revin[N], removed[N];
int newbie[N], parent[N], lastq[N], nlist[N], nl, tn;
LL value[N];
void treeinit(int x, int l, int r) {
T[x].left = l;
T[x].right = r;
T[x].add = 0;
if (l < r) {
treeinit(x + x, l, (l + r) >> 1);
treeinit(x + x + 1, (l + r + 2) >> 1, r);
T[x].sum = T[x + x].sum + T[x + x + 1].sum;
T[x].cnt = T[x + x].cnt + T[x + x + 1].cnt;
} else {
T[x].sum = value[ revin[l] ];
T[x].cnt = 1;
}
}
void treepropogate(int x, LL add = 0) {
if (T[x].cnt == 0) return;
if (T[x].left == T[x].right) {
value[ revin[T[x].left] ] = T[x].sum + add;
return;
}
treepropogate(x + x, add + T[x].add);
treepropogate(x + x + 1, add + T[x].add);
}
void treeadd(int x, int l, int r, LL val) {
if (T[x].cnt == 0 || l > T[x].right || r < T[x].left) return;
if (l <= T[x].left && r >= T[x].right) {
T[x].add += val;
T[x].sum += val * T[x].cnt;
return;
}
treeadd(x + x, l, r, val);
treeadd(x + x + 1, l, r, val);
T[x].sum = T[x].add * T[x].cnt + T[x + x].sum + T[x + x + 1].sum;
}
void treeclear(int x, int l, int r) {
if (T[x].cnt == 0 || l > T[x].right || r < T[x].left) return;
if (l <= T[x].left && r >= T[x].right) {
T[x].add = T[x].sum = T[x].cnt = 0;
return;
}
treeclear(x + x, l, r);
treeclear(x + x + 1, l, r);
T[x].cnt = T[x + x].cnt + T[x + x + 1].cnt;
T[x].sum = T[x].add * T[x].cnt + T[x + x].sum + T[x + x + 1].sum;
}
LL treesum(int x, int l, int r, LL add = 0) {
if (T[x].cnt == 0 || l > T[x].right || r < T[x].left) return 0;
if (l <= T[x].left && r >= T[x].right) return T[x].sum + T[x].cnt * add;
return treesum(x + x, l, r, add + T[x].add) + treesum(x + x + 1, l, r, add + T[x].add);
}
int n, qtimer = 0;
void CHECK_KEY(int key) {
assert(!(key < 0 || key >= n || removed[key]));
}
void dfs(int x) {
if (removed[x]) return;
in[x] = ++timer;
revin[timer] = x;
for (int i = 0; i < (int)g[x].size(); ++i) dfs(g[x][i]);
out[x] = timer;
}
inline void rebuild(bool first = false) {
if (!first) {
for (int i = 0; i < nl; ++i) newbie[nlist[i]] = 0;
treepropogate(1);
}
timer = 0;
nl = 0;
tn = 0;
cerr << clock() << endl;
dfs(0);
cerr << clock() << endl;
tn = timer;
treeinit(1, 1, tn);
}
inline void create(int key, LL val) {
CHECK_KEY(key);
++qtimer;
int nkey = n++;
g[key].push_back(nkey);
value[nkey] = val;
nlist[nl++] = nkey;
parent[nkey] = key;
newbie[nkey] = 1;
in[nkey] = out[nkey] = 0;
}
inline void add(int key, LL val) {
CHECK_KEY(key);
++qtimer;
if (nl > MAX_NEWBIE) {
rebuild();
}
if (!newbie[key])
treeadd(1, in[key], out[key], val);
else {
value[key] += val;
lastq[key] = qtimer;
}
for (int i = 0; i < nl; ++i) {
int x = nlist[i];
if (removed[x]) continue;
if ((newbie[parent[x]] && lastq[parent[x]] == qtimer) ||
(!newbie[parent[x]] && in[key] <= in[parent[x]] && out[key] >= out[parent[x]])
)
{
lastq[x] = qtimer;
value[x] += val;
}
}
}
inline void clear(int key) {
CHECK_KEY(key);
++qtimer;
if (nl > MAX_NEWBIE) {
rebuild();
}
removed[key] = 1;
if (!newbie[key])
treeclear(1, in[key], out[key]);
else {
value[key] = 0;
lastq[key] = qtimer;
}
for (int i = 0; i < nl; ++i) {
int x = nlist[i];
if (removed[x]) continue;
if ((newbie[parent[x]] && lastq[parent[x]] == qtimer) ||
(!newbie[parent[x]] && in[key] <= in[parent[x]] && out[key] >= out[parent[x]])
)
{
lastq[x] = qtimer;
value[x] = 0;
removed[x] = 1;
}
}
}
inline LL sum(int key) {
CHECK_KEY(key);
++qtimer;
if (nl > MAX_NEWBIE) {
rebuild();
}
LL ans = 0;
if (!newbie[key])
ans += treesum(1, in[key], out[key]);
else {
ans += value[key];
lastq[key] = qtimer;
}
for (int i = 0; i < nl; ++i) {
int x = nlist[i];
if (removed[x]) continue;
if ((newbie[parent[x]] && lastq[parent[x]] == qtimer) ||
(!newbie[parent[x]] && in[key] <= in[parent[x]] && out[key] >= out[parent[x]])
)
{
lastq[x] = qtimer;
ans += value[x];
}
}
return ans;
}
int main() {
freopen(".in", "r", stdin);
// freopen(".out", "w", stdout);
scanf("%d", &n);
for (int i = 0; i < n; ++i) {
int x;
scanf("%d", &x);
value[i] = x;
}
for (int i = 1; i < n; ++i) {
int x, y;
scanf("%d%d", &x, &y);
g[x].push_back(y);
}
rebuild(true);
LL SPECIAL = 0;
int q;
scanf("%d", &q);
while (q--) {
LL key;
int t, value;
scanf("%d", &t);
switch (t) {
case 1:
scanf("%lld%d", &key, &value);
create(key + SPECIAL, value);
break;
case 2:
scanf("%lld%d", &key, &value);
add(key + SPECIAL, value);
break;
case 3:
scanf("%lld", &key);
clear(key + SPECIAL);
break;
case 4:
scanf("%lld", &key);
SPECIAL = sum(key + SPECIAL);
printf("%lld\n", SPECIAL);
// SPECIAL = 0;
break;
}
}
cerr << clock() << endl;
return 0;
}
|
#ifndef SCALARFIELD_H
#define SCALARFIELD_H
#include <stdlib.h>
// Needed to pass a function to this class when constructing the initial grid of scalars in initialise
#include <boost/function.hpp>
// This could cause problems, as uint's are popular typedefs
typedef unsigned int uint;
/**
* Construct a spacial scalar field in any dimension, with the goal of interpolating across the space using
* an appropriate interpolation scheme. This particular class uses Catmull-Rom splines formed from
* neighbouring points to the input space.
*
* This is general dimensional, but only interpolates a scalar field in that space. The dimension is
* specified on construction - this could be made a template parameter I guess, but doesn't help much
* at the moment. Obvious the return types and precision of the scalar field could be user specified.
*
* For portability reasons I've not depended on STL structures to hold the data - everything is
* stored in plain-old data chunks. The n-D scalar values are stored in m_data, which is the flattened
* array of values. The min and max values of the space is stored in m_minValue and m_maxValue, and
* the resolution is stored in m_resolution. The partition size (useful for internal computations,
* calculated from the previous values) is stored in m_partSize and m_invPartSize (the inverse).
*
* The general dimensional functionality is achieved using recursion. There are two functions: initRecurse
* and evalRecurse, which use this approach. The main API for this class is the init() with
* user specified function, max and min grid ranges in each dimension, and the resolution, which
* initialises the grid using the scalar function (calling again will clear existing data). Also the
* eval() function is the key interface, which recursively evaluates the interpolated scalar value
* using catmull-rom splines.
*
* Note that at some stage in the future it would be great to extend this as a base class and offer
* alternative interpolation techniques, such as RBF's, for comparison. Also, note that it is limited
* in that the grid is regular (required by Catmull-Rom splines).
*/
class ScalarField {
public:
/// Construct the empty scalar field with the specified dimension
ScalarField(uint _dim);
/// Destroy the scalar field
virtual ~ScalarField();
/// Initialise the grid
virtual void init(boost::function<double (double*)> _func,
double *_minValue,
double *_maxValue,
uint *_resolution);
/// Retrieve the value at the specified point location using a preferred interpolation technique
virtual double eval(double *pt);
/// For debugging, dump the entire structure as an obj file (only works if field is 2D)
void dumpObj();
protected:
/// Recursively build the n-Dimensional grid using the specified function
void initRecurse(boost::function<double (double*)> _func,
uint dim,
uint *idx,
double *pos);
/// Recursively evaluate the n-Dimensional spline using catmull rom spline interpolation
double evalRecurse(uint dim,
uint *idx,
uint *currentIdx,
double *x);
private:
/// Basic catmull Rom spline interpolation between scalars
double catmullRomSpline(double x,
double v0,
double v1,
double v2,
double v3);
/// Delete memory associated with this structure
void cleanup();
/// Store the data in a fat array
double *m_data;
/// The size, dimension and number of variables (m_var <= m_dim-1)
uint m_dim;
/// Keep track of the min, max and resolution values
double *m_minValue, *m_maxValue, *m_partSize, *m_invPartSize;
uint *m_resolution;
/// Set to true when this class is ready to be used
bool m_isInit;
};
#endif // SCALARFIELD_H
|
// Created on: 1992-11-24
// Created by: Didier PIFFAULT
// Copyright (c) 1992-1999 Matra Datavision
// Copyright (c) 1999-2014 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _Bnd_BoundSortBox_HeaderFile
#define _Bnd_BoundSortBox_HeaderFile
#include <Standard.hxx>
#include <Standard_DefineAlloc.hxx>
#include <Standard_Handle.hxx>
#include <Bnd_Box.hxx>
#include <Bnd_HArray1OfBox.hxx>
#include <Standard_Integer.hxx>
#include <TColStd_DataMapOfIntegerInteger.hxx>
#include <TColStd_ListOfInteger.hxx>
#include <Standard_Address.hxx>
class gp_Pln;
//! A tool to compare a bounding box or a plane with a set of
//! bounding boxes. It sorts the set of bounding boxes to give
//! the list of boxes which intersect the element being compared.
//! The boxes being sorted generally bound a set of shapes,
//! while the box being compared bounds a shape to be
//! compared. The resulting list of intersecting boxes therefore
//! gives the list of items which potentially intersect the shape to be compared.
class Bnd_BoundSortBox
{
public:
DEFINE_STANDARD_ALLOC
//! Constructs an empty comparison algorithm for bounding boxes.
//! The bounding boxes are then defined using the Initialize function.
Standard_EXPORT Bnd_BoundSortBox();
//! Initializes this comparison algorithm with
//! - the set of bounding boxes SetOfBox.
Standard_EXPORT void Initialize (const Bnd_Box& CompleteBox, const Handle(Bnd_HArray1OfBox)& SetOfBox);
//! Initializes this comparison algorithm with
//! - the set of bounding boxes SetOfBox, where
//! CompleteBox is given as the global bounding box of SetOfBox.
Standard_EXPORT void Initialize (const Handle(Bnd_HArray1OfBox)& SetOfBox);
//! Initializes this comparison algorithm, giving it only
//! - the maximum number nbComponents
//! of the bounding boxes to be managed. Use the Add
//! function to define the array of bounding boxes to be sorted by this algorithm.
Standard_EXPORT void Initialize (const Bnd_Box& CompleteBox, const Standard_Integer nbComponents);
//! Adds the bounding box theBox at position boxIndex in
//! the array of boxes to be sorted by this comparison algorithm.
//! This function is used only in conjunction with the third
//! syntax described in the synopsis of Initialize.
//!
//! Exceptions:
//!
//! - Standard_OutOfRange if boxIndex is not in the
//! range [ 1,nbComponents ] where
//! nbComponents is the maximum number of bounding
//! boxes declared for this comparison algorithm at
//! initialization.
//!
//! - Standard_MultiplyDefined if a box already exists at
//! position boxIndex in the array of boxes to be sorted by
//! this comparison algorithm.
Standard_EXPORT void Add (const Bnd_Box& theBox, const Standard_Integer boxIndex);
//! Compares the bounding box theBox,
//! with the set of bounding boxes to be sorted by this
//! comparison algorithm, and returns the list of intersecting
//! bounding boxes as a list of indexes on the array of
//! bounding boxes used by this algorithm.
Standard_EXPORT const TColStd_ListOfInteger& Compare (const Bnd_Box& theBox);
//! Compares the plane P
//! with the set of bounding boxes to be sorted by this
//! comparison algorithm, and returns the list of intersecting
//! bounding boxes as a list of indexes on the array of
//! bounding boxes used by this algorithm.
Standard_EXPORT const TColStd_ListOfInteger& Compare (const gp_Pln& P);
Standard_EXPORT void Dump() const;
Standard_EXPORT void Destroy();
~Bnd_BoundSortBox()
{
Destroy();
}
protected:
private:
//! Prepares BoundSortBox and sorts the boxes of
//! <SetOfBox> .
Standard_EXPORT void SortBoxes();
Bnd_Box myBox;
Handle(Bnd_HArray1OfBox) myBndComponents;
Standard_Real Xmin;
Standard_Real Ymin;
Standard_Real Zmin;
Standard_Real deltaX;
Standard_Real deltaY;
Standard_Real deltaZ;
Standard_Integer discrX;
Standard_Integer discrY;
Standard_Integer discrZ;
Standard_Integer theFound;
TColStd_DataMapOfIntegerInteger Crible;
TColStd_ListOfInteger lastResult;
Standard_Address TabBits;
};
#endif // _Bnd_BoundSortBox_HeaderFile
|
//Phoenix_RK
/*
https://leetcode.com/problems/longest-continuous-increasing-subsequence/
Given an unsorted array of integers, find the length of longest continuous increasing subsequence (subarray).
Example 1:
Input: [1,3,5,4,7]
Output: 3
Explanation: The longest continuous increasing subsequence is [1,3,5], its length is 3.
Even though [1,3,5,7] is also an increasing subsequence, it's not a continuous one where 5 and 7 are separated by 4.
Example 2:
Input: [2,2,2,2,2]
Output: 1
Explanation: The longest continuous increasing subsequence is [2], its length is 1.
Note: Length of the array will not exceed 10,000.
*/
class Solution {
public:
int findLengthOfLCIS(vector<int>& nums) {
if(nums.size()==0 || nums.size()==1)
return nums.size();
int max_len=0;
int len;
for(int i=1;i<nums.size();i++)
{
len=1;
while(i<nums.size() && nums[i]>nums[i-1])
{
i++;
len++;
}
max_len=max(len,max_len);
}
return max_len;
}
};
|
#pragma once
#include "Types.h"
#include "Renderer.h"
class Object
{
public:
std::string objectId;
Rect objectRect;
Rect objectSpriteRect;
Object();
virtual void Update();
virtual void Draw();
~Object();
};
|
/* -*- Mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* Copyright (C) Opera Software ASA 2009-2011
*
* WebGL GLSL compiler -- standalone shell.
*
*/
#include "core/pch.h"
#include "modules/webgl/src/wgl_base.h"
#include "modules/webgl/src/wgl_context.h"
#include "modules/webgl/src/wgl_lexer.h"
#include "modules/webgl/src/wgl_parser.h"
#include "modules/webgl/src/wgl_printer_stdio.h"
#include "modules/webgl/src/wgl_ast.h"
#include "modules/webgl/src/wgl_builder.h"
#include "modules/webgl/src/wgl_cgbuilder.h"
#include "modules/webgl/src/wgl_validate.h"
#include "modules/webgl/src/wgl_validator.h"
#include "modules/util/simset.h"
#include <stdio.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <signal.h>
#ifndef WIN32
# include <sys/time.h>
# include <sys/resource.h>
# include <sys/errno.h>
#endif // !WIN32
Opera* g_opera;
OpSystemInfo* g_op_system_info;
OpTimeInfo *g_op_time_info;
extern "C"
void Debug_OpAssert(const char* expression, const char* file, int line)
{
printf("ASSERT FAILED: OP_ASSERT(%s) %s:%d\n",expression, file, line);
#ifdef UNIX
raise(SIGABRT);
#else
assert(0);
#endif // UNIX
}
static OP_STATUS
read_file(uni_char *&buf, unsigned int &size, char *file_name)
{
struct stat st;
if (stat(file_name, &st) < 0)
return OpStatus::ERR;
int len = st.st_size;
buf = OP_NEWA(uni_char, (st.st_size + 1));
if (!buf)
return OpStatus::ERR_NO_MEMORY;
FILE *f = fopen(file_name, "rb");
if (!f)
{
OP_DELETEA(buf);
return OpStatus::ERR;
}
while (len > 0)
{
int l;
if ((l = fread(buf+(st.st_size - len), sizeof(unsigned char), len, f)) <= 0)
{
OP_DELETEA(buf);
fclose(f);
return OpStatus::ERR;
}
len -= l;
}
fclose(f);
make_doublebyte_in_place(buf, st.st_size-1);
size = st.st_size;
return OpStatus::OK;
}
/** Ad-hoc class holding the options supported by the standalone test
* harness. Correspondence to command-line options (and meaning)
* should be easily derivable from the names.
*/
class WGL_Standalone_Options
{
public:
WGL_Standalone_Options()
: quiet(FALSE)
, debug(FALSE)
, codegen(FALSE)
, validate(TRUE)
, show_vars(FALSE)
, have_vs(FALSE)
, have_fs(FALSE)
, vs_file("")
, fs_file("")
, out_file("")
, for_directx_version(10)
, for_gl_es(FALSE)
, for_highp(TRUE)
, support_oes(FALSE)
, for_version(100)
{
}
BOOL quiet;
BOOL debug;
BOOL codegen;
BOOL validate;
BOOL show_vars;
BOOL have_vs;
BOOL have_fs;
const char *vs_file;
const char *fs_file;
const char *out_file;
unsigned for_directx_version;
BOOL for_gl_es;
BOOL for_highp;
BOOL support_oes;
unsigned for_version;
};
class OpAutoContext
{
public:
OpAutoContext(WGL_Context *context)
: context(context)
{
}
~OpAutoContext()
{
if (context)
context->Release();
}
private:
WGL_Context *context;
};
// Returns true if the program parses and validates, otherwise false.
BOOL
ProcessSourceL(WGL_Context *context, WGL_PrettyPrinter *printer, WGL_DeclList *&shader_decls, WGL_ShaderVariables *vars, const uni_char *source, unsigned length, BOOL for_vertex, WGL_Standalone_Options &opts)
{
WGL_ProgramText vs_input[1];
vs_input[0].program_text = const_cast<uni_char *>(source);
vs_input[0].program_text_length = length;
WGL_Lexer *lexer;
WGL_Lexer::MakeL(lexer, context);
lexer->ConstructL(vs_input, ARRAY_SIZE(vs_input), for_vertex);
WGL_Error::ReportErrorsL(printer->printer, lexer->GetFirstError());
if (lexer->HaveErrors())
return FALSE;
WGL_Parser *parser;
WGL_Parser::MakeL(parser, context, lexer, for_vertex, opts.codegen);
shader_decls = parser->TopDecls();
WGL_Error::ReportErrorsL(printer->printer, parser->GetFirstError());
if (parser->HaveErrors())
return FALSE;
WGL_ValidateShader *validator;
WGL_Validator::Configuration config;
config.for_vertex = for_vertex;
config.output_format = opts.codegen ? (opts.for_directx_version == 10 ?
VEGA3D_SHADER_LANGUAGE(SHADER_HLSL_10) :
VEGA3D_SHADER_LANGUAGE(SHADER_HLSL_9))
:
(opts.for_gl_es ?
VEGA3D_SHADER_LANGUAGE(SHADER_GLSL_ES) :
VEGA3D_SHADER_LANGUAGE(SHADER_GLSL));
config.output_version = opts.for_version;
WGL_ValidateShader::MakeL(validator, context, printer->printer);
if (!validator->ValidateL(shader_decls, config))
{
WGL_Error::ReportErrorsL(printer->printer, validator->GetFirstError());
return FALSE;
}
if (vars)
{
LEAVE_IF_ERROR(context->RecordResult(for_vertex, vars));
if (opts.show_vars)
LEAVE_IF_ERROR(vars->Show(printer));
}
return TRUE;
}
int
main(int argc, char **argv)
{
Opera opera;
op_memset(&opera, 0, sizeof(Opera));
g_opera = &opera;
g_opera->InitL();
WGL_Standalone_Options opts;
int arg = 1;
unsigned files_seen = 0;
while (arg < argc)
{
if (op_strcmp(argv[arg], "-v") == 0)
opts.quiet = FALSE;
else if (op_strcmp(argv[arg], "-va") == 0 || op_strcmp(argv[arg], "--validate") == 0)
opts.validate = TRUE;
else if (op_strcmp(argv[arg], "-q") == 0)
opts.quiet = TRUE;
else if (op_strcmp(argv[arg], "-d") == 0)
opts.debug = TRUE;
else if (op_strcmp(argv[arg], "-fs") == 0 || op_strcmp(argv[arg], "--fragment-shader") == 0)
opts.have_fs = TRUE;
else if (op_strcmp(argv[arg], "-g") == 0 || op_strcmp(argv[arg], "--generate-hlsl") == 0)
opts.codegen = TRUE;
else if (op_strcmp(argv[arg], "--oes") == 0)
opts.support_oes = TRUE;
else if (op_strncmp(argv[arg], "--version-output=", 17) == 0)
{
unsigned i = op_atoi(argv[arg] + 17);
opts.for_version = i;
}
else if (op_strcmp(argv[arg], "--dx9") == 0)
opts.for_directx_version = 9;
else if (op_strcmp(argv[arg], "--dx10") == 0)
opts.for_directx_version = 10;
else if (op_strcmp(argv[arg], "--gles") == 0)
opts.for_gl_es = TRUE;
else if (op_strcmp(argv[arg], "--nohighp") == 0)
opts.for_highp = FALSE;
else if (op_strcmp(argv[arg], "-s") == 0 || op_strcmp(argv[arg], "--show-variables") == 0)
opts.show_vars = TRUE;
else if (op_strcmp(argv[arg], "-o") == 0 && (arg + 1) < argc)
{
++arg;
opts.out_file = argv[arg];
}
else if (op_strcmp(argv[arg], "-vs") == 0 || op_strcmp(argv[arg], "--vertex-shader") == 0)
opts.have_vs = TRUE;
else if (files_seen < 2)
{
if (!opts.have_vs && !(files_seen == 0 && opts.have_fs))
{
opts.vs_file = argv[arg];
opts.have_vs = TRUE;
}
else if (files_seen < 2)
{
opts.fs_file = argv[arg];
opts.have_fs = TRUE;
}
files_seen++;
}
else
{
fprintf(stderr, "Unrecognised option: %s\n", argv[arg]);
fflush(stderr);
}
arg++;
}
if (files_seen < 1)
{
printf("Usage: %s [options] vshader-file [pshader-file]\n", argv[0]);
return 1;
}
FILE *out_file;
if (*opts.out_file)
{
out_file = fopen(opts.out_file, "w");
if (!out_file)
{
fprintf(stderr, "Unable to open '%s'; exiting.\n", opts.out_file);
return 1;
}
}
else
out_file = stdout;
OpMemGroup region;
WGL_StdioPrinter *printer = OP_NEW(WGL_StdioPrinter, (out_file, opts.for_gl_es, opts.for_highp, *opts.out_file));
if (!printer)
{
if (*opts.out_file)
fclose(out_file);
return 1;
}
OpAutoPtr<WGL_StdioPrinter> anchor_printer(printer);
WGL_PrettyPrinter pretty(printer);
WGL_Context *context;
if (OpStatus::IsError(WGL_Context::Make(context, ®ion, opts.support_oes)))
return 1;
OpAutoContext anchor_context(context);
WGL_ASTBuilder builder(context);
context->SetASTBuilder(&builder);
BOOL vs_validates;
BOOL fs_validates;
WGL_DeclList *vertex_shader = NULL;
WGL_ShaderVariables vertex_vars;
if (opts.have_vs)
{
uni_char *vs_buf;
unsigned size;
if (OpStatus::IsError(read_file(vs_buf, size, const_cast<char *>(opts.vs_file))))
{
fprintf(stderr, "Error while reading '%s'; exiting.\n", opts.vs_file);
return 1;
}
TRAPD(status,
context->SetSourceContextL(opts.vs_file);
vs_validates = ProcessSourceL(context, &pretty, vertex_shader, &vertex_vars, vs_buf, size, TRUE, opts));
OP_DELETEA(vs_buf);
if (OpStatus::IsError(status))
return 1;
}
WGL_DeclList *fragment_shader = NULL;
WGL_ShaderVariables fragment_vars;
if (opts.have_fs)
{
uni_char *ps_buf;
unsigned size;
if (OpStatus::IsError(read_file(ps_buf, size, const_cast<char *>(opts.fs_file))))
{
fprintf(stderr, "Error while reading '%s'; exiting.\n", opts.fs_file);
return 1;
}
TRAPD(status,
context->SetSourceContextL(opts.fs_file);
fs_validates = ProcessSourceL(context, &pretty, fragment_shader, &fragment_vars, ps_buf, size, FALSE, opts));
OP_DELETEA(ps_buf);
if (OpStatus::IsError(status))
return 1;
}
if (opts.have_vs && vs_validates &&
opts.have_fs && fs_validates)
{
WGL_Validator::Configuration config;
TRAPD(status, WGL_Validator::ValidateLinkageL(config, &vertex_vars, &fragment_vars));
if (OpStatus::IsError(status))
return 1;
}
if (opts.debug && opts.have_vs)
{
if (!vs_validates)
{
printf("(No -d output for vertex shader (%s) - did not validate.)\n", opts.vs_file);
}
else
{
printer->OutString("// Vertex shader: ");
printer->OutString(opts.vs_file);
printer->OutNewline();
if (context->GetUsedClamp())
{
printer->OutString("int webgl_op_clamp(int x, int ma) { return (x < 0 ? 0 : (x > ma ? ma : x)); }");
printer->OutNewline();
}
vertex_shader->VisitDeclList(&pretty);
}
}
if (opts.debug && opts.have_fs)
{
if (!fs_validates)
{
printf("(No -d output for fragment shader (%s) - did not validate.)\n", opts.fs_file);
}
else
{
printer->OutString("// Fragment shader: ");
printer->OutString(opts.fs_file);
printer->OutNewline();
WGL_Validator::PrintVersionAndExtensionPrelude(printer, opts.for_version, context);
fragment_shader->VisitDeclList(&pretty);
}
}
if (opts.codegen)
{
if (opts.have_vs && !vs_validates)
{
printf("(No HLSL code generation, because the vertex shader (%s) did not validate.)\n", opts.vs_file);
goto after_codegen;
}
if (opts.have_fs && !fs_validates)
{
printf("(No HLSL code generation, because the fragment shader (%s) did not validate.)\n", opts.fs_file);
goto after_codegen;
}
WGL_ASTBuilder fragment_builder(context);
WGL_HLSLBuiltins::SemanticInfo semantic_info[] =
{ {UNI_L("g_Normal"), UNI_L("NORMAL"), WGL_HLSLBuiltins::NORMAL},
{UNI_L("g_Diffuse"), UNI_L("COLOR"), WGL_HLSLBuiltins::COLOR}
};
WGL_CgBuilder::Configuration config(opts.for_directx_version);
config.vertex_semantic_info = semantic_info;
config.vertex_semantic_info_elements = ARRAY_SIZE(semantic_info);
config.pixel_semantic_info = semantic_info;
config.pixel_semantic_info_elements = ARRAY_SIZE(semantic_info);
WGL_CgBuilder cg(&config, context, printer, &fragment_builder);
TRAPD(status,
vertex_vars.MergeWithL(&fragment_vars);
cg.GenerateCode(&vertex_vars, vertex_shader, fragment_shader));
if (OpStatus::IsError(status))
return 1;
}
after_codegen:
return 0;
}
|
#pragma once
#include <QtWidgets/QWidget>
#include "ui_Xplay.h"
class Xplay : public QWidget
{
Q_OBJECT
public:
Xplay(QWidget *parent = Q_NULLPTR);
~Xplay();
// 定时器 刷新滑动条
void timerEvent(QTimerEvent* e) override;
// 窗口尺寸变化
void resizeEvent(QResizeEvent* e) override;
// 双击全屏
void mouseDoubleClickEvent(QMouseEvent* e) override;
// 暂停
void SetPause(bool isPause);
public slots:
void OpenFile();
void PlayOrPause();
void SliderPress();
void SliderRelease();
private:
Ui::XplayClass ui {};
bool isSliderPress = false;
};
|
#include "Student.h"
Student::Student()
{
}
Student::~Student()
{
}
//Input Student's Information from keyboard
void Student::Input() {
cout << "Fullname: ";
cin.get(sName, 31, '/n');
cout << "Gender(0: male, 1: female): ";
cin >> Gender;
}
//Split Fullname into First name and Last name
void Student::splitName(char* firstName, char* lastName) {
int i = 0;
while (sName[i] != ' ') {
lastName[i] = sName[i];
++i;
}
int label = 0;
while (sName[i] != '/n') {
if (sName[i] == ' ')
label = i + 1;
++i;
}
int j = 0;
while (sName[label] != '/n') {
lastName[j] = sName[label];
++j;
++label;
}
}
//Find Student's Class
int Student::ID_toClass() {
return ID / 100000;
}
//Transfering Mark to GPA
char Student::Mark_toGPA() {
if (fMark <= 1.0)
return 'F';
else if (fMark > 1.0 && fMark <= 3.0)
return 'E';
else if (fMark > 3.0 && fMark <= 5.0)
return 'D';
else if (fMark > 5.0 && fMark <= 7.0)
return 'C';
else if (fMark > 7.0 && fMark <= 8.5)
return 'B';
else
return 'A';
}
//Save Student's Information to a file
bool Student::saveFile(char* filePath) {
ofstream fout;
fout.open(filePath);
if (!fout.is_open()) {
cout << "Cannot open file to write" << endl;
return false;
}
fout << "<Student>" << endl;
char firstName[6], lastName[6];
splitName(firstName, lastName);
fout << " <First name>" << firstName << "</First name" << endl;
fout << " <Last name>" << lastName << "</Last name" << endl;
fout << " <Class>" << ID_toClass() << "</Class>" << endl;
if (Gender == 0)
fout << " <Gender>Female</Gender" << endl;
else
fout << " <Gender>Male</Gender" << endl;
fout << " <Address>" << sAddress << "/Address" << endl;
fout << " <Mark>" << fMark << "/Mark" << endl;
fout << " <GPA>" << Mark_toGPA() << "/GPA" << endl;
fout << "</Student>" << endl;
fout.close();
return true;
}
//Comparing mark of 2 students
int Student::compareMark(Student B) {
if (this->fMark > B.fMark)
return 1;
else
return -1;
}
|
/* -*- Mode: c++; tab-width: 4; c-basic-offset: 4 -*-
* Copyright Opera Software 2007, do not distribute.
*/
#define ENABLE_OP_KEY_F1 YES
#define ENABLE_OP_KEY_F2 YES
#define ENABLE_OP_KEY_F3 YES
#define ENABLE_OP_KEY_F4 YES
#define ENABLE_OP_KEY_F5 YES
#define ENABLE_OP_KEY_F6 YES
#define ENABLE_OP_KEY_F7 YES
#define ENABLE_OP_KEY_F8 YES
#define ENABLE_OP_KEY_F9 YES
#define ENABLE_OP_KEY_F10 YES
#define ENABLE_OP_KEY_F11 YES
#define ENABLE_OP_KEY_F12 YES
#if defined(_UNIX_DESKTOP_)
#define ENABLE_OP_KEY_F13 YES
#define ENABLE_OP_KEY_F14 YES
#define ENABLE_OP_KEY_F15 YES
#define ENABLE_OP_KEY_F16 YES
#define ENABLE_OP_KEY_F17 YES
#define ENABLE_OP_KEY_F18 YES
#define ENABLE_OP_KEY_F19 YES
#define ENABLE_OP_KEY_F20 YES
#define ENABLE_OP_KEY_F21 YES
#define ENABLE_OP_KEY_F22 YES
#define ENABLE_OP_KEY_F23 YES
#define ENABLE_OP_KEY_F24 YES
#define ENABLE_OP_KEY_F25 YES
#define ENABLE_OP_KEY_F26 YES
#define ENABLE_OP_KEY_F27 YES
#define ENABLE_OP_KEY_F28 YES
#define ENABLE_OP_KEY_F29 YES
#define ENABLE_OP_KEY_F30 YES
#define ENABLE_OP_KEY_F31 YES
#define ENABLE_OP_KEY_F32 YES
#define ENABLE_OP_KEY_F33 YES
#define ENABLE_OP_KEY_F34 YES
#define ENABLE_OP_KEY_F35 YES
#define ENABLE_OP_KEY_F36 YES
#else
#define ENABLE_OP_KEY_F13 NO
#define ENABLE_OP_KEY_F14 NO
#define ENABLE_OP_KEY_F15 NO
#define ENABLE_OP_KEY_F16 NO
#define ENABLE_OP_KEY_F17 NO
#define ENABLE_OP_KEY_F18 NO
#define ENABLE_OP_KEY_F19 NO
#define ENABLE_OP_KEY_F20 NO
#define ENABLE_OP_KEY_F21 NO
#define ENABLE_OP_KEY_F22 NO
#define ENABLE_OP_KEY_F23 NO
#define ENABLE_OP_KEY_F24 NO
#define ENABLE_OP_KEY_F25 NO
#define ENABLE_OP_KEY_F26 NO
#define ENABLE_OP_KEY_F27 NO
#define ENABLE_OP_KEY_F28 NO
#define ENABLE_OP_KEY_F29 NO
#define ENABLE_OP_KEY_F30 NO
#define ENABLE_OP_KEY_F31 NO
#define ENABLE_OP_KEY_F32 NO
#define ENABLE_OP_KEY_F33 NO
#define ENABLE_OP_KEY_F34 NO
#define ENABLE_OP_KEY_F35 NO
#define ENABLE_OP_KEY_F36 NO
#endif
#define ENABLE_OP_KEY_HOME YES
#define ENABLE_OP_KEY_END YES
#define ENABLE_OP_KEY_PAGEUP YES
#define ENABLE_OP_KEY_PAGEDOWN YES
#define ENABLE_OP_KEY_UP YES
#define ENABLE_OP_KEY_DOWN YES
#define ENABLE_OP_KEY_LEFT YES
#define ENABLE_OP_KEY_RIGHT YES
#define ENABLE_OP_KEY_ESC YES
#define ENABLE_OP_KEY_OEM_1 YES
#define ENABLE_OP_KEY_OEM_PLUS YES
#define ENABLE_OP_KEY_OEM_COMMA YES
#define ENABLE_OP_KEY_OEM_MINUS YES
#define ENABLE_OP_KEY_OEM_PERIOD YES
#define ENABLE_OP_KEY_OEM_2 YES
#define ENABLE_OP_KEY_OEM_3 YES
#define ENABLE_OP_KEY_OEM_4 YES
#define ENABLE_OP_KEY_OEM_5 YES
#define ENABLE_OP_KEY_OEM_6 YES
#define ENABLE_OP_KEY_OEM_7 YES
#define ENABLE_OP_KEY_OEM_8 YES
#define ENABLE_OP_KEY_OEM_102 YES
#define ENABLE_OP_KEY_PROCESSKEY YES
#define ENABLE_OP_KEY_UNICODE YES
#define ENABLE_OP_KEY_NUMPAD0 YES
#define ENABLE_OP_KEY_NUMPAD1 YES
#define ENABLE_OP_KEY_NUMPAD2 YES
#define ENABLE_OP_KEY_NUMPAD3 YES
#define ENABLE_OP_KEY_NUMPAD4 YES
#define ENABLE_OP_KEY_NUMPAD5 YES
#define ENABLE_OP_KEY_NUMPAD6 YES
#define ENABLE_OP_KEY_NUMPAD7 YES
#define ENABLE_OP_KEY_NUMPAD8 YES
#define ENABLE_OP_KEY_NUMPAD9 YES
#define ENABLE_OP_KEY_CANCEL YES
#define ENABLE_OP_KEY_CLEAR YES
#define ENABLE_OP_KEY_KANA YES
#define ENABLE_OP_KEY_FINAL YES
#define ENABLE_OP_KEY_KANJI YES
#define ENABLE_OP_KEY_ESCAPE YES
#define ENABLE_OP_KEY_CONVERT YES
#define ENABLE_OP_KEY_NONCONVERT YES
#define ENABLE_OP_KEY_ACCEPT YES
#define ENABLE_OP_KEY_MODECHANGE YES
#define ENABLE_OP_KEY_PRINT YES
#define ENABLE_OP_KEY_EXECUTE YES
#define ENABLE_OP_KEY_HELP YES
#define ENABLE_OP_KEY_WINDOW YES
#define ENABLE_OP_KEY_SLEEP YES
#define ENABLE_OP_KEY_DIVIDE YES
#define ENABLE_OP_KEY_MULTIPLY YES
#define ENABLE_OP_KEY_ADD YES
#define ENABLE_OP_KEY_SEPARATOR YES
#define ENABLE_OP_KEY_SUBTRACT YES
#define ENABLE_OP_KEY_DECIMAL YES
#define ENABLE_OP_KEY_INSERT YES
#define ENABLE_OP_KEY_DELETE YES
#define ENABLE_OP_KEY_BACKSPACE YES
#define ENABLE_OP_KEY_TAB YES
#define ENABLE_OP_KEY_SPACE YES
#define ENABLE_OP_KEY_ENTER YES
#define ENABLE_OP_KEY_ALT YES
#define ENABLE_OP_KEY_LEFT_ALT YES
#define ENABLE_OP_KEY_RIGHT_ALT YES
#define ENABLE_OP_KEY_SHIFT YES
#define ENABLE_OP_KEY_LEFT_SHIFT YES
#define ENABLE_OP_KEY_RIGHT_SHIFT YES
#define ENABLE_OP_KEY_CTRL YES
#define ENABLE_OP_KEY_LEFT_CONTROL YES
#define ENABLE_OP_KEY_RIGHT_CONTROL YES
#define ENABLE_OP_KEY_META YES
#define ENABLE_OP_KEY_CAPS_LOCK YES
#define ENABLE_OP_KEY_NUM_LOCK YES
#define ENABLE_OP_KEY_SCROLL_LOCK YES
#define ENABLE_OP_KEY_PAUSE YES
#define ENABLE_OP_KEY_PRINTSCREEN YES
#define ENABLE_OP_KEY_CONTEXT_MENU YES
#define ENABLE_OP_KEY_NORTH NO
#define ENABLE_OP_KEY_NORTH_EAST NO
#define ENABLE_OP_KEY_EAST NO
#define ENABLE_OP_KEY_SOUTH_EAST NO
#define ENABLE_OP_KEY_SOUTH NO
#define ENABLE_OP_KEY_SOUTH_WEST NO
#define ENABLE_OP_KEY_WEST NO
#define ENABLE_OP_KEY_NORTH_WEST NO
#define ENABLE_OP_KEY_OK NO
#define ENABLE_OP_KEY_RED NO
#define ENABLE_OP_KEY_GREEN NO
#define ENABLE_OP_KEY_BLUE NO
#define ENABLE_OP_KEY_YELLOW NO
#define ENABLE_OP_KEY_PURPLE NO
#define ENABLE_OP_KEY_PLAY NO
#define ENABLE_OP_KEY_PAUSE_RC NO
#define ENABLE_OP_KEY_STOP NO
#define ENABLE_OP_KEY_REWIND NO
#define ENABLE_OP_KEY_FASTFORWARD NO
#define ENABLE_OP_KEY_RECORD NO
#define ENABLE_OP_KEY_EXIT NO
#define ENABLE_OP_KEY_BYPASS NO
#define ENABLE_OP_KEY_VOLUMEUP NO
#define ENABLE_OP_KEY_VOLUMEDOWN NO
#define ENABLE_OP_KEY_CHANNELDOWN NO
#define ENABLE_OP_KEY_CHANNELUP NO
#define ENABLE_OP_KEY_FAVOURITE NO
#define ENABLE_OP_KEY_GUIDE NO
#define ENABLE_OP_KEY_INFO NO
#define ENABLE_OP_KEY_LAST_CHANNEL NO
#define ENABLE_OP_KEY_MUTE NO
#define ENABLE_OP_KEY_POWER NO
#define ENABLE_OP_KEY_SETTINGS NO
#define ENABLE_OP_KEY_MENU NO
#define ENABLE_OP_KEY_NEXT NO
#define ENABLE_OP_KEY_PREVIOUS NO
#define ENABLE_OP_KEY_PAYPERVIEW NO
#define ENABLE_OP_KEY_MOUSE_BUTTON_1 YES
#define ENABLE_OP_KEY_MOUSE_BUTTON_2 YES
#define ENABLE_OP_KEY_MOUSE_BUTTON_3 YES
#define ENABLE_OP_KEY_MOUSE_BUTTON_4 YES
#define ENABLE_OP_KEY_MOUSE_BUTTON_5 YES
#define ENABLE_OP_KEY_MOUSE_BUTTON_6 YES
#define ENABLE_OP_KEY_MOUSE_BUTTON_7 YES
#define ENABLE_OP_KEY_MOUSE_BUTTON_8 YES
#define ENABLE_OP_KEY_MOUSE_BUTTON_9 YES
#define ENABLE_OP_KEY_GESTURE_UP YES
#define ENABLE_OP_KEY_GESTURE_RIGHT YES
#define ENABLE_OP_KEY_GESTURE_DOWN YES
#define ENABLE_OP_KEY_GESTURE_LEFT YES
#define ENABLE_OP_KEY_GESTURE_UP_LEFT YES
#define ENABLE_OP_KEY_GESTURE_UP_RIGHT YES
#define ENABLE_OP_KEY_GESTURE_DOWN_LEFT YES
#define ENABLE_OP_KEY_GESTURE_DOWN_RIGHT YES
#define ENABLE_OP_KEY_FLIP_BACK YES
#define ENABLE_OP_KEY_FLIP_FORWARD YES
#define ENABLE_OP_KEY_KEYPAD_SIDE NO
#define ENABLE_OP_KEY_KEYPAD_SOFT1 NO
#define ENABLE_OP_KEY_KEYPAD_SOFT2 NO
#define ENABLE_OP_KEY_KEYPAD_SEND NO
#define ENABLE_OP_KEY_KEYPAD_END NO
#define ENABLE_OP_KEY_KEYPAD_BROWSER NO
#define ENABLE_OP_KEY_KEYPAD_MAIL NO
#define ENABLE_OP_KEY_KEYPAD_PAGEUP NO
#define ENABLE_OP_KEY_KEYPAD_PAGEDOWN NO
#define ENABLE_OP_KEY_KEYPAD_UP NO
#define ENABLE_OP_KEY_KEYPAD_DOWN NO
#define ENABLE_OP_KEY_KEYPAD_LEFT NO
#define ENABLE_OP_KEY_KEYPAD_RIGHT NO
#define ENABLE_OP_KEY_KEYPAD_OK NO
#define ENABLE_OP_KEY_KEYPAD_CLEAR NO
#define ENABLE_OP_KEY_KEYPAD_1 NO
#define ENABLE_OP_KEY_KEYPAD_2 NO
#define ENABLE_OP_KEY_KEYPAD_3 NO
#define ENABLE_OP_KEY_KEYPAD_4 NO
#define ENABLE_OP_KEY_KEYPAD_5 NO
#define ENABLE_OP_KEY_KEYPAD_6 NO
#define ENABLE_OP_KEY_KEYPAD_7 NO
#define ENABLE_OP_KEY_KEYPAD_8 NO
#define ENABLE_OP_KEY_KEYPAD_9 NO
#define ENABLE_OP_KEY_KEYPAD_0 NO
#define ENABLE_OP_KEY_KEYPAD_STAR NO
#define ENABLE_OP_KEY_KEYPAD_HASH NO
#define ENABLE_OP_KEY_MAC_CTRL NO
#define ENABLE_OP_KEY_GP_ANALOG_NORTH NO
#define ENABLE_OP_KEY_GP_ANALOG_SOUTH NO
#define ENABLE_OP_KEY_GP_ANALOG_WEST NO
#define ENABLE_OP_KEY_GP_ANALOG_EAST NO
#define ENABLE_OP_KEY_GP_DIGITAL_NORTH NO
#define ENABLE_OP_KEY_GP_DIGITAL_SOUTH NO
#define ENABLE_OP_KEY_GP_DIGITAL_WEST NO
#define ENABLE_OP_KEY_GP_DIGITAL_EAST NO
#define ENABLE_OP_KEY_GP_A NO
#define ENABLE_OP_KEY_GP_B NO
#define ENABLE_OP_KEY_GP_C_NORTH NO
#define ENABLE_OP_KEY_GP_C_SOUTH NO
#define ENABLE_OP_KEY_GP_C_WEST NO
#define ENABLE_OP_KEY_GP_C_EAST NO
#define ENABLE_OP_KEY_GP_L NO
#define ENABLE_OP_KEY_GP_R NO
#define ENABLE_OP_KEY_GP_X NO
#define ENABLE_OP_KEY_GP_Y NO
#define ENABLE_OP_KEY_GP_Z NO
#define ENABLE_OP_KEY_GP_START NO
#define ENABLE_OP_KEY_REDO YES
#define ENABLE_OP_KEY_UNDO YES
#define ENABLE_OP_KEY_PROPERITES YES
#define ENABLE_OP_KEY_FRONT YES
#define ENABLE_OP_KEY_MAGIC_INPUT_1 NO
#define ENABLE_OP_KEY_MAGIC_INPUT_2 NO
#define ENABLE_OP_KEY_MAGIC_INPUT_3 NO
#define ENABLE_OP_KEY_MAGIC_INPUT_4 NO
#define ENABLE_OP_KEY_MAGIC_INPUT_5 NO
#define ENABLE_OP_KEY_MAGIC_INPUT_6 NO
#define ENABLE_OP_KEY_MAGIC_INPUT_7 NO
#define ENABLE_OP_KEY_MAGIC_INPUT_8 NO
#define ENABLE_OP_KEY_MAGIC_INPUT_9 NO
#define ENABLE_OP_KEY_MAGIC_INPUT_10 NO
# define ENABLE_OP_KEY_SELECT YES
# define ENABLE_OP_KEY_BACK NO
# define ENABLE_OP_KEY_CONTEXT1 NO
# define ENABLE_OP_KEY_CONTEXT2 NO
# define ENABLE_OP_KEY_CONTEXT3 NO
# define ENABLE_OP_KEY_CONTEXT4 NO
# define ENABLE_OP_KEY_YES NO
# define ENABLE_OP_KEY_NO NO
# define ENABLE_OP_KEY_CALL NO
# define ENABLE_OP_KEY_HANGUP NO
# define ENABLE_OP_KEY_MAC_CTRL_LEFT NO
# define ENABLE_OP_KEY_MAC_CTRL_RIGHT NO
# define ENABLE_OP_KEY_SWIPE_DOWN NO
# define ENABLE_OP_KEY_SWIPE_LEFT NO
# define ENABLE_OP_KEY_SWIPE_RIGHT NO
# define ENABLE_OP_KEY_SWIPE_UP NO
# define ENABLE_OP_KEY_LEFT_TAB YES
#define ENABLE_OP_KEY_XF86XK_MON_BRIGHTNESS_UP YES
#define ENABLE_OP_KEY_XF86XK_MON_BRIGHTNESS_DOWN YES
#define ENABLE_OP_KEY_XF86XK_KBD_LIGHT_ON_OFF YES
#define ENABLE_OP_KEY_XF86XK_KBD_BRIGHTNESS_UP YES
#define ENABLE_OP_KEY_XF86XK_KBD_BRIGHTNESS_DOWN YES
#define ENABLE_OP_KEY_XF86XK_STANDBY YES
#define ENABLE_OP_KEY_XF86XK_AUDIO_LOWER_VOLUME YES
#define ENABLE_OP_KEY_XF86XK_AUDIO_MUTE YES
#define ENABLE_OP_KEY_XF86XK_AUDIO_RAISE_VOLUME YES
#define ENABLE_OP_KEY_XF86XK_AUDIO_PLAY YES
#define ENABLE_OP_KEY_XF86XK_AUDIO_STOP YES
#define ENABLE_OP_KEY_XF86XK_AUDIO_PREV YES
#define ENABLE_OP_KEY_XF86XK_AUDIO_NEXT YES
#define ENABLE_OP_KEY_XF86XK_HOME_PAGE YES
#define ENABLE_OP_KEY_XF86XK_MAIL YES
#define ENABLE_OP_KEY_XF86XK_START YES
#define ENABLE_OP_KEY_XF86XK_SEARCH YES
#define ENABLE_OP_KEY_XF86XK_AUDIO_RECORD YES
#define ENABLE_OP_KEY_XF86XK_CALCULATOR YES
#define ENABLE_OP_KEY_XF86XK_MEMO YES
#define ENABLE_OP_KEY_XF86XK_TO_DO_LIST YES
#define ENABLE_OP_KEY_XF86XK_CALENDAR YES
#define ENABLE_OP_KEY_XF86XK_POWER_DOWN YES
#define ENABLE_OP_KEY_XF86XK_CONTRAST_ADJUST YES
#define ENABLE_OP_KEY_XF86XK_ROCKER_UP YES
#define ENABLE_OP_KEY_XF86XK_ROCKER_DOWN YES
#define ENABLE_OP_KEY_XF86XK_ROCKER_ENTER YES
#define ENABLE_OP_KEY_XF86XK_BACK YES
#define ENABLE_OP_KEY_XF86XK_FORWARD YES
#define ENABLE_OP_KEY_XF86XK_STOP YES
#define ENABLE_OP_KEY_XF86XK_REFRESH YES
#define ENABLE_OP_KEY_XF86XK_POWER_OFF YES
#define ENABLE_OP_KEY_XF86XK_WAKE_UP YES
#define ENABLE_OP_KEY_XF86XK_EJECT YES
#define ENABLE_OP_KEY_XF86XK_SCREEN_SAVER YES
#define ENABLE_OP_KEY_XF86XK_WWW YES
#define ENABLE_OP_KEY_XF86XK_FAVORITES YES
#define ENABLE_OP_KEY_XF86XK_AUDIO_PAUSE YES
#define ENABLE_OP_KEY_XF86XK_AUDIO_MEDIA YES
#define ENABLE_OP_KEY_XF86XK_MY_COMPUTER YES
#define ENABLE_OP_KEY_XF86XK_VENDOR_HOME YES
#define ENABLE_OP_KEY_XF86XK_LIGHT_BULB YES
#define ENABLE_OP_KEY_XF86XK_SHOP YES
#define ENABLE_OP_KEY_XF86XK_HISTORY YES
#define ENABLE_OP_KEY_XF86XK_OPEN_URL YES
#define ENABLE_OP_KEY_XF86XK_ADD_FAVORITE YES
#define ENABLE_OP_KEY_XF86XK_HOT_LINKS YES
#define ENABLE_OP_KEY_XF86XK_BRIGHTNESS_ADJUST YES
#define ENABLE_OP_KEY_XF86XK_FINANCE YES
#define ENABLE_OP_KEY_XF86XK_COMMUNITY YES
#define ENABLE_OP_KEY_XF86XK_AUDIO_REWIND YES
#define ENABLE_OP_KEY_XF86XK_BACK_FORWARD YES
#define ENABLE_OP_KEY_XF86XK_LAUNCH0 YES
#define ENABLE_OP_KEY_XF86XK_LAUNCH1 YES
#define ENABLE_OP_KEY_XF86XK_LAUNCH2 YES
#define ENABLE_OP_KEY_XF86XK_LAUNCH3 YES
#define ENABLE_OP_KEY_XF86XK_LAUNCH4 YES
#define ENABLE_OP_KEY_XF86XK_LAUNCH5 YES
#define ENABLE_OP_KEY_XF86XK_LAUNCH6 YES
#define ENABLE_OP_KEY_XF86XK_LAUNCH7 YES
#define ENABLE_OP_KEY_XF86XK_LAUNCH8 YES
#define ENABLE_OP_KEY_XF86XK_LAUNCH9 YES
#define ENABLE_OP_KEY_XF86XK_LAUNCH_A YES
#define ENABLE_OP_KEY_XF86XK_LAUNCH_B YES
#define ENABLE_OP_KEY_XF86XK_LAUNCH_C YES
#define ENABLE_OP_KEY_XF86XK_LAUNCH_D YES
#define ENABLE_OP_KEY_XF86XK_LAUNCH_E YES
#define ENABLE_OP_KEY_XF86XK_LAUNCH_F YES
#define ENABLE_OP_KEY_XF86XK_APPLICATION_LEFT YES
#define ENABLE_OP_KEY_XF86XK_APPLICATION_RIGHT YES
#define ENABLE_OP_KEY_XF86XK_BOOK YES
#define ENABLE_OP_KEY_XF86XK_CD YES
#define ENABLE_OP_KEY_XF86XK_CLOSE YES
#define ENABLE_OP_KEY_XF86XK_COPY YES
#define ENABLE_OP_KEY_XF86XK_CUT YES
#define ENABLE_OP_KEY_XF86XK_DISPLAY YES
#define ENABLE_OP_KEY_XF86XK_DOS YES
#define ENABLE_OP_KEY_XF86XK_DOCUMENTS YES
#define ENABLE_OP_KEY_XF86XK_EXCEL YES
#define ENABLE_OP_KEY_XF86XK_EXPLORER YES
#define ENABLE_OP_KEY_XF86XK_GAME YES
#define ENABLE_OP_KEY_XF86XK_GO YES
#define ENABLE_OP_KEY_XF86XK_I_TOUCH YES
#define ENABLE_OP_KEY_XF86XK_LOG_OFF YES
#define ENABLE_OP_KEY_XF86XK_MARKET YES
#define ENABLE_OP_KEY_XF86XK_MEETING YES
#define ENABLE_OP_KEY_XF86XK_MENU_KB YES
#define ENABLE_OP_KEY_XF86XK_MENU_PB YES
#define ENABLE_OP_KEY_XF86XK_MY_SITES YES
#define ENABLE_OP_KEY_XF86XK_NEW YES
#define ENABLE_OP_KEY_XF86XK_NEWS YES
#define ENABLE_OP_KEY_XF86XK_OFFICE_HOME YES
#define ENABLE_OP_KEY_XF86XK_OPEN YES
#define ENABLE_OP_KEY_XF86XK_OPTION YES
#define ENABLE_OP_KEY_XF86XK_PASTE YES
#define ENABLE_OP_KEY_XF86XK_PHONE YES
#define ENABLE_OP_KEY_XF86XK_REPLY YES
#define ENABLE_OP_KEY_XF86XK_RELOAD YES
#define ENABLE_OP_KEY_XF86XK_ROTATE_WINDOWS YES
#define ENABLE_OP_KEY_XF86XK_ROTATION_PB YES
#define ENABLE_OP_KEY_XF86XK_ROTATION_KB YES
#define ENABLE_OP_KEY_XF86XK_SAVE YES
#define ENABLE_OP_KEY_XF86XK_SCROLL_UP YES
#define ENABLE_OP_KEY_XF86XK_SCROLL_DOWN YES
#define ENABLE_OP_KEY_XF86XK_SCROLL_CLICK YES
#define ENABLE_OP_KEY_XF86XK_SEND YES
#define ENABLE_OP_KEY_XF86XK_SPELL YES
#define ENABLE_OP_KEY_XF86XK_SPLIT_SCREEN YES
#define ENABLE_OP_KEY_XF86XK_SUPPORT YES
#define ENABLE_OP_KEY_XF86XK_TASK_PANE YES
#define ENABLE_OP_KEY_XF86XK_TERMINAL YES
#define ENABLE_OP_KEY_XF86XK_TOOLS YES
#define ENABLE_OP_KEY_XF86XK_TRAVEL YES
#define ENABLE_OP_KEY_XF86XK_USER_PB YES
#define ENABLE_OP_KEY_XF86XK_USER1KB YES
#define ENABLE_OP_KEY_XF86XK_USER2KB YES
#define ENABLE_OP_KEY_XF86XK_VIDEO YES
#define ENABLE_OP_KEY_XF86XK_WHEEL_BUTTON YES
#define ENABLE_OP_KEY_XF86XK_WORD YES
#define ENABLE_OP_KEY_XF86XK_XFER YES
#define ENABLE_OP_KEY_XF86XK_ZOOM_IN YES
#define ENABLE_OP_KEY_XF86XK_ZOOM_OUT YES
#define ENABLE_OP_KEY_XF86XK_AWAY YES
#define ENABLE_OP_KEY_XF86XK_MESSENGER YES
#define ENABLE_OP_KEY_XF86XK_WEB_CAM YES
#define ENABLE_OP_KEY_XF86XK_MAIL_FORWARD YES
#define ENABLE_OP_KEY_XF86XK_PICTURES YES
#define ENABLE_OP_KEY_XF86XK_MUSIC YES
#define ENABLE_OP_KEY_XF86XK_BATTERY YES
#define ENABLE_OP_KEY_XF86XK_BLUETOOTH YES
#define ENABLE_OP_KEY_XF86XK_WLAN YES
#define ENABLE_OP_KEY_XF86XK_UWB YES
#define ENABLE_OP_KEY_XF86XK_AUDIO_FORWARD YES
#define ENABLE_OP_KEY_XF86XK_AUDIO_REPEAT YES
#define ENABLE_OP_KEY_XF86XK_AUDIO_RANDOM_PLAY YES
#define ENABLE_OP_KEY_XF86XK_SUBTITLE YES
#define ENABLE_OP_KEY_XF86XK_AUDIO_CYCLE_TRACK YES
#define ENABLE_OP_KEY_XF86XK_CYCLE_ANGLE YES
#define ENABLE_OP_KEY_XF86XK_FRAME_BACK YES
#define ENABLE_OP_KEY_XF86XK_FRAME_FORWARD YES
#define ENABLE_OP_KEY_XF86XK_TIME YES
#define ENABLE_OP_KEY_XF86XK_VIEW YES
#define ENABLE_OP_KEY_XF86XK_TOP_MENU YES
#define ENABLE_OP_KEY_XF86XK_RED YES
#define ENABLE_OP_KEY_XF86XK_GREEN YES
#define ENABLE_OP_KEY_XF86XK_YELLOW YES
#define ENABLE_OP_KEY_XF86XK_BLUE YES
#define ENABLE_OP_KEY_XF86XK_SUSPEND YES
#define ENABLE_OP_KEY_XF86XK_HIBERNATE YES
#define ENABLE_OP_KEY_HK_TOGGLE YES
#define ENABLE_OP_KEY_KATAKANA YES
#define ENABLE_OP_KEY_HIRAGANA YES
|
#pragma once
#include <unordered_map>
#include <list>
template <typename K, typename V> class LRUCache {
private:
using iterator = typename std::unordered_map<K, V>::iterator;
size_t _capacity;
std::unordered_map<K, V> _kv;
std::unordered_map<K, typename std::list<K>::iterator> _ki;
std::list<K> _kl;
public:
explicit LRUCache(size_t capacity) { _capacity = capacity; }
iterator get(K key) {
auto it = _kv.find(key);
if (it == _kv.end())
return it;
auto ki = _ki.find(key);
_kl.splice(_kl.begin(), _kl, ki->second);
return it;
}
void put(K key, V value) {
if (_kv.find(key) != _kv.end()) {
_kv[key] = value;
auto ki = _ki.find(key);
_kl.splice(_kl.begin(), _kl, ki->second);
return;
}
_kv[key] = value;
_kl.emplace_front(key);
_ki[key] = _kl.begin();
if (_kv.size() > _capacity) {
_kv.erase(_kl.back());
_ki.erase(_kl.back());
_kl.pop_back();
}
}
};
|
// Created on: 2004-11-24
// Created by: Edward AGAPOV
// Copyright (c) 2004-2014 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
// The original implementation Copyright: (C) RINA S.p.A
#ifndef XmlTObjDrivers_ObjectDriver_HeaderFile
#define XmlTObjDrivers_ObjectDriver_HeaderFile
#include <TObj_Common.hxx>
#include <XmlMDF_ADriver.hxx>
class XmlTObjDrivers_ObjectDriver : public XmlMDF_ADriver
{
public:
Standard_EXPORT XmlTObjDrivers_ObjectDriver
(const Handle(Message_Messenger)& theMessageDriver);
// constructor
Standard_EXPORT Handle(TDF_Attribute) NewEmpty() const Standard_OVERRIDE;
// Creates a new attribute
Standard_EXPORT Standard_Boolean Paste
(const XmlObjMgt_Persistent& Source,
const Handle(TDF_Attribute)& Target,
XmlObjMgt_RRelocationTable& RelocTable) const Standard_OVERRIDE;
// Translate the contents of <aSource> and put it
// into <aTarget>, using the relocation table
// <aRelocTable> to keep the sharings.
// an TObj_Object is restored by TObj_Persistence basing on class name
// stored in Source
Standard_EXPORT void Paste
(const Handle(TDF_Attribute)& Source,
XmlObjMgt_Persistent& Target,
XmlObjMgt_SRelocationTable& RelocTable) const Standard_OVERRIDE;
// Translate the contents of <aSource> and put it
// into <aTarget>, using the relocation table
// <aRelocTable> to keep the sharings.
// anObject is stored as a Name of class derived from TObj_Object
public:
// CASCADE RTTI
DEFINE_STANDARD_RTTIEXT(XmlTObjDrivers_ObjectDriver,XmlMDF_ADriver)
};
// Define handle class
DEFINE_STANDARD_HANDLE(XmlTObjDrivers_ObjectDriver,XmlMDF_ADriver)
#endif
#ifdef _MSC_VER
#pragma once
#endif
|
#include "Camera.h"
Camera::Camera(float xRotation, float yRotation, float zRotation, const Vertex& position)
{
_xRot = xRotation;
_yRot = yRotation;
_zRot = zRotation;
_position = position;
}
Camera::Camera()
{
_xRot = 0;
_yRot = 0;
_zRot = 0;
_position = Vertex(0, 0, -50);
}
float Camera::GetXRotation() const
{
return _xRot;
}
void Camera::SetXRotation(const float x)
{
_xRot = x;
}
float Camera::GetYRotation() const
{
return _yRot;
}
void Camera::SetYRotation(const float y)
{
_yRot = y;
}
void Camera::SetZRotation(const float z)
{
_zRot = z;
}
Vertex Camera::GetPosition() const
{
return _position;
}
void Camera::SetPosition(const Vertex p)
{
_position = p;
}
Matrix Camera::GetCameraMatrix() const
{
float convert = (3.14159265359f / 180.0f);
float xRadians = _xRot * convert;
float yRadians = _yRot * convert;
float zRadians = _zRot * convert;
Matrix xRotation
{
1, 0, 0, 0,
0, static_cast<float>(cos(xRadians)), static_cast<float>(sin(xRadians)),0,
0,static_cast<float>(-sin(xRadians)), static_cast<float>(cos(xRadians)),0,
0,0,0,1
};
Matrix yRotation
{
static_cast<float>(cos(yRadians)), 0, static_cast<float>(-sin(yRadians)),0,
0,1,0,0,
static_cast<float>(sin(yRadians)),0,static_cast<float>(cos(yRadians)),0,
0,0,0,1
};
Matrix zRotation
{
static_cast<float>(cos(zRadians)), static_cast<float>(sin(zRadians)),0,0,
static_cast<float>(-sin(zRadians)), static_cast<float>(cos(zRadians)),0,0,
0,0,1,0,
0,0,0,1
};
Matrix cameraPos{
1,0,0, -_position.GetX(),
0,1,0,-_position.GetY(),
0,0,1,-_position.GetZ(),
0,0,0,1 };
Matrix cMatrix = xRotation * yRotation * zRotation * cameraPos;
return cMatrix;
}
float Camera::GetZRotation() const
{
return _zRot;
}
|
/*
This file is part of the VRender library.
Copyright (C) 2005 Cyril Soler (Cyril.Soler@imag.fr)
Version 1.0.0, released on June 27, 2005.
http://artis.imag.fr/Members/Cyril.Soler/VRender
VRender 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.
VRender 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 VRender; if not, write to the Free Software Foundation, Inc.,
51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*/
/****************************************************************************
Copyright (C) 2002-2014 Gilles Debunne. All rights reserved.
This file is part of the QGLViewer library version 2.6.3.
http://www.libqglviewer.com - contact@libqglviewer.com
This file may be used under the terms of the GNU General Public License
versions 2.0 or 3.0 as published by the Free Software Foundation and
appearing in the LICENSE file included in the packaging of this file.
In addition, as a special exception, Gilles Debunne gives you certain
additional rights, described in the file GPL_EXCEPTION in this package.
libQGLViewer uses dual licensing. Commercial/proprietary software must
purchase a libQGLViewer Commercial License.
This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*****************************************************************************/
#ifndef _VRENDER_H_
#define _VRENDER_H_
#include "../config.h"
#include <QTextStream>
#include <QString>
#include "../qglviewer.h"
namespace vrender
{
class VRenderParams ;
typedef void (*RenderCB)(void *) ;
typedef void (*ProgressFunction)(float,const QString&) ;
void VectorialRender(RenderCB DrawFunc, void *callback_params, VRenderParams& render_params) ;
class VRenderParams
{
public:
VRenderParams() ;
~VRenderParams() ;
enum VRenderSortMethod { NoSorting, BSPSort, TopologicalSort, AdvancedTopologicalSort };
enum VRenderFormat { EPS, PS, XFIG, SVG };
enum VRenderOption { CullHiddenFaces = 0x1,
OptimizeBackFaceCulling = 0x4,
RenderBlackAndWhite = 0x8,
AddBackground = 0x10,
TightenBoundingBox = 0x20 } ;
int sortMethod() { return _sortMethod; }
void setSortMethod(VRenderParams::VRenderSortMethod s) { _sortMethod = s ; }
int format() { return _format; }
void setFormat(VRenderFormat f) { _format = f; }
const QString filename() { return _filename ; }
void setFilename(const QString& filename) ;
void setOption(VRenderOption,bool) ;
bool isEnabled(VRenderOption) ;
void setProgressFunction(ProgressFunction pf) { _progress_function = pf ; }
private:
int _error;
VRenderSortMethod _sortMethod;
VRenderFormat _format ;
ProgressFunction _progress_function ;
unsigned int _options; // _DrawMode; _ClearBG; _TightenBB;
QString _filename;
friend void VectorialRender( RenderCB render_callback,
void *callback_params,
VRenderParams& vparams);
friend class ParserGL ;
friend class Exporter ;
friend class BSPSortMethod ;
friend class VisibilityOptimizer ;
friend class TopologicalSortMethod ;
friend class TopologicalSortUtils ;
int& error() { return _error ; }
int& size() { static int size=1000000; return size ; }
void progress(float,const QString&) ;
};
}
#endif
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.