blob_id stringlengths 40 40 | directory_id stringlengths 40 40 | path stringlengths 3 264 | content_id stringlengths 40 40 | detected_licenses listlengths 0 85 | license_type stringclasses 2 values | repo_name stringlengths 5 140 | snapshot_id stringlengths 40 40 | revision_id stringlengths 40 40 | branch_name stringclasses 986 values | visit_date timestamp[us] | revision_date timestamp[us] | committer_date timestamp[us] | github_id int64 3.89k 681M ⌀ | star_events_count int64 0 209k | fork_events_count int64 0 110k | gha_license_id stringclasses 23 values | gha_event_created_at timestamp[us] | gha_created_at timestamp[us] | gha_language stringclasses 145 values | src_encoding stringclasses 34 values | language stringclasses 1 value | is_vendor bool 1 class | is_generated bool 2 classes | length_bytes int64 3 10.4M | extension stringclasses 122 values | content stringlengths 3 10.4M | authors listlengths 1 1 | author_id stringlengths 0 158 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
9880a1d012f02c7cef5360ccaad5e1078c764ef7 | 7a6853d2dcf07b60f0c880c0e84388bc14ec8468 | /temperature.cpp | 7a69ce0712bb3d2360462009dede16c7ff019928 | [
"ISC"
] | permissive | andrejewski/c-plus-practice | df4f893373a5fe8d1ed4ba88ef9037ad807f3f34 | 5f2fc9cdb603ac525a00cf3602b68b009de2994d | refs/heads/master | 2020-04-20T16:37:04.636641 | 2015-10-12T15:25:58 | 2015-10-12T15:25:58 | 41,434,475 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 662 | cpp |
#include <iostream>
using namespace std;
enum scale {CELCIUS, FARENHEIT};
double toCelcius(double temp) {
return ((temp - 32) * 5) / 9;
}
double toFarenheit(double temp) {
return ((9*temp)/5) + 32;
}
int main() {
char* input_unit;
scale unit;
double temp;
cout << "Choose to convert from celcius or farenheit: ";
cin >> input_unit;
char init = input_unit[0];
if(init == 'c' || init == 'C') {
unit = CELCIUS;
} else {
unit = FARENHEIT;
}
cout << "Enter the temperature: ";
cin >> temp;
if(unit == CELCIUS) {
cout << toFarenheit(temp) << " F\n";
} else {
cout << toCelcius(temp) << " C\n";
}
return 0;
}
| [
"christopher.andrejewski@gmail.com"
] | christopher.andrejewski@gmail.com |
c9482babaf91e59a582a5d827c9e4d33aa3948e5 | e5c0fe740ff81c95075250debe12c7869f5e01bc | /MEM.h | 9218471ad2715b4cd831605d12694b6669f68c87 | [] | no_license | lin-zhe/system_monitor | 0e4a361a3f3c3723bc5d3a2ee3ca076bbeab8b9c | 9338282f1ede971239f2c1963358334758250ce9 | refs/heads/master | 2020-04-18T01:54:32.989581 | 2019-02-23T04:48:47 | 2019-02-23T04:48:47 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 503 | h | #ifndef MEM_H_
#define MEM_H_
class MEM{
private:
float MemUsageFree;
float MemUsageAvailable;
int MemTot;
int MemFree;
int MemAvail;
bool MemFileStatus;
int FileLineNum;
public:
MEM();
~MEM();
const void GetMemData();
void ShowMemUsage(const std::string & InfoFile);
void MemUsageRank(const std::string & InfoFile,const int & rank);
void FileStatus(const bool & Status,const int & Num);
bool GetFileValue();
};
#endif // MEM_INFO_H_INCLUDED
| [
"964941118@qq.com"
] | 964941118@qq.com |
505bd7521b364908a29f4bcd9ae471816f264421 | bd7bccdad0acd759e985066d9aa879c0a479644e | /test/brpc_nova_pbrpc_protocol_unittest.cpp | 67390aebc646775f25f25a1fdb9865fd419f64dd | [
"Apache-2.0"
] | permissive | ibyte2011/brpc | 0aa56b74474cf605a680e64c3c783abdf0e9e2f4 | 2f047758765bface9a9fa093106e3b677ed4d3c5 | refs/heads/master | 2021-07-17T03:57:42.171051 | 2017-10-25T08:31:22 | 2017-10-25T08:31:22 | 104,150,642 | 0 | 0 | null | 2017-09-20T01:40:46 | 2017-09-20T01:40:46 | null | UTF-8 | C++ | false | false | 8,759 | cpp | // Baidu RPC - A framework to host and access services throughout Baidu.
// Copyright (c) 2014 Baidu, Inc.
// Date: Sun Jul 13 15:04:18 CST 2014
#include <sys/ioctl.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <gtest/gtest.h>
#include <gperftools/profiler.h>
#include <gflags/gflags.h>
#include <google/protobuf/descriptor.h>
#include "butil/time.h"
#include "butil/macros.h"
#include "brpc/socket.h"
#include "brpc/acceptor.h"
#include "brpc/server.h"
#include "brpc/policy/nova_pbrpc_protocol.h"
#include "brpc/policy/most_common_message.h"
#include "brpc/controller.h"
#include "echo.pb.h"
namespace {
static const std::string EXP_REQUEST = "hello";
static const std::string EXP_RESPONSE = "world";
static const std::string MOCK_CREDENTIAL = "mock credential";
static const std::string MOCK_USER = "mock user";
class MyAuthenticator : public brpc::Authenticator {
public:
MyAuthenticator() {}
int GenerateCredential(std::string* auth_str) const {
*auth_str = MOCK_CREDENTIAL;
return 0;
}
int VerifyCredential(const std::string& auth_str,
const butil::EndPoint&,
brpc::AuthContext* ctx) const {
EXPECT_EQ(MOCK_CREDENTIAL, auth_str);
ctx->set_user(MOCK_USER);
return 0;
}
};
class MyEchoService : public ::test::EchoService {
void Echo(::google::protobuf::RpcController* cntl_base,
const ::test::EchoRequest* req,
::test::EchoResponse* res,
::google::protobuf::Closure* done) {
brpc::Controller* cntl =
static_cast<brpc::Controller*>(cntl_base);
brpc::ClosureGuard done_guard(done);
if (req->close_fd()) {
cntl->CloseConnection("Close connection according to request");
return;
}
EXPECT_EQ(EXP_REQUEST, req->message());
res->set_message(EXP_RESPONSE);
}
};
class NovaTest : public ::testing::Test{
protected:
NovaTest() {
EXPECT_EQ(0, _server.AddService(
&_svc, brpc::SERVER_DOESNT_OWN_SERVICE));
// Hack: Regard `_server' as running
_server._status = brpc::Server::RUNNING;
_server._options.nshead_service = new brpc::policy::NovaServiceAdaptor;
// Nova doesn't support authentication
// _server._options.auth = &_auth;
EXPECT_EQ(0, pipe(_pipe_fds));
brpc::SocketId id;
brpc::SocketOptions options;
options.fd = _pipe_fds[1];
EXPECT_EQ(0, brpc::Socket::Create(options, &id));
EXPECT_EQ(0, brpc::Socket::Address(id, &_socket));
};
virtual ~NovaTest() {};
virtual void SetUp() {};
virtual void TearDown() {};
void VerifyMessage(brpc::InputMessageBase* msg) {
if (msg->_socket == NULL) {
_socket->ReAddress(&msg->_socket);
}
msg->_arg = &_server;
EXPECT_TRUE(brpc::policy::VerifyNsheadRequest(msg));
}
void ProcessMessage(void (*process)(brpc::InputMessageBase*),
brpc::InputMessageBase* msg, bool set_eof) {
if (msg->_socket == NULL) {
_socket->ReAddress(&msg->_socket);
}
msg->_arg = &_server;
_socket->PostponeEOF();
if (set_eof) {
_socket->SetEOF();
}
(*process)(msg);
}
brpc::policy::MostCommonMessage* MakeRequestMessage(
const brpc::nshead_t& head) {
brpc::policy::MostCommonMessage* msg =
brpc::policy::MostCommonMessage::Get();
msg->meta.append(&head, sizeof(head));
test::EchoRequest req;
req.set_message(EXP_REQUEST);
butil::IOBufAsZeroCopyOutputStream req_stream(&msg->payload);
EXPECT_TRUE(req.SerializeToZeroCopyStream(&req_stream));
return msg;
}
brpc::policy::MostCommonMessage* MakeResponseMessage() {
brpc::policy::MostCommonMessage* msg =
brpc::policy::MostCommonMessage::Get();
brpc::nshead_t head;
memset(&head, 0, sizeof(head));
msg->meta.append(&head, sizeof(head));
test::EchoResponse res;
res.set_message(EXP_RESPONSE);
butil::IOBufAsZeroCopyOutputStream res_stream(&msg->payload);
EXPECT_TRUE(res.SerializeToZeroCopyStream(&res_stream));
return msg;
}
void CheckEmptyResponse() {
int bytes_in_pipe = 0;
ioctl(_pipe_fds[0], FIONREAD, &bytes_in_pipe);
EXPECT_EQ(0, bytes_in_pipe);
}
int _pipe_fds[2];
brpc::SocketUniquePtr _socket;
brpc::Server _server;
MyEchoService _svc;
MyAuthenticator _auth;
};
TEST_F(NovaTest, process_request_failed_socket) {
brpc::nshead_t head;
memset(&head, 0, sizeof(head));
brpc::policy::MostCommonMessage* msg = MakeRequestMessage(head);
_socket->SetFailed();
ProcessMessage(brpc::policy::ProcessNsheadRequest, msg, false);
ASSERT_EQ(0ll, _server._nerror.get_value());
CheckEmptyResponse();
}
TEST_F(NovaTest, process_request_logoff) {
brpc::nshead_t head;
head.reserved = 0;
brpc::policy::MostCommonMessage* msg = MakeRequestMessage(head);
_server._status = brpc::Server::READY;
ProcessMessage(brpc::policy::ProcessNsheadRequest, msg, false);
ASSERT_EQ(1ll, _server._nerror.get_value());
ASSERT_TRUE(_socket->Failed());
CheckEmptyResponse();
}
TEST_F(NovaTest, process_request_wrong_method) {
brpc::nshead_t head;
head.reserved = 10;
brpc::policy::MostCommonMessage* msg = MakeRequestMessage(head);
ProcessMessage(brpc::policy::ProcessNsheadRequest, msg, false);
ASSERT_EQ(1ll, _server._nerror.get_value());
ASSERT_TRUE(_socket->Failed());
CheckEmptyResponse();
}
TEST_F(NovaTest, process_response_after_eof) {
test::EchoResponse res;
brpc::Controller cntl;
cntl._response = &res;
brpc::policy::MostCommonMessage* msg = MakeResponseMessage();
_socket->set_correlation_id(cntl.call_id().value);
ProcessMessage(brpc::policy::ProcessNovaResponse, msg, true);
ASSERT_EQ(EXP_RESPONSE, res.message());
ASSERT_TRUE(_socket->Failed());
}
TEST_F(NovaTest, complete_flow) {
butil::IOBuf request_buf;
butil::IOBuf total_buf;
brpc::Controller cntl;
test::EchoRequest req;
test::EchoResponse res;
cntl._response = &res;
cntl._connection_type = brpc::CONNECTION_TYPE_SHORT;
ASSERT_EQ(0, brpc::Socket::Address(_socket->id(), &cntl._current_call.sending_sock));
// Send request
req.set_message(EXP_REQUEST);
brpc::SerializeRequestDefault(&request_buf, &cntl, &req);
ASSERT_FALSE(cntl.Failed());
brpc::policy::PackNovaRequest(
&total_buf, NULL, cntl.call_id().value,
test::EchoService::descriptor()->method(0), &cntl, request_buf, &_auth);
ASSERT_FALSE(cntl.Failed());
// Verify and handle request
brpc::ParseResult req_pr =
brpc::policy::ParseNsheadMessage(&total_buf, NULL, false, NULL);
ASSERT_EQ(brpc::PARSE_OK, req_pr.error());
brpc::InputMessageBase* req_msg = req_pr.message();
VerifyMessage(req_msg);
ProcessMessage(brpc::policy::ProcessNsheadRequest, req_msg, false);
// Read response from pipe
butil::IOPortal response_buf;
response_buf.append_from_file_descriptor(_pipe_fds[0], 1024);
brpc::ParseResult res_pr =
brpc::policy::ParseNsheadMessage(&response_buf, NULL, false, NULL);
ASSERT_EQ(brpc::PARSE_OK, res_pr.error());
brpc::InputMessageBase* res_msg = res_pr.message();
ProcessMessage(brpc::policy::ProcessNovaResponse, res_msg, false);
ASSERT_FALSE(cntl.Failed()) << cntl.ErrorText();
ASSERT_EQ(EXP_RESPONSE, res.message());
}
TEST_F(NovaTest, close_in_callback) {
butil::IOBuf request_buf;
butil::IOBuf total_buf;
brpc::Controller cntl;
test::EchoRequest req;
cntl._connection_type = brpc::CONNECTION_TYPE_SHORT;
ASSERT_EQ(0, brpc::Socket::Address(_socket->id(), &cntl._current_call.sending_sock));
// Send request
req.set_message(EXP_REQUEST);
req.set_close_fd(true);
brpc::SerializeRequestDefault(&request_buf, &cntl, &req);
ASSERT_FALSE(cntl.Failed());
brpc::policy::PackNovaRequest(
&total_buf, NULL, cntl.call_id().value,
test::EchoService::descriptor()->method(0), &cntl, request_buf, &_auth);
ASSERT_FALSE(cntl.Failed());
// Handle request
brpc::ParseResult req_pr =
brpc::policy::ParseNsheadMessage(&total_buf, NULL, false, NULL);
ASSERT_EQ(brpc::PARSE_OK, req_pr.error());
brpc::InputMessageBase* req_msg = req_pr.message();
ProcessMessage(brpc::policy::ProcessNsheadRequest, req_msg, false);
// Socket should be closed
ASSERT_TRUE(_socket->Failed());
}
} //namespace
| [
"gejun@baidu.com"
] | gejun@baidu.com |
ef03b70917ab41be3cfe1e0863540351272910f4 | dd1b4089f638d801698e34b830b2767149b665f6 | /VetoSim/Source/Graphics/Miki_Back.cpp | 0500bd7d2b495e663b8c85ac96d92d709ee70ac4 | [] | no_license | ChristiaanAlwin/NeuLAND_Veto | d1c1b41cfb1f4ade2de664188da615b2541d3e7b | ed06682b03b1bd6b2c7ecc2f3be7c62036ef45ee | refs/heads/master | 2021-01-05T19:02:08.598882 | 2020-02-17T13:55:17 | 2020-02-17T13:55:17 | 241,109,623 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 12,902 | cpp | // include the required C++ headers:
#include <iostream>
// include the required root headers:
// include own headers:
#include "../Analysis/Inputs_Load.h"
#include "AnaLeafs_Connect.h"
#include "DrawHistDouma.h"
// use the standard C++ variables:
using namespace std;
void Miki_Back()
{
// This function Creates a plot of Yield vs X-coordinate for either a single NeuLAND plane,
// or for the entire NeuLAND. These pictures are the same as in Ken Miki his slides.
// These pictures are a bit complicated to explain. The first thing to understand is that
// the particles in these planes are INCOMING particles. Then for each bar that such a
// particle fired, one count is added in the histogram (for the respective coordinate).
// Hence we plot #incoming particles on the y-axis against x-coordinate on the x-axis.
// If a partilce fired multiple bars, the particle is counted multiple times.
// Output is given on the screen.
// Written by C. A. Douma.
// ===================================================================================
// NOTE: Get the counter and the series from sed:
Int_t Series = 0;
Series = 0;
Int_t Counter = 0;
Counter = 1;
cout << "We now read out a single analysis tree.\n\n"
<< "=========================================================================\n\n";
// We begin with connecting to the Inputs.root-file:
Inputs_Structure TheInputs;
Inputs_Structure* Inputs = &TheInputs;
Bool_t Load = Inputs_Load(Inputs,Counter,Series);
// Then connect to the analysis tree:
AnaLeafs_Structure TheLeafs;
AnaLeafs_Structure* AnaLeafs = &TheLeafs;
Bool_t Connect = AnaLeafs_Connect(AnaLeafs,Counter);
// Then check if everything worked:
if (!(Connect&&Load))
{
cout << "### ERROR: Some initializers could not be created!\n"
<< "### ERROR: Without these initializers this task could not be performed!\n"
<< "### ERROR: Therefore the program is now terminated!\n\n";
}
else
{
cout << "All initializers are succesfully created.\n\n"
<< "======================================================================\n\n"
<< "We will now loop over the tree.\n\n";
// ====================================================================================
// Now get everything that we need for the event loop:
Long64_t nEvents = Inputs->nEvents;
Long64_t nBytes = 0;
Int_t Plane = Inputs->NeuContent_Plane;
Double_t pos = 0.0;
if (Plane%2==0)
{
// even planes are vertical. Hence we are interested in horizontal position:
pos = Inputs->VETO_geo_Xpos;
}
else
{
pos = Inputs->VETO_geo_Ypos;
}
pos = 0.0; // to compensate for shifts!
Int_t NbarsFired = 0;
Int_t barNumber;
Int_t ThisPlane = 0;
Int_t TrackID = 0;
Int_t Prim_TrackID = 0;
Int_t Nprims = 0;
Int_t PDG = 0;
Double_t XY_hit = 0.0;
Bool_t VETOed = kFALSE;
Bool_t FromTarget = kFALSE;
Bool_t EventVETO = kFALSE;
// Declare TH1D histograms:
TH1D* protons = new TH1D("protons","protons",50,pos-125.0,pos+125.0);
TH1D* neutrons = new TH1D("neutrons","neutrons",50,pos-125.0,pos+125.0);
TH1D* NfromT = new TH1D("NfromT","NfromT",50,pos-125.0,pos+125.0);
TH1D* electrons = new TH1D("electrons","electrons",50,pos-125.0,pos+125.0);
TH1D* gammas = new TH1D("gammas","gammas",50,pos-125.0,pos+125.0);
TH1D* pions = new TH1D("pions","pions",50,pos-125.0,pos+125.0);
TH1D* muons = new TH1D("muons","muons",50,pos-125.0,pos+125.0);
TH1D* alphas = new TH1D("alphas","alphas",50,pos-125.0,pos+125.0);
TH1D* Cions = new TH1D("Cions","Cions",50,pos-125.0,pos+125.0);
TH1D* fragments = new TH1D("fragments","fragments",50,pos-125.0,pos+125.0);
TH1D* total = new TH1D("total","total",50,pos-125.0,pos+125.0);
// Now perform the event loop over the tree:
for (Long64_t Event = 0; Event<nEvents; ++Event)
{
// read out an event:
nBytes = AnaLeafs->TheTree->GetEntry(Event);
if ((Inputs->UseTrigger!=1)||((AnaLeafs->Full_Trigger->GetValue(0)==kTRUE)))
{
// Now we will read out this event:
NbarsFired = AnaLeafs->NbarsFired_NeuLAND->GetValue(0);
Nprims = AnaLeafs->Nprims_NeuLAND->GetValue(0);
// Do the naive VETO on the 3rd NeuLAND plane:
EventVETO = kFALSE;
if (NbarsFired>0)
{
for (Int_t k = 0; k<NbarsFired; ++k)
{
barNumber = AnaLeafs->Neu_BarNumber_Fired->GetValue(k);
if ((barNumber>50)&&(barNumber<101)) {EventVETO = kTRUE;}
// NOTE: The first plane is the VETO detector, not NeuLAND. Hence we should put this
// VETO condition on the second palne, not the third one!
}
}
if (NbarsFired>0)
{
for (Int_t k = 0; k<NbarsFired; ++k)
{
// request barnumber:
barNumber = AnaLeafs->Neu_BarNumber_Fired->GetValue(k);
// find out the barnumber within that plane and the plane number:
ThisPlane = 1;
while (barNumber>50)
{
ThisPlane = ThisPlane + 1;
barNumber = barNumber - 50;
}
// Get the trackID of the incoming particle that fired this bar:
TrackID = AnaLeafs->Neu_Primary_TrackID->GetValue(k);
// Get the PDG that belongs to this TrackID:
PDG = 0;
VETOed = kFALSE; // Since we only want to add particles that are not VETOed:
FromTarget = kFALSE; // reset.
for (Int_t n = 0; n<Nprims; ++n)
{
Prim_TrackID = AnaLeafs->Prim_TrackID->GetValue(n);
if (TrackID==Prim_TrackID)
{
PDG = AnaLeafs->Prim_PDG->GetValue(n);
VETOed = AnaLeafs->Prim_IsVETOed->GetValue(n);
FromTarget = AnaLeafs->Prim_IsFromTarget->GetValue(n);
}
}
if (PDG==0) {cout << "We have a fired bar without primary particle! Plane = " << ThisPlane << " | Bar in the plane = " << barNumber << " | TrackID = " << TrackID << "\n";}
// so now we know the barnumber and the PDG of the incoming particles. Hence now define the hit:
XY_hit = -125.0 + 2.5 + 5.0*((Int_t) (barNumber-1));
if (Inputs->VETO_select==100) {VETOed = EventVETO;}
if (Inputs->VETO_select==0) {VETOed = kFALSE;}
// so now we can decide how to fill our histograms:
if (((Plane==ThisPlane)||(Plane==0))&&(!VETOed))
{
if (TMath::Abs(PDG)==2212) {protons->Fill(XY_hit);}
else if (TMath::Abs(PDG)==2112)
{
neutrons->Fill(XY_hit);
if (FromTarget) {NfromT->Fill(XY_hit);}
}
else if (TMath::Abs(PDG)==11) {electrons->Fill(XY_hit);}
else if (TMath::Abs(PDG)==22) {gammas->Fill(XY_hit);}
else if (TMath::Abs(PDG)==211) {pions->Fill(XY_hit);}
else if (TMath::Abs(PDG)==13) {muons->Fill(XY_hit);}
else if (TMath::Abs(PDG)==1000020040) {alphas->Fill(XY_hit);}
else if ((TMath::Abs(PDG)>1000060000)&&(TMath::Abs(PDG)<1000060190)) {Cions->Fill(XY_hit);}
else if (TMath::Abs(PDG)>1000000000) {fragments->Fill(XY_hit);}
total->Fill(XY_hit);
}
// Then close the blocks:
}
}
}
// Give a sign of life:
if ((Event+1)%1000==0) {cout << "We processed " << Event+1 << " Events\n";}
}
cout << "The AnalysisTree is read out succesfully.\n\n"
<< "==========================================================================\n\n";
//total->Draw();
// ====================================================================================
// Now all that we need to do is to make a nice decent plot. We have to plot the histograms
// on top of each other, which requires some more algebra.
TString Title = "Incoming particles distribution in NeuLAND plane ";
TString st = "";
Title = Title + st.Itoa(Plane,10);
TString xlabel = "";
if (Plane%2==0)
{
xlabel = "X-position (vertical plane) [cm]";
}
else
{
xlabel = "Y-position (horizontal plane) [cm]";
}
TString ylabel = "Bar Multiplicity [dim. less]";
// Now create the empty plot:
TH1D* h_clone = (TH1D*) total->Clone("h_clone");
TCanvas* c = DrawHistDouma(h_clone,Title,xlabel,ylabel,0);
// Now we have to plot the individual particles:
Double_t max = total->GetMaximum();
Double_t min = total->GetMinimum();
Double_t Xmin = -125.0+pos;
Double_t Xmax = 125.0+pos;
// C-ions:
gStyle->SetHistLineColor(13);
gStyle->SetHistFillColor(13);
gStyle->SetLineWidth(1.0);
TH1D* h_c = (TH1D*) total->Clone("h_c");
h_c->UseCurrentStyle();
h_c->Draw("same");
total->Add(Cions,-1.0);
// alphas:
gStyle->SetHistLineColor(4);
gStyle->SetHistFillColor(4);
gStyle->SetLineWidth(1.0);
TH1D* h_alpha = (TH1D*) total->Clone("h_alpha");
h_alpha->UseCurrentStyle();
h_alpha->Draw("same");
total->Add(alphas,-1.0);
// muons
gStyle->SetHistLineColor(6);
gStyle->SetHistFillColor(6);
gStyle->SetLineWidth(1.0);
TH1D* h_mu = (TH1D*) total->Clone("h_mu");
h_mu->UseCurrentStyle();
h_mu->Draw("same");
total->Add(muons,-1.0);
// pions:
gStyle->SetHistLineColor(9);
gStyle->SetHistFillColor(9);
gStyle->SetLineWidth(1.0);
TH1D* h_pi = (TH1D*) total->Clone("h_pi");
h_pi->UseCurrentStyle();
h_pi->Draw("same");
total->Add(pions,-1.0);
// gammas:
gStyle->SetHistLineColor(3);
gStyle->SetHistFillColor(3);
gStyle->SetLineWidth(1.0);
TH1D* h_gam = (TH1D*) total->Clone("h_gam");
h_gam->UseCurrentStyle();
h_gam->Draw("same");
total->Add(gammas,-1.0);
// electrons:
gStyle->SetHistLineColor(7);
gStyle->SetHistFillColor(7);
gStyle->SetLineWidth(1.0);
TH1D* h_e = (TH1D*) total->Clone("h_e");
h_e->UseCurrentStyle();
h_e->Draw("same");
total->Add(electrons,-1.0);
// fragments:
gStyle->SetHistLineColor(28);
gStyle->SetHistFillColor(28);
gStyle->SetLineWidth(1.0);
TH1D* h_frag = (TH1D*) total->Clone("h_frag");
h_frag->UseCurrentStyle();
h_frag->Draw("same");
total->Add(fragments,-1.0);
// protons:
gStyle->SetHistLineColor(2);
gStyle->SetHistFillColor(2);
gStyle->SetLineWidth(1.0);
TH1D* h_p = (TH1D*) total->Clone("h_p");
h_p->UseCurrentStyle();
h_p->Draw("same");
total->Add(protons,-1.0);
// neutrons:
gStyle->SetHistLineColor(8);
gStyle->SetHistFillColor(8);
gStyle->SetLineWidth(1.0);
TH1D* h_n = (TH1D*) total->Clone("h_n");
h_n->UseCurrentStyle();
h_n->Draw("same");
total->Add(neutrons,-1.0);
// neutrons from target:
gStyle->SetHistFillColor(32);
gStyle->SetHistLineColor(32);
gStyle->SetLineWidth(1.0);
NfromT->UseCurrentStyle();
NfromT->Draw("same");
if (total->Integral()>0.4) {cout << "### ERROR: You missed some particles!!!\n\n\n";}
cout << "# Fragments = " << fragments->Integral() << "\n";
cout << "# C-ions = " << Cions->Integral() << "\n";
cout << "# Alphas = " << alphas->Integral() << "\n";
cout << "# Muons = " << muons->Integral() << "\n";
cout << "# Pions = " << pions->Integral() << "\n";
cout << "# Gammas = " << gammas->Integral() << "\n";
cout << "# Electrons = " << electrons->Integral() << "\n";
cout << "# Neutrons = " << neutrons->Integral() << "\n";
cout << "# N from Target = " << NfromT->Integral() << "\n";
cout << "# Protons = " << protons->Integral() << "\n";
// Now build the legenda:
TPaveText** text = new TPaveText*[10];
for (Int_t k = 0; k<10; ++k)
{
text[k] = new TPaveText(Xmin+(Xmax-Xmin)*0.95,(1.15-0.05*((Int_t) k))*max,Xmin+(Xmax-Xmin)*0.96,(1.16-0.05*((Int_t) k))*max,"NB"); // NB says that no borders are drawn.
text[k]->SetFillColor(0);
text[k]->SetTextSize(0.03);
text[k]->SetTextFont(1);
text[k]->SetTextAngle(0.0);
if (k==0) {text[k]->SetTextColor(2); text[k]->AddText("Protons");}
if (k==1) {text[k]->SetTextColor(8); text[k]->AddText("Neutrons");}
if (k==2) {text[k]->SetTextColor(7); text[k]->AddText("Electrons");}
if (k==3) {text[k]->SetTextColor(3); text[k]->AddText("Gammas");}
if (k==4) {text[k]->SetTextColor(9); text[k]->AddText("Pions");}
if (k==5) {text[k]->SetTextColor(6); text[k]->AddText("Muons");}
if (k==6) {text[k]->SetTextColor(4); text[k]->AddText("Alphas");}
if (k==7) {text[k]->SetTextColor(13); text[k]->AddText("C-ions");}
if (k==8) {text[k]->SetTextColor(28); text[k]->AddText("fragments");}
if (k==9) {text[k]->SetTextColor(32); text[k]->AddText("Neutrons from Target");}
}
for (Int_t k = 0; k<10; ++k)
{
text[k]->Draw("same");
}
// Done! Now just print the picture:
c->SaveAs("../../UI/Pictures/" + Title + ".png");
// Finish:
cout << "Program is finished now.\n\n\n";
// Done!
}
}
// Now define the main for stand-alone compilation:
#ifndef __CINT__
#include <TApplication.h>
int main(int argc, char** argv)
{
TApplication* TheApp = new TApplication("Miki_Back",&argc,argv);
Miki_Back();
TheApp->Run();
return 0;
}
#endif | [
"Christiaan90518@gmail.com"
] | Christiaan90518@gmail.com |
32a108caf4b11ab8e90b7d954530d7f13dc1fb30 | c6079d52c6571a809d59feff22ecf816bb64f4e5 | /Semestre 02/INF01203 - Estrutura de Dados/Aula 07 (Lab.) - Solução para o problema de Listas Simplesmente Encadeadas (LSE)/main.cpp | fa2dd42f206cd78df70f80915d70194b03e76504 | [] | no_license | peslopes/computer-science-full-graduation | 326e206613b50d611215bc158da3cb8adb085127 | 44b37ea182dd8425b32573b3e9aaab472a3e140c | refs/heads/master | 2022-12-02T17:17:00.220007 | 2020-08-12T02:02:11 | 2020-08-12T02:02:11 | null | 0 | 0 | null | null | null | null | ISO-8859-2 | C++ | false | false | 555 | cpp | #include <stdio.h>
#include <stdlib.h>
#include "LSE.h"
int main(void)
{
TipoInfoNo dados;
char cont;
TipoPtNo* l;
l = cria_lista();
do
{
printf("\nTitulo: "); scanf("%s",dados.titulo);
printf("ISBN: "); scanf("%s",dados.isbn);
printf("Numero de páginas: "); scanf("%d",&dados.numpag);
l = insere_fim(l, dados);
printf("Continua? \n");
fflush(stdin);
cont = getchar();
}while (cont!='n');
imprime(l);
l=destroi(l);
imprime(l);
system("pause");
}
| [
"joaolggross@gmail.com"
] | joaolggross@gmail.com |
7363ff9dc130149486ec61b4ea368171c84e9866 | 0d2eab2c7aaf0b78c32c30e7ab484b91e115e8a5 | /nicolas/ch3/useGeometry/src/useGeometry.cpp | 3eed2ee4c59b05fca4f08293f36f9108b5e2c69f | [
"MIT"
] | permissive | nicolasrosa-forks/slambook2 | 08275c8680e24f3c473667ca8ee595b425ef0d3d | 9cae572378fc5da758b6404e45d443b0bde71853 | refs/heads/master | 2023-05-15T17:52:06.421885 | 2021-05-12T00:56:31 | 2021-05-12T00:56:31 | 312,411,541 | 0 | 1 | MIT | 2021-04-15T14:55:56 | 2020-11-12T22:31:16 | C++ | UTF-8 | C++ | false | false | 6,888 | cpp | /* System Libraries */
#include <iostream>
#include <cmath>
/* Eigen3 Libraries */
#include <eigen3/Eigen/Core>
#include <eigen3/Eigen/Geometry>
#include <eigen3/Eigen/Dense>
/* Custom Libraries */
#include "../../../common/libUtils_basic.h"
#include "../../../common/libUtils_eigen.h"
using namespace std;
using namespace Eigen;
/* ================================================================ */
/* This program demonstrates how to use the Eigen geometry module */
/* ================================================================ */
// The Eigen/Geometry module provides a variety of rotation and translation representations
// Hint:
// Rotation matrix (3×3): Eigen::Matrix3d.
// Rotation vector (3×1): Eigen::AngleAxisd.
// Euler angle (3×1): Eigen::Vector3d.
// Quaternion (4×1): Eigen::Quaterniond.
// Euclidean transformation matrix (4×4): Eigen::Isometry3d.
// Affine transform (4×4): Eigen::Affine3d.
// Perspective transformation (4×4): Eigen::Projective3d.
int main(int argc, char** argv){
/* 1. Rotation Matrix */
// 3D rotation matrix can be declared directly using Matrix3d (3x3, double) or Matrix3f (3x3, float)
Matrix3d R = Matrix3d::Identity(); // Rotation Matrix
printMatrix<Matrix3d>("R:", R);
/* 2. Angle-Axis */
// The rotation vector uses AngleAxis, the underlying layer is not directly Matrix,
// but the operation can be treated as a matrix (because the operator is overloaded)
AngleAxisd n(M_PI_4, Vector3d(0, 0, 1)); // Rotation Vector (n), rotate pi/4 rad (45 deg) along the Z-axis
// Rot. Vector -> Rot. Matrix (Z-axis)
cout.precision(3);
printMatrix<Matrix3d>("n:", n.matrix());
// can also be assigned directly
R = n.toRotationMatrix(); // or just n.matrix()
printMatrix<Matrix3d>("R:", R);
/* 3. Coordinate transformation */
Vector3d v1(1, 0, 0); // Arbitrary Vector in X-axis direction
Vector3d v2(0, 1, 1); // Arbitrary Vector in Y-axis direction
Vector3d v3(0, 0, 1); // Arbitrary Vector in Z-axis direction (Coordinates won't change, vector at same direction of the rotation)
// Rotation by Angle-Axis
Vector3d v_rot1 = n*v1;
Vector3d v_rot2 = n*v2;
Vector3d v_rot3 = n*v3;
cout << "v1=[1,0,0] after rotation (by angle axis): " << v_rot1.transpose() << endl;
cout << "v2=[0,1,0] after rotation (by angle axis): " << v_rot2.transpose() << endl;
cout << "v3=[0,0,1] after rotation (by angle axis): " << v_rot3.transpose() << endl << endl;
// Rotation by Matrix
v_rot1 = R*v1;
v_rot2 = R*v2;
v_rot3 = R*v3;
cout << "v1=[1,0,0] after rotation (by matrix): " << v_rot1.transpose() << endl;
cout << "v2=[0,1,0] after rotation (by matrix): " << v_rot2.transpose() << endl;
cout << "v2=[0,0,1] after rotation (by matrix): " << v_rot3.transpose() << endl << endl;
/* 4. Euler angles */
// You can convert the rotation matrix directly into Euler angles
Vector3d euler_angles = R.eulerAngles(2, 1, 0); // RPY Angles, ZYX order
cout << "rpy=[yaw, pitch, roll]: " << euler_angles.transpose() << endl << endl;
/* 5. Euclidean transformation matrix using Eigen::Isometry */
Isometry3d T = Isometry3d::Identity(); //Although called 3d, it's essentially a Matrix4d (4x4)
T.rotate(n); // Rotate according to the rotation vector n.
T.pretranslate(Vector3d(1,3,4)); // Set the translation vector, t=(1,3,4)
printMatrix<Matrix4d>("T:", T.matrix());
// Use the transformation matrix for coodinate transformation
Vector3d v_transformed = T*v1; // Equivalent to R*v+t
cout << "v1=[1,0,0] after transformation T(R, t): " << v_transformed.transpose() << endl << endl;
/* 6. For affine and projective transformations, use Eigen::Affine3d and Eigen::Projective3d.
//TODO
/* Quaternions */
// You can assign AngleAxis directly to quaternions, and vice versa
Quaterniond q1 = Quaterniond(n); // Quaternion(q1) initialized from Rotation Vector(n)
// Note that the order of coeffs is (x, y, z, w), w is the real part, the first three are the imaginary part
Vector4d q1_coeffs = q1.coeffs();
double q1_real_part = q1.w();
Vector3d q1_imag_part = q1.vec();
printQuaternion("q1[s1, v1]: ", q1);
cout << "s1: " << q1_real_part << endl; // Or, w
cout << "v1: " << q1_imag_part.transpose() << endl; // Or, [x, y, z]
printMatrix<Matrix3d>("R from q1:", q1.matrix()); // Converts Quaternion created by AngleAxis to Rotation Matrix
// Can also assign a rotation matrix to it
Quaterniond q2 = Quaterniond(R); // Quaternion(q2) initialized from Rotation Matrix(R)
Vector4d q2_coeffs = q2.coeffs();
double q2_real_part = q2.w();
Vector3d q2_imag_part = q2.vec();
printQuaternion("q2[s2, v2]: ", q2);
cout << "s2: " << q2_real_part << endl; // Or, w
cout << "v2: " << q2_imag_part.transpose() << endl << endl; // Or, [x, y, z]
/* =================================== */
/* Rotate a vector with a quaternion */
/* =================================== */
// [Method 1] By operator overloading in C++, quaternions and 3D Vectors can directly be multiplied.
// [Method 2] However, mathematically, the vector needs to be converted into an imaginary quaternion like shown in the book, and then quaternion multiplication is used for calculation.
/* ----- Method 1, returns a Vector3d ----- */
// Using overloaded multiplication
Vector3d v1_new = q1*v1; // Note that the math is: v' = q.v, (Rot. Quaternion*Vector)
cout << "[Method 1]" << endl;
printQuaternion("q1: ", q1);
cout << "v1: " << v1.transpose() << endl;
printQuaternion("inv(q1): ", q1.inverse());
cout << "v1_new: " << v1_new.transpose() << endl << endl;
/* ----- Method 2, returns a Quaterniond ----- */
// Option 1: Quaternion Initialization by Vector4d, (x, y, z, w)!
// Vector4d v1_aux{1, 0, 0, 0}; // [v1, 0]
// Quaterniond q_v1 = Quaterniond(v1_aux);
// Option 2: Quaternion Initialization by scalar values, (w, x, y, z)!
Quaterniond q_v1 = Quaterniond(0, 1, 0, 0);
// Select different initialization options to see that the declaration way matters. It changes the Quaternion coefficients!!!
cout << "[Method 2]" << endl;
cout << "x: " << q_v1.x() << endl;
cout << "y: " << q_v1.y() << endl;
cout << "z: " << q_v1.z() << endl;
cout << "w: " << q_v1.w() << endl << endl;
Quaterniond q_v1_new = q1*q_v1*q1.inverse(); // Note that the math is: v' = q.v.inv(q), (Rot. Quaternion * Quat. of Vector*Inv. of Rot. Quaternion)
printQuaternion("q1: ", q1);
printQuaternion("q_v1: ", q_v1);
printQuaternion("inv(q1): ", q1.inverse());
printQuaternion("q_v1_new: ", q_v1_new);
cout << "v1_new: " << q_v1_new.vec().transpose() << endl << endl;
return 0;
} | [
"nicolas.rosa@hotmail.com"
] | nicolas.rosa@hotmail.com |
fafbfe393a6eb194af71a8cc2855f8e74aca3bcc | 6599cdd83598e7e9e1afa0c2a03a44553f0e9ef3 | /src/sqlite_001/src/a.cpp | 7e56a6c54ddd52333e51fc4855c96bcf125b7ddf | [] | no_license | skullquake/pocosamples | 72004a8e0b60f646763069c3dff74d0ac219adcb | d693c5da89e265c9eda37c03e58623c1a3afc48d | refs/heads/master | 2021-06-21T23:54:03.020453 | 2021-04-12T09:36:30 | 2021-04-12T09:36:30 | 211,299,107 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,350 | cpp | //#include "Poco/Data/Common.h"
#include"Poco/Data/SQLite/Connector.h"
#include"Poco/Data/Session.h"
#include"Poco/Data/RecordSet.h"
#include"Poco/Data/Row.h"
#include<iostream>
#include<vector>
#include<tuple>
using namespace Poco::Data;
int main(int argc, char* argv[]){
SQLite::Connector::registerConnector();
Session ses("SQLite", "./db/a.db");
//ses.setFeature("emptyStringIsNull",true);
//ses.setFeature("forceEmptyString",true);
std::cout<<"Dropping table...";
ses<<
R"(DROP TABLE IF EXISTS Vec3f)",
Poco::Data::Keywords::now
;
ses<<
R"(DROP TABLE IF EXISTS DataSet)",
Poco::Data::Keywords::now
;
std::cout<<"done"<<std::endl;
std::cout<<"Creating table...";
ses<<
R"(
CREATE TABLE IF NOT EXISTS DataSet
(
id INTEGER NOT NULL PRIMARY KEY
)
)",
Poco::Data::Keywords::now
;
ses<<
R"(
CREATE TABLE IF NOT EXISTS Vec3f
(
x REAL,
y REAL,
z REAL,
id_DataSet INTEGER,
FOREIGN KEY(id_DataSet) REFERENCES DataSet(id)
)
)",
Poco::Data::Keywords::now
;
std::cout<<"done"<<std::endl;
ses.begin();
int nvec3f=10;
int ndataset=10;
std::cout<<"Populating...";
for(int datasetidx=0;datasetidx<ndataset;datasetidx++){
{
Poco::Data::Statement stmt(ses);
stmt<<
R"(
INSERT INTO
DataSet
(id)
VALUES(?)
)",
Poco::Data::Keywords::bind(datasetidx)
;
stmt.execute();
}
for(int vec3fidx=0;vec3fidx<nvec3f;vec3fidx++){
{
Poco::Data::Statement stmt(ses);
stmt<<
R"(
INSERT INTO
Vec3f
(x,y,z,id_DataSet)
VALUES(?,?,?,?)
)",
Poco::Data::Keywords::bind((float)vec3fidx/nvec3f),
Poco::Data::Keywords::bind((float)vec3fidx/nvec3f),
Poco::Data::Keywords::bind((float)vec3fidx/nvec3f),
Poco::Data::Keywords::bind(datasetidx)
;
stmt.execute();
}
}
}
ses.commit();
std::cout<<"done"<<std::endl;
//iterate
{
Poco::Data::Statement stmt(ses);
Poco::Nullable<int> dsid;
Poco::Nullable<float> x;
Poco::Nullable<float> y;
Poco::Nullable<float> z;
stmt<<
R"(
SELECT
dataset.id,
vec3f.x,
vec3f.y,
vec3f.z
FROM Vec3f AS vec3f
INNER JOIN DataSet as dataset
ON Vec3f.id_DataSet=DataSet.id
)",
Poco::Data::Keywords::into(dsid),
Poco::Data::Keywords::into(x),
Poco::Data::Keywords::into(y),
Poco::Data::Keywords::into(z),
Poco::Data::Keywords::range(0,1)
;
while(!stmt.done()){
stmt.execute();
std::cout<<"["
//<<(dsid.isNull()?0:dsid)
<<dsid
<<"]["
<<x
<<","
<<y
<<","
<<z
<<"]"
<<std::endl
;
}
}
//multiple data sets
{
Poco::Data::Statement stmt(ses);
Poco::Nullable<int> dsid;
Poco::Nullable<float> x;
Poco::Nullable<float> y;
Poco::Nullable<float> z;
std::vector<std::tuple<int,float,float,float>> a;
stmt<<
R"(
SELECT
dataset.id,
vec3f.x,
vec3f.y,
vec3f.z
FROM Vec3f AS vec3f
INNER JOIN DataSet as dataset
ON Vec3f.id_DataSet=DataSet.id
)"//,
//Poco::Data::Keywords::range(0,1)
;
stmt.execute();
Poco::Data::RecordSet rs(stmt);
for(auto rsit=rs.begin();rsit!=rs.end();++rsit){
Poco::Data::Row& r=*rsit;
std::cout<<r.valuesToString();//<<std::endl;
}
}
SQLite::Connector::unregisterConnector();
}
| [
"ockert8080@gmail.com"
] | ockert8080@gmail.com |
ef2c79007fce495a962cc24c5ff48072e6508aff | 65f83d093297e4413ffaf0fe5aaf3ffc57fcef62 | /cpp/Top-100-Liked-Questions/75-Sort-Colors/solution_75.cpp | 6505144bfdf6c82c6c90b91a2e244661a89642b3 | [] | no_license | iluoeli/LeetCode-Solutions | fc6ad1c3f9d288325854b2e77be36e225d77f816 | 26e93078be2606cc30ca82c37a7b419830d65fa2 | refs/heads/master | 2022-02-28T16:53:55.130929 | 2019-10-20T14:08:22 | 2019-10-20T14:08:22 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 797 | cpp | /*
* 75. Sort Colors
*/
#include "common.h"
#if LEET_CODE == 75
class Solution {
public:
void sortColors(vector<int>& nums) {
if (nums.size() <= 1)
return;
int left = 0;
int right = nums.size() - 1;
int curIdx = 0; // Scan from left to right.
while (curIdx <= right) {
if (nums[curIdx] == 0) {
if (left < curIdx)
swap(nums[left], nums[curIdx]);
curIdx ++;
left ++;
}
else if (nums[curIdx] == 2) {
swap(nums[curIdx], nums[right]);
right --;
}
else
curIdx ++;
}
}
};
int main()
{
cout << "75. Sort Colors" << endl;
return 0;
}
#endif
| [
"luoyili233@gmail.com"
] | luoyili233@gmail.com |
300e4f28b20efbe37894c2727c8dd81c46a4b6d0 | a6b87253faeace0c4e1aa9400d0dd1e80ee4c1bd | /Assignment 1/seismoModified2/SeismoSrc/main.cpp | 5c19b46d07f42e6e45d77a053671dc38b3053592 | [] | no_license | poliu2s/CPSC-260 | 972b4140dacdc2720f4260c35295e072b66449c5 | a60ecd8f50cd25f95faf62e4a95c2fc61a433abf | refs/heads/master | 2021-01-10T19:03:48.024948 | 2012-12-27T22:23:42 | 2012-12-27T22:23:42 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 13,735 | cpp |
//
// This is example code from Chapter 15.6.1 "Reading a file" of
// "Programming -- Principles and Practice Using C++" by Bjarne Stroustrup
//
//Po Liu,13623079,x2f7
//Hao Ran Wu,26620096,y0f7
//last updated: Jul 8th, 2010
// Jul 7th, 2010
// Jul 6th, 2010
//created data (downloading data) : Jul 5th, 2010
#include "Simple_window.h" // get access to our window library
#include "Graph.h" // get access to our graphics library facilities
#include "std_lib_facilities.h"
#include <iostream>
#include <string>
//------------------------------------------------------------------------------
struct Distribution {
int recordedData;
};
//------------------------------------------------------------------------------
istream& operator>>(istream& is, Distribution& d)
// assume format: one integer per line
{
Distribution dd;
is >>dd.recordedData;
if(!is) return is;
d = dd;
return is;
}
//------------------------------------------------------------------------------
class Scale { // data value to coordinate conversion
int cbase; // coordinate base
int vbase; // base of values
double scale;
public:
Scale(int b, int vb, double s) :cbase(b), vbase(vb), scale(s) { }
int operator()(int v) const { return cbase + (v-vbase)*scale; }
};
//invarient: totalSlots(maximum number of ints being stored at a time)
//a type that can keep adding new integers and dumping the oldest ones while the
//total amount of integers being stored at a time conserves
class CustomedList {
int counter;
int slots;//total slots available
int total;//total number of int has been inserted
bool reused;//once total>slots, new inserted ints will be stored from the beginning of the list (the list is being reused)
int* list;
public:
CustomedList(int b) :slots(b){
counter=0;
list = new int[b];
reused = false;
total = 0;
}
//pre: none
//post: an int being inserted
// if total<slots, the new int will be stored in a new slot
// else, the latest inserted int will be replaced by the new int
void insert(int a){
list[counter] = a;
counter++;
total++;
if (counter == slots){
counter = 0;
reused = true;
}
}
//pre: 0 <= b < numbers being inserted into the object (in case total < slots)
//pre: 0 <= b < slots (for total > slots)
//b = 0 as the the earliest int being inserted
//post: return the int corresponding to possition b
int getInt ( int b){
if (!reused)
return list[b];
else{
if (counter+b+1>=slots)
return list[counter+b+1-slots];
else
return list[counter+b+1];
}
}
//pre: none
//post: return reused;
bool isReused(){
return reused;
}
//pre:none
//post: return the total number being stored in the list
int getTotal (){
if (!reused) return total;
else return slots;
}
};
//------------------------------------------------------------------------------
int main()
try
{
const int xmax = 1000; // window size
const int ymax = 800;
const int xoffset = 100; // distance from left hand side of window to y axis
const int yoffset = 400; // distance from bottom of window to x axis
const int xspace = 40; // space beyond axis
const int yspace = 40;
const int xlength = xmax-xoffset-xspace; // length of axes
const int ylength = ymax-yspace*2;
const int sampleNum = 48000;
const double xscale
= double(xlength)/(sampleNum); // scale of x values
const double yscale = double(ylength)/10000000; // scale of y values --> basically the zoom
Scale xs(xoffset,0,xscale);
Scale ys(yoffset,0,-yscale);
// Asks the user to enter the directory name and changes any '/' to '\\'
cout << "Please enter the file name and directory of the seismic data: " << endl;
cout << "Note: the program will exit immediately if directory or file name does not exist" << endl;
cout << "(Example: L:/Courses/cs260/A1Data/earthq1.PGC.BHZ)" << endl << endl;
string file_name;
cin >> file_name;
cout << endl << endl;
string searchString = "/";
string replaceString = "\\";
string::size_type pos = 0;
while ( (pos = file_name.find(searchString, pos)) != string::npos ) {
file_name.replace( pos, 1, replaceString );
file_name.insert( pos, replaceString );
pos++;
}
// Open the file from the given directory with error checking
ifstream ifs;
ifs.open(file_name);
if (!ifs) error("can't open ",file_name);
Distribution d;
string title; //title
getline(ifs, title);
string tempDate; //temperate storage of the date
getline(ifs, tempDate);
stringstream ss(tempDate);
char date;
//complete the title
ss>>date; title = title+" "+date; ss>>date; title = title + date; ss>>date; title = title + date; ss>>date; title = title + date;
ss>>date; title = title+" "+date; ss>>date; title = title + date;
ss>>date; title = title+" "+date; ss>>date; title = title + date;
ss>>date;
ss>>date; title = title+" "+date; ss>>date; title = title + date;
ss>>date; title = title+":"+date; ss>>date; title = title + date;
ss>>date; title = title+"'"+date; ss>>date; title = title + date+"''";
//go through the next two lines
getline(ifs, tempDate);
getline(ifs, tempDate);
cout<<"Regarding to reality, and due to designing purpose, datas within 15 minutes after a trigger value has been detected would not be examined (they will only be displayed on the graph)."<<endl;
cout<<"As a result, please make sure the trigger value is sufficiently high enough."<<endl;
cout<<"Please enter an trigger value: "<<endl;
int triggerValue;
cin>>triggerValue;
//Check if trigger value is positive
if (!(triggerValue>0)) {
cout << "The trigger value must be an integer and greater than 0." << endl;
return 0;
}
cout << endl << "Please be patient..." << endl;
const int fiveMin = 12000; //sample numbers for 5 minutes
const int maxMin = 48000; //max sample numbers (20minutes)
//using the array beforeEarthQuake to collect 5 minutes worth of data
CustomedList beforeEarthQuake(fiveMin);
//------------------------------------------------------------------------------start going over the file
while (ifs) {
int tempt;// it holds the next data which being examined
//start reading datas from the file again
ifs>>d;
tempt = d.recordedData ;
//trigger value detected
if (tempt>=triggerValue){
Open_polyline recordedData;
int dataCounter = 0;
//------------------------------------------------------------previous 5 minutes!!
//load datas from the array beforeEarthQuake to the line
dataCounter = fiveMin - beforeEarthQuake.getTotal();
for (int k = 0; k < beforeEarthQuake.getTotal(); k++){
int x = xs(dataCounter);
recordedData.add(Point(x,ys(beforeEarthQuake.getInt(k))));
dataCounter++;
}
//loading datas for the previous 5 minutes finished
//load the trigger value
recordedData.add(Point(xs(dataCounter),ys(tempt)));
//keep on loading new data from the file
while (ifs>>d && dataCounter < maxMin) {
int x = xs(dataCounter);
recordedData.add(Point(x,ys(d.recordedData)));
dataCounter++;
//load the last five minutes to beforeEarthQuake
if ((maxMin - dataCounter - fiveMin)<0)
beforeEarthQuake.insert(d.recordedData);
}
//--------------------- Lay out of the Graph -----------------------------------------------------------
Simple_window win(Point(100,100),xmax,ymax,title);
// Plot the x axis representing time
Axis x(Axis::x, Point(xoffset,ymax-yoffset), xlength, 20, "Time (minutes)");
x.label.move(550,0);
//Plot the y axis representing Magnitude
Axis y(Axis::y, Point(xoffset,ymax-yspace), ylength, 0,"Magnitude (Seismic Units)");
y.label.move(-10, -10);
// Declaration of Time Labels
Text time_Labels0(Point(xoffset + 0*(double)xlength/20 - 5 , ymax-yoffset - 7), "-5");
Text time_Labels1(Point(xoffset + 1*(double)xlength/20 - 5 , ymax-yoffset - 7), "-4");
Text time_Labels2(Point(xoffset + 2*(double)xlength/20 - 5 , ymax-yoffset - 7), "-3");
Text time_Labels3(Point(xoffset + 3*(double)xlength/20 - 5 , ymax-yoffset - 7), "-2");
Text time_Labels4(Point(xoffset + 4*(double)xlength/20 - 5 , ymax-yoffset - 7), "-1");
Text time_Labels5(Point(xoffset + 5*(double)xlength/20 - 5 , ymax-yoffset - 7), "0");
Text time_Labels6(Point(xoffset + 6*(double)xlength/20 - 5 , ymax-yoffset - 7), "1");
Text time_Labels7(Point(xoffset + 7*(double)xlength/20 - 5 , ymax-yoffset - 7), "2");
Text time_Labels8(Point(xoffset + 8*(double)xlength/20 - 5 , ymax-yoffset - 7), "3");
Text time_Labels9(Point(xoffset + 9*(double)xlength/20 - 5 , ymax-yoffset - 7), "4");
Text time_Labels10(Point(xoffset + 10*(double)xlength/20 - 5 , ymax-yoffset - 7), "5");
Text time_Labels11(Point(xoffset + 11*(double)xlength/20 - 5 , ymax-yoffset - 7), "6");
Text time_Labels12(Point(xoffset + 12*(double)xlength/20 - 5 , ymax-yoffset - 7), "7");
Text time_Labels13(Point(xoffset + 13*(double)xlength/20 - 5 , ymax-yoffset - 7), "8");
Text time_Labels14(Point(xoffset + 14*(double)xlength/20 - 5 , ymax-yoffset - 7), "9");
Text time_Labels15(Point(xoffset + 15*(double)xlength/20 - 5 , ymax-yoffset - 7), "10");
Text time_Labels16(Point(xoffset + 16*(double)xlength/20 - 5 , ymax-yoffset - 7), "11");
Text time_Labels17(Point(xoffset + 17*(double)xlength/20 - 5 , ymax-yoffset - 7), "12");
Text time_Labels18(Point(xoffset + 18*(double)xlength/20 - 5 , ymax-yoffset - 7), "13");
Text time_Labels19(Point(xoffset + 19*(double)xlength/20 - 5 , ymax-yoffset - 7), "14");
Text time_Labels20(Point(xoffset + 20*(double)xlength/20 - 5 , ymax-yoffset - 7), "15");
// Declaration of Magnitude Labels (values are hard-coded in)
Text seismic_Labels01(Point(xoffset-80,ymax-yspace), "-5000000");
Text seismic_Labels02(Point(xoffset-80,ymax-yspace - 1*(double)ylength/10), "-4000000");
Text seismic_Labels03(Point(xoffset-80,ymax-yspace - 2*(double)ylength/10), "-3000000");
Text seismic_Labels04(Point(xoffset-80,ymax-yspace - 3*(double)ylength/10), "-2000000");
Text seismic_Labels05(Point(xoffset-80,ymax-yspace - 4*(double)ylength/10), "-1000000");
Text seismic_Labels06(Point(xoffset-80,ymax-yspace - 5*(double)ylength/10), "0");
Text seismic_Labels07(Point(xoffset-80,ymax-yspace - 6*(double)ylength/10), "1000000");
Text seismic_Labels08(Point(xoffset-80,ymax-yspace - 7*(double)ylength/10), "2000000");
Text seismic_Labels09(Point(xoffset-80,ymax-yspace - 8*(double)ylength/10), "3000000");
Text seismic_Labels10(Point(xoffset-80,ymax-yspace - 9*(double)ylength/10), "4000000");
Text seismic_Labels11(Point(xoffset-80,ymax-yspace - 10*(double)ylength/10), "5000000");
// Declaring and formating of dashed line at t=0
Line activation_point(Point(xs(12000),yspace),Point(xs(12000),ymax - yspace));
activation_point.set_style(Line_style::dash);
// Plot data labels
Text data_label(Point(xmax-200,ymax-yspace*2),"Plotted Seismic Data");
recordedData.set_color(Color::red);
data_label.set_color(Color::red);
// Graph Title
Text graphTitle(Point(xspace*4,yspace), "Graph of Seismic Data Illustrating Earthquake Magnitude from -5 to +15 mins");
graphTitle.set_color(Color::blue);
// Attach everything to the window
//win.attach(recordedData);
win.attach(data_label);
win.attach(seismic_Labels01);
win.attach(seismic_Labels02);
win.attach(seismic_Labels03);
win.attach(seismic_Labels04);
win.attach(seismic_Labels05);
win.attach(seismic_Labels06);
win.attach(seismic_Labels07);
win.attach(seismic_Labels08);
win.attach(seismic_Labels09);
win.attach(seismic_Labels10);
win.attach(seismic_Labels11);
win.attach(time_Labels0);
win.attach(time_Labels1);
win.attach(time_Labels2);
win.attach(time_Labels3);
win.attach(time_Labels4);
win.attach(time_Labels5);
win.attach(time_Labels6);
win.attach(time_Labels7);
win.attach(time_Labels8);
win.attach(time_Labels9);
win.attach(time_Labels10);
win.attach(time_Labels11);
win.attach(time_Labels12);
win.attach(time_Labels13);
win.attach(time_Labels14);
win.attach(time_Labels15);
win.attach(time_Labels16);
win.attach(time_Labels17);
win.attach(time_Labels18);
win.attach(time_Labels19);
win.attach(time_Labels20);
win.attach(x);
win.attach(y);
win.attach(activation_point);
win.attach(graphTitle);
win.attach(recordedData);
//reattach some components since they might be covered by the graph
win.attach(time_Labels0);
win.attach(time_Labels1);
win.attach(time_Labels2);
win.attach(time_Labels3);
win.attach(time_Labels4);
win.attach(time_Labels5);
win.attach(time_Labels6);
win.attach(time_Labels7);
win.attach(time_Labels8);
win.attach(time_Labels9);
win.attach(time_Labels10);
win.attach(time_Labels11);
win.attach(time_Labels12);
win.attach(time_Labels13);
win.attach(time_Labels14);
win.attach(time_Labels15);
win.attach(time_Labels16);
win.attach(time_Labels17);
win.attach(time_Labels18);
win.attach(time_Labels19);
win.attach(time_Labels20);
win.attach(x);
win.attach(activation_point);
win.attach(graphTitle);
win.wait_for_button();
}
else beforeEarthQuake.insert(tempt); //if tempt is not greater then the trigger value, store it in beforeEarthQuake
}
}
catch(exception& e) {
// some error reporting
return 1;
}
catch(...) {
// some more error reporting
return 2;
}
//------------------------------------------------------------------------------
| [
"po.liu.2s@gmail.com"
] | po.liu.2s@gmail.com |
4eb2046637cb3a7c259c187e840313fc7ea55eec | ed5a0540b571dae25568bbff1620ebbd2cf4adc0 | /011-MaximumArea/cpp/main.cpp | d3a676f6e4ead3430ee46ae25c3457528f570b08 | [] | no_license | samguns/leetcode | 4b842bd51c45ac1a154bca103d165f608131097f | ac7f05693d0f1f5dd239737379a76c667e25d6f3 | refs/heads/master | 2021-06-12T09:59:42.875259 | 2021-03-10T02:20:56 | 2021-03-10T02:20:56 | 152,015,366 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,647 | cpp | #include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
using namespace std;
class Solution {
public:
int maxArea(vector<int>& height) {
int max_area(0);
int left(0);
int right(height.size() - 1);
int found_min(0);
while (left < right) {
int min_height = min(height[left], height[right]);
if (min_height > found_min) {
int area = min_height * (right - left);
if (area > max_area) {
max_area = area;
}
}
if (height[left] < height[right]) {
left++;
} else if (height[left] == height[right]) {
left++;
right--;
} else {
right--;
}
}
return max_area;
}
};
void trimLeftTrailingSpaces(string &input) {
input.erase(input.begin(), find_if(input.begin(), input.end(), [](int ch) {
return !isspace(ch);
}));
}
void trimRightTrailingSpaces(string &input) {
input.erase(find_if(input.rbegin(), input.rend(), [](int ch) {
return !isspace(ch);
}).base(), input.end());
}
vector<int> stringToIntegerVector(string input) {
vector<int> output;
trimLeftTrailingSpaces(input);
trimRightTrailingSpaces(input);
input = input.substr(1, input.length() - 2);
stringstream ss;
ss.str(input);
string item;
char delim = ',';
while (getline(ss, item, delim)) {
output.push_back(stoi(item));
}
return output;
}
int main() {
string line;
while (getline(cin, line)) {
vector<int> height = stringToIntegerVector(line);
int ret = Solution().maxArea(height);
string out = to_string(ret);
cout << out << endl;
}
return 0;
} | [
"wang.vai@gmail.com"
] | wang.vai@gmail.com |
05fc3ad682e31857c9e2a01787040bbdfedc1fe2 | bd4e33394f01dc85cddb6015f81a79af89906983 | /student/10/calculator/calculations.cpp | ed04ba1eff37ce46151ce0ca4170f84ea90989cd | [] | no_license | VARTIOMIES/ohjelmointi-2-cplusplus | d7441ebbe8cf1fb2cff3e245bd1606cdc456a420 | e0f7a970ddcee34827d5cfbbdf54f96097f37e58 | refs/heads/master | 2023-05-05T03:02:55.125758 | 2021-05-10T20:57:49 | 2021-05-10T20:57:49 | 371,703,863 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 654 | cpp | // Note that there is no need for "using namespace std",
// since no C++ standard libraries are used.
double addition(double left, double right) {
return left + right;
}
double subtraction(double left, double right) {
return left - right;
}
double multiplication(double left, double right) {
return left * right;
}
double division(double left, double right) {
return left / right;
}
double exponent(double left, double right){
double result = left;
if (right > 0)
{
for (double i=1;i < right;i++)
{
result*=left;
}
}
else
{
result = 1;
}
return result;
}
| [
"onni.merila@tuni.fi"
] | onni.merila@tuni.fi |
4457d9c351f5997149550d58a2854849a96fca00 | 8a8e3c827914a71161b2c264d96b47cb1c8ed67b | /chap-11/graceserver.cpp | a0fb22d73ae2b33bd35e2bdded12ea013af385d5 | [] | no_license | zouchunxu/net_pratice | 34f1dcc0b40d83855b89ce66b0493510f10a2ee1 | fd4d7c32b75a6e02d66f17ff2760eda9d71d4dea | refs/heads/master | 2023-01-09T21:43:28.209024 | 2020-11-15T09:47:47 | 2020-11-15T09:47:47 | 312,795,404 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,506 | cpp | #include "lib/common.h"
static int count;
static void sig_int(int signo) {
printf("\n received %d datagrams \n", count);
exit(0);
}
int main() {
int listenfd = socket(AF_INET, SOCK_STREAM, 0);
struct sockaddr_in server_addr;
server_addr.sin_family = AF_INET;
server_addr.sin_port = htons(SERV_PORT);
server_addr.sin_addr.s_addr = htonl(INADDR_ANY);
bind(listenfd, (struct sockaddr *) &server_addr, sizeof(server_addr));
int r = listen(listenfd, 1024);
if (r < 0) {
error(1, errno, "listen failed");
}
signal(SIGINT, sig_int);
signal(SIGPIPE, SIG_DFL);
struct sockaddr_in client_addr;
socklen_t socklen = sizeof(client_addr);
int connfd = accept(listenfd, (struct sockaddr *) &client_addr, &socklen);
char message[MAXLINE];
count = 0;
send(connfd, "hello world", sizeof("hello world") + 1, 0);
while (true) {
int n = read(connfd, message, MAXLINE);
if (n < 0) {
error(1, errno, "error read");
} else if (n == 0) {
error(1, 0, "client closed \n");
}
message[n] = 0;
printf("received %d bytes: %s\n", n, message);
count++;
char send_line[MAXLINE];
sprintf(send_line, "Hi,%s", message);
sleep(5);
int write_nc = send(connfd, send_line, strlen(send_line), 0);
printf("send bytes: %zu \n", write_nc);
if (write_nc < 0) {
error(1, errno, "error write");
}
}
} | [
"471500439@qq.com"
] | 471500439@qq.com |
871590fd2da7416c4d483776333dbf003639b7d6 | 99a02bdfe2492ab4133c5092f03c3a380798f8ff | /Ex6_6to6_7/student.h | 0283cf08fcf8a31dcf9c787bb686d93f7b1eadbc | [] | no_license | markusbuchholz/Ezust | 3f593c46738fa3b65c39b1ef920da873f48187e7 | af518f716ec7ca7c88dffa8ac3efb1f79b8a439d | refs/heads/master | 2021-09-15T16:05:14.636662 | 2018-06-06T07:55:13 | 2018-06-06T07:55:13 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,209 | h | #ifndef STUDENT_H
#define STUDENT_H
#include <QString>
//start id="student"
class Student {
public:
Student(QString nm, long id, QString major, int year = 1);
virtual ~Student() {} /* We added the keyword virtual here. */
virtual QString getClassName() const;/* We added virtual here also. */
virtual QString toString() const; /* This should also be virtual.*/
private:
QString m_Name;
QString m_Major;
long m_StudentId;
protected:
int m_Year;
QString yearStr() const;
};
//end
class Undergrad: public Student {
public:
Undergrad(QString name, long id, QString major, int year, int sat);
QString getClassName() const;
QString toString() const;
private:
int m_SAT; /* Scholastic Aptitude Test score total */
};
class GradStudent : public Student {
public:
enum Support { ta, ra, fellowship, other };
GradStudent(QString nm, long id, QString major,
int yr, Support support);
QString getClassName() const ;
QString toString() const;
protected:
static QString supportStr(Support sup) ;
private:
Support m_Support;
};
#endif // #ifndef STUDENT_H
| [
"noreply@github.com"
] | markusbuchholz.noreply@github.com |
efea5489411f46c299077c7af4237ac0dff84cbf | ad273708d98b1f73b3855cc4317bca2e56456d15 | /aws-cpp-sdk-config/include/aws/config/model/DeleteRemediationExceptionsResult.h | c4198fe08f7b445876558de45676ea7c268b22eb | [
"MIT",
"Apache-2.0",
"JSON"
] | permissive | novaquark/aws-sdk-cpp | b390f2e29f86f629f9efcf41c4990169b91f4f47 | a0969508545bec9ae2864c9e1e2bb9aff109f90c | refs/heads/master | 2022-08-28T18:28:12.742810 | 2020-05-27T15:46:18 | 2020-05-27T15:46:18 | 267,351,721 | 1 | 0 | Apache-2.0 | 2020-05-27T15:08:16 | 2020-05-27T15:08:15 | null | UTF-8 | C++ | false | false | 3,910 | h | /*
* Copyright 2010-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file 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 <aws/config/ConfigService_EXPORTS.h>
#include <aws/core/utils/memory/stl/AWSVector.h>
#include <aws/config/model/FailedDeleteRemediationExceptionsBatch.h>
#include <utility>
namespace Aws
{
template<typename RESULT_TYPE>
class AmazonWebServiceResult;
namespace Utils
{
namespace Json
{
class JsonValue;
} // namespace Json
} // namespace Utils
namespace ConfigService
{
namespace Model
{
class AWS_CONFIGSERVICE_API DeleteRemediationExceptionsResult
{
public:
DeleteRemediationExceptionsResult();
DeleteRemediationExceptionsResult(const Aws::AmazonWebServiceResult<Aws::Utils::Json::JsonValue>& result);
DeleteRemediationExceptionsResult& operator=(const Aws::AmazonWebServiceResult<Aws::Utils::Json::JsonValue>& result);
/**
* <p>Returns a list of failed delete remediation exceptions batch objects. Each
* object in the batch consists of a list of failed items and failure messages.</p>
*/
inline const Aws::Vector<FailedDeleteRemediationExceptionsBatch>& GetFailedBatches() const{ return m_failedBatches; }
/**
* <p>Returns a list of failed delete remediation exceptions batch objects. Each
* object in the batch consists of a list of failed items and failure messages.</p>
*/
inline void SetFailedBatches(const Aws::Vector<FailedDeleteRemediationExceptionsBatch>& value) { m_failedBatches = value; }
/**
* <p>Returns a list of failed delete remediation exceptions batch objects. Each
* object in the batch consists of a list of failed items and failure messages.</p>
*/
inline void SetFailedBatches(Aws::Vector<FailedDeleteRemediationExceptionsBatch>&& value) { m_failedBatches = std::move(value); }
/**
* <p>Returns a list of failed delete remediation exceptions batch objects. Each
* object in the batch consists of a list of failed items and failure messages.</p>
*/
inline DeleteRemediationExceptionsResult& WithFailedBatches(const Aws::Vector<FailedDeleteRemediationExceptionsBatch>& value) { SetFailedBatches(value); return *this;}
/**
* <p>Returns a list of failed delete remediation exceptions batch objects. Each
* object in the batch consists of a list of failed items and failure messages.</p>
*/
inline DeleteRemediationExceptionsResult& WithFailedBatches(Aws::Vector<FailedDeleteRemediationExceptionsBatch>&& value) { SetFailedBatches(std::move(value)); return *this;}
/**
* <p>Returns a list of failed delete remediation exceptions batch objects. Each
* object in the batch consists of a list of failed items and failure messages.</p>
*/
inline DeleteRemediationExceptionsResult& AddFailedBatches(const FailedDeleteRemediationExceptionsBatch& value) { m_failedBatches.push_back(value); return *this; }
/**
* <p>Returns a list of failed delete remediation exceptions batch objects. Each
* object in the batch consists of a list of failed items and failure messages.</p>
*/
inline DeleteRemediationExceptionsResult& AddFailedBatches(FailedDeleteRemediationExceptionsBatch&& value) { m_failedBatches.push_back(std::move(value)); return *this; }
private:
Aws::Vector<FailedDeleteRemediationExceptionsBatch> m_failedBatches;
};
} // namespace Model
} // namespace ConfigService
} // namespace Aws
| [
"aws-sdk-cpp-automation@github.com"
] | aws-sdk-cpp-automation@github.com |
2361969f33e679a89d39b5a0a370a7c3280467ce | 6b2a8dd202fdce77c971c412717e305e1caaac51 | /solutions_5669245564223488_1/C++/Paja/b.cpp | 0af047ab44c65aeb9ea985e4703d47266eb93c07 | [] | no_license | alexandraback/datacollection | 0bc67a9ace00abbc843f4912562f3a064992e0e9 | 076a7bc7693f3abf07bfdbdac838cb4ef65ccfcf | refs/heads/master | 2021-01-24T18:27:24.417992 | 2017-05-23T09:23:38 | 2017-05-23T09:23:38 | 84,313,442 | 2 | 4 | null | null | null | null | UTF-8 | C++ | false | false | 2,264 | cpp | #include <cstdlib>
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <string>
using namespace std;
const int MAXN = 100005;
const int MAXM = 205;
const long long MOD = 1000000007;
long long fakt[MAXM];
bool one_letter(const string & s){
char let = s[0];
for(int i = 0; i < s.size(); i++)
if(s[i] != let)
return false;
return true;
}
bool check(const string & s){
//~ cout << s << endl;
int last[MAXM];
fill(last, last + MAXM, -1);
for(int i = 0; i < s.size(); i++){
if(last[s[i]-'a'] != -1 && last[s[i]-'a'] != i - 1)
return false;
last[s[i]-'a'] = i;
}
return true;
}
void solve(int test){
vector<string> eil;
bool taken[MAXN];
bool one[MAXN];
int n;
scanf("%d\n", &n);
string st;
for(int i = 0; i < n; i++)
cin >> st, eil.push_back(st);
for(int i = 0; i < n; i++)
one[i] = one_letter(eil[i]), taken[i] = false;
long long answ = 1;
for(char c = 'a'; c <= 'z'; c++){
int to = eil.size();
string t = "";
int same = 0;
for(int j = 0; j < to; j++)
if(!taken[j]){
if(eil[j][0] != c && eil[j][eil[j].size()-1] == c)
t = eil[j] + t, taken[j] = true;
if(eil[j][0] == c && eil[j][eil[j].size()-1] != c)
t = t+eil[j], taken[j] = true;
if(eil[j][0] == c && eil[j][eil[j].size()-1] == c && one[j]){
taken[j] = true, same++;
if(t == "") t += eil[j];
}
}
if(t != ""){
answ *= fakt[same], answ %= MOD;
one[eil.size()] = one_letter(t);
taken[eil.size()] = false;
eil.push_back(t);
//~ cout << c << " " << t << endl;
}
}
//~ cout << "--" << endl;
//~ for(int i = 0; i < eil.size(); i++)
//~ cout << eil[i] << " " << taken[i] << endl;
int sm = 0;
for(int i = 0; i < eil.size(); i++)
sm += !taken[i];
answ *= fakt[sm], answ %= MOD;
string giant ="";
for(int i = 0; i < eil.size(); i++)
if(!taken[i])
giant += eil[i];
if(check(giant))
printf("Case #%d: %lld\n", test, answ);
else
printf("Case #%d: %d\n", test, 0);
}
int main(){
int testcases;
scanf("%d", &testcases);
fakt[0] = 1;
for(int i = 1; i < MAXM; i++)
fakt[i] = fakt[i-1]*i, fakt[i] %= MOD;
for(int test = 0; test < testcases; test++)
solve(test+1);
return 0;
}
| [
"eewestman@gmail.com"
] | eewestman@gmail.com |
e40512f5414ff9eb2daa2549125afe3c0e900410 | b86384723f6a3f5795511321294cd23003828276 | /labs/lab-5/tutorial/Step2/tutorial.cxx | 315b82396cb3891bba7f635d7ac269990964e23f | [
"MIT"
] | permissive | Colton-Zecca/open-source-software | f7b8bd4a825191b34ef11931cfc0d850516a77f0 | 4aa5fc84f718067e42f969e46e18bcae6eb5fd62 | refs/heads/master | 2023-09-05T20:34:46.192729 | 2021-11-05T00:11:44 | 2021-11-05T00:11:44 | 335,123,735 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 994 | cxx | // A simple program that computes the square root of a number
#include <cmath>
#include <iostream>
#include <string>
#include "TutorialConfig.h"
// Exercise: Why is it important that we configure TutorialConfig.h.in after the option for USE_MYMATH?
// What would happen if we inverted the two?
#ifdef USE_MYMATH
# include "MathFunctions.h"
#endif
int main(int argc, char* argv[])
{
if (argc < 2) {
// report version
std::cout << argv[0] << " Version " << Tutorial_VERSION_MAJOR << "."
<< Tutorial_VERSION_MINOR << std::endl;
std::cout << "Usage: " << argv[0] << " number" << std::endl;
return 1;
}
// convert input to double
const double inputValue = std::stod(argv[1]);
// calculate square root
#ifdef USE_MYMATH
const double outputValue = mysqrt(inputValue);
#else
const double outputValue = sqrt(inputValue);
#endif
std::cout << "The square root of " << inputValue << " is " << outputValue
<< std::endl;
return 0;
}
| [
"colton.zecca18@gmail.com"
] | colton.zecca18@gmail.com |
499ae445db20d33ff5e57a032b79e1b1592dc849 | 8f07d92e33474e91f69d07aac155dc93d8c9f6d9 | /Source/WebKit/chromium/tests/GIFImageDecoderTest.cpp | a4ec5d2ab026031a30c1bde2f43364207e7e5891 | [
"BSD-2-Clause"
] | permissive | kalyankondapally/webkit | c41c9569d3b6ccadf858365cb066f6fc9669e6e2 | a6e27412b0792b850bc14a2268fb7e4052214402 | refs/heads/master | 2023-01-12T11:41:31.861477 | 2013-02-28T20:47:08 | 2013-02-28T20:47:08 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 7,277 | cpp | /*
* Copyright (C) 2013 Google Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Google Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "config.h"
#include "GIFImageDecoder.h"
#include "FileSystem.h"
#include "SharedBuffer.h"
#include <gtest/gtest.h>
#include <public/Platform.h>
#include <public/WebData.h>
#include <public/WebSize.h>
#include <public/WebUnitTestSupport.h>
#include <wtf/OwnPtr.h>
#include <wtf/PassOwnPtr.h>
using namespace WebCore;
using namespace WebKit;
namespace {
static PassRefPtr<SharedBuffer> readFile(const char* fileName)
{
String filePath = Platform::current()->unitTestSupport()->webKitRootDir();
filePath.append(fileName);
long long fileSize;
if (!getFileSize(filePath, fileSize))
return 0;
PlatformFileHandle handle = openFile(filePath, OpenForRead);
int fileLength = static_cast<int>(fileSize);
Vector<char> buffer(fileLength);
readFromFile(handle, buffer.data(), fileLength);
closeFile(handle);
return SharedBuffer::adoptVector(buffer);
}
TEST(GIFImageDecoderTest, decodeTwoFrames)
{
OwnPtr<GIFImageDecoder> decoder(adoptPtr(new GIFImageDecoder(ImageSource::AlphaNotPremultiplied, ImageSource::GammaAndColorProfileApplied)));
RefPtr<SharedBuffer> data = readFile("/LayoutTests/fast/images/resources/animated.gif");
ASSERT_TRUE(data.get());
decoder->setData(data.get(), true);
EXPECT_EQ(cAnimationLoopOnce, decoder->repetitionCount());
ImageFrame* frame = decoder->frameBufferAtIndex(0);
EXPECT_EQ(ImageFrame::FrameComplete, frame->status());
EXPECT_EQ(16, frame->getSkBitmap().width());
EXPECT_EQ(16, frame->getSkBitmap().height());
frame = decoder->frameBufferAtIndex(1);
EXPECT_EQ(ImageFrame::FrameComplete, frame->status());
EXPECT_EQ(16, frame->getSkBitmap().width());
EXPECT_EQ(16, frame->getSkBitmap().height());
EXPECT_EQ(2u, decoder->frameCount());
EXPECT_EQ(cAnimationLoopInfinite, decoder->repetitionCount());
}
#if !OS(ANDROID)
TEST(GIFImageDecoderTest, parseAndDecode)
{
OwnPtr<GIFImageDecoder> decoder(adoptPtr(new GIFImageDecoder(ImageSource::AlphaNotPremultiplied, ImageSource::GammaAndColorProfileApplied)));
RefPtr<SharedBuffer> data = readFile("/LayoutTests/fast/images/resources/animated.gif");
ASSERT_TRUE(data.get());
decoder->setData(data.get(), true);
EXPECT_EQ(cAnimationLoopOnce, decoder->repetitionCount());
// This call will parse the entire file.
EXPECT_EQ(2u, decoder->frameCount());
ImageFrame* frame = decoder->frameBufferAtIndex(0);
EXPECT_EQ(ImageFrame::FrameComplete, frame->status());
EXPECT_EQ(16, frame->getSkBitmap().width());
EXPECT_EQ(16, frame->getSkBitmap().height());
frame = decoder->frameBufferAtIndex(1);
EXPECT_EQ(ImageFrame::FrameComplete, frame->status());
EXPECT_EQ(16, frame->getSkBitmap().width());
EXPECT_EQ(16, frame->getSkBitmap().height());
EXPECT_EQ(cAnimationLoopInfinite, decoder->repetitionCount());
}
TEST(GIFImageDecoderTest, parseByteByByte)
{
OwnPtr<GIFImageDecoder> decoder(adoptPtr(new GIFImageDecoder(ImageSource::AlphaNotPremultiplied, ImageSource::GammaAndColorProfileApplied)));
RefPtr<SharedBuffer> data = readFile("/LayoutTests/fast/images/resources/animated.gif");
ASSERT_TRUE(data.get());
size_t frameCount = 0;
// Pass data to decoder byte by byte.
for (unsigned length = 1; length <= data->size(); ++length) {
RefPtr<SharedBuffer> tempData = SharedBuffer::create(data->data(), length);
decoder->setData(tempData.get(), length == data->size());
EXPECT_LE(frameCount, decoder->frameCount());
frameCount = decoder->frameCount();
}
EXPECT_EQ(2u, decoder->frameCount());
decoder->frameBufferAtIndex(0);
decoder->frameBufferAtIndex(1);
EXPECT_EQ(cAnimationLoopInfinite, decoder->repetitionCount());
}
TEST(GIFImageDecoderTest, parseAndDecodeByteByByte)
{
OwnPtr<GIFImageDecoder> decoder(adoptPtr(new GIFImageDecoder(ImageSource::AlphaNotPremultiplied, ImageSource::GammaAndColorProfileApplied)));
RefPtr<SharedBuffer> data = readFile("/LayoutTests/fast/images/resources/animated-gif-with-offsets.gif");
ASSERT_TRUE(data.get());
size_t frameCount = 0;
size_t framesDecoded = 0;
// Pass data to decoder byte by byte.
for (unsigned length = 1; length <= data->size(); ++length) {
RefPtr<SharedBuffer> tempData = SharedBuffer::create(data->data(), length);
decoder->setData(tempData.get(), length == data->size());
EXPECT_LE(frameCount, decoder->frameCount());
frameCount = decoder->frameCount();
ImageFrame* frame = decoder->frameBufferAtIndex(frameCount - 1);
if (frame && frame->status() == ImageFrame::FrameComplete && framesDecoded < frameCount)
++framesDecoded;
}
EXPECT_EQ(5u, decoder->frameCount());
EXPECT_EQ(5u, framesDecoded);
EXPECT_EQ(cAnimationLoopInfinite, decoder->repetitionCount());
}
// Second frame in the file is broken but test that first frame can be decoded.
TEST(GIFImageDecoderTest, brokenSecondFrame)
{
OwnPtr<GIFImageDecoder> decoder(adoptPtr(new GIFImageDecoder(ImageSource::AlphaNotPremultiplied, ImageSource::GammaAndColorProfileApplied)));
RefPtr<SharedBuffer> data = readFile("/Source/WebKit/chromium/tests/data/broken.gif");
ASSERT_TRUE(data.get());
decoder->setData(data.get(), true);
EXPECT_EQ(1u, decoder->frameCount());
ImageFrame* frame = decoder->frameBufferAtIndex(0);
EXPECT_EQ(ImageFrame::FrameComplete, frame->status());
EXPECT_EQ(16, frame->getSkBitmap().width());
EXPECT_EQ(16, frame->getSkBitmap().height());
frame = decoder->frameBufferAtIndex(1);
EXPECT_FALSE(frame);
EXPECT_EQ(cAnimationLoopOnce, decoder->repetitionCount());
}
#endif
} // namespace
| [
"hclam@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc"
] | hclam@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc |
d95fcaf0cd99546cbba3120e3835f82e6d179a95 | c34ad4311acf72dbbcdf9865a70446e97bb932d5 | /src/board/board.Mega2560.h | 6d5ea00119651696224dfa39c17ff86b9bd339bf | [] | no_license | AlessioMichelassi/brainDuino | c1346b9a2d85c9cf4bcfbdea78cfe1c90d200435 | 3f11312b5515329b7036b5c1b1477e9cfd112adf | refs/heads/main | 2023-02-12T03:38:27.379810 | 2021-01-06T16:22:44 | 2021-01-06T16:22:44 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,821 | h | #include "Arduino.h"
#include "board/pinDefinition_Mega2560.h"
class Mega2560SetUp
{
private:
/* data */
public:
Mega2560SetUp(/* args */);
~Mega2560SetUp();
void setPin();
};
Mega2560SetUp::Mega2560SetUp(/* args */)
{
setPin();
}
Mega2560SetUp::~Mega2560SetUp()
{
}
void Mega2560SetUp::setPin()
{
//pinMode(genPin1, OUTPUT);
// Generalmente questo pin è associato al lettore di temperatura interno
//pinMode(genPin2, OUTPUT);
// pin collegato al buzzer
pinMode(buzzerPin, OUTPUT);
//pinMode(genPin4, OUTPUT);
//pinMode(genPin5, OUTPUT);
//pinMode(genPin6, OUTPUT);
//pinMode(genPin7, OUTPUT);
// Questo pin E' collegato al relay generale che alimenta la board
pinMode(mainPower, OUTPUT); //pin8
// Quando vengono premuti i pulsanti vengono accesi i led collegati
// a questi pin
pinMode(iLedPin1, OUTPUT); //pin9
pinMode(iLedPin2, OUTPUT); //pin10
pinMode(iLedPin3, OUTPUT); //pin11
pinMode(iLedPin4, OUTPUT); //pin12
pinMode(ledBuiltIn, OUTPUT); //LedBuiltIn
//pinMode(genPin14, OUTPUT);
//pinMode(genPin15, OUTPUT);
//pinMode(genPin16, OUTPUT);
//pinMode(genPin17, OUTPUT);
//pinMode(genPin18, OUTPUT);
//pinMode(genPin19, OUTPUT);
//pinMode(genPin20, OUTPUT);
//pinMode(genPin21, OUTPUT);
// ################### THIS IS CONNECTED TO THE RELAY 4 CH MODULE
pinMode(relaych1, OUTPUT); //pin22
pinMode(relaych2, OUTPUT); //pin23
pinMode(relaych3, OUTPUT); //pin24
pinMode(relaych4, OUTPUT); //pin25
// ################### THIS IS CONNECTED TO THE RELAY 4 PUSHBUTTON
pinMode(pushBtn1, INPUT); //pin26
pinMode(pushBtn2, INPUT); //pin27
pinMode(pushBtn3, INPUT); //pin28
pinMode(pushBtn4, INPUT); //pin29
//pinMode(genPin30, OUTPUT);
//pinMode(genPin31, OUTPUT);
//pinMode(genPin32, OUTPUT);
//pinMode(genPin33, OUTPUT);
//pinMode(genPin34, OUTPUT);
//pinMode(genPin35, OUTPUT);
//pinMode(genPin36, OUTPUT);
//pinMode(genPin37, OUTPUT);
//pinMode(genPin38, OUTPUT);
//pinMode(genPin49, OUTPUT);
//pinMode(genPin40, OUTPUT);
//pinMode(genPin41, OUTPUT);
//pinMode(genPin42, OUTPUT);
//pinMode(genPin43, OUTPUT);
//pinMode(genPin44, OUTPUT);
//pinMode(genPin45, OUTPUT);
//pinMode(genPin46, OUTPUT);
//pinMode(genPin47, OUTPUT);
//pinMode(genPin48, OUTPUT);
//pinMode(genPin49, OUTPUT);
//pinMode(genPin50, OUTPUT);
//pinMode(genPin51, OUTPUT);
// This pin is used for reset the boad
pinMode(resetBoard, OUTPUT);
} | [
"noreply@github.com"
] | AlessioMichelassi.noreply@github.com |
f2f15ae17f9e623c76d11580190dab65e3a22050 | 0103454b52923519a02260ade79ded03d345efa9 | /driver/port.build/module.numpy.linalg.info.cpp | b2e3bad18bc74825e09fe37cd8da3ae99fe17775 | [] | no_license | podema/echo3d | 8c7722a942c187a1d9ee01fe3120439cdce7dd6b | 42af02f01d56c49f0616289b1f601bd1e8dbc643 | refs/heads/master | 2016-09-06T16:22:13.043969 | 2015-03-24T10:39:19 | 2015-03-24T10:39:19 | 32,747,234 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 13,320 | cpp | // Generated code for Python source for module 'numpy.linalg.info'
// created by Nuitka version 0.5.5.3
// This code is in part copyright 2014 Kay Hayen.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include "nuitka/prelude.hpp"
#include "__helpers.hpp"
// The _module_numpy$linalg$info is a Python object pointer of module type.
// Note: For full compatability with CPython, every module variable access
// needs to go through it except for cases where the module cannot possibly
// have changed in the mean time.
PyObject *module_numpy$linalg$info;
PyDictObject *moduledict_numpy$linalg$info;
// The module constants used
extern PyObject *const_int_0;
extern PyObject *const_tuple_empty;
extern PyObject *const_str_plain_core;
extern PyObject *const_str_plain_info;
extern PyObject *const_str_plain___doc__;
extern PyObject *const_str_plain_depends;
extern PyObject *const_str_plain___file__;
extern PyObject *const_str_plain_division;
extern PyObject *const_str_plain___future__;
extern PyObject *const_list_str_plain_core_list;
extern PyObject *const_str_plain_print_function;
extern PyObject *const_str_plain_absolute_import;
static PyObject *const_str_digest_86e4b0954abc4709ab7ae648d1c05fcd;
static PyObject *const_str_digest_8f6646a3a66c3b887689f41ede2e1699;
static PyObject *const_str_digest_b4f4c63fe6ff8ef216727830b23a3168;
extern PyObject *const_tuple_b3c114ff65e5229953139969fd8f9f4c_tuple;
static void _initModuleConstants(void)
{
const_str_digest_86e4b0954abc4709ab7ae648d1c05fcd = UNSTREAM_STRING( &constant_bin[ 1480632 ], 17, 0 );
const_str_digest_8f6646a3a66c3b887689f41ede2e1699 = UNSTREAM_STRING( &constant_bin[ 1480649 ], 53, 0 );
const_str_digest_b4f4c63fe6ff8ef216727830b23a3168 = UNSTREAM_STRING( &constant_bin[ 1480702 ], 1104, 0 );
}
// The module code objects.
static PyCodeObject *codeobj_36bd0a5c4abff4361de023e71565613d;
static void _initModuleCodeObjects(void)
{
codeobj_36bd0a5c4abff4361de023e71565613d = MAKE_CODEOBJ( const_str_digest_8f6646a3a66c3b887689f41ede2e1699, const_str_plain_info, 0, const_tuple_empty, 0, CO_NOFREE | CO_FUTURE_DIVISION | CO_FUTURE_ABSOLUTE_IMPORT | CO_FUTURE_PRINT_FUNCTION );
}
// The module function declarations.
// The module function definitions.
#if PYTHON_VERSION >= 300
static struct PyModuleDef mdef_numpy$linalg$info =
{
PyModuleDef_HEAD_INIT,
"numpy.linalg.info", /* m_name */
NULL, /* m_doc */
-1, /* m_size */
NULL, /* m_methods */
NULL, /* m_reload */
NULL, /* m_traverse */
NULL, /* m_clear */
NULL, /* m_free */
};
#endif
#define _MODULE_UNFREEZER 0
#if _MODULE_UNFREEZER
#include "nuitka/unfreezing.hpp"
// Table for lookup to find "frozen" modules or DLLs, i.e. the ones included in
// or along this binary.
static struct Nuitka_MetaPathBasedLoaderEntry meta_path_loader_entries[] =
{
{ NULL, NULL, 0 }
};
#endif
// The exported interface to CPython. On import of the module, this function
// gets called. It has to have an exact function name, in cases it's a shared
// library export. This is hidden behind the MOD_INIT_DECL.
MOD_INIT_DECL( numpy$linalg$info )
{
#if defined(_NUITKA_EXE) || PYTHON_VERSION >= 300
static bool _init_done = false;
// Packages can be imported recursively in deep executables.
if ( _init_done )
{
return MOD_RETURN_VALUE( module_numpy$linalg$info );
}
else
{
_init_done = true;
}
#endif
#ifdef _NUITKA_MODULE
// In case of a stand alone extension module, need to call initialization
// the init here because that's the first and only time we are going to get
// called here.
// Initialize the constant values used.
_initBuiltinModule();
_initConstants();
// Initialize the compiled types of Nuitka.
PyType_Ready( &Nuitka_Generator_Type );
PyType_Ready( &Nuitka_Function_Type );
PyType_Ready( &Nuitka_Method_Type );
PyType_Ready( &Nuitka_Frame_Type );
#if PYTHON_VERSION < 300
initSlotCompare();
#endif
patchBuiltinModule();
patchTypeComparison();
#endif
#if _MODULE_UNFREEZER
registerMetaPathBasedUnfreezer( meta_path_loader_entries );
#endif
_initModuleConstants();
_initModuleCodeObjects();
// puts( "in initnumpy$linalg$info" );
// Create the module object first. There are no methods initially, all are
// added dynamically in actual code only. Also no "__doc__" is initially
// set at this time, as it could not contain NUL characters this way, they
// are instead set in early module code. No "self" for modules, we have no
// use for it.
#if PYTHON_VERSION < 300
module_numpy$linalg$info = Py_InitModule4(
"numpy.linalg.info", // Module Name
NULL, // No methods initially, all are added
// dynamically in actual module code only.
NULL, // No __doc__ is initially set, as it could
// not contain NUL this way, added early in
// actual code.
NULL, // No self for modules, we don't use it.
PYTHON_API_VERSION
);
#else
module_numpy$linalg$info = PyModule_Create( &mdef_numpy$linalg$info );
#endif
moduledict_numpy$linalg$info = (PyDictObject *)((PyModuleObject *)module_numpy$linalg$info)->md_dict;
assertObject( module_numpy$linalg$info );
// Seems to work for Python2.7 out of the box, but for Python3, the module
// doesn't automatically enter "sys.modules", so do it manually.
#if PYTHON_VERSION >= 300
{
int r = PyObject_SetItem( PySys_GetObject( (char *)"modules" ), const_str_digest_86e4b0954abc4709ab7ae648d1c05fcd, module_numpy$linalg$info );
assert( r != -1 );
}
#endif
// For deep importing of a module we need to have "__builtins__", so we set
// it ourselves in the same way than CPython does. Note: This must be done
// before the frame object is allocated, or else it may fail.
PyObject *module_dict = PyModule_GetDict( module_numpy$linalg$info );
if ( PyDict_GetItem( module_dict, const_str_plain___builtins__ ) == NULL )
{
PyObject *value = (PyObject *)builtin_module;
// Check if main module, not a dict then.
#if !defined(_NUITKA_EXE) || !0
value = PyModule_GetDict( value );
#endif
#ifndef __NUITKA_NO_ASSERT__
int res =
#endif
PyDict_SetItem( module_dict, const_str_plain___builtins__, value );
assert( res == 0 );
}
#if PYTHON_VERSION >= 330
#if _MODULE_UNFREEZER
PyDict_SetItem( module_dict, const_str_plain___loader__, metapath_based_loader );
#else
PyDict_SetItem( module_dict, const_str_plain___loader__, Py_None );
#endif
#endif
// Temp variables if any
PyObject *exception_type, *exception_value;
PyTracebackObject *exception_tb;
PyObject *tmp_assign_source_1;
PyObject *tmp_assign_source_2;
PyObject *tmp_assign_source_3;
PyObject *tmp_assign_source_4;
PyObject *tmp_assign_source_5;
PyObject *tmp_assign_source_6;
PyObject *tmp_import_globals_1;
PyObject *tmp_import_globals_2;
PyObject *tmp_import_globals_3;
PyObject *tmp_import_name_from_1;
PyObject *tmp_import_name_from_2;
PyObject *tmp_import_name_from_3;
// Module code.
tmp_assign_source_1 = const_str_digest_b4f4c63fe6ff8ef216727830b23a3168;
UPDATE_STRING_DICT0( moduledict_numpy$linalg$info, (Nuitka_StringObject *)const_str_plain___doc__, tmp_assign_source_1 );
tmp_assign_source_2 = const_str_digest_8f6646a3a66c3b887689f41ede2e1699;
UPDATE_STRING_DICT0( moduledict_numpy$linalg$info, (Nuitka_StringObject *)const_str_plain___file__, tmp_assign_source_2 );
// Frame without reuse.
PyFrameObject *frame_module = MAKE_FRAME( codeobj_36bd0a5c4abff4361de023e71565613d, module_numpy$linalg$info );
// Push the new frame as the currently active one, and we should be exlusively
// owning it.
pushFrameStack( frame_module );
assert( Py_REFCNT( frame_module ) == 1 );
#if PYTHON_VERSION >= 340
frame_module->f_executing += 1;
#endif
// Framed code:
tmp_import_globals_1 = ((PyModuleObject *)module_numpy$linalg$info)->md_dict;
frame_module->f_lineno = 35;
tmp_import_name_from_1 = IMPORT_MODULE( const_str_plain___future__, tmp_import_globals_1, tmp_import_globals_1, const_tuple_b3c114ff65e5229953139969fd8f9f4c_tuple, const_int_0 );
if ( tmp_import_name_from_1 == NULL )
{
assert( ERROR_OCCURED() );
PyErr_Fetch( &exception_type, &exception_value, (PyObject **)&exception_tb );
frame_module->f_lineno = 35;
goto frame_exception_exit_1;
}
tmp_assign_source_3 = IMPORT_NAME( tmp_import_name_from_1, const_str_plain_division );
Py_DECREF( tmp_import_name_from_1 );
if ( tmp_assign_source_3 == NULL )
{
assert( ERROR_OCCURED() );
PyErr_Fetch( &exception_type, &exception_value, (PyObject **)&exception_tb );
frame_module->f_lineno = 35;
goto frame_exception_exit_1;
}
UPDATE_STRING_DICT1( moduledict_numpy$linalg$info, (Nuitka_StringObject *)const_str_plain_division, tmp_assign_source_3 );
tmp_import_globals_2 = ((PyModuleObject *)module_numpy$linalg$info)->md_dict;
frame_module->f_lineno = 35;
tmp_import_name_from_2 = IMPORT_MODULE( const_str_plain___future__, tmp_import_globals_2, tmp_import_globals_2, const_tuple_b3c114ff65e5229953139969fd8f9f4c_tuple, const_int_0 );
if ( tmp_import_name_from_2 == NULL )
{
assert( ERROR_OCCURED() );
PyErr_Fetch( &exception_type, &exception_value, (PyObject **)&exception_tb );
frame_module->f_lineno = 35;
goto frame_exception_exit_1;
}
tmp_assign_source_4 = IMPORT_NAME( tmp_import_name_from_2, const_str_plain_absolute_import );
Py_DECREF( tmp_import_name_from_2 );
if ( tmp_assign_source_4 == NULL )
{
assert( ERROR_OCCURED() );
PyErr_Fetch( &exception_type, &exception_value, (PyObject **)&exception_tb );
frame_module->f_lineno = 35;
goto frame_exception_exit_1;
}
UPDATE_STRING_DICT1( moduledict_numpy$linalg$info, (Nuitka_StringObject *)const_str_plain_absolute_import, tmp_assign_source_4 );
tmp_import_globals_3 = ((PyModuleObject *)module_numpy$linalg$info)->md_dict;
frame_module->f_lineno = 35;
tmp_import_name_from_3 = IMPORT_MODULE( const_str_plain___future__, tmp_import_globals_3, tmp_import_globals_3, const_tuple_b3c114ff65e5229953139969fd8f9f4c_tuple, const_int_0 );
if ( tmp_import_name_from_3 == NULL )
{
assert( ERROR_OCCURED() );
PyErr_Fetch( &exception_type, &exception_value, (PyObject **)&exception_tb );
frame_module->f_lineno = 35;
goto frame_exception_exit_1;
}
tmp_assign_source_5 = IMPORT_NAME( tmp_import_name_from_3, const_str_plain_print_function );
Py_DECREF( tmp_import_name_from_3 );
if ( tmp_assign_source_5 == NULL )
{
assert( ERROR_OCCURED() );
PyErr_Fetch( &exception_type, &exception_value, (PyObject **)&exception_tb );
frame_module->f_lineno = 35;
goto frame_exception_exit_1;
}
UPDATE_STRING_DICT1( moduledict_numpy$linalg$info, (Nuitka_StringObject *)const_str_plain_print_function, tmp_assign_source_5 );
// Restore frame exception if necessary.
#if 0
RESTORE_FRAME_EXCEPTION( frame_module );
#endif
popFrameStack();
assertFrameObject( frame_module );
Py_DECREF( frame_module );
goto frame_no_exception_1;
frame_exception_exit_1:;
#if 0
RESTORE_FRAME_EXCEPTION( frame_module );
#endif
if ( exception_tb == NULL )
{
exception_tb = MAKE_TRACEBACK( INCREASE_REFCOUNT( frame_module ) );
}
else if ( exception_tb->tb_frame != frame_module )
{
PyTracebackObject *traceback_new = (PyTracebackObject *)MAKE_TRACEBACK( INCREASE_REFCOUNT( frame_module ) );
traceback_new->tb_next = exception_tb;
exception_tb = traceback_new;
}
// Put the previous frame back on top.
popFrameStack();
#if PYTHON_VERSION >= 340
frame_module->f_executing -= 1;
#endif
Py_DECREF( frame_module );
// Return the error.
goto module_exception_exit;
frame_no_exception_1:;
tmp_assign_source_6 = LIST_COPY( const_list_str_plain_core_list );
UPDATE_STRING_DICT1( moduledict_numpy$linalg$info, (Nuitka_StringObject *)const_str_plain_depends, tmp_assign_source_6 );
return MOD_RETURN_VALUE( module_numpy$linalg$info );
module_exception_exit:
PyErr_Restore( exception_type, exception_value, (PyObject *)exception_tb );
return MOD_RETURN_VALUE( NULL );
}
| [
"pol.delgado.martin@gmail.com"
] | pol.delgado.martin@gmail.com |
1eef86dd77e14533c717b98fa4db2646f5bc2054 | 6bd3c7b88d4798290c22cf799e5ceb671924fccf | /Samsung AlgoChallenge 2018/_light_show.cpp | a02cb2477af9c8c76e547abafe8d053545b955c1 | [] | no_license | marcavenzaid/competitive-programming | 2c42b3dd70268ea9797af7cf91915eb9e60eea72 | bb712e9e83472335d3e8db7d70945275c4865fc1 | refs/heads/master | 2020-03-22T02:06:04.571656 | 2019-03-23T03:34:53 | 2019-03-23T03:34:53 | 139,349,059 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,802 | cpp | #include <bits/stdc++.h>
using namespace std;
int N, M;
int L[10];
int B[10][3];
int out[10];
const int MAX_COMB = 7;
int binary_to_decimal(vector<int> a) {
int dec_value = 0;
int base = 1;
for (int i = N - 1; i >= 0; i--) {
if (a[i] == 1) {
dec_value += base;
}
base = base * 2;
}
return dec_value;
}
bool is_seen(int dec, vector<int> seen) {
if (dec == 0 || (dec > 0 && seen[dec - 1] == 1)) {
return true;
}
return false;
}
vector<int> _xor(vector<int> a, int B[3], int l) {
for (int i = 0; i < l; ++i) {
a[B[i]] ^= 1;
}
return a;
}
void print(vector<int> a) {
cout << "{";
for (int j = 0; j < a.size(); ++j) {
cout << a[j] << ", ";
}
cout << "}\n";
}
void printa(int a[], int n) {
cout << "{";
for (int j = 0; j < n; ++j) {
cout << a[j] << ", ";
}
cout << "}\n";
}
vector<int> longest;
void recur(vector<int> A, vector<int> is, vector<int> seen) {
for (int i = 0; i < M; ++i) {
vector<int> temp_A = A;
// cout << "temp_A: "; print(temp_A); //
//cout << "B[" << i << "]: "; printa(B[i], L[i]); //
temp_A = _xor(temp_A, B[i], L[i]); // switch
//cout << "temp_A after xor: "; print(temp_A); //
int dec = binary_to_decimal(temp_A);
//cout << "dec: " << dec << "\n"; //
if (!is_seen(dec, seen)) {
cout << "temp_A: "; print(temp_A); //
vector<int> new_seen = seen;
new_seen[dec - 1] = 1;
vector<int> new_is = is;
new_is.push_back(i);
recur(temp_A, new_is, new_seen);
}
//
// cout << "is = " << is.size() << ": {";
// for (int i = 0; i < is.size(); ++i) {
// cout << is[i] << ", ";
// }
// cout << "}\n";
//
if (is.size() > longest.size()) {
longest = is;
}
}
}
int solve(int N, int M, int L[10], int B[10][3], int out[]) {
longest.clear();
vector<int> seen(MAX_COMB, 0);
vector<int> _A(N, 0);
recur(_A, vector<int>(), seen);
copy(longest.begin(), longest.end(), out);
return longest.size();
}
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int t;
cin >> t;
while (t--) {
cin >> N >> M;
for (int i = 0; i < M; ++i) {
cin >> L[i];
for (int j = 0; j < L[i]; ++j) {
cin >> B[i][j];
}
}
for (int i = 0; i < N; ++i) {
out[i] = -1;
}
int ret = solve(N, M, L, B, out);
cout << "ret: " << ret << "\n";
for (int i = 0; i < ret; ++i) {
cout << out[i] << " ";
}
cout << "\n";
}
return 0;
}
| [
"marcavenzaid.gamil@gmail.com"
] | marcavenzaid.gamil@gmail.com |
c035418643b60c0faeb2cbc3c36da263019dc0be | 99dcd91dd33909dda57f3db1019858bb5095381a | /engine/scene/SceneManager.hpp | 298c1d8f4b5c6f40661beb12a35e64085718e2f1 | [
"BSD-2-Clause",
"BSD-3-Clause"
] | permissive | RaphaelK12/ouzel | 164cd262a80b5302ecff72c97eae45dd9032ce81 | 8ec93acd642cdc86ea647d9b278a1a20c61fe2f5 | refs/heads/master | 2022-12-16T16:50:49.050905 | 2020-09-04T04:55:30 | 2020-09-04T04:55:30 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,149 | hpp | // Copyright 2015-2020 Elviss Strazdins. All rights reserved.
#ifndef OUZEL_SCENE_SCENEMANAGER_HPP
#define OUZEL_SCENE_SCENEMANAGER_HPP
#include <functional>
#include <memory>
#include <mutex>
#include <queue>
#include <set>
#include <vector>
namespace ouzel::scene
{
class Scene;
class SceneManager final
{
public:
SceneManager() = default;
~SceneManager();
SceneManager(const SceneManager&) = delete;
SceneManager& operator=(const SceneManager&) = delete;
SceneManager(SceneManager&&) = delete;
SceneManager& operator=(SceneManager&&) = delete;
void draw();
void setScene(Scene* scene);
template <class T> void setScene(std::unique_ptr<T> scene)
{
setScene(scene.get());
ownedScenes.push_back(std::move(scene));
}
bool removeScene(const Scene* scene);
auto getScene() const noexcept { return scenes.empty() ? nullptr : scenes.back(); }
private:
std::vector<Scene*> scenes;
std::vector<std::unique_ptr<Scene>> ownedScenes;
};
}
#endif // OUZEL_SCENE_SCENEMANAGER_HPP
| [
"elviss@elviss.lv"
] | elviss@elviss.lv |
3672442dc10dc9561a0883740406f971b384abad | 57c55be8a6880e535facb81a7401ebf63c382e90 | /test/pch.h | b474aa57ececdbaf7c7d73e130bbb8507d235c12 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | twiggler/slotmap | 15ba247d6519dc62a7334010b3558e3b2c87c80e | 95abc843e45f667a471f0b5bec7638177466bfab | refs/heads/master | 2022-08-11T01:11:43.778516 | 2022-07-26T08:11:32 | 2022-07-26T08:11:32 | 103,035,797 | 34 | 0 | null | 2022-07-26T08:11:33 | 2017-09-10T14:28:25 | C++ | UTF-8 | C++ | false | false | 605 | h | //
// pch.h
// Header for standard system include files.
//
#pragma once
#include "gtest/gtest.h"
#include <foonathan/memory/temporary_allocator.hpp>
#include <foonathan/memory/std_allocator.hpp>
#include <vector>
#include <map>
#include <boost/range/adaptor/transformed.hpp>
#include <boost/range/algorithm/equal.hpp>
#include <boost/hana/tuple.hpp>
#include <boost/hana/cartesian_product.hpp>
#include <boost/hana/transform.hpp>
#include <boost/hana/for_each.hpp>
#include <boost/hana/unpack.hpp>
#include <boost/hana/ext/std/tuple.hpp>
#include <boost/hana/front.hpp>
#include <boost/hana/type.hpp>
| [
"dejongroel@gmail.com"
] | dejongroel@gmail.com |
97bb72003c2dacbb3658ade9958c10667c7d3786 | 3a79dccba99c50c48e42f3c66192664ab35ff1e8 | /network.cpp | 1e99cffd3ef29a8056306f79e1b901115f8ff67e | [] | no_license | eacbpd/qt-widget-app-demo | 199929a16c4fe710ea537a761f4ef371999e040e | 561f2af6cc9303cffd9ba0c966755d3da4494793 | refs/heads/master | 2021-08-24T10:46:10.421316 | 2017-12-09T08:59:31 | 2017-12-09T08:59:31 | 112,502,300 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,367 | cpp | #include "network.h"
#include "ui_network.h"
NetWork::NetWork(QWidget *parent) :
QWidget(parent),
ui(new Ui::NetWork)
{
ui->setupUi(this);
ui->editAddr->setText("127.0.0.1");
ui->editPort->setText("17904");
connect(ui->btnServer,&QPushButton::clicked,this,&NetWork::onBtnServer);
connect(ui->btnClient,&QPushButton::clicked,this,&NetWork::onBtnClient);
connect(ui->btnExit,&QPushButton::clicked,this,&NetWork::onCBtnClose);
connect(ui->btnClose,&QPushButton::clicked,this,&NetWork::onSBtnClose);
}
NetWork::~NetWork()
{
delete ui;
}
void NetWork::onBtnServer()
{
m_pServer = new serverClass();
connect(ui->btnNotice,&QPushButton::clicked,this,&NetWork::onSBtnWrite);
//connect(m_pServer->tcpserver,&QTcpServer::newConnection,)
connect(ui->btnClose,&QPushButton::clicked,this,&NetWork::onSBtnClose);
ui->stackedWidget->setCurrentIndex(2);
}
void NetWork::onSBtnWrite()
{
for(auto &a:m_pServer->ql_psocket)
a->write(ui->sInputEdit->toPlainText().toStdString().c_str());
}
void NetWork::onSRead()
{
}
void NetWork::onSBtnClose()
{
delete m_pServer;
ui->stackedWidget->setCurrentIndex(0);
}
void NetWork::onBtnClient()
{
m_pClient = new clientClass(ui->editAddr->text(),quint16(ui->editPort->text().toShort()));
//connect(ui->btnSend,&QPushButton::clicked,m_pClient,&clientClass::Onsend);
//readyRead()表示服务端发送数据过来即发动信号,接着revData()进行处理。
connect(m_pClient->tcpsocket,&QTcpSocket::readyRead,this,&NetWork::onCRead);
ui->stackedWidget->setCurrentIndex(1);
}
void NetWork::onCBtnWrite()
{
}
void NetWork::onCRead()
{
QString str = m_pClient->tcpsocket->readAll();
ui->cDisplayEdit->append(str);
qDebug()<< str;
}
void NetWork::onCBtnClose()
{
delete m_pClient;
ui->stackedWidget->setCurrentIndex(0);
}
serverClass::serverClass(NetWork *parent):m_parent(parent)
{
tcpserver = new QTcpServer(this);
if(!tcpserver->listen(QHostAddress::Any,17904))
{
qDebug()<<tcpserver->errorString();
//close();
return;
}
//newConnection()用于当有客户端访问时发出信号,Onaccept()信号处理函数
connect(tcpserver,&QTcpServer::newConnection,this,&serverClass::Onaccept);
//当tcpSocket在接受客户端连接时出现错误时,displayError(QAbstractSocket::SocketError)进行错误提醒并关闭tcpSocket。
//connect(tcpSocket,SIGNAL(error(QAbstractSocket::SocketError)),this,SLOT(displayError(QAbstractSocket::SocketError)));
// //send message
// connect(ui->pushButton,SIGNAL(clicked(bool)),this,SLOT(Onsend()));
// //close
// connect(this,SIGNAL(destroyed(QObject*)),this,SLOT(Onclose()));
}
serverClass::~serverClass()
{
delete tcpserver;
}
void serverClass::Onaccept()
{
QTcpSocket *psocket = tcpserver->nextPendingConnection();
ql_psocket.push_back(psocket);
//recv message
connect(psocket,&QTcpSocket::readyRead,this,&serverClass::Onrecv);
}
void serverClass::Onsend(/*const QString &str*/)
{
// std::string const str = static_cast<QTextEdit>
// (parent()->findChild("sInputEdit")).toPlainText().toStdString();
for(auto &a:ql_psocket)
// a->write(str.c_str());
a->write("notice from server");
}
void serverClass::Onrecv()
{
}
void serverClass::Onerr(QAbstractSocket::SocketError)
{
//qDebug()<<tcpsocket->errorString();
//tcpsocket->close();
}
void serverClass::Onclose()
{
for(auto &a:ql_psocket);
//a->write(ui->lineEdit->text().toStdString().c_str());
}
clientClass::clientClass(const QString &a,const quint16 &p,NetWork *parent) :addr(a),port(p),m_parent(parent)
{
tcpsocket = new QTcpSocket(this);
//这里我是采用程序启动就自访问服务端(也可根据实际情况采用手动连接手动输入服务端ip的方式。)
tcpsocket->abort();//assert closed
tcpsocket->connectToHost(addr,port);//connect
//connect(tcpsocket,SIGNAL(error(QAbstractSocket::SocketError)),this,SLOT(Onerr(QAbstractSocket::SocketError)));
}
clientClass::~clientClass()
{
delete tcpsocket;
}
//void DlgClient::Onsend()
//{
//}
//void DlgClient::Onerr(QAbstractSocket::SocketError)
//{
// qDebug()<<tcpsocket->errorString();
// tcpsocket->close();
//}
//void DlgClient::Onclose()
//{
//}
| [
"eacbpd@hotmail.com"
] | eacbpd@hotmail.com |
777f06010dd197b9f5b8506cf55c926bf52f992b | 91b4c051e53eee73812b3a5705f3240a391dfde9 | /CSAMOL.HPP | 9686b81636a1201c2e64eb258589353e75263244 | [] | no_license | arekp/gra-samolot | 74414dd19b365340d72f6150db2ca8a89ad48c12 | 3f83701b7c05adc0ed3dda5fbbebdcf10eab153f | refs/heads/master | 2021-01-11T10:47:56.220211 | 2011-05-30T06:59:42 | 2011-05-30T06:59:42 | 32,317,051 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 567 | hpp | #ifndef _CSAMOL_HPP
#define _CSAMOL_HPP
#include"clasdu.hpp"
struct pocis
{
int xp,yp;
int spx,spy;
int licz_klat_p;
int stan_p;
int akt_klat_p;
int czest,zeg;
int dx,dy;
pocis *nast, *pop;
};
class samol:public duszek
{
public:
int tabl;
samol();
samol(int xa, int ya, int pr, int po, int cz);
~samol();
pocis *p;
void ruch();// ruch wroga
void rys_p();
void strzal();
void przes_p();//przesun pocisk
void wstaw();//do labiryntu
void przesun(); // do labiryntu
};
#endif | [
"arek.ptak@b4d527fe-13cc-e26a-a031-e9ae50367e36"
] | arek.ptak@b4d527fe-13cc-e26a-a031-e9ae50367e36 |
8404d5ea02febda1b7e296eaeb722291d6e71848 | 3d7cd6327b78c352f47b021b41f15307b9f60477 | /MyFirstC++/Timer/Timer.cpp | 38e424cd2d43d1be8330a1c1efd5bf6335fa1468 | [] | no_license | Ikegorgon/MyFirstCPP | 8f818347d638d10b3022cfe0b27f08b8099b1036 | 1ffadaeee3a26431a9871c9ecac8bace0270dc2d | refs/heads/master | 2021-09-06T10:48:38.822356 | 2018-02-05T19:13:18 | 2018-02-05T19:13:18 | 118,965,513 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 712 | cpp | //
// Timer.cpp
// MyFirstC++
//
// Created by Lamb, Isaac on 1/25/18.
// Copyright © 2018 Lamb, Isaac. All rights reserved.
//
#include "Timer.hpp"
using namespace std;
Timer :: Timer() {
executionTime = 0;
}
void Timer :: resetTimer() {
executionTime = 0;
}
void Timer :: startTimer() {
executionTime = clock();
}
void Timer :: stopTimer() {
assert(executionTime != 0);
executionTime = clock() - executionTime;
}
void Timer :: displayInformation() {
cout << "The execion time is: " << executionTime << endl;
cout << "In human time it is " << double (executionTime)/CLOCKS_PER_SEC << " seconds." << endl;
}
long Timer :: getTimeInMicroseconds() {
return executionTime;
}
| [
"31518729+Ikegorgon@users.noreply.github.com"
] | 31518729+Ikegorgon@users.noreply.github.com |
eac825fc1de99d5ec00f2e4055d500f3e97d7480 | 1cf0344795731c3ea4a06c3f9776367ee6e3d91f | /Codeforces/1419/671d.cpp | bbff19d062d7e0d3ecee30802c00dbc655da8586 | [] | no_license | Alex7Li/ProgrammingContests | cf900303ef6ea34d686ea005ba810aabcc6bcc3d | cf6aa6758beb4cc5ca458fcda4ba8dd258e639c1 | refs/heads/master | 2023-03-11T04:14:49.577346 | 2023-02-24T20:48:29 | 2023-02-24T20:48:29 | 100,300,632 | 3 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 843 | cpp | # include <bits/stdc++.h>
using namespace std;
# define rep(i, a, b) for(int i = a; i < (b); ++i)
# define trav(a, x) for(auto& a : x)
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n;
cin >> n;
vi a(n);
for (int i = 0; i < n; i++) {
cin >> a[i];
}
sort(a.begin(), a.end());
vi b(n);
for (int i = 0; i < n; i++) {
if (i % 2 == 0) {
b[i] = a[n / 2 + i / 2];
} else {
b[i] = a[i / 2];
}
}
int score = 0;
for (int i = 1; i < n - 1; i++) {
if (b[i] < b[i - 1] && b[i] < b[i + 1]) {
score++;
}
}
cout << score << "\n" << b[0];
for (int i = 1; i < n; i++) {
cout << " " << b[i];
}
return 0;
} | [
"7alex7li@gmail.com"
] | 7alex7li@gmail.com |
c4266a9b2cdbc2ba3545c2cc5823b23f34e280af | c8b39acfd4a857dc15ed3375e0d93e75fa3f1f64 | /Engine/Source/Editor/LocalizationDashboard/Private/SLocalizationDashboardTargetRow.cpp | 51c7e54af0617e2d90ac677f9ef15f1606537f67 | [
"MIT",
"LicenseRef-scancode-proprietary-license"
] | permissive | windystrife/UnrealEngine_NVIDIAGameWorks | c3c7863083653caf1bc67d3ef104fb4b9f302e2a | b50e6338a7c5b26374d66306ebc7807541ff815e | refs/heads/4.18-GameWorks | 2023-03-11T02:50:08.471040 | 2022-01-13T20:50:29 | 2022-01-13T20:50:29 | 124,100,479 | 262 | 179 | MIT | 2022-12-16T05:36:38 | 2018-03-06T15:44:09 | C++ | UTF-8 | C++ | false | false | 21,695 | cpp | // Copyright 1998-2017 Epic Games, Inc. All Rights Reserved.
#include "SLocalizationDashboardTargetRow.h"
#include "Misc/MessageDialog.h"
#include "Internationalization/Culture.h"
#include "DesktopPlatformModule.h"
#include "Framework/Application/SlateApplication.h"
#include "Widgets/Images/SImage.h"
#include "Widgets/Text/STextBlock.h"
#include "Widgets/Input/SButton.h"
#include "Widgets/Views/SListView.h"
#include "EditorStyleSet.h"
#include "FileHelpers.h"
#include "LocalizationDashboard.h"
#include "IPropertyUtilities.h"
#include "PropertyHandle.h"
#include "LocalizationTargetTypes.h"
#include "Widgets/Docking/SDockTab.h"
#include "Widgets/Input/SHyperlink.h"
#include "SLocalizationTargetStatusButton.h"
#include "LocalizationConfigurationScript.h"
#include "LocalizationCommandletTasks.h"
#define LOCTEXT_NAMESPACE "LocalizationDashboardTargetRow"
void SLocalizationDashboardTargetRow::Construct(const FTableRowArgs& InArgs, const TSharedRef<STableViewBase>& OwnerTableView, const TSharedRef<IPropertyUtilities>& InPropertyUtilities, const TSharedRef<IPropertyHandle>& InTargetObjectPropertyHandle)
{
PropertyUtilities = InPropertyUtilities;
TargetObjectPropertyHandle = InTargetObjectPropertyHandle;
FSuperRowType::Construct(InArgs, OwnerTableView);
}
TSharedRef<SWidget> SLocalizationDashboardTargetRow::GenerateWidgetForColumn( const FName& ColumnName )
{
TSharedPtr<SWidget> Return;
if (ColumnName == "Target")
{
// Target Name
Return = SNew(SHyperlink)
.Text(this, &SLocalizationDashboardTargetRow::GetTargetName)
.OnNavigate(this, &SLocalizationDashboardTargetRow::OnNavigate);
}
else if(ColumnName == "Status")
{
ULocalizationTarget* const LocalizationTarget = GetTarget();
if (LocalizationTarget)
{
// Status icon button.
Return = SNew(SLocalizationTargetStatusButton, *LocalizationTarget);
}
}
else if(ColumnName == "WordCount")
{
// Progress Bar and Word Counts
Return = SNew(STextBlock)
.Text(this, &SLocalizationDashboardTargetRow::GetWordCountText);
}
else if(ColumnName == "Actions")
{
TSharedRef<SHorizontalBox> HorizontalBox = SNew(SHorizontalBox);
Return = HorizontalBox;
// Delete Target
HorizontalBox->AddSlot()
.FillWidth(1.0f)
.HAlign(HAlign_Center)
.VAlign(VAlign_Center)
[
SNew(SButton)
.ButtonStyle( FEditorStyle::Get(), TEXT("HoverHintOnly") )
.ToolTipText(LOCTEXT("DeleteButtonLabel", "Delete this target."))
.OnClicked(this, &SLocalizationDashboardTargetRow::EnqueueDeletion)
.Content()
[
SNew(SImage)
.Image(FEditorStyle::GetBrush("LocalizationDashboard.DeleteTarget"))
]
];
}
return Return.IsValid() ? Return.ToSharedRef() : SNullWidget::NullWidget;
}
ULocalizationTarget* SLocalizationDashboardTargetRow::GetTarget() const
{
if (TargetObjectPropertyHandle.IsValid() && TargetObjectPropertyHandle->IsValidHandle())
{
UObject* Object = nullptr;
if(FPropertyAccess::Result::Success == TargetObjectPropertyHandle->GetValue(Object))
{
return Cast<ULocalizationTarget>(Object);
}
}
return nullptr;
}
FLocalizationTargetSettings* SLocalizationDashboardTargetRow::GetTargetSettings() const
{
ULocalizationTarget* const LocalizationTarget = GetTarget();
return LocalizationTarget ? &(LocalizationTarget->Settings) : nullptr;
}
FText SLocalizationDashboardTargetRow::GetTargetName() const
{
ULocalizationTarget* const LocalizationTarget = GetTarget();
return LocalizationTarget ? FText::FromString(LocalizationTarget->Settings.Name) : FText::GetEmpty();
}
void SLocalizationDashboardTargetRow::OnNavigate()
{
ULocalizationTarget* const LocalizationTarget = GetTarget();
if (LocalizationTarget)
{
FLocalizationDashboard* const LocalizationDashboard = FLocalizationDashboard::Get();
if (LocalizationDashboard)
{
TargetEditorDockTab = LocalizationDashboard->ShowTargetEditorTab(LocalizationTarget);
}
}
}
FText SLocalizationDashboardTargetRow::GetCulturesText() const
{
FLocalizationTargetSettings* const TargetSettings = GetTargetSettings();
if (TargetSettings)
{
TArray<FString> OrderedCultureNames;
for (const auto& CultureStatistics : TargetSettings->SupportedCulturesStatistics)
{
OrderedCultureNames.Add(CultureStatistics.CultureName);
}
FString Result;
for (FString& CultureName : OrderedCultureNames)
{
const FCulturePtr Culture = FInternationalization::Get().GetCulture(CultureName);
if (Culture.IsValid())
{
const FString CultureDisplayName = Culture->GetDisplayName();
if (!Result.IsEmpty())
{
Result.Append(TEXT(", "));
}
Result.Append(CultureDisplayName);
}
}
return FText::FromString(Result);
}
return FText::GetEmpty();
}
uint32 SLocalizationDashboardTargetRow::GetWordCount() const
{
FLocalizationTargetSettings* const TargetSettings = GetTargetSettings();
return TargetSettings && TargetSettings->SupportedCulturesStatistics.IsValidIndex(TargetSettings->NativeCultureIndex) ? TargetSettings->SupportedCulturesStatistics[TargetSettings->NativeCultureIndex].WordCount : 0;
}
uint32 SLocalizationDashboardTargetRow::GetNativeWordCount() const
{
FLocalizationTargetSettings* const TargetSettings = GetTargetSettings();
return TargetSettings && TargetSettings->SupportedCulturesStatistics.IsValidIndex(TargetSettings->NativeCultureIndex) ? TargetSettings->SupportedCulturesStatistics[TargetSettings->NativeCultureIndex].WordCount : 0;
}
FText SLocalizationDashboardTargetRow::GetWordCountText() const
{
return FText::AsNumber(GetWordCount());
}
void SLocalizationDashboardTargetRow::UpdateTargetFromReports()
{
ULocalizationTarget* const LocalizationTarget = GetTarget();
if (LocalizationTarget)
{
//TArray< TSharedPtr<IPropertyHandle> > WordCountPropertyHandles;
//const TSharedPtr<IPropertyHandle> TargetSettingsPropertyHandle = TargetEditor->GetTargetSettingsPropertyHandle();
//if (TargetSettingsPropertyHandle.IsValid() && TargetSettingsPropertyHandle->IsValidHandle())
//{
// const TSharedPtr<IPropertyHandle> NativeCultureStatisticsPropertyHandle = TargetSettingsPropertyHandle->GetChildHandle(GET_MEMBER_NAME_CHECKED(FLocalizationTargetSettings, NativeCultureStatistics));
// if (NativeCultureStatisticsPropertyHandle.IsValid() && NativeCultureStatisticsPropertyHandle->IsValidHandle())
// {
// const TSharedPtr<IPropertyHandle> WordCountPropertyHandle = NativeCultureStatisticsPropertyHandle->GetChildHandle(GET_MEMBER_NAME_CHECKED(FCultureStatistics, WordCount));
// if (WordCountPropertyHandle.IsValid() && WordCountPropertyHandle->IsValidHandle())
// {
// WordCountPropertyHandles.Add(WordCountPropertyHandle);
// }
// }
// const TSharedPtr<IPropertyHandle> SupportedCulturesStatisticsPropertyHandle = TargetSettingsPropertyHandle->GetChildHandle(GET_MEMBER_NAME_CHECKED(FLocalizationTargetSettings, SupportedCulturesStatistics));
// if (SupportedCulturesStatisticsPropertyHandle.IsValid() && SupportedCulturesStatisticsPropertyHandle->IsValidHandle())
// {
// uint32 SupportedCultureCount = 0;
// SupportedCulturesStatisticsPropertyHandle->GetNumChildren(SupportedCultureCount);
// for (uint32 i = 0; i < SupportedCultureCount; ++i)
// {
// const TSharedPtr<IPropertyHandle> ElementPropertyHandle = SupportedCulturesStatisticsPropertyHandle->GetChildHandle(i);
// if (ElementPropertyHandle.IsValid() && ElementPropertyHandle->IsValidHandle())
// {
// const TSharedPtr<IPropertyHandle> WordCountPropertyHandle = SupportedCulturesStatisticsPropertyHandle->GetChildHandle(GET_MEMBER_NAME_CHECKED(FCultureStatistics, WordCount));
// if (WordCountPropertyHandle.IsValid() && WordCountPropertyHandle->IsValidHandle())
// {
// WordCountPropertyHandles.Add(WordCountPropertyHandle);
// }
// }
// }
// }
//}
//for (const TSharedPtr<IPropertyHandle>& WordCountPropertyHandle : WordCountPropertyHandles)
//{
// WordCountPropertyHandle->NotifyPreChange();
//}
LocalizationTarget->UpdateWordCountsFromCSV();
LocalizationTarget->UpdateStatusFromConflictReport();
//for (const TSharedPtr<IPropertyHandle>& WordCountPropertyHandle : WordCountPropertyHandles)
//{
// WordCountPropertyHandle->NotifyPostChange();
//}
}
}
bool SLocalizationDashboardTargetRow::CanGatherText() const
{
ULocalizationTarget* const LocalizationTarget = GetTarget();
return LocalizationTarget && LocalizationTarget->Settings.SupportedCulturesStatistics.Num() > 0 && LocalizationTarget->Settings.SupportedCulturesStatistics.IsValidIndex(LocalizationTarget->Settings.NativeCultureIndex);
}
FReply SLocalizationDashboardTargetRow::GatherText()
{
ULocalizationTarget* const LocalizationTarget = GetTarget();
if (LocalizationTarget)
{
// Save unsaved packages.
const bool bPromptUserToSave = true;
const bool bSaveMapPackages = true;
const bool bSaveContentPackages = true;
const bool bFastSave = false;
const bool bNotifyNoPackagesSaved = false;
const bool bCanBeDeclined = true;
bool DidPackagesNeedSaving;
const bool WerePackagesSaved = FEditorFileUtils::SaveDirtyPackages(bPromptUserToSave, bSaveMapPackages, bSaveContentPackages, bFastSave, bNotifyNoPackagesSaved, bCanBeDeclined, &DidPackagesNeedSaving);
if (DidPackagesNeedSaving && !WerePackagesSaved)
{
// Give warning dialog.
const FText MessageText = NSLOCTEXT("LocalizationCultureActions", "UnsavedPackagesWarningDialogMessage", "There are unsaved changes. These changes may not be gathered from correctly.");
const FText TitleText = NSLOCTEXT("LocalizationCultureActions", "UnsavedPackagesWarningDialogTitle", "Unsaved Changes Before Gather");
switch(FMessageDialog::Open(EAppMsgType::OkCancel, MessageText, &TitleText))
{
case EAppReturnType::Cancel:
{
return FReply::Handled();
}
break;
}
}
// Execute gather.
const TSharedPtr<SWindow> ParentWindow = FSlateApplication::Get().FindWidgetWindow(AsShared());
LocalizationCommandletTasks::GatherTextForTarget(ParentWindow.ToSharedRef(), LocalizationTarget);
UpdateTargetFromReports();
}
return FReply::Handled();
}
bool SLocalizationDashboardTargetRow::CanImportText() const
{
ULocalizationTarget* const LocalizationTarget = GetTarget();
return LocalizationTarget && LocalizationTarget->Settings.SupportedCulturesStatistics.Num() > 0 && LocalizationTarget->Settings.SupportedCulturesStatistics.IsValidIndex(LocalizationTarget->Settings.NativeCultureIndex);
}
FReply SLocalizationDashboardTargetRow::ImportText()
{
ULocalizationTarget* const LocalizationTarget = GetTarget();
IDesktopPlatform* DesktopPlatform = FDesktopPlatformModule::Get();
if (LocalizationTarget && DesktopPlatform)
{
void* ParentWindowWindowHandle = NULL;
const TSharedPtr<SWindow> ParentWindow = FSlateApplication::Get().FindWidgetWindow(AsShared());
if (ParentWindow.IsValid() && ParentWindow->GetNativeWindow().IsValid())
{
ParentWindowWindowHandle = ParentWindow->GetNativeWindow()->GetOSWindowHandle();
}
const FString DefaultPath = FPaths::ConvertRelativePathToFull(LocalizationConfigurationScript::GetDataDirectory(LocalizationTarget));
FText DialogTitle;
{
FFormatNamedArguments FormatArguments;
FormatArguments.Add(TEXT("TargetName"), FText::FromString(LocalizationTarget->Settings.Name));
DialogTitle = FText::Format(LOCTEXT("ImportAllTranslationsForTargetDialogTitleFormat", "Import All Translations for {TargetName} from Directory"), FormatArguments);
}
// Prompt the user for the directory
FString OutputDirectory;
if (DesktopPlatform->OpenDirectoryDialog(ParentWindowWindowHandle, DialogTitle.ToString(), DefaultPath, OutputDirectory))
{
LocalizationCommandletTasks::ImportTextForTarget(ParentWindow.ToSharedRef(), LocalizationTarget, TOptional<FString>(OutputDirectory));
UpdateTargetFromReports();
}
}
return FReply::Handled();
}
bool SLocalizationDashboardTargetRow::CanExportText() const
{
ULocalizationTarget* const LocalizationTarget = GetTarget();
return LocalizationTarget && LocalizationTarget->Settings.SupportedCulturesStatistics.Num() > 0 && LocalizationTarget->Settings.SupportedCulturesStatistics.IsValidIndex(LocalizationTarget->Settings.NativeCultureIndex);
}
FReply SLocalizationDashboardTargetRow::ExportText()
{
ULocalizationTarget* const LocalizationTarget = GetTarget();
IDesktopPlatform* DesktopPlatform = FDesktopPlatformModule::Get();
if (LocalizationTarget && DesktopPlatform)
{
void* ParentWindowWindowHandle = NULL;
const TSharedPtr<SWindow> ParentWindow = FSlateApplication::Get().FindWidgetWindow(AsShared());
if (ParentWindow.IsValid() && ParentWindow->GetNativeWindow().IsValid())
{
ParentWindowWindowHandle = ParentWindow->GetNativeWindow()->GetOSWindowHandle();
}
const FString DefaultPath = FPaths::ConvertRelativePathToFull(LocalizationConfigurationScript::GetDataDirectory(LocalizationTarget));
FText DialogTitle;
{
FFormatNamedArguments FormatArguments;
FormatArguments.Add(TEXT("TargetName"), FText::FromString(LocalizationTarget->Settings.Name));
DialogTitle = FText::Format(LOCTEXT("ExportAllTranslationsForTargetDialogTitleFormat", "Export All Translations for {TargetName} to Directory"), FormatArguments);
}
// Prompt the user for the directory
FString OutputDirectory;
if (DesktopPlatform->OpenDirectoryDialog(ParentWindowWindowHandle, DialogTitle.ToString(), DefaultPath, OutputDirectory))
{
LocalizationCommandletTasks::ExportTextForTarget(ParentWindow.ToSharedRef(), LocalizationTarget, TOptional<FString>(OutputDirectory));
}
}
return FReply::Handled();
}
bool SLocalizationDashboardTargetRow::CanImportDialogueScript() const
{
ULocalizationTarget* const LocalizationTarget = GetTarget();
return LocalizationTarget && LocalizationTarget->Settings.SupportedCulturesStatistics.Num() > 0 && LocalizationTarget->Settings.SupportedCulturesStatistics.IsValidIndex(LocalizationTarget->Settings.NativeCultureIndex);
}
FReply SLocalizationDashboardTargetRow::ImportDialogueScript()
{
ULocalizationTarget* const LocalizationTarget = GetTarget();
IDesktopPlatform* DesktopPlatform = FDesktopPlatformModule::Get();
if (LocalizationTarget && DesktopPlatform)
{
void* ParentWindowWindowHandle = NULL;
const TSharedPtr<SWindow> ParentWindow = FSlateApplication::Get().FindWidgetWindow(AsShared());
if (ParentWindow.IsValid() && ParentWindow->GetNativeWindow().IsValid())
{
ParentWindowWindowHandle = ParentWindow->GetNativeWindow()->GetOSWindowHandle();
}
const FString DefaultPath = FPaths::ConvertRelativePathToFull(LocalizationConfigurationScript::GetDataDirectory(LocalizationTarget));
FText DialogTitle;
{
FFormatNamedArguments FormatArguments;
FormatArguments.Add(TEXT("TargetName"), FText::FromString(LocalizationTarget->Settings.Name));
DialogTitle = FText::Format(LOCTEXT("ImportAllDialogueScriptsForTargetDialogTitleFormat", "Import All Dialogue Scripts for {TargetName} from Directory"), FormatArguments);
}
// Prompt the user for the directory
FString OutputDirectory;
if (DesktopPlatform->OpenDirectoryDialog(ParentWindowWindowHandle, DialogTitle.ToString(), DefaultPath, OutputDirectory))
{
LocalizationCommandletTasks::ImportDialogueScriptForTarget(ParentWindow.ToSharedRef(), LocalizationTarget, TOptional<FString>(OutputDirectory));
UpdateTargetFromReports();
}
}
return FReply::Handled();
}
bool SLocalizationDashboardTargetRow::CanExportDialogueScript() const
{
ULocalizationTarget* const LocalizationTarget = GetTarget();
return LocalizationTarget && LocalizationTarget->Settings.SupportedCulturesStatistics.Num() > 0 && LocalizationTarget->Settings.SupportedCulturesStatistics.IsValidIndex(LocalizationTarget->Settings.NativeCultureIndex);
}
FReply SLocalizationDashboardTargetRow::ExportDialogueScript()
{
ULocalizationTarget* const LocalizationTarget = GetTarget();
IDesktopPlatform* DesktopPlatform = FDesktopPlatformModule::Get();
if (LocalizationTarget && DesktopPlatform)
{
void* ParentWindowWindowHandle = NULL;
const TSharedPtr<SWindow> ParentWindow = FSlateApplication::Get().FindWidgetWindow(AsShared());
if (ParentWindow.IsValid() && ParentWindow->GetNativeWindow().IsValid())
{
ParentWindowWindowHandle = ParentWindow->GetNativeWindow()->GetOSWindowHandle();
}
const FString DefaultPath = FPaths::ConvertRelativePathToFull(LocalizationConfigurationScript::GetDataDirectory(LocalizationTarget));
FText DialogTitle;
{
FFormatNamedArguments FormatArguments;
FormatArguments.Add(TEXT("TargetName"), FText::FromString(LocalizationTarget->Settings.Name));
DialogTitle = FText::Format(LOCTEXT("ExportAllDialogueScriptsForTargetDialogTitleFormat", "Export All Dialogue Scripts for {TargetName} to Directory"), FormatArguments);
}
// Prompt the user for the directory
FString OutputDirectory;
if (DesktopPlatform->OpenDirectoryDialog(ParentWindowWindowHandle, DialogTitle.ToString(), DefaultPath, OutputDirectory))
{
LocalizationCommandletTasks::ExportDialogueScriptForTarget(ParentWindow.ToSharedRef(), LocalizationTarget, TOptional<FString>(OutputDirectory));
}
}
return FReply::Handled();
}
bool SLocalizationDashboardTargetRow::CanImportDialogue() const
{
ULocalizationTarget* const LocalizationTarget = GetTarget();
return LocalizationTarget && LocalizationTarget->Settings.SupportedCulturesStatistics.Num() > 0 && LocalizationTarget->Settings.SupportedCulturesStatistics.IsValidIndex(LocalizationTarget->Settings.NativeCultureIndex);
}
FReply SLocalizationDashboardTargetRow::ImportDialogue()
{
ULocalizationTarget* const LocalizationTarget = GetTarget();
if (LocalizationTarget)
{
// Warn about potentially loaded audio assets
{
TArray<ULocalizationTarget*> Targets;
Targets.Add(LocalizationTarget);
if (!LocalizationCommandletTasks::ReportLoadedAudioAssets(Targets))
{
return FReply::Handled();
}
}
// Execute import dialogue.
const TSharedPtr<SWindow> ParentWindow = FSlateApplication::Get().FindWidgetWindow(AsShared());
LocalizationCommandletTasks::ImportDialogueForTarget(ParentWindow.ToSharedRef(), LocalizationTarget);
}
return FReply::Handled();
}
bool SLocalizationDashboardTargetRow::CanCountWords() const
{
ULocalizationTarget* const LocalizationTarget = GetTarget();
return LocalizationTarget && LocalizationTarget->Settings.SupportedCulturesStatistics.Num() > 0 && LocalizationTarget->Settings.SupportedCulturesStatistics.IsValidIndex(LocalizationTarget->Settings.NativeCultureIndex);
}
FReply SLocalizationDashboardTargetRow::CountWords()
{
bool HasSucceeded = false;
ULocalizationTarget* const LocalizationTarget = GetTarget();
if (LocalizationTarget)
{
const TSharedPtr<SWindow> ParentWindow = FSlateApplication::Get().FindWidgetWindow(AsShared());
LocalizationCommandletTasks::GenerateWordCountReportForTarget(ParentWindow.ToSharedRef(), LocalizationTarget);
UpdateTargetFromReports();
}
return FReply::Handled();
}
bool SLocalizationDashboardTargetRow::CanCompileText() const
{
ULocalizationTarget* const LocalizationTarget = GetTarget();
return LocalizationTarget && LocalizationTarget->Settings.SupportedCulturesStatistics.Num() > 0 && LocalizationTarget->Settings.SupportedCulturesStatistics.IsValidIndex(LocalizationTarget->Settings.NativeCultureIndex);
}
FReply SLocalizationDashboardTargetRow::CompileText()
{
ULocalizationTarget* const LocalizationTarget = GetTarget();
if (LocalizationTarget)
{
// Execute compile.
const TSharedPtr<SWindow> ParentWindow = FSlateApplication::Get().FindWidgetWindow(AsShared());
LocalizationCommandletTasks::CompileTextForTarget(ParentWindow.ToSharedRef(), LocalizationTarget);
}
return FReply::Handled();
}
FReply SLocalizationDashboardTargetRow::EnqueueDeletion()
{
PropertyUtilities->EnqueueDeferredAction(FSimpleDelegate::CreateSP(this, &SLocalizationDashboardTargetRow::Delete));
return FReply::Handled();
}
void SLocalizationDashboardTargetRow::Delete()
{
static bool IsExecuting = false;
if (!IsExecuting)
{
TGuardValue<bool> ReentranceGuard(IsExecuting, true);
ULocalizationTarget* const LocalizationTarget = GetTarget();
if (LocalizationTarget)
{
// Setup dialog for deleting target.
const FText FormatPattern = NSLOCTEXT("LocalizationDashboard", "DeleteTargetConfirmationDialogMessage", "This action can not be undone and data will be permanently lost. Are you sure you would like to delete {TargetName}?");
FFormatNamedArguments Arguments;
Arguments.Add(TEXT("TargetName"), FText::FromString(LocalizationTarget->Settings.Name));
const FText MessageText = FText::Format(FormatPattern, Arguments);
const FText TitleText = NSLOCTEXT("LocalizationDashboard", "DeleteTargetConfirmationDialogTitle", "Confirm Target Deletion");
switch(FMessageDialog::Open(EAppMsgType::OkCancel, MessageText, &TitleText))
{
case EAppReturnType::Ok:
{
LocalizationTarget->DeleteFiles();
// Close target editor.
if (TargetEditorDockTab.IsValid())
{
const TSharedPtr<SDockTab> OldTargetEditorTab = TargetEditorDockTab.Pin();
OldTargetEditorTab->RequestCloseTab();
}
// Remove this element from the parent array.
const TSharedPtr<IPropertyHandle> ParentPropertyHandle = TargetObjectPropertyHandle->GetParentHandle();
if (ParentPropertyHandle.IsValid() && ParentPropertyHandle->IsValidHandle())
{
const TSharedPtr<IPropertyHandleArray> ParentArrayPropertyHandle = ParentPropertyHandle->AsArray();
if (ParentArrayPropertyHandle.IsValid())
{
ParentArrayPropertyHandle->DeleteItem(TargetObjectPropertyHandle->GetIndexInArray());
}
}
}
break;
}
}
}
}
#undef LOCTEXT_NAMESPACE
| [
"tungnt.rec@gmail.com"
] | tungnt.rec@gmail.com |
fb15775b03923472cf9c501d6f23a9be8b9ffb4c | c4311c96d1c88a6e255d27353acb9e4320be9497 | /Guard/GameRender.h | 94b99d67ae24e246968bbf2f6e591aa584fdecab | [] | no_license | daxietx/2D-Small-Game-Guardian | d089d2d6a5bd14a8d084b9ecc8bb698872af133f | b4d7009d5db6397654bcf3a99c555546d7cc1f4e | refs/heads/master | 2020-12-30T16:59:32.497449 | 2017-05-12T03:48:49 | 2017-05-12T03:48:49 | 91,048,641 | 0 | 0 | null | null | null | null | GB18030 | C++ | false | false | 2,815 | h | #include "stdafx.h"
#include"Monster_Four.h"
#include "FireBomb.h"
#include "Castle.h"
#include "Bombshell.h"
#include "list"
#include <vector>
using namespace std;
class CGameSetting;
class CMusicPlay;
class GameRender
{
public:
GameRender(void);
~GameRender();
static GameRender* GetInstance();
void Init(HGE * hge);
bool FrameFunc();
void RenderFunc();
GAME_STATE GetState();
void Start();
void UpdateMonster();
void UpdateBoss();
void AddMonster();
void IsAutoCreatMonster();
void UpdateState();
void UpdateBombshell(float dt);
void UpdateMonNum();
void MonsterMove();
void UpdateSecondState();
void StartItemEffect(float x,float y);
void UpdateItemEffect(float dt);
void RenderItemEffect();
HGE * m_hge;
static GameRender *m_pGameRender;
HTEXTURE bg_Tex; //背景纹理
hgeSprite * bg_Spr; //背景的精灵
hgeSprite *cursor; //鼠标精灵
HTEXTURE cursorTex; //鼠标纹理
hgeGUI *cursorGui;
int guiId;
POINT p; //接受鼠标点击
bool mouseClicked; //判断鼠标是否点击
Castle castle;
hgeSprite *itemSpr; //道具特效的精灵
HTEXTURE itemEffectTex;
hgeParticleSystem* item_particle_effect;
const char* item_psi;
bool itemClicked;
vector<Monster > monster; //存储怪物
vector<Boss > bosses;
bool monsterIsDisappear;
int totalMonsterNum;
int monsterCreatNum;
int monsterDeadNum;
GAME_STATE gameState;
CGameSetting *m_pGameSetting; //游戏设置类指针
CMusicPlay *m_pMusicPlay; //音乐播放类指针
float oldTime;
float currentTime;
float lastTime;
float currentTime1;
float startTime2; //判断爆炸应该爆多久
float currentTime2;
vector<Bomb *> bombs; //存储所有炮
int weaponID; //炮ID
int doubleBombPrice; //双管炮价格
int firePrice; //喷火器价格
int bombshellPrice; //炸弹道具价格
int chengFangPrice; //城防道具价格
int FrameNum;
//道具的纹理,精灵 道具所在的矩形
HTEXTURE chengFangTex;
HTEXTURE bombshellTex;
HTEXTURE fireTex;
HTEXTURE doubleBombTex;
hgeSprite *chengFangspr;
hgeSprite *bombshellspr;
hgeSprite *firespr;
hgeSprite *doubleBombspr;
hgeRect chengFangRect;
hgeRect bombshellRect;
hgeRect fireRect;
hgeRect doubleBombRect;
//金钱的纹理,精灵
HTEXTURE moneyTex;
hgeSprite * moneySpr[10];
//血条的纹理,精灵
HTEXTURE bloodTex;
hgeSprite * bloodSpr[6];
int moneyNum; //金钱数
vector<Bombshell> bombshells;
//鼠标浮动的位置
float mouse_x;
float mouse_y;
bool hasBomb;//容器中有炸弹
bool fireAbleRender; //粒子可以渲染
bool isDeadBoss;
};
| [
"xieningtx@gmail.com"
] | xieningtx@gmail.com |
309cfa16d5c605a39149cd9fefa127532881ec1b | 0f0df7351c29d0ec9178afb44225c84d6e28ccd6 | /gdcm/gdcm-2.0.16/Testing/Source/MediaStorageAndFileFormat/Cxx/TestIconImage.cxx | 5ed486d7b7e6f762e33c2e887acfc5fad161ce49 | [
"BSD-3-Clause",
"BSD-2-Clause"
] | permissive | gbook/miview | 070cde96c1dfbc55ea6ff8f3a87bf7004c4862e2 | eea025e8e24fdd5e40986ee42eb8ea00e860b79a | refs/heads/master | 2021-01-10T11:16:50.802257 | 2015-07-16T19:44:45 | 2015-07-16T19:44:45 | 36,947,429 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,406 | cxx | /*=========================================================================
Program: GDCM (Grassroots DICOM). A DICOM library
Module: $URL$
Copyright (c) 2006-2010 Mathieu Malaterre
All rights reserved.
See Copyright.txt or http://gdcm.sourceforge.net/Copyright.html for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
#include "gdcmIconImage.h"
// FIXME:
// gdcmData/US-GE-4AICL142.dcm has a private data element that is an Icon:
/*
(6003,0010) LO [GEMS_Ultrasound_ImageGroup_001] # 30, 1 PrivateCreator
(6003,1010) SQ (Sequence with explicit length #=1) # 12522, 1 Unknown Tag & Data
(fffe,e000) na (Item with explicit length #=15) # 12514, 1 Item
(0002,0010) UI =LittleEndianExplicit # 20, 1 TransferSyntaxUID
(0008,0008) CS [DERIVED\SECONDARY] # 18, 2 ImageType
(0008,2111) ST [SmallPreview] # 12, 1 DerivationDescription
(0028,0002) US 3 # 2, 1 SamplesPerPixel
(0028,0004) CS [RGB] # 4, 1 PhotometricInterpretation
(0028,0006) US 0 # 2, 1 PlanarConfiguration
(0028,0010) US 64 # 2, 1 Rows
(0028,0011) US 64 # 2, 1 Columns
(0028,0014) US 1 # 2, 1 UltrasoundColorDataPresent
(0028,0100) US 8 # 2, 1 BitsAllocated
(0028,0101) US 8 # 2, 1 BitsStored
(0028,0102) US 7 # 2, 1 HighBit
(0028,0103) US 0 # 2, 1 PixelRepresentation
(6003,0010) LO [GEMS_Ultrasound_ImageGroup_001] # 30, 1 PrivateCreator
(6003,1011) OB 00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00... # 12288, 1 Unknown Tag & Data
(fffe,e00d) na (ItemDelimitationItem for re-encoding) # 0, 0 ItemDelimitationItem
*/
int TestIconImage(int, char *[])
{
gdcm::IconImage icon;
return 0;
}
| [
"gregory.a.book@gmail.com"
] | gregory.a.book@gmail.com |
8f8a43bdd39e3ecda480f42e49ed543fee1ad6da | 4ef911522f28384d38c26e2468d8a1ff858bb33b | /Particle.h | 19de15bfe4ccbf3693abb88839e4cf382a444391 | [] | no_license | fbgtoke/VJ3D | 215b5d24eacb663dc1809cdeeec07f68d622c6e2 | f4c399a6c5257f9b00015ac285ec6b2e579147c7 | refs/heads/master | 2021-09-03T10:20:05.448115 | 2018-01-08T10:05:30 | 2018-01-08T10:05:30 | 109,996,340 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 439 | h | #ifndef _PARTICLE_INCLUDE
#define _PARTICLE_INCLUDE
#include "Model.h"
#include "Tile.h"
class Particle : public Model {
public:
void init();
void update(int deltaTime) override;
void setAliveTime(int aliveTime);
void setColor(const glm::vec3& color);
static void generateExplosion(const glm::vec3& origin);
private:
float kGravity;
float kFriction;
int mAliveTime;
glm::vec3 mColor;
};
#endif // _PARTICLE_INCLUDE | [
"fbg.toke@gmail.com"
] | fbg.toke@gmail.com |
417bba01a6a05cb8876a17aad5a8465c95886be4 | 9b5e8dcc6af30dbed73ae09e6313410fe69a6cbf | /试题泛做/AGC032C.cpp | d48ef0cb5c0c4b29499c812583f19e3588f39c66 | [] | no_license | learn22coding/IOI2020Homework | 8c1a2d1a6488874c1a07fc5b55f0a2a27563ee44 | 7186dd4a78f732abfcb2cf0453c87a4f0818aebe | refs/heads/master | 2023-03-17T10:28:06.804204 | 2020-01-03T06:40:37 | 2020-01-03T06:40:37 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 913 | cpp | #include <bits/stdc++.h>
using namespace std;
const int N = 100344;
int n, m;
vector<int> G[N];
int main() {
scanf("%d%d", &n, &m);
for (int i = 1; i <= m; i++) {
int x, y;
scanf("%d%d", &x, &y);
G[x].push_back(y);
G[y].push_back(x);
}
int cnt4 = 0, cnt6 = 0;
for (int i = 1; i <= n; i++) {
if ((int) G[i].size() & 1) {
puts("No");
return 0;
} else if ((int) G[i].size() == 4) {
cnt4++;
} else if ((int) G[i].size() >= 6) {
cnt6++;
}
}
if (cnt6 || cnt4 >= 3) {
puts("Yes");
return 0;
}
if (cnt4 == 2) {
for (int i = 1; i <= n; i++) {
if (G[i].size() == 2) {
int x = G[i][0], y = G[i][1];
if (x == y) {
puts("Yes");
return 0;
}
for (auto &t : G[x]) if (t == i) {t = y; break;}
for (auto &t : G[y]) if (t == i) {t = x; break;}
}
}
}
puts("No");
}
| [
"flx1260085323@163.com"
] | flx1260085323@163.com |
3f1ae44d5b8da5add0c2d53d9071f8406a6bbdd3 | 93353cdfaabbec0963d37d5aa25a3ce576f95a2e | /src/handler/product_handler.cpp | da10437764465af16423d5a5decd44c01663241f | [] | no_license | pluveto/ecomm | 6c9535efca7f6a9882bc5f1fe098057c8271f2cc | 7aba14715c62f48e90e3e1d2dfebd9db6f906868 | refs/heads/main | 2023-05-12T14:17:24.599264 | 2021-05-30T16:30:49 | 2021-05-30T16:30:49 | 369,792,717 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 17,126 | cpp | /**
* @file product_handler.cpp
* @author Pluveto (pluvet@foxmail.com)
* @brief
* @version 0.1
* @date 2021-05-23
*
* @copyright Pluveto (Zhang Zijing), Incolore Team. All Rights Reserved.
*
*/
#include <ecomm/handler/product_handler.hpp>
#include <regex>
#include <ecomm/util.hpp>
#include <ctime>
#include <ecomm/model/food_product.hpp>
#include <ecomm/model/dress_product.hpp>
#include <ecomm/model/book_product.hpp>
namespace ecomm
{
namespace handler
{
product_handler::product_handler(ecomm::ioc_container *const iocc) : base_handler(iocc)
{
this->_callback = std::bind(&product_handler::handle, this, std::placeholders::_1);
this->_product_service = iocc->resolve<service::product_service>("product_service");
}
void product_handler::handle(std::vector<std::string> args)
{
this->_current_user = this->_iocc->resolve<model::user_abstract>("current_user");
if (args.size() == 1)
{
printf("Type `help %s` for details.\n", args[0].c_str());
return;
}
if (args.size() == 2)
{
if (args[1] == "add")
{
this->handle_add(args);
return;
}
else if (args[1] == "remove")
{
this->handle_remove(args);
return;
}
else if (args[1] == "list")
{
this->handle_list(args);
return;
}
else if (args[1] == "discount")
{
this->handle_discount(args);
return;
}
printf("Type `help %s` for details.\n", args[0].c_str());
}
if (args.size() == 3)
{
if (args[1] == "view")
{
this->handle_view(args);
return;
}
else if (args[1] == "edit")
{
this->handle_edit(args);
return;
}
else if (args[1] == "list")
{
this->handle_list(args);
return;
}
else if (args[1] == "search")
{
this->handle_search(args);
return;
}
printf("Type `help %s` for details.\n", args[0].c_str());
}
}
void product_handler::handle_view(std::vector<std::string> &args)
{
std::string id_str = args[2];
if (!util::is_integer(id_str))
{
printf("Invalid id: not a integer.\n");
return;
}
int id = std::atoi(id_str.c_str());
if (id <= 0)
{
printf("Invalid id: out of range.\n");
return;
}
auto prod = this->_product_service->get_by(u"id", std::to_string(id));
if (nullptr == prod)
{
printf("Not found.\n");
return;
}
std::cout << prod->detail();
delete prod;
}
void product_handler::handle_add(std::vector<std::string> &args)
{
if (nullptr == this->_current_user)
{
printf("Please login.\n");
return;
}
if ("business" != this->_current_user->role)
{
printf("Permission denied for this operation. Role not permitted.\n");
return;
}
printf("Available product types:\n"
"1. Food\n"
"2. Dress\n"
"3. Book\n"
"Choose type: ");
int type_num = 0;
if (!util::expect_number_max_try(type_num, 1, 3, 3, "Choose a type: "))
{
return;
}
std::string type = std::vector<std::string>{"food", "dress", "book"}[type_num - 1];
printf("Selected type: %s\n", type.c_str());
double price = 0;
printf("Set price: ");
if (!util::expect_number_max_try(price, 0.01, 10000000000000.00, 3, "Set price: "))
{
return;
}
double discount = 0.00;
printf("Set discount: ");
if (!util::expect_number_max_try(discount, 0.00, 0.99, 3, "Set discount: "))
{
return;
}
double total_amount = 0;
printf("Set total amount: ");
if (!util::expect_number_max_try(total_amount, 0.01, 10000000000000.00, 3, "Set total amount: "))
{
return;
}
double available_amount = total_amount;
std::string title;
printf("Write down product name (title for display): \n");
if (!util::expect_string_max_try(title, 1, 128, 3, "Write down product name (title for display): \n"))
{
return;
}
std::string description;
printf("Write down product description: \n");
if (!util::expect_string_max_try(description, 0, 2048, 3, "Write down product description: \n"))
{
return;
}
std::string _ext_props;
model::product_abstract *new_product;
size_t uid = this->_current_user->id;
if (type == "food")
{
time_t current_ts, expired_at, manufactured_at;
current_ts = std::time(0);
printf("Input expiration time: ");
if (!util::expect_datetime_max_try(expired_at, current_ts, current_ts + 100L * 365L * 24L * 3600L, 3L, "Input expiration time: "))
{
return;
}
printf("Input manufacture time: ");
if (!util::expect_datetime_max_try(manufactured_at, current_ts, current_ts + 100L * 365L * 24L * 3600L, 3L, "Input manufacture time: "))
{
return;
}
new_product = new model::food_product(uid, price, discount, total_amount, available_amount, type, title, description, expired_at, manufactured_at);
}
else if (type == "dress")
{
std::string size;
printf("Write dress size: \n");
if (!util::expect_string_max_try(size, 1, 32, 3, "Write dress size: \n"))
{
return;
}
std::string brand;
printf("Write dress brand: \n");
if (!util::expect_string_max_try(brand, 1, 32, 3, "Write dress brand: \n"))
{
return;
}
new_product = new model::dress_product(uid, price, discount, total_amount, available_amount, type, title, description, size, brand);
}
else if (type == "book")
{
std::string author;
printf("Write book author: \n");
if (!util::expect_string_max_try(author, 1, 32, 3, "Write book author: \n"))
{
return;
}
std::string press;
printf("Write book press: \n");
if (!util::expect_string_max_try(press, 1, 32, 3, "Write book press: \n"))
{
return;
}
std::string isbn;
printf("Write book isbn: \n");
if (!util::expect_string_max_try(isbn, 1, 32, 3, "Write book isbn: \n"))
{
return;
}
new_product = new model::book_product(uid, price, discount, total_amount, available_amount, type, title, description, author, press, isbn);
new_product->id = 0;
spdlog::debug("new_product created.");
}
else
{
throw("Unexpected type.");
return;
}
printf("new_product type : %s\n", new_product->type.c_str());
this->_product_service->save(new_product);
delete new_product;
}
void product_handler::handle_edit(std::vector<std::string> &args)
{
if (nullptr == this->_current_user)
{
printf("Please login.\n");
return;
}
if ("business" != this->_current_user->role)
{
printf("Permission denied for this operation.\n");
return;
}
std::string id_str = args[2];
if (!util::is_integer(id_str))
{
printf("Invalid id: not a integer.\n");
return;
}
int id = std::atoi(id_str.c_str());
if (id <= 0)
{
printf("Invalid id: out of range.\n");
return;
}
std::u16string uid_limit = u" and uid = " + util::int_to_u16string(this->_current_user->id);
auto prod = this->_product_service->get_by(u"id", std::to_string(id), uid_limit);
if (nullptr == prod)
{
printf("Not found or not your product.\n");
return;
}
printf("Available operation:\n"
"1. Edit price\n"
"2. Edit discount\n"
"3. Increase stock\n"
"4. Decrease stock\n"
"Choose type: ");
int type = 0;
if (!util::expect_number_max_try(type, 1, 4, 3, "Choose a operation: "))
{
delete prod;
return;
}
if (type == 1)
{
double price = 0;
printf("Set price: ");
if (!util::expect_number_max_try(price, 0.01, 10000000000000.00, 3, "Set price: "))
{
delete prod;
return;
}
prod->price = price;
this->_product_service->save(prod);
delete prod;
return;
}
else if (type == 2)
{
double discount = 0.00;
printf("Set discount: ");
if (!util::expect_number_max_try(discount, 0.00, 0.99, 3, "Set discount: "))
{
delete prod;
return;
}
prod->discount = discount;
this->_product_service->save(prod);
delete prod;
return;
}
else if (type == 3)
{
double increase_amount = 0;
printf("Set increase amount: ");
if (!util::expect_number_max_try(increase_amount, 0.01, 10000000000000.00, 3, "Set increase amount: "))
{
delete prod;
return;
}
prod->total_amount += increase_amount;
prod->available_amount += increase_amount;
this->_product_service->save(prod);
delete prod;
return;
}
else if (type == 4)
{
double decrease_amount = 0;
printf("Set increase amount: ");
double max_decrease = prod->available_amount;
if (!util::expect_number_max_try(decrease_amount, 0.01, max_decrease, 3, "Set increase amount: "))
{
delete prod;
return;
}
prod->total_amount -= decrease_amount;
prod->available_amount -= decrease_amount;
this->_product_service->save(prod);
delete prod;
return;
}
}
void product_handler::handle_search(std::vector<std::string> &args)
{
spdlog::debug("product_handler::handle_search");
if (args.size() == 3)
{
auto keyword = args[2];
std::u16string additional_condition = u"";
auto list = this->_product_service->search_by(u"title", keyword, additional_condition);
if (list->size() == 0)
{
printf("No result.\n");
}
else
{
for (auto i : *list)
{
std::cout << i->brief();
delete i;
}
}
delete list;
}
}
void product_handler::handle_list(std::vector<std::string> &args)
{
spdlog::debug("product_handler::handle_list");
std::u16string additional_condition = u"";
if (args.size() == 3)
{
if (args[2] == "my")
{
if (nullptr == this->_current_user)
{
printf("Please login.\n");
return;
}
additional_condition = u" and uid = " + util::int_to_u16string(this->_current_user->id);
}
printf("Unknown operation.\n");
return;
}
spdlog::debug("fetch list");
auto list = this->_product_service->list_by(u"", "", additional_condition);
if (list->size() == 0)
{
printf("No result.\n");
}
else
{
for (auto i : *list)
{
std::cout << i->brief();
delete i;
}
}
delete list;
}
void product_handler::handle_remove(std::vector<std::string> &args)
{
if (nullptr == this->_current_user)
{
printf("Please login.\n");
return;
}
if ("business" != this->_current_user->role)
{
printf("Permission denied for this operation.\n");
return;
}
}
void product_handler::handle_discount(std::vector<std::string> &args)
{
if (nullptr == this->_current_user)
{
printf("Please login.\n");
return;
}
if ("business" != this->_current_user->role)
{
printf("Permission denied for this operation. Role not permitted.\n");
return;
}
printf("You're going to perform a batch discount action\n"
"Available product types:\n"
"1. Food\n"
"2. Dress\n"
"3. Book\n"
"Choose type: ");
int type_num = 0;
if (!util::expect_number_max_try(type_num, 1, 3, 3, "Choose a type: "))
{
return;
}
std::string type = std::vector<std::string>{"food", "dress", "book"}[type_num - 1];
printf("Selected type: %s\n", type.c_str());
double discount = 0.00;
printf("Set discount: ");
if (!util::expect_number_max_try(discount, 0.00, 0.99, 3, "Set discount: "))
{
return;
}
size_t aff = this->_product_service->update(u"discount", std::to_string(discount), u"type", type, (this->_current_user->id));
printf("%ld products affected.\n", aff);
return;
}
std::string product_handler::desc() const
{
return "Product operations.";
}
std::string product_handler::help() const
{
auto help_text = "-- Product --\n"
" {cmd} add\n"
" Add product.\n"
" {cmd} view ID\n"
" Show detail of product.\n"
" {cmd} edit ID\n"
" Edit product by id.\n"
" {cmd} discount\n"
" Batch set discount by type.\n"
" {cmd} list\n"
" List products.\n"
" {cmd} list my\n"
" List your products.\n"
" {cmd} search\n"
" Search products.\n";
return help_text;
}
}
} | [
"receding@protonmail.com"
] | receding@protonmail.com |
2e098b76aa1fb11bc0c0801e96ac1871766425b5 | 7ff69550416d7100e87869f2e3a708e4fb335e7c | /docker/dev/src/Utilities/itkImposeMinimaImageFilter.h | 676504c46e5c8275d73754dc97d5fcb905045b8a | [
"BSD-3-Clause"
] | permissive | rt106/rt106-wavelet-nuclei-segmentation | cdbbd5bb5eb3dacb0bf77dce527cd2e63f1b98a4 | ced313a818867113313ced8dbc081948100eb49c | refs/heads/master | 2021-09-04T09:19:46.376053 | 2018-01-17T17:04:06 | 2018-01-17T17:04:06 | 116,753,570 | 0 | 1 | BSD-3-Clause | 2018-01-09T16:31:09 | 2018-01-09T02:14:31 | C++ | UTF-8 | C++ | false | false | 4,570 | h | // Copyright (c) General Electric Company, 2017. All rights reserved.
/*=========================================================================
Author: Dirk Padfield
date: 03/03/2007
=========================================================================*/
#ifndef __itkImposeMinimaImageFilter_h
#define __itkImposeMinimaImageFilter_h
#include "itkImage.h"
//#include "itkReconstructionImageFilter.h"
#include "itkReconstructionByErosionImageFilter.h"
#include "itkInvertIntensityImageFilter.h"
#include "itkAddImageFilter.h"
#include "itkMinimumImageFilter.h"
#include "itkShiftScaleImageFilter.h"
//#include "FileDumper.h"
namespace itk
{
/** \class ImposeMinimaImageFilter
This filter imposes minima defined in a marker image on the grayscale
mask image.
*/
template < class TInputImage, class TMarkerImage, class TOutputImage >
class ITK_EXPORT ImposeMinimaImageFilter :
public ImageToImageFilter<TInputImage,TOutputImage>
{
public:
/** Run-time type information (and related methods). */
itkTypeMacro(ImposeMinimaImageFilter, ImageToImageFilter);
/** Extract dimension from input and output image. */
itkStaticConstMacro(ImageDimension, unsigned int, TInputImage::ImageDimension);
/** Some typedefs associated with the input images. */
typedef TInputImage InputImageType;
typedef typename InputImageType::Pointer InputImagePointer;
typedef typename InputImageType::ConstPointer InputImageConstPointer;
typedef typename InputImageType::RegionType InputImageRegionType;
typedef TOutputImage OutputImageType;
typedef typename OutputImageType::Pointer OutputImagePointer;
typedef typename OutputImageType::RegionType OutputImageRegionType;
/** Image typedef support. */
typedef typename InputImageType::PixelType InputImagePixelType;
typedef typename OutputImageType::PixelType OutputImagePixelType;
/** Standard class typedefs. */
typedef ImposeMinimaImageFilter Self;
typedef SmartPointer<Self> Pointer;
typedef SmartPointer<const Self> ConstPointer;
typedef ImageToImageFilter< TInputImage, TOutputImage > Superclass;
/** Some convenient typedefs. */
typedef TMarkerImage MarkerImageType;
typedef TInputImage MaskImageType;
typedef typename InputImageType::SizeType ISizeType;
typedef typename MarkerImageType::Pointer MarkerImagePointer;
typedef typename MarkerImageType::ConstPointer MarkerImageConstPointer;
typedef typename MarkerImageType::RegionType MarkerImageRegionType;
typedef typename MarkerImageType::PixelType MarkerImagePixelType;
typedef typename InputImageType::IndexType InputImageIndexType;
typedef typename MaskImageType::Pointer MaskImagePointer;
typedef typename MaskImageType::ConstPointer MaskImageConstPointer;
typedef typename MaskImageType::RegionType MaskImageRegionType;
typedef typename MaskImageType::PixelType MaskImagePixelType;
typedef typename OutputImageType::ConstPointer OutputImageConstPointer;
typedef typename OutputImageType::IndexType OutputImageIndexType;
/** Method for creation through the object factory. */
itkNewMacro(Self);
/** Set/Get the marker image. Traditionally, the marker image must
* be pixelwise less than or equal to the mask image (for dilation),
* however this filter implicitly applies a mask to force the
* constraint to hold. */
void SetMarkerImage(const MarkerImageType *);
const MarkerImageType* GetMarkerImage();
/** Set/Get the mask image. The mask image is used to "mask" the
* dilated marker image. The mask operation is a pixelwise
* minimum. */
void SetMaskImage(const MaskImageType *);
const MaskImageType* GetMaskImage();
/**
* Set/Get whether the connected components are defined strictly by
* face connectivity or by face+edge+vertex connectivity. Default is
* FullyConnectedOff. For objects that are 1 pixel wide, use
* FullyConnectedOn.
*/
itkSetMacro(FullyConnected, bool);
itkGetConstReferenceMacro(FullyConnected, bool);
itkBooleanMacro(FullyConnected);
protected:
ImposeMinimaImageFilter();
virtual ~ImposeMinimaImageFilter() {}
void PrintSelf(std::ostream& os, Indent indent) const;
void GenerateData ();
private:
ImposeMinimaImageFilter(const Self&); //purposely not implemented
void operator=(const Self&); //purposely not implemented
bool m_FullyConnected;
};
} // end namespace itk
#ifndef GEITK_MANUAL_INSTANTIATION
#include "itkImposeMinimaImageFilter.txx"
#endif
#endif
| [
"millerjv@ge.com"
] | millerjv@ge.com |
67419502ed8b12dccaf0e6e0cdca785b6b2f150e | 707a36a28efd9b68ac7a7636bba8f4f8eee2697c | /tensorflow/tensorflow/core/common_runtime/gpu/gpu_device.h | 5eae9c445db0694d33e9bb349ff8f9f8ba6bccf1 | [
"Apache-2.0"
] | permissive | mlsys-seo/ooo-backprop | f9e6e1e531dff2be45173dbc158db9d4a421d1f3 | 0beb419dabd0b55505fd07e715f257decf9420e3 | refs/heads/main | 2023-04-09T12:10:30.045508 | 2022-12-05T05:10:04 | 2022-12-05T05:10:04 | 452,698,031 | 24 | 4 | null | null | null | null | UTF-8 | C++ | false | false | 16,274 | h | /* Copyright 2015 The TensorFlow Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==============================================================================*/
#if !GOOGLE_CUDA && !TENSORFLOW_USE_ROCM
#error This file must only be included when building with Cuda or ROCm support
#endif
#ifndef TENSORFLOW_CORE_COMMON_RUNTIME_GPU_GPU_DEVICE_H_
#define TENSORFLOW_CORE_COMMON_RUNTIME_GPU_GPU_DEVICE_H_
#include <memory>
#include <string>
#include <unordered_map>
#include <vector>
#include "third_party/eigen3/unsupported/Eigen/CXX11/Tensor"
#include "tensorflow/core/common_runtime/device_factory.h"
#include "tensorflow/core/common_runtime/gpu/gpu_event_mgr.h"
#include "tensorflow/core/common_runtime/gpu/gpu_id.h"
#include "tensorflow/core/common_runtime/gpu/gpu_id_manager.h"
#include "tensorflow/core/common_runtime/gpu/gpu_id_utils.h"
#include "tensorflow/core/common_runtime/gpu_device_context.h"
#include "tensorflow/core/common_runtime/local_device.h"
#include "tensorflow/core/common_runtime/scoped_allocator_mgr.h"
#include "tensorflow/core/common_runtime/shared_counter.h"
#include "tensorflow/core/framework/allocator.h"
#include "tensorflow/core/framework/device_base.h"
#include "tensorflow/core/framework/op_kernel.h"
#include "tensorflow/core/framework/tensor.h"
#include "tensorflow/core/lib/core/status.h"
#include "tensorflow/core/lib/gtl/inlined_vector.h"
#include "tensorflow/core/platform/mutex.h"
#include "tensorflow/core/platform/stream_executor.h"
#include "tensorflow/core/platform/types.h"
#include "tensorflow/core/public/session_options.h"
namespace tensorflow {
class GPUKernelTracker;
class BaseGPUDevice : public LocalDevice {
public:
BaseGPUDevice(const SessionOptions& options, const std::string& name,
Bytes memory_limit, const DeviceLocality& locality,
TfGpuId tf_gpu_id, const std::string& physical_device_desc,
Allocator* gpu_allocator, Allocator* cpu_allocator,
bool sync_every_op);
~BaseGPUDevice() override;
// Initialize the device and return the status of initialization.
Status Init(const SessionOptions& options);
void Compute(OpKernel* op_kernel, OpKernelContext* context) override;
Status Sync() override;
void ComputeAsync(AsyncOpKernel* op_kernel, OpKernelContext* context,
AsyncOpKernel::DoneCallback done) override;
Status MakeTensorFromProto(const TensorProto& tensor_proto,
const AllocatorAttributes alloc_attrs,
Tensor* tensor) override;
void CopyTensorInSameDevice(const Tensor* input_tensor, Tensor* output_tensor,
const DeviceContext* device_context,
StatusCallback done) override;
// The caller owns the returned device.
PerOpGpuDevice* MakeGpuDevice() override;
Status ReinitializeGpuDevice(OpKernelContext* context, PerOpGpuDevice* device,
DeviceContext* dc,
Allocator* allocator) override;
// Returns the platform GPU id of this device within the native driver system;
// e.g., for CUDA and ROCm this is the ordinal of the GPU within the system.
int gpu_id() const {
PlatformGpuId platform_gpu_id;
TF_CHECK_OK(GpuIdManager::TfToPlatformGpuId(tf_gpu_id_, &platform_gpu_id));
return platform_gpu_id.value();
}
// The executor that provides control for the device; e.g., for CUDA this
// corresponds to the cuda context.
se::StreamExecutor* executor() const { return executor_; }
Allocator* GetScopedAllocator(AllocatorAttributes attr,
int64 step_id) override;
ScopedAllocatorMgr* GetScopedAllocatorMgr() const override {
return scoped_allocator_mgr_.get();
}
// The following two functions always return 0 unless one of the
// related experimental config options has been specified.
// If returned value is > 0 then GPU Memory chunks freed before this count
// are guaranteed not to be in use by any kernel pending on this device.
uint64 SafeAllocFrontier(uint64 old_value) override;
// Returns the number of kernels that have been queued for execution on
// the compute stream and are not yet known to have completed.
int PendingKernels();
int priority() const { return stream_->priority; }
// Helper method for unit tests to reset the streams. Never use in production.
static void TestOnlyReset();
protected:
Allocator* gpu_allocator_; // not owned
Allocator* cpu_allocator_; // not owned
se::StreamExecutor* executor_; // not owned
std::unique_ptr<ScopedAllocatorMgr> scoped_allocator_mgr_;
private:
friend class GPUDeviceTestHelper;
struct StreamGroup {
se::Stream* compute = nullptr;
#if TENSORFLOW_USE_ROCM
se::Stream* nccl = nullptr;
#endif
se::Stream* host_to_device = nullptr;
se::Stream* device_to_host = nullptr;
gtl::InlinedVector<se::Stream*, 4> device_to_device;
int priority = 0;
};
class StreamGroupFactory;
StreamGroup* stream_;
mutex scratch_init_mutex_;
char* scratch_ = nullptr;
GPUDeviceContext* device_context_;
GPUDeviceContext* sub_stream_device_context_;
StreamGroup* sub_stream_;
GpuDeviceInfo* gpu_device_info_ = nullptr;
mutex trace_mu_;
TfGpuId tf_gpu_id_;
const bool sync_every_op_ = false;
EventMgr* em_ = nullptr;
std::unique_ptr<thread::ThreadPool> thread_pool_;
std::unique_ptr<GPUKernelTracker> kernel_tracker_;
int32 pending_cap_ = 0;
bool timestamped_allocator_ = false;
bool do_ooo_backprop_ = false;
int capture_iter_ = -1;
std::string capture_op_name_;
// Initialize scratch buffers used by Eigen.
Status InitScratchBuffers();
void ReinitializeDevice(OpKernelContext* context, PerOpGpuDevice* device,
int stream_id, Allocator* allocator);
std::string ComputeOpKernelDebugString(const OpKernel& op_kernel,
const int& stream_id);
// This method returns an initialization status, in addition to
// calling the "done" StatusCallback, if there is a failure to
// allocate memory or if the tensor "from" is not DMA-copyable.
// If there is no error prior to enqueueing the copy, an OK status
// is returned.
Status MaybeCopyTensorToGPU(const AllocatorAttributes& alloc_attrs,
const Tensor& from, Tensor* to,
StatusCallback done);
bool IsCapturePhase();
};
// A per-compute-stream utility that keeps track of kernels that have been
// queued for execution but may not yet have terminated and also the queued
// time of the most recently terminated kernel.
class GPUKernelTracker {
public:
// Controls the strategy for inserting tracking events after GPU kernels.
// If max_interval >= 0, then insert an event after this many kernels
// if an event has not been inserted for another reason.
// If max_bytes > 0, then insert an event after kernels allocating this
// many bytes have been queued since the last event.
// If max_pending > 0, then track up to this many events at once. If
// this limit is reached the GPU::Compute() method will delay starting
// additional ops until some event completes. If 0 and one of the other
// fields is non-zero, then a reasonable default will be selected.
struct Params {
int max_interval = 0;
int max_bytes = 0;
int max_pending = 0;
Params(int mi, int mb, int mp)
: max_interval(mi), max_bytes(mb), max_pending(mp) {}
};
// If we're going to share a SharedCounter with an allocator, it's owned
// by the allocator because allocators are initialized once per process.
// Devices are per-session.
explicit GPUKernelTracker(const Params& params, Env* env,
se::Stream* compute_stream,
SharedCounter* timing_counter, Allocator* allocator,
EventMgr* event_manager)
: params_(params),
env_(env),
stream_(compute_stream),
timing_counter_(timing_counter),
allocator_(allocator),
em_(event_manager),
pending_kernels_(
params.max_pending > 0 ? std::max(8, 2 * params.max_pending) : 64) {
mem_since_last_ = 0;
if (!timing_counter_) {
// There's not a preexisting counter owned by GPUProcessState, i.e.
// pending_cap > 0 but timestamped_allocator == false.
owned_counter_.reset(new SharedCounter);
timing_counter_ = owned_counter_.get();
}
}
// Determine whether a GPU kernel should have a recording event queued
// immediately afterwards. If so, advance the counter and return the new
// counter value after enqueuing.
uint64 MaybeQueue(OpKernelContext* ctx);
// Record that a GPU kernel has just been enqueued on the compute stream.
// Inserts the supplied counter value in a new PendingKernel record appended
// to the end of the ring buffer then returns that same count.
// Caller is responsible for ensuring that RecordTerminate() is eventually
// called with the same counter value.
void RecordQueued(uint64 queued_count, int weight)
TF_EXCLUSIVE_LOCKS_REQUIRED(mu_);
// Takes a count value returned by RecordQueued and finds the corresponding
// PendingKernel record in the ring buffer. Marks the kernel as completed and
// advances the completion frontier accordingly.
void RecordTerminated(uint64 queued_count);
// Returns the largest timing count such that all kernels queued no
// later than that count are known to have terminated.
inline uint64 LastTerminatedCount(uint64 old_value) {
uint64 new_value = last_terminated_count_.load(std::memory_order_relaxed);
if (new_value == old_value) {
MaybeQueueProgressEvent();
}
return new_value;
}
// Returns the number of kernels enqueued that are not yet known to
// have terminated.
int NumPending() {
mutex_lock l(mu_);
return num_pending_;
}
// Yield current thread until number of pending kernels no longer
// exceeds the cap.
void PauseWhilePendingExceeds(int cap) TF_LOCKS_EXCLUDED(mu_) {
mutex_lock l(mu_);
while (num_pending_ > cap) {
VLOG(1) << "num_pending_=" << num_pending_ << " cap=" << cap;
pending_decreased_.wait(l);
}
}
private:
friend class GPUKernelTrackerTest;
Params params_;
Env* env_;
se::Stream* stream_;
SharedCounter* timing_counter_;
std::unique_ptr<SharedCounter> owned_counter_;
Allocator* allocator_ = nullptr;
EventMgr* em_ = nullptr;
std::atomic<uint64> last_terminated_count_ = {1};
void MaybeQueueProgressEvent();
// Records when a kernel was queued for execution. Kernel launches are
// identified by a unique count value from a per-GPU device timing counter.
struct PendingKernel {
uint64 queued_count;
int weight;
bool terminated;
PendingKernel(const PendingKernel& pk)
: queued_count(pk.queued_count),
weight(pk.weight),
terminated(pk.terminated) {}
PendingKernel() : queued_count(0), weight(0), terminated(false) {}
};
mutex mu_;
int32 mem_since_last_ TF_GUARDED_BY(mu_);
int32 ops_since_last_ TF_GUARDED_BY(mu_);
// Ring buffer of PendingKernel records.
std::vector<PendingKernel> pending_kernels_ TF_GUARDED_BY(mu_);
// Next unused slot in pending_kernels_.
int first_available_ TF_GUARDED_BY(mu_) = 0;
// Last completed PendingKernel such that all prior PendingKernels are
// also completed. With out-of-order completion there may be a mixture
// of completed and uncompleted entries between last_completed_ and
// first_available_.
int last_completed_ TF_GUARDED_BY(mu_) = -1;
// Sum of weights of the outstanding events marking tracked kernels.
int num_pending_ TF_GUARDED_BY(mu_) = 0;
condition_variable pending_decreased_ TF_GUARDED_BY(mu_);
};
class BaseGPUDeviceFactory : public DeviceFactory {
public:
Status ListPhysicalDevices(std::vector<string>* devices) override;
Status CreateDevices(const SessionOptions& options,
const std::string& name_prefix,
std::vector<std::unique_ptr<Device>>* devices) override;
Status GetDeviceDetails(int device_index,
std::unordered_map<string, string>* details) override;
struct InterconnectMap {
// Name of interconnect technology, if known.
std::string name;
// If possible, strength should approximate Gb/sec bandwidth rate.
// Where architecture-specific subclassing is not done that won't
// always be possible. The minimum expectation is that
// faster links should have a higher value than slower links.
int32 strength;
static const int kSameDeviceStrength;
static const int kStreamExecutorStrength;
std::set<std::pair<PlatformGpuId, PlatformGpuId>> directed_links;
};
protected:
// Populates *maps with interconnect maps for all local direct access
// pathways between GPUs.
virtual Status GetInterconnectMaps(
const std::vector<PlatformGpuId>& visible_gpu_order,
se::Platform* gpu_manager, std::vector<InterconnectMap>* maps);
struct TfGpuIdHash {
std::size_t operator()(const TfGpuId& id) const noexcept {
return std::hash<int>{}(id.value());
}
};
typedef std::unordered_map<TfGpuId, DeviceLocality, TfGpuIdHash> LocalityMap;
// Populates *localities with the DeviceLocality descriptor for
// every TfGpuId.
virtual Status GetDeviceLocalities(
int num_tf_gpus, const std::vector<InterconnectMap>& interconnects,
LocalityMap* localities);
private:
// Creates a BaseGPUDevice associated with 'tf_gpu_id', allocates (strictly)
// 'memory_limit' bytes of GPU memory to it, and adds it to the 'devices'
// vector.
Status CreateGPUDevice(const SessionOptions& options,
const std::string& name_prefix, TfGpuId tf_gpu_id,
int64 memory_limit, const DeviceLocality& dev_locality,
std::vector<std::unique_ptr<Device>>* devices);
virtual std::unique_ptr<BaseGPUDevice> CreateGPUDevice(
const SessionOptions& options, const string& name, Bytes memory_limit,
const DeviceLocality& dev_locality, TfGpuId tf_gpu_id,
const string& physical_device_desc, Allocator* gpu_allocator,
Allocator* cpu_allocator) = 0;
Status EnablePeerAccess(const std::vector<PlatformGpuId>& visible_gpu_order);
// Returns into 'ids' the list of valid platform GPU ids, in the order that
// they should map to TF GPU ids "/device:GPU:0", "/device:GPU:1", etc,
// based upon 'visible_gpu_order' which was generated by parsing
// GPUOptions::visible_device_list which is a comma-separated list of CUDA or
// ROCm GPU ids.
Status GetValidDeviceIds(const std::vector<PlatformGpuId>& visible_gpu_order,
std::vector<PlatformGpuId>* ids);
// Cache the valid device IDs if not already cached. Cached IDs are stored in
// field cached_device_ids_. Passes {0, 1, ..., num_devices-1} to
// GetValidDeviceIds, so this should only be used in functions where all
// devices should be treated as visible, like ListPhysicalDevices.
Status CacheDeviceIds();
// visible_gpu_initialized_[platform_gpu_id] is true if visible GPU
// platform_gpu_id has been initialized by the process.
std::unordered_map<int, bool> visible_gpu_initialized_;
// Cached device IDs, as returned by GetValidDeviceIds when every physical
// device is visible. Cache should not be used if some devices are not
// visible.
std::vector<PlatformGpuId> cached_device_ids_;
};
} // namespace tensorflow
#endif // TENSORFLOW_CORE_COMMON_RUNTIME_GPU_GPU_DEVICE_H_
| [
"shie44167@gmail.com"
] | shie44167@gmail.com |
a8a31a92aa6345cda6bb5ae8c3e9abeabb5b7e54 | 5ca23ba036c710b6f3c1359385e53b36de63a0a2 | /app/src/main/jni/conn/Hound.cpp | 79339a3bba0fcc3cba97b295e9d6e4127164e084 | [
"MIT"
] | permissive | ZhangLang001/dex-hdog | 737a239741c9a38f3350cbd7ffa310d86d46e21c | 8b738546b1a7f7d174f2533e5f3f87e55fae690d | refs/heads/master | 2021-06-12T15:37:50.527266 | 2017-04-11T11:22:34 | 2017-04-11T11:22:34 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,787 | cpp | //
// Created by 薛祥清 on 2017/3/31.
//
#include "Hound.h"
static JNINativeMethod gMethods[] = {
{"isRunning", "(Ljava/lang/String;)Z", (void *) isRunning},
};
jint JNI_OnLoad(JavaVM *vm, void *reserved) {
LOGI("Start >>> JNI_OnLoad");
JNIEnv *env = NULL;
jint result = -1;
if (vm->GetEnv((void **) &env, JNI_VERSION_1_6) != JNI_OK) {
return result;
}
const char *CLASS_NAME = "cc/gnaixx/hdog/util/JniUtil";
jclass clazz = env->FindClass(CLASS_NAME);
if (clazz == NULL) {
LOGE("Find %s failed !!!", CLASS_NAME);
return JNI_FALSE;
}
if (env->RegisterNatives(clazz, gMethods, NELEM(gMethods)) != JNI_OK) {
LOGE("Register natives failed !!!");
}
return JNI_VERSION_1_6;
}
jboolean isRunning(JNIEnv *env, jclass clazz, jstring jpackageName) {
LOGI("%d",getuid());
if(setuid(0) == -1){
printf("Get root failed: %d, %s\n", errno, strerror(errno));
}
LOGI("%d", getuid());
const char *packageName = env->GetStringUTFChars(jpackageName, NULL);
int isRunning = JNI_FALSE;
char cmd[256];
char process[256];
char buff[1024];
sprintf(cmd, "ps | grep %s", packageName);
FILE *fp = popen(cmd, "r");
if (fp == NULL) {
printf("Exec popen failed {%d, %s}\n", errno, strerror(errno));
}else {
while (fgets(buff, sizeof(buff), fp) != NULL) {
uint32_t pid = 0;
sscanf(buff, "%*s\t%d %*d\t%*d %*d %*x %*x %*c %s", &pid, process);
//printf("Read pid:%d, process:%s\n", pid, targetProcess);
if (strcmp(process, packageName) == 0) {
isRunning = JNI_TRUE;
break;
}
}
fclose(fp);
fp = NULL;
}
return isRunning;
} | [
"990828785@qq.com"
] | 990828785@qq.com |
93918fdb5d8e9ae93b8fe6e0116df508885d53d6 | a5938b70a2db3763365e57f5adae334c4dd5953c | /WTL/LibraryDlgDemo/LibraryDlgDemo/LibraryDlgDemo.cpp | 19ce743f75a331e18d62faed89ceb79c6dd7fdc3 | [] | no_license | jerryhanhuan/test-code-backup | 7dea8a8eb4209dc241dae1864df6b1eb1a48c7bd | 2ebf0b1cb6715f66ea4c0b3153d426652ce9235f | refs/heads/master | 2021-01-22T22:57:25.097424 | 2014-09-17T02:31:47 | 2014-09-17T02:31:47 | null | 0 | 0 | null | null | null | null | GB18030 | C++ | false | false | 355 | cpp | // LibraryDlgDemo.cpp : 定义控制台应用程序的入口点。
//
#include "stdafx.h"
#include <Windows.h>
#include "WTL_Dlg_DLL.h"
int _tmain(int argc, _TCHAR* argv[])
{
printf("3S后调用DLL中的WTL对话框!!!\r\n");
Sleep(3000);
ShowDlg();
printf("调用DLL中的WTL对话框完毕,程序退出!\r\n");
return 0;
}
| [
"wubuxiansheng@gmail.com"
] | wubuxiansheng@gmail.com |
76d3da63d97d415eff08997e468c733cdbda0ea3 | caf6a8ac778eeb3183a7a35523044a5905519b76 | /libs/crashrpt/src/CrashRpt.cpp | b3c0b69ad0194d45947955bb6679fc57e7ee6ca0 | [
"Zlib"
] | permissive | odasm/coh-original-server-vs2010 | ec8ddd227d6d99e08e562b2c0b08df20e06eb02c | 479e4baccd5b2688c216674492c4b87e4562595c | refs/heads/master | 2020-05-16T07:21:09.364167 | 2019-04-22T03:21:57 | 2019-04-22T03:21:57 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,306 | cpp | ///////////////////////////////////////////////////////////////////////////////
//
// Module: CrashRpt.cpp
//
// Desc: See CrashRpt.h
//
// Copyright (c) 2003 Michael Carruth
//
///////////////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "CrashRpt.h"
#include "CrashHandler.h"
#ifdef _DEBUG
#define CRASH_ASSERT(pObj) \
if (!pObj || sizeof(*pObj) != sizeof(CCrashHandler)) \
DebugBreak()
#else
#define CRASH_ASSERT(pObj)
#endif // _DEBUG
BOOL WINAPI
DllMain(HINSTANCE hinstDLL,ULONG fdwReason,LPVOID lpvReserved)
{
return TRUE;
}
LPVOID CrashRptInstall(LPGETLOGFILE pfn)
{
CCrashHandler *pImpl = new CCrashHandler(pfn);
CRASH_ASSERT(pImpl);
// Setup a default way to report errors.
CrashRptSetFTPConduit(pImpl, _T("errors.coh.com"), _T("errors"), _T("kicks"));
return pImpl;
}
void CrashRptUninstall(LPVOID lpState)
{
CCrashHandler *pImpl = (CCrashHandler*)lpState;
CRASH_ASSERT(pImpl);
delete pImpl;
}
void CrashRptAddFile(LPVOID lpState, LPCTSTR lpFile, LPCTSTR lpDesc)
{
CCrashHandler *pImpl = (CCrashHandler*)lpState;
CRASH_ASSERT(pImpl);
pImpl->AddFile(lpFile, lpDesc);
}
void CrashRptGenerateErrorReport(LPVOID lpState, PEXCEPTION_POINTERS pExInfo)
{
CCrashHandler *pImpl = (CCrashHandler*)lpState;
CRASH_ASSERT(pImpl);
pImpl->GenerateErrorReport(pExInfo, "UnknownAuth", "UnknownEntity", "UnknownShard", "UnknownShardTime", "UnknownVersion", "UnknownMessage", "UnknownGLFileName", "UnknownLauncherLogFile", GetCurrentThreadId());
}
int CrashRptGenerateErrorReport2(LPVOID lpState, PEXCEPTION_POINTERS pExInfo, const char *szAuth, const char *szEntity, const char *szShard, const char *szShardTime, const char *szVersion, const char *szMessage, const char *glReportFileName, const char *launcherLogFileName)
{
CCrashHandler *pImpl = (CCrashHandler*)lpState;
CRASH_ASSERT(pImpl);
pImpl->GenerateErrorReport(pExInfo, szAuth, szEntity, szShard, szShardTime, szVersion, szMessage, glReportFileName, launcherLogFileName, GetCurrentThreadId());
return EXCEPTION_EXECUTE_HANDLER;
}
int CrashRptGenerateErrorReport3(LPVOID lpState, PEXCEPTION_POINTERS pExInfo, const char *szAuth, const char *szEntity, const char *szShard, const char *szShardTime, const char *szVersion, const char *szMessage, const char *glReportFileName, const char *launcherLogFileName, DWORD dwThreadID)
{
CCrashHandler *pImpl = (CCrashHandler*)lpState;
CRASH_ASSERT(pImpl);
pImpl->GenerateErrorReport(pExInfo, szAuth, szEntity, szShard, szShardTime, szVersion, szMessage, glReportFileName, launcherLogFileName, dwThreadID);
return EXCEPTION_EXECUTE_HANDLER;
}
void CrashRptAbortErrorReport(LPVOID lpState)
{
CCrashHandler *pImpl = (CCrashHandler*)lpState;
CRASH_ASSERT(pImpl);
pImpl->AbortErrorReport();
}
void CrashRptSetFTPConduit(LPVOID lpState, LPCTSTR hostname, LPCTSTR username, LPCTSTR password)
{
CCrashHandler *pImpl = (CCrashHandler*)lpState;
CRASH_ASSERT(pImpl);
if(pImpl->m_reportConduit)
{
delete pImpl->m_reportConduit;
pImpl->m_reportConduit = NULL;
}
pImpl->m_reportConduit = new CFtpConduit(hostname, username, password);
}
| [
"Woovie"
] | Woovie |
691c206032918f3d87edbb348a681547a8308377 | 816425d3a8d4ee9ba18e0882eee9df2f3f769c0a | /include/rbc/msgs/geometry_msgs/pose_with_covariance_stamped.h | 0badddbbd6113dd76b67222b4499ec3c5cf3a1f9 | [] | no_license | msinvent/rbcpp | 770655585f2c47086ef640bb0ac54b132c4f3844 | 57ceabf6186861c987a92d98f1bd65859615f10f | refs/heads/master | 2020-05-25T06:18:04.379213 | 2019-03-23T10:28:27 | 2019-03-23T10:28:27 | 187,664,974 | 2 | 0 | null | 2019-05-20T15:14:28 | 2019-05-20T15:14:27 | null | UTF-8 | C++ | false | false | 1,297 | h | //
// Created by Julian on 27.10.18.
//
#ifndef ROSBRIDGECLIENT_POSE_WITH_COVARIANCE_STAMPED_H
#define ROSBRIDGECLIENT_POSE_WITH_COVARIANCE_STAMPED_H
#include <cpprest/json.h>
#include <rbc/msgs/ros_type_base.h>
#include <rbc/msgs/std_msgs/header.h>
#include <rbc/msgs/geometry_msgs/pose_with_covariance.h>
namespace rbc::msgs::geometry_msgs
{
struct PoseWithCovarianceStamped : public ROSTypeBase
{
PoseWithCovarianceStamped();
PoseWithCovarianceStamped(const Point &p, const Quaternion &q, const std::array<double, 36> &arr, std::string frame_id = "world");
PoseWithCovarianceStamped(const Pose &pose, const std::array<double, 36> &arr, std::string frame_id = "world");
explicit PoseWithCovarianceStamped(const PoseWithCovariance &pose, std::string frame_id = "world");
explicit PoseWithCovarianceStamped(const web::json::value &response);
~PoseWithCovarianceStamped() final = default;
PoseWithCovariance pose;
std_msgs::Header header;
};
} // namespace rbc::msgs::geometry_msgs
std::ostream &operator<<(std::ostream &os, const rbc::msgs::geometry_msgs::PoseWithCovarianceStamped &p);
std::ostream &
operator<<(std::ostream &os, const std::shared_ptr<rbc::msgs::geometry_msgs::PoseWithCovarianceStamped> &p);
#endif //ROSBRIDGECLIENT_POSE_WITH_COVARIANCE_STAMPED_H
| [
"gjulian@uos.de"
] | gjulian@uos.de |
9f6db5582c7e7382497cc4b4c3863176bd6308a7 | 7983da2a6f9096e6c547fb67a2b638302c55809e | /unit.h | ecdfafdec656bc1882b0741392b2db44cc11a534 | [] | no_license | KertAles/Osvajalec-Game | ff8a4c4df491550ecc8f3f065f7b0cbd7db7890d | 64f6a51f3793918463abbd8dcb71ffe81f93d142 | refs/heads/master | 2022-11-14T08:41:20.141703 | 2020-07-05T09:43:26 | 2020-07-05T09:43:26 | 277,158,666 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,766 | h | #ifndef UNIT_H
#define UNIT_H
#include "mainwindow.h"
#include "gridsquare.h"
#include "player.h"
#include "upkeep.h"
#include <QList>
#include <QGraphicsItem>
#include <QGraphicsSceneMouseEvent>
class Player;
class QueueBuilding;
class Unit : public QObject , public QGraphicsItemGroup
{
Q_OBJECT
Q_PROPERTY(QPointF pos READ pos WRITE setPos)
protected:
QGraphicsPixmapItem* unitPix;
QGraphicsEllipseItem* background;
GridSquare* position;
bool moving;
int maxHp;
int hp;
int attack;
int defense;
int range;
int los; //line of sight
Upkeep upkeep;
double movesLeft;
double maxMoves;
Player* owner;
char type;
public:
Unit();
void init();
Player* getOwner();
GridSquare* getPosition();
int getLoS();
int getMaxHp() { return maxHp; }
int getHp() { return hp; }
double getMovesLeft() { return movesLeft; }
double getMaxMoves() { return maxMoves; }
char getType() { return type; }
Upkeep getUpkeep() { return upkeep; }
bool isMoving() { return moving; }
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
void move(GridSquare* newPos); //en premik
void moveTo(GridSquare* newPos); //celotna pot, kombinirano s pathfinder
void killMoves() { movesLeft = 0; }
void resetMoves() { movesLeft = maxMoves; }
bool attackUnit(Unit* enemy);
void attackUnitAI(Unit* enemy);
bool attackBuilding(Building* enemy);
void attackBuildingAI(Building* enemy);
bool inRange(Unit* enemy);
bool inRange(Building* enemy);
bool inRange(GridSquare* pos);
void attacked(int dmg, Unit* opponent);
int biteBack(Unit* opponent);
signals:
public slots:
};
#endif // UNIT_H
| [
"ales.kert@gmail.com"
] | ales.kert@gmail.com |
de6d8e83cbd812a151946d012d9f08c65a74963a | 863e81df328820e02685fa1b8f4eebf00f80e999 | /AlcantareaInjector.cpp | 4a040f221d6e03181e22abb560f0a85fbb989bfe | [
"CC-BY-4.0"
] | permissive | alisci01/Alcantarea | 0a06fca106fc6a882108fd6309c846266d4533e3 | 5dbd6d55422de47a6b5a08dd1e7048c409be83d4 | refs/heads/master | 2020-03-15T09:22:00.790080 | 2018-05-04T02:23:10 | 2018-05-04T02:23:10 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,310 | cpp | #include <string>
#include <vector>
#include <algorithm>
#include <windows.h>
bool InjectDLL(HANDLE hProcess, const char* dllname)
{
SIZE_T bytesRet = 0;
DWORD oldProtect = 0;
LPVOID remote_addr = NULL;
HANDLE hThread = NULL;
size_t len = strlen(dllname) + 1;
remote_addr = ::VirtualAllocEx(hProcess, 0, 1024, MEM_COMMIT|MEM_RESERVE, PAGE_EXECUTE_READWRITE);
if(remote_addr==NULL) { return false; }
::VirtualProtectEx(hProcess, remote_addr, len, PAGE_EXECUTE_READWRITE, &oldProtect);
::WriteProcessMemory(hProcess, remote_addr, dllname, len, &bytesRet);
::VirtualProtectEx(hProcess, remote_addr, len, oldProtect, &oldProtect);
hThread = ::CreateRemoteThread(hProcess, NULL, 0, (LPTHREAD_START_ROUTINE)((void*)&LoadLibraryA), remote_addr, 0, NULL);
::WaitForSingleObject(hThread, 5000);
::VirtualFreeEx(hProcess, remote_addr, 0, MEM_RELEASE);
return true;
}
const char* GetMainModuleFilename()
{
static char s_full_path[MAX_PATH+1];
static char *s_filename = nullptr;
if(!s_filename) {
::GetModuleFileNameA(nullptr, s_full_path, sizeof(s_full_path));
for(int i=0; s_full_path[i]!='\0'; ++i) {
if(s_full_path[i]=='\\') {
s_filename = s_full_path+i+1;
}
}
}
return s_filename;
}
int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE prev, LPWSTR cmd, int show)
{
if(__argc<2) {
printf("usage: %s [path-to-exe or pid:ProcessID] [path to dll(s)] (/suspended)\n", GetMainModuleFilename());
return 0;
}
std::vector<std::string> dll_paths;
std::wstring exe_path;
DWORD exe_pid = 0;
DWORD flags = NORMAL_PRIORITY_CLASS;
if(wcsncmp(__wargv[1], L"/pid:", 5)==0) {
swscanf(__wargv[1]+5, L"%u", &exe_pid);
}
else {
exe_path = __wargv[1];
}
for(int i=2; i<__argc; ++i) {
if(wcscmp(__wargv[i], L"/suspended")==0) {
flags |= CREATE_SUSPENDED;
}
else {
char mbs[MAX_PATH+1];
size_t l = wcstombs(mbs, __wargv[i], sizeof(mbs));
mbs[l] = '\0';
dll_paths.push_back(mbs);
}
}
if(!exe_path.empty()) {
STARTUPINFOW si;
PROCESS_INFORMATION pi;
::ZeroMemory(&si, sizeof(si));
::ZeroMemory(&pi, sizeof(pi));
si.cb = sizeof(si);
BOOL ret = ::CreateProcessW(nullptr, (wchar_t*)exe_path.c_str(), nullptr, nullptr, FALSE,
flags, nullptr, nullptr, &si, &pi);
if(ret) {
std::for_each(dll_paths.begin(), dll_paths.end(), [&](const std::string &dll){
InjectDLL(pi.hProcess, dll.c_str());
});
::CloseHandle(pi.hThread);
::CloseHandle(pi.hProcess);
return pi.dwProcessId;
}
}
else if(exe_pid!=0) {
HANDLE process = ::OpenProcess(PROCESS_ALL_ACCESS, FALSE, exe_pid);
if(process!=nullptr) {
std::for_each(dll_paths.begin(), dll_paths.end(), [&](const std::string &dll){
InjectDLL(process, dll.c_str());
});
::CloseHandle(process);
return exe_pid;
}
}
return 0;
}
| [
"saint.skr@gmail.com"
] | saint.skr@gmail.com |
514a17863b9dc37d60403c1db5fb2ab5ab2b18f1 | 9cc01c3e1ba6428f649341da0e94efc8f38bd03b | /StkUI/Dialog/SetBasedataDlg.h | 748312760d78f92e52ce5217997e81501a5ed073 | [] | no_license | late0001/tradingStrategyGM | da2780e235254e39fc61ded142f4c8cbf3e2c4cf | b969fd0b286849e3a6d23461c19277ef58993b82 | refs/heads/master | 2021-03-29T00:26:01.204741 | 2020-03-17T08:33:11 | 2020-03-17T08:33:11 | 247,908,308 | 3 | 1 | null | null | null | null | GB18030 | C++ | false | false | 2,077 | h | #if !defined(AFX_SETBASEDATADLG_H__03465F7B_741C_4358_A2F2_636329DF6D09__INCLUDED_)
#define AFX_SETBASEDATADLG_H__03465F7B_741C_4358_A2F2_636329DF6D09__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// SetBasedataDlg.h : header file
//
#include "SetGroupDlg.h"
/////////////////////////////////////////////////////////////////////////////
// CSetBasedataDlg dialog
/***
设置除权除息资料的对话框
*/
class CSetBasedataDlg : public CPropertyPageEx
{
DECLARE_DYNCREATE(CSetBasedataDlg)
// Construction
public:
CSetBasedataDlg( ); // standard constructor
void OnCompleted( );
// Dialog Data
//{{AFX_DATA(CSetBasedataDlg)
enum { IDD = IDD_SETBASEDATA };
CButton m_btnSave;
CEdit m_editTotal;
CEdit m_editCorp;
CEdit m_editNational;
CEdit m_editH;
CEdit m_editB;
CEdit m_editA;
CStatic m_staticStock;
CDomainListBox m_listStockSrc;
CDomainComboBox m_comboGroupSrc;
CEdit m_editCode;
CString m_strA;
CString m_strB;
CString m_strH;
CString m_strNational;
CString m_strCorp;
CString m_strTotal;
//}}AFX_DATA
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CSetBasedataDlg)
public:
virtual BOOL OnKillActive();
virtual BOOL PreTranslateMessage(MSG* pMsg);
virtual void OnCancel();
virtual void OnOK();
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
CString m_strCurStockCode;
void EnableEdit( BOOL bEnable );
void LoadBasedata( CString strStockCode );
BOOL StoreBasedata( CString strStockCode );
// Generated message map functions
//{{AFX_MSG(CSetBasedataDlg)
virtual BOOL OnInitDialog();
afx_msg void OnChangeEditcode();
afx_msg void OnSelchangeComboGroupsrc();
afx_msg void OnSelchangeListStocksrc();
afx_msg void OnSave();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_SETBASEDATADLG_H__03465F7B_741C_4358_A2F2_636329DF6D09__INCLUDED_)
| [
"jdqiu@sina.cn"
] | jdqiu@sina.cn |
0f3dec517870f0106aed1cbfc27314564639e7b3 | 742344de1454de62c49f32dccdeb4235973d47b1 | /hazelcast/include/hazelcast/client/Pipelining.h | f04af824e90a9ca8a0bfb867ded93a4bc658db9a | [
"Apache-2.0"
] | permissive | enozcan/hazelcast-cpp-client | 31f558cac860095f9a53c5d2cba3c3f4fdc6d967 | 672ea72811d6281329bd84070e798af711d5cbfb | refs/heads/master | 2022-08-29T14:59:11.322441 | 2020-03-30T11:20:49 | 2020-03-30T11:20:49 | 256,820,114 | 0 | 0 | Apache-2.0 | 2020-04-18T18:04:38 | 2020-04-18T18:04:37 | null | UTF-8 | C++ | false | false | 8,552 | h | /*
* Copyright (c) 2008-2020, Hazelcast, Inc. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef HAZELCAST_CLIENT_PIPELINING_H_
#define HAZELCAST_CLIENT_PIPELINING_H_
#include <vector>
#include "hazelcast/client/ICompletableFuture.h"
#include "hazelcast/util/Preconditions.h"
#include "hazelcast/util/ConditionVariable.h"
#include "hazelcast/util/concurrent/ConcurrencyUtil.h"
namespace hazelcast {
namespace client {
/**
* @Beta
*
* The Pipelining can be used to speed up requests. It is build on top of asynchronous
* requests like e.g. {@link IMap#getAsync(const K&)} or any other asynchronous call.
*
* The main purpose of the Pipelining is to control the number of concurrent requests
* when using asynchronous invocations. This can be done by setting the depth using
* the constructor. So you could set the depth to e.g 100 and do 1000 calls. That means
* that at any given moment, there will only be 100 concurrent requests.
*
* It depends on the situation what the optimal depth (number of invocations in
* flight) should be. If it is too high, you can run into memory related problems.
* If it is too low, it will provide little or no performance advantage at all. In
* most cases a Pipelining and a few hundred map/cache puts/gets should not lead to any
* problems. For testing purposes we frequently have a Pipelining of 1000 or more
* concurrent requests to be able to saturate the system.
*
* The Pipelining can't be used for transaction purposes. So you can't create a
* Pipelining, add a set of asynchronous request and then not call {@link #results()}
* to prevent executing these requests. Invocations can be executed before the
* {@link #results()} is called.
*
*
* The Pipelining isn't threadsafe. So only a single thread should add requests to
* the Pipelining and wait for results.
*
* Currently all {@link ICompletableFuture} and their responses are stored in the
* Pipelining. So be careful executing a huge number of request with a single Pipelining
* because it can lead to a huge memory bubble. In this cases it is better to
* periodically, after waiting for completion, to replace the Pipelining by a new one.
* In the future we might provide this as an out of the box experience, but currently
* we do not.
*
* A Pipelining provides its own backpressure on the system. So there will not be more
* in flight invocations than the depth of the Pipelining. This means that the Pipelining
* will work fine when backpressure on the client/member is disabled (default). Also
* when it is enabled it will work fine, but keep in mind that the number of concurrent
* invocations in the Pipelining could be lower than the configured number of invocation
* of the Pipelining because the backpressure on the client/member is leading.
*
* The Pipelining has been marked as Beta since we need to see how the API needs to
* evolve. But there is no problem using it in production. We use similar techniques
* to achieve high performance.
*
* @param <E>
*/
template<typename E>
class Pipelining : public std::enable_shared_from_this<Pipelining<E> > {
public:
/**
* Creates a Pipelining with the given depth.
*
* We use this factory create method and hide the constructor from the user, because the private
* {@link up()} and {@link down()} methods of this class may be called from the executor thread, and
* we need to make sure that the `Pipelining` instance is not destructed when these methods are accessed.
*
* @param depth the maximum number of concurrent calls allowed in this Pipelining.
* @throws IllegalArgumentException if depth smaller than 1. But if you use depth 1, it means that
* every call is sync and you will not benefit from pipelining at all.
*/
static std::shared_ptr<Pipelining> create(int depth) {
util::Preconditions::checkPositive(depth, "depth must be positive");
return std::shared_ptr<Pipelining>(new Pipelining(depth));
}
/**
* Returns the results.
* <p>
* The results are returned in the order the requests were done.
* <p>
* This call waits till all requests have completed.
*
* @return the List of results.
* @throws IException if something fails getting the results.
*/
std::vector<std::shared_ptr<E> > results() {
std::vector<std::shared_ptr<E> > result;
result.reserve(futures.size());
for (typename FuturesVector::const_iterator it = futures.begin(); it != futures.end(); ++it) {
result.push_back((*it)->get());
}
return result;
}
/**
* Adds a future to this Pipelining or blocks until there is capacity to add the future to the Pipelining.
* <p>
* This call blocks until there is space in the Pipelining, but it doesn't mean that the invocation that
* returned the ICompletableFuture got blocked.
*
* @param future the future to add.
* @return the future added.
* @throws NullPointerException if future is null.
*/
const std::shared_ptr<ICompletableFuture<E> > &
add(const std::shared_ptr<ICompletableFuture<E> > &future) {
util::Preconditions::checkNotNull<ICompletableFuture<E> >(future, "future can't be null");
down();
futures.push_back(future);
future->andThen(std::shared_ptr<ExecutionCallback<E> >(
new PipeliningExecutionCallback(this->shared_from_this())),
util::concurrent::ConcurrencyUtil::CALLER_RUNS());
return future;
}
private:
class PipeliningExecutionCallback : public ExecutionCallback<E> {
public:
PipeliningExecutionCallback(const std::shared_ptr<Pipelining> &pipelining) : pipelining(pipelining) {}
virtual void onResponse(const std::shared_ptr<E> &response) {
pipelining->up();
}
virtual void onFailure(const std::shared_ptr<exception::IException> &e) {
pipelining->up();
}
private:
const std::shared_ptr<Pipelining> pipelining;
};
Pipelining(int depth) : permits(util::Preconditions::checkPositive(depth, "depth must be positive")) {
}
// TODO: Change with lock-free implementation when atomic is integrated into the library
void down() {
util::LockGuard lockGuard(mutex);
while (permits == 0) {
conditionVariable.wait(mutex);
}
--permits;
}
void up() {
util::LockGuard lockGuard(mutex);
if (permits == 0) {
conditionVariable.notify_all();
}
++permits;
}
typedef std::vector<std::shared_ptr<ICompletableFuture<E> > > FuturesVector;
int permits;
FuturesVector futures;
util::ConditionVariable conditionVariable;
util::Mutex mutex;
};
}
}
#endif //HAZELCAST_CLIENT_PIPELINING_H_
| [
"noreply@github.com"
] | enozcan.noreply@github.com |
61e4ee53382484daae7590f5bd293e90b077eb43 | 0d294a056401ab85bc5eab02afbc550c202d2fea | /sort/merge.cpp | 1734d40d302bb0ccce433aef91c812c214d3140f | [] | no_license | aishwarydewangan/algorithms | e2ef48480f740d5714a9412b1a02034300ff3870 | 3bc34c1e315b2e2ff30c6e66ce8e9e6ec5999c25 | refs/heads/master | 2021-07-12T20:01:02.227541 | 2021-07-11T10:46:42 | 2021-07-11T10:46:42 | 126,575,527 | 4 | 13 | null | 2019-10-12T11:51:15 | 2018-03-24T07:20:11 | C++ | UTF-8 | C++ | false | false | 798 | cpp | #include <iostream>
using namespace std;
void show(int a[], int size) {
for(int i = 0; i < size; i++)
cout << a[i] << "\t";
cout << endl;
}
void merge(int a[], int l, int m, int r) {
int *ta;
int i = 0, x = l, y = m + 1;
ta = new int[r-l+1];
while(x <= m && y <= r)
ta[i++] = (a[x] <= a[y]) ? a[x++] : a[y++];
if(x <= m) {
for(int j = x; j <= m; j++) {
ta[i++] = a[j];
}
}
if(y <= r) {
for(int j = y; j <= r; j++)
ta[i++] = a[j];
}
i = 0;
for(int j = l; j <= r; j++)
a[j] = ta[i++];
delete ta;
}
void mergeSort(int a[], int l, int r) {
if(l < r) {
int m = (l+r)/2;
mergeSort(a, l, m);
mergeSort(a, m+1, r);
merge(a, l, m, r);
}
}
int main() {
int a[10] = {9, 8, 7, 6, 5, 4, 3, 2, 1, 0};
mergeSort(a, 0, 9);
show(a, 10);
return 0;
}
| [
"aishwary.dewangan@gmail.com"
] | aishwary.dewangan@gmail.com |
6d280795573d50a20c34c93221097a2731376271 | 1ab7b3f2aa63de8488ce7c466a67d367771aa1f2 | /Ricardo_OS/Example_code/sd_test/lib/SPIMemory-master/examples/readWriteString/readWriteString.ino | d5be110aaf4fa034dc7b029e8b6019c44718d074 | [
"MIT",
"GPL-3.0-only"
] | permissive | icl-rocketry/Avionics | 9d39aeb11aba11115826fd73357b415026a7adad | 95b7a061eabd6f2b607fba79e007186030f02720 | refs/heads/master | 2022-07-30T07:54:10.642930 | 2022-07-10T12:19:10 | 2022-07-10T12:19:10 | 216,184,670 | 9 | 1 | MIT | 2022-06-27T10:17:06 | 2019-10-19T09:57:07 | C++ | UTF-8 | C++ | false | false | 3,335 | ino | /*
|~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
| readWriteString.ino |
| SPIMemory library |
| v 3.0.0 |
|~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
| Marzogh |
| 29.05.2017 |
|~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
| |
| This program shows the method of reading a string from the console and saving it to flash memory |
| |
|~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
*/
#include<SPIMemory.h>
uint32_t strAddr;
#if defined(ARDUINO_SAMD_ZERO) && defined(SERIAL_PORT_USBVIRTUAL)
// Required for Serial on Zero based boards
#define Serial SERIAL_PORT_USBVIRTUAL
#endif
#if defined (SIMBLEE)
#define BAUD_RATE 250000
#define RANDPIN 1
#else
#define BAUD_RATE 115200
#define RANDPIN A0
#endif
//SPIFlash flash(SS1, &SPI1); //Use this constructor if using an SPI bus other than the default SPI. Only works with chips with more than one hardware SPI bus
SPIFlash flash;
bool readSerialStr(String &inputStr);
void setup() {
Serial.begin(BAUD_RATE);
#if defined (ARDUINO_SAMD_ZERO) || (__AVR_ATmega32U4__)
while (!Serial) ; // Wait for Serial monitor to open
#endif
flash.begin();
randomSeed(analogRead(RANDPIN));
strAddr = random(0, flash.getCapacity());
String inputString = "This is a test String";
flash.writeStr(strAddr, inputString);
Serial.print(F("Written string: "));
Serial.println(inputString);
Serial.print(F("To address: "));
Serial.println(strAddr);
String outputString = "";
if (flash.readStr(strAddr, outputString)) {
Serial.print(F("Read string: "));
Serial.println(outputString);
Serial.print(F("From address: "));
Serial.println(strAddr);
}
while (!flash.eraseSector(strAddr));
}
void loop() {
}
//Reads a string from Serial
bool readSerialStr(String &inputStr) {
if (!Serial)
Serial.begin(115200);
while (Serial.available()) {
inputStr = Serial.readStringUntil('\n');
Serial.println(inputStr);
return true;
}
return false;
}
| [
"kiran@MacBook-Pro-3.local"
] | kiran@MacBook-Pro-3.local |
099f981790e625599b3f907403ced6a4703d0958 | 2fcc9ad89cf0c85d12fa549f969973b6f4c68fdc | /SampleGraphics/ShadowMaps/ShadowMaps.cpp | 0c3c8389f128a63980891624d23d8b11eee18a98 | [
"BSL-1.0"
] | permissive | nmnghjss/WildMagic | 9e111de0a23d736dc5b2eef944f143ca84e58bc0 | b1a7cc2140dde23d8d9a4ece52a07bd5ff938239 | refs/heads/master | 2022-04-22T09:01:12.909379 | 2013-05-13T21:28:18 | 2013-05-13T21:28:18 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 12,793 | cpp | // Geometric Tools, LLC
// Copyright (c) 1998-2012
// Distributed under the Boost Software License, Version 1.0.
// http://www.boost.org/LICENSE_1_0.txt
// http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt
//
// File Version: 5.0.0 (2010/01/01)
#include "ShadowMaps.h"
WM5_WINDOW_APPLICATION(ShadowMaps);
//----------------------------------------------------------------------------
ShadowMaps::ShadowMaps ()
:
WindowApplication3("SampleGraphics/ShadowMaps", 0, 0, 640, 480,
Float4(0.75f, 0.75f, 0.75f, 1.0f)),
mShadowClear(1.0f, 1.0f, 1.0f, 1.0f),
mUnlitClear(1.0f, 1.0f, 1.0f, 1.0f),
mTextColor(0.0f, 0.0f, 0.0f, 1.0f)
{
Environment::InsertDirectory(ThePath + "Shaders/");
}
//----------------------------------------------------------------------------
bool ShadowMaps::OnInitialize ()
{
if (!WindowApplication3::OnInitialize())
{
return false;
}
// Set up the camera.
mCamera->SetFrustum(60.0f, 1.0f, 0.1f, 100.0f);
APoint camPosition(8.0f, 0.0f, 4.0f);
AVector camDVector = APoint::ORIGIN - camPosition; // look at origin
camDVector.Normalize();
AVector camUVector(camDVector[2], 0, -camDVector[0]);
AVector camRVector(0.0f, 1.0f, 0.0f);
mCamera->SetFrame(camPosition, camDVector, camUVector, camRVector);
CreateScene();
// Initial update of objects.
mScene->Update();
// Initial culling of scene.
mCuller.SetCamera(mCamera);
mCuller.ComputeVisibleSet(mScene);
InitializeCameraMotion(0.01f, 0.001f);
InitializeObjectMotion(mScene);
return true;
}
//----------------------------------------------------------------------------
void ShadowMaps::OnTerminate ()
{
mScene = 0;
mScreenCamera = 0;
mScreenPolygon = 0;
mShadowTarget = 0;
mUnlitTarget = 0;
mHBlurTarget = 0;
mVBlurTarget = 0;
mPlaneSceneInstance = 0;
mSphereSceneInstance = 0;
mShadowEffect = 0;
mUnlitEffect = 0;
mHBlurInstance = 0;
mVBlurInstance = 0;
WindowApplication3::OnTerminate();
}
//----------------------------------------------------------------------------
//#define DUMP_RENDER_TARGETS
//----------------------------------------------------------------------------
void ShadowMaps::OnIdle ()
{
MeasureTime();
if (MoveCamera())
{
mCuller.ComputeVisibleSet(mScene);
}
if (MoveObject())
{
mScene->Update();
mCuller.ComputeVisibleSet(mScene);
}
if (mRenderer->PreDraw())
{
// Draw the scene from the light's perspective, writing the depths
// from the light into the render target.
mRenderer->Enable(mShadowTarget);
mRenderer->SetClearColor(mShadowClear);
mRenderer->ClearBuffers();
mRenderer->Draw(mCuller.GetVisibleSet(), mShadowEffect);
mRenderer->Disable(mShadowTarget);
#ifdef DUMP_RENDER_TARGETS
Texture2D* texture = mRenderer->Read(mShadowTarget);
texture->SaveWMTF("ShadowTarget.wmtf");
delete0(texture);
#endif
// Draw the scene from the camera's perspective, using projected
// texturing of the shadow map and determining which pixels are lit
// and which are shadowed.
mRenderer->ClearBuffers();
mRenderer->Enable(mUnlitTarget);
mRenderer->SetClearColor(mUnlitClear);
mRenderer->ClearBuffers();
mRenderer->Draw(mCuller.GetVisibleSet(), mUnlitEffect);
mRenderer->Disable(mUnlitTarget);
#ifdef DUMP_RENDER_TARGETS
texture = mRenderer->Read(mUnlitTarget);
texture->SaveWMTF("UnlitTarget.wmtf");
delete0(texture);
#endif
// Do screen space drawing.
mRenderer->SetCamera(mScreenCamera);
// Horizontally blur the unlit render target.
mScreenPolygon->SetEffectInstance(mHBlurInstance);
mRenderer->Enable(mHBlurTarget);
mRenderer->Draw(mScreenPolygon);
mRenderer->Disable(mHBlurTarget);
#ifdef DUMP_RENDER_TARGETS
texture = mRenderer->Read(mHBlurTarget);
texture->SaveWMTF("HBlurTarget.wmtf");
delete0(texture);
#endif
// Vertically blur the horizontal blur render target.
mScreenPolygon->SetEffectInstance(mVBlurInstance);
mRenderer->Enable(mVBlurTarget);
mRenderer->Draw(mScreenPolygon);
mRenderer->Disable(mVBlurTarget);
#ifdef DUMP_RENDER_TARGETS
texture = mRenderer->Read(mVBlurTarget);
texture->SaveWMTF("VBlurTarget.wmtf");
delete0(texture);
#endif
// Draw the scene using regular textures, combining the shadow
// information with the scene.
mRenderer->SetCamera(mCamera);
mRenderer->SetClearColor(mClearColor);
mRenderer->ClearBuffers();
mRenderer->Draw(mCuller.GetVisibleSet());
DrawFrameRate(8, GetHeight()-8, mTextColor);
mRenderer->PostDraw();
mRenderer->DisplayColorBuffer();
}
UpdateFrameCount();
}
//----------------------------------------------------------------------------
void ShadowMaps::CreateScene ()
{
CreateScreenSpaceObjects();
CreateShaders();
// Create a scene graph containing a sphere and a plane. The sphere will
// cast a shadow on the plane.
mScene = new0 Node();
VertexFormat* vformat = VertexFormat::Create(3,
VertexFormat::AU_POSITION, VertexFormat::AT_FLOAT3, 0,
VertexFormat::AU_NORMAL, VertexFormat::AT_FLOAT3, 0,
VertexFormat::AU_TEXCOORD, VertexFormat::AT_FLOAT2, 0);
StandardMesh sm(vformat);
TriMesh* plane = sm.Rectangle(128, 128, 16.0f, 16.0f);
plane->SetEffectInstance(mPlaneSceneInstance);
mScene->AttachChild(plane);
TriMesh* sphere = sm.Sphere(64, 64, 1.0f);
sphere->LocalTransform.SetTranslate(APoint(0.0f, 0.0f, 1.0f));
sphere->SetEffectInstance(mSphereSceneInstance);
mScene->AttachChild(sphere);
}
//----------------------------------------------------------------------------
void ShadowMaps::CreateScreenSpaceObjects ()
{
// Create a screen-space camera to use with the render target.
mScreenCamera = ScreenTarget::CreateCamera();
// Create a screen polygon to use with the render target.
VertexFormat* vformat = VertexFormat::Create(2,
VertexFormat::AU_POSITION, VertexFormat::AT_FLOAT3, 0,
VertexFormat::AU_TEXCOORD, VertexFormat::AT_FLOAT2, 0);
mScreenTargetSize = 512;
mScreenPolygon = ScreenTarget::CreateRectangle(vformat, mScreenTargetSize,
mScreenTargetSize, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f);
// Create a render target for the shadow effect.
mShadowTarget = new0 RenderTarget(1, Texture::TF_A32B32G32R32F,
mScreenTargetSize, mScreenTargetSize, false, true);
// Create a render target for the unlit scene.
mUnlitTarget = new0 RenderTarget(1, Texture::TF_A32B32G32R32F, GetWidth(),
GetHeight(), false, true);
// Create a render target for the horizontally blurred scene.
mHBlurTarget = new0 RenderTarget(1, Texture::TF_A8R8G8B8, GetWidth(),
GetHeight(), false, false);
// Create a render target for the vertically blurred scene.
mVBlurTarget = new0 RenderTarget(1, Texture::TF_A8R8G8B8, GetWidth(),
GetHeight(), false, false);
mRenderer->Bind(mShadowTarget);
mRenderer->Bind(mUnlitTarget);
mRenderer->Bind(mHBlurTarget);
mRenderer->Bind(mVBlurTarget);
}
//----------------------------------------------------------------------------
void ShadowMaps::CreateShaders ()
{
// Create the shader constants. Some of these are shared.
// Create the light projector.
Projector* projector = new0 Projector(Camera::PM_DEPTH_ZERO_TO_ONE);
projector->SetFrustum(60.0f, 1.0f, 0.1f, 100.0f);
APoint projPosition(4.0f, 4.0f, 4.0f);
AVector projDVector(-1.0f, -1.0f, -1.0f);
projDVector.Normalize();
AVector projUVector(-1.0f, -1.0f, 2.0f);
projUVector.Normalize();
AVector projRVector = projDVector.Cross(projUVector);
projector->SetFrame(projPosition, projDVector, projUVector, projRVector);
// For SMSceneEffect and SMUnlitEffect.
ProjectorMatrixConstant* lightPVMatrix =
new0 ProjectorMatrixConstant(projector, false, 0);
ShaderFloat* lightBSMatrixUnlit = new0 ShaderFloat(4);
ShaderFloat* lightBSMatrixScene = new0 ShaderFloat(4);
ShaderFloat* screenBSMatrix = new0 ShaderFloat(4);
const float* src;
if (VertexShader::GetProfile() == VertexShader::VP_ARBVP1)
{
src = (const float*)Projector::BiasScaleMatrix[1];
memcpy(lightBSMatrixUnlit->GetData(), src, 16*sizeof(float));
memcpy(lightBSMatrixScene->GetData(), src, 16*sizeof(float));
memcpy(screenBSMatrix->GetData(), src, 16*sizeof(float));
}
else
{
src = (const float*)Projector::BiasScaleMatrix[0];
memcpy(lightBSMatrixUnlit->GetData(), src, 16*sizeof(float));
memcpy(screenBSMatrix->GetData(), src, 16*sizeof(float));
src = (const float*)Projector::BiasScaleMatrix[1];
memcpy(lightBSMatrixScene->GetData(), src, 16*sizeof(float));
}
// For SMSceneEffect.
ProjectorWorldPositionConstant* lightWorldPosition =
new0 ProjectorWorldPositionConstant(projector);
ShaderFloat* lightColor = new0 ShaderFloat(1);
(*lightColor)[0] = 1.0f;
(*lightColor)[1] = 1.0f;
(*lightColor)[2] = 1.0f;
(*lightColor)[3] = 1.0f;
// For SMUnlitEffect.
ShaderFloat* depthBiasConstant = new0 ShaderFloat(1);
(*depthBiasConstant)[0] = 0.1f;
ShaderFloat* texelSizeConstant = new0 ShaderFloat(1);
(*texelSizeConstant)[0] = 1.0f/(float)mScreenTargetSize;
(*texelSizeConstant)[1] = 1.0f/(float)mScreenTargetSize;
// For SMBlurEffect.
const int numRegisters = 11;
ShaderFloat* weights = new0 ShaderFloat(numRegisters);
ShaderFloat* hOffsets = new0 ShaderFloat(numRegisters);
ShaderFloat* vOffsets = new0 ShaderFloat(numRegisters);
// Compute the weights. They must sum to 1.
Float4* weightsData = (Float4*)weights->GetData();
const float stdDev = 1.0f;
const float invTwoVariance = 1.0f/(2.0f*stdDev*stdDev);
float totalWeight = 0.0f;
int i, j;
for (i = 0, j = -numRegisters/2; i < numRegisters; ++i, ++j)
{
float weight = Mathf::Exp(-j*j*invTwoVariance);
weightsData[i] = Float4(weight, weight, weight, 0.0f);
totalWeight += weight;
}
float invTotalWeight = 1.0f/totalWeight;
for (i = 0; i < numRegisters; ++i)
{
weightsData[i][0] *= invTotalWeight;
weightsData[i][1] *= invTotalWeight;
weightsData[i][2] *= invTotalWeight;
}
// Compute the horizontal and vertical offsets.
Float4* hOffsetsData = (Float4*)hOffsets->GetData();
Float4* vOffsetsData = (Float4*)vOffsets->GetData();
float uDelta = 1.0f/(float)GetWidth();
float vDelta = 1.0f/(float)GetHeight();
for (i = 0, j = -numRegisters/2; i < numRegisters; ++i, ++j)
{
hOffsetsData[i] = Float4(j*uDelta, 0.0f, 0.0f, 0.0f);
vOffsetsData[i] = Float4(0.0f, j*vDelta, 0.0f, 0.0f);
}
// Create the scene effect.
std::string effectFile = Environment::GetPathR("SMScene.wmfx");
SMSceneEffect* sceneEffect = new0 SMSceneEffect(effectFile);
std::string stoneName = Environment::GetPathR("Stone.wmtf");
Texture2D* stoneTexture = Texture2D::LoadWMTF(stoneName);
std::string ballName = Environment::GetPathR("BallTexture.wmtf");
Texture2D* ballTexture = Texture2D::LoadWMTF(ballName);
std::string projectedName = Environment::GetPathR("Magician.wmtf");
Texture2D* projectedTexture = Texture2D::LoadWMTF(projectedName);
mPlaneSceneInstance = sceneEffect->CreateInstance(lightWorldPosition,
lightPVMatrix, lightBSMatrixScene, screenBSMatrix, lightColor,
stoneTexture, mVBlurTarget->GetColorTexture(0), projectedTexture);
mSphereSceneInstance = sceneEffect->CreateInstance(lightWorldPosition,
lightPVMatrix, lightBSMatrixScene, screenBSMatrix, lightColor,
ballTexture, mVBlurTarget->GetColorTexture(0), projectedTexture);
// Create the shadow effect.
effectFile = Environment::GetPathR("SMShadow.wmfx");
mShadowEffect = new0 SMShadowEffect(effectFile, lightPVMatrix);
// Create the unlit effect.
effectFile = Environment::GetPathR("SMUnlit.wmfx");
mUnlitEffect = new0 SMUnlitEffect(effectFile, lightPVMatrix,
lightBSMatrixUnlit, depthBiasConstant, texelSizeConstant,
mShadowTarget->GetColorTexture(0));
// Create the blur effect and instantiate for horizontal and vertical
// blurring.
effectFile = Environment::GetPathR("SMBlur.wmfx");
SMBlurEffect* blurEffect = new0 SMBlurEffect(effectFile);
mHBlurInstance = blurEffect->CreateInstance(weights, hOffsets,
mUnlitTarget->GetColorTexture(0));
mVBlurInstance = blurEffect->CreateInstance(weights, vOffsets,
mHBlurTarget->GetColorTexture(0));
}
//----------------------------------------------------------------------------
| [
"bazhenovc@bazhenovc-laptop"
] | bazhenovc@bazhenovc-laptop |
006ffaf1e8fca1b4d479fe02e14a4c1088977cba | 677bf35616660675c41dcca57bf2dfd5e717ac82 | /prototype/engine/include/ShaderRes.h | c7226c868d42608e899b5ef842d89c4449bbc0da | [] | no_license | DeadlyKom/Old-Prototype | 71d2fe7012dd97cee528d69bd40df5defd972487 | 4447a5d16f2922fa4f063d6c9c9476a685e4c718 | refs/heads/master | 2020-04-22T10:41:41.583522 | 2019-02-12T16:51:59 | 2019-02-12T16:51:59 | 170,313,472 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,362 | h | #pragma once
#include <agile.h>
#include <d3d11_4.h>
#include <memory>
#include <ppltasks.h>
#include <string>
#include <vector>
#include "prototype\include\Type.h"
#include "Device.h"
#include "FileManager.h"
#include "ResourceManager.h"
using namespace std;
using namespace Concurrency;
namespace SystemEngine
{
class ShaderRes : public IResource
{
public:
enum class TShader
{
Vertex = 0, Geometry, Pixel
};
public:
ShaderRes() = delete;
// Конструктор
ShaderRes(string name);
// Деструктор
virtual ~ShaderRes();
// Перезагрузить
virtual task<void> Reload() override;
// Освободить
virtual void Release() override;
// Установка файла шейдера
void SetFile(TShader type_shader, int index_file_shader);
// Компиляция шейдера
bool Compiled(TShader type_shader, const shared_ptr<vector<byte>> byte_code);
// Установка формата вершин
void SetInputLayout(const shared_ptr<vector<D3D11_INPUT_ELEMENT_DESC>> vertex_layout = nullptr);
// Добовление формата вершин
void AddInputLayout(string semantic_name, int semantic_index, DXGI_FORMAT format, UINT offset = D3D11_APPEND_ALIGNED_ELEMENT);
// Установка шейдера
bool Include(TShader type_shader);
// Установка привязки формата вершин
bool IncludeInputLayout();
protected:
// Компиляция вершинного шейдера
void CompiledVertex(const shared_ptr<vector<byte>> byte_code_vertex);
// Компиляция геометрического шейдера
void CompiledGeometry(const shared_ptr<vector<byte>> byte_code_geometry);
// Компиляция пиксельного шейдера
void CompiledPixel(const shared_ptr<vector<byte>> byte_code_pixel);
// Системные переменные
shared_ptr<Device> m_device; // ссылка на интерфейс устройства
shared_ptr<FileManager> m_file_manager; // ссылка на диспетчер файлов
shared_ptr<ResourceManager> m_resource_manadger; // ссылка на диспетчер ресурсов
// Структура шейдера
Microsoft::WRL::ComPtr<ID3D11VertexShader> m_vertex_shader; // интерфейс вершинного шейдера
Microsoft::WRL::ComPtr<ID3D11GeometryShader> m_geometry_shader; // интерфейс геометрического шейдера
Microsoft::WRL::ComPtr<ID3D11PixelShader> m_pixel_shader; // интерфейс пиксельного шейдера
Microsoft::WRL::ComPtr<ID3D11InputLayout> m_input_layout; // интерфейс порядка и параметров вершин
// Внутренние переменные
int m_index_file_vertex_shader; // индекс файла вершинного шейдера
int m_index_file_geometry_shader; // индекс файла геометрического шейдера
int m_index_file_pixel_shader; // индекс файла пиксельного шейдера
vector<D3D11_INPUT_ELEMENT_DESC> m_list_input_layout; // список формата
};
} | [
"gma.deadly.kom@mail.ru"
] | gma.deadly.kom@mail.ru |
7787feac22f2e9c7eac1b4e32b87936a2dec8668 | 58724cda603f98cc6f4cba7942bec47c5c52c222 | /Framework/Source/Raytracing/RtProgramVarsHelper.cpp | 2eebe958f7e365138cd5970359183a21665ea11e | [] | permissive | dgough/Falcor | 879ed05e34f325998615cb2f614710fcd4edeb1b | cc62b5bd2fd1dc87c0b55ff80d9b810b84cddb6f | refs/heads/master | 2021-04-28T03:39:34.370158 | 2018-06-08T00:53:09 | 2018-06-08T01:30:43 | 122,143,882 | 0 | 0 | BSD-3-Clause | 2018-02-20T01:46:25 | 2018-02-20T01:46:24 | null | UTF-8 | C++ | false | false | 4,686 | cpp | /***************************************************************************
# Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# * Neither the name of NVIDIA CORPORATION nor the names of its
# contributors may be used to endorse or promote products derived
# from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
# OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
***************************************************************************/
#include "Framework.h"
#include "RtProgramVarsHelper.h"
#include "API/Device.h"
#include "API/LowLevel/DescriptorPool.h"
#include "API/D3D12/LowLevel/D3D12DescriptorData.h"
#include "API/D3D12/LowLevel/D3D12DescriptorHeap.h"
namespace Falcor
{
RtVarsContext::SharedPtr RtVarsContext::create(CopyContext::SharedPtr pRtContext)
{
return SharedPtr(new RtVarsContext(pRtContext));
}
RtVarsContext::RtVarsContext(CopyContext::SharedPtr pRtContext) : mpRayTraceContext(pRtContext)
{
mpLowLevelData = LowLevelContextData::create(LowLevelContextData::CommandQueueType::Direct, nullptr);
mpList = RtVarsCmdList::create();
ID3D12GraphicsCommandList* pList = mpList.get();
mpLowLevelData->setCommandList(pList);
}
RtVarsContext::~RtVarsContext()
{
// Release the low-level data before the list
mpLowLevelData = nullptr;
mpList = nullptr;
}
HRESULT RtVarsCmdList::QueryInterface(REFIID riid, void **ppvObject)
{
return gpDevice->getRenderContext()->getLowLevelData()->getCommandList()->QueryInterface(riid, ppvObject);
}
void RtVarsCmdList::SetGraphicsRootDescriptorTable(UINT RootParameterIndex, D3D12_GPU_DESCRIPTOR_HANDLE BaseDescriptor)
{
uint32_t rootOffset = mpRootSignature->getElementByteOffset(RootParameterIndex);
*(uint64_t*)(mpRootBase + rootOffset) = BaseDescriptor.ptr;
}
void RtVarsCmdList::SetGraphicsRoot32BitConstant(UINT RootParameterIndex, UINT SrcData, UINT DestOffsetIn32BitValues)
{
assert(DestOffsetIn32BitValues == 0);
uint32_t rootOffset = mpRootSignature->getElementByteOffset(RootParameterIndex);
*(uint32_t*)(mpRootBase + rootOffset) = SrcData;
}
void RtVarsCmdList::SetGraphicsRoot32BitConstants(UINT RootParameterIndex, UINT Num32BitValuesToSet, const void *pSrcData, UINT DestOffsetIn32BitValues)
{
should_not_get_here();
}
void RtVarsCmdList::SetGraphicsRootConstantBufferView(UINT RootParameterIndex, D3D12_GPU_VIRTUAL_ADDRESS BufferLocation)
{
uint32_t rootOffset = mpRootSignature->getElementByteOffset(RootParameterIndex);
assert((rootOffset % 8) == 0);
*(D3D12_GPU_VIRTUAL_ADDRESS*)(mpRootBase + rootOffset) = BufferLocation;
}
void RtVarsCmdList::SetGraphicsRootShaderResourceView(UINT RootParameterIndex, D3D12_GPU_VIRTUAL_ADDRESS BufferLocation)
{
uint32_t rootOffset = mpRootSignature->getElementByteOffset(RootParameterIndex);
assert((rootOffset % 8) == 0);
*(D3D12_GPU_VIRTUAL_ADDRESS*)(mpRootBase + rootOffset) = BufferLocation;
}
void RtVarsCmdList::SetGraphicsRootUnorderedAccessView(UINT RootParameterIndex, D3D12_GPU_VIRTUAL_ADDRESS BufferLocation)
{
uint32_t rootOffset = mpRootSignature->getElementByteOffset(RootParameterIndex);
assert((rootOffset % 8) == 0);
*(D3D12_GPU_VIRTUAL_ADDRESS*)(mpRootBase + rootOffset) = BufferLocation;
}
}
| [
"nbenty@nvidia.com"
] | nbenty@nvidia.com |
eb61ad3bd0679b9b634879898bc52d1cc05686f4 | 03ee754445d2dc6abbb3c1f2a57a35519f8acc96 | /old_pratcis.cpp | f30113118cedba131a7da865908beec99fcc4f23 | [] | no_license | mizan-cs/Practise-Code | d34a67d1f3ea7a9a81e8096020227b705ca5ec13 | 74b21d810c242af249a17ec8fef683fdb3c0d1b0 | refs/heads/master | 2021-01-19T21:19:25.831029 | 2017-09-09T03:23:47 | 2017-09-09T03:23:47 | 101,249,329 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 450 | cpp | #include<iostream>
using namespace std;
class Sample{
static int a,b;
public:
void setAB(int x, int y)
{
a=x;
b=y;
}
void printAB()
{
cout<<"A= "<<a<<"\tB= "<<b<<endl;
}
};
int Sample::a;
int Sample::b;
int main()
{
Sample smp1,smp2;
smp1.setAB(100,200);
smp1.printAB();
smp2.printAB();
return 0;
}
| [
"mysalfe02@gmail.com"
] | mysalfe02@gmail.com |
c9b99b3f5bf9a434bd3d08de6218afce7e49c9ad | 6ba38fe94e7ea5146c633f56f59c0c3278d695a7 | /plugins/core/WhiteNoiseBackground/WhiteNoiseBackgroundShaderTypes.h | 0d0cb7ef13c8da0e1536f0ec93ec14cb2365229a | [
"MIT"
] | permissive | mworks/mworks | b49b721c2c5c0471180516892649fe3bd753a326 | abf78fc91a44b99a97cf0eafb29e68ca3b7a08c7 | refs/heads/master | 2023-09-05T20:04:58.434227 | 2023-08-30T01:08:09 | 2023-08-30T01:08:09 | 2,356,013 | 14 | 11 | null | 2012-10-03T17:48:45 | 2011-09-09T14:55:57 | C++ | UTF-8 | C++ | false | false | 1,574 | h | //
// WhiteNoiseBackgroundShaderTypes.h
// WhiteNoiseBackground
//
// Created by Christopher Stawarz on 3/4/21.
//
#ifndef WhiteNoiseBackgroundShaderTypes_h
#define WhiteNoiseBackgroundShaderTypes_h
#ifndef __METAL_VERSION__
BEGIN_NAMESPACE_MW
BEGIN_NAMESPACE(white_noise_background)
#endif
struct MinStdRand {
using value_type = uint32_t;
static constexpr value_type a() { return 48271u; }
static constexpr value_type c() { return 0u; }
static constexpr value_type m() { return 2147483647u; }
static constexpr value_type min() { return c() == 0u; }
static constexpr value_type max() { return m() - 1u; }
static constexpr value_type next(value_type previous) { return (a() * previous + c()) % m(); }
static constexpr float normalize(value_type value) { return float(value - min()) / float(max() - min()); }
};
#ifndef __METAL_VERSION__
// Sanity checks
static_assert(MinStdRand::a() == std::minstd_rand::multiplier);
static_assert(MinStdRand::c() == std::minstd_rand::increment);
static_assert(MinStdRand::m() == std::minstd_rand::modulus);
static_assert(MinStdRand::min() == std::minstd_rand::min());
static_assert(MinStdRand::max() == std::minstd_rand::max());
#endif
enum {
seedTextureIndex,
noiseTextureIndex
};
enum {
rgbNoiseFunctionConstantIndex
};
enum {
redNoiseTextureIndex,
greenNoiseTextureIndex,
blueNoiseTextureIndex
};
#ifndef __METAL_VERSION__
END_NAMESPACE(white_noise_background)
END_NAMESPACE_MW
#endif
#endif /* WhiteNoiseBackgroundShaderTypes_h */
| [
"cstawarz@mit.edu"
] | cstawarz@mit.edu |
edb4d4893c1fb44de080f423de84eaf27d6f99d9 | a0631bbee143c830f6b2ac6bf37b6c055bd8981a | /flappy/envs/fwmav/Actuator.hpp | 9782013c9e1fde36a109e340a8c73bf2a0db1906 | [
"MIT"
] | permissive | chen3082/flappy | 1c5aa7bc0bcb07a04d913934818d4dc1d55602ee | 63d23c86016e10956f2b365ab4d5bb82a25c323a | refs/heads/master | 2020-08-11T07:30:15.093671 | 2020-01-30T20:03:50 | 2020-01-30T20:03:50 | 214,517,921 | 1 | 1 | MIT | 2019-11-13T15:48:02 | 2019-10-11T19:51:45 | C++ | UTF-8 | C++ | false | false | 1,439 | hpp | /************************* FWMAV Simulation *************************
* Version 0.3
* Fan Fei Jan 2018
* FWMAV simulation with dual motor driven robotic flapper
* PID controller using split cycle mechanism
***********************************************************************
*/
#include <vector>
#include <iostream>
#include <Eigen/Dense>
namespace FWMAV{
class Actuator {
public:
Actuator(double variable_resistance, double* stroke_velocity, double* stroke_acceleration);
virtual ~Actuator();
void doNothing();
void updateDriverVoltage(double voltage);
void UpdateTorque();
double GetTorque();
double GetMotorTorque();
double GetMagTorque();
double GetInerTorque();
double GetDampTorque();
double GetFricTorque();
double GetBEMF();
double GetCurrent();
protected:
double* stroke_velocity_;
double* stroke_acceleration_;
const double k_resistance_;
const double k_torque_constant_;
const double k_gear_ratio_;
const double k_mechanical_efficiency_;
const double k_friction_coefficient_;
const double k_damping_coefficient_;
const double k_inertia_;
double psi_dot_;
double psi_ddot_;
double motor_vel_;
double motor_accel_;
double sign_;
double voltage_;
double current_;
double back_EMF_;
double variable_resistance_;
double resistance_;
double inertia_torque_;
double damping_torque_;
double friction_torque_;
double magnetic_torque_;
double motor_torque_;
double output_torque_;
};
} | [
"ffnc1020@gmail.com"
] | ffnc1020@gmail.com |
208ff8dfb7917f16eaf5594560c39bdd97df49b4 | 92ede1a7294762c38518f7b482f69a8716737f3b | /googleclient/third_party/v8/src/char-predicates-inl.h | 217db9c33106248944d47bb9570f0f620134883e | [
"BSD-3-Clause",
"MIT"
] | permissive | petersont/o3d | 4ec4afd5aad46f2b89f526266dbbc7b69bbc23f7 | 1a13ccf12a349e13212401bfe81d5166e84e79c5 | refs/heads/master | 2021-01-01T15:35:58.169917 | 2015-05-15T22:53:12 | 2015-05-15T22:53:12 | 35,642,163 | 2 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 2,755 | h | // Copyright 2006-2008 the V8 project authors. All rights reserved.
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following
// disclaimer in the documentation and/or other materials provided
// with the distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef V8_CHAR_PREDICATES_INL_H_
#define V8_CHAR_PREDICATES_INL_H_
#include "char-predicates.h"
namespace v8 { namespace internal {
inline bool IsCarriageReturn(uc32 c) {
return c == 0x000D;
}
inline bool IsLineFeed(uc32 c) {
return c == 0x000A;
}
static inline bool IsInRange(int value, int lower_limit, int higher_limit) {
ASSERT(lower_limit <= higher_limit);
return static_cast<unsigned int>(value - lower_limit) <=
static_cast<unsigned int>(higher_limit - lower_limit);
}
inline bool IsDecimalDigit(uc32 c) {
// ECMA-262, 3rd, 7.8.3 (p 16)
return IsInRange(c, '0', '9');
}
inline bool IsHexDigit(uc32 c) {
// ECMA-262, 3rd, 7.6 (p 15)
return IsDecimalDigit(c) || IsInRange(c | 0x20, 'a', 'f');
}
inline bool IsRegExpWord(uc16 c) {
return IsInRange(c | 0x20, 'a', 'z')
|| IsDecimalDigit(c)
|| (c == '_');
}
inline bool IsRegExpNewline(uc16 c) {
switch (c) {
// CR LF LS PS
case 0x000A: case 0x000D: case 0x2028: case 0x2029:
return false;
default:
return true;
}
}
} } // namespace v8::internal
#endif // V8_CHAR_PREDICATES_INL_H_
| [
"peterson@kamcord.com"
] | peterson@kamcord.com |
9660b5eb0179feadfb8149a02b78f6c6e52bb42c | 4507ccce42f19599927ddeeef695358fb454464f | /src/bwt.h | 4b15afe80a8f02344156a3635a1332a9c62491b7 | [] | no_license | dridk/bwt | 57862d6797b44de02dfa7eac510fdefcef3d160a | bda8b75e69f45d70808ceff72de16985d07f8f03 | refs/heads/master | 2021-01-10T12:22:38.750347 | 2015-10-13T21:22:59 | 2015-10-13T21:22:59 | 44,205,700 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 558 | h | #ifndef BWT_H
#define BWT_H
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <set>
using namespace std;
class Bwt
{
public:
// Convert readable string to bwt
string transform(const string& text);
// Convert bwt to readable string
string reverse(const string& text);
protected:
// Return the suffix array sorted by lexic
vector<pair<string,int>> suffixArray(const string& text);
// Return the bw sorted
vector<int> rank(const string& txt);
};
#endif // BWT_H
| [
"sacha@labsquare.org"
] | sacha@labsquare.org |
2b08f33e45b4ba2c176c8246eb37f68af3b09d06 | a5b729de0e89513446dd0aae17751ab3b959467f | /Gray/src/Platform/Opengl/RenderBuffer.h | 53587d008aa77131cfaebcda84b8648cdab4ab33 | [] | no_license | Rahulbiju315-yb/Gray | d1a026064433d3e8ee59287520d3cc604ee6464c | f55b20514108887a888dc934ef526a93eee99292 | refs/heads/master | 2023-04-18T10:30:05.717117 | 2021-05-07T09:36:59 | 2021-05-07T09:36:59 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 841 | h | #pragma once
#include "Shared.h"
#include "NoCopy.h"
#include "WeakRef.h"
namespace Gray
{
enum class RBType //Render buffer Type
{
StencilRB,
DepthRB,
DepthStencilRB
};
class RenderBuffer
{
public:
void CreateBuffer(RBType type, int width, int height);
void Bind() const;
void Unbind() const;
bool IsBound() const;
uint GetID() const;
private:
static uint boundRB_ID;
uint ID;
RenderBuffer();
RenderBuffer(const RenderBuffer&) = default;
RenderBuffer(RenderBuffer&&) = default;
RenderBuffer& operator=(const RenderBuffer&) = default;
RenderBuffer& operator=(RenderBuffer&&) = default;
void CopyFrom(const RenderBuffer&);
void Free();
friend class Shared<RenderBuffer>;
friend class NoCopy<RenderBuffer>;
friend class WeakRef<RenderBuffer>;
};
uint RBTypeToUINT(RBType type);
} | [
"f20190134@pilani.bits-pilani.ac.in"
] | f20190134@pilani.bits-pilani.ac.in |
dc746f747995be94309a26d90929abdcab991982 | e559656096653d30be5cb7cb144b994efcf2f36a | /Algoritmi/opencl/cpp_cl/DwtHaar1DCPPKernel/DwtHaar1DCPPKernel.cpp | 60c18979f784fad0a3df011f5bd8ac45316afd70 | [] | no_license | morellid/featureBasedScheduling | 6c7db2b2cba6028f7c963e1428011b3371cefc87 | 6b8079f8c046814e3fc295ba2b12c87f3d38a507 | refs/heads/master | 2021-01-13T02:18:33.701664 | 2014-10-16T08:49:25 | 2014-10-16T08:49:25 | null | 0 | 0 | null | null | null | null | WINDOWS-1252 | C++ | false | false | 23,792 | cpp | /**********************************************************************
Copyright ©2013 Advanced Micro Devices, Inc. All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
• Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
• Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or
other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
********************************************************************/
#include "DwtHaar1DCPPKernel.hpp"
#include <math.h>
int
DwtHaar1D::calApproxFinalOnHost()
{
// Copy inData to hOutData
cl_float *tempOutData = (cl_float*)malloc(signalLength * sizeof(cl_float));
CHECK_ALLOCATION(tempOutData, "Failed to allocate host memory. (tempOutData)");
memcpy(tempOutData, inData, signalLength * sizeof(cl_float));
for(cl_uint i = 0; i < signalLength; ++i)
{
tempOutData[i] = tempOutData[i] / sqrt((float)signalLength);
}
cl_uint length = signalLength;
while(length > 1u)
{
for(cl_uint i = 0; i < length / 2; ++i)
{
cl_float data0 = tempOutData[2 * i];
cl_float data1 = tempOutData[2 * i + 1];
hOutData[i] = (data0 + data1) / sqrt((float)2);
hOutData[length / 2 + i] = (data0 - data1) / sqrt((float)2);
}
// Copy inData to hOutData
memcpy(tempOutData, hOutData, signalLength * sizeof(cl_float));
length >>= 1;
}
FREE(tempOutData);
return SDK_SUCCESS;
}
int
DwtHaar1D::getLevels(unsigned int length, unsigned int* levels)
{
cl_int returnVal = SDK_FAILURE;
for(unsigned int i = 0; i < 24; ++i)
{
if(length == (1 << i))
{
*levels = i;
returnVal = SDK_SUCCESS;
break;
}
}
return returnVal;
}
int DwtHaar1D::setupDwtHaar1D()
{
// signal length must be power of 2
signalLength = roundToPowerOf2<cl_uint>(signalLength);
unsigned int levels = 0;
int result = getLevels(signalLength, &levels);
CHECK_ERROR(result,SDK_SUCCESS, "signalLength > 2 ^ 23 not supported");
// Allocate and init memory used by host
inData = (cl_float*)malloc(signalLength * sizeof(cl_float));
CHECK_ALLOCATION(inData, "Failed to allocate host memory. (inData)");
for(unsigned int i = 0; i < signalLength; i++)
{
inData[i] = (cl_float)(rand() % 10);
}
dOutData = (cl_float*) malloc(signalLength * sizeof(cl_float));
CHECK_ALLOCATION(dOutData, "Failed to allocate host memory. (dOutData)");
memset(dOutData, 0, signalLength * sizeof(cl_float));
dPartialOutData = (cl_float*) malloc(signalLength * sizeof(cl_float));
CHECK_ALLOCATION(dPartialOutData,
"Failed to allocate host memory.(dPartialOutData)");
memset(dPartialOutData, 0, signalLength * sizeof(cl_float));
hOutData = (cl_float*)malloc(signalLength * sizeof(cl_float));
CHECK_ALLOCATION(hOutData, "Failed to allocate host memory. (hOutData)");
memset(hOutData, 0, signalLength * sizeof(cl_float));
if(!sampleArgs->quiet)
{
printArray<cl_float>("Input Signal", inData, 256, 1);
}
return SDK_SUCCESS;
}
int
DwtHaar1D::genBinaryImage()
{
bifData binaryData;
binaryData.kernelName = std::string("DwtHaar1DCPPKernel_Kernels.cl");
binaryData.flagsStr = std::string("-x clc++ ");
if(sampleArgs->isComplierFlagsSpecified())
{
binaryData.flagsFileName = std::string(sampleArgs->flags.c_str());
}
binaryData.binaryName = std::string(sampleArgs->dumpBinary.c_str());
int status = generateBinaryImage(binaryData);
return status;
}
int
DwtHaar1D::setupCL(void)
{
cl_int status = 0;
cl_device_type dType;
if(sampleArgs->deviceType.compare("cpu") == 0)
{
dType = CL_DEVICE_TYPE_CPU;
}
else //deviceType = "gpu"
{
dType = CL_DEVICE_TYPE_GPU;
if(sampleArgs->isThereGPU() == false)
{
std::cout << "GPU not found. Falling back to CPU device" << std::endl;
dType = CL_DEVICE_TYPE_CPU;
}
}
/*
* Have a look at the available platforms and pick either
* the AMD one if available or a reasonable default.
*/
cl_platform_id platform = NULL;
int retValue = getPlatform(platform, sampleArgs->platformId,
sampleArgs->isPlatformEnabled());
CHECK_ERROR(retValue, SDK_SUCCESS, "getPlatform() failed");
// Display available devices.
retValue = displayDevices(platform, dType);
CHECK_ERROR(retValue, SDK_SUCCESS, "displayDevices() failed");
// If we could find our platform, use it. Otherwise use just available platform.
cl_context_properties cps[3] =
{
CL_CONTEXT_PLATFORM,
(cl_context_properties)platform,
0
};
context = clCreateContextFromType(cps,
dType,
NULL,
NULL,
&status);
CHECK_OPENCL_ERROR(status, "clCreateContextFromType failed.");
// getting device on which to run the sample
status = getDevices(context, &devices, sampleArgs->deviceId,
sampleArgs->isDeviceIdEnabled());
CHECK_ERROR(status, SDK_SUCCESS, "getDevices() failed");
commandQueue = clCreateCommandQueue(context,
devices[sampleArgs->deviceId],
0,
&status);
CHECK_OPENCL_ERROR(status, "clCreateCommandQueue failed.");
//Set device info of given cl_device_id
retValue = deviceInfo.setDeviceInfo(devices[sampleArgs->deviceId]);
CHECK_ERROR(retValue, 0, "SDKDeviceInfo::setDeviceInfo() failed");
// Set Persistent memory only for AMD platform
cl_mem_flags inMemFlags = CL_MEM_READ_ONLY;
if(sampleArgs->isAmdPlatform())
{
inMemFlags |= CL_MEM_USE_PERSISTENT_MEM_AMD;
}
inDataBuf = clCreateBuffer(context,
inMemFlags,
sizeof(cl_float) * signalLength,
NULL,
&status);
CHECK_OPENCL_ERROR(status, "clCreateBuffer failed. (inDataBuf)");
dOutDataBuf = clCreateBuffer(context,
CL_MEM_WRITE_ONLY,
signalLength * sizeof(cl_float),
NULL,
&status);
CHECK_OPENCL_ERROR(status, "clCreateBuffer failed. (dOutDataBuf)");
dPartialOutDataBuf = clCreateBuffer(context,
CL_MEM_WRITE_ONLY,
signalLength * sizeof(cl_float),
NULL,
&status);
CHECK_OPENCL_ERROR(status, "clCreateBuffer failed. (dPartialOutDataBuf)");
// create a CL program using the kernel source
buildProgramData buildData;
buildData.kernelName = std::string("DwtHaar1DCPPKernel_Kernels.cl");
buildData.devices = devices;
buildData.deviceId = sampleArgs->deviceId;
buildData.flagsStr = std::string("-x clc++ ");
if(sampleArgs->isLoadBinaryEnabled())
{
buildData.binaryName = std::string(sampleArgs->loadBinary.c_str());
}
if(sampleArgs->isComplierFlagsSpecified())
{
buildData.flagsFileName = std::string(sampleArgs->flags.c_str());
}
retValue = buildOpenCLProgram(program, context, buildData);
CHECK_ERROR(retValue, 0, "buildOpenCLProgram() failed");
// get a kernel object handle for a kernel with the given name
kernel = clCreateKernel(program, "dwtHaar1D", &status);
CHECK_OPENCL_ERROR(status, "clCreateKernel failed.");
status = kernelInfo.setKernelWorkGroupInfo(kernel,
devices[sampleArgs->deviceId]);
CHECK_ERROR(status, SDK_SUCCESS, " setKernelWorkGroupInfo() failed");
return SDK_SUCCESS;
}
int DwtHaar1D::setWorkGroupSize()
{
cl_int status = 0;
globalThreads = curSignalLength >> 1;
localThreads = groupSize;
if(localThreads > deviceInfo.maxWorkItemSizes[0] ||
localThreads > deviceInfo.maxWorkGroupSize)
{
std::cout << "Unsupported: Device does not support"
"requested number of work items.";
return SDK_FAILURE;
}
if(kernelInfo.localMemoryUsed > deviceInfo.localMemSize)
{
std::cout << "Unsupported: Insufficient local memory on device." <<
std::endl;
return SDK_FAILURE;
}
return SDK_SUCCESS;
}
int DwtHaar1D::runDwtHaar1DKernel()
{
cl_int status;
status = this->setWorkGroupSize();
CHECK_ERROR(status, SDK_SUCCESS, "setWorkGroupSize failed");
// Force write to inData Buf to update its values
cl_event writeEvt;
status = clEnqueueWriteBuffer(
commandQueue,
inDataBuf,
CL_FALSE,
0,
curSignalLength * sizeof(cl_float),
inData,
0,
NULL,
&writeEvt);
CHECK_OPENCL_ERROR(status, "clEnqueueWriteBuffer failed. (inDataBuf)");
status = clFlush(commandQueue);
CHECK_OPENCL_ERROR(status, "clFlush failed.");
status = waitForEventAndRelease(&writeEvt);
CHECK_ERROR(status, SDK_SUCCESS, "WaitForEventAndRelease(writeEvt1) Failed");
ParaClass *paraClass = new ParaClass;//new a paraclass
this->classObj = clCreateBuffer(context,CL_MEM_USE_HOST_PTR,sizeof(ParaClass),
paraClass,&status);
CHECK_OPENCL_ERROR(status, "clclCreateBuffer failed. (inDataBuf)");
cl_event mapEvt;
paraClass=(ParaClass *)clEnqueueMapBuffer(commandQueue,this->classObj,CL_FALSE,
CL_MAP_WRITE,0,sizeof(ParaClass),0,NULL,&mapEvt,&status);
CHECK_OPENCL_ERROR(status, "clEnqueueMapBuffer failed. (classObj)");
status = clFlush(commandQueue);
CHECK_OPENCL_ERROR(status, "clFlush failed.");
status = waitForEventAndRelease(&mapEvt);
CHECK_ERROR(status, SDK_SUCCESS, "WaitForEventAndRelease(mapEvt1) Failed");
paraClass->setValue(this->totalLevels,this->curSignalLength,this->levelsDone,
this->maxLevelsOnDevice);
cl_event unmapEvt;
status=clEnqueueUnmapMemObject(commandQueue,this->classObj,paraClass,0,NULL,
&unmapEvt);//class is passed to the Device
CHECK_OPENCL_ERROR(status, "clEnqueueunMapBuffer failed. (classObj)");
status = clFlush(commandQueue);
CHECK_OPENCL_ERROR(status, "clFlush failed.");
status = waitForEventAndRelease(&unmapEvt);
CHECK_ERROR(status, SDK_SUCCESS, "WaitForEventAndRelease(mapEvt1) Failed");
// Whether sort is to be in increasing order. CL_TRUE implies increasing
status = clSetKernelArg(kernel,
0,
sizeof(cl_mem),
(void*)&inDataBuf);
CHECK_OPENCL_ERROR(status, "clSetKernelArg failed. (inDataBuf)");
status = clSetKernelArg(kernel,
1,
sizeof(cl_mem),
(void*)&dOutDataBuf);
CHECK_OPENCL_ERROR(status, "clSetKernelArg failed. (dOutDataBuf)");
status = clSetKernelArg(kernel,
2,
sizeof(cl_mem),
(void*)&dPartialOutDataBuf);
CHECK_OPENCL_ERROR(status, "clSetKernelArg failed. (dPartialOutData)");
status = clSetKernelArg(kernel,
3,
(localThreads * 2 * sizeof(cl_float)),
NULL);
CHECK_OPENCL_ERROR(status, "clSetKernelArg failed. (local memory)");
status = clSetKernelArg(kernel,
4,
sizeof(cl_mem),
(void*)&this->classObj);
CHECK_OPENCL_ERROR(status, "clSetKernelArg failed. (global memory)");
/*
* Enqueue a kernel run call.
*/
cl_event ndrEvt;
status = clEnqueueNDRangeKernel(
commandQueue,
kernel,
1,
NULL,
&globalThreads,
&localThreads,
0,
NULL,
&ndrEvt);
CHECK_OPENCL_ERROR(status, "clEnqueueNDRangeKernel failed.");
status = clFlush(commandQueue);
CHECK_OPENCL_ERROR(status, "clFlush failed.");
status = waitForEventAndRelease(&ndrEvt);
CHECK_ERROR(status, SDK_SUCCESS, "WaitForEventAndRelease(ndrEvt1) Failed");
// Enqueue the results to application pointer
cl_event readEvt1;
status = clEnqueueReadBuffer(
commandQueue,
dOutDataBuf,
CL_FALSE,
0,
signalLength * sizeof(cl_float),
dOutData,
0,
NULL,
&readEvt1);
CHECK_OPENCL_ERROR(status, "clEnqueueReadBuffer failed.");
// Enqueue the results to application pointer
cl_event readEvt2;
status = clEnqueueReadBuffer(
commandQueue,
dPartialOutDataBuf,
CL_FALSE,
0,
signalLength * sizeof(cl_float),
dPartialOutData,
0,
NULL,
&readEvt2);
CHECK_OPENCL_ERROR(status, "clEnqueueReadBuffer failed.");
status = clFlush(commandQueue);
CHECK_OPENCL_ERROR(status, "clFlush failed.");
status = waitForEventAndRelease(&readEvt1);
CHECK_ERROR(status, SDK_SUCCESS, "WaitForEventAndRelease(readEvt1) Failed");
status = waitForEventAndRelease(&readEvt2);
CHECK_ERROR(status, SDK_SUCCESS, "WaitForEventAndRelease(readEvt2) Failed");
delete paraClass;
clReleaseMemObject(this->classObj);
return SDK_SUCCESS;
}
int
DwtHaar1D::runCLKernels(void)
{
// Calculate thread-histograms
unsigned int levels = 0;
unsigned int curLevels = 0;
unsigned int actualLevels = 0;
int result = getLevels(signalLength, &levels);
CHECK_ERROR(result, SDK_SUCCESS, "getLevels() failed");
actualLevels = levels;
//max levels on device should be decided by kernelWorkGroupSize
int tempVar = (int)(log((float)kernelInfo.kernelWorkGroupSize) / log((float)2));
maxLevelsOnDevice = tempVar + 1;
cl_float* temp = (cl_float*)malloc(signalLength * sizeof(cl_float));
memcpy(temp, inData, signalLength * sizeof(cl_float));
levelsDone = 0;
int one = 1;
while((unsigned int)levelsDone < actualLevels)
{
curLevels = (levels < maxLevelsOnDevice) ? levels : maxLevelsOnDevice;
// Set the signal length for current iteration
if(levelsDone == 0)
{
curSignalLength = signalLength;
}
else
{
curSignalLength = (one << levels);
}
// Set group size
groupSize = (1 << curLevels) / 2;
totalLevels = levels;
runDwtHaar1DKernel();
if(levels <= maxLevelsOnDevice)
{
dOutData[0] = dPartialOutData[0];
memcpy(hOutData, dOutData, (one << curLevels) * sizeof(cl_float));
memcpy(dOutData + (one << curLevels), hOutData + (one << curLevels),
(signalLength - (one << curLevels)) * sizeof(cl_float));
break;
}
else
{
levels -= maxLevelsOnDevice;
memcpy(hOutData, dOutData, curSignalLength * sizeof(cl_float));
memcpy(inData, dPartialOutData, (one << levels) * sizeof(cl_float));
levelsDone += (int)maxLevelsOnDevice;
}
}
memcpy(inData, temp, signalLength * sizeof(cl_float));
free(temp);
return SDK_SUCCESS;
}
int
DwtHaar1D::initialize()
{
// Call base class Initialize to get default configuration
if(sampleArgs->initialize())
{
return SDK_FAILURE;
}
Option* length_option = new Option;
CHECK_ALLOCATION(length_option,
"Error. Failed to allocate memory (length_option)\n");
length_option->_sVersion = "x";
length_option->_lVersion = "signalLength";
length_option->_description = "Length of the signal";
length_option->_type = CA_ARG_INT;
length_option->_value = &signalLength;
sampleArgs->AddOption(length_option);
delete length_option;
Option* iteration_option = new Option;
CHECK_ALLOCATION(iteration_option,
"Error. Failed to allocate memory (iteration_option)\n");
iteration_option->_sVersion = "i";
iteration_option->_lVersion = "iterations";
iteration_option->_description = "Number of iterations for kernel execution";
iteration_option->_type = CA_ARG_INT;
iteration_option->_value = &iterations;
sampleArgs->AddOption(iteration_option);
delete iteration_option;
return SDK_SUCCESS;
}
int DwtHaar1D::setup()
{
if(iterations < 1)
{
std::cout<<"Error, iterations cannot be 0 or negative. Exiting..\n";
exit(0);
}
if(setupDwtHaar1D() != SDK_SUCCESS)
{
return SDK_FAILURE;
}
int timer = sampleTimer->createTimer();
sampleTimer->resetTimer(timer);
sampleTimer->startTimer(timer);
if(setupCL() != SDK_SUCCESS)
{
return SDK_FAILURE;
}
sampleTimer->stopTimer(timer);
// Compute setup time
setupTime = (double)(sampleTimer->readTimer(timer));
return SDK_SUCCESS;
}
int DwtHaar1D::run()
{
// Warm up
for(int i = 0; i < 2 && iterations != 1; i++)
{
// Arguments are set and execution call is enqueued on command buffer
if(runCLKernels() != SDK_SUCCESS)
{
return SDK_FAILURE;
}
}
std::cout << "Executing kernel for " <<
iterations << " iterations" << std::endl;
std::cout << "-------------------------------------------" << std::endl;
int timer = sampleTimer->createTimer();
sampleTimer->resetTimer(timer);
sampleTimer->startTimer(timer);
for(int i = 0; i < iterations; i++)
{
// Arguments are set and execution call is enqueued on command buffer
if(runCLKernels() != SDK_SUCCESS)
{
return SDK_FAILURE;
}
}
sampleTimer->stopTimer(timer);
// Compute kernel time
kernelTime = (double)(sampleTimer->readTimer(timer)) / iterations;
if(!sampleArgs->quiet)
{
printArray<cl_float>("dOutData", dOutData, 256, 1);
}
return SDK_SUCCESS;
}
int
DwtHaar1D::verifyResults()
{
if(sampleArgs->verify)
{
// Rreference implementation on host device
calApproxFinalOnHost();
// Compare the results and see if they match
bool result = true;
for(cl_uint i = 0; i < signalLength; ++i)
{
if(fabs(dOutData[i] - hOutData[i]) > 0.1f)
{
result = false;
break;
}
}
if(result)
{
std::cout << "Passed!\n" << std::endl;
return SDK_SUCCESS;
}
else
{
std::cout << "Failed\n" << std::endl;
return SDK_FAILURE;
}
}
return SDK_SUCCESS;
}
void DwtHaar1D::printStats()
{
if(sampleArgs->timing)
{
std::string strArray[3] = {"SignalLength", "Time(sec)", "[Transfer+Kernel]Time(sec)"};
sampleTimer->totalTime = setupTime + kernelTime;
std::string stats[3];
stats[0] = toString(signalLength, std::dec);
stats[1] = toString(sampleTimer->totalTime, std::dec);
stats[2] = toString(kernelTime, std::dec);
printStatistics(strArray, stats, 3);
}
}
int DwtHaar1D::cleanup()
{
// Releases OpenCL resources (Context, Memory etc.)
cl_int status;
status = clReleaseMemObject(inDataBuf);
CHECK_OPENCL_ERROR(status, "clReleaseMemObject failed.(inDataBuf)");
status = clReleaseMemObject(dOutDataBuf);
CHECK_OPENCL_ERROR(status, "clReleaseMemObject failed.(dOutDataBuf)");
status = clReleaseMemObject(dPartialOutDataBuf);
CHECK_OPENCL_ERROR(status, "clReleaseMemObject failed.(dPartialOutDataBuf)");
status = clReleaseKernel(kernel);
CHECK_OPENCL_ERROR(status, "clReleaseKernel failed.(kernel)");
status = clReleaseProgram(program);
CHECK_OPENCL_ERROR(status, "clReleaseProgram failed.(program)");
status = clReleaseCommandQueue(commandQueue);
CHECK_OPENCL_ERROR(status, "clReleaseCommandQueue failed.(commandQueue)");
status = clReleaseContext(context);
CHECK_OPENCL_ERROR(status, "clReleaseContext failed.(context)");
// Release program resources (input memory etc.)
FREE(inData);
FREE(dOutData);
FREE(dPartialOutData);
FREE(hOutData);
FREE(devices);
return SDK_SUCCESS;
}
int
main(int argc, char * argv[])
{
// Create MonteCalroAsian object
DwtHaar1D clDwtHaar1D;
// Initialization
if(clDwtHaar1D.initialize() != SDK_SUCCESS)
{
return SDK_FAILURE;
}
// Parse command line options
if(clDwtHaar1D.sampleArgs->parseCommandLine(argc, argv) != SDK_SUCCESS)
{
return SDK_FAILURE;
}
if(clDwtHaar1D.sampleArgs->isDumpBinaryEnabled())
{
return clDwtHaar1D.genBinaryImage();
}
// Setup
if(clDwtHaar1D.setup()!=SDK_SUCCESS)
{
return SDK_FAILURE;
}
// Run
if(clDwtHaar1D.run()!=SDK_SUCCESS)
{
return SDK_FAILURE;
}
// Verify
if(clDwtHaar1D.verifyResults()!=SDK_SUCCESS)
{
return SDK_FAILURE;
}
// Cleanup resources created
if(clDwtHaar1D.cleanup()!=SDK_SUCCESS)
{
return SDK_FAILURE;
}
// Print performance statistics
clDwtHaar1D.printStats();
return SDK_SUCCESS;
}
| [
"gabriele@Gabrieles-MacBook-Pro.local"
] | gabriele@Gabrieles-MacBook-Pro.local |
932e07fcb4ac5c0b4ae443e9d4a7d5269ea7a688 | d1f5d8ce94915a9752db25d76858eb867a30a3c3 | /src/Camera.cpp | 892145574f0ac29d4139bfa266d6944ffaccff1a | [] | no_license | anilguneyaltun/opengl-workout | 3fb8ad14afbc463fa8440087c6ea3ca2333ed336 | d810c73aaffd1384c9cdbc3f9ba483ff694e7366 | refs/heads/master | 2023-06-24T07:04:42.607125 | 2021-07-24T16:12:21 | 2021-07-24T16:12:21 | 332,916,902 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,736 | cpp | #include "Camera.h"
Camera::Camera() {}
Camera::Camera(glm::vec3 startPosition, glm::vec3 startUp, GLfloat startYaw, GLfloat startPitch, GLfloat startMoveSpeed, GLfloat startTurnSpeed)
{
position = startPosition;
worldUp = startUp;
yaw = startYaw;
pitch = startPitch;
front = glm::vec3(0.0f, 0.0f, -1.0f);
movementSpeed = startMoveSpeed;
turnSpeed = startTurnSpeed;
update();
}
void Camera::keyControl(bool* keys, GLfloat deltaTime)
{
GLfloat velocity = movementSpeed * deltaTime;
if (keys[GLFW_KEY_W])
{
position += front * velocity;
}
if (keys[GLFW_KEY_S])
{
position -= front * velocity;
}
if (keys[GLFW_KEY_A])
{
position -= right * velocity;
}
if (keys[GLFW_KEY_D])
{
position += right * velocity;
}
}
void Camera::mouseControl(GLfloat xChange, GLfloat yChange)
{
xChange *= turnSpeed;
yChange *= turnSpeed;
yaw += xChange;
pitch += yChange;
if (pitch > 89.0f)
{
pitch = 89.0f;
}
if (pitch < -89.0f)
{
pitch = -89.0f;
}
update();
}
glm::mat4 Camera::calculateViewMatrix()
{
return glm::lookAt(position, position + front, up);
}
glm::vec3 Camera::getCameraPosition()
{
return position;
}
glm::vec3 Camera::getCameraDirection()
{
return glm::normalize(front);
}
void Camera::update()
{
front.x = cos(glm::radians(yaw)) * cos(glm::radians(pitch));
front.y = sin(glm::radians(pitch));
front.z = sin(glm::radians(yaw)) * cos(glm::radians(pitch));
front = glm::normalize(front);
right = glm::normalize(glm::cross(front, worldUp));
up = glm::normalize(glm::cross(right, front));
}
Camera::~Camera()
{
}
| [
"anilguneyaltun@gmail.com"
] | anilguneyaltun@gmail.com |
e4456a4f08f997f7f06be24ed684bbd63910fd4e | ecac474a3f5095c61cfccd0e69cab0d4ca050ebd | /BZOJ/BZOJ1137-Wsp岛屿-单调栈.cpp | e47b6b32fdd995fa89cb3363a3a4e641c19a9734 | [
"Apache-2.0"
] | permissive | xehoth/OnlineJudgeCodes | 478e678b35ba1b7e168b8230da594f03532aa74c | 013d31cccaaa1d2b6d652c2f5d5d6cb2e39884a7 | refs/heads/master | 2021-01-20T05:37:25.194545 | 2019-08-17T16:07:02 | 2019-08-17T16:07:02 | 101,457,867 | 7 | 3 | null | null | null | null | UTF-8 | C++ | false | false | 3,599 | cpp | /**
* Copyright (c) 2016-2018, xehoth
* All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* 「BZOJ 1137」Wsp 岛屿 24-02-2018
* 单调栈
* @author xehoth
*/
#include <cctype>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <vector>
struct InputStream {
enum { SIZE = 1 << 18 | 1 };
char ibuf[SIZE], *s, *t;
InputStream() : s(), t() {}
inline char read() {
return (s == t) && (t = (s = ibuf) + fread(ibuf, 1, SIZE, stdin)),
s == t ? -1 : *s++;
}
template <typename T>
inline InputStream &operator>>(T &x) {
static char c;
static bool iosig;
for (c = read(), iosig = false; !isdigit(c); c = read()) {
if (c == -1) return *this;
iosig |= c == '-';
}
for (x = 0; isdigit(c); c = read()) x = x * 10 + (c ^ '0');
iosig && (x = -x);
return *this;
}
} io;
struct Point {
double x, y;
Point() {}
Point(const double x, const double y) : x(x), y(y) {}
inline Point operator-(const Point &p) const {
return Point(x - p.x, y - p.y);
}
inline Point operator+(const Point &p) const {
return Point(x + p.x, y + p.y);
}
inline double operator*(const Point &p) const { return x * p.y - y * p.x; }
inline Point operator*(double p) const { return Point(x * p, y * p); }
inline void read() {
static int v;
io >> v;
x = v;
io >> v;
y = v;
}
inline double norm() const { return sqrt(x * x + y * y); }
};
struct Line {
Point s, t;
Line() {}
Line(const Point &s, const Point &t) : s(s), t(t) {}
inline Point intersect(const Line &l) const {
return s +
(t - s) * (((l.s - s) * (l.t - s)) / ((t - s) * (l.t - l.s)));
}
};
std::vector<Point> p;
std::vector<Line> q;
inline void add(int i, int j) {
Line tmp(p[i], p[j]);
while ((int)q.size() > 1 && (p[j] - p[i]) * (q[(int)q.size() - 1].intersect(
q[(int)q.size() - 2]) -
p[i]) >
0)
q.pop_back();
q.push_back(tmp);
}
int main() {
int n, m;
io >> n >> m;
std::vector<std::vector<int> > g(n + 1);
p.resize(n + 1);
for (int i = 1; i <= n; i++) p[i].read();
for (int i = 0, u, v; i < m; i++) {
io >> u >> v;
if (u < v)
g[u].push_back(v);
else
g[v].push_back(u);
}
std::vector<int> vis(n + 1);
int now = 0;
for (int i = 1, j; i < n; i++) {
for (j = 0; j < (int)g[i].size(); j++) vis[g[i][j]] = i;
for (j = n; j > 0 && vis[j] == i; j--)
;
if (j > now) add(i, now = j);
}
Point tmp, last = p[1];
double ans = 0;
for (int i = 0; i < (int)q.size() - 1; i++) {
tmp = q[i].intersect(q[i + 1]);
ans += (tmp - last).norm();
last = tmp;
}
ans += (p[n] - last).norm();
printf("%.9f", ans);
return 0;
} | [
"824547322@qq.com"
] | 824547322@qq.com |
e706d3060f6426fd7a2c8591155bef6602a3b8d3 | 050ebbbc7d5f89d340fd9f2aa534eac42d9babb7 | /grupa1/koredmat/p1/poc.cpp | 18866ac6533c0da4555c4cb6ede08296d483928c | [] | no_license | anagorko/zpk2015 | 83461a25831fa4358366ec15ab915a0d9b6acdf5 | 0553ec55d2617f7bea588d650b94828b5f434915 | refs/heads/master | 2020-04-05T23:47:55.299547 | 2016-09-14T11:01:46 | 2016-09-14T11:01:46 | 52,429,626 | 0 | 13 | null | 2016-03-22T09:35:25 | 2016-02-24T09:19:07 | C++ | UTF-8 | C++ | false | false | 208 | cpp | #include <iostream>
using namespace std;
int main() {
cout << "Mount Everest - 8850 m n.p.m." << endl;
cout << "McKinley - 6194 m n.p.m." << endl;
cout << "Mont Blanc - 4810 m n.p.m." << endl;
}
| [
"e.lasek@student.uw.edu.pl"
] | e.lasek@student.uw.edu.pl |
66dcdb42a58c85ee7a7670496111ece754efde0f | 228875e8bf8745b43f4615fb4b1ebad7e747d57f | /mysql.cpp | 9b9199d4b39999385db326ac78da02fcb57797f2 | [] | no_license | Nicer0815/JLU-C-2020 | 7af53415557964c05f07c6f5fbdea7089e050a2c | 106583f8f26c73b4240a71f58c3fb77835f8ce66 | refs/heads/main | 2023-09-05T06:22:36.983647 | 2021-11-26T06:40:22 | 2021-11-26T06:40:22 | 305,566,267 | 27 | 4 | null | null | null | null | UTF-8 | C++ | false | false | 20,273 | cpp | #include "serverHead.h"
extern unsigned __int64 client[10][2];
extern char onlineName[10][20];
extern char onlineQQID[10][20];
extern int clientNum;
User_mysql::User_mysql()
{
strcpy_s(user, "root");
strcpy_s(pswd, "2");
strcpy_s(host, "localhost");
port = 3307;
mysql_init(&myCont);
if (mysql_real_connect(&myCont, host, user, pswd, "mydesign", port, NULL, 0))
{
mysql_query(&myCont, "SET NAMES GBK");
if (mysql_query(&myCont, "use mydesign"))
{
cout << "fail to use mydesign in confirm stage " << endl;
system("pause");
exit(-1);
}
cout << "mydesign 成功打开" << endl;
}
else
{
cout << "fail to connect mydesign in confirm stage" << endl;
system("pause");
exit(-1);
}
}
//检测总平台账号密码的正确性,并提前将各平台账号存储至Data以便接下来各平台对象的构造
int User_mysql::login(message & Data)
{
char order[1024];
sprintf_s(order, "SELECT * FROM id_confirm WHERE 账号='%s'", Data.ID);
res = mysql_query(&myCont, order);
if (!res)
{
result = mysql_store_result(&myCont);
if (result)
{
//如果查询不为空
if (sql_row = mysql_fetch_row(result))
{
//密码正确
if (!strcmp(sql_row[1], Data.paswad))
{
//提前把三个账号存储到Data中 方便 微X平台的对象的构造
strcpy_s(Data.QQID, sql_row[3]);
strcpy_s(Data.WCID, sql_row[4]);
strcpy_s(Data.WBID, sql_row[5]);
//对QQ特异性实现的即时聊天功能
strcpy_s(onlineQQID[clientNum - 1], Data.QQID);
return 1;
}
else
{
return 3;
}
}
//账号不存在
else
{
return 2;
}
}
}
else
{
cout << "查询失败" << endl;
system("pause");
exit(-1);
}
//账号不存在
return 2;
}
//返回客户端基类 user 构造所需信息
int User_mysql::returnInfo(message & Data)
{
char order[1024];
sprintf_s(order, "SELECT * FROM id_confirm WHERE 账号='%s'", Data.ID);
res = mysql_query(&myCont, order);
if (!res)
{
result = mysql_store_result(&myCont);
if (result)
{
//如果查询不为空
if (sql_row = mysql_fetch_row(result))
{
//后期再增加信息?
strcpy_s(Data.ID, sql_row[0]);
cout << "user return over" << endl;
return 1;
}
//账号不存在
else
{
cout << "return User_Info error cause ID do not exist" << endl;
return 2;
}
}
else
{
cout << "return User_Info error cause ID do not exist" << endl;
return 2;
}
}
else
{
cout << "return info sql 请求语句失败" << endl;
return 3;
}
}
//QQ好友数据库对象构造函数
Friend_mysql::Friend_mysql()
{
strcpy_s(user, "root");
strcpy_s(pswd, "201501516lyn...");
strcpy_s(host, "localhost");
port = 3307;
mysql_init(&myCont);
if (mysql_real_connect(&myCont, host, user, pswd, "mydesign", port, NULL, 0))
{
mysql_query(&myCont, "SET NAMES GBK");
if (mysql_query(&myCont, "use mydesign"))
{
cout << "fail to use mydesign in confirm stage " << endl;
system("pause");
exit(-1);
}
cout << "mydesign 成功打开" << endl;
}
else
{
cout << "fail to connect mydesign in confirm stage" << endl;
system("pause");
exit(-1);
}
}
//QQ群数据库对象构造函数
Group_mysql::Group_mysql()
{
strcpy_s(user, "root");
strcpy_s(pswd, "201501516lyn...");
strcpy_s(host, "localhost");
port = 3307;
mysql_init(&myCont);
if (mysql_real_connect(&myCont, host, user, pswd, "mydesign", port, NULL, 0))
{
mysql_query(&myCont, "SET NAMES GBK");
if (mysql_query(&myCont, "use mydesign"))
{
cout << "fail to use mydesign in confirm stage " << endl;
system("pause");
exit(-1);
}
cout << "mydesign 成功打开" << endl;
}
else
{
cout << "fail to connect mydesign in confirm stage" << endl;
system("pause");
exit(-1);
}
}
//去数据库中返回 -本人- 详细信息,即客户端myqq对象构造所需信息
int Friend_mysql::returnDetails(message & Data)
{
char order[1024];
sprintf_s(order, "SELECT * FROM %s_details WHERE %s账号=%s"
,Data.table, Data.table, Data.XID);
cout << order << endl;
Data.platform = 0;
res = mysql_query(&myCont, order);
if (!res)
{
result = mysql_store_result(&myCont);
if (result)
{
//查询结果不为空
if (sql_row = mysql_fetch_row(result))
{
//删了Data.platform
Data.platform = 1;
strcpy_s(Data.Name, sql_row[1]); //微X名字
Data.TAge = atoi(sql_row[2]); //T龄
strcpy_s(Data.BirthDay, sql_row[3]); //出生日期
strcpy_s(Data.Place, sql_row[4]); //所在地
if (strcmp(sql_row[5], "0"))
{
if (!strcmp("qq", Data.table))
{
Data.platform = 10;
strcpy_s(Data.WCID, sql_row[5]);
}
else if (!strcmp("wc", Data.table))
{
Data.platform = 10;
strcpy_s(Data.QQID, sql_row[5]);
}
else if (!strcmp("wb", Data.table))
{
Data.platform = 10;
strcpy_s(Data.WBID, sql_row[5]);
}
else //非QQ构造函数
{
Data.platform = -10;
strcpy_s(Data.QQID, sql_row[5]);
}
}
//记录当前上线的客户端的QQ账号 和 名字
if (!strcmp(Data.table, "qq"))
{
client[clientNum - 1][1] = atoi(Data.QQID);
strcpy_s(onlineName[clientNum - 1], Data.Name);
cout << clientNum << "位: "
<< client[clientNum - 1][1] << " QQ用户: "
<< onlineName[clientNum - 1] << "上线" << endl;
}
return 1;
}
else
{
cout << "sql "<<Data.table<<"_details 查询结果为空,该用户可能不存在" << endl;
return 2;
}
}
else
{
cout << "sql " << Data.table << "_details 查询结果为空,该用户可能不存在" << endl;
return 2;
}
}
else
{
cout << "sql " << Data.table << "_datails 请求语句失败" << endl;
return 3;
}
}
//去数据库中返回好友列表,即客户端myqq对象构造所需信息
int Friend_mysql::returnInfo(message & Data)
{
char order[1024];
sprintf_s(order
, "SELECT * FROM %s_friend WHERE 所属账号='%s'"
,Data.table, Data.XID);
res = mysql_query(&myCont, order);
Data.FriendNum = 0;
if (!res)
{
result = mysql_store_result(&myCont);
if (result)
{
//如果查询不为空
while (sql_row = mysql_fetch_row(result))
{
strcpy_s(Data.FriendList[Data.FriendNum], sql_row[1]);
strcpy_s(Data.FriendAccount[Data.FriendNum], sql_row[4]);
strcpy_s(Data.FriendNickName[Data.FriendNum], sql_row[3]);
Data.FriendNum++;
cout << "好友序号" << Data.FriendNum <<":"<< sql_row[1] <<"---"<< sql_row[3];
cout << endl;
}
//账号不存在
if(!Data.FriendNum)
{
cout << "return FriendList error cause ID do not have" << endl;
return 2;
}
else
{
return 1;
}
}
{
cout << "return FriendList error cause ID do not have(result)" << endl;
return 2;
}
}
else
{
cout << "return FriendList sql 请求语句失败" << endl;
return 3;
}
}
//去数据库中返回群组列表,即客户端myqq对象构造所需信息
int Group_mysql::returnInfo(message & Data)
{
char order[1024];
sprintf_s(order
, "SELECT * FROM %s_group WHERE 群成员账号='%s'"
,Data.table, Data.XID);
res = mysql_query(&myCont, order);
Data.GroupNum = 0;
int cnt = 0;
if (!res)
{
result = mysql_store_result(&myCont);
if (result)
{
//如果查询不为空
while (sql_row = mysql_fetch_row(result))
{
cnt++;
strcpy_s(Data.GroupList[Data.GroupNum], sql_row[0]);
strcpy_s(Data.GroupName[Data.GroupNum], sql_row[2]);
Data.GroupStatus[Data.GroupNum] = atoi(sql_row[5]);
Data.GroupNum++;
}
//账号不存在
if (!cnt)
{
cout << "return GroupList error cause ID do not have" << endl;
return 2;
}
else
{
return 1;
}
}
{
cout << "return GroupList error cause ID do not have(result)" << endl;
return 2;
}
}
else
{
cout << "return GroupList sql 请求语句失败" << endl;
return 3;
}
}
//去数据库中设置好友备注(修改好友信息)
int Friend_mysql::setNicknameToFriend(message & Data)
{
char order[1024];
sprintf_s(order, "UPDATE %s_friend SET 好友备注='%s' WHERE 所属账号=%s AND 好友账号= %s"
,Data.table, Data.NickName, Data.ID, Data.XID);
res = mysql_query(&myCont, order);
//sql 语句执行成功
//cout <<"查看res返回值ing:"<< res << endl; //成功了而且res==1;
if (!res)
{
return 1;
}
else
{
return 0;
}
}
//去数据库中把好友的详细信息返回
int Friend_mysql::findFriend(message & Data)
{
char order[1024];
sprintf_s(order, "SELECT * FROM %s_details WHERE %s账号=%s"
,Data.table,Data.table, Data.XID);
cout << order << endl;
res = mysql_query(&myCont, order);
if (!res)
{
result = mysql_store_result(&myCont);
if (result)
{
if (sql_row = mysql_fetch_row(result))
{
strcpy_s(Data.Name, sql_row[1]); //微X名字
Data.TAge = atoi(sql_row[2]); //T龄
strcpy_s(Data.BirthDay, sql_row[3]); //出生日期
strcpy_s(Data.Place, sql_row[4]); //所在地
return 1;
}
else
{
cout << "sql "<< Data.table <<"_details 查询结果为空,该用户可能不存在" << endl;
return 2;
}
}
else
{
cout << "sql "<<Data.table <<"_details 查询结果为空,该用户可能不存在(result)" << endl;
return 2;
}
}
else
{
cout << "sql "<< Data.table <<"_datails 请求语句失败" << endl;
return 3;
}
}
//去数据库退群
int Group_mysql::dropGroup(message & Data)
{
char order[1024];
sprintf_s(order
, "DELETE FROM %s_group WHERE 群号=%s AND 群成员账号=%s"
,Data.table, Data.GID, Data.XID);
res = mysql_query(&myCont, order);
if (!res)
{
cout <<Data.XID <<"退群"<<Data.GID<<"成功" << endl;
return 1;
}
else
{
cout << "退群失败 sql 语句请求失败" << endl;
return 0;
}
}
//去数据库删除好友
int Friend_mysql::deleteFriend(message & Data)
{
char order[1024];
sprintf_s(order
, "DELETE FROM %s_friend WHERE 所属账号=%s AND 好友账号=%s"
,Data.table, Data.ID, Data.XID);
res = mysql_query(&myCont, order);
sprintf_s(order
, "DELETE FROM %s_friend WHERE 所属账号=%s AND 好友账号=%s"
,Data.table, Data.XID, Data.ID);
res = mysql_query(&myCont, order);
if (!res)
{
cout << Data.ID << "删除好友" << Data.XID << "成功" << endl;
return 1;
}
else
{
cout << "删除好友失败 sql 语句请求失败" << endl;
return 0;
}
}
//去数据库添加群
int Group_mysql::addGroup(message & Data)
{
int groupKind = -1;
char order[1024];
sprintf_s(order
, "SELECT * FROM %s_group WHERE 群号=%s"
,Data.table, Data.GID);
cout << "准备查询群的具体信息。。。" << endl;
cout << order << endl;
res = mysql_query(&myCont, order);
if (!res)
{
result = mysql_store_result(&myCont);
if (result)
{
if (sql_row = mysql_fetch_row(result))
{
strcpy_s(Data.GroupName[0], sql_row[2]);
groupKind = atoi(sql_row[1]);
cout << "群名称" << Data.GroupName[0] << "群类型" << groupKind << endl;
}
}
}
//相当于flag值,判断前面查询过程是否已经顺利执行查询
if (groupKind == -1)
{
cout << "加群失败 sql 语句没有查到该群" << endl;
return 0;
}
sprintf_s(order
, "INSERT INTO %s_group VALUES (%s,%d,'%s',%s,'%s',0)"
,Data.table, Data.GID, groupKind,Data.GroupName[0], Data.XID,Data.Name);
res = mysql_query(&myCont, order);
if (!res)
{
cout << Data.XID << "加群" << Data.GID << "成功" << endl;
return 1;
}
else
{
cout << "加群失败 sql 语句请求失败" << endl;
return 0;
}
}
//去数据库加好友
int Friend_mysql::addFriend(message & Data)
{
int flag = 0;
char TID[12];
char friendName[20];
char order[1024];
sprintf_s(order
, "SELECT * FROM id_confirm WHERE %s账号=%s"
,Data.table, Data.XID);
cout << order << endl;
res = mysql_query(&myCont, order);
if (!res)
{
result = mysql_store_result(&myCont);
if (result)
{
if (sql_row = mysql_fetch_row(result))
{
flag = 1;
strcpy_s(TID, sql_row[0]);
strcpy_s(friendName, sql_row[6]);
cout << "好友名字:" << friendName << "平台总账号:" << TID << endl;
}
}
}
if (!flag)
{
cout << "没有找到" << Data.XID << endl;
return 0;
}
sprintf_s(order
, "INSERT INTO %s_friend VALUES (%s,%s,'%s','%s',%s)"
,Data.table, Data.ID, Data.XID, friendName, Data.NickName, TID);
res = mysql_query(&myCont, order);
sprintf_s(order
, "INSERT INTO %s_friend VALUES (%s,%s,'%s','%s',%s)"
,Data.table, Data.XID, Data.ID, Data.Name, Data.Name, Data.GID);
res = mysql_query(&myCont, order);
if (!res)
{
cout << Data.ID << "添加好友" << Data.XID << "成功" << endl;
return 1;
}
else
{
cout << "添加好友失败 sql 语句请求失败" << endl;
return 0;
}
}
//根据平台总账号,去数据库中查询 微X平台账号是否存在(存在即可推荐)
int Friend_mysql::isExist(message & Data)
{
char order[1024];
sprintf_s(order, "SELECT * FROM id_confirm WHERE 账号=%s AND %s账号<>0 "
, Data.ID, Data.table);
cout << order << endl;
res = mysql_query(&myCont, order);
if (!res)
{
result = mysql_store_result(&myCont);
if (result)
{
if (sql_row = mysql_fetch_row(result))
{
int line = -1;
if (!strcmp("qq", Data.table))line = 3;
else if (!strcmp("wc", Data.table))line = 4;
else line = 5;
strcpy_s(Data.XID, sql_row[line]);
cout << "找到对应的" << Data.table << "账号:" << Data.XID << endl;
return 1;
}
}
}
return 0;
}
//去数据库踢人
int Group_mysql::kickGroupMember(message & Data)
{
char order[1024];
int myStatus= -1;
int itStatus= -1;
sprintf_s(order
, "SELECT * FROM %s_group WHERE 群号=%s AND 群成员账号=%s"
,Data.table, Data.GID, Data.ID);
cout << order << endl;
res = mysql_query(&myCont, order);
if (!res)
{
result = mysql_store_result(&myCont);
if (result)
{
if (sql_row = mysql_fetch_row(result))
{
myStatus = atoi(sql_row[5]);
cout << "myStatus:" << myStatus << endl;
}
}
}
if (myStatus == -1)
{
cout << "没查到myStatus" << endl;
return -1;
}
sprintf_s(order
, "SELECT * FROM %s_group WHERE 群号=%s AND 群成员账号=%s"
,Data.table, Data.GID, Data.XID);
cout << order << endl;
res = mysql_query(&myCont, order);
if (!res)
{
result = mysql_store_result(&myCont);
if (result)
{
if (sql_row = mysql_fetch_row(result))
{
itStatus = atoi(sql_row[5]);
cout << "itStatus:" << itStatus << endl;
}
}
}
if (itStatus == -1)
{
cout << "没查到itStatus" << endl;
return -1;
}
if (myStatus <= itStatus)
{
cout << "地位太低踢不了" << endl;
return 0;
}
sprintf_s(order
, "DELETE FROM %s_group WHERE 群号=%s AND 群成员账号=%s"
,Data.table, Data.GID, Data.XID);
cout << order << endl;
res = mysql_query(&myCont, order);
if (!res)
{
cout << Data.ID << "将" << Data.XID << "从" << Data.GID << "群中踢出" << endl;
return 1;
}
else
{
cout << "踢人sql语句执行失败" << endl;
return -2;
}
}
//去数据库中把某个群的成员信息返回
int Group_mysql::listMember(message & Data)
{
char order[1024];
sprintf_s(order
, "SELECT * FROM %s_group WHERE 群号=%s"
,Data.table, Data.GID);
res = mysql_query(&myCont, order);
//成员个数
Data.GroupNum = 0;
if (!res)
{
result = mysql_store_result(&myCont);
if (result)
{
while (sql_row = mysql_fetch_row(result))
{
strcpy_s(Data.GroupList[Data.GroupNum], sql_row[3]); //账号
strcpy_s(Data.GroupName[Data.GroupNum], sql_row[4]); //名字
Data.GroupStatus[Data.GroupNum] = atoi(sql_row[5]); //身份
Data.GroupNum++;
}
}
}
if (0 == Data.GroupNum)
{
cout << Data.GID << "群内没人" << endl;
return 0;
}
else
{
cout << Data.GID << "群查到" << Data.GroupNum << "个成员" <<endl;
return 1;
}
}
//去数据库中升级QQ群
int Group_mysql::levelUpGroup(message & Data)
{
char order[1024];
sprintf_s(order
, "SELECT * FROM %s_group WHERE 群号=%s AND 群成员账号=%s"
,Data.table, Data.GID, Data.ID);
int flag = 0;
res = mysql_query(&myCont, order);
if (!res)
{
result = mysql_store_result(&myCont);
if (result)
{
if (sql_row = mysql_fetch_row(result))
{
if (1 == atoi(sql_row[1])) //群已经是最高级
{
Data.action = 0;
return 0;
}
if (3 != atoi(sql_row[5])) //不是群主
{
Data.action = -1;
return -1;
}
flag = 1;
}
}
}
if (flag)
{
sprintf_s(order
, "UPDATE %s_group SET 群类型=1 WHERE 群号=%s"
,Data.table, Data.GID);
res = mysql_query(&myCont, order);
cout << order << endl;
cout <<Data.GID<< "成功升级为常规"<< Data.table <<"群" << endl;
Data.action = 1;
return 1;
}
else
{
cout << "没有找到符合要求的群组" << endl;;
return -1;
}
}
//去数据库创建群
int Group_mysql::creatGroup(message & Data)
{
char order[1024];
sprintf_s(order, "select 群号 FROM %s_group order by 群号 desc"
, Data.table);
res = mysql_query(&myCont, order);
int maxGid = 0;
if (!res)
{
result = mysql_store_result(&myCont);
if (result)
{
if (sql_row = mysql_fetch_row(result))
{
maxGid = atoi(sql_row[0]);
}
}
}
if (!maxGid)
{
cout << "sql 自动分配群账号失败" << endl;
return 0;
}
_itoa_s(maxGid + 1, Data.GroupList[0], 10);
sprintf_s(order
, "INSERT INTO %s_group VALUES(%d,1,'%s',%s,'%s',3)"
,Data.table, maxGid + 1, Data.GroupName[1], Data.GroupList[1],Data.Name);
res = mysql_query(&myCont, order);
if (!res)
{
return 1;
}
else
{
return 0;
}
}
//去数据库创建子群(复制原群成员,谁创建谁是子群的群主)
int Group_mysql::creatTempGroup(message & Data)
{
char order[1024];
sprintf_s(order, "select 群号 FROM %s_group order by 群号 desc"
, Data.table);
res = mysql_query(&myCont, order);
int maxGid = 0;
if (!res)
{
result = mysql_store_result(&myCont);
if (result)
{
if (sql_row = mysql_fetch_row(result))
{
maxGid = atoi(sql_row[0]);
}
}
}
if (!maxGid)
{
cout << "sql 自动分配子群账号失败" << endl;
return 0;
}
char origin_Gid[10];
strcpy_s(origin_Gid, Data.GID);
char GName[21];
strcpy_s(GName, Data.GroupName[1]);
_itoa_s(maxGid + 1, Data.GID, 10);
//从原群插入人
sprintf_s(order
, "SELECT * FROM %s_group WHERE 群号=%s"
, Data.table, origin_Gid);
res = mysql_query(&myCont, order);
//成员个数
Data.GroupNum = 0;
if (!res)
{
result = mysql_store_result(&myCont);
if (result)
{
while (sql_row = mysql_fetch_row(result))
{
strcpy_s(Data.GroupList[Data.GroupNum], sql_row[3]); //账号
strcpy_s(Data.GroupName[Data.GroupNum], sql_row[4]); //名字
Data.GroupNum++;
}
}
}
for (int i = 0; i < Data.GroupNum; i++)
{
sprintf_s(order
, "INSERT INTO %s_group VALUES(%d,2,'%s',%s,'%s',1)"
, Data.table, maxGid + 1, GName, Data.GroupList[i], Data.GroupName[i]);
cout << order << endl;
res = mysql_query(&myCont, order);
if (res)
{
cout << "复制成员出错" << endl;
return -1;
}
}
sprintf_s(order
, "UPDATE %s_group SET 群成员身份 = 3 WHERE 群号=%d AND 群成员账号=%s"
, Data.table, maxGid + 1, Data.XID);
cout << order << endl;
res = mysql_query(&myCont, order);
if (!res)
{
cout << "子群群主设置成功" << endl;
return 1;
}
else
{
cout << "子群群主设置失败" << endl;
return -1;
}
}
| [
"noreply@github.com"
] | Nicer0815.noreply@github.com |
1ffe7a90a823d904257932d0ac1d2903d1fa961a | 4af3f82a9e4c8f8cd40dbd0086e0b931f051ce30 | /Particle_engine/Particle.h | 123a52ce0bef5c4b4d4e77f5ce3b7901fc61ed5d | [] | no_license | ntaztonny/Particle-engine | ae9a38468677147f0603f2cacb5b1527ef21bed0 | a91d67552eae15dff62aa75b24eaada1121b69ce | refs/heads/master | 2020-05-29T16:51:48.855818 | 2019-05-29T18:37:05 | 2019-05-29T18:37:05 | 189,260,696 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 508 | h |
#ifndef PARTICLE_H
#define PARTICLE_H
#include "GLEngine.h"
#include "Vector3.h"
class Particle
{
public:
Particle(int id);
void Update (long time);
// variables
int id;
long lastTime;
float totalLife;
float life;
float alpha;
float size;
float bounciness;
bool active;
Vector3 color;
Vector3 position;
Vector3 velocity;
Vector3 acceleration;
Vector3 rotation;
private:
void rotate(float angle, float &y, float &z);
};
#endif | [
"noreply@github.com"
] | ntaztonny.noreply@github.com |
642072063d4c7daa6059424fa3d3e674fa7f2c84 | 7feafc361420ba68c0df24840e62d18ccfdf11ef | /CSE/u/Recovered data 05-03-2015 at 01_06_36/NTFS/My pc/programing fun/C++/File/gcount( ).cpp | 9209df963bb086507d94cd9f1fab86f312610363 | [] | no_license | omarKaushru/Numb-UV-Life-activites | b7e94645c9bbc52317fcb80cd6c83e95793fcefb | 63a74e875edee6dc5cfe77439247172da009f2c5 | refs/heads/master | 2022-12-05T11:34:12.142216 | 2020-09-01T18:19:41 | 2020-09-01T18:19:41 | 292,070,016 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 666 | cpp | #include<iostream>
#include<fstream>
#include<conio.h>
using namespace std;
main()
{
double fnum[4] = {99.75, -34.4, 1776.0, 200.1};
int i;
ofstream out("numbers", ios::out | ios::binary);
if(!out) {
cout << "Cannot open file.";
return 1;
}
out.write((char *) &fnum, sizeof fnum);
out.close();
for(i=0; i<4; i++) // clear array
fnum[i] = 0.0;
ifstream in("numbers", ios::in | ios::binary);
in.read((char *) &fnum, sizeof fnum);
// see how many bytes have been read
cout << in.gcount() << " bytes read\n"; //gcount( ) is used to determine how many bytes were just read.
for(i=0; i<4; i++) // show values read from file
cout << fnum[i] << " ";
in.close();
getch();
}
| [
"omarkaushru@gmail.com"
] | omarkaushru@gmail.com |
c21e5ce5d78b873d48913603c001f2dd119b92de | 56a77194fc0cd6087b0c2ca1fb6dc0de64b8a58a | /applications/ThermalDEMApplication/custom_constitutive/conduction/indirect_conduction_vargas.cpp | cc5a0192aadb73b5a1e32dd579b4ebde7c11b52f | [
"BSD-3-Clause"
] | permissive | KratosMultiphysics/Kratos | 82b902a2266625b25f17239b42da958611a4b9c5 | 366949ec4e3651702edc6ac3061d2988f10dd271 | refs/heads/master | 2023-08-30T20:31:37.818693 | 2023-08-30T18:01:01 | 2023-08-30T18:01:01 | 81,815,495 | 994 | 285 | NOASSERTION | 2023-09-14T13:22:43 | 2017-02-13T10:58:24 | C++ | UTF-8 | C++ | false | false | 1,970 | cpp | // Kratos Multi-Physics - ThermalDEM Application
//
// License: BSD License
// Kratos default license: kratos/license.txt
//
// Main authors: Rafael Rangel (rrangel@cimne.upc.edu)
//
// System includes
// External includes
// Project includes
#include "indirect_conduction_vargas.h"
namespace Kratos {
//-----------------------------------------------------------------------------------------------------------------------
IndirectConductionVargas::IndirectConductionVargas() {}
IndirectConductionVargas::~IndirectConductionVargas() {}
//------------------------------------------------------------------------------------------------------------
double IndirectConductionVargas::ComputeHeatFlux(const ProcessInfo& r_process_info, ThermalSphericParticle* particle) {
KRATOS_TRY
// Check for contact
if (!particle->mNeighborInContact)
return 0.0;
// Assumption 1: Formulation for a liquid (not gas) as the interstitial fluid is being used
const double fluid_conductivity = r_process_info[FLUID_THERMAL_CONDUCTIVITY];
const double temp_grad = particle->GetNeighborTemperature() - particle->GetParticleTemperature();
// Assumption 2 : Model developed for mono-sized particles, but the average radius is being used (if neighbor is a wall, it is assumed as a particle with the same radius)
const double particle_radius = particle->GetParticleRadius();
const double neighbor_radius = (particle->mNeighborType & PARTICLE_NEIGHBOR) ? particle->GetNeighborRadius() : particle_radius;
const double avg_radius = (particle_radius + neighbor_radius) / 2.0;
const double contact_radius = particle->mContactRadiusAdjusted;
// Compute heat flux
return 2.0 * Globals::Pi * fluid_conductivity * temp_grad * (1.0 - 0.5 * pow(contact_radius / avg_radius, 2.0)) * (avg_radius - contact_radius) / (1.0 - Globals::Pi / 4.0);
KRATOS_CATCH("")
}
} // namespace Kratos
| [
"rrangel@cimne.upc.edu"
] | rrangel@cimne.upc.edu |
4bf5e370404eb1822978169fc4bf9d305c6a267e | 63b780d4f90e6c7c051d516bf380f596809161a1 | /FreeEarthSDK/include/FePlugins/PluginDependent/GisService.h | 9c1dfea58edae11b62e5550837e02e541490a79c | [] | no_license | hewuhun/OSG | 44f4a0665b4a20756303be21e71f0e026e384486 | cfea9a84711ed29c0ca0d0bfec633ec41d8b8cec | refs/heads/master | 2022-09-05T00:44:54.244525 | 2020-05-26T14:44:03 | 2020-05-26T14:44:03 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 7,740 | h | /**************************************************************************************************
* @file GisService.h
* @note 提供Gis服务信息,主要用于读取配置文件中的配置信息以及构建URL
* @author c00005
* @data 2013-12-20
**************************************************************************************************/
#ifndef CGisService_H
#define CGisService_H
#include <list>
#include <osgEarth/Profile>
#include <osgEarth/URI>
#include <PluginDependent/Export.h>
#include <PluginDependent/Extent.h>
#include <PluginDependent/HgSharpOptions.h>
using namespace osgEarth;
namespace FePlugin
{
class PLUGIN_EXPORT CTileInfo
{
public:
/**
* @brief 默认的构造函数
* @note 默认的构造函数
* @return 无
*/
CTileInfo();
/**
* @brief 构造函数
* @note 带有参数的构造函数
* @param tile_size [in] 传入影像瓦片的大小
* @param format [in] 传入影像瓦片的文件格式
* @param min_level [in] 最小的显示级别
* @param max_level [in] 最大的显示级别
* @param _num_tiles_wide [in] 横向的瓦片的数目
* @param _num_tiles_high [in] 纵向的瓦片的数目
* @return 无
*/
CTileInfo( int tile_size, const std::string& format, int min_level, int max_level,
int _num_tiles_wide, int _num_tiles_high );
/**
* @brief 构造函数
* @note 拷贝构造函数
* @param rhs [in] 用于初始化类对象
* @return 无
*/
CTileInfo( const CTileInfo& rhs );
/**
* @brief 赋值函数
* @note 赋值函数
* @param rhs [in] CTileInfo类的对象引用,用来初始化类中变量的值
* @return 无
*/
CTileInfo & operator= (const CTileInfo &other);
/**
* @note 返回该CTileInfo是否有效
*/
virtual bool IsValid() const;
/**
* @note 返回该影像瓦片的大小
*/
virtual int GetTileSize() const;
/**
* @note 返回该影像瓦片文件的格式
*/
virtual const std::string& GetFormat() const;
/**
* @note 返回该影像瓦片的最小的Lod级数
*/
virtual int GetMinLevel() const;
/**
* @note 返回该影像瓦片的最大的Lod级数
*/
virtual int GetMaxLevel() const;
/**
* @note 返回该结构横向的瓦片数量
*/
virtual int GetNumTilesWide() const;
/**
* @note 返回该结构纵向的瓦片数量
*/
virtual int GetNumTilesHigh() const;
private:
///影像瓦片文件的格式
std::string m_strFormat;
///影像瓦片文件的大小
int m_nTileSize;
///影像瓦片文件显示的最小和最大级数
int m_nMinLevel, m_nMaxLevel;
///是否有效
bool m_bIsValid;
///横向的瓦片数量
int m_nNumTilesWide;
///纵向的瓦片数量
int m_nNumTilesHigh;
};
/**
* @class GisService
* @brief Gis服务的接口
* @note Gis服务的接口,可以调用该Gis的瓦片等信息,读取配置文件的信息,构建URL
* @author c00005
*/
class PLUGIN_EXPORT CGisService
{
public:
/**
* @brief 构造函数
* @note 默认构造函数
* @return 无
*/
CGisService(void);
/**
* @brief 构造函数
* @note 带有参数的构造函数
* @param bIsValid [in] 是否初始化成功
* @param uriUri [in] 配置文件的uri
* @param pProfile [in] 本Gis服务的profile
* @param strErrorMsg [in] 错误信息
* @param plistLayers [in] Gis服务的图层列表
* @param bTiled [in] 是否初始化了瓦片信息
* @param tileInfo [in] 存储瓦片信息
* @param strType [in] Gis服务的瓦片的存储结构(行或者列或者其他)
* @return 无
*/
CGisService( bool bIsValid, URI uriUri, const Profile * pProfile, std::string strErrorMsg,
bool bTiled, CTileInfo tileInfo, std::string strType );
/**
* @brief 构造函数
* @note 拷贝构造函数
* @param rhs [in] 类的对象引用,用于初始化类对象
* @return 无
*/
CGisService( const CGisService& rhs );
/**
* @brief 赋值函数
* @note 赋值函数
* @param rhs [in] 类的对象引用,用来初始化类中变量的值
* @return 无
*/
CGisService & operator= (const CGisService &other);
/**
* @brief 初始化函数
* @note 初始化该Gis服务,根据给的URI中的配置文件,将需要用到的配置读取出来并保存
* @param uri [in] 传入要读取的配置文件的uri
* @param options [in]
* @return bool 返回是否读取配置信息是否完成
*/
virtual bool Init( const URI& uri, const osgDB::Options* options =0L );
/**
* @brief 获取文件的URL
* @note 通过传入的Key以及文件的整体路径,通过本类的Type匹配出适合的URL
* @param key [in]
* @param full [in] 文件夹的路径
* @return std::string 返回拼接后的URL
*/
virtual std::string ConstructUrl(const TileKey& key, const CHgSharpOptions& options ) const;
/**
* @brief 检测图片是否有效
* @note 图片若处在边界处,四个角会至少有一个角有黑色,或图片全黑,为无效
* @return 无效则为true, 否则为false
*/
virtual bool CheckBlackImage(osg::Image* image);
/**
* @note 返回该类是否初始化成功
*/
virtual bool IsValid() const;
/**
* @note 返回在读取配置文件时,瓦片的信息是否读取成功
*/
virtual bool IsTiled() const;
/**
* @note set功能函数,当出错时设置错误信息
*/
bool SetError( const std::string& );
/**
* @note 如果该类初始化失败,则返回错误信息
*/
virtual const std::string& GetError() const;
/**
* @note 返回该gis服务相关的profile信息
*/
virtual const Profile* GetProfile() const;
/**
* @note 返回该gis服务的瓦片的信息并不可被修改
*/
virtual const CTileInfo& GetTileInfo() const;
/**
* @note 返回该gis服务的组织结构类型
*/
virtual std::string GetTileType() const;
/**
* @note 返回是否检测图片
*/
virtual std::string GetStrCheck() const;
private:
///是否初始化成功
bool m_bIsValid;
///保存传入的配置文件的uri
URI m_uriUri;
///本Gis服务的profile
osg::ref_ptr<const Profile> m_rpProfile;
///错误信息
std::string m_strErrorMsg;
///是否初始化了瓦片信息
bool m_bTiled;
///存储瓦片信息
CTileInfo m_tileInfo;
///该Gis服务的瓦片的存储结构(行或者列或者其他)
std::string m_strType;
///判断是否对图片进行检测,检测的目的是如果有全黑的图片,则认为无效。一般不需要检测
std::string m_strCheck;
};
}
#endif
| [
"Wang_123456"
] | Wang_123456 |
1de44bf9cb355991b7a0212c2b1e82e5ed439556 | 919b13ba5ea8bf9f24c86b9043b398f4c87e0ed6 | /hw2/permutations/permutations/permutations.cpp | b6ea603e01ba9fc76e17513c8d0bd1d576c42f65 | [] | no_license | kirilkadoncheva/fmi-sda | 71db76022ca4f7bb3255832169d3a47ce0c6a280 | 0e40ec179a5e11f2f7fc4bda949810b7cb4225ab | refs/heads/main | 2023-03-25T11:30:18.931621 | 2021-03-13T13:19:08 | 2021-03-13T13:19:08 | 347,375,065 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,340 | cpp | #include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
void countingSort(string &word)
{
int letters[26] = { 0 };
int size = word.size();
for (int i = 0; i < size; i++)
{
if (word[i] >= 'A'&&word[i] <= 'Z') { word[i] = word[i] + 32; }
switch (word[i])
{
case 'a':letters[0]++; break;
case 'b':letters[1]++; break;
case 'c':letters[2]++; break;
case 'd':letters[3]++; break;
case 'e':letters[4]++; break;
case 'f':letters[5]++; break;
case 'g':letters[6]++; break;
case 'h':letters[7]++; break;
case 'i':letters[8]++; break;
case 'j':letters[9]++; break;
case 'k':letters[10]++; break;
case 'l':letters[11]++; break;
case 'm':letters[12]++; break;
case 'n':letters[13]++; break;
case 'o':letters[14]++; break;
case 'p':letters[15]++; break;
case 'q':letters[16]++; break;
case 'r':letters[17]++; break;
case 's':letters[18]++; break;
case 't':letters[19]++; break;
case 'u':letters[20]++; break;
case 'v':letters[21]++; break;
case 'w':letters[22]++; break;
case 'x':letters[23]++; break;
case 'y':letters[24]++; break;
case 'z':letters[25]++; break;
}
}
//string word_copy = word;
//for (int i = 0; i < 26; i++)
//{
// cout << letters[i] << " ";
//}
//cout << endl;
//for (int i = 1; i < 26; i++)
//{
// letters[i] = letters[i] + letters[i - 1];
//}
//cout << word[letters[int(word_copy[1]) - 65] - 1] << "\n";
int p = 0;
for (int k = 0; k < 26; k++)
{
if (letters[k] > 0)
{
for (int i = p; i < p + letters[k]; i++)
{
word[i] = char(k + 97);
}
p = p + letters[k];
}
}
//cout << word << "\n";
//for (int i = size-1; i > 0; i--)
// {
// word[letters[word_copy[i] - 65] - 1] = word_copy[i];
// letters[word_copy[i] - 65]--;
// }
//cout << word << "\n";
//for (int i = 0; i < 26; i++)
//{
// cout << letters[i] << " ";
//}
//cout << endl;
}
int main() {
int n;
cin >> n;
string word1;
cin >> word1;
string word2;
cin >> word2;
if (word1.size() != word2.size()) { cout << "no\n"; return 0; }
//cout << word1 << "\n";
countingSort(word1);
countingSort(word2);
if (word1 == word2) { cout << "yes\n"; }
else cout << "no\n";
return 0;
} | [
"kiki.doncheva393@gmail.com"
] | kiki.doncheva393@gmail.com |
8b9f5a7cfd638658e4d2106a1e6f0c7f6f42a558 | 01c2cd73f527d8f78c075431e5c05ddcfafb782e | /AgoraWinRT/AudioDeviceCollection.h | 5e193998483ce0741dfbdf7f492e3bff70412e8c | [] | no_license | jiayanana/AgoraUWP | 8d64b395e427beb7cecfc5d200072a15426d0a65 | 1cd1e042b53138b8a0e0b913557bb4a13a2c6c01 | refs/heads/master | 2023-06-10T14:08:54.727949 | 2021-06-28T03:18:42 | 2021-06-28T03:18:42 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 725 | h | #pragma once
#include "pch.h"
#include "AudioDeviceCollection.g.h"
namespace winrt::AgoraWinRT::implementation
{
struct AudioDeviceCollection : AudioDeviceCollectionT<AudioDeviceCollection>
{
AudioDeviceCollection(agora::rtc::IAudioDeviceCollection* collection);
int32_t GetCount();
int16_t GetDevice(int32_t index, hstring& name, hstring& id);
int16_t SetDevice(hstring const& id);
int16_t SetApplicationVolume(uint8_t volume);
int16_t GetApplicationVolume(uint8_t& volume);
int16_t SetApplicationMute(bool muted);
int16_t IsApplicationMute(bool& muted);
void Close();
private:
agora::rtc::IAudioDeviceCollection* m_raw;
};
}
| [
"sid@Sids-MacBook-Pro.local"
] | sid@Sids-MacBook-Pro.local |
5d92cd669ab74008287cd2c021925547117ce3e3 | 52510cbe2cc9b05a604604f9e0049ee5e348aca8 | /ThBOT_Src/MotionControl/MotionControl.h | 3706bd3a500f8a0c41d948b9ffc6f3000888d2d0 | [] | no_license | 3Xpresso/ThBOT_Mainboard | e38e1c52d89f36e34a54b429c7c57ebd249b964e | f6ef64dfbe728d6b7e815e60c3f0f68d547df2d1 | refs/heads/master | 2018-12-27T06:45:51.645381 | 2018-10-23T15:22:21 | 2018-10-23T15:22:21 | 110,987,165 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,458 | h | /*
* MotionControl.h
*
* Created on: 10 mars 2018
* Author: jpb
*/
#ifndef MOTIONCONTROL_H_
#define MOTIONCONTROL_H_
/* Includes ------------------------------------------------------------------*/
#include "FreeRTOS.h"
#include "task.h"
#include "cmsis_os.h"
#include "bsp/DcMotor.h"
#include "Odometry/Odometry.h"
#include <MotionControl/MotionMotor.h>
#include "thb-bsp.h"
#define ECH_PERIOD_MS 10
enum
{
MOTION_MOTOR_LEFT = 0,
MOTION_MOTOR_RIGHT,
MOTION_MOTOR_MAX,
};
class RobotCore;
class MotionControl {
public:
MotionControl(RobotCore * Rob);
virtual ~MotionControl();
Odom_t GetOdomValue(){
return odom->GetOdomValue();
}
int32_t EncoderLeftGetAbsoluteStep(){
return odom->EncoderLeftGetAbsoluteStep();
}
int32_t EncoderRightGetAbsoluteStep(){
return odom->EncoderRightGetAbsoluteStep();
}
int32_t EncoderLeftGetAbsoluteStepFromDelta(){
return odom->EncoderLeftGetAbsoluteStepFromDelta();
}
int32_t EncoderRightGetAbsoluteStepFromDelta(){
return odom->EncoderRightGetAbsoluteStepFromDelta();
}
double EncoderLeftGetAbsoluteMM(){
return odom->EncoderLeftGetAbsoluteMM();
}
double EncoderRightGetAbsoluteMM(){
return odom->EncoderRightGetAbsoluteMM();
}
void SetMotionMotor(uint32_t Id, uint32_t Direction, uint32_t Percentage){
switch(Id) {
case MOTION_MOTOR_LEFT:
motionMotorLeft->SetDirection(Direction);
motionMotorLeft->SetPercentPower(Percentage);
if (Percentage > 0)
motorLeftIsRunning = true;
else {
motorLeftIsRunning = false;
motionMotorLeft->SetPercentPower(Percentage);
}
break;
case MOTION_MOTOR_RIGHT:
motionMotorRight->SetDirection(Direction);
motionMotorRight->SetPercentPower(Percentage);
if (Percentage > 0)
motorRightIsRunning = true;
else {
motorRightIsRunning = false;
motionMotorLeft->SetPercentPower(Percentage);
}
break;
}
}
void PidReload(void){
motionMotorRight->PidReload();
motionMotorLeft->PidReload();
}
void PrintStats(void){
thb_StatsPrintResponse();
}
void ClearStats(void){
thb_StatsInit();
}
void task(void);
bool isRunning(void)
{
if (motorLeftIsRunning | motorRightIsRunning)
return true;
else
return false;
}
protected:
RobotCore * Robocore;
osThreadId motionTaskHandle;
MotionMotor * motionMotorLeft;
MotionMotor * motionMotorRight;
Odometry * odom;
bool motorLeftIsRunning;
bool motorRightIsRunning;
};
#endif /* MOTIONCONTROL_H_ */
| [
"jpb.ulysse@gmail.com"
] | jpb.ulysse@gmail.com |
110139527856e4b77ff4a9b9b3e8cc712c10fe90 | ad6bf5258014ddb47fc46e120a3868bf8e75592d | /simplenavigateview.h | 21864a9bc2b7cad08915bc2c5ab219360cc07bb8 | [] | no_license | Schikasi/spmiTest | b1ffb448d56d6510cf5da385c1d906e3ce7db3e7 | aa17db0fe5df03830a4ae7feb5fbca6340b7c3f7 | refs/heads/master | 2023-06-15T00:53:34.657593 | 2021-07-16T12:22:21 | 2021-07-16T12:22:21 | 382,876,703 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 815 | h | #ifndef SIMPLENAVIGATEVIEW_H
#define SIMPLENAVIGATEVIEW_H
#include <QButtonGroup>
#include <QPushButton>
#include <QWidget>
namespace Ui {
class SimpleNavigateView;
}
class SimpleNavigateView : public QWidget
{
Q_OBJECT
public:
enum button{
next = 0x001,
prev = 0x002,
pages = 0x004
};
Q_DECLARE_FLAGS(buttons,button)
explicit SimpleNavigateView(buttons b, int countPages, QWidget *parent = nullptr);
~SimpleNavigateView();
signals:
void PreviousQuestion();
void ChangeQuestion(int i);
void NextQuestion();
private:
Ui::SimpleNavigateView *ui;
QPushButton* prevPB = nullptr;
QPushButton* nextPB = nullptr;
QButtonGroup *pagesG = nullptr;
};
Q_DECLARE_OPERATORS_FOR_FLAGS(SimpleNavigateView::buttons)
#endif // SIMPLENAVIGATEVIEW_H
| [
"35520439+Schikasi@users.noreply.github.com"
] | 35520439+Schikasi@users.noreply.github.com |
603ca9b76530ed709d192450b0678d208d11b97a | 5b4e65ff1a4e5ec233962342a648249e32f8ba81 | /cpp/Graphics.h | 222e8eaad428cf2c2d48ae60b80ca0bc3372474e | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | msimms/LibMath | 6b880e31e830ef773470399d6d8b15cbf1d2fd8b | 1be0914d49191dd55849519eebc41455c67170ad | refs/heads/master | 2022-08-31T14:43:07.327774 | 2022-08-15T18:43:54 | 2022-08-15T18:43:54 | 138,065,153 | 7 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 1,410 | h | // by Michael J. Simms
// Copyright (c) 2022 Michael J. Simms
// 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.
#pragma once
#ifndef _GRAPHICS_
#define _GRAPHICS_
#include <stdlib.h>
namespace LibMath
{
void QuadBezierFit2D(double in[][2], double out[][2], size_t numPoints, double t);
void QuadBezierFit3D(double in[][3], double out[][3], size_t numPoints, double t);
}
#endif
| [
"msimms01@gmail.com"
] | msimms01@gmail.com |
2ac6d38fd8b5de68f3f801c7aca15ed0bbd54a64 | 62a7d30053e7640ef770e041f65b249d101c9757 | /ByteDance - Moscow Workshops ICPC Programming Camp 2019. Day 4, Div A/C.cpp | 0e7ea69ba3eb0ac3ff858cfda8e46ceb0361bbdd | [] | no_license | wcysai/Calabash | 66e0137fd59d5f909e4a0cab940e3e464e0641d0 | 9527fa7ffa7e30e245c2d224bb2fb77a03600ac2 | refs/heads/master | 2022-05-15T13:11:31.904976 | 2022-04-11T01:22:50 | 2022-04-11T01:22:50 | 148,618,062 | 76 | 16 | null | 2019-11-07T05:27:40 | 2018-09-13T09:53:04 | C++ | UTF-8 | C++ | false | false | 3,847 | cpp | //
// Created by bytedance on 19-2-19.
//
#include <bits/stdc++.h>
using namespace std;
const int maxn = 6e5+100;
typedef long long ll;
char s[maxn];
int ch[maxn];
int lc[maxn];
int n;
int N;
void manacher(){
N = 2 * n + 1;
ch[N] = '#';
for (int i=n;i>=1;i--){
ch[i*2] = s[i];
ch[i*2-1] = '#';
}
ch[0] = 'z'+1;
ch[N+1] = '\0';
lc[1] = 1;
int k=1;
for (int i=2;i<=N;i++){
int p = k + lc[k] - 1;
if (i <= p){
lc[i] = min(lc[2*k-i],p-i+1);
}else{
lc[i] = 1;
}
while (ch[i+lc[i]] == ch[i-lc[i]])lc[i] ++;
if (i + lc[i] > k + lc[k]) k = i;
}
//for (int i=1;i<=N;i++){
// printf("lc[%d]=%d\n",i,lc[i]);
//}
//for (int i=1;i<=N;i++){
// printf("%c ",ch[i]);
//}
//puts("");
}
ll ans[maxn];
struct QUERY{
int l,mid,r,id;
};
struct Seg_Tree{
ll sum[maxn*4];
ll lazy[maxn*4];
void up(int x){
sum[x] = sum[x<<1] + sum[x<<1|1];
}
void down(int x,int l,int mid,int r){
if (lazy[x]){
lazy[x<<1] += lazy[x];
lazy[x<<1|1] += lazy[x];
sum[x<<1] += 1ll * lazy[x] * (mid-l+1);
sum[x<<1|1] += 1ll * lazy[x] * (r - mid);
lazy[x] = 0;
}
}
void build(int x,int l,int r){
sum[x] = 0;
lazy[x] = 0;
if (l == r)return;
int mid = l + r >> 1;
build(x<<1,l,mid);
build(x<<1|1,mid+1,r);
}
void add(int x,int l,int r,int L,int R,ll val){
if (l > R || L > r)return;
if (L<= l && r <= R){
sum[x] += 1ll * (r-l + 1) * val;
lazy[x] += val;
return;
}
int mid = l + r >> 1;
down(x,l,mid,r);
add(x<<1,l,mid,L,R,val);
add(x<<1|1,mid+1,r,L,R,val);
up(x);
}
ll query(int x,int l,int r,int L,int R){
if (l > R || L > r)return 0;
if (L <= l && r <= R)return sum[x];
int mid = l +r >> 1;
down(x,l,mid,r);
return query(x<<1,l,mid,L,R) + query(x<<1|1,mid+1,r,L,R);
}
}segtree;
vector<QUERY> query;
void workl(){
segtree.build(1,1,N);
sort(query.begin(),query.end(),[](const QUERY x ,const QUERY y){
return x.mid < y.mid;
});
for (int i=1,j=0;i<=N && j < query.size();i++){
while (j < query.size() && query[j].mid == i ){
ans[query[j].id] += segtree.query(1,1,N,query[j].l,query[j].mid-1);
j++;
}
segtree.add(1,1,N,i-lc[i] + 1,i,1);
}
}
void workr(){
segtree.build(1,1,N);
sort(query.begin(),query.end(),[](const QUERY x ,const QUERY y){
return x.mid > y.mid;
});
for (int i=N,j=0;i>=1 && j < query.size();i--){
while (j < query.size() && query[j].mid == i){
ans[query[j].id] += segtree.query(1,1,N,query[j].mid+1,query[j].r);
j++;
}
segtree.add(1,1,N,i,i+lc[i] -1,1);
}
}
void workmid(){
sort(query.begin(),query.end(),[](const QUERY x ,const QUERY y){
return x.mid < y.mid;
});
for (int i=1,j=0;i<=N&& j < query.size();i++){
while (query[j].mid == i){
ans[query[j].id] += min(lc[i],query[j].mid - query[j].l + 1);
j++;
}
}
}
void debug(int q){
for (int i=1;i<=q;i++){
printf("ans[%d]=%lld\n",i,ans[i]);
}
}
int main(){
scanf("%s",s+1);
n = strlen(s+1);
manacher();
int q;
scanf("%d",&q);
for (int i=1;i<=q;i++){
int l,r;
scanf("%d%d",&l,&r);
ans[i] = - (r-l+2);
l = 2*l-1;
r = 2 * r + 1;
int mid = l + r >> 1;
query.push_back((QUERY){l,mid,r,i});
}
workl();
//debug(q);
workr();
workmid();
for (int i=1;i<=q;i++){
printf("%lld\n",ans[i]/2);
}
return 0;
}
| [
"wcysai@foxmail.com"
] | wcysai@foxmail.com |
47f3f400d9e26fd496bdd77ac1df55db2eec1583 | bd51b8626ee07a692964a511228a6cfce694cfbd | /mockmon/include/stats/battle_stats.h | f84c68bbc37817f20a47c18cea22cc9ce9064cdc | [] | no_license | BenjaminShinar/FlexingMyCode | 937de5e0f71d9c3e79f88e27b4cb35fa71f990a2 | d873bd2b0e92ed76c234c2ce7766a6ab400a330e | refs/heads/main | 2023-06-11T06:09:34.240872 | 2021-07-06T14:24:29 | 2021-07-06T14:24:29 | 324,566,900 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,122 | h | #pragma once
#include "stats.h"
#include "single_stats.h"
#include <string>
#include <iostream>
#include <algorithm>
#include <map>
#include <array>
namespace mockmon::stats
{
struct BattleStats
{
explicit BattleStats() = default;
//this happenes at Level Up, at creation, and maybe at pokemon center / when taking vitamins?
void UpdateBattleStats(const MockmonStats &mockmonStats)
{
Health.ChangeStatMax(mockmonStats.Stats.Health);
m_battleStats.at(StatsTypes::Attack).ChangeStat(mockmonStats.Stats.Attack);
m_battleStats.at(StatsTypes::Defence).ChangeStat(mockmonStats.Stats.Defence);
m_battleStats.at(StatsTypes::Special).ChangeStat(mockmonStats.Stats.Special);
m_battleStats.at(StatsTypes::Speed).ChangeStat(mockmonStats.Stats.Speed);
}
// std::array<BattleSingleStat<double>,6> m_battle_stats =
// {
// BattleSingleStat<double>(StatsTypes::Attack,1.0),
// BattleSingleStat<double>(StatsTypes::Defence,1.0),
// BattleSingleStat<double>(StatsTypes::Special,1.0),
// BattleSingleStat<double>(StatsTypes::Speed,1.0),
// BattleSingleStat<double>(StatsTypes::Evasion,1.0),
// BattleSingleStat<double>(StatsTypes::Accuracy,1.0),
// };
std::map<StatsTypes, BattleSingleStat> m_battleStats =
{
{StatsTypes::Attack, BattleSingleStat(StatsTypes::Attack,1)},
{StatsTypes::Defence, BattleSingleStat(StatsTypes::Defence,1)},
{StatsTypes::Special, BattleSingleStat(StatsTypes::Special,1)},
{StatsTypes::Speed, BattleSingleStat(StatsTypes::Speed,1)},
{StatsTypes::Evasion, BattleSingleStat(StatsTypes::Evasion,1.0)},
{StatsTypes::Accuracy, BattleSingleStat(StatsTypes::Accuracy,1.0)},
{StatsTypes::CriticalHitChance, BattleSingleStat(StatsTypes::CriticalHitChance,1.0)},
};
HealthStat Health{1}; //this should be special
};
} | [
"benjaminShinar@gmail.com"
] | benjaminShinar@gmail.com |
94a4478631eafb5450c6fdde2b5680a91bb53f51 | 93376006df2e645ae7406ff739aa43643df9b3d5 | /CODE/WORMS/minkowski1.cpp | 377d6313d374c16d83f4caeee5bd5c1b502cbe25 | [] | no_license | omer4d/OldCodeBackup | fd5f84e660cc91ab32cb08032848f779ced66053 | d836c14006fa72f6e660bcf39d2315e69dc292f8 | refs/heads/master | 2021-01-10T05:54:20.340232 | 2015-12-13T14:44:10 | 2015-12-13T14:44:10 | 47,922,932 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,532 | cpp | #include <stdio.h>
#include <conio.h>
#include <math.h>
#include <allegro.h>
#include <list>
#include <vector>
#include <algorithm>
#include "Vec2f.hpp"
#include "Buffer.hpp"
BITMAP* buffer;
#define PIXEL(bmp, x, y) ((long*)(bmp)->line[(y)])[(x)]
void init()
{
allegro_init();
install_mouse();
install_keyboard();
set_color_depth(32);
set_gfx_mode(GFX_AUTODETECT_WINDOWED, 640, 480, 0, 0);
buffer = create_bitmap(SCREEN_W, SCREEN_H);
//set_add_blender(255, 255, 255, 255);
//drawing_mode(DRAW_MODE_TRANS, NULL, 0, 0);
}
void deinit()
{
destroy_bitmap(buffer);
}
int main()
{
bool exit = false;
init();
int rx1 = 50, ry1 = 100;
int rx2 = 200, ry2 = 30;
int cx = 320, cy = 240;
while(!exit)
{
if(key[KEY_ESC]) exit = true;
clear_to_color(buffer, makecol(0, 0,0));
for(int i = 0; i < 100; ++i)
{
float alpha = (i / 100.0) * 2 * M_PI;
float x = cx + rx1 * cos(alpha);
float y = cy + ry1 * sin(alpha);
ellipse(buffer, (int)x, (int)y, rx2, ry2, makecol(0, 0, 100));
}
ellipse(buffer, cx, cy, rx1, ry1, makecol(255, 0, 0));
ellipse(buffer, cx, cy, rx1 + rx2, ry1 + ry2, makecol(255, 0, 0));
//draw_sprite(buffer, mouse_sprite, mouse_x, mouse_y);
blit(buffer, screen, 0, 0, 0, 0, SCREEN_W, SCREEN_H);
}
deinit();
return 0;
}END_OF_MAIN()
| [
"omer4d@gmail.com"
] | omer4d@gmail.com |
33df30c846ad33d8a26d1da77fecd78bd02d58dd | 9088ceeec034b6e295f80ccdba6d348949e17180 | /sw/device/tests/dif/dif_alert_handler_unittest.cc | f99ffd99a377b087782722ff5566399e15eeb97e | [
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0"
] | permissive | poena/opentitan | b2185ec091597d70a25e5cefb3c3d8e2197e4bb6 | cfd7de485ab6cdfef4d22f17e73300fd723a3cb9 | refs/heads/master | 2021-07-21T15:01:26.529772 | 2020-10-30T06:30:59 | 2020-10-30T06:30:59 | 227,606,860 | 0 | 0 | Apache-2.0 | 2020-10-30T06:31:01 | 2019-12-12T12:53:50 | null | UTF-8 | C++ | false | false | 33,740 | cc | // Copyright lowRISC contributors.
// Licensed under the Apache License, Version 2.0, see LICENSE for details.
// SPDX-License-Identifier: Apache-2.0
#include "sw/device/lib/dif/dif_alert_handler.h"
#include <cstring>
#include <limits>
#include <ostream>
#include "gtest/gtest.h"
#include "sw/device/lib/base/mmio.h"
#include "sw/device/lib/testing/mock_mmio.h"
#include "alert_handler_regs.h" // Generated.
namespace dif_alert_handler_unittest {
namespace {
using ::mock_mmio::LeInt;
using ::mock_mmio::MmioTest;
using ::mock_mmio::MockDevice;
using ::testing::_;
using ::testing::Return;
constexpr uint32_t kAlerts = 12;
constexpr uint32_t kAllOnes = std::numeric_limits<uint32_t>::max();
class AlertTest : public testing::Test, public MmioTest {
protected:
dif_alert_handler_t handler_ = {.params = {
.base_addr = dev().region(),
.alert_count = kAlerts,
.escalation_signal_count = 4,
}};
};
class InitTest : public AlertTest,
public testing::WithParamInterface<uint32_t> {};
TEST_P(InitTest, Success) {
dif_alert_handler_params_t params = {
.base_addr = dev().region(),
.alert_count = GetParam(),
.escalation_signal_count = 4,
};
dif_alert_handler_t handler;
EXPECT_EQ(dif_alert_handler_init(params, &handler), kDifAlertHandlerOk);
}
TEST_P(InitTest, NullArgs) {
dif_alert_handler_params_t params = {
.base_addr = dev().region(),
.alert_count = GetParam(),
.escalation_signal_count = 4,
};
EXPECT_EQ(dif_alert_handler_init(params, nullptr), kDifAlertHandlerBadArg);
}
INSTANTIATE_TEST_SUITE_P(
InitTestSignalCounts, InitTest,
testing::Values(1, 2, 12, 16
// TODO: Enable these parameters once we can support them.
// See: #3826
// 24, 32,
));
class ConfigTest : public AlertTest {
// We provide our own dev_ member variable in this fixture, in order to
// support IgnoreMmioCalls().
//
// NOTE: This must come before handler_!
private:
std::unique_ptr<MockDevice> dev_ =
std::make_unique<testing::StrictMock<MockDevice>>();
protected:
ConfigTest() { handler_.params.base_addr = dev().region(); }
// Non-virtual-override dev(), so that EXPECT_*() functions look this one
// up instead of AlertTest::dev().
MockDevice &dev() { return *dev_; }
// Disables expectations on MMIO operations. This is useful for configuration
// tests that partially configure the device but fail due to a configuration
// error, returning kError.
void IgnoreMmioCalls() {
dev_ = std::make_unique<testing::NiceMock<MockDevice>>();
handler_.params.base_addr = dev().region();
// Make sure that the peripheral looks unlocked.
ON_CALL(*dev_, Read32(_)).WillByDefault(Return(kAllOnes));
}
};
TEST_F(ConfigTest, Locked) {
dif_alert_handler_config_t config = {
.ping_timeout = 0,
};
EXPECT_READ32(ALERT_HANDLER_REGEN_REG_OFFSET, 0);
EXPECT_EQ(dif_alert_handler_configure(&handler_, config),
kDifAlertHandlerConfigLocked);
}
TEST_F(ConfigTest, NoClassInit) {
dif_alert_handler_config_t config = {
.ping_timeout = 50,
};
EXPECT_READ32(ALERT_HANDLER_REGEN_REG_OFFSET,
{{ALERT_HANDLER_REGEN_REGEN, true}});
EXPECT_WRITE32(
ALERT_HANDLER_PING_TIMEOUT_CYC_REG_OFFSET,
{{ALERT_HANDLER_PING_TIMEOUT_CYC_PING_TIMEOUT_CYC_OFFSET, 50}});
EXPECT_EQ(dif_alert_handler_configure(&handler_, config),
kDifAlertHandlerConfigOk);
}
TEST_F(ConfigTest, TimeoutTooBig) {
dif_alert_handler_config_t config = {
.ping_timeout = ALERT_HANDLER_PING_TIMEOUT_CYC_PING_TIMEOUT_CYC_MASK + 1,
};
EXPECT_EQ(dif_alert_handler_configure(&handler_, config),
kDifAlertHandlerConfigBadArg);
}
TEST_F(ConfigTest, BadClassPtr) {
dif_alert_handler_config_t config = {
.ping_timeout = 50,
.classes = nullptr,
.classes_len = 2,
};
EXPECT_EQ(dif_alert_handler_configure(&handler_, config),
kDifAlertHandlerConfigBadArg);
}
TEST_F(ConfigTest, ClassInit) {
std::vector<dif_alert_handler_alert_t> alerts_a = {1, 2, 5};
std::vector<dif_alert_handler_local_alert_t> locals_a = {
kDifAlertHandlerLocalAlertEscalationPingFail,
};
std::vector<dif_alert_handler_class_phase_signal_t> signals_a = {
{.phase = kDifAlertHandlerClassStatePhase0, .signal = 3},
{.phase = kDifAlertHandlerClassStatePhase2, .signal = 1},
};
std::vector<dif_alert_handler_class_phase_duration_t> durations_a = {
{.phase = kDifAlertHandlerClassStatePhase1, .cycles = 20000},
{.phase = kDifAlertHandlerClassStatePhase2, .cycles = 15000},
};
std::vector<dif_alert_handler_alert_t> alerts_b = {9, 6, 11};
std::vector<dif_alert_handler_local_alert_t> locals_b = {
kDifAlertHandlerLocalAlertAlertPingFail,
kDifAlertHandlerLocalAlertAlertIntegrityFail,
};
std::vector<dif_alert_handler_class_phase_signal_t> signals_b = {
{.phase = kDifAlertHandlerClassStatePhase1, .signal = 0},
};
std::vector<dif_alert_handler_class_phase_duration_t> durations_b = {
{.phase = kDifAlertHandlerClassStatePhase1, .cycles = 20000},
{.phase = kDifAlertHandlerClassStatePhase2, .cycles = 15000},
{.phase = kDifAlertHandlerClassStatePhase3, .cycles = 150000},
};
std::vector<dif_alert_handler_class_config_t> classes = {
{
.alert_class = kDifAlertHandlerClassA,
.alerts = alerts_a.data(),
.alerts_len = alerts_a.size(),
.local_alerts = locals_a.data(),
.local_alerts_len = locals_a.size(),
.use_escalation_protocol = kDifAlertHandlerToggleDisabled,
.automatic_locking = kDifAlertHandlerToggleEnabled,
.accumulator_threshold = 12,
.irq_deadline_cycles = 30000,
.phase_signals = signals_a.data(),
.phase_signals_len = signals_a.size(),
.phase_durations = durations_a.data(),
.phase_durations_len = durations_a.size(),
},
{
.alert_class = kDifAlertHandlerClassB,
.alerts = alerts_b.data(),
.alerts_len = alerts_b.size(),
.local_alerts = locals_b.data(),
.local_alerts_len = locals_b.size(),
.use_escalation_protocol = kDifAlertHandlerToggleEnabled,
.automatic_locking = kDifAlertHandlerToggleDisabled,
.accumulator_threshold = 8,
.irq_deadline_cycles = 2000,
.phase_signals = signals_b.data(),
.phase_signals_len = signals_b.size(),
.phase_durations = durations_b.data(),
.phase_durations_len = durations_b.size(),
},
};
dif_alert_handler_config_t config = {
.ping_timeout = 50,
.classes = classes.data(),
.classes_len = classes.size(),
};
EXPECT_READ32(ALERT_HANDLER_REGEN_REG_OFFSET,
{{ALERT_HANDLER_REGEN_REGEN, true}});
// Unfortunately, we can't use EXPECT_MASK for these reads and writes,
// since there are not sequenced exactly.
EXPECT_READ32(ALERT_HANDLER_ALERT_EN_REG_OFFSET, 0);
EXPECT_READ32(ALERT_HANDLER_ALERT_CLASS_REG_OFFSET, kAllOnes);
EXPECT_WRITE32(ALERT_HANDLER_ALERT_EN_REG_OFFSET, {
{1, true},
{2, true},
{5, true},
});
uint32_t reg_a = kAllOnes;
for (auto alert : alerts_a) {
reg_a =
bitfield_field32_write(reg_a, {.mask = 0b11, .index = alert * 2}, 0b00);
}
EXPECT_WRITE32(ALERT_HANDLER_ALERT_CLASS_REG_OFFSET, reg_a);
EXPECT_READ32(ALERT_HANDLER_LOC_ALERT_EN_REG_OFFSET, 0);
EXPECT_READ32(ALERT_HANDLER_LOC_ALERT_CLASS_REG_OFFSET, kAllOnes);
EXPECT_WRITE32(ALERT_HANDLER_LOC_ALERT_EN_REG_OFFSET,
{
{ALERT_HANDLER_LOC_ALERT_EN_EN_LA_1, true},
});
uint32_t loc_reg_a = kAllOnes;
loc_reg_a = bitfield_field32_write(
loc_reg_a,
{
.mask = ALERT_HANDLER_LOC_ALERT_CLASS_CLASS_LA_1_MASK,
.index = ALERT_HANDLER_LOC_ALERT_CLASS_CLASS_LA_1_OFFSET,
},
0b00);
EXPECT_WRITE32(ALERT_HANDLER_LOC_ALERT_CLASS_REG_OFFSET, loc_reg_a);
EXPECT_WRITE32(ALERT_HANDLER_CLASSA_CTRL_REG_OFFSET,
{
{ALERT_HANDLER_CLASSA_CTRL_EN, false},
{ALERT_HANDLER_CLASSA_CTRL_LOCK, true},
{ALERT_HANDLER_CLASSA_CTRL_EN_E0, true},
{ALERT_HANDLER_CLASSA_CTRL_MAP_E0_OFFSET, 3},
{ALERT_HANDLER_CLASSA_CTRL_EN_E2, true},
{ALERT_HANDLER_CLASSA_CTRL_MAP_E2_OFFSET, 1},
});
EXPECT_WRITE32(ALERT_HANDLER_CLASSA_ACCUM_THRESH_REG_OFFSET, 12);
EXPECT_WRITE32(ALERT_HANDLER_CLASSA_TIMEOUT_CYC_REG_OFFSET, 30000);
EXPECT_WRITE32(ALERT_HANDLER_CLASSA_PHASE1_CYC_REG_OFFSET, 20000);
EXPECT_WRITE32(ALERT_HANDLER_CLASSA_PHASE2_CYC_REG_OFFSET, 15000);
EXPECT_READ32(ALERT_HANDLER_ALERT_EN_REG_OFFSET, 0);
EXPECT_READ32(ALERT_HANDLER_ALERT_CLASS_REG_OFFSET, kAllOnes);
EXPECT_WRITE32(ALERT_HANDLER_ALERT_EN_REG_OFFSET, {
{9, true},
{6, true},
{11, true},
});
uint32_t reg_b = kAllOnes;
for (auto alert : alerts_b) {
reg_b =
bitfield_field32_write(reg_b, {.mask = 0b11, .index = alert * 2}, 0b01);
}
EXPECT_WRITE32(ALERT_HANDLER_ALERT_CLASS_REG_OFFSET, reg_b);
EXPECT_READ32(ALERT_HANDLER_LOC_ALERT_EN_REG_OFFSET, 0);
EXPECT_READ32(ALERT_HANDLER_LOC_ALERT_CLASS_REG_OFFSET, kAllOnes);
EXPECT_WRITE32(ALERT_HANDLER_LOC_ALERT_EN_REG_OFFSET,
{
{ALERT_HANDLER_LOC_ALERT_EN_EN_LA_0, true},
{ALERT_HANDLER_LOC_ALERT_EN_EN_LA_2, true},
});
uint32_t loc_reg_b = kAllOnes;
loc_reg_b = bitfield_field32_write(
loc_reg_b,
{
.mask = ALERT_HANDLER_LOC_ALERT_CLASS_CLASS_LA_0_MASK,
.index = ALERT_HANDLER_LOC_ALERT_CLASS_CLASS_LA_0_OFFSET,
},
0b01);
loc_reg_b = bitfield_field32_write(
loc_reg_b,
{
.mask = ALERT_HANDLER_LOC_ALERT_CLASS_CLASS_LA_2_MASK,
.index = ALERT_HANDLER_LOC_ALERT_CLASS_CLASS_LA_2_OFFSET,
},
0b01);
EXPECT_WRITE32(ALERT_HANDLER_LOC_ALERT_CLASS_REG_OFFSET, loc_reg_b);
EXPECT_WRITE32(ALERT_HANDLER_CLASSB_CTRL_REG_OFFSET,
{
{ALERT_HANDLER_CLASSB_CTRL_EN, true},
{ALERT_HANDLER_CLASSB_CTRL_LOCK, false},
{ALERT_HANDLER_CLASSB_CTRL_EN_E1, true},
{ALERT_HANDLER_CLASSB_CTRL_MAP_E1_OFFSET, 0},
});
EXPECT_WRITE32(ALERT_HANDLER_CLASSB_ACCUM_THRESH_REG_OFFSET, 8);
EXPECT_WRITE32(ALERT_HANDLER_CLASSB_TIMEOUT_CYC_REG_OFFSET, 2000);
EXPECT_WRITE32(ALERT_HANDLER_CLASSB_PHASE1_CYC_REG_OFFSET, 20000);
EXPECT_WRITE32(ALERT_HANDLER_CLASSB_PHASE2_CYC_REG_OFFSET, 15000);
EXPECT_WRITE32(ALERT_HANDLER_CLASSB_PHASE3_CYC_REG_OFFSET, 150000);
EXPECT_WRITE32(
ALERT_HANDLER_PING_TIMEOUT_CYC_REG_OFFSET,
{{ALERT_HANDLER_PING_TIMEOUT_CYC_PING_TIMEOUT_CYC_OFFSET, 50}});
EXPECT_EQ(dif_alert_handler_configure(&handler_, config),
kDifAlertHandlerConfigOk);
}
TEST_F(ConfigTest, BadAlert) {
IgnoreMmioCalls();
std::vector<dif_alert_handler_alert_t> alerts_a = {1, 2, kAlerts + 1};
std::vector<dif_alert_handler_local_alert_t> locals_a = {
kDifAlertHandlerLocalAlertEscalationPingFail,
};
std::vector<dif_alert_handler_class_phase_signal_t> signals_a = {
{.phase = kDifAlertHandlerClassStatePhase0, .signal = 3},
{.phase = kDifAlertHandlerClassStatePhase2, .signal = 1},
};
std::vector<dif_alert_handler_class_phase_duration_t> durations_a = {
{.phase = kDifAlertHandlerClassStatePhase1, .cycles = 20000},
{.phase = kDifAlertHandlerClassStatePhase2, .cycles = 15000},
};
std::vector<dif_alert_handler_class_config_t> classes = {
{
.alert_class = kDifAlertHandlerClassA,
.alerts = alerts_a.data(),
.alerts_len = alerts_a.size(),
.local_alerts = locals_a.data(),
.local_alerts_len = locals_a.size(),
.use_escalation_protocol = kDifAlertHandlerToggleDisabled,
.automatic_locking = kDifAlertHandlerToggleEnabled,
.accumulator_threshold = 12,
.irq_deadline_cycles = 30000,
.phase_signals = signals_a.data(),
.phase_signals_len = signals_a.size(),
.phase_durations = durations_a.data(),
.phase_durations_len = durations_a.size(),
},
};
dif_alert_handler_config_t config = {
.ping_timeout = 50,
.classes = classes.data(),
.classes_len = classes.size(),
};
EXPECT_EQ(dif_alert_handler_configure(&handler_, config),
kDifAlertHandlerConfigError);
}
TEST_F(ConfigTest, BadSignalPhase) {
IgnoreMmioCalls();
std::vector<dif_alert_handler_alert_t> alerts_a = {1, 2, 5};
std::vector<dif_alert_handler_local_alert_t> locals_a = {
kDifAlertHandlerLocalAlertEscalationPingFail,
};
std::vector<dif_alert_handler_class_phase_signal_t> signals_a = {
{.phase = kDifAlertHandlerClassStatePhase0, .signal = 3},
{.phase = kDifAlertHandlerClassStateTerminal, .signal = 1},
};
std::vector<dif_alert_handler_class_phase_duration_t> durations_a = {
{.phase = kDifAlertHandlerClassStatePhase1, .cycles = 20000},
{.phase = kDifAlertHandlerClassStatePhase2, .cycles = 15000},
};
std::vector<dif_alert_handler_class_config_t> classes = {
{
.alert_class = kDifAlertHandlerClassA,
.alerts = alerts_a.data(),
.alerts_len = alerts_a.size(),
.local_alerts = locals_a.data(),
.local_alerts_len = locals_a.size(),
.use_escalation_protocol = kDifAlertHandlerToggleDisabled,
.automatic_locking = kDifAlertHandlerToggleEnabled,
.accumulator_threshold = 12,
.irq_deadline_cycles = 30000,
.phase_signals = signals_a.data(),
.phase_signals_len = signals_a.size(),
.phase_durations = durations_a.data(),
.phase_durations_len = durations_a.size(),
},
};
dif_alert_handler_config_t config = {
.ping_timeout = 50,
.classes = classes.data(),
.classes_len = classes.size(),
};
EXPECT_EQ(dif_alert_handler_configure(&handler_, config),
kDifAlertHandlerConfigError);
}
TEST_F(ConfigTest, BadDurationPhase) {
IgnoreMmioCalls();
std::vector<dif_alert_handler_alert_t> alerts_a = {1, 2, 5};
std::vector<dif_alert_handler_local_alert_t> locals_a = {
kDifAlertHandlerLocalAlertEscalationPingFail,
};
std::vector<dif_alert_handler_class_phase_signal_t> signals_a = {
{.phase = kDifAlertHandlerClassStatePhase0, .signal = 3},
{.phase = kDifAlertHandlerClassStatePhase2, .signal = 1},
};
std::vector<dif_alert_handler_class_phase_duration_t> durations_a = {
{.phase = kDifAlertHandlerClassStateTerminal, .cycles = 20000},
{.phase = kDifAlertHandlerClassStatePhase2, .cycles = 15000},
};
std::vector<dif_alert_handler_class_config_t> classes = {
{
.alert_class = kDifAlertHandlerClassA,
.alerts = alerts_a.data(),
.alerts_len = alerts_a.size(),
.local_alerts = locals_a.data(),
.local_alerts_len = locals_a.size(),
.use_escalation_protocol = kDifAlertHandlerToggleDisabled,
.automatic_locking = kDifAlertHandlerToggleEnabled,
.accumulator_threshold = 12,
.irq_deadline_cycles = 30000,
.phase_signals = signals_a.data(),
.phase_signals_len = signals_a.size(),
.phase_durations = durations_a.data(),
.phase_durations_len = durations_a.size(),
},
};
dif_alert_handler_config_t config = {
.ping_timeout = 50,
.classes = classes.data(),
.classes_len = classes.size(),
};
EXPECT_EQ(dif_alert_handler_configure(&handler_, config),
kDifAlertHandlerConfigError);
}
TEST_F(ConfigTest, BadPointers) {
IgnoreMmioCalls();
std::vector<dif_alert_handler_alert_t> alerts_a = {1, 2, 5};
std::vector<dif_alert_handler_local_alert_t> locals_a = {
kDifAlertHandlerLocalAlertEscalationPingFail,
};
std::vector<dif_alert_handler_class_phase_signal_t> signals_a = {
{.phase = kDifAlertHandlerClassStatePhase0, .signal = 3},
{.phase = kDifAlertHandlerClassStatePhase2, .signal = 1},
};
std::vector<dif_alert_handler_class_phase_duration_t> durations_a = {
{.phase = kDifAlertHandlerClassStateTerminal, .cycles = 20000},
{.phase = kDifAlertHandlerClassStatePhase2, .cycles = 15000},
};
std::vector<dif_alert_handler_class_config_t> classes = {
{
.alert_class = kDifAlertHandlerClassA,
.alerts = alerts_a.data(),
.alerts_len = alerts_a.size(),
.local_alerts = locals_a.data(),
.local_alerts_len = locals_a.size(),
.use_escalation_protocol = kDifAlertHandlerToggleDisabled,
.automatic_locking = kDifAlertHandlerToggleEnabled,
.accumulator_threshold = 12,
.irq_deadline_cycles = 30000,
.phase_signals = signals_a.data(),
.phase_signals_len = signals_a.size(),
.phase_durations = durations_a.data(),
.phase_durations_len = durations_a.size(),
},
};
dif_alert_handler_config_t config = {
.ping_timeout = 50,
.classes = classes.data(),
.classes_len = classes.size(),
};
classes[0].alerts = nullptr;
EXPECT_EQ(dif_alert_handler_configure(&handler_, config),
kDifAlertHandlerConfigError);
classes[0].alerts = alerts_a.data();
classes[0].local_alerts = nullptr;
EXPECT_EQ(dif_alert_handler_configure(&handler_, config),
kDifAlertHandlerConfigError);
classes[0].local_alerts = locals_a.data();
classes[0].phase_signals = nullptr;
EXPECT_EQ(dif_alert_handler_configure(&handler_, config),
kDifAlertHandlerConfigError);
classes[0].phase_signals = signals_a.data();
classes[0].phase_durations = nullptr;
EXPECT_EQ(dif_alert_handler_configure(&handler_, config),
kDifAlertHandlerConfigError);
}
TEST_F(ConfigTest, BadClass) {
IgnoreMmioCalls();
std::vector<dif_alert_handler_alert_t> alerts_a = {1, 2, 5};
std::vector<dif_alert_handler_local_alert_t> locals_a = {
kDifAlertHandlerLocalAlertEscalationPingFail,
};
std::vector<dif_alert_handler_class_phase_signal_t> signals_a = {
{.phase = kDifAlertHandlerClassStatePhase0, .signal = 3},
{.phase = kDifAlertHandlerClassStatePhase2, .signal = 1},
};
std::vector<dif_alert_handler_class_phase_duration_t> durations_a = {
{.phase = kDifAlertHandlerClassStateTerminal, .cycles = 20000},
{.phase = kDifAlertHandlerClassStatePhase2, .cycles = 15000},
};
std::vector<dif_alert_handler_class_config_t> classes = {
{
.alert_class = static_cast<dif_alert_handler_class_t>(12),
.alerts = alerts_a.data(),
.alerts_len = alerts_a.size(),
.local_alerts = locals_a.data(),
.local_alerts_len = locals_a.size(),
.use_escalation_protocol = kDifAlertHandlerToggleDisabled,
.automatic_locking = kDifAlertHandlerToggleEnabled,
.accumulator_threshold = 12,
.irq_deadline_cycles = 30000,
.phase_signals = signals_a.data(),
.phase_signals_len = signals_a.size(),
.phase_durations = durations_a.data(),
.phase_durations_len = durations_a.size(),
},
};
dif_alert_handler_config_t config = {
.ping_timeout = 50,
.classes = classes.data(),
.classes_len = classes.size(),
};
EXPECT_EQ(dif_alert_handler_configure(&handler_, config),
kDifAlertHandlerConfigError);
}
TEST_F(ConfigTest, NullArgs) {
EXPECT_EQ(dif_alert_handler_configure(nullptr, {}),
kDifAlertHandlerConfigBadArg);
}
class LockTest : public AlertTest {};
TEST_F(LockTest, IsLocked) {
bool flag;
EXPECT_READ32(ALERT_HANDLER_REGEN_REG_OFFSET,
{{ALERT_HANDLER_REGEN_REGEN, true}});
EXPECT_EQ(dif_alert_handler_is_locked(&handler_, &flag), kDifAlertHandlerOk);
EXPECT_FALSE(flag);
EXPECT_READ32(ALERT_HANDLER_REGEN_REG_OFFSET,
{{ALERT_HANDLER_REGEN_REGEN, false}});
EXPECT_EQ(dif_alert_handler_is_locked(&handler_, &flag), kDifAlertHandlerOk);
EXPECT_TRUE(flag);
}
TEST_F(LockTest, Lock) {
EXPECT_WRITE32(ALERT_HANDLER_REGEN_REG_OFFSET,
{{ALERT_HANDLER_REGEN_REGEN, true}});
EXPECT_EQ(dif_alert_handler_lock(&handler_), kDifAlertHandlerOk);
}
TEST_F(LockTest, NullArgs) {
bool flag;
EXPECT_EQ(dif_alert_handler_is_locked(nullptr, &flag),
kDifAlertHandlerBadArg);
EXPECT_EQ(dif_alert_handler_is_locked(&handler_, nullptr),
kDifAlertHandlerBadArg);
EXPECT_EQ(dif_alert_handler_lock(nullptr), kDifAlertHandlerBadArg);
}
class IrqTest : public AlertTest {};
TEST_F(IrqTest, IsPending) {
bool flag;
EXPECT_READ32(ALERT_HANDLER_INTR_STATE_REG_OFFSET,
{
{ALERT_HANDLER_INTR_COMMON_CLASSB, true},
{ALERT_HANDLER_INTR_COMMON_CLASSD, true},
});
EXPECT_EQ(dif_alert_handler_irq_is_pending(&handler_, kDifAlertHandlerClassA,
&flag),
kDifAlertHandlerOk);
EXPECT_FALSE(flag);
EXPECT_READ32(ALERT_HANDLER_INTR_STATE_REG_OFFSET,
{
{ALERT_HANDLER_INTR_COMMON_CLASSB, true},
{ALERT_HANDLER_INTR_COMMON_CLASSD, true},
});
EXPECT_EQ(dif_alert_handler_irq_is_pending(&handler_, kDifAlertHandlerClassB,
&flag),
kDifAlertHandlerOk);
EXPECT_TRUE(flag);
}
TEST_F(IrqTest, Ack) {
EXPECT_MASK32(ALERT_HANDLER_INTR_STATE_REG_OFFSET,
{{ALERT_HANDLER_INTR_COMMON_CLASSC, 1, true}});
EXPECT_EQ(
dif_alert_handler_irq_acknowledge(&handler_, kDifAlertHandlerClassC),
kDifAlertHandlerOk);
}
TEST_F(IrqTest, GetEnabled) {
dif_alert_handler_toggle_t flag;
EXPECT_READ32(ALERT_HANDLER_INTR_ENABLE_REG_OFFSET,
{
{ALERT_HANDLER_INTR_COMMON_CLASSB, true},
{ALERT_HANDLER_INTR_COMMON_CLASSD, true},
});
EXPECT_EQ(dif_alert_handler_irq_get_enabled(&handler_, kDifAlertHandlerClassA,
&flag),
kDifAlertHandlerOk);
EXPECT_EQ(flag, kDifAlertHandlerToggleDisabled);
EXPECT_READ32(ALERT_HANDLER_INTR_ENABLE_REG_OFFSET,
{
{ALERT_HANDLER_INTR_COMMON_CLASSB, true},
{ALERT_HANDLER_INTR_COMMON_CLASSD, true},
});
EXPECT_EQ(dif_alert_handler_irq_get_enabled(&handler_, kDifAlertHandlerClassB,
&flag),
kDifAlertHandlerOk);
EXPECT_EQ(flag, kDifAlertHandlerToggleEnabled);
}
TEST_F(IrqTest, SetEnabled) {
EXPECT_MASK32(ALERT_HANDLER_INTR_ENABLE_REG_OFFSET,
{{ALERT_HANDLER_INTR_COMMON_CLASSC, 1, true}});
EXPECT_EQ(dif_alert_handler_irq_set_enabled(&handler_, kDifAlertHandlerClassC,
kDifAlertHandlerToggleEnabled),
kDifAlertHandlerOk);
}
TEST_F(IrqTest, SetDisabled) {
EXPECT_MASK32(ALERT_HANDLER_INTR_ENABLE_REG_OFFSET,
{{ALERT_HANDLER_INTR_COMMON_CLASSD, 1, false}});
EXPECT_EQ(dif_alert_handler_irq_set_enabled(&handler_, kDifAlertHandlerClassD,
kDifAlertHandlerToggleDisabled),
kDifAlertHandlerOk);
}
TEST_F(IrqTest, Force) {
EXPECT_WRITE32(ALERT_HANDLER_INTR_TEST_REG_OFFSET,
{{ALERT_HANDLER_INTR_COMMON_CLASSC, true}});
EXPECT_EQ(dif_alert_handler_irq_force(&handler_, kDifAlertHandlerClassC),
kDifAlertHandlerOk);
}
TEST_F(IrqTest, Snapshot) {
EXPECT_WRITE32(ALERT_HANDLER_INTR_ENABLE_REG_OFFSET, 0);
EXPECT_EQ(dif_alert_handler_irq_disable_all(&handler_, nullptr),
kDifAlertHandlerOk);
EXPECT_READ32(ALERT_HANDLER_INTR_ENABLE_REG_OFFSET, 0xaa4242aa);
EXPECT_WRITE32(ALERT_HANDLER_INTR_ENABLE_REG_OFFSET, 0);
dif_alert_handler_irq_snapshot_t snap;
EXPECT_EQ(dif_alert_handler_irq_disable_all(&handler_, &snap),
kDifAlertHandlerOk);
EXPECT_WRITE32(ALERT_HANDLER_INTR_ENABLE_REG_OFFSET, 0xaa4242aa);
EXPECT_EQ(dif_alert_handler_irq_restore_all(&handler_, &snap),
kDifAlertHandlerOk);
}
TEST_F(IrqTest, NullArgs) {
bool flag;
EXPECT_EQ(
dif_alert_handler_irq_is_pending(nullptr, kDifAlertHandlerClassA, &flag),
kDifAlertHandlerBadArg);
EXPECT_EQ(dif_alert_handler_irq_is_pending(&handler_, kDifAlertHandlerClassA,
nullptr),
kDifAlertHandlerBadArg);
EXPECT_EQ(dif_alert_handler_irq_acknowledge(nullptr, kDifAlertHandlerClassA),
kDifAlertHandlerBadArg);
dif_alert_handler_toggle_t toggle;
EXPECT_EQ(dif_alert_handler_irq_get_enabled(nullptr, kDifAlertHandlerClassA,
&toggle),
kDifAlertHandlerBadArg);
EXPECT_EQ(dif_alert_handler_irq_get_enabled(&handler_, kDifAlertHandlerClassA,
nullptr),
kDifAlertHandlerBadArg);
EXPECT_EQ(dif_alert_handler_irq_set_enabled(nullptr, kDifAlertHandlerClassA,
kDifAlertHandlerToggleEnabled),
kDifAlertHandlerBadArg);
EXPECT_EQ(dif_alert_handler_irq_force(nullptr, kDifAlertHandlerClassA),
kDifAlertHandlerBadArg);
dif_alert_handler_irq_snapshot_t snap;
EXPECT_EQ(dif_alert_handler_irq_disable_all(nullptr, &snap),
kDifAlertHandlerBadArg);
EXPECT_EQ(dif_alert_handler_irq_disable_all(nullptr, &snap),
kDifAlertHandlerBadArg);
EXPECT_EQ(dif_alert_handler_irq_restore_all(&handler_, nullptr),
kDifAlertHandlerBadArg);
}
class CauseTest : public AlertTest {};
TEST_F(CauseTest, IsCause) {
bool flag;
EXPECT_READ32(ALERT_HANDLER_ALERT_CAUSE_REG_OFFSET, {{0, true}, {5, true}});
EXPECT_EQ(dif_alert_handler_alert_is_cause(&handler_, 5, &flag),
kDifAlertHandlerOk);
EXPECT_TRUE(flag);
EXPECT_READ32(ALERT_HANDLER_ALERT_CAUSE_REG_OFFSET, {{0, true}, {5, true}});
EXPECT_EQ(dif_alert_handler_alert_is_cause(&handler_, 6, &flag),
kDifAlertHandlerOk);
EXPECT_FALSE(flag);
}
TEST_F(CauseTest, Ack) {
EXPECT_WRITE32(ALERT_HANDLER_ALERT_CAUSE_REG_OFFSET, {{11, true}});
EXPECT_EQ(dif_alert_handler_alert_acknowledge(&handler_, 11),
kDifAlertHandlerOk);
}
TEST_F(CauseTest, BadAlert) {
bool flag;
EXPECT_EQ(dif_alert_handler_alert_is_cause(&handler_, kAlerts, &flag),
kDifAlertHandlerBadArg);
EXPECT_EQ(dif_alert_handler_alert_acknowledge(&handler_, kAlerts),
kDifAlertHandlerBadArg);
}
TEST_F(CauseTest, IsCauseLocal) {
bool flag;
EXPECT_READ32(ALERT_HANDLER_LOC_ALERT_CAUSE_REG_OFFSET,
{{ALERT_HANDLER_LOC_ALERT_CAUSE_LA_0, true},
{ALERT_HANDLER_LOC_ALERT_CAUSE_LA_1, true}});
EXPECT_EQ(dif_alert_handler_local_alert_is_cause(
&handler_, kDifAlertHandlerLocalAlertEscalationPingFail, &flag),
kDifAlertHandlerOk);
EXPECT_TRUE(flag);
EXPECT_READ32(ALERT_HANDLER_LOC_ALERT_CAUSE_REG_OFFSET,
{{ALERT_HANDLER_LOC_ALERT_CAUSE_LA_0, true},
{ALERT_HANDLER_LOC_ALERT_CAUSE_LA_1, true}});
EXPECT_EQ(dif_alert_handler_local_alert_is_cause(
&handler_, kDifAlertHandlerLocalAlertAlertIntegrityFail, &flag),
kDifAlertHandlerOk);
EXPECT_FALSE(flag);
}
TEST_F(CauseTest, AckLocal) {
EXPECT_WRITE32(ALERT_HANDLER_LOC_ALERT_CAUSE_REG_OFFSET,
{{ALERT_HANDLER_LOC_ALERT_CAUSE_LA_3, true}});
EXPECT_EQ(dif_alert_handler_local_alert_acknowledge(
&handler_, kDifAlertHandlerLocalAlertEscalationIntegrityFail),
kDifAlertHandlerOk);
}
TEST_F(CauseTest, NullArgs) {
bool flag;
EXPECT_EQ(dif_alert_handler_alert_is_cause(nullptr, 5, &flag),
kDifAlertHandlerBadArg);
EXPECT_EQ(dif_alert_handler_alert_is_cause(&handler_, 5, nullptr),
kDifAlertHandlerBadArg);
EXPECT_EQ(dif_alert_handler_alert_acknowledge(nullptr, 11),
kDifAlertHandlerBadArg);
EXPECT_EQ(dif_alert_handler_local_alert_is_cause(
nullptr, kDifAlertHandlerLocalAlertEscalationPingFail, &flag),
kDifAlertHandlerBadArg);
EXPECT_EQ(
dif_alert_handler_local_alert_is_cause(
&handler_, kDifAlertHandlerLocalAlertEscalationPingFail, nullptr),
kDifAlertHandlerBadArg);
EXPECT_EQ(dif_alert_handler_local_alert_acknowledge(
nullptr, kDifAlertHandlerLocalAlertEscalationIntegrityFail),
kDifAlertHandlerBadArg);
}
class EscalationTest : public AlertTest {};
TEST_F(EscalationTest, CanClear) {
bool flag;
EXPECT_READ32(ALERT_HANDLER_CLASSB_CLREN_REG_OFFSET, true);
EXPECT_EQ(dif_alert_handler_escalation_can_clear(
&handler_, kDifAlertHandlerClassB, &flag),
kDifAlertHandlerOk);
EXPECT_TRUE(flag);
EXPECT_READ32(ALERT_HANDLER_CLASSA_CLREN_REG_OFFSET, false);
EXPECT_EQ(dif_alert_handler_escalation_can_clear(
&handler_, kDifAlertHandlerClassA, &flag),
kDifAlertHandlerOk);
EXPECT_FALSE(flag);
}
TEST_F(EscalationTest, Disable) {
EXPECT_WRITE32(ALERT_HANDLER_CLASSC_CLREN_REG_OFFSET, true);
EXPECT_EQ(dif_alert_handler_escalation_disable_clearing(
&handler_, kDifAlertHandlerClassC),
kDifAlertHandlerOk);
}
TEST_F(EscalationTest, Clear) {
EXPECT_WRITE32(ALERT_HANDLER_CLASSD_CLR_REG_OFFSET, true);
EXPECT_EQ(
dif_alert_handler_escalation_clear(&handler_, kDifAlertHandlerClassD),
kDifAlertHandlerOk);
}
TEST_F(EscalationTest, NullArgs) {
bool flag;
EXPECT_EQ(dif_alert_handler_escalation_can_clear(
nullptr, kDifAlertHandlerClassB, &flag),
kDifAlertHandlerBadArg);
EXPECT_EQ(dif_alert_handler_escalation_can_clear(
&handler_, kDifAlertHandlerClassB, nullptr),
kDifAlertHandlerBadArg);
EXPECT_EQ(dif_alert_handler_escalation_disable_clearing(
nullptr, kDifAlertHandlerClassC),
kDifAlertHandlerBadArg);
EXPECT_EQ(dif_alert_handler_escalation_clear(nullptr, kDifAlertHandlerClassD),
kDifAlertHandlerBadArg);
}
class GetterTest : public AlertTest {};
TEST_F(GetterTest, GetAcc) {
uint16_t alerts;
EXPECT_READ32(ALERT_HANDLER_CLASSB_ACCUM_CNT_REG_OFFSET, 0xaaaa);
EXPECT_EQ(dif_alert_handler_get_accumulator(&handler_, kDifAlertHandlerClassB,
&alerts),
kDifAlertHandlerOk);
EXPECT_EQ(alerts, 0xaaaa);
}
TEST_F(GetterTest, GetCycles) {
uint32_t cycles;
EXPECT_READ32(ALERT_HANDLER_CLASSD_ESC_CNT_REG_OFFSET, 0xaaaaaaaa);
EXPECT_EQ(dif_alert_handler_get_escalation_counter(
&handler_, kDifAlertHandlerClassD, &cycles),
kDifAlertHandlerOk);
EXPECT_EQ(cycles, 0xaaaaaaaa);
}
TEST_F(GetterTest, GetState) {
dif_alert_handler_class_state_t state;
EXPECT_READ32(ALERT_HANDLER_CLASSC_STATE_REG_OFFSET,
ALERT_HANDLER_CLASSA_STATE_CLASSA_STATE_VALUE_TIMEOUT);
EXPECT_EQ(dif_alert_handler_get_class_state(&handler_, kDifAlertHandlerClassC,
&state),
kDifAlertHandlerOk);
EXPECT_EQ(state, kDifAlertHandlerClassStateTimeout);
EXPECT_READ32(ALERT_HANDLER_CLASSA_STATE_REG_OFFSET,
ALERT_HANDLER_CLASSA_STATE_CLASSA_STATE_VALUE_PHASE2);
EXPECT_EQ(dif_alert_handler_get_class_state(&handler_, kDifAlertHandlerClassA,
&state),
kDifAlertHandlerOk);
EXPECT_EQ(state, kDifAlertHandlerClassStatePhase2);
}
TEST_F(GetterTest, NullArgs) {
uint16_t alerts;
EXPECT_EQ(dif_alert_handler_get_accumulator(nullptr, kDifAlertHandlerClassB,
&alerts),
kDifAlertHandlerBadArg);
EXPECT_EQ(dif_alert_handler_get_accumulator(&handler_, kDifAlertHandlerClassB,
nullptr),
kDifAlertHandlerBadArg);
uint32_t cycles;
EXPECT_EQ(dif_alert_handler_get_escalation_counter(
nullptr, kDifAlertHandlerClassB, &cycles),
kDifAlertHandlerBadArg);
EXPECT_EQ(dif_alert_handler_get_escalation_counter(
&handler_, kDifAlertHandlerClassB, nullptr),
kDifAlertHandlerBadArg);
dif_alert_handler_class_state_t state;
EXPECT_EQ(dif_alert_handler_get_class_state(nullptr, kDifAlertHandlerClassC,
&state),
kDifAlertHandlerBadArg);
EXPECT_EQ(dif_alert_handler_get_class_state(&handler_, kDifAlertHandlerClassC,
nullptr),
kDifAlertHandlerBadArg);
}
} // namespace
} // namespace dif_alert_handler_unittest
| [
"mcyoung@google.com"
] | mcyoung@google.com |
275f443a5357af91782a36337c21c298c0a43790 | 068a46b3281cb80277d3f1068da8223894dcccb6 | /client/c_baseentity.h | 03362c48487dda713115c331523e9c8252bf8a17 | [] | no_license | lachbr/libpandabsp-game | f8b9155db9a57ebb6f620125c0e87b52451d26ef | ecf668230bfd2606adde43ac00d3d7b9348f5a9d | refs/heads/master | 2022-04-23T19:11:06.716343 | 2020-04-19T02:06:52 | 2020-04-19T02:06:52 | 256,395,933 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 964 | h | /**
* PANDA3D BSP LIBRARY
*
* Copyright (c) Brian Lach <brianlach72@gmail.com>
* All rights reserved.
*
* @file c_baseentity.h
* @author Brian Lach
* @date January 25, 2020
*/
#ifndef C_BASEENTITY_H_
#define C_BASEENTITY_H_
#include <typedReferenceCount.h>
#include "config_clientdll.h"
#include <aa_luse.h>
#include <nodePath.h>
#include <pvector.h>
#include "client_class.h"
NotifyCategoryDeclNoExport( c_baseentity )
class EXPORT_CLIENT_DLL C_BaseEntity : public CBaseEntityShared
{
DECLARE_CLASS( C_BaseEntity, CBaseEntityShared )
public:
C_BaseEntity();
entid_t get_owner() const;
void send_entity_message( Datagram &dg );
virtual void receive_entity_message( int msgtype, DatagramIterator &dgi );
virtual void post_data_update();
virtual void spawn();
virtual void init( entid_t entnum );
public:
entid_t _owner_entity;
};
INLINE entid_t C_BaseEntity::get_owner() const
{
return _owner_entity;
}
#endif // C_BASEENTITY_H_
| [
"brianlach72@gmail.com"
] | brianlach72@gmail.com |
1de52b80bcf05375b644917c6509a10b81be423b | b0df09b397384c149877cebfdfd9f88db077edc4 | /disciplinas/cmp134/jpeg/TonyJpegLib_src/J2kDemo/JpcDoc.cpp | df6b6c83eede695ba268e06a3e9f361507061f09 | [] | no_license | kdubezerra/kdubezerra | 95f8b4285c7460b1f3fb4ac1a1593545e2a13dcd | f3054a15d74d2047c751070f5720ea933f9b73fe | refs/heads/master | 2020-05-18T15:12:28.546476 | 2015-09-16T13:55:36 | 2015-09-16T13:55:36 | 32,155,920 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,739 | cpp | // JpcDoc.cpp : implementation file
//
#include "stdafx.h"
#include "J2kDemo.h"
#include "JpcDoc.h"
#include "RateDlg.h"
#include "QualityDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CJpcDoc
IMPLEMENT_DYNCREATE(CJpcDoc, CDocument)
CJpcDoc::CJpcDoc()
{
}
BOOL CJpcDoc::OnNewDocument()
{
if (!CDocument::OnNewDocument())
return FALSE;
return TRUE;
}
CJpcDoc::~CJpcDoc()
{
}
BEGIN_MESSAGE_MAP(CJpcDoc, CDocument)
//{{AFX_MSG_MAP(CJpcDoc)
ON_COMMAND(ID_FILE_SAVE_AS, OnFileSaveAs)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CJpcDoc diagnostics
#ifdef _DEBUG
void CJpcDoc::AssertValid() const
{
CDocument::AssertValid();
}
void CJpcDoc::Dump(CDumpContext& dc) const
{
CDocument::Dump(dc);
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CJpcDoc serialization
void CJpcDoc::Serialize(CArchive& ar)
{
if (ar.IsStoring())
{
// TODO: add storing code here
}
else
{
// TODO: add loading code here
}
}
/////////////////////////////////////////////////////////////////////////////
// CJpcDoc commands
BOOL CJpcDoc::OnOpenDocument(LPCTSTR lpszPathName)
{
m_dib.LoadFrom( lpszPathName );
return TRUE;
}
void CJpcDoc::OnFileSaveAs()
{
char BASED_CODE szFilter[] =
"BMP Files (*.bmp)|*.bmp|JPG Files (*.jpg)|*.jpg|\
JPP Files (*.jpp)|*.jpp|JPC Files (*.jpc)|*.jpc|JP2 Files (*.jp2)|*.jp2||";
CString strPath, strFile, strExt;
CFileDialog dlg( FALSE, "bmp", "tmp",
OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, szFilter );
if( dlg.DoModal() == IDOK )
{
strPath = dlg.GetPathName();
strFile = dlg.GetFileName();
strExt = dlg.GetFileExt();
if(( strExt == "bmp" )||( strExt == "BMP" ))
{
m_dib.Save( strPath );
}
else if(( strExt == "jpg" )||( strExt == "JPG" ))
{
CQualityDlg dlg;
dlg.DoModal();
int quality = dlg.m_nTrackbar1;
m_dib.SaveJpg( strPath, true, quality );
}
else if(( strExt == "jpp" )||( strExt == "JPP" ))
{
m_dib.SaveJppFile( strPath );
}
else if(( strExt == "jpc" )||( strExt == "JPC" ))
{
CRateDlg dlg;
dlg.DoModal();
int rate = dlg.m_nTrackbar1;
m_dib.SaveAs( strPath, rate );
}
else if(( strExt == "jp2" )||( strExt == "JP2" ))
{
CRateDlg dlg;
dlg.DoModal();
int rate = dlg.m_nTrackbar1;
m_dib.SaveAs( strPath, rate );
}
else
{
AfxMessageBox( "unsupported file type !" );
return;
}
}
}
| [
"kdubezerra@67108f60-033f-0410-b9a3-03c69097e409"
] | kdubezerra@67108f60-033f-0410-b9a3-03c69097e409 |
4e85d18d872897bbf03c9b9f38e585918647719f | d2c2c673fea8e61bfa760d005c1263f0818c51ad | /libnativebridge/tests/DummyNativeBridge3.cpp | c538fa071f5396c0791725d16fa6e0bc90bb4a4e | [
"LicenseRef-scancode-unicode",
"Apache-2.0"
] | permissive | sandamoo1982/platform_system_core | 626928297cf9809fe3e46d5b2e1f1f5f45dbf0ce | b5f062bde4c9d2d5e3d2be9b9711231a4fc64a6e | refs/heads/master | 2020-12-24T12:14:26.261782 | 2016-11-04T20:52:49 | 2016-11-04T20:52:49 | 73,058,441 | 1 | 0 | null | 2016-11-07T08:41:25 | 2016-11-07T08:41:23 | null | UTF-8 | C++ | false | false | 4,056 | cpp | /*
* Copyright (C) 2016 The Android Open Source Project
*
* 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.
*/
// A dummy implementation of the native-bridge interface.
#include "nativebridge/native_bridge.h"
#include <signal.h>
// NativeBridgeCallbacks implementations
extern "C" bool native_bridge3_initialize(
const android::NativeBridgeRuntimeCallbacks* /* art_cbs */,
const char* /* app_code_cache_dir */,
const char* /* isa */) {
return true;
}
extern "C" void* native_bridge3_loadLibrary(const char* /* libpath */, int /* flag */) {
return nullptr;
}
extern "C" void* native_bridge3_getTrampoline(void* /* handle */, const char* /* name */,
const char* /* shorty */, uint32_t /* len */) {
return nullptr;
}
extern "C" bool native_bridge3_isSupported(const char* /* libpath */) {
return false;
}
extern "C" const struct android::NativeBridgeRuntimeValues* native_bridge3_getAppEnv(
const char* /* abi */) {
return nullptr;
}
extern "C" bool native_bridge3_isCompatibleWith(uint32_t version) {
// For testing, allow 1-3, but disallow 4+.
return version <= 3;
}
static bool native_bridge3_dummy_signal_handler(int, siginfo_t*, void*) {
// TODO: Implement something here. We'd either have to have a death test with a log here, or
// we'd have to be able to resume after the faulting instruction...
return true;
}
extern "C" android::NativeBridgeSignalHandlerFn native_bridge3_getSignalHandler(int signal) {
if (signal == SIGSEGV) {
return &native_bridge3_dummy_signal_handler;
}
return nullptr;
}
extern "C" int native_bridge3_unloadLibrary(void* /* handle */) {
return 0;
}
extern "C" char* native_bridge3_getError() {
return nullptr;
}
extern "C" bool native_bridge3_isPathSupported(const char* /* path */) {
return true;
}
extern "C" bool native_bridge3_initNamespace(const char* /* public_ns_sonames */,
const char* /* anon_ns_library_path */) {
return true;
}
extern "C" android::native_bridge_namespace_t*
native_bridge3_createNamespace(const char* /* name */,
const char* /* ld_library_path */,
const char* /* default_library_path */,
uint64_t /* type */,
const char* /* permitted_when_isolated_path */,
android::native_bridge_namespace_t* /* parent_ns */) {
return nullptr;
}
extern "C" void* native_bridge3_loadLibraryExt(const char* /* libpath */,
int /* flag */,
android::native_bridge_namespace_t* /* ns */) {
return nullptr;
}
android::NativeBridgeCallbacks NativeBridgeItf {
// v1
.version = 3,
.initialize = &native_bridge3_initialize,
.loadLibrary = &native_bridge3_loadLibrary,
.getTrampoline = &native_bridge3_getTrampoline,
.isSupported = &native_bridge3_isSupported,
.getAppEnv = &native_bridge3_getAppEnv,
// v2
.isCompatibleWith = &native_bridge3_isCompatibleWith,
.getSignalHandler = &native_bridge3_getSignalHandler,
// v3
.unloadLibrary = &native_bridge3_unloadLibrary,
.getError = &native_bridge3_getError,
.isPathSupported = &native_bridge3_isPathSupported,
.initNamespace = &native_bridge3_initNamespace,
.createNamespace = &native_bridge3_createNamespace,
.loadLibraryExt = &native_bridge3_loadLibraryExt
};
| [
"dimitry@google.com"
] | dimitry@google.com |
e2adc410b03d10116b893ab6fda9aeaf273aa308 | 1d1f67e1a3f98871a1b9ba100704083e426fade9 | /Leet2019/LargestPalindromeProduct.cpp | 1be7a1d894dd7a51f7f11f1233688607a178caca | [] | no_license | flameshimmer/leet2019.io | fae46200ed78fb0478db726b8c31e976e7d57001 | 47808dc97609f5a96c97a6fc703b98c75ad9a2b3 | refs/heads/master | 2022-07-22T10:51:10.651558 | 2022-07-07T18:05:48 | 2022-07-07T18:05:48 | 202,389,705 | 1 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 165 | cpp | #include "stdafx.h"
//
namespace Solution2019
{
namespace LargestPalindromeProduct
{
void Main() {
string test = "tst test test";
print(test);
}
}
}
| [
"Ning@ningmadev99.redmond.corp.microsoft.com"
] | Ning@ningmadev99.redmond.corp.microsoft.com |
e54e74d1c39f804bbc8b84381b088adab6731860 | b4fbabc1814ad11ebb50ca7077b0d4d4a3855e2e | /GateServer/gateServer.h | 41fc3463a3161f2bb26bd881fe746e483df4564d | [
"MIT"
] | permissive | Crasader/MyServer-1 | 637a977a15f4cd7c416de519aebc3fb145412f3d | e5436bf18466a0bad1aaa29bff2bbc0e8b790ef8 | refs/heads/master | 2023-03-17T03:18:56.887909 | 2015-11-30T14:01:15 | 2015-11-30T14:03:15 | null | 0 | 0 | null | null | null | null | GB18030 | C++ | false | false | 2,225 | h | #ifndef __GATE_SERVER_H__
#define __GATE_SERVER_H__
#include <map>
#include <boost/shared_ptr.hpp>
#include <boost/asio.hpp>
#include <boost/thread/detail/singleton.hpp>
#include <boost/thread/thread_time.hpp>
#include <string>
#include "tcpServer.h"
#include "tcpConnection.h"
#include "gateHandler.h"
#include "http_server.h"
#include "connection.h"
using namespace boost::asio;
#define gateSvr boost::detail::thread::singleton<my::GateServer>::instance()
#define __SERVER_NAME__ "gate"
#define MAX_NET_ID 2147483647
namespace my
{
class GateServer : public TcpServer
{
public:
typedef boost::shared_ptr<TcpConnection> ConnectionPtr;
typedef std::map<int, ConnectionPtr> ConnectionMap;
typedef boost::shared_ptr<GateServer> ptr;
typedef boost::shared_ptr<boost::asio::ip::tcp::acceptor> AcceptorPtr;
typedef boost::shared_ptr<http::HttpServer> HttpServerPtr;
public:
GateServer();
virtual ~GateServer();
void connectToGameSvr(std::string ipaddr, int port);
void connectToAccountSvr(std::string ipaddr, int port);
void sendToGameSvr(NetMessage& msg);
void sendToAccountSvr(NetMessage& msg);
void sendToPlayer(NetMessage& msg);
void init();
void handle_accept(ConnectionPtr conn, boost::system::error_code err); // 重写handle_accept
void handle_connect(ConnectionPtr conn, boost::system::error_code err);
virtual void handle_disconnect(ConnectionPtr conn);
void onPlayerLogin(int playerId, int netId);
void update();
boost::system_time getSystemTime();
void on_http_req(http::Connection* connPtr, Json::Value& reqJson);
private:
void connect(std::string ipaddr, std::string port, ConnectionPtr conn);
void checkHeartBeat(boost::system_time time);
void checkServerAlive(boost::system_time time);
bool kickConnection(ConnectionPtr conn);
void kickPlayer(int playerId, int netId);
private:
Json::Value m_GateConf;
AcceptorPtr m_pAcceptor;
ConnectionMap m_ConnMap;
ConnectionMap m_PlayerMap;
int m_nConnCount;
int m_nNetIdHolder;
ConnectionPtr m_pGameConn; // 用于连接到game
ConnectionPtr m_pAccountConn; //连接AcountSvr
boost::system_time m_SystemTime;
GateHandler::ptr m_GateHandler;
HttpServerPtr m_HttpServerPtr;
};
}
#endif | [
"elenno.chen@gmail.com"
] | elenno.chen@gmail.com |
a29c67d5429ef6434fef51289b1bec94fae7e913 | 474ca3fbc2b3513d92ed9531a9a99a2248ec7f63 | /ThirdParty/boost_1_63_0/libs/asio/test/local/stream_protocol.cpp | 49d5b1253a2bd3f38ec869c36a941dcfe4dfbd7d | [
"BSL-1.0"
] | permissive | LazyPlanet/MX-Architecture | 17b7b2e6c730409b22b7f38633e7b1f16359d250 | 732a867a5db3ba0c716752bffaeb675ebdc13a60 | refs/heads/master | 2020-12-30T15:41:18.664826 | 2018-03-02T00:59:12 | 2018-03-02T00:59:12 | 91,156,170 | 4 | 0 | null | 2018-02-04T03:29:46 | 2017-05-13T07:05:52 | C++ | UTF-8 | C++ | false | false | 6,760 | cpp | //
// stream_protocol.cpp
// ~~~~~~~~~~~~~~~~~~~
//
// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
// Disable autolinking for unit tests.
#if !defined(BOOST_ALL_NO_LIB)
#define BOOST_ALL_NO_LIB 1
#endif // !defined(BOOST_ALL_NO_LIB)
// Test that header file is self-contained.
#include <boost/asio/local/stream_protocol.hpp>
#include <cstring>
#include <boost/asio/io_service.hpp>
#include "../unit_test.hpp"
//------------------------------------------------------------------------------
// local_stream_protocol_socket_compile test
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// The following test checks that all public member functions on the class
// local::stream_protocol::socket compile and link correctly. Runtime failures
// are ignored.
namespace local_stream_protocol_socket_compile {
void connect_handler(const boost::system::error_code&)
{
}
void send_handler(const boost::system::error_code&, std::size_t)
{
}
void receive_handler(const boost::system::error_code&, std::size_t)
{
}
void write_some_handler(const boost::system::error_code&, std::size_t)
{
}
void read_some_handler(const boost::system::error_code&, std::size_t)
{
}
void test()
{
#if defined(BOOST_ASIO_HAS_LOCAL_SOCKETS)
using namespace boost::asio;
namespace local = boost::asio::local;
typedef local::stream_protocol sp;
try
{
io_service ios;
char mutable_char_buffer[128] = "";
const char const_char_buffer[128] = "";
socket_base::message_flags in_flags = 0;
socket_base::keep_alive socket_option;
socket_base::bytes_readable io_control_command;
boost::system::error_code ec;
// basic_stream_socket constructors.
sp::socket socket1(ios);
sp::socket socket2(ios, sp());
sp::socket socket3(ios, sp::endpoint(""));
int native_socket1 = ::socket(AF_UNIX, SOCK_STREAM, 0);
sp::socket socket4(ios, sp(), native_socket1);
// basic_io_object functions.
io_service& ios_ref = socket1.get_io_service();
(void)ios_ref;
// basic_socket functions.
sp::socket::lowest_layer_type& lowest_layer = socket1.lowest_layer();
(void)lowest_layer;
socket1.open(sp());
socket1.open(sp(), ec);
int native_socket2 = ::socket(AF_UNIX, SOCK_STREAM, 0);
socket1.assign(sp(), native_socket2);
int native_socket3 = ::socket(AF_UNIX, SOCK_STREAM, 0);
socket1.assign(sp(), native_socket3, ec);
bool is_open = socket1.is_open();
(void)is_open;
socket1.close();
socket1.close(ec);
sp::socket::native_type native_socket4 = socket1.native();
(void)native_socket4;
socket1.cancel();
socket1.cancel(ec);
bool at_mark1 = socket1.at_mark();
(void)at_mark1;
bool at_mark2 = socket1.at_mark(ec);
(void)at_mark2;
std::size_t available1 = socket1.available();
(void)available1;
std::size_t available2 = socket1.available(ec);
(void)available2;
socket1.bind(sp::endpoint(""));
socket1.bind(sp::endpoint(""), ec);
socket1.connect(sp::endpoint(""));
socket1.connect(sp::endpoint(""), ec);
socket1.async_connect(sp::endpoint(""), connect_handler);
socket1.set_option(socket_option);
socket1.set_option(socket_option, ec);
socket1.get_option(socket_option);
socket1.get_option(socket_option, ec);
socket1.io_control(io_control_command);
socket1.io_control(io_control_command, ec);
sp::endpoint endpoint1 = socket1.local_endpoint();
sp::endpoint endpoint2 = socket1.local_endpoint(ec);
sp::endpoint endpoint3 = socket1.remote_endpoint();
sp::endpoint endpoint4 = socket1.remote_endpoint(ec);
socket1.shutdown(socket_base::shutdown_both);
socket1.shutdown(socket_base::shutdown_both, ec);
// basic_stream_socket functions.
socket1.send(buffer(mutable_char_buffer));
socket1.send(buffer(const_char_buffer));
socket1.send(null_buffers());
socket1.send(buffer(mutable_char_buffer), in_flags);
socket1.send(buffer(const_char_buffer), in_flags);
socket1.send(null_buffers(), in_flags);
socket1.send(buffer(mutable_char_buffer), in_flags, ec);
socket1.send(buffer(const_char_buffer), in_flags, ec);
socket1.send(null_buffers(), in_flags, ec);
socket1.async_send(buffer(mutable_char_buffer), send_handler);
socket1.async_send(buffer(const_char_buffer), send_handler);
socket1.async_send(null_buffers(), send_handler);
socket1.async_send(buffer(mutable_char_buffer), in_flags, send_handler);
socket1.async_send(buffer(const_char_buffer), in_flags, send_handler);
socket1.async_send(null_buffers(), in_flags, send_handler);
socket1.receive(buffer(mutable_char_buffer));
socket1.receive(null_buffers());
socket1.receive(buffer(mutable_char_buffer), in_flags);
socket1.receive(null_buffers(), in_flags);
socket1.receive(buffer(mutable_char_buffer), in_flags, ec);
socket1.receive(null_buffers(), in_flags, ec);
socket1.async_receive(buffer(mutable_char_buffer), receive_handler);
socket1.async_receive(null_buffers(), receive_handler);
socket1.async_receive(buffer(mutable_char_buffer), in_flags,
receive_handler);
socket1.async_receive(null_buffers(), in_flags, receive_handler);
socket1.write_some(buffer(mutable_char_buffer));
socket1.write_some(buffer(const_char_buffer));
socket1.write_some(null_buffers());
socket1.write_some(buffer(mutable_char_buffer), ec);
socket1.write_some(buffer(const_char_buffer), ec);
socket1.write_some(null_buffers(), ec);
socket1.async_write_some(buffer(mutable_char_buffer), write_some_handler);
socket1.async_write_some(buffer(const_char_buffer), write_some_handler);
socket1.async_write_some(null_buffers(), write_some_handler);
socket1.read_some(buffer(mutable_char_buffer));
socket1.read_some(buffer(mutable_char_buffer), ec);
socket1.read_some(null_buffers(), ec);
socket1.async_read_some(buffer(mutable_char_buffer), read_some_handler);
socket1.async_read_some(null_buffers(), read_some_handler);
}
catch (std::exception&)
{
}
#endif // defined(BOOST_ASIO_HAS_LOCAL_SOCKETS)
}
} // namespace local_stream_protocol_socket_compile
//------------------------------------------------------------------------------
BOOST_ASIO_TEST_SUITE
(
"local/stream_protocol",
BOOST_ASIO_TEST_CASE(local_stream_protocol_socket_compile::test)
)
| [
"1211618464@qq.com"
] | 1211618464@qq.com |
013340ea3328d8fa389b37a6f98b633e755ed021 | 7cfc0c9c43bf5edb91b818fbcf726eb15e108ab3 | /curves/View.h | 05c3e16f6960572b9fd812ee10aa38458f056d5c | [
"MIT"
] | permissive | kujenga/curves | 1cba327f61d00c76c5f4bb3e113f63f695b2811b | 03857442c7b200a9206f6cfaadeb648047e578fe | refs/heads/master | 2021-01-20T10:59:38.411666 | 2015-04-15T13:40:17 | 2015-04-15T13:40:17 | 24,816,067 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 796 | h | //
// View.h
// curves
//
// Created by Aaron Taylor on 10/9/14.
// Copyright (c) 2014 Aaron Taylor. All rights reserved.
//
#ifndef __curves__View__
#define __curves__View__
#include <stdio.h>
#include <OpenGL/gl.h>
#include <OpenGL/glu.h>
#include <GLUT/glut.h>
#include "curve.h"
class View {
protected:
bool selected = false;
float2 transformedFloat2(float x, float y)
{
return scale * float2(x, y) + origin;
}
float2 transformedFloat2(float2 p)
{
return scale * p + origin;
}
public:
float2 scale;
float2 origin;
bool containsPoint(float2 point);
void setSelected(bool select) { selected = select; }
virtual void draw();
void draw(Color c);
};
#endif /* defined(__curves__View__) */
| [
"ataylor0123@gmail.com"
] | ataylor0123@gmail.com |
9b5b37184ea4b21f24237632c6ec9883eaabf1f3 | 86105b5998a9958245b29051f19f010e740a8bd4 | /helper.h | b6e014919121c7dec81c55eec2f6af09a96e5f22 | [] | no_license | Prayas-Agrawal/simplecs-A-C-compiler | c3599ad6e7d84631c3494fadefcf8c68166537e9 | 5b78493f81c671516d937b6ad69889e987b8aee6 | refs/heads/master | 2023-02-22T23:11:14.209475 | 2021-01-24T14:17:13 | 2021-01-24T14:17:13 | 298,882,861 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 9,755 | h | #include<bits/stdc++.h>
#include <cassert>
#include "tree.h"
#include "symbolTable.h"
#include "logging.h"
#ifndef HEADER_HELPER
#define HEADER_HELPER
#define DBG(x) ((void)0)
#ifndef DBG
#define DBG(x) x
#endif
#define _UN 0
#define _EQEQ 1
#define _GT 2
#define _GEQ 3
#define _LT 4
#define _LEQ 5
#define _NEQ 6
#define _PLUS 7
#define _MINUS 8
#define _STAR 9
#define _DIV 10
#define _MOD 11
#define _OR 12
#define _TWC 13
#define _AND 14
#define _NOT 15
#define _SIZEOF 16
#define _INT 201
#define _ID 202
#define _EXPR 203
#define BUF 1<<8
#define SHORTBUF 1<<4
using namespace std;
void constantPropogation(int lineNum, string var, int val)
{
logConstProp(lineNum, var, val);
}
void constantFolding(int op, treeNode* lhs, treeNode* lOp, treeNode* rOp)
{
switch(op)
{
case _LT:
lhs->val = lOp->val < rOp->val;
break;
case _GT:
lhs->val = lOp->val > rOp->val;
break;
case _LEQ:
lhs->val = lOp->val <= rOp->val;
break;
case _GEQ:
lhs->val = lOp->val >= rOp->val;
break;
case _OR:
lhs->val = lOp->val || rOp->val;
break;
case _SIZEOF:
//TODO
//lhs->val = lOp->val + rOp->val;
break;
case _EQEQ:
lhs->val = (lOp->val == rOp->val);
break;
case _NEQ:
lhs->val = (lOp->val != rOp->val);
break;
case _TWC:
lhs->val = 1*(lOp->val > rOp->val) + (-1)*(lOp->val < rOp->val);
break;
case _AND:
lhs->val = lOp->val && rOp->val;
break;
case _PLUS:
lhs->val = lOp->val + rOp->val;
break;
case _MINUS:
lhs->val = lOp->val - rOp->val;
break;
case _STAR:
lhs->val = lOp->val * rOp->val;
break;
case _DIV:
lhs->val = lOp->val / rOp->val;
break;
case _MOD:
lhs->val = lOp->val % rOp->val;
break;
}
char buf[BUF];
sprintf(buf, "$%d", lhs->val);
lhs->isLitOrStaticDefined = 1;
lhs->timesExprFolded = lOp->timesExprFolded + rOp->timesExprFolded + 1;
lhs->makeIns("movl", buf, "%eax");
DBG(printf(
"binary constant folding of %s(%d) and %s(%d) at line %d, with expr folded %d times\n",
(char*)&(lOp->nodeName)[0],
lOp->val,
(char*)&(rOp->nodeName)[0],
rOp->val,
lhs->lineNum,
lhs->timesExprFolded
)
);
logConstantFolding(lhs);
}
void constantFolding(int op, treeNode* lhs, treeNode* oprnd)
{
//TODO: log
switch(op)
{
case _NOT:
lhs->val = !(oprnd->val);
break;
case _MINUS:
lhs->val = -(oprnd->val);
break;
case _PLUS:
lhs->val = +(oprnd->val);
break;
}
char buf[BUF];
sprintf(buf, "$%d", lhs->val);
lhs->isLitOrStaticDefined = 1;
lhs->timesExprFolded = oprnd->timesExprFolded + 1;
lhs->makeIns("movl", buf, "%eax");
DBG(printf("unary constant folding of %s(%d) at line %d\n", (char*)&(oprnd->nodeName)[0], oprnd->val, lhs->lineNum ));
logConstantFolding(lhs);
}
void strengthReduction(treeNode* lhs, treeNode* lOp, treeNode* rOp)
{
if(lOp->isLitOrStaticDefined)
{
double exp = log2((double)lOp->val);
if(ceil(exp) == floor(exp))
{
logStrengthReduction(lhs->lineNum, exp);
char buf[BUF];
sprintf(buf, "$%d", (int)exp);
lhs->isLitOrStaticDefined = 0;
lhs->append(rOp);
lhs->makeIns("pushq", "%rax");
lhs->makeIns("movl", buf, "%ebx");
lhs->makeIns("shl", "%ebx", "%eax");
}
else
{
lhs->append(rOp);
lhs->makeIns("pushq", "%rax");
lhs->append(lOp);
lhs->makeIns("popq", "%rbx");
lhs->makeIns("imul", "%ebx", "%eax");
}
}
else if(rOp->isLitOrStaticDefined)
{
double exp = log2((double)rOp->val);
if(ceil(exp)== floor(exp))
{
logStrengthReduction(lhs->lineNum, exp);
char buf[BUF];
sprintf(buf, "$%d", (int)exp);
lhs->isLitOrStaticDefined = 0;
lhs->append(lOp);
lhs->makeIns("pushq", "%rax");
lhs->makeIns("movl", buf, "%ebx");
lhs->makeIns("shl", "%ebx", "%eax");
}
else
{
lhs->append(rOp);
lhs->makeIns("pushq", "%rax");
lhs->append(lOp);
lhs->makeIns("popq", "%rbx");
lhs->makeIns("imul", "%ebx", "%eax");
}
}
}
void purgeUnusedVars(SymbolTableClass& symbolTable)
{
//DBG(printf("inside unused func, symboltable size is %ld\n", (symbolTable.ST).size()));
//map<string, int> unusedVars;
for(int i=0; i<(symbolTable.ST).size(); i++)
{
//DBG(printf("symbol table has %d elements\n", symbolTable.ST[1].size()));
for(auto it = (symbolTable.ST[i]).begin(); it != (symbolTable.ST[i]).end(); ++it)
{
if((it->first)[0] != NULL)
{
//DBG(printf("checking unsed %s\n", (char*)&(it->first)[0]));
if((it->second).isDefined <= 0)
{
//TODO: log
//DBG(printf("logging unsed %s\n", (char*)&(it->first)[0]));
logUnusedVar(it->first, (it->second).order);
//symbolTable.ST[i].erase(it);
}
}
}
}
}
int bfs(SymbolTableClass& symbolTable, treeNode* root, treeNode* node)
{
//int terminalsMatched = 0;
if(root->children.size() != node->children.size())
{
DBG(printf("size of nodes uneual, returing\n"));
return -1;
}
for(int j =0; j < root->children.size(); j++)
{
treeNode* rootTerm = (root->children)[j];
treeNode* nodeTerm = (node->children)[j];
string IDENTIFIER = "IDENTIFIER";
string identifier = "identifier";
string INTEGER_NUMBER = "INTEGER_NUMBER";
string integerlit = "integerLit";
if( ( (rootTerm->children).size() == 0) && ( (nodeTerm->children).size() == 0) )
{
DBG(printf("terminal check started\n"));
if((rootTerm->nodeName == IDENTIFIER) && (nodeTerm->nodeName == IDENTIFIER))
{
if(rootTerm->lexValue == nodeTerm->lexValue)
{
DBG(printf("%d | matched terminal %s %s\n",
node->lineNum, (char*)&(rootTerm->lexValue)[0], (char*)&(nodeTerm->lexValue)[0] ));
}
else return -1;
}
else if( (rootTerm->nodeName == IDENTIFIER) && (nodeTerm->nodeName == INTEGER_NUMBER) )
{
DBG(printf("inside the unequal check\n"));
struct attr* rootSym = symbolTable.getSymbolAttr((root->children)[j]->lexValue);
if( (rootSym->isStaticallyDefined == 1) && (to_string(rootSym->staticValue) == nodeTerm->lexValue) )
{
DBG(printf("%d | matched terminal %d %s\n",
node->lineNum, (rootSym->staticValue), (char*)&(nodeTerm->lexValue)[0] ));
}
else return -1;
}
else if( (nodeTerm->nodeName == IDENTIFIER) && (rootTerm->nodeName == INTEGER_NUMBER) )
{
DBG(printf("inside the unequal check\n"));
struct attr* nodeSym = symbolTable.getSymbolAttr((node->children)[j]->lexValue);
if( (nodeSym->isStaticallyDefined == 1) && (to_string(nodeSym->staticValue) == rootTerm->lexValue) )
{
DBG(printf("%d | matched terminal %s %d\n",
node->lineNum, (char*)&(rootTerm->lexValue)[0], (nodeSym->staticValue) ));
}
else return -1;
}
else if(rootTerm->lexValue == nodeTerm->lexValue)
{
DBG(printf("%d | matched terminal %s %s\n",
node->lineNum, (char*)&(rootTerm->lexValue)[0], (char*)&(nodeTerm->lexValue)[0] ));
}
else return -1;
}
else if( ( (rootTerm->children).size() != 0) && ( (nodeTerm->children).size() != 0) )
{
DBG(printf("NON-terminal check started\n"));
if( rootTerm->nodeName == nodeTerm->nodeName )
{
DBG(printf("%d | matched NON-terminal %s %s\n", node->lineNum, (char*)&(rootTerm->nodeName)[0], (char*)&(nodeTerm->nodeName)[0] ));
}
else if( (rootTerm->nodeName == identifier && nodeTerm->nodeName == integerlit) ||
(rootTerm->nodeName == integerlit && nodeTerm->nodeName == identifier) )
{
DBG(printf("%d | continue chcking %s %s\n", node->lineNum, (char*)&(rootTerm->nodeName)[0], (char*)&(nodeTerm->nodeName)[0] ));
}
else
{
DBG(printf("%d | MISMATCH NON-terminal %s %s\n", node->lineNum, (char*)&(rootTerm->nodeName)[0], (char*)&(nodeTerm->nodeName)[0] ));
return -1;
}
}
else
{
DBG(printf("one node childeren size is zero, returning\n"));
return -1;
}
}
for(int j = 0; j < root->children.size(); j++)
{
if(bfs(symbolTable, (root->children)[j], (node->children)[j]) <=0)
{
return -1;
}
}
return 1;
}
treeNode* findSubTree(SymbolTableClass& symbolTable, vector<treeNode*> &treeNodeList, treeNode* node)
{
for(int i=0; i<treeNodeList.size(); i++)
{
if( (treeNodeList[i] != node) && (treeNodeList[i]->nodeName == node->nodeName))
{
treeNode* root = treeNodeList[i];
DBG(printf("%d | checking tree with line %d with root num in node list %d having nodename %s\n",
node->lineNum, root->lineNum, i, (char*)&(root->nodeName)[0] ));
if(bfs(symbolTable, root, node) > 0)
{
DBG(printf("%d | MATCHED tree with line %d with root num in node list %d having nodename %s\n",
node->lineNum, root->lineNum, i, (char*)&(root->nodeName)[0] ));
logCommonSubExprElimination(root->lineNum, node->lineNum);
return root;
}
}
}
return NULL;
}
int findSubTreeFromNode(SymbolTableClass& symbolTable, treeNode* root, treeNode* node)
{
DBG(printf("FINDING MAXIMAL EXPR TREE at line %d \n", root->lineNum));
if(bfs(symbolTable, root, node) > 0)
{
DBG(printf("MAXIMAL TREE FOUND\n"));
return 1;
}
if( (node->nodeName == "expr") && (node->children.size() == 1) && (node->children[0]->nodeName == "Pexpr") )
{
if(bfs(symbolTable, root, node->children[0])>0)
{
DBG(printf("MAXIMAL TREE FOUND\n"));
return 1;
}
}
for(int i=0; i < root->children.size(); i++)
{
if(findSubTreeFromNode(symbolTable, (root->children)[i], node)>0)
{
DBG(printf("MAXIMAL TREE FOUND\n"));
return 1;
}
}
DBG(printf("MAXIMAL TREE NOT FOUND\n"));
return -1;
}
#endif
| [
"noreply@github.com"
] | Prayas-Agrawal.noreply@github.com |
e8e8d7e062459caeccae953a79716da1166001e1 | c8241ab766f14ea71669ce34fab70bfd928d6d4b | /main/test_manual.cpp | dc9b5be22203e332cb154ee8d934239d0a5c8d98 | [] | no_license | zbqxyz/Tcutest_SerialSystem | 7f82916722f6c4f554b84897253b0fb4259dfaa2 | 46cb3b2d287ca471edd853760185042342296869 | refs/heads/master | 2020-04-13T22:00:40.648743 | 2018-03-16T03:26:44 | 2018-03-16T03:26:44 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,646 | cpp | #include "test_manual.h"
#include "ui_test_manual.h"
#include "Card_window.h"
#include "Emter_window.h"
#include "connect_charge.h"
#include "equipment_testing.h"
#include "gps/gps.h"
#include "gprs/gprs.h"
#include "network/netwindow.h"
//#include "mythread.h"
#include "qr_code.h"
#include "first_interface.h"
#include "card_operation.h"
#include "double_gun.h"
//mythread test_Manual::mythread_can ;
#include "serialsystem.h"
//#define MYTHREAD
//#undef MYTHREAD
test_Manual::test_Manual(QWidget *parent) :
QWidget(parent),
ui(new Ui::test_Manual)
{
ui->setupUi(this);
setWindowFlags(Qt::FramelessWindowHint);//窗口没有没有边
QPalette palette;
palette.setBrush(QPalette::Background, QBrush(QPixmap(":/img/images/Main.png")));
this->setPalette(palette);
setAttribute(Qt::WA_DeleteOnClose); //关闭时自动的释放内存
connect(ui->back_but,SIGNAL(clicked()),this,SLOT(slot_hide()));//BACK
connect(ui->Card_but,SIGNAL(clicked()),this,SLOT(slot_card()));
connect(ui->Emeter_but,SIGNAL(clicked()),this,SLOT(slot_emter()));
connect(ui->Canbus_but,SIGNAL(clicked()),this,SLOT(slot_canbus()));
connect(ui->gprs_but,SIGNAL(clicked()),this,SLOT(slot_gprs()));
connect(ui->gps_but,SIGNAL(clicked()),this,SLOT(slot_gps()));
connect(ui->network_but,SIGNAL(clicked()),this,SLOT(slot_network()));
connect(ui->touch_but,SIGNAL(clicked()),this,SLOT(slot_touch()));
connect(ui->pwm_but,SIGNAL(clicked()),this,SLOT(slot_pwm()));
// w_connect = new connect_charge;
// stackLayout = new QStackedLayout;
// stackLayout->addWidget(w_connect);
// connect(w_connect, SIGNAL(display(int)), stackLayout, SLOT(setCurrentIndex(int)));
// mainLayout = new QVBoxLayout;
// mainLayout->addLayout(stackLayout);
// setLayout(mainLayout);
}
test_Manual::~test_Manual()
{
delete ui;
}
void test_Manual::slot_hide()
{
hide();
#ifdef MYTHREAD
mythread_can.stop();
#endif
}
void test_Manual::slot_card()
{
CardWindow *w_card = new CardWindow;
w_card->show();
}
void test_Manual::slot_emter()
{
EmterWindow *w_emter = new EmterWindow;
w_emter->show();
//equipment_testing *w_equ_testing = new equipment_testing(this);
//w_equ_testing->show();
}
void test_Manual::slot_canbus()
{
#ifdef MYTHREAD
if(mythread_can.stopstatus == true){
mythread_can.stop();
}
mythread_can.start();
#endif
#ifndef MYTHREAD
connect_charge *w_connect = new connect_charge(this);
w_connect->show();
#endif
// widget_tmp = new Widget;
// widget_tmp->show();
//widget_tmp->showFullScreen();
//widget_tmp->showMaximized();
}
void test_Manual::slot_gprs()
{
Gprs *w_gprs = new Gprs;
w_gprs->show();
}
void test_Manual::slot_gps()
{
gps *w_gps = new gps;
w_gps->show();
}
void test_Manual::slot_network()
{
NetWindow *w_net = new NetWindow;
w_net->show();
}
void test_Manual::slot_touch()
{
// QProcess *pro = new QProcess;
// pro->start("ts_calibrate");
// ::system("ts_calibrate");
// QR_code *w_qrcode = new QR_code;
// w_qrcode->show();
double_gun *w_double_gun = new double_gun;
w_double_gun->show();
}
void test_Manual::slot_pwm()
{
//First_interface *w_interface = new First_interface;
//w_interface->show();
//card_operation *w_card_operation = new card_operation;
//w_card_operation->show();
//::system("aplay audio/wo.wav");
//::system("mplayer audio/test.mp3");
tcu_canbus();
}
| [
"891276268@qq.com"
] | 891276268@qq.com |
a62e5b368aefe33f562f8dbba5073850e047faf4 | f4d5cea422189fa68b9c48d59d14c52562adc0fb | /VIC_2018_MT1/CubeClass.cpp | 63cdbba59680ef1ae4a5b2d4caa0b10ae7a48364 | [] | no_license | LoganLeeee/Moonbase | 43f5fdffc170e30958648cbf5f2080f18afbc2f5 | 6ec933407aae1b926a92c555d7d7142c5d181235 | refs/heads/master | 2020-03-28T05:22:36.629455 | 2018-09-15T01:40:17 | 2018-09-15T01:40:17 | 147,772,387 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,324 | cpp | /**** Cube in points-polygons (polyhedron) form ****/
#include "CubeClass.h"
static GLfloat Verts[8][3] = {
{ -0.5, 0.5, -0.5 }, /* 0 left top rear */
{ 0.5, 0.5, -0.5 }, /* 1 right top rear */
{ 0.5, -0.5, -0.5 }, /* 2 right bottom rear */
{ -0.5, -0.5, -0.5 }, /* 3 left bottom rear */
{ -0.5, 0.5, 0.5 }, /* 4 left top front */
{ 0.5, 0.5, 0.5 }, /* 5 right top front */
{ 0.5, -0.5, 0.5 }, /* 6 right bottom front */
{ -0.5, -0.5, 0.5 } /* 7 left bottom front */
};
static GLuint Faces[6][4] = {
4, 5, 6, 7, /* front */
5, 1, 2, 6, /* right */
0, 4, 7, 3, /* left */
4, 0, 1, 5, /* top */
7, 6, 2, 3, /* bottom */
1, 0, 3, 2 /* rear */
};
// glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
// glColor3f(0.0, 1.0, 1.0);
// glLineWidth(3);
CubeClass::CubeClass()
{
}
void CubeClass::renderCW()
{
/* Draw cube in traditional OpenGL style */
glBegin(GL_QUADS);
for (int face = 0; face < 6; face++)
{
for (int vert = 0; vert < 4; vert++)
glVertex3fv(Verts[Faces[face][vert]]);
}
glEnd();
}
void CubeClass::renderCCW()
{
/* Draw cube in traditional OpenGL style */
glBegin(GL_QUADS);
for (int face = 0; face < 6; face++)
{
for (int vert = 3; vert >= 0; vert--)
glVertex3fv(Verts[Faces[face][vert]]);
}
glEnd();
}
void CubeClass::render()
{
renderCCW();
} | [
"1161537463@qq.com"
] | 1161537463@qq.com |
b0a51004baa8a6480d4765b146852bb1b804f08a | e050245561271ac4359b7ccf9a86e68c05cf258f | /mainwindow.h | a0a3f31eb51d91601161a3b62ea295fdebd3357c | [
"MIT"
] | permissive | Jackiu1997/QtMineCleaner | 23e31f656ecfc56c56b4400d3ff281a82909f629 | b0b50ca1b0523bfad57fd1098c00ee82a5af3499 | refs/heads/master | 2020-07-22T05:20:45.983047 | 2019-09-08T10:00:40 | 2019-09-08T10:00:40 | 207,085,437 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,180 | h | #ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
#include <QPoint>
#include <QPainter>
#include <QMouseEvent>
#include "minecleaner.h"
namespace Ui {
class MainWindow;
}
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
explicit MainWindow(QWidget *parent = 0);
~MainWindow();
private slots:
void on_btn_aiMode_clicked();
void on_btn_reset_clicked();
void on_btn_exit_clicked();
void on_btn_randomMap_clicked();
void on_btn_customMap_clicked();
private:
int areaWidth;
bool editMode;
int bombCount;
int **cusMap;
bool gameStart;
MineCleaner mineCleaner;
QImage blackImg;
QImage whiteImg;
QImage bombImg;
QImage flagImg;
QPoint origin;
int blockWidth;
Ui::MainWindow *ui;
void paintEvent(QPaintEvent *event);
void drawBlock(QPainter &painter, int row, int col, int type);
void mousePressEvent(QMouseEvent *event);
bool getClickRowCol(QPoint clickPos, int &row, int &col);
int clickDelay = 100;
void aiClick();
void getRoundCount(int row, int col, int &coverNum, int &flagNum);
bool judgeWinDead();
};
#endif // MAINWINDOW_H
| [
"Jackiu1997@outlook.com"
] | Jackiu1997@outlook.com |
02030fb63e806124412b9376b7a6f24568d38f61 | ec9106a5a1c91077f2aef585fb5baa4d29fdc480 | /CashDispenser.h | d33fb771fe870eb5936105fa033f781847b99147 | [] | no_license | mosobhy/ATM-Software-System | 9b246a3add3d7d99554cdfa988421f7efcedb0b7 | d65baf870c70c9593ef59b2d6431fe7642c07549 | refs/heads/main | 2023-07-11T17:09:32.063628 | 2021-08-06T14:32:25 | 2021-08-06T14:32:25 | 362,509,407 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 498 | h | // CashDispnser.h
#ifndef CASH_DISPENSER_H
#define CASH_DISPENSER_H
#include <iostream>
using namespace std;
class CashDispenser {
private:
static const int INITIAL_COUNT = 500; // class attribute to be copied into the count attribute each day
int count;
public:
CashDispenser(); // this will be set to 500 bill of 20
bool isSufficientCredit(int amount);
bool dispenseCash(int amount); // if the count suffice, decrement
};
#endif | [
"mosobhy@debian"
] | mosobhy@debian |
98c47ab4e99a1166a8868373c267407380aaa993 | 3318f27240391d490939a2e7245492cba42ab1ff | /extra/test.cpp | ee4816efcd12b890ea44db5ceaf20d16a32ab80b | [
"MIT"
] | permissive | buckaroo-upgrade-bot/jpcy-xatlas | 7597d526b490870cc4951adeffa22acbe278249b | 82af04633ca32cdb7963bc898e12919fdad9c5ad | refs/heads/master | 2020-04-30T11:58:39.121233 | 2019-03-20T16:06:54 | 2019-03-20T16:06:54 | 176,815,096 | 0 | 1 | null | 2019-03-20T20:52:17 | 2019-03-20T20:52:17 | null | UTF-8 | C++ | false | false | 4,459 | cpp | /*
xatlas
https://github.com/jpcy/xatlas
Copyright (c) 2018 Jonathan Young
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <stdio.h>
#include <time.h>
#ifdef _MSC_VER
#pragma warning(push)
#pragma warning(disable : 4201)
#endif
#include "thirdparty/tiny_obj_loader.h"
#ifdef _MSC_VER
#pragma warning(pop)
#endif
#include "../xatlas.h"
#define MODEL_PATH "../../models/"
#define ASSERT(_condition) if (!(_condition)) printf("[FAILED] '%s' %s %d\n", #_condition, __FILE__, __LINE__);
struct AtlasResult {
uint32_t chartCount;
};
bool generateAtlas(const char *name, AtlasResult *result)
{
char filename[256];
snprintf(filename, sizeof(filename), MODEL_PATH "%s.obj", name);
printf("%s", name);
std::vector<tinyobj::shape_t> shapes;
std::vector<tinyobj::material_t> materials;
std::string err;
if (!tinyobj::LoadObj(shapes, materials, err, filename, NULL, tinyobj::triangulation)) {
printf("\n[FAILED]: %s\n", err.c_str());
return false;
}
if (shapes.size() == 0) {
printf("\n[FAILED]: no shapes in obj file\n");
return false;
}
const clock_t start = clock();
xatlas::Atlas *atlas = xatlas::Create();
uint32_t totalVertices = 0, totalFaces = 0;
for (int i = 0; i < (int)shapes.size(); i++) {
const tinyobj::mesh_t &objMesh = shapes[i].mesh;
xatlas::MeshDecl meshDecl;
meshDecl.vertexCount = (int)objMesh.positions.size() / 3;
meshDecl.vertexPositionData = objMesh.positions.data();
meshDecl.vertexPositionStride = sizeof(float) * 3;
if (!objMesh.normals.empty()) {
meshDecl.vertexNormalData = objMesh.normals.data();
meshDecl.vertexNormalStride = sizeof(float) * 3;
}
if (!objMesh.texcoords.empty()) {
meshDecl.vertexUvData = objMesh.texcoords.data();
meshDecl.vertexUvStride = sizeof(float) * 2;
}
meshDecl.indexCount = (int)objMesh.indices.size();
meshDecl.indexData = objMesh.indices.data();
meshDecl.indexFormat = xatlas::IndexFormat::UInt32;
xatlas::AddMeshError::Enum error = xatlas::AddMesh(atlas, meshDecl);
if (error != xatlas::AddMeshError::Success) {
printf("\n[FAILED]: Error adding mesh %d '%s': %s\n", i, shapes[i].name.c_str(), xatlas::StringForEnum(error));
return false;
}
totalVertices += meshDecl.vertexCount;
totalFaces += meshDecl.indexCount / 3;
}
xatlas::Generate(atlas);
const clock_t end = clock();
printf(" [%g ms]\n", (end - start) * 1000.0 / (double)CLOCKS_PER_SEC);
uint32_t atlasTotalVertices = 0, atlasTotalFaces = 0;
for (uint32_t i = 0; i < atlas->meshCount; i++) {
const xatlas::Mesh &mesh = atlas->meshes[i];
atlasTotalVertices += mesh.vertexCount;
atlasTotalFaces += mesh.indexCount / 3;
}
ASSERT(atlasTotalVertices == totalVertices);
ASSERT(atlasTotalFaces == totalFaces);
result->chartCount = atlas->chartCount;
xatlas::Destroy(atlas);
return true;
}
int main(int /*argc*/, char ** /*argv*/)
{
AtlasResult result;
if (generateAtlas("cube", &result)) {
ASSERT(result.chartCount == 6);
}
if (generateAtlas("degenerate_edge", &result)) {
ASSERT(result.chartCount == 1);
}
// double sided quad
if (generateAtlas("double_sided", &result)) {
ASSERT(result.chartCount == 2);
}
if (generateAtlas("duplicate_edge", &result)) {
ASSERT(result.chartCount == 2);
}
if (generateAtlas("gazebo", &result)) {
ASSERT(result.chartCount == 333);
}
if (generateAtlas("zero_area_face", &result)) {
ASSERT(result.chartCount == 0);
}
if (generateAtlas("zero_length_edge", &result)) {
ASSERT(result.chartCount == 1);
}
return 0;
}
| [
"young.jpc@gmail.com"
] | young.jpc@gmail.com |
319f66f0cbe6f3bf23e7aae1f3e6d9ec625086f9 | bf7f457e73780694af1c688f55fac3ba2413e82f | /mindspore/core/ops/ones_like.cc | 4872ed2ac97befeae6836d832a5142c7f8a69bb0 | [
"Apache-2.0",
"LicenseRef-scancode-proprietary-license",
"LGPL-2.1-only",
"Libpng",
"IJG",
"Zlib",
"MIT",
"MPL-2.0",
"BSD-3-Clause-Open-MPI",
"MPL-2.0-no-copyleft-exception",
"BSD-3-Clause",
"LicenseRef-scancode-warranty-disclaimer",
"LicenseRef-scancode-unknown-license-reference",
"AGPL-3.0-only",
"MPL-1.1",
"GPL-2.0-only",
"Unlicense",
"BSL-1.0",
"LicenseRef-scancode-public-domain",
"BSD-2-Clause",
"MPL-1.0"
] | permissive | chncwang/mindspore | 974441b85c9edc1e1ce30e086e9d33fb1ab2052c | 6dac92aedf0aa1541d181e6aedab29aaadc2dafb | refs/heads/master | 2023-03-10T11:13:31.752406 | 2021-03-02T11:21:09 | 2021-03-02T11:21:09 | 343,701,879 | 0 | 0 | Apache-2.0 | 2021-03-02T11:56:25 | 2021-03-02T08:38:28 | null | UTF-8 | C++ | false | false | 2,472 | cc | /**
* Copyright 2020 Huawei Technologies Co., Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <set>
#include <string>
#include <vector>
#include <memory>
#include "ops/ones_like.h"
#include "ops/op_utils.h"
#include "utils/check_convert_utils.h"
#include "abstract/primitive_infer_map.h"
namespace mindspore {
namespace ops {
namespace {
abstract::ShapePtr InferShape(const PrimitivePtr &primitive, const std::vector<AbstractBasePtr> &input_args) {
MS_EXCEPTION_IF_NULL(primitive);
auto OnesLike_prim = primitive->cast<PrimOnesLikePtr>();
MS_EXCEPTION_IF_NULL(OnesLike_prim);
auto prim_name = OnesLike_prim->name();
auto input_shape =
CheckAndConvertUtils::ConvertShapePtrToShape("input_shape", input_args[0]->BuildShape(), prim_name);
return std::make_shared<abstract::Shape>(input_shape);
}
TypePtr InferType(const PrimitivePtr &primitive, const std::vector<AbstractBasePtr> &input_args) {
// const std::set<TypeId> valid_types = {kNumberTypeInt8, kNumberTypeInt16, kNumberTypeInt32, kNumberTypeInt64,
// kNumberTypeUInt16, kNumberTypeUInt32, kNumberTypeUInt64,
// kNumberTypeFloat16, kNumberTypeFloat32, kNumberTypeFloat64,
// kNumberTypeBool};
auto infer_type = input_args[0]->BuildType();
CheckAndConvertUtils::CheckTensorTypeValid("infer_type", infer_type, common_valid_types, "OnesLike");
return infer_type;
}
} // namespace
AbstractBasePtr OnesLikeInfer(const abstract::AnalysisEnginePtr &, const PrimitivePtr &primitive,
const std::vector<AbstractBasePtr> &input_args) {
return std::make_shared<abstract::AbstractTensor>(InferType(primitive, input_args),
InferShape(primitive, input_args)->shape());
}
REGISTER_PRIMITIVE_C(kNameOnesLike, OnesLike);
} // namespace ops
} // namespace mindspore
| [
"jinyaohui@huawei.com"
] | jinyaohui@huawei.com |
f6815df7f05aa5d307096399ebbb9c2eef99f299 | 3844678a0fb3b1f0838fb04bc57fd93dee6ee631 | /sileecode/boost_book_ex/chap-11-serialization/ex.11.8.cpp | 719a0452b70dcf29b094f70d0eeab5c4a3dee5d6 | [] | no_license | jeonghanlee/Work | daa9295da3af3ff6c3a68daf51fac804dd1942cd | bef817911ea29fe091547f001ac35ac3765d8258 | refs/heads/master | 2022-09-28T03:59:29.435017 | 2022-09-15T18:26:34 | 2022-09-15T18:26:34 | 91,843,357 | 3 | 0 | null | 2019-01-08T16:10:37 | 2017-05-19T20:34:36 | VHDL | UTF-8 | C++ | false | false | 841 | cpp | #include <boost/archive/text_oarchive.hpp>
#include <boost/archive/text_iarchive.hpp>
#include <iostream>
#include <sstream>
std::stringstream ss;
class person
{
public:
person() {}
person(int age) : age_(age) {}
int age() const { return age_; }
private:
friend class boost::serialization::access;
template <typename Archive>
void serialize(Archive &ar, const unsigned int version)
{
ar & age_;
}
int age_;
};
void save()
{
boost::archive::text_oarchive oa(ss);
person *p = new person(31);
oa << p;
std::cout << std::hex << p << std::endl;
delete p;
}
void load()
{
boost::archive::text_iarchive ia(ss);
person *p;
ia >> p;
std::cout << std::hex << p << std::endl;
std::cout << p->age() << std::endl;
delete p;
}
int main()
{
save();
load();
} | [
"silee7103@gmail.com"
] | silee7103@gmail.com |
608221b042cde10601778f436248cae5022d6c1f | c02e6a950d0bf2ee8c875c70ad707df8b074bb8e | /build/Android/Release/bimcast/app/src/main/include/Uno.Vector.h | bdb454e1de98a702faa36c1d280d0f943ab2fec0 | [] | no_license | BIMCast/bimcast-landing-ui | 38c51ad5f997348f8c97051386552509ff4e3faf | a9c7ff963d32d625dfb0237a8a5d1933c7009516 | refs/heads/master | 2021-05-03T10:51:50.705052 | 2016-10-04T12:18:22 | 2016-10-04T12:18:22 | 69,959,209 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,707 | h | // This file was generated based on C:\ProgramData\Uno\Packages\UnoCore\0.35.8\Source\Uno\$.uno.
// WARNING: Changes might be lost if you edit this file directly.
#pragma once
#include <Uno.h>
namespace g{namespace Uno{struct Float2;}}
namespace g{namespace Uno{struct Float3;}}
namespace g{namespace Uno{struct Float4;}}
namespace g{namespace Uno{struct Float4x4;}}
namespace g{namespace Uno{struct Vector;}}
namespace g{
namespace Uno{
// public static class Vector :8537
// {
uClassType* Vector_typeof();
void Vector__Cross_fn(::g::Uno::Float3* left, ::g::Uno::Float3* right, ::g::Uno::Float3* __retval);
void Vector__Distance_fn(::g::Uno::Float2* p0, ::g::Uno::Float2* p1, float* __retval);
void Vector__Distance1_fn(::g::Uno::Float3* p0, ::g::Uno::Float3* p1, float* __retval);
void Vector__Dot_fn(::g::Uno::Float2* a, ::g::Uno::Float2* b, float* __retval);
void Vector__Dot1_fn(::g::Uno::Float3* a, ::g::Uno::Float3* b, float* __retval);
void Vector__Length_fn(::g::Uno::Float2* v, float* __retval);
void Vector__Length1_fn(::g::Uno::Float3* v, float* __retval);
void Vector__Length2_fn(::g::Uno::Float4* v, float* __retval);
void Vector__LengthSquared_fn(::g::Uno::Float2* v, float* __retval);
void Vector__LengthSquared1_fn(::g::Uno::Float3* v, float* __retval);
void Vector__LengthSquared2_fn(::g::Uno::Float4* v, float* __retval);
void Vector__Normalize_fn(::g::Uno::Float2* v, ::g::Uno::Float2* __retval);
void Vector__Normalize1_fn(::g::Uno::Float3* v, ::g::Uno::Float3* __retval);
void Vector__Normalize2_fn(::g::Uno::Float4* v, ::g::Uno::Float4* __retval);
void Vector__Transform1_fn(::g::Uno::Float2* vector, ::g::Uno::Float4x4* matrix, ::g::Uno::Float4* __retval);
void Vector__Transform4_fn(::g::Uno::Float3* vector, ::g::Uno::Float4x4* matrix, ::g::Uno::Float4* __retval);
void Vector__Transform5_fn(::g::Uno::Float4* vector, ::g::Uno::Float4x4* matrix, ::g::Uno::Float4* __retval);
void Vector__TransformCoordinate_fn(::g::Uno::Float2* vector, ::g::Uno::Float4x4* matrix, ::g::Uno::Float2* __retval);
void Vector__TransformCoordinate1_fn(::g::Uno::Float3* vector, ::g::Uno::Float4x4* matrix, ::g::Uno::Float3* __retval);
void Vector__TransformNormal1_fn(::g::Uno::Float3* vector, ::g::Uno::Float4x4* matrix, ::g::Uno::Float3* __retval);
struct Vector : uObject
{
static ::g::Uno::Float3 Cross(::g::Uno::Float3 left, ::g::Uno::Float3 right);
static float Distance(::g::Uno::Float2 p0, ::g::Uno::Float2 p1);
static float Distance1(::g::Uno::Float3 p0, ::g::Uno::Float3 p1);
static float Dot(::g::Uno::Float2 a, ::g::Uno::Float2 b);
static float Dot1(::g::Uno::Float3 a, ::g::Uno::Float3 b);
static float Length(::g::Uno::Float2 v);
static float Length1(::g::Uno::Float3 v);
static float Length2(::g::Uno::Float4 v);
static float LengthSquared(::g::Uno::Float2 v);
static float LengthSquared1(::g::Uno::Float3 v);
static float LengthSquared2(::g::Uno::Float4 v);
static ::g::Uno::Float2 Normalize(::g::Uno::Float2 v);
static ::g::Uno::Float3 Normalize1(::g::Uno::Float3 v);
static ::g::Uno::Float4 Normalize2(::g::Uno::Float4 v);
static ::g::Uno::Float4 Transform1(::g::Uno::Float2 vector, ::g::Uno::Float4x4 matrix);
static ::g::Uno::Float4 Transform4(::g::Uno::Float3 vector, ::g::Uno::Float4x4 matrix);
static ::g::Uno::Float4 Transform5(::g::Uno::Float4 vector, ::g::Uno::Float4x4 matrix);
static ::g::Uno::Float2 TransformCoordinate(::g::Uno::Float2 vector, ::g::Uno::Float4x4 matrix);
static ::g::Uno::Float3 TransformCoordinate1(::g::Uno::Float3 vector, ::g::Uno::Float4x4 matrix);
static ::g::Uno::Float3 TransformNormal1(::g::Uno::Float3 vector, ::g::Uno::Float4x4 matrix);
};
// }
}} // ::g::Uno
| [
"mabu@itechhub.co.za"
] | mabu@itechhub.co.za |
9c741755ef1dcfc669395b0f7fc8a582cd6c410e | 1e01b697191a910a872e95ddfce27a91cebc57dd | /ExprScriptFunction.cpp | a5d2ba822a8cb0950ea3850b96b0534b34c05310 | [] | no_license | canercandan/codeworker | 7c9871076af481e98be42bf487a9ec1256040d08 | a68851958b1beef3d40114fd1ceb655f587c49ad | refs/heads/master | 2020-05-31T22:53:56.492569 | 2011-01-29T19:12:59 | 2011-01-29T19:12:59 | 1,306,254 | 7 | 5 | null | null | null | null | IBM852 | C++ | false | false | 414,335 | cpp | /* "CodeWorker": a scripting language for parsing and generating text.
Copyright (C) 1996-1997, 1999-2002 CÚdric Lemaire
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library 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
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
To contact the author: codeworker@free.fr
*/
#ifdef WIN32
#pragma warning (disable : 4786)
#endif
#include <math.h>
#include "UtlException.h"
#include "ScpStream.h"
#include "CppCompilerEnvironment.h"
#include "CGRuntime.h"
#include "CGExternalHandling.h"
#include "DtaArrayIterator.h"
#include "GrfFunction.h"
#include "GrfForeach.h"
#include "GrfParseFree.h"
#include "GrfTranslate.h"
#include "DtaProject.h"
#include "DtaDesignScript.h"
#include "DtaPatternScript.h"
#include "DtaBNFScript.h"
#include "DtaScriptVariable.h"
#include "ExprScriptVariable.h"
#include "ExprScriptFunction.h"
namespace CodeWorker {
class ExprScriptFirst : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptFirst() {}
public:
virtual ~ExprScriptFirst() {}
virtual const char* getName() const { return "first"; }
virtual unsigned int getArity() const { return 1; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
if (iIndex == 0) return ITERATOR_EXPRTYPE;
return UNKNOWN_EXPRTYPE;
}
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
ExprScriptVariable* pIndexParam = (ExprScriptVariable*) _parameters.front();
DtaScriptVariable* pIndexExpr = visibility.getIterator(pIndexParam->getName().c_str());
if (pIndexExpr == NULL) throw UtlException("'first(" + pIndexParam->getName() + ")' has no sense: '" + pIndexParam->getName() + "' isn't declared as an index");
DtaArrayIterator* pIteratorData = pIndexExpr->getIteratorData();
if (pIteratorData == NULL) throw UtlException("'first(" + pIndexParam->getName() + ")' can't work here: '" + pIndexParam->getName() + "' is a reference to an index\nif '" + pIndexParam->getName() + "' is a function parameter, write '" + pIndexParam->getName() + " : index' in the prototype");
if (pIteratorData->first()) return "true";
return "";
}
virtual bool compileCppBoolean(CppCompilerEnvironment& theCompilerEnvironment, bool bNegative) const {
GrfForeach* pForeach = theCompilerEnvironment.getLastForeach();
std::string sModifier;
if (pForeach->getSorted()) {
sModifier = "Sorted";
if (pForeach->getSortedNoCase()) sModifier += "NoCase";
}
if (bNegative) {
CW_BODY_STREAM << "_compilerIndex" << sModifier << "Foreach_" << ((ExprScriptVariable*) _parameters.front())->getName() << " != _compilerMap" << sModifier << "Foreach_" << ((ExprScriptVariable*) _parameters.front())->getName() << "->begin()";
} else {
CW_BODY_STREAM << "_compilerIndex" << sModifier << "Foreach_" << ((ExprScriptVariable*) _parameters.front())->getName() << " == _compilerMap" << sModifier << "Foreach_" << ((ExprScriptVariable*) _parameters.front())->getName() << "->begin()";
}
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptFirst;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptFirst::_iCounter = 0;
class ExprScriptLast : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptLast() {}
public:
virtual ~ExprScriptLast() {}
virtual const char* getName() const { return "last"; }
virtual unsigned int getArity() const { return 1; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
if (iIndex == 0) return ITERATOR_EXPRTYPE;
return UNKNOWN_EXPRTYPE;
}
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
ExprScriptVariable* pIndexParam = (ExprScriptVariable*) _parameters.front();
DtaScriptVariable* pIndexExpr = visibility.getIterator(pIndexParam->getName().c_str());
if (pIndexExpr == NULL) throw UtlException("'last(" + pIndexParam->getName() + ")' has no sense: '" + pIndexParam->getName() + "' isn't declared as an index");
DtaArrayIterator* pIteratorData = pIndexExpr->getIteratorData();
if (pIteratorData == NULL) throw UtlException("'last(" + pIndexParam->getName() + ")' can't work here: '" + pIndexParam->getName() + "' is a reference to an index\nif '" + pIndexParam->getName() + "' is a function parameter, write '" + pIndexParam->getName() + " : index' in the prototype");
if (pIteratorData->last()) return "true";
return "";
}
virtual bool compileCppBoolean(CppCompilerEnvironment& theCompilerEnvironment, bool bNegative) const {
GrfForeach* pForeach = theCompilerEnvironment.getLastForeach();
std::string sModifier;
if (pForeach->getSorted()) {
sModifier = "Sorted";
if (pForeach->getSortedNoCase()) sModifier += "NoCase";
}
if (bNegative) {
CW_BODY_STREAM << "CGRuntime::nextIteration(_compilerIndex" << sModifier << "Foreach_" << ((ExprScriptVariable*) _parameters.front())->getName() << ") != _compilerMap" << sModifier << "Foreach_" << ((ExprScriptVariable*) _parameters.front())->getName() << "->end()";
} else {
CW_BODY_STREAM << "CGRuntime::nextIteration(_compilerIndex" << sModifier << "Foreach_" << ((ExprScriptVariable*) _parameters.front())->getName() << ") == _compilerMap" << sModifier << "Foreach_" << ((ExprScriptVariable*) _parameters.front())->getName() << "->end()";
}
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptLast;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptLast::_iCounter = 0;
class ExprScriptKey : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptKey() {}
public:
virtual ~ExprScriptKey() {}
virtual const char* getName() const { return "key"; }
virtual unsigned int getArity() const { return 1; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
if (iIndex == 0) return ITERATOR_EXPRTYPE;
return UNKNOWN_EXPRTYPE;
}
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
ExprScriptVariable* pIndexParam = (ExprScriptVariable*) _parameters.front();
DtaScriptVariable* pIndexExpr = visibility.getIterator(pIndexParam->getName().c_str());
if (pIndexExpr == NULL) throw UtlException("'key(" + pIndexParam->getName() + ")' has no sense: '" + pIndexParam->getName() + "' isn't declared as an index");
DtaArrayIterator* pIteratorData = pIndexExpr->getIteratorData();
if (pIteratorData == NULL) throw UtlException("'key(" + pIndexParam->getName() + ")' can't work here: '" + pIndexParam->getName() + "' is a reference to an index\nif '" + pIndexParam->getName() + "' is a function parameter, write '" + pIndexParam->getName() + " : index' in the prototype");
return pIteratorData->key();
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppString(theCompilerEnvironment);
return STRING_TYPE;
}
virtual bool compileCppBoolean(CppCompilerEnvironment& theCompilerEnvironment, bool bNegative) const {
if (!bNegative) CW_BODY_STREAM << "!";
compileCpp(theCompilerEnvironment);
CW_BODY_STREAM << ".empty()";
return true;
}
virtual bool compileCppString(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "_compilerKeyForeach_" << ((ExprScriptVariable*) _parameters.front())->getName();
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptKey;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptKey::_iCounter = 0;
class ExprScriptIndex : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptIndex() {}
public:
virtual ~ExprScriptIndex() {}
virtual const char* getName() const { return "index"; }
virtual unsigned int getArity() const { return 1; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
if (iIndex == 0) return ITERATOR_EXPRTYPE;
return UNKNOWN_EXPRTYPE;
}
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
ExprScriptVariable* pIndexParam = (ExprScriptVariable*) _parameters.front();
DtaScriptVariable* pIndexExpr = visibility.getIterator(pIndexParam->getName().c_str());
if (pIndexExpr == NULL) throw UtlException("'index(" + pIndexParam->getName() + ")' has no sense: '" + pIndexParam->getName() + "' isn't declared as an iterator");
DtaArrayIterator* pIteratorData = pIndexExpr->getIteratorData();
if (pIteratorData == NULL) throw UtlException("'index(" + pIndexParam->getName() + ")' can't work here: '" + pIndexParam->getName() + "' is a reference to an iterator\nif '" + pIndexParam->getName() + "' is a function parameter, write '" + pIndexParam->getName() + " : index' in the prototype");
char tcResult[32];
sprintf(tcResult, "%d", pIteratorData->index());
return tcResult;
}
virtual bool compileCppInt(CppCompilerEnvironment& theCompilerEnvironment, bool bNegative) const {
CW_BODY_STREAM << "<index() not handled yet!>";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptIndex;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptIndex::_iCounter = 0;
class ExprScriptPrec : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptPrec() {}
public:
virtual ~ExprScriptPrec() {}
virtual const char* getName() const { return "prec"; }
virtual unsigned int getArity() const { return 1; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
if (iIndex == 0) return ITERATOR_EXPRTYPE;
return UNKNOWN_EXPRTYPE;
}
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
ExprScriptVariable* pIndexParam = (ExprScriptVariable*) _parameters.front();
DtaScriptVariable* pIndexExpr = visibility.getIterator(pIndexParam->getName().c_str());
if (pIndexExpr == NULL) throw UtlException("'prec(" + pIndexParam->getName() + ")' has no sense: '" + pIndexParam->getName() + "' isn't declared as an iterator");
DtaArrayIterator* pIteratorData = pIndexExpr->getIteratorData();
if (pIteratorData == NULL) throw UtlException("'prec(" + pIndexParam->getName() + ")' can't work here: '" + pIndexParam->getName() + "' is a reference to an iterator\nif '" + pIndexParam->getName() + "' is a function parameter, write '" + pIndexParam->getName() + " : Prec' in the prototype");
if (pIteratorData->prec()) return "true";
return "";
}
virtual bool compileCppInt(CppCompilerEnvironment& theCompilerEnvironment, bool bNegative) const {
CW_BODY_STREAM << "<prec() not handled yet!>";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptPrec;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptPrec::_iCounter = 0;
class ExprScriptNext : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptNext() {}
public:
virtual ~ExprScriptNext() {}
virtual const char* getName() const { return "next"; }
virtual unsigned int getArity() const { return 1; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
if (iIndex == 0) return ITERATOR_EXPRTYPE;
return UNKNOWN_EXPRTYPE;
}
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
ExprScriptVariable* pIndexParam = (ExprScriptVariable*) _parameters.front();
DtaScriptVariable* pIndexExpr = visibility.getIterator(pIndexParam->getName().c_str());
if (pIndexExpr == NULL) throw UtlException("'next(" + pIndexParam->getName() + ")' has no sense: '" + pIndexParam->getName() + "' isn't declared as an iterator");
DtaArrayIterator* pIteratorData = pIndexExpr->getIteratorData();
if (pIteratorData == NULL) throw UtlException("'next(" + pIndexParam->getName() + ")' can't work here: '" + pIndexParam->getName() + "' is a reference to an iterator\nif '" + pIndexParam->getName() + "' is a function parameter, write '" + pIndexParam->getName() + " : Next' in the prototype");
if (pIteratorData->next()) return "true";
return "";
}
virtual bool compileCppInt(CppCompilerEnvironment& theCompilerEnvironment, bool bNegative) const {
CW_BODY_STREAM << "<next() not handled yet!>";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptNext;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptNext::_iCounter = 0;
class ExprScriptNot : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptNot() {}
public:
virtual ~ExprScriptNot() {}
virtual const char* getName() const { return "not"; }
virtual unsigned int getArity() const { return 1; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
if (iIndex == 0) return VALUE_EXPRTYPE;
return UNKNOWN_EXPRTYPE;
}
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
std::string sValue = _parameters.front()->getValue(visibility);
if (sValue.empty()) return "true";
return "";
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppBoolean(theCompilerEnvironment, true);
return BOOL_TYPE;
}
virtual bool compileCppBoolean(CppCompilerEnvironment& theCompilerEnvironment, bool bNegative) const {
return _parameters.front()->compileCppBoolean(theCompilerEnvironment, !bNegative);
}
virtual bool compileCppString(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "((";
compileCppBoolean(theCompilerEnvironment, false);
CW_BODY_STREAM << ") ? \"\" : \"true\")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptNot;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptNot::_iCounter = 0;
//##markup##"declarations"
//##begin##"declarations"
class ExprScriptFlushOutputToSocket : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptFlushOutputToSocket() {
}
public:
virtual ~ExprScriptFlushOutputToSocket() { }
virtual const char* getName() const { return "flushOutputToSocket"; }
virtual unsigned int getArity() const { return 1; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
if (iIndex == 0) return VALUE_EXPRTYPE;
return UNKNOWN_EXPRTYPE;
}
virtual bool isAGenerateFunction() const { return true; }
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
std::string sSocket = (*cursor)->getValue(visibility);
int iSocket = atoi(sSocket.c_str());
bool returnValue = CGRuntime::flushOutputToSocket(iSocket);
return (returnValue ? "true" : "");
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppBoolean(theCompilerEnvironment, false);
return BOOL_TYPE;
}
virtual bool compileCppBoolean(CppCompilerEnvironment& theCompilerEnvironment, bool bNegative) const {
if (bNegative) CW_BODY_STREAM << "!";
CW_BODY_STREAM << "CGRuntime::flushOutputToSocket(";
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
(*cursor)->compileCppInt(theCompilerEnvironment);
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptFlushOutputToSocket;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptFlushOutputToSocket::_iCounter = 0;
class ExprScriptAcceptSocket : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptAcceptSocket() {
}
public:
virtual ~ExprScriptAcceptSocket() { }
virtual const char* getName() const { return "acceptSocket"; }
virtual unsigned int getArity() const { return 1; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
if (iIndex == 0) return VALUE_EXPRTYPE;
return UNKNOWN_EXPRTYPE;
}
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
std::string sServerSocket = (*cursor)->getValue(visibility);
int iServerSocket = atoi(sServerSocket.c_str());
int returnValue = CGRuntime::acceptSocket(iServerSocket);
char tcNumber[16];
sprintf(tcNumber, "%d", returnValue);
return tcNumber;
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppInt(theCompilerEnvironment);
return INT_TYPE;
}
virtual bool compileCppDouble(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "(double) ";
return compileCppInt(theCompilerEnvironment);
}
virtual bool compileCppString(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "CGRuntime::toString(";
bool bSuccess = compileCppInt(theCompilerEnvironment);
if (bSuccess) CW_BODY_STREAM << ")";
return bSuccess;
}
virtual bool compileCppInt(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "CGRuntime::acceptSocket(";
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
(*cursor)->compileCppInt(theCompilerEnvironment);
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptAcceptSocket;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptAcceptSocket::_iCounter = 0;
class ExprScriptAdd : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptAdd() {
}
public:
virtual ~ExprScriptAdd() { }
virtual const char* getName() const { return "add"; }
virtual unsigned int getArity() const { return 2; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
if (iIndex == 0) return VALUE_EXPRTYPE;
if (iIndex == 1) return VALUE_EXPRTYPE;
return UNKNOWN_EXPRTYPE;
}
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
std::string sLeft = (*cursor)->getValue(visibility);
double dLeft = atof(sLeft.c_str());
++cursor;
std::string sRight = (*cursor)->getValue(visibility);
double dRight = atof(sRight.c_str());
double returnValue = CGRuntime::add(dLeft, dRight);
return CGRuntime::toString(returnValue);
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppDouble(theCompilerEnvironment);
return DOUBLE_TYPE;
}
virtual bool compileCppInt(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "(int) ";
return compileCppDouble(theCompilerEnvironment);
}
virtual bool compileCppString(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "CGRuntime::toString(";
bool bSuccess = compileCppDouble(theCompilerEnvironment);
if (bSuccess) CW_BODY_STREAM << ")";
return bSuccess;
}
virtual bool compileCppDouble(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "CGRuntime::add(";
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
(*cursor)->compileCppDouble(theCompilerEnvironment);
CW_BODY_STREAM << ", ";
++cursor;
(*cursor)->compileCppDouble(theCompilerEnvironment);
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptAdd;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptAdd::_iCounter = 0;
class ExprScriptAddGenerationTagsHandler : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptAddGenerationTagsHandler(GrfBlock& block) {
//##protect##"addGenerationTagsHandler::constructor"
_pReaderCache = NULL;
_pWriterCache = NULL;
//##protect##"addGenerationTagsHandler::constructor"
}
private:
//##protect##"addGenerationTagsHandler::attributes"
mutable DtaBNFScript* _pReaderCache;
mutable DtaPatternScript* _pWriterCache;
//##protect##"addGenerationTagsHandler::attributes"
public:
virtual ~ExprScriptAddGenerationTagsHandler() {
//##protect##"addGenerationTagsHandler::destructor"
if (_pReaderCache != NULL) delete _pReaderCache;
if (_pWriterCache != NULL) delete _pWriterCache;
//##protect##"addGenerationTagsHandler::destructor"
}
virtual const char* getName() const { return "addGenerationTagsHandler"; }
virtual unsigned int getArity() const { return 3; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
if (iIndex == 0) return VALUE_EXPRTYPE;
if (iIndex == 1) return SCRIPTFILE_BNF_EXPRTYPE;
if (iIndex == 2) return SCRIPTFILE_PATTERN_EXPRTYPE;
return UNKNOWN_EXPRTYPE;
}
virtual void initializationDone() {
//##protect##"addGenerationTagsHandler::initializationDone"
//##protect##"addGenerationTagsHandler::initializationDone"
}
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
bool returnValue;
//##protect##"addGenerationTagsHandler::execute"
std::string sKey = _parameters[0]->getValue(visibility);
returnValue = !DtaProject::getInstance().existGenerationTagsHandler(sKey);
if (returnValue) {
// the reader
DtaBNFScript* pReader;
ExprScriptScriptFile* pBNFFileName = dynamic_cast<ExprScriptScriptFile*>(_parameters[1]);
if (pBNFFileName->isFileName()) {
if (_pReaderCache == NULL) {
std::string sScriptFile = pBNFFileName->getFileName()->getValue(visibility);
std::auto_ptr<DtaBNFScript> pScript(new DtaBNFScript);
pScript->parseFile(sScriptFile.c_str());
_pReaderCache = pScript.release();
}
pReader = _pReaderCache;
} else {
pReader = dynamic_cast<DtaBNFScript*>(pBNFFileName->getBody());
}
// the writer
DtaPatternScript* pWriter;
ExprScriptScriptFile* pPatternFileName = dynamic_cast<ExprScriptScriptFile*>(_parameters[2]);
if (pPatternFileName->isFileName()) {
if (_pWriterCache == NULL) {
std::string sScriptFile = pPatternFileName->getFileName()->getValue(visibility);
std::auto_ptr<DtaPatternScript> pScript(new DtaPatternScript);
pScript->parseFile(sScriptFile.c_str());
_pWriterCache = pScript.release();
}
pWriter = _pWriterCache;
} else {
pWriter = dynamic_cast<DtaPatternScript*>(pPatternFileName->getBody());
}
// register the handler
returnValue = DtaProject::getInstance().addGenerationTagsHandler(sKey, pReader, pWriter);
}
//##protect##"addGenerationTagsHandler::execute"
return (returnValue ? "true" : "");
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppBoolean(theCompilerEnvironment, false);
return BOOL_TYPE;
}
virtual bool compileCppBoolean(CppCompilerEnvironment& theCompilerEnvironment, bool bNegative) const {
if (bNegative) CW_BODY_STREAM << "!";
//##protect##"addGenerationTagsHandler::compileCppBoolean"
//##protect##"addGenerationTagsHandler::compileCppBoolean"
return true;
}
static ExprScriptFunction* create(GrfBlock& block) {
return new ExprScriptAddGenerationTagsHandler(block);
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptAddGenerationTagsHandler::_iCounter = 0;
class ExprScriptAddToDate : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptAddToDate() {
}
public:
virtual ~ExprScriptAddToDate() { }
virtual const char* getName() const { return "addToDate"; }
virtual unsigned int getArity() const { return 3; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
if (iIndex == 0) return VALUE_EXPRTYPE;
if (iIndex == 1) return VALUE_EXPRTYPE;
if (iIndex == 2) return VALUE_EXPRTYPE;
return UNKNOWN_EXPRTYPE;
}
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
std::string sDate = (*cursor)->getValue(visibility);
++cursor;
std::string sFormat = (*cursor)->getValue(visibility);
++cursor;
std::string sShifting = (*cursor)->getValue(visibility);
std::string returnValue = CGRuntime::addToDate(sDate, sFormat, sShifting);
return returnValue;
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppString(theCompilerEnvironment);
return STRING_TYPE;
}
virtual bool compileCppString(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "CGRuntime::addToDate(";
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
(*cursor)->compileCppString(theCompilerEnvironment);
CW_BODY_STREAM << ", ";
++cursor;
(*cursor)->compileCppString(theCompilerEnvironment);
CW_BODY_STREAM << ", ";
++cursor;
(*cursor)->compileCppString(theCompilerEnvironment);
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptAddToDate;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptAddToDate::_iCounter = 0;
class ExprScriptByteToChar : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptByteToChar() {
}
public:
virtual ~ExprScriptByteToChar() { }
virtual const char* getName() const { return "byteToChar"; }
virtual unsigned int getArity() const { return 1; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
if (iIndex == 0) return VALUE_EXPRTYPE;
return UNKNOWN_EXPRTYPE;
}
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
std::string sByte = (*cursor)->getValue(visibility);
std::string returnValue = CGRuntime::byteToChar(sByte);
return returnValue;
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppString(theCompilerEnvironment);
return STRING_TYPE;
}
virtual bool compileCppString(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "CGRuntime::byteToChar(";
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
(*cursor)->compileCppString(theCompilerEnvironment);
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptByteToChar;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptByteToChar::_iCounter = 0;
class ExprScriptBytesToLong : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptBytesToLong() {
}
public:
virtual ~ExprScriptBytesToLong() { }
virtual const char* getName() const { return "bytesToLong"; }
virtual unsigned int getArity() const { return 1; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
if (iIndex == 0) return VALUE_EXPRTYPE;
return UNKNOWN_EXPRTYPE;
}
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
std::string sBytes = (*cursor)->getValue(visibility);
unsigned long returnValue = CGRuntime::bytesToLong(sBytes);
char tcNumber[16];
sprintf(tcNumber, "%Lu", returnValue);
return tcNumber;
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppUnsignedLong(theCompilerEnvironment);
return ULONG_TYPE;
}
virtual bool compileCppUnsignedLong(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "CGRuntime::bytesToLong(";
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
(*cursor)->compileCppString(theCompilerEnvironment);
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptBytesToLong;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptBytesToLong::_iCounter = 0;
class ExprScriptBytesToShort : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptBytesToShort() {
}
public:
virtual ~ExprScriptBytesToShort() { }
virtual const char* getName() const { return "bytesToShort"; }
virtual unsigned int getArity() const { return 1; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
if (iIndex == 0) return VALUE_EXPRTYPE;
return UNKNOWN_EXPRTYPE;
}
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
std::string sBytes = (*cursor)->getValue(visibility);
unsigned short returnValue = CGRuntime::bytesToShort(sBytes);
char tcNumber[16];
sprintf(tcNumber, "%hu", returnValue);
return tcNumber;
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppUnsignedShort(theCompilerEnvironment);
return USHORT_TYPE;
}
virtual bool compileCppUnsignedShort(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "CGRuntime::bytesToShort(";
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
(*cursor)->compileCppString(theCompilerEnvironment);
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptBytesToShort;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptBytesToShort::_iCounter = 0;
class ExprScriptCanonizePath : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptCanonizePath() {
}
public:
virtual ~ExprScriptCanonizePath() { }
virtual const char* getName() const { return "canonizePath"; }
virtual unsigned int getArity() const { return 1; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
if (iIndex == 0) return VALUE_EXPRTYPE;
return UNKNOWN_EXPRTYPE;
}
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
std::string sPath = (*cursor)->getValue(visibility);
std::string returnValue = CGRuntime::canonizePath(sPath);
return returnValue;
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppString(theCompilerEnvironment);
return STRING_TYPE;
}
virtual bool compileCppString(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "CGRuntime::canonizePath(";
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
(*cursor)->compileCppString(theCompilerEnvironment);
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptCanonizePath;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptCanonizePath::_iCounter = 0;
class ExprScriptChangeDirectory : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptChangeDirectory() {
}
public:
virtual ~ExprScriptChangeDirectory() { }
virtual const char* getName() const { return "changeDirectory"; }
virtual unsigned int getArity() const { return 1; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
if (iIndex == 0) return VALUE_EXPRTYPE;
return UNKNOWN_EXPRTYPE;
}
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
std::string sPath = (*cursor)->getValue(visibility);
bool returnValue = CGRuntime::changeDirectory(sPath);
return (returnValue ? "true" : "");
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppBoolean(theCompilerEnvironment, false);
return BOOL_TYPE;
}
virtual bool compileCppBoolean(CppCompilerEnvironment& theCompilerEnvironment, bool bNegative) const {
if (bNegative) CW_BODY_STREAM << "!";
CW_BODY_STREAM << "CGRuntime::changeDirectory(";
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
(*cursor)->compileCppString(theCompilerEnvironment);
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptChangeDirectory;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptChangeDirectory::_iCounter = 0;
class ExprScriptChangeFileTime : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptChangeFileTime() {
}
public:
virtual ~ExprScriptChangeFileTime() { }
virtual const char* getName() const { return "changeFileTime"; }
virtual unsigned int getArity() const { return 3; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
if (iIndex == 0) return VALUE_EXPRTYPE;
if (iIndex == 1) return VALUE_EXPRTYPE;
if (iIndex == 2) return VALUE_EXPRTYPE;
return UNKNOWN_EXPRTYPE;
}
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
std::string sFilename = (*cursor)->getValue(visibility);
++cursor;
std::string sAccessTime = (*cursor)->getValue(visibility);
++cursor;
std::string sModificationTime = (*cursor)->getValue(visibility);
int returnValue = CGRuntime::changeFileTime(sFilename, sAccessTime, sModificationTime);
char tcNumber[16];
sprintf(tcNumber, "%d", returnValue);
return tcNumber;
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppInt(theCompilerEnvironment);
return INT_TYPE;
}
virtual bool compileCppDouble(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "(double) ";
return compileCppInt(theCompilerEnvironment);
}
virtual bool compileCppString(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "CGRuntime::toString(";
bool bSuccess = compileCppInt(theCompilerEnvironment);
if (bSuccess) CW_BODY_STREAM << ")";
return bSuccess;
}
virtual bool compileCppInt(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "CGRuntime::changeFileTime(";
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
(*cursor)->compileCppString(theCompilerEnvironment);
CW_BODY_STREAM << ", ";
++cursor;
(*cursor)->compileCppString(theCompilerEnvironment);
CW_BODY_STREAM << ", ";
++cursor;
(*cursor)->compileCppString(theCompilerEnvironment);
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptChangeFileTime;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptChangeFileTime::_iCounter = 0;
class ExprScriptCharAt : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptCharAt() {
}
public:
virtual ~ExprScriptCharAt() { }
virtual const char* getName() const { return "charAt"; }
virtual unsigned int getArity() const { return 2; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
if (iIndex == 0) return VALUE_EXPRTYPE;
if (iIndex == 1) return VALUE_EXPRTYPE;
return UNKNOWN_EXPRTYPE;
}
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
std::string sText = (*cursor)->getValue(visibility);
++cursor;
std::string sIndex = (*cursor)->getValue(visibility);
int iIndex = atoi(sIndex.c_str());
std::string returnValue = CGRuntime::charAt(sText, iIndex);
return returnValue;
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppString(theCompilerEnvironment);
return STRING_TYPE;
}
virtual bool compileCppString(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "CGRuntime::charAt(";
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
(*cursor)->compileCppString(theCompilerEnvironment);
CW_BODY_STREAM << ", ";
++cursor;
(*cursor)->compileCppInt(theCompilerEnvironment);
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptCharAt;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptCharAt::_iCounter = 0;
class ExprScriptCharToByte : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptCharToByte() {
}
public:
virtual ~ExprScriptCharToByte() { }
virtual const char* getName() const { return "charToByte"; }
virtual unsigned int getArity() const { return 1; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
if (iIndex == 0) return VALUE_EXPRTYPE;
return UNKNOWN_EXPRTYPE;
}
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
std::string sChar = (*cursor)->getValue(visibility);
std::string returnValue = CGRuntime::charToByte(sChar);
return returnValue;
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppString(theCompilerEnvironment);
return STRING_TYPE;
}
virtual bool compileCppString(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "CGRuntime::charToByte(";
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
(*cursor)->compileCppString(theCompilerEnvironment);
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptCharToByte;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptCharToByte::_iCounter = 0;
class ExprScriptCharToInt : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptCharToInt() {
}
public:
virtual ~ExprScriptCharToInt() { }
virtual const char* getName() const { return "charToInt"; }
virtual unsigned int getArity() const { return 1; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
if (iIndex == 0) return VALUE_EXPRTYPE;
return UNKNOWN_EXPRTYPE;
}
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
std::string sChar = (*cursor)->getValue(visibility);
int returnValue = CGRuntime::charToInt(sChar);
char tcNumber[16];
sprintf(tcNumber, "%d", returnValue);
return tcNumber;
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppInt(theCompilerEnvironment);
return INT_TYPE;
}
virtual bool compileCppDouble(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "(double) ";
return compileCppInt(theCompilerEnvironment);
}
virtual bool compileCppString(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "CGRuntime::toString(";
bool bSuccess = compileCppInt(theCompilerEnvironment);
if (bSuccess) CW_BODY_STREAM << ")";
return bSuccess;
}
virtual bool compileCppInt(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "CGRuntime::charToInt(";
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
(*cursor)->compileCppString(theCompilerEnvironment);
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptCharToInt;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptCharToInt::_iCounter = 0;
class ExprScriptChmod : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptChmod() {
}
public:
virtual ~ExprScriptChmod() { }
virtual const char* getName() const { return "chmod"; }
virtual unsigned int getArity() const { return 2; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
if (iIndex == 0) return VALUE_EXPRTYPE;
if (iIndex == 1) return VALUE_EXPRTYPE;
return UNKNOWN_EXPRTYPE;
}
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
std::string sFilename = (*cursor)->getValue(visibility);
++cursor;
std::string sMode = (*cursor)->getValue(visibility);
bool returnValue = CGRuntime::chmod(sFilename, sMode);
return (returnValue ? "true" : "");
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppBoolean(theCompilerEnvironment, false);
return BOOL_TYPE;
}
virtual bool compileCppBoolean(CppCompilerEnvironment& theCompilerEnvironment, bool bNegative) const {
if (bNegative) CW_BODY_STREAM << "!";
CW_BODY_STREAM << "CGRuntime::chmod(";
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
(*cursor)->compileCppString(theCompilerEnvironment);
CW_BODY_STREAM << ", ";
++cursor;
(*cursor)->compileCppString(theCompilerEnvironment);
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptChmod;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptChmod::_iCounter = 0;
class ExprScriptCeil : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptCeil() {
}
public:
virtual ~ExprScriptCeil() { }
virtual const char* getName() const { return "ceil"; }
virtual unsigned int getArity() const { return 1; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
if (iIndex == 0) return VALUE_EXPRTYPE;
return UNKNOWN_EXPRTYPE;
}
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
std::string sNumber = (*cursor)->getValue(visibility);
double dNumber = atof(sNumber.c_str());
int returnValue = CGRuntime::ceil(dNumber);
char tcNumber[16];
sprintf(tcNumber, "%d", returnValue);
return tcNumber;
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppInt(theCompilerEnvironment);
return INT_TYPE;
}
virtual bool compileCppDouble(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "(double) ";
return compileCppInt(theCompilerEnvironment);
}
virtual bool compileCppString(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "CGRuntime::toString(";
bool bSuccess = compileCppInt(theCompilerEnvironment);
if (bSuccess) CW_BODY_STREAM << ")";
return bSuccess;
}
virtual bool compileCppInt(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "CGRuntime::ceil(";
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
(*cursor)->compileCppDouble(theCompilerEnvironment);
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptCeil;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptCeil::_iCounter = 0;
class ExprScriptCompareDate : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptCompareDate() {
}
public:
virtual ~ExprScriptCompareDate() { }
virtual const char* getName() const { return "compareDate"; }
virtual unsigned int getArity() const { return 2; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
if (iIndex == 0) return VALUE_EXPRTYPE;
if (iIndex == 1) return VALUE_EXPRTYPE;
return UNKNOWN_EXPRTYPE;
}
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
std::string sDate1 = (*cursor)->getValue(visibility);
++cursor;
std::string sDate2 = (*cursor)->getValue(visibility);
int returnValue = CGRuntime::compareDate(sDate1, sDate2);
char tcNumber[16];
sprintf(tcNumber, "%d", returnValue);
return tcNumber;
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppInt(theCompilerEnvironment);
return INT_TYPE;
}
virtual bool compileCppDouble(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "(double) ";
return compileCppInt(theCompilerEnvironment);
}
virtual bool compileCppString(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "CGRuntime::toString(";
bool bSuccess = compileCppInt(theCompilerEnvironment);
if (bSuccess) CW_BODY_STREAM << ")";
return bSuccess;
}
virtual bool compileCppInt(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "CGRuntime::compareDate(";
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
(*cursor)->compileCppString(theCompilerEnvironment);
CW_BODY_STREAM << ", ";
++cursor;
(*cursor)->compileCppString(theCompilerEnvironment);
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptCompareDate;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptCompareDate::_iCounter = 0;
class ExprScriptCompleteDate : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptCompleteDate() {
}
public:
virtual ~ExprScriptCompleteDate() { }
virtual const char* getName() const { return "completeDate"; }
virtual unsigned int getArity() const { return 2; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
if (iIndex == 0) return VALUE_EXPRTYPE;
if (iIndex == 1) return VALUE_EXPRTYPE;
return UNKNOWN_EXPRTYPE;
}
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
std::string sDate = (*cursor)->getValue(visibility);
++cursor;
std::string sFormat = (*cursor)->getValue(visibility);
std::string returnValue = CGRuntime::completeDate(sDate, sFormat);
return returnValue;
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppString(theCompilerEnvironment);
return STRING_TYPE;
}
virtual bool compileCppString(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "CGRuntime::completeDate(";
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
(*cursor)->compileCppString(theCompilerEnvironment);
CW_BODY_STREAM << ", ";
++cursor;
(*cursor)->compileCppString(theCompilerEnvironment);
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptCompleteDate;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptCompleteDate::_iCounter = 0;
class ExprScriptCompleteLeftSpaces : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptCompleteLeftSpaces() {
}
public:
virtual ~ExprScriptCompleteLeftSpaces() { }
virtual const char* getName() const { return "completeLeftSpaces"; }
virtual unsigned int getArity() const { return 2; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
if (iIndex == 0) return VALUE_EXPRTYPE;
if (iIndex == 1) return VALUE_EXPRTYPE;
return UNKNOWN_EXPRTYPE;
}
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
std::string sText = (*cursor)->getValue(visibility);
++cursor;
std::string sLength = (*cursor)->getValue(visibility);
int iLength = atoi(sLength.c_str());
std::string returnValue = CGRuntime::completeLeftSpaces(sText, iLength);
return returnValue;
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppString(theCompilerEnvironment);
return STRING_TYPE;
}
virtual bool compileCppString(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "CGRuntime::completeLeftSpaces(";
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
(*cursor)->compileCppString(theCompilerEnvironment);
CW_BODY_STREAM << ", ";
++cursor;
(*cursor)->compileCppInt(theCompilerEnvironment);
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptCompleteLeftSpaces;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptCompleteLeftSpaces::_iCounter = 0;
class ExprScriptCompleteRightSpaces : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptCompleteRightSpaces() {
}
public:
virtual ~ExprScriptCompleteRightSpaces() { }
virtual const char* getName() const { return "completeRightSpaces"; }
virtual unsigned int getArity() const { return 2; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
if (iIndex == 0) return VALUE_EXPRTYPE;
if (iIndex == 1) return VALUE_EXPRTYPE;
return UNKNOWN_EXPRTYPE;
}
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
std::string sText = (*cursor)->getValue(visibility);
++cursor;
std::string sLength = (*cursor)->getValue(visibility);
int iLength = atoi(sLength.c_str());
std::string returnValue = CGRuntime::completeRightSpaces(sText, iLength);
return returnValue;
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppString(theCompilerEnvironment);
return STRING_TYPE;
}
virtual bool compileCppString(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "CGRuntime::completeRightSpaces(";
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
(*cursor)->compileCppString(theCompilerEnvironment);
CW_BODY_STREAM << ", ";
++cursor;
(*cursor)->compileCppInt(theCompilerEnvironment);
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptCompleteRightSpaces;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptCompleteRightSpaces::_iCounter = 0;
class ExprScriptComposeAdaLikeString : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptComposeAdaLikeString() {
}
public:
virtual ~ExprScriptComposeAdaLikeString() { }
virtual const char* getName() const { return "composeAdaLikeString"; }
virtual unsigned int getArity() const { return 1; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
if (iIndex == 0) return VALUE_EXPRTYPE;
return UNKNOWN_EXPRTYPE;
}
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
std::string sText = (*cursor)->getValue(visibility);
std::string returnValue = CGRuntime::composeAdaLikeString(sText);
return returnValue;
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppString(theCompilerEnvironment);
return STRING_TYPE;
}
virtual bool compileCppString(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "CGRuntime::composeAdaLikeString(";
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
(*cursor)->compileCppString(theCompilerEnvironment);
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptComposeAdaLikeString;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptComposeAdaLikeString::_iCounter = 0;
class ExprScriptComposeCLikeString : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptComposeCLikeString() {
}
public:
virtual ~ExprScriptComposeCLikeString() { }
virtual const char* getName() const { return "composeCLikeString"; }
virtual unsigned int getArity() const { return 1; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
if (iIndex == 0) return VALUE_EXPRTYPE;
return UNKNOWN_EXPRTYPE;
}
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
std::string sText = (*cursor)->getValue(visibility);
std::string returnValue = CGRuntime::composeCLikeString(sText);
return returnValue;
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppString(theCompilerEnvironment);
return STRING_TYPE;
}
virtual bool compileCppString(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "CGRuntime::composeCLikeString(";
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
(*cursor)->compileCppString(theCompilerEnvironment);
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptComposeCLikeString;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptComposeCLikeString::_iCounter = 0;
class ExprScriptComposeHTMLLikeString : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptComposeHTMLLikeString() {
}
public:
virtual ~ExprScriptComposeHTMLLikeString() { }
virtual const char* getName() const { return "composeHTMLLikeString"; }
virtual unsigned int getArity() const { return 1; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
if (iIndex == 0) return VALUE_EXPRTYPE;
return UNKNOWN_EXPRTYPE;
}
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
std::string sText = (*cursor)->getValue(visibility);
std::string returnValue = CGRuntime::composeHTMLLikeString(sText);
return returnValue;
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppString(theCompilerEnvironment);
return STRING_TYPE;
}
virtual bool compileCppString(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "CGRuntime::composeHTMLLikeString(";
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
(*cursor)->compileCppString(theCompilerEnvironment);
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptComposeHTMLLikeString;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptComposeHTMLLikeString::_iCounter = 0;
class ExprScriptComposeSQLLikeString : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptComposeSQLLikeString() {
}
public:
virtual ~ExprScriptComposeSQLLikeString() { }
virtual const char* getName() const { return "composeSQLLikeString"; }
virtual unsigned int getArity() const { return 1; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
if (iIndex == 0) return VALUE_EXPRTYPE;
return UNKNOWN_EXPRTYPE;
}
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
std::string sText = (*cursor)->getValue(visibility);
std::string returnValue = CGRuntime::composeSQLLikeString(sText);
return returnValue;
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppString(theCompilerEnvironment);
return STRING_TYPE;
}
virtual bool compileCppString(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "CGRuntime::composeSQLLikeString(";
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
(*cursor)->compileCppString(theCompilerEnvironment);
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptComposeSQLLikeString;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptComposeSQLLikeString::_iCounter = 0;
class ExprScriptComputeMD5 : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptComputeMD5() {
}
public:
virtual ~ExprScriptComputeMD5() { }
virtual const char* getName() const { return "computeMD5"; }
virtual unsigned int getArity() const { return 1; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
if (iIndex == 0) return VALUE_EXPRTYPE;
return UNKNOWN_EXPRTYPE;
}
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
std::string sText = (*cursor)->getValue(visibility);
std::string returnValue = CGRuntime::computeMD5(sText);
return returnValue;
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppString(theCompilerEnvironment);
return STRING_TYPE;
}
virtual bool compileCppString(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "CGRuntime::computeMD5(";
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
(*cursor)->compileCppString(theCompilerEnvironment);
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptComputeMD5;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptComputeMD5::_iCounter = 0;
class ExprScriptCopySmartFile : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptCopySmartFile() {
}
public:
virtual ~ExprScriptCopySmartFile() { }
virtual const char* getName() const { return "copySmartFile"; }
virtual unsigned int getArity() const { return 2; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
if (iIndex == 0) return VALUE_EXPRTYPE;
if (iIndex == 1) return VALUE_EXPRTYPE;
return UNKNOWN_EXPRTYPE;
}
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
std::string sSourceFileName = (*cursor)->getValue(visibility);
++cursor;
std::string sDestinationFileName = (*cursor)->getValue(visibility);
bool returnValue = CGRuntime::copySmartFile(sSourceFileName, sDestinationFileName);
return (returnValue ? "true" : "");
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppBoolean(theCompilerEnvironment, false);
return BOOL_TYPE;
}
virtual bool compileCppBoolean(CppCompilerEnvironment& theCompilerEnvironment, bool bNegative) const {
if (bNegative) CW_BODY_STREAM << "!";
CW_BODY_STREAM << "CGRuntime::copySmartFile(";
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
(*cursor)->compileCppString(theCompilerEnvironment);
CW_BODY_STREAM << ", ";
++cursor;
(*cursor)->compileCppString(theCompilerEnvironment);
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptCopySmartFile;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptCopySmartFile::_iCounter = 0;
class ExprScriptCoreString : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptCoreString() {
}
public:
virtual ~ExprScriptCoreString() { }
virtual const char* getName() const { return "coreString"; }
virtual unsigned int getArity() const { return 3; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
if (iIndex == 0) return VALUE_EXPRTYPE;
if (iIndex == 1) return VALUE_EXPRTYPE;
if (iIndex == 2) return VALUE_EXPRTYPE;
return UNKNOWN_EXPRTYPE;
}
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
std::string sText = (*cursor)->getValue(visibility);
++cursor;
std::string sPos = (*cursor)->getValue(visibility);
int iPos = atoi(sPos.c_str());
++cursor;
std::string sLastRemoved = (*cursor)->getValue(visibility);
int iLastRemoved = atoi(sLastRemoved.c_str());
std::string returnValue = CGRuntime::coreString(sText, iPos, iLastRemoved);
return returnValue;
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppString(theCompilerEnvironment);
return STRING_TYPE;
}
virtual bool compileCppString(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "CGRuntime::coreString(";
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
(*cursor)->compileCppString(theCompilerEnvironment);
CW_BODY_STREAM << ", ";
++cursor;
(*cursor)->compileCppInt(theCompilerEnvironment);
CW_BODY_STREAM << ", ";
++cursor;
(*cursor)->compileCppInt(theCompilerEnvironment);
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptCoreString;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptCoreString::_iCounter = 0;
class ExprScriptCountStringOccurences : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptCountStringOccurences() {
}
public:
virtual ~ExprScriptCountStringOccurences() { }
virtual const char* getName() const { return "countStringOccurences"; }
virtual unsigned int getArity() const { return 2; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
if (iIndex == 0) return VALUE_EXPRTYPE;
if (iIndex == 1) return VALUE_EXPRTYPE;
return UNKNOWN_EXPRTYPE;
}
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
std::string sString = (*cursor)->getValue(visibility);
++cursor;
std::string sText = (*cursor)->getValue(visibility);
int returnValue = CGRuntime::countStringOccurences(sString, sText);
char tcNumber[16];
sprintf(tcNumber, "%d", returnValue);
return tcNumber;
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppInt(theCompilerEnvironment);
return INT_TYPE;
}
virtual bool compileCppDouble(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "(double) ";
return compileCppInt(theCompilerEnvironment);
}
virtual bool compileCppString(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "CGRuntime::toString(";
bool bSuccess = compileCppInt(theCompilerEnvironment);
if (bSuccess) CW_BODY_STREAM << ")";
return bSuccess;
}
virtual bool compileCppInt(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "CGRuntime::countStringOccurences(";
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
(*cursor)->compileCppString(theCompilerEnvironment);
CW_BODY_STREAM << ", ";
++cursor;
(*cursor)->compileCppString(theCompilerEnvironment);
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptCountStringOccurences;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptCountStringOccurences::_iCounter = 0;
class ExprScriptCreateDirectory : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptCreateDirectory() {
}
public:
virtual ~ExprScriptCreateDirectory() { }
virtual const char* getName() const { return "createDirectory"; }
virtual unsigned int getArity() const { return 1; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
if (iIndex == 0) return VALUE_EXPRTYPE;
return UNKNOWN_EXPRTYPE;
}
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
std::string sPath = (*cursor)->getValue(visibility);
bool returnValue = CGRuntime::createDirectory(sPath);
return (returnValue ? "true" : "");
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppBoolean(theCompilerEnvironment, false);
return BOOL_TYPE;
}
virtual bool compileCppBoolean(CppCompilerEnvironment& theCompilerEnvironment, bool bNegative) const {
if (bNegative) CW_BODY_STREAM << "!";
CW_BODY_STREAM << "CGRuntime::createDirectory(";
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
(*cursor)->compileCppString(theCompilerEnvironment);
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptCreateDirectory;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptCreateDirectory::_iCounter = 0;
class ExprScriptCreateINETClientSocket : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptCreateINETClientSocket() {
}
public:
virtual ~ExprScriptCreateINETClientSocket() { }
virtual const char* getName() const { return "createINETClientSocket"; }
virtual unsigned int getArity() const { return 2; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
if (iIndex == 0) return VALUE_EXPRTYPE;
if (iIndex == 1) return VALUE_EXPRTYPE;
return UNKNOWN_EXPRTYPE;
}
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
std::string sRemoteAddress = (*cursor)->getValue(visibility);
++cursor;
std::string sPort = (*cursor)->getValue(visibility);
int iPort = atoi(sPort.c_str());
int returnValue = CGRuntime::createINETClientSocket(sRemoteAddress, iPort);
char tcNumber[16];
sprintf(tcNumber, "%d", returnValue);
return tcNumber;
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppInt(theCompilerEnvironment);
return INT_TYPE;
}
virtual bool compileCppDouble(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "(double) ";
return compileCppInt(theCompilerEnvironment);
}
virtual bool compileCppString(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "CGRuntime::toString(";
bool bSuccess = compileCppInt(theCompilerEnvironment);
if (bSuccess) CW_BODY_STREAM << ")";
return bSuccess;
}
virtual bool compileCppInt(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "CGRuntime::createINETClientSocket(";
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
(*cursor)->compileCppString(theCompilerEnvironment);
CW_BODY_STREAM << ", ";
++cursor;
(*cursor)->compileCppInt(theCompilerEnvironment);
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptCreateINETClientSocket;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptCreateINETClientSocket::_iCounter = 0;
class ExprScriptCreateINETServerSocket : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptCreateINETServerSocket() {
}
public:
virtual ~ExprScriptCreateINETServerSocket() { }
virtual const char* getName() const { return "createINETServerSocket"; }
virtual unsigned int getArity() const { return 2; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
if (iIndex == 0) return VALUE_EXPRTYPE;
if (iIndex == 1) return VALUE_EXPRTYPE;
return UNKNOWN_EXPRTYPE;
}
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
std::string sPort = (*cursor)->getValue(visibility);
int iPort = atoi(sPort.c_str());
++cursor;
std::string sBackLog = (*cursor)->getValue(visibility);
int iBackLog = atoi(sBackLog.c_str());
int returnValue = CGRuntime::createINETServerSocket(iPort, iBackLog);
char tcNumber[16];
sprintf(tcNumber, "%d", returnValue);
return tcNumber;
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppInt(theCompilerEnvironment);
return INT_TYPE;
}
virtual bool compileCppDouble(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "(double) ";
return compileCppInt(theCompilerEnvironment);
}
virtual bool compileCppString(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "CGRuntime::toString(";
bool bSuccess = compileCppInt(theCompilerEnvironment);
if (bSuccess) CW_BODY_STREAM << ")";
return bSuccess;
}
virtual bool compileCppInt(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "CGRuntime::createINETServerSocket(";
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
(*cursor)->compileCppInt(theCompilerEnvironment);
CW_BODY_STREAM << ", ";
++cursor;
(*cursor)->compileCppInt(theCompilerEnvironment);
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptCreateINETServerSocket;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptCreateINETServerSocket::_iCounter = 0;
class ExprScriptCreateIterator : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptCreateIterator() {
}
public:
virtual ~ExprScriptCreateIterator() { }
virtual const char* getName() const { return "createIterator"; }
virtual unsigned int getArity() const { return 2; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
if (iIndex == 0) return ITERATOR_EXPRTYPE;
if (iIndex == 1) return NODE_EXPRTYPE;
return UNKNOWN_EXPRTYPE;
}
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
DtaScriptVariable* pI = visibility.getIterator(dynamic_cast<ExprScriptVariable*>(*cursor)->getName().c_str());
if (pI == NULL) pI = visibility.getVariable(*dynamic_cast<ExprScriptVariable*>(*cursor));
++cursor;
DtaScriptVariable* pList = visibility.getExistingVariable(*dynamic_cast<ExprScriptVariable*>(*cursor));
bool returnValue = CGRuntime::createIterator(pI, pList);
return (returnValue ? "true" : "");
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppBoolean(theCompilerEnvironment, false);
return BOOL_TYPE;
}
virtual bool compileCppBoolean(CppCompilerEnvironment& theCompilerEnvironment, bool bNegative) const {
if (bNegative) CW_BODY_STREAM << "!";
CW_BODY_STREAM << "CGRuntime::createIterator(";
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
(*cursor)->compileCpp(theCompilerEnvironment);
CW_BODY_STREAM << ", ";
++cursor;
(*cursor)->compileCpp(theCompilerEnvironment);
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptCreateIterator;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptCreateIterator::_iCounter = 0;
class ExprScriptCreateReverseIterator : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptCreateReverseIterator() {
}
public:
virtual ~ExprScriptCreateReverseIterator() { }
virtual const char* getName() const { return "createReverseIterator"; }
virtual unsigned int getArity() const { return 2; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
if (iIndex == 0) return ITERATOR_EXPRTYPE;
if (iIndex == 1) return NODE_EXPRTYPE;
return UNKNOWN_EXPRTYPE;
}
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
DtaScriptVariable* pI = visibility.getIterator(dynamic_cast<ExprScriptVariable*>(*cursor)->getName().c_str());
if (pI == NULL) pI = visibility.getVariable(*dynamic_cast<ExprScriptVariable*>(*cursor));
++cursor;
DtaScriptVariable* pList = visibility.getExistingVariable(*dynamic_cast<ExprScriptVariable*>(*cursor));
bool returnValue = CGRuntime::createReverseIterator(pI, pList);
return (returnValue ? "true" : "");
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppBoolean(theCompilerEnvironment, false);
return BOOL_TYPE;
}
virtual bool compileCppBoolean(CppCompilerEnvironment& theCompilerEnvironment, bool bNegative) const {
if (bNegative) CW_BODY_STREAM << "!";
CW_BODY_STREAM << "CGRuntime::createReverseIterator(";
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
(*cursor)->compileCpp(theCompilerEnvironment);
CW_BODY_STREAM << ", ";
++cursor;
(*cursor)->compileCpp(theCompilerEnvironment);
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptCreateReverseIterator;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptCreateReverseIterator::_iCounter = 0;
class ExprScriptCreateVirtualFile : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptCreateVirtualFile() {
}
public:
virtual ~ExprScriptCreateVirtualFile() { }
virtual const char* getName() const { return "createVirtualFile"; }
virtual unsigned int getArity() const { return 2; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
if (iIndex == 0) return VALUE_EXPRTYPE;
if (iIndex == 1) return VALUE_EXPRTYPE;
return UNKNOWN_EXPRTYPE;
}
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
std::string sHandle = (*cursor)->getValue(visibility);
++cursor;
std::string sContent = (*cursor)->getValue(visibility);
bool returnValue = CGRuntime::createVirtualFile(sHandle, sContent);
return (returnValue ? "true" : "");
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppBoolean(theCompilerEnvironment, false);
return BOOL_TYPE;
}
virtual bool compileCppBoolean(CppCompilerEnvironment& theCompilerEnvironment, bool bNegative) const {
if (bNegative) CW_BODY_STREAM << "!";
CW_BODY_STREAM << "CGRuntime::createVirtualFile(";
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
(*cursor)->compileCppString(theCompilerEnvironment);
CW_BODY_STREAM << ", ";
++cursor;
(*cursor)->compileCppString(theCompilerEnvironment);
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptCreateVirtualFile;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptCreateVirtualFile::_iCounter = 0;
class ExprScriptCreateVirtualTemporaryFile : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptCreateVirtualTemporaryFile() {
}
public:
virtual ~ExprScriptCreateVirtualTemporaryFile() { }
virtual const char* getName() const { return "createVirtualTemporaryFile"; }
virtual unsigned int getArity() const { return 1; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
if (iIndex == 0) return VALUE_EXPRTYPE;
return UNKNOWN_EXPRTYPE;
}
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
std::string sContent = (*cursor)->getValue(visibility);
std::string returnValue = CGRuntime::createVirtualTemporaryFile(sContent);
return returnValue;
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppString(theCompilerEnvironment);
return STRING_TYPE;
}
virtual bool compileCppString(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "CGRuntime::createVirtualTemporaryFile(";
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
(*cursor)->compileCppString(theCompilerEnvironment);
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptCreateVirtualTemporaryFile;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptCreateVirtualTemporaryFile::_iCounter = 0;
class ExprScriptDecodeURL : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptDecodeURL() {
}
public:
virtual ~ExprScriptDecodeURL() { }
virtual const char* getName() const { return "decodeURL"; }
virtual unsigned int getArity() const { return 1; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
if (iIndex == 0) return VALUE_EXPRTYPE;
return UNKNOWN_EXPRTYPE;
}
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
std::string sURL = (*cursor)->getValue(visibility);
std::string returnValue = CGRuntime::decodeURL(sURL);
return returnValue;
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppString(theCompilerEnvironment);
return STRING_TYPE;
}
virtual bool compileCppString(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "CGRuntime::decodeURL(";
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
(*cursor)->compileCppString(theCompilerEnvironment);
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptDecodeURL;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptDecodeURL::_iCounter = 0;
class ExprScriptDecrement : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptDecrement() {
}
public:
virtual ~ExprScriptDecrement() { }
virtual const char* getName() const { return "decrement"; }
virtual unsigned int getArity() const { return 1; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
if (iIndex == 0) return NODE_EXPRTYPE;
return UNKNOWN_EXPRTYPE;
}
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
DtaScriptVariable* pNumber = visibility.getVariable(*dynamic_cast<ExprScriptVariable*>(*cursor));
double dNumber = pNumber->getDoubleValue();
double returnValue = CGRuntime::decrement(dNumber);
pNumber->setValue(dNumber);
return CGRuntime::toString(returnValue);
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppDouble(theCompilerEnvironment);
return DOUBLE_TYPE;
}
virtual bool compileCppInt(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "(int) ";
return compileCppDouble(theCompilerEnvironment);
}
virtual bool compileCppString(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "CGRuntime::toString(";
bool bSuccess = compileCppDouble(theCompilerEnvironment);
if (bSuccess) CW_BODY_STREAM << ")";
return bSuccess;
}
virtual bool compileCppDouble(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "CGRuntime::decrement(";
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
dynamic_cast<ExprScriptVariable*>(*cursor)->compileCppForSet(theCompilerEnvironment);
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptDecrement;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptDecrement::_iCounter = 0;
class ExprScriptDeleteFile : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptDeleteFile() {
}
public:
virtual ~ExprScriptDeleteFile() { }
virtual const char* getName() const { return "deleteFile"; }
virtual unsigned int getArity() const { return 1; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
if (iIndex == 0) return VALUE_EXPRTYPE;
return UNKNOWN_EXPRTYPE;
}
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
std::string sFilename = (*cursor)->getValue(visibility);
bool returnValue = CGRuntime::deleteFile(sFilename);
return (returnValue ? "true" : "");
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppBoolean(theCompilerEnvironment, false);
return BOOL_TYPE;
}
virtual bool compileCppBoolean(CppCompilerEnvironment& theCompilerEnvironment, bool bNegative) const {
if (bNegative) CW_BODY_STREAM << "!";
CW_BODY_STREAM << "CGRuntime::deleteFile(";
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
(*cursor)->compileCppString(theCompilerEnvironment);
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptDeleteFile;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptDeleteFile::_iCounter = 0;
class ExprScriptDeleteVirtualFile : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptDeleteVirtualFile() {
}
public:
virtual ~ExprScriptDeleteVirtualFile() { }
virtual const char* getName() const { return "deleteVirtualFile"; }
virtual unsigned int getArity() const { return 1; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
if (iIndex == 0) return VALUE_EXPRTYPE;
return UNKNOWN_EXPRTYPE;
}
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
std::string sHandle = (*cursor)->getValue(visibility);
bool returnValue = CGRuntime::deleteVirtualFile(sHandle);
return (returnValue ? "true" : "");
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppBoolean(theCompilerEnvironment, false);
return BOOL_TYPE;
}
virtual bool compileCppBoolean(CppCompilerEnvironment& theCompilerEnvironment, bool bNegative) const {
if (bNegative) CW_BODY_STREAM << "!";
CW_BODY_STREAM << "CGRuntime::deleteVirtualFile(";
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
(*cursor)->compileCppString(theCompilerEnvironment);
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptDeleteVirtualFile;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptDeleteVirtualFile::_iCounter = 0;
class ExprScriptDiv : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptDiv() {
}
public:
virtual ~ExprScriptDiv() { }
virtual const char* getName() const { return "div"; }
virtual unsigned int getArity() const { return 2; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
if (iIndex == 0) return VALUE_EXPRTYPE;
if (iIndex == 1) return VALUE_EXPRTYPE;
return UNKNOWN_EXPRTYPE;
}
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
std::string sDividend = (*cursor)->getValue(visibility);
double dDividend = atof(sDividend.c_str());
++cursor;
std::string sDivisor = (*cursor)->getValue(visibility);
double dDivisor = atof(sDivisor.c_str());
double returnValue = CGRuntime::div(dDividend, dDivisor);
return CGRuntime::toString(returnValue);
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppDouble(theCompilerEnvironment);
return DOUBLE_TYPE;
}
virtual bool compileCppInt(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "(int) ";
return compileCppDouble(theCompilerEnvironment);
}
virtual bool compileCppString(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "CGRuntime::toString(";
bool bSuccess = compileCppDouble(theCompilerEnvironment);
if (bSuccess) CW_BODY_STREAM << ")";
return bSuccess;
}
virtual bool compileCppDouble(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "CGRuntime::div(";
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
(*cursor)->compileCppDouble(theCompilerEnvironment);
CW_BODY_STREAM << ", ";
++cursor;
(*cursor)->compileCppDouble(theCompilerEnvironment);
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptDiv;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptDiv::_iCounter = 0;
class ExprScriptDuplicateIterator : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptDuplicateIterator() {
}
public:
virtual ~ExprScriptDuplicateIterator() { }
virtual const char* getName() const { return "duplicateIterator"; }
virtual unsigned int getArity() const { return 2; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
if (iIndex == 0) return ITERATOR_EXPRTYPE;
if (iIndex == 1) return NODE_EXPRTYPE;
return UNKNOWN_EXPRTYPE;
}
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
DtaScriptVariable* pOldIt = visibility.getIterator(dynamic_cast<ExprScriptVariable*>(*cursor)->getName().c_str());
if (pOldIt == NULL) pOldIt = visibility.getVariable(*dynamic_cast<ExprScriptVariable*>(*cursor));
++cursor;
DtaScriptVariable* pNewIt = visibility.getExistingVariable(*dynamic_cast<ExprScriptVariable*>(*cursor));
bool returnValue = CGRuntime::duplicateIterator(pOldIt, pNewIt);
return (returnValue ? "true" : "");
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppBoolean(theCompilerEnvironment, false);
return BOOL_TYPE;
}
virtual bool compileCppBoolean(CppCompilerEnvironment& theCompilerEnvironment, bool bNegative) const {
if (bNegative) CW_BODY_STREAM << "!";
CW_BODY_STREAM << "CGRuntime::duplicateIterator(";
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
(*cursor)->compileCpp(theCompilerEnvironment);
CW_BODY_STREAM << ", ";
++cursor;
(*cursor)->compileCpp(theCompilerEnvironment);
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptDuplicateIterator;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptDuplicateIterator::_iCounter = 0;
class ExprScriptEncodeURL : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptEncodeURL() {
}
public:
virtual ~ExprScriptEncodeURL() { }
virtual const char* getName() const { return "encodeURL"; }
virtual unsigned int getArity() const { return 1; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
if (iIndex == 0) return VALUE_EXPRTYPE;
return UNKNOWN_EXPRTYPE;
}
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
std::string sURL = (*cursor)->getValue(visibility);
std::string returnValue = CGRuntime::encodeURL(sURL);
return returnValue;
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppString(theCompilerEnvironment);
return STRING_TYPE;
}
virtual bool compileCppString(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "CGRuntime::encodeURL(";
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
(*cursor)->compileCppString(theCompilerEnvironment);
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptEncodeURL;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptEncodeURL::_iCounter = 0;
class ExprScriptEndl : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptEndl() {
}
public:
virtual ~ExprScriptEndl() { }
virtual const char* getName() const { return "endl"; }
virtual unsigned int getArity() const { return 0; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
return UNKNOWN_EXPRTYPE;
}
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
std::string returnValue = CGRuntime::endl();
return returnValue;
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppString(theCompilerEnvironment);
return STRING_TYPE;
}
virtual bool compileCppString(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "CGRuntime::endl(";
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptEndl;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptEndl::_iCounter = 0;
class ExprScriptEndString : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptEndString() {
}
public:
virtual ~ExprScriptEndString() { }
virtual const char* getName() const { return "endString"; }
virtual unsigned int getArity() const { return 2; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
if (iIndex == 0) return VALUE_EXPRTYPE;
if (iIndex == 1) return VALUE_EXPRTYPE;
return UNKNOWN_EXPRTYPE;
}
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
std::string sText = (*cursor)->getValue(visibility);
++cursor;
std::string sEnd = (*cursor)->getValue(visibility);
bool returnValue = CGRuntime::endString(sText, sEnd);
return (returnValue ? "true" : "");
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppBoolean(theCompilerEnvironment, false);
return BOOL_TYPE;
}
virtual bool compileCppBoolean(CppCompilerEnvironment& theCompilerEnvironment, bool bNegative) const {
if (bNegative) CW_BODY_STREAM << "!";
CW_BODY_STREAM << "CGRuntime::endString(";
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
(*cursor)->compileCppString(theCompilerEnvironment);
CW_BODY_STREAM << ", ";
++cursor;
(*cursor)->compileCppString(theCompilerEnvironment);
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptEndString;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptEndString::_iCounter = 0;
class ExprScriptEqual : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptEqual() {
}
public:
virtual ~ExprScriptEqual() { }
virtual const char* getName() const { return "equal"; }
virtual unsigned int getArity() const { return 2; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
if (iIndex == 0) return VALUE_EXPRTYPE;
if (iIndex == 1) return VALUE_EXPRTYPE;
return UNKNOWN_EXPRTYPE;
}
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
std::string sLeft = (*cursor)->getValue(visibility);
double dLeft = atof(sLeft.c_str());
++cursor;
std::string sRight = (*cursor)->getValue(visibility);
double dRight = atof(sRight.c_str());
bool returnValue = CGRuntime::equal(dLeft, dRight);
return (returnValue ? "true" : "");
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppBoolean(theCompilerEnvironment, false);
return BOOL_TYPE;
}
virtual bool compileCppBoolean(CppCompilerEnvironment& theCompilerEnvironment, bool bNegative) const {
if (bNegative) CW_BODY_STREAM << "!";
CW_BODY_STREAM << "CGRuntime::equal(";
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
(*cursor)->compileCppDouble(theCompilerEnvironment);
CW_BODY_STREAM << ", ";
++cursor;
(*cursor)->compileCppDouble(theCompilerEnvironment);
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptEqual;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptEqual::_iCounter = 0;
class ExprScriptEqualsIgnoreCase : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptEqualsIgnoreCase() {
}
public:
virtual ~ExprScriptEqualsIgnoreCase() { }
virtual const char* getName() const { return "equalsIgnoreCase"; }
virtual unsigned int getArity() const { return 2; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
if (iIndex == 0) return VALUE_EXPRTYPE;
if (iIndex == 1) return VALUE_EXPRTYPE;
return UNKNOWN_EXPRTYPE;
}
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
std::string sLeft = (*cursor)->getValue(visibility);
++cursor;
std::string sRight = (*cursor)->getValue(visibility);
bool returnValue = CGRuntime::equalsIgnoreCase(sLeft, sRight);
return (returnValue ? "true" : "");
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppBoolean(theCompilerEnvironment, false);
return BOOL_TYPE;
}
virtual bool compileCppBoolean(CppCompilerEnvironment& theCompilerEnvironment, bool bNegative) const {
if (bNegative) CW_BODY_STREAM << "!";
CW_BODY_STREAM << "CGRuntime::equalsIgnoreCase(";
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
(*cursor)->compileCppString(theCompilerEnvironment);
CW_BODY_STREAM << ", ";
++cursor;
(*cursor)->compileCppString(theCompilerEnvironment);
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptEqualsIgnoreCase;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptEqualsIgnoreCase::_iCounter = 0;
class ExprScriptEqualTrees : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptEqualTrees() {
}
public:
virtual ~ExprScriptEqualTrees() { }
virtual const char* getName() const { return "equalTrees"; }
virtual unsigned int getArity() const { return 2; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
if (iIndex == 0) return NODE_EXPRTYPE;
if (iIndex == 1) return NODE_EXPRTYPE;
return UNKNOWN_EXPRTYPE;
}
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
DtaScriptVariable* pFirstTree = visibility.getExistingVariable(*dynamic_cast<ExprScriptVariable*>(*cursor));
++cursor;
DtaScriptVariable* pSecondTree = visibility.getExistingVariable(*dynamic_cast<ExprScriptVariable*>(*cursor));
bool returnValue = CGRuntime::equalTrees(pFirstTree, pSecondTree);
return (returnValue ? "true" : "");
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppBoolean(theCompilerEnvironment, false);
return BOOL_TYPE;
}
virtual bool compileCppBoolean(CppCompilerEnvironment& theCompilerEnvironment, bool bNegative) const {
if (bNegative) CW_BODY_STREAM << "!";
CW_BODY_STREAM << "CGRuntime::equalTrees(";
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
(*cursor)->compileCpp(theCompilerEnvironment);
CW_BODY_STREAM << ", ";
++cursor;
(*cursor)->compileCpp(theCompilerEnvironment);
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptEqualTrees;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptEqualTrees::_iCounter = 0;
class ExprScriptExecuteStringQuiet : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptExecuteStringQuiet() {
}
public:
virtual ~ExprScriptExecuteStringQuiet() { }
virtual const char* getName() const { return "executeStringQuiet"; }
virtual unsigned int getArity() const { return 2; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
if (iIndex == 0) return NODE_EXPRTYPE;
if (iIndex == 1) return VALUE_EXPRTYPE;
return UNKNOWN_EXPRTYPE;
}
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
DtaScriptVariable* pThis = visibility.getVariable(*dynamic_cast<ExprScriptVariable*>(*cursor));
++cursor;
std::string sCommand = (*cursor)->getValue(visibility);
std::string returnValue = CGRuntime::executeStringQuiet(pThis, sCommand);
return returnValue;
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppString(theCompilerEnvironment);
return STRING_TYPE;
}
virtual bool compileCppString(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "CGRuntime::executeStringQuiet(";
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
(*cursor)->compileCpp(theCompilerEnvironment);
CW_BODY_STREAM << ", ";
++cursor;
(*cursor)->compileCppString(theCompilerEnvironment);
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptExecuteStringQuiet;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptExecuteStringQuiet::_iCounter = 0;
class ExprScriptExistDirectory : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptExistDirectory() {
}
public:
virtual ~ExprScriptExistDirectory() { }
virtual const char* getName() const { return "existDirectory"; }
virtual unsigned int getArity() const { return 1; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
if (iIndex == 0) return VALUE_EXPRTYPE;
return UNKNOWN_EXPRTYPE;
}
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
std::string sPath = (*cursor)->getValue(visibility);
bool returnValue = CGRuntime::existDirectory(sPath);
return (returnValue ? "true" : "");
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppBoolean(theCompilerEnvironment, false);
return BOOL_TYPE;
}
virtual bool compileCppBoolean(CppCompilerEnvironment& theCompilerEnvironment, bool bNegative) const {
if (bNegative) CW_BODY_STREAM << "!";
CW_BODY_STREAM << "CGRuntime::existDirectory(";
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
(*cursor)->compileCppString(theCompilerEnvironment);
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptExistDirectory;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptExistDirectory::_iCounter = 0;
class ExprScriptExistEnv : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptExistEnv() {
}
public:
virtual ~ExprScriptExistEnv() { }
virtual const char* getName() const { return "existEnv"; }
virtual unsigned int getArity() const { return 1; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
if (iIndex == 0) return VALUE_EXPRTYPE;
return UNKNOWN_EXPRTYPE;
}
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
std::string sVariable = (*cursor)->getValue(visibility);
bool returnValue = CGRuntime::existEnv(sVariable);
return (returnValue ? "true" : "");
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppBoolean(theCompilerEnvironment, false);
return BOOL_TYPE;
}
virtual bool compileCppBoolean(CppCompilerEnvironment& theCompilerEnvironment, bool bNegative) const {
if (bNegative) CW_BODY_STREAM << "!";
CW_BODY_STREAM << "CGRuntime::existEnv(";
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
(*cursor)->compileCppString(theCompilerEnvironment);
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptExistEnv;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptExistEnv::_iCounter = 0;
class ExprScriptExistFile : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptExistFile() {
}
public:
virtual ~ExprScriptExistFile() { }
virtual const char* getName() const { return "existFile"; }
virtual unsigned int getArity() const { return 1; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
if (iIndex == 0) return VALUE_EXPRTYPE;
return UNKNOWN_EXPRTYPE;
}
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
std::string sFileName = (*cursor)->getValue(visibility);
bool returnValue = CGRuntime::existFile(sFileName);
return (returnValue ? "true" : "");
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppBoolean(theCompilerEnvironment, false);
return BOOL_TYPE;
}
virtual bool compileCppBoolean(CppCompilerEnvironment& theCompilerEnvironment, bool bNegative) const {
if (bNegative) CW_BODY_STREAM << "!";
CW_BODY_STREAM << "CGRuntime::existFile(";
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
(*cursor)->compileCppString(theCompilerEnvironment);
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptExistFile;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptExistFile::_iCounter = 0;
class ExprScriptExistVirtualFile : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptExistVirtualFile() {
}
public:
virtual ~ExprScriptExistVirtualFile() { }
virtual const char* getName() const { return "existVirtualFile"; }
virtual unsigned int getArity() const { return 1; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
if (iIndex == 0) return VALUE_EXPRTYPE;
return UNKNOWN_EXPRTYPE;
}
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
std::string sHandle = (*cursor)->getValue(visibility);
bool returnValue = CGRuntime::existVirtualFile(sHandle);
return (returnValue ? "true" : "");
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppBoolean(theCompilerEnvironment, false);
return BOOL_TYPE;
}
virtual bool compileCppBoolean(CppCompilerEnvironment& theCompilerEnvironment, bool bNegative) const {
if (bNegative) CW_BODY_STREAM << "!";
CW_BODY_STREAM << "CGRuntime::existVirtualFile(";
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
(*cursor)->compileCppString(theCompilerEnvironment);
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptExistVirtualFile;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptExistVirtualFile::_iCounter = 0;
class ExprScriptExistVariable : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptExistVariable() {
}
public:
virtual ~ExprScriptExistVariable() { }
virtual const char* getName() const { return "existVariable"; }
virtual unsigned int getArity() const { return 1; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
if (iIndex == 0) return NODE_EXPRTYPE;
return UNKNOWN_EXPRTYPE;
}
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
DtaScriptVariable* pVariable = visibility.getNoWarningExistingVariable(*dynamic_cast<ExprScriptVariable*>(*cursor));
bool returnValue = CGRuntime::existVariable(pVariable);
return (returnValue ? "true" : "");
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppBoolean(theCompilerEnvironment, false);
return BOOL_TYPE;
}
virtual bool compileCppBoolean(CppCompilerEnvironment& theCompilerEnvironment, bool bNegative) const {
if (bNegative) CW_BODY_STREAM << "!";
CW_BODY_STREAM << "CGRuntime::existVariable(";
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
(*cursor)->compileCpp(theCompilerEnvironment);
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptExistVariable;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptExistVariable::_iCounter = 0;
class ExprScriptExp : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptExp() {
}
public:
virtual ~ExprScriptExp() { }
virtual const char* getName() const { return "exp"; }
virtual unsigned int getArity() const { return 1; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
if (iIndex == 0) return VALUE_EXPRTYPE;
return UNKNOWN_EXPRTYPE;
}
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
std::string sX = (*cursor)->getValue(visibility);
double dX = atof(sX.c_str());
double returnValue = CGRuntime::exp(dX);
return CGRuntime::toString(returnValue);
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppDouble(theCompilerEnvironment);
return DOUBLE_TYPE;
}
virtual bool compileCppInt(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "(int) ";
return compileCppDouble(theCompilerEnvironment);
}
virtual bool compileCppString(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "CGRuntime::toString(";
bool bSuccess = compileCppDouble(theCompilerEnvironment);
if (bSuccess) CW_BODY_STREAM << ")";
return bSuccess;
}
virtual bool compileCppDouble(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "CGRuntime::exp(";
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
(*cursor)->compileCppDouble(theCompilerEnvironment);
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptExp;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptExp::_iCounter = 0;
class ExprScriptExploreDirectory : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptExploreDirectory() {
}
public:
virtual ~ExprScriptExploreDirectory() { }
virtual const char* getName() const { return "exploreDirectory"; }
virtual unsigned int getArity() const { return 3; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
if (iIndex == 0) return NODE_EXPRTYPE;
if (iIndex == 1) return VALUE_EXPRTYPE;
if (iIndex == 2) return VALUE_EXPRTYPE;
return UNKNOWN_EXPRTYPE;
}
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
DtaScriptVariable* pDirectory = visibility.getVariable(*dynamic_cast<ExprScriptVariable*>(*cursor));
++cursor;
std::string sPath = (*cursor)->getValue(visibility);
++cursor;
std::string sSubfolders = (*cursor)->getValue(visibility);
bool bSubfolders = !sSubfolders.empty();
bool returnValue = CGRuntime::exploreDirectory(pDirectory, sPath, bSubfolders);
return (returnValue ? "true" : "");
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppBoolean(theCompilerEnvironment, false);
return BOOL_TYPE;
}
virtual bool compileCppBoolean(CppCompilerEnvironment& theCompilerEnvironment, bool bNegative) const {
if (bNegative) CW_BODY_STREAM << "!";
CW_BODY_STREAM << "CGRuntime::exploreDirectory(";
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
(*cursor)->compileCpp(theCompilerEnvironment);
CW_BODY_STREAM << ", ";
++cursor;
(*cursor)->compileCppString(theCompilerEnvironment);
CW_BODY_STREAM << ", ";
++cursor;
(*cursor)->compileCppBoolean(theCompilerEnvironment, false);
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptExploreDirectory;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptExploreDirectory::_iCounter = 0;
class ExprScriptExtractGenerationHeader : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptExtractGenerationHeader() {
}
public:
virtual ~ExprScriptExtractGenerationHeader() { }
virtual const char* getName() const { return "extractGenerationHeader"; }
virtual unsigned int getArity() const { return 4; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
if (iIndex == 0) return VALUE_EXPRTYPE;
if (iIndex == 1) return NODE_EXPRTYPE;
if (iIndex == 2) return NODE_EXPRTYPE;
if (iIndex == 3) return NODE_EXPRTYPE;
return UNKNOWN_EXPRTYPE;
}
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
std::string sFilename = (*cursor)->getValue(visibility);
++cursor;
DtaScriptVariable* pGenerator = visibility.getVariable(*dynamic_cast<ExprScriptVariable*>(*cursor));
std::string sGenerator;
const char* tsGenerator = pGenerator->getValue();
if (tsGenerator != NULL) sGenerator = tsGenerator;
++cursor;
DtaScriptVariable* pVersion = visibility.getVariable(*dynamic_cast<ExprScriptVariable*>(*cursor));
std::string sVersion;
const char* tsVersion = pVersion->getValue();
if (tsVersion != NULL) sVersion = tsVersion;
++cursor;
DtaScriptVariable* pDate = visibility.getVariable(*dynamic_cast<ExprScriptVariable*>(*cursor));
std::string sDate;
const char* tsDate = pDate->getValue();
if (tsDate != NULL) sDate = tsDate;
std::string returnValue = CGRuntime::extractGenerationHeader(sFilename, sGenerator, sVersion, sDate);
pGenerator->setValue(sGenerator.c_str());
pVersion->setValue(sVersion.c_str());
pDate->setValue(sDate.c_str());
return returnValue;
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppString(theCompilerEnvironment);
return STRING_TYPE;
}
virtual bool compileCppString(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "CGRuntime::extractGenerationHeader(";
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
(*cursor)->compileCppString(theCompilerEnvironment);
CW_BODY_STREAM << ", ";
++cursor;
dynamic_cast<ExprScriptVariable*>(*cursor)->compileCppForSet(theCompilerEnvironment);
CW_BODY_STREAM << ", ";
++cursor;
dynamic_cast<ExprScriptVariable*>(*cursor)->compileCppForSet(theCompilerEnvironment);
CW_BODY_STREAM << ", ";
++cursor;
dynamic_cast<ExprScriptVariable*>(*cursor)->compileCppForSet(theCompilerEnvironment);
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptExtractGenerationHeader;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptExtractGenerationHeader::_iCounter = 0;
class ExprScriptFileCreation : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptFileCreation() {
}
public:
virtual ~ExprScriptFileCreation() { }
virtual const char* getName() const { return "fileCreation"; }
virtual unsigned int getArity() const { return 1; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
if (iIndex == 0) return VALUE_EXPRTYPE;
return UNKNOWN_EXPRTYPE;
}
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
std::string sFilename = (*cursor)->getValue(visibility);
std::string returnValue = CGRuntime::fileCreation(sFilename);
return returnValue;
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppString(theCompilerEnvironment);
return STRING_TYPE;
}
virtual bool compileCppString(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "CGRuntime::fileCreation(";
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
(*cursor)->compileCppString(theCompilerEnvironment);
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptFileCreation;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptFileCreation::_iCounter = 0;
class ExprScriptFileLastAccess : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptFileLastAccess() {
}
public:
virtual ~ExprScriptFileLastAccess() { }
virtual const char* getName() const { return "fileLastAccess"; }
virtual unsigned int getArity() const { return 1; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
if (iIndex == 0) return VALUE_EXPRTYPE;
return UNKNOWN_EXPRTYPE;
}
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
std::string sFilename = (*cursor)->getValue(visibility);
std::string returnValue = CGRuntime::fileLastAccess(sFilename);
return returnValue;
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppString(theCompilerEnvironment);
return STRING_TYPE;
}
virtual bool compileCppString(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "CGRuntime::fileLastAccess(";
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
(*cursor)->compileCppString(theCompilerEnvironment);
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptFileLastAccess;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptFileLastAccess::_iCounter = 0;
class ExprScriptFileLastModification : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptFileLastModification() {
}
public:
virtual ~ExprScriptFileLastModification() { }
virtual const char* getName() const { return "fileLastModification"; }
virtual unsigned int getArity() const { return 1; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
if (iIndex == 0) return VALUE_EXPRTYPE;
return UNKNOWN_EXPRTYPE;
}
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
std::string sFilename = (*cursor)->getValue(visibility);
std::string returnValue = CGRuntime::fileLastModification(sFilename);
return returnValue;
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppString(theCompilerEnvironment);
return STRING_TYPE;
}
virtual bool compileCppString(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "CGRuntime::fileLastModification(";
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
(*cursor)->compileCppString(theCompilerEnvironment);
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptFileLastModification;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptFileLastModification::_iCounter = 0;
class ExprScriptFileLines : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptFileLines() {
}
public:
virtual ~ExprScriptFileLines() { }
virtual const char* getName() const { return "fileLines"; }
virtual unsigned int getArity() const { return 1; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
if (iIndex == 0) return VALUE_EXPRTYPE;
return UNKNOWN_EXPRTYPE;
}
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
std::string sFilename = (*cursor)->getValue(visibility);
int returnValue = CGRuntime::fileLines(sFilename);
char tcNumber[16];
sprintf(tcNumber, "%d", returnValue);
return tcNumber;
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppInt(theCompilerEnvironment);
return INT_TYPE;
}
virtual bool compileCppDouble(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "(double) ";
return compileCppInt(theCompilerEnvironment);
}
virtual bool compileCppString(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "CGRuntime::toString(";
bool bSuccess = compileCppInt(theCompilerEnvironment);
if (bSuccess) CW_BODY_STREAM << ")";
return bSuccess;
}
virtual bool compileCppInt(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "CGRuntime::fileLines(";
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
(*cursor)->compileCppString(theCompilerEnvironment);
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptFileLines;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptFileLines::_iCounter = 0;
class ExprScriptFileMode : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptFileMode() {
}
public:
virtual ~ExprScriptFileMode() { }
virtual const char* getName() const { return "fileMode"; }
virtual unsigned int getArity() const { return 1; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
if (iIndex == 0) return VALUE_EXPRTYPE;
return UNKNOWN_EXPRTYPE;
}
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
std::string sFilename = (*cursor)->getValue(visibility);
std::string returnValue = CGRuntime::fileMode(sFilename);
return returnValue;
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppString(theCompilerEnvironment);
return STRING_TYPE;
}
virtual bool compileCppString(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "CGRuntime::fileMode(";
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
(*cursor)->compileCppString(theCompilerEnvironment);
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptFileMode;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptFileMode::_iCounter = 0;
class ExprScriptFileSize : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptFileSize() {
}
public:
virtual ~ExprScriptFileSize() { }
virtual const char* getName() const { return "fileSize"; }
virtual unsigned int getArity() const { return 1; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
if (iIndex == 0) return VALUE_EXPRTYPE;
return UNKNOWN_EXPRTYPE;
}
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
std::string sFilename = (*cursor)->getValue(visibility);
int returnValue = CGRuntime::fileSize(sFilename);
char tcNumber[16];
sprintf(tcNumber, "%d", returnValue);
return tcNumber;
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppInt(theCompilerEnvironment);
return INT_TYPE;
}
virtual bool compileCppDouble(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "(double) ";
return compileCppInt(theCompilerEnvironment);
}
virtual bool compileCppString(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "CGRuntime::toString(";
bool bSuccess = compileCppInt(theCompilerEnvironment);
if (bSuccess) CW_BODY_STREAM << ")";
return bSuccess;
}
virtual bool compileCppInt(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "CGRuntime::fileSize(";
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
(*cursor)->compileCppString(theCompilerEnvironment);
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptFileSize;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptFileSize::_iCounter = 0;
class ExprScriptFindElement : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptFindElement() {
}
public:
virtual ~ExprScriptFindElement() { }
virtual const char* getName() const { return "findElement"; }
virtual unsigned int getArity() const { return 2; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
if (iIndex == 0) return VALUE_EXPRTYPE;
if (iIndex == 1) return NODE_EXPRTYPE;
return UNKNOWN_EXPRTYPE;
}
virtual int getThisPosition() const { return 1; }
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
std::string sValue = (*cursor)->getValue(visibility);
++cursor;
DtaScriptVariable* pVariable = visibility.getExistingVariable(*dynamic_cast<ExprScriptVariable*>(*cursor));
bool returnValue = CGRuntime::findElement(sValue, pVariable);
return (returnValue ? "true" : "");
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppBoolean(theCompilerEnvironment, false);
return BOOL_TYPE;
}
virtual bool compileCppBoolean(CppCompilerEnvironment& theCompilerEnvironment, bool bNegative) const {
if (bNegative) CW_BODY_STREAM << "!";
CW_BODY_STREAM << "CGRuntime::findElement(";
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
(*cursor)->compileCppString(theCompilerEnvironment);
CW_BODY_STREAM << ", ";
++cursor;
(*cursor)->compileCpp(theCompilerEnvironment);
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptFindElement;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptFindElement::_iCounter = 0;
class ExprScriptFindFirstChar : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptFindFirstChar() {
}
public:
virtual ~ExprScriptFindFirstChar() { }
virtual const char* getName() const { return "findFirstChar"; }
virtual unsigned int getArity() const { return 2; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
if (iIndex == 0) return VALUE_EXPRTYPE;
if (iIndex == 1) return VALUE_EXPRTYPE;
return UNKNOWN_EXPRTYPE;
}
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
std::string sText = (*cursor)->getValue(visibility);
++cursor;
std::string sSomeChars = (*cursor)->getValue(visibility);
int returnValue = CGRuntime::findFirstChar(sText, sSomeChars);
char tcNumber[16];
sprintf(tcNumber, "%d", returnValue);
return tcNumber;
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppInt(theCompilerEnvironment);
return INT_TYPE;
}
virtual bool compileCppDouble(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "(double) ";
return compileCppInt(theCompilerEnvironment);
}
virtual bool compileCppString(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "CGRuntime::toString(";
bool bSuccess = compileCppInt(theCompilerEnvironment);
if (bSuccess) CW_BODY_STREAM << ")";
return bSuccess;
}
virtual bool compileCppInt(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "CGRuntime::findFirstChar(";
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
(*cursor)->compileCppString(theCompilerEnvironment);
CW_BODY_STREAM << ", ";
++cursor;
(*cursor)->compileCppString(theCompilerEnvironment);
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptFindFirstChar;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptFindFirstChar::_iCounter = 0;
class ExprScriptFindFirstSubstringIntoKeys : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptFindFirstSubstringIntoKeys() {
}
public:
virtual ~ExprScriptFindFirstSubstringIntoKeys() { }
virtual const char* getName() const { return "findFirstSubstringIntoKeys"; }
virtual unsigned int getArity() const { return 2; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
if (iIndex == 0) return VALUE_EXPRTYPE;
if (iIndex == 1) return NODE_EXPRTYPE;
return UNKNOWN_EXPRTYPE;
}
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
std::string sSubstring = (*cursor)->getValue(visibility);
++cursor;
DtaScriptVariable* pArray = visibility.getExistingVariable(*dynamic_cast<ExprScriptVariable*>(*cursor));
int returnValue = CGRuntime::findFirstSubstringIntoKeys(sSubstring, pArray);
char tcNumber[16];
sprintf(tcNumber, "%d", returnValue);
return tcNumber;
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppInt(theCompilerEnvironment);
return INT_TYPE;
}
virtual bool compileCppDouble(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "(double) ";
return compileCppInt(theCompilerEnvironment);
}
virtual bool compileCppString(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "CGRuntime::toString(";
bool bSuccess = compileCppInt(theCompilerEnvironment);
if (bSuccess) CW_BODY_STREAM << ")";
return bSuccess;
}
virtual bool compileCppInt(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "CGRuntime::findFirstSubstringIntoKeys(";
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
(*cursor)->compileCppString(theCompilerEnvironment);
CW_BODY_STREAM << ", ";
++cursor;
(*cursor)->compileCpp(theCompilerEnvironment);
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptFindFirstSubstringIntoKeys;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptFindFirstSubstringIntoKeys::_iCounter = 0;
class ExprScriptFindLastString : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptFindLastString() {
}
public:
virtual ~ExprScriptFindLastString() { }
virtual const char* getName() const { return "findLastString"; }
virtual unsigned int getArity() const { return 2; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
if (iIndex == 0) return VALUE_EXPRTYPE;
if (iIndex == 1) return VALUE_EXPRTYPE;
return UNKNOWN_EXPRTYPE;
}
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
std::string sText = (*cursor)->getValue(visibility);
++cursor;
std::string sFind = (*cursor)->getValue(visibility);
int returnValue = CGRuntime::findLastString(sText, sFind);
char tcNumber[16];
sprintf(tcNumber, "%d", returnValue);
return tcNumber;
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppInt(theCompilerEnvironment);
return INT_TYPE;
}
virtual bool compileCppDouble(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "(double) ";
return compileCppInt(theCompilerEnvironment);
}
virtual bool compileCppString(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "CGRuntime::toString(";
bool bSuccess = compileCppInt(theCompilerEnvironment);
if (bSuccess) CW_BODY_STREAM << ")";
return bSuccess;
}
virtual bool compileCppInt(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "CGRuntime::findLastString(";
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
(*cursor)->compileCppString(theCompilerEnvironment);
CW_BODY_STREAM << ", ";
++cursor;
(*cursor)->compileCppString(theCompilerEnvironment);
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptFindLastString;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptFindLastString::_iCounter = 0;
class ExprScriptFindNextString : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptFindNextString() {
}
public:
virtual ~ExprScriptFindNextString() { }
virtual const char* getName() const { return "findNextString"; }
virtual unsigned int getArity() const { return 3; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
if (iIndex == 0) return VALUE_EXPRTYPE;
if (iIndex == 1) return VALUE_EXPRTYPE;
if (iIndex == 2) return VALUE_EXPRTYPE;
return UNKNOWN_EXPRTYPE;
}
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
std::string sText = (*cursor)->getValue(visibility);
++cursor;
std::string sFind = (*cursor)->getValue(visibility);
++cursor;
std::string sPosition = (*cursor)->getValue(visibility);
int iPosition = atoi(sPosition.c_str());
int returnValue = CGRuntime::findNextString(sText, sFind, iPosition);
char tcNumber[16];
sprintf(tcNumber, "%d", returnValue);
return tcNumber;
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppInt(theCompilerEnvironment);
return INT_TYPE;
}
virtual bool compileCppDouble(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "(double) ";
return compileCppInt(theCompilerEnvironment);
}
virtual bool compileCppString(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "CGRuntime::toString(";
bool bSuccess = compileCppInt(theCompilerEnvironment);
if (bSuccess) CW_BODY_STREAM << ")";
return bSuccess;
}
virtual bool compileCppInt(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "CGRuntime::findNextString(";
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
(*cursor)->compileCppString(theCompilerEnvironment);
CW_BODY_STREAM << ", ";
++cursor;
(*cursor)->compileCppString(theCompilerEnvironment);
CW_BODY_STREAM << ", ";
++cursor;
(*cursor)->compileCppInt(theCompilerEnvironment);
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptFindNextString;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptFindNextString::_iCounter = 0;
class ExprScriptFindNextSubstringIntoKeys : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptFindNextSubstringIntoKeys() {
}
public:
virtual ~ExprScriptFindNextSubstringIntoKeys() { }
virtual const char* getName() const { return "findNextSubstringIntoKeys"; }
virtual unsigned int getArity() const { return 3; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
if (iIndex == 0) return VALUE_EXPRTYPE;
if (iIndex == 1) return NODE_EXPRTYPE;
if (iIndex == 2) return VALUE_EXPRTYPE;
return UNKNOWN_EXPRTYPE;
}
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
std::string sSubstring = (*cursor)->getValue(visibility);
++cursor;
DtaScriptVariable* pArray = visibility.getExistingVariable(*dynamic_cast<ExprScriptVariable*>(*cursor));
++cursor;
std::string sNext = (*cursor)->getValue(visibility);
int iNext = atoi(sNext.c_str());
int returnValue = CGRuntime::findNextSubstringIntoKeys(sSubstring, pArray, iNext);
char tcNumber[16];
sprintf(tcNumber, "%d", returnValue);
return tcNumber;
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppInt(theCompilerEnvironment);
return INT_TYPE;
}
virtual bool compileCppDouble(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "(double) ";
return compileCppInt(theCompilerEnvironment);
}
virtual bool compileCppString(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "CGRuntime::toString(";
bool bSuccess = compileCppInt(theCompilerEnvironment);
if (bSuccess) CW_BODY_STREAM << ")";
return bSuccess;
}
virtual bool compileCppInt(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "CGRuntime::findNextSubstringIntoKeys(";
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
(*cursor)->compileCppString(theCompilerEnvironment);
CW_BODY_STREAM << ", ";
++cursor;
(*cursor)->compileCpp(theCompilerEnvironment);
CW_BODY_STREAM << ", ";
++cursor;
(*cursor)->compileCppInt(theCompilerEnvironment);
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptFindNextSubstringIntoKeys;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptFindNextSubstringIntoKeys::_iCounter = 0;
class ExprScriptFindString : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptFindString() {
}
public:
virtual ~ExprScriptFindString() { }
virtual const char* getName() const { return "findString"; }
virtual unsigned int getArity() const { return 2; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
if (iIndex == 0) return VALUE_EXPRTYPE;
if (iIndex == 1) return VALUE_EXPRTYPE;
return UNKNOWN_EXPRTYPE;
}
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
std::string sText = (*cursor)->getValue(visibility);
++cursor;
std::string sFind = (*cursor)->getValue(visibility);
int returnValue = CGRuntime::findString(sText, sFind);
char tcNumber[16];
sprintf(tcNumber, "%d", returnValue);
return tcNumber;
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppInt(theCompilerEnvironment);
return INT_TYPE;
}
virtual bool compileCppDouble(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "(double) ";
return compileCppInt(theCompilerEnvironment);
}
virtual bool compileCppString(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "CGRuntime::toString(";
bool bSuccess = compileCppInt(theCompilerEnvironment);
if (bSuccess) CW_BODY_STREAM << ")";
return bSuccess;
}
virtual bool compileCppInt(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "CGRuntime::findString(";
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
(*cursor)->compileCppString(theCompilerEnvironment);
CW_BODY_STREAM << ", ";
++cursor;
(*cursor)->compileCppString(theCompilerEnvironment);
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptFindString;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptFindString::_iCounter = 0;
class ExprScriptFloor : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptFloor() {
}
public:
virtual ~ExprScriptFloor() { }
virtual const char* getName() const { return "floor"; }
virtual unsigned int getArity() const { return 1; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
if (iIndex == 0) return VALUE_EXPRTYPE;
return UNKNOWN_EXPRTYPE;
}
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
std::string sNumber = (*cursor)->getValue(visibility);
double dNumber = atof(sNumber.c_str());
int returnValue = CGRuntime::floor(dNumber);
char tcNumber[16];
sprintf(tcNumber, "%d", returnValue);
return tcNumber;
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppInt(theCompilerEnvironment);
return INT_TYPE;
}
virtual bool compileCppDouble(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "(double) ";
return compileCppInt(theCompilerEnvironment);
}
virtual bool compileCppString(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "CGRuntime::toString(";
bool bSuccess = compileCppInt(theCompilerEnvironment);
if (bSuccess) CW_BODY_STREAM << ")";
return bSuccess;
}
virtual bool compileCppInt(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "CGRuntime::floor(";
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
(*cursor)->compileCppDouble(theCompilerEnvironment);
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptFloor;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptFloor::_iCounter = 0;
class ExprScriptFormatDate : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptFormatDate() {
}
public:
virtual ~ExprScriptFormatDate() { }
virtual const char* getName() const { return "formatDate"; }
virtual unsigned int getArity() const { return 2; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
if (iIndex == 0) return VALUE_EXPRTYPE;
if (iIndex == 1) return VALUE_EXPRTYPE;
return UNKNOWN_EXPRTYPE;
}
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
std::string sDate = (*cursor)->getValue(visibility);
++cursor;
std::string sFormat = (*cursor)->getValue(visibility);
std::string returnValue = CGRuntime::formatDate(sDate, sFormat);
return returnValue;
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppString(theCompilerEnvironment);
return STRING_TYPE;
}
virtual bool compileCppString(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "CGRuntime::formatDate(";
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
(*cursor)->compileCppString(theCompilerEnvironment);
CW_BODY_STREAM << ", ";
++cursor;
(*cursor)->compileCppString(theCompilerEnvironment);
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptFormatDate;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptFormatDate::_iCounter = 0;
class ExprScriptGetArraySize : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptGetArraySize() {
}
public:
virtual ~ExprScriptGetArraySize() { }
virtual const char* getName() const { return "getArraySize"; }
virtual unsigned int getArity() const { return 1; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
if (iIndex == 0) return NODE_EXPRTYPE;
return UNKNOWN_EXPRTYPE;
}
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
DtaScriptVariable* pVariable = visibility.getExistingVariable(*dynamic_cast<ExprScriptVariable*>(*cursor));
int returnValue = CGRuntime::getArraySize(pVariable);
char tcNumber[16];
sprintf(tcNumber, "%d", returnValue);
return tcNumber;
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppInt(theCompilerEnvironment);
return INT_TYPE;
}
virtual bool compileCppDouble(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "(double) ";
return compileCppInt(theCompilerEnvironment);
}
virtual bool compileCppString(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "CGRuntime::toString(";
bool bSuccess = compileCppInt(theCompilerEnvironment);
if (bSuccess) CW_BODY_STREAM << ")";
return bSuccess;
}
virtual bool compileCppInt(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "CGRuntime::getArraySize(";
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
(*cursor)->compileCpp(theCompilerEnvironment);
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptGetArraySize;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptGetArraySize::_iCounter = 0;
class ExprScriptGetCommentBegin : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptGetCommentBegin() {
}
public:
virtual ~ExprScriptGetCommentBegin() { }
virtual const char* getName() const { return "getCommentBegin"; }
virtual unsigned int getArity() const { return 0; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
return UNKNOWN_EXPRTYPE;
}
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
std::string returnValue = CGRuntime::getCommentBegin();
return returnValue;
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppString(theCompilerEnvironment);
return STRING_TYPE;
}
virtual bool compileCppString(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "CGRuntime::getCommentBegin(";
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptGetCommentBegin;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptGetCommentBegin::_iCounter = 0;
class ExprScriptGetCommentEnd : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptGetCommentEnd() {
}
public:
virtual ~ExprScriptGetCommentEnd() { }
virtual const char* getName() const { return "getCommentEnd"; }
virtual unsigned int getArity() const { return 0; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
return UNKNOWN_EXPRTYPE;
}
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
std::string returnValue = CGRuntime::getCommentEnd();
return returnValue;
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppString(theCompilerEnvironment);
return STRING_TYPE;
}
virtual bool compileCppString(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "CGRuntime::getCommentEnd(";
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptGetCommentEnd;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptGetCommentEnd::_iCounter = 0;
class ExprScriptGetCurrentDirectory : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptGetCurrentDirectory() {
}
public:
virtual ~ExprScriptGetCurrentDirectory() { }
virtual const char* getName() const { return "getCurrentDirectory"; }
virtual unsigned int getArity() const { return 0; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
return UNKNOWN_EXPRTYPE;
}
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
std::string returnValue = CGRuntime::getCurrentDirectory();
return returnValue;
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppString(theCompilerEnvironment);
return STRING_TYPE;
}
virtual bool compileCppString(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "CGRuntime::getCurrentDirectory(";
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptGetCurrentDirectory;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptGetCurrentDirectory::_iCounter = 0;
class ExprScriptGetEnv : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptGetEnv() {
}
public:
virtual ~ExprScriptGetEnv() { }
virtual const char* getName() const { return "getEnv"; }
virtual unsigned int getArity() const { return 1; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
if (iIndex == 0) return VALUE_EXPRTYPE;
return UNKNOWN_EXPRTYPE;
}
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
std::string sVariable = (*cursor)->getValue(visibility);
std::string returnValue = CGRuntime::getEnv(sVariable);
return returnValue;
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppString(theCompilerEnvironment);
return STRING_TYPE;
}
virtual bool compileCppString(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "CGRuntime::getEnv(";
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
(*cursor)->compileCppString(theCompilerEnvironment);
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptGetEnv;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptGetEnv::_iCounter = 0;
class ExprScriptGetGenerationHeader : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptGetGenerationHeader() {
}
public:
virtual ~ExprScriptGetGenerationHeader() { }
virtual const char* getName() const { return "getGenerationHeader"; }
virtual unsigned int getArity() const { return 0; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
return UNKNOWN_EXPRTYPE;
}
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
std::string returnValue = CGRuntime::getGenerationHeader();
return returnValue;
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppString(theCompilerEnvironment);
return STRING_TYPE;
}
virtual bool compileCppString(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "CGRuntime::getGenerationHeader(";
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptGetGenerationHeader;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptGetGenerationHeader::_iCounter = 0;
class ExprScriptGetHTTPRequest : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptGetHTTPRequest() {
}
public:
virtual ~ExprScriptGetHTTPRequest() { }
virtual const char* getName() const { return "getHTTPRequest"; }
virtual unsigned int getArity() const { return 3; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
if (iIndex == 0) return VALUE_EXPRTYPE;
if (iIndex == 1) return NODE_EXPRTYPE;
if (iIndex == 2) return NODE_EXPRTYPE;
return UNKNOWN_EXPRTYPE;
}
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
std::string sURL = (*cursor)->getValue(visibility);
++cursor;
DtaScriptVariable* pHTTPSession = visibility.getVariable(*dynamic_cast<ExprScriptVariable*>(*cursor));
++cursor;
DtaScriptVariable* pArguments = visibility.getVariable(*dynamic_cast<ExprScriptVariable*>(*cursor));
std::string returnValue = CGRuntime::getHTTPRequest(sURL, pHTTPSession, pArguments);
return returnValue;
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppString(theCompilerEnvironment);
return STRING_TYPE;
}
virtual bool compileCppString(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "CGRuntime::getHTTPRequest(";
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
(*cursor)->compileCppString(theCompilerEnvironment);
CW_BODY_STREAM << ", ";
++cursor;
(*cursor)->compileCpp(theCompilerEnvironment);
CW_BODY_STREAM << ", ";
++cursor;
(*cursor)->compileCpp(theCompilerEnvironment);
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptGetHTTPRequest;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptGetHTTPRequest::_iCounter = 0;
class ExprScriptGetIncludePath : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptGetIncludePath() {
}
public:
virtual ~ExprScriptGetIncludePath() { }
virtual const char* getName() const { return "getIncludePath"; }
virtual unsigned int getArity() const { return 0; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
return UNKNOWN_EXPRTYPE;
}
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
std::string returnValue = CGRuntime::getIncludePath();
return returnValue;
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppString(theCompilerEnvironment);
return STRING_TYPE;
}
virtual bool compileCppString(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "CGRuntime::getIncludePath(";
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptGetIncludePath;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptGetIncludePath::_iCounter = 0;
class ExprScriptGetLastDelay : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptGetLastDelay() {
}
public:
virtual ~ExprScriptGetLastDelay() { }
virtual const char* getName() const { return "getLastDelay"; }
virtual unsigned int getArity() const { return 0; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
return UNKNOWN_EXPRTYPE;
}
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
double returnValue = CGRuntime::getLastDelay();
return CGRuntime::toString(returnValue);
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppDouble(theCompilerEnvironment);
return DOUBLE_TYPE;
}
virtual bool compileCppInt(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "(int) ";
return compileCppDouble(theCompilerEnvironment);
}
virtual bool compileCppString(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "CGRuntime::toString(";
bool bSuccess = compileCppDouble(theCompilerEnvironment);
if (bSuccess) CW_BODY_STREAM << ")";
return bSuccess;
}
virtual bool compileCppDouble(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "CGRuntime::getLastDelay(";
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptGetLastDelay;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptGetLastDelay::_iCounter = 0;
class ExprScriptGetNow : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptGetNow() {
}
public:
virtual ~ExprScriptGetNow() { }
virtual const char* getName() const { return "getNow"; }
virtual unsigned int getArity() const { return 0; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
return UNKNOWN_EXPRTYPE;
}
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
std::string returnValue = CGRuntime::getNow();
return returnValue;
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppString(theCompilerEnvironment);
return STRING_TYPE;
}
virtual bool compileCppString(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "CGRuntime::getNow(";
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptGetNow;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptGetNow::_iCounter = 0;
class ExprScriptGetProperty : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptGetProperty() {
}
public:
virtual ~ExprScriptGetProperty() { }
virtual const char* getName() const { return "getProperty"; }
virtual unsigned int getArity() const { return 1; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
if (iIndex == 0) return VALUE_EXPRTYPE;
return UNKNOWN_EXPRTYPE;
}
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
std::string sDefine = (*cursor)->getValue(visibility);
std::string returnValue = CGRuntime::getProperty(sDefine);
return returnValue;
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppString(theCompilerEnvironment);
return STRING_TYPE;
}
virtual bool compileCppString(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "CGRuntime::getProperty(";
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
(*cursor)->compileCppString(theCompilerEnvironment);
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptGetProperty;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptGetProperty::_iCounter = 0;
class ExprScriptGetShortFilename : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptGetShortFilename() {
}
public:
virtual ~ExprScriptGetShortFilename() { }
virtual const char* getName() const { return "getShortFilename"; }
virtual unsigned int getArity() const { return 1; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
if (iIndex == 0) return VALUE_EXPRTYPE;
return UNKNOWN_EXPRTYPE;
}
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
std::string sPathFilename = (*cursor)->getValue(visibility);
std::string returnValue = CGRuntime::getShortFilename(sPathFilename);
return returnValue;
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppString(theCompilerEnvironment);
return STRING_TYPE;
}
virtual bool compileCppString(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "CGRuntime::getShortFilename(";
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
(*cursor)->compileCppString(theCompilerEnvironment);
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptGetShortFilename;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptGetShortFilename::_iCounter = 0;
class ExprScriptGetTextMode : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptGetTextMode() {
}
public:
virtual ~ExprScriptGetTextMode() { }
virtual const char* getName() const { return "getTextMode"; }
virtual unsigned int getArity() const { return 0; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
return UNKNOWN_EXPRTYPE;
}
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
std::string returnValue = CGRuntime::getTextMode();
return returnValue;
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppString(theCompilerEnvironment);
return STRING_TYPE;
}
virtual bool compileCppString(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "CGRuntime::getTextMode(";
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptGetTextMode;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptGetTextMode::_iCounter = 0;
class ExprScriptGetVariableAttributes : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptGetVariableAttributes() {
}
public:
virtual ~ExprScriptGetVariableAttributes() { }
virtual const char* getName() const { return "getVariableAttributes"; }
virtual unsigned int getArity() const { return 2; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
if (iIndex == 0) return NODE_EXPRTYPE;
if (iIndex == 1) return NODE_EXPRTYPE;
return UNKNOWN_EXPRTYPE;
}
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
DtaScriptVariable* pVariable = visibility.getExistingVariable(*dynamic_cast<ExprScriptVariable*>(*cursor));
++cursor;
DtaScriptVariable* pList = visibility.getVariable(*dynamic_cast<ExprScriptVariable*>(*cursor));
int returnValue = CGRuntime::getVariableAttributes(pVariable, pList);
char tcNumber[16];
sprintf(tcNumber, "%d", returnValue);
return tcNumber;
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppInt(theCompilerEnvironment);
return INT_TYPE;
}
virtual bool compileCppDouble(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "(double) ";
return compileCppInt(theCompilerEnvironment);
}
virtual bool compileCppString(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "CGRuntime::toString(";
bool bSuccess = compileCppInt(theCompilerEnvironment);
if (bSuccess) CW_BODY_STREAM << ")";
return bSuccess;
}
virtual bool compileCppInt(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "CGRuntime::getVariableAttributes(";
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
(*cursor)->compileCpp(theCompilerEnvironment);
CW_BODY_STREAM << ", ";
++cursor;
(*cursor)->compileCpp(theCompilerEnvironment);
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptGetVariableAttributes;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptGetVariableAttributes::_iCounter = 0;
class ExprScriptGetVersion : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptGetVersion() {
}
public:
virtual ~ExprScriptGetVersion() { }
virtual const char* getName() const { return "getVersion"; }
virtual unsigned int getArity() const { return 0; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
return UNKNOWN_EXPRTYPE;
}
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
std::string returnValue = CGRuntime::getVersion();
return returnValue;
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppString(theCompilerEnvironment);
return STRING_TYPE;
}
virtual bool compileCppString(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "CGRuntime::getVersion(";
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptGetVersion;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptGetVersion::_iCounter = 0;
class ExprScriptGetWorkingPath : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptGetWorkingPath() {
}
public:
virtual ~ExprScriptGetWorkingPath() { }
virtual const char* getName() const { return "getWorkingPath"; }
virtual unsigned int getArity() const { return 0; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
return UNKNOWN_EXPRTYPE;
}
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
std::string returnValue = CGRuntime::getWorkingPath();
return returnValue;
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppString(theCompilerEnvironment);
return STRING_TYPE;
}
virtual bool compileCppString(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "CGRuntime::getWorkingPath(";
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptGetWorkingPath;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptGetWorkingPath::_iCounter = 0;
class ExprScriptGetWriteMode : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptGetWriteMode() {
}
public:
virtual ~ExprScriptGetWriteMode() { }
virtual const char* getName() const { return "getWriteMode"; }
virtual unsigned int getArity() const { return 0; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
return UNKNOWN_EXPRTYPE;
}
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
std::string returnValue = CGRuntime::getWriteMode();
return returnValue;
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppString(theCompilerEnvironment);
return STRING_TYPE;
}
virtual bool compileCppString(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "CGRuntime::getWriteMode(";
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptGetWriteMode;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptGetWriteMode::_iCounter = 0;
class ExprScriptHexaToDecimal : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptHexaToDecimal() {
}
public:
virtual ~ExprScriptHexaToDecimal() { }
virtual const char* getName() const { return "hexaToDecimal"; }
virtual unsigned int getArity() const { return 1; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
if (iIndex == 0) return VALUE_EXPRTYPE;
return UNKNOWN_EXPRTYPE;
}
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
std::string sHexaNumber = (*cursor)->getValue(visibility);
int returnValue = CGRuntime::hexaToDecimal(sHexaNumber);
char tcNumber[16];
sprintf(tcNumber, "%d", returnValue);
return tcNumber;
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppInt(theCompilerEnvironment);
return INT_TYPE;
}
virtual bool compileCppDouble(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "(double) ";
return compileCppInt(theCompilerEnvironment);
}
virtual bool compileCppString(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "CGRuntime::toString(";
bool bSuccess = compileCppInt(theCompilerEnvironment);
if (bSuccess) CW_BODY_STREAM << ")";
return bSuccess;
}
virtual bool compileCppInt(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "CGRuntime::hexaToDecimal(";
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
(*cursor)->compileCppString(theCompilerEnvironment);
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptHexaToDecimal;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptHexaToDecimal::_iCounter = 0;
class ExprScriptHostToNetworkLong : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptHostToNetworkLong() {
}
public:
virtual ~ExprScriptHostToNetworkLong() { }
virtual const char* getName() const { return "hostToNetworkLong"; }
virtual unsigned int getArity() const { return 1; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
if (iIndex == 0) return VALUE_EXPRTYPE;
return UNKNOWN_EXPRTYPE;
}
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
std::string sBytes = (*cursor)->getValue(visibility);
std::string returnValue = CGRuntime::hostToNetworkLong(sBytes);
return returnValue;
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppString(theCompilerEnvironment);
return STRING_TYPE;
}
virtual bool compileCppString(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "CGRuntime::hostToNetworkLong(";
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
(*cursor)->compileCppString(theCompilerEnvironment);
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptHostToNetworkLong;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptHostToNetworkLong::_iCounter = 0;
class ExprScriptHostToNetworkShort : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptHostToNetworkShort() {
}
public:
virtual ~ExprScriptHostToNetworkShort() { }
virtual const char* getName() const { return "hostToNetworkShort"; }
virtual unsigned int getArity() const { return 1; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
if (iIndex == 0) return VALUE_EXPRTYPE;
return UNKNOWN_EXPRTYPE;
}
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
std::string sBytes = (*cursor)->getValue(visibility);
std::string returnValue = CGRuntime::hostToNetworkShort(sBytes);
return returnValue;
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppString(theCompilerEnvironment);
return STRING_TYPE;
}
virtual bool compileCppString(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "CGRuntime::hostToNetworkShort(";
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
(*cursor)->compileCppString(theCompilerEnvironment);
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptHostToNetworkShort;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptHostToNetworkShort::_iCounter = 0;
class ExprScriptIncrement : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptIncrement() {
}
public:
virtual ~ExprScriptIncrement() { }
virtual const char* getName() const { return "increment"; }
virtual unsigned int getArity() const { return 1; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
if (iIndex == 0) return NODE_EXPRTYPE;
return UNKNOWN_EXPRTYPE;
}
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
DtaScriptVariable* pNumber = visibility.getVariable(*dynamic_cast<ExprScriptVariable*>(*cursor));
double dNumber = pNumber->getDoubleValue();
double returnValue = CGRuntime::increment(dNumber);
pNumber->setValue(dNumber);
return CGRuntime::toString(returnValue);
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppDouble(theCompilerEnvironment);
return DOUBLE_TYPE;
}
virtual bool compileCppInt(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "(int) ";
return compileCppDouble(theCompilerEnvironment);
}
virtual bool compileCppString(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "CGRuntime::toString(";
bool bSuccess = compileCppDouble(theCompilerEnvironment);
if (bSuccess) CW_BODY_STREAM << ")";
return bSuccess;
}
virtual bool compileCppDouble(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "CGRuntime::increment(";
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
dynamic_cast<ExprScriptVariable*>(*cursor)->compileCppForSet(theCompilerEnvironment);
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptIncrement;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptIncrement::_iCounter = 0;
class ExprScriptIndentFile : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptIndentFile() {
}
public:
virtual ~ExprScriptIndentFile() { }
virtual const char* getName() const { return "indentFile"; }
virtual unsigned int getArity() const { return 2; }
virtual unsigned int getMinArity() const { return 1; }
virtual ExprScriptExpression* getDefaultParameter(unsigned int iIndex) const {
static ExprScriptConstant _internalmode("");
if (iIndex == 1) return &_internalmode;
return NULL;
}
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
if (iIndex == 0) return VALUE_EXPRTYPE;
if (iIndex == 1) return VALUE_EXPRTYPE;
return UNKNOWN_EXPRTYPE;
}
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
std::string sFile = (*cursor)->getValue(visibility);
++cursor;
std::string sMode = (*cursor)->getValue(visibility);
bool returnValue = CGRuntime::indentFile(sFile, sMode);
return (returnValue ? "true" : "");
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppBoolean(theCompilerEnvironment, false);
return BOOL_TYPE;
}
virtual bool compileCppBoolean(CppCompilerEnvironment& theCompilerEnvironment, bool bNegative) const {
if (bNegative) CW_BODY_STREAM << "!";
CW_BODY_STREAM << "CGRuntime::indentFile(";
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
(*cursor)->compileCppString(theCompilerEnvironment);
CW_BODY_STREAM << ", ";
++cursor;
(*cursor)->compileCppString(theCompilerEnvironment);
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptIndentFile;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptIndentFile::_iCounter = 0;
class ExprScriptInf : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptInf() {
}
public:
virtual ~ExprScriptInf() { }
virtual const char* getName() const { return "inf"; }
virtual unsigned int getArity() const { return 2; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
if (iIndex == 0) return VALUE_EXPRTYPE;
if (iIndex == 1) return VALUE_EXPRTYPE;
return UNKNOWN_EXPRTYPE;
}
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
std::string sLeft = (*cursor)->getValue(visibility);
double dLeft = atof(sLeft.c_str());
++cursor;
std::string sRight = (*cursor)->getValue(visibility);
double dRight = atof(sRight.c_str());
bool returnValue = CGRuntime::inf(dLeft, dRight);
return (returnValue ? "true" : "");
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppBoolean(theCompilerEnvironment, false);
return BOOL_TYPE;
}
virtual bool compileCppBoolean(CppCompilerEnvironment& theCompilerEnvironment, bool bNegative) const {
if (bNegative) CW_BODY_STREAM << "!";
CW_BODY_STREAM << "CGRuntime::inf(";
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
(*cursor)->compileCppDouble(theCompilerEnvironment);
CW_BODY_STREAM << ", ";
++cursor;
(*cursor)->compileCppDouble(theCompilerEnvironment);
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptInf;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptInf::_iCounter = 0;
class ExprScriptInputKey : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptInputKey() {
}
public:
virtual ~ExprScriptInputKey() { }
virtual const char* getName() const { return "inputKey"; }
virtual unsigned int getArity() const { return 1; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
if (iIndex == 0) return VALUE_EXPRTYPE;
return UNKNOWN_EXPRTYPE;
}
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
std::string sEcho = (*cursor)->getValue(visibility);
bool bEcho = !sEcho.empty();
std::string returnValue = CGRuntime::inputKey(bEcho);
return returnValue;
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppString(theCompilerEnvironment);
return STRING_TYPE;
}
virtual bool compileCppString(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "CGRuntime::inputKey(";
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
(*cursor)->compileCppBoolean(theCompilerEnvironment, false);
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptInputKey;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptInputKey::_iCounter = 0;
class ExprScriptInputLine : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptInputLine() {
}
public:
virtual ~ExprScriptInputLine() { }
virtual const char* getName() const { return "inputLine"; }
virtual unsigned int getArity() const { return 2; }
virtual unsigned int getMinArity() const { return 1; }
virtual ExprScriptExpression* getDefaultParameter(unsigned int iIndex) const {
static ExprScriptConstant _internalprompt("");
if (iIndex == 1) return &_internalprompt;
return NULL;
}
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
if (iIndex == 0) return VALUE_EXPRTYPE;
if (iIndex == 1) return VALUE_EXPRTYPE;
return UNKNOWN_EXPRTYPE;
}
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
std::string sEcho = (*cursor)->getValue(visibility);
bool bEcho = !sEcho.empty();
++cursor;
std::string sPrompt = (*cursor)->getValue(visibility);
std::string returnValue = CGRuntime::inputLine(bEcho, sPrompt);
return returnValue;
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppString(theCompilerEnvironment);
return STRING_TYPE;
}
virtual bool compileCppString(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "CGRuntime::inputLine(";
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
(*cursor)->compileCppBoolean(theCompilerEnvironment, false);
CW_BODY_STREAM << ", ";
++cursor;
(*cursor)->compileCppString(theCompilerEnvironment);
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptInputLine;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptInputLine::_iCounter = 0;
class ExprScriptIsEmpty : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptIsEmpty() {
}
public:
virtual ~ExprScriptIsEmpty() { }
virtual const char* getName() const { return "isEmpty"; }
virtual unsigned int getArity() const { return 1; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
if (iIndex == 0) return NODE_EXPRTYPE;
return UNKNOWN_EXPRTYPE;
}
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
DtaScriptVariable* pArray = visibility.getExistingVariable(*dynamic_cast<ExprScriptVariable*>(*cursor));
bool returnValue = CGRuntime::isEmpty(pArray);
return (returnValue ? "true" : "");
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppBoolean(theCompilerEnvironment, false);
return BOOL_TYPE;
}
virtual bool compileCppBoolean(CppCompilerEnvironment& theCompilerEnvironment, bool bNegative) const {
if (bNegative) CW_BODY_STREAM << "!";
CW_BODY_STREAM << "CGRuntime::isEmpty(";
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
(*cursor)->compileCpp(theCompilerEnvironment);
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptIsEmpty;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptIsEmpty::_iCounter = 0;
class ExprScriptIsIdentifier : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptIsIdentifier() {
}
public:
virtual ~ExprScriptIsIdentifier() { }
virtual const char* getName() const { return "isIdentifier"; }
virtual unsigned int getArity() const { return 1; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
if (iIndex == 0) return VALUE_EXPRTYPE;
return UNKNOWN_EXPRTYPE;
}
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
std::string sIdentifier = (*cursor)->getValue(visibility);
bool returnValue = CGRuntime::isIdentifier(sIdentifier);
return (returnValue ? "true" : "");
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppBoolean(theCompilerEnvironment, false);
return BOOL_TYPE;
}
virtual bool compileCppBoolean(CppCompilerEnvironment& theCompilerEnvironment, bool bNegative) const {
if (bNegative) CW_BODY_STREAM << "!";
CW_BODY_STREAM << "CGRuntime::isIdentifier(";
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
(*cursor)->compileCppString(theCompilerEnvironment);
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptIsIdentifier;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptIsIdentifier::_iCounter = 0;
class ExprScriptIsNegative : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptIsNegative() {
}
public:
virtual ~ExprScriptIsNegative() { }
virtual const char* getName() const { return "isNegative"; }
virtual unsigned int getArity() const { return 1; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
if (iIndex == 0) return VALUE_EXPRTYPE;
return UNKNOWN_EXPRTYPE;
}
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
std::string sNumber = (*cursor)->getValue(visibility);
double dNumber = atof(sNumber.c_str());
bool returnValue = CGRuntime::isNegative(dNumber);
return (returnValue ? "true" : "");
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppBoolean(theCompilerEnvironment, false);
return BOOL_TYPE;
}
virtual bool compileCppBoolean(CppCompilerEnvironment& theCompilerEnvironment, bool bNegative) const {
if (bNegative) CW_BODY_STREAM << "!";
CW_BODY_STREAM << "CGRuntime::isNegative(";
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
(*cursor)->compileCppDouble(theCompilerEnvironment);
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptIsNegative;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptIsNegative::_iCounter = 0;
class ExprScriptIsNumeric : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptIsNumeric() {
}
public:
virtual ~ExprScriptIsNumeric() { }
virtual const char* getName() const { return "isNumeric"; }
virtual unsigned int getArity() const { return 1; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
if (iIndex == 0) return VALUE_EXPRTYPE;
return UNKNOWN_EXPRTYPE;
}
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
std::string sNumber = (*cursor)->getValue(visibility);
bool returnValue = CGRuntime::isNumeric(sNumber);
return (returnValue ? "true" : "");
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppBoolean(theCompilerEnvironment, false);
return BOOL_TYPE;
}
virtual bool compileCppBoolean(CppCompilerEnvironment& theCompilerEnvironment, bool bNegative) const {
if (bNegative) CW_BODY_STREAM << "!";
CW_BODY_STREAM << "CGRuntime::isNumeric(";
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
(*cursor)->compileCppString(theCompilerEnvironment);
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptIsNumeric;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptIsNumeric::_iCounter = 0;
class ExprScriptIsPositive : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptIsPositive() {
}
public:
virtual ~ExprScriptIsPositive() { }
virtual const char* getName() const { return "isPositive"; }
virtual unsigned int getArity() const { return 1; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
if (iIndex == 0) return VALUE_EXPRTYPE;
return UNKNOWN_EXPRTYPE;
}
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
std::string sNumber = (*cursor)->getValue(visibility);
double dNumber = atof(sNumber.c_str());
bool returnValue = CGRuntime::isPositive(dNumber);
return (returnValue ? "true" : "");
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppBoolean(theCompilerEnvironment, false);
return BOOL_TYPE;
}
virtual bool compileCppBoolean(CppCompilerEnvironment& theCompilerEnvironment, bool bNegative) const {
if (bNegative) CW_BODY_STREAM << "!";
CW_BODY_STREAM << "CGRuntime::isPositive(";
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
(*cursor)->compileCppDouble(theCompilerEnvironment);
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptIsPositive;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptIsPositive::_iCounter = 0;
class ExprScriptJoinStrings : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptJoinStrings() {
}
public:
virtual ~ExprScriptJoinStrings() { }
virtual const char* getName() const { return "joinStrings"; }
virtual unsigned int getArity() const { return 2; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
if (iIndex == 0) return NODE_EXPRTYPE;
if (iIndex == 1) return VALUE_EXPRTYPE;
return UNKNOWN_EXPRTYPE;
}
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
DtaScriptVariable* pList = visibility.getVariable(*dynamic_cast<ExprScriptVariable*>(*cursor));
++cursor;
std::string sSeparator = (*cursor)->getValue(visibility);
std::string returnValue = CGRuntime::joinStrings(pList, sSeparator);
return returnValue;
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppString(theCompilerEnvironment);
return STRING_TYPE;
}
virtual bool compileCppString(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "CGRuntime::joinStrings(";
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
(*cursor)->compileCpp(theCompilerEnvironment);
CW_BODY_STREAM << ", ";
++cursor;
(*cursor)->compileCppString(theCompilerEnvironment);
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptJoinStrings;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptJoinStrings::_iCounter = 0;
class ExprScriptLeftString : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptLeftString() {
}
public:
virtual ~ExprScriptLeftString() { }
virtual const char* getName() const { return "leftString"; }
virtual unsigned int getArity() const { return 2; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
if (iIndex == 0) return VALUE_EXPRTYPE;
if (iIndex == 1) return VALUE_EXPRTYPE;
return UNKNOWN_EXPRTYPE;
}
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
std::string sText = (*cursor)->getValue(visibility);
++cursor;
std::string sLength = (*cursor)->getValue(visibility);
int iLength = atoi(sLength.c_str());
std::string returnValue = CGRuntime::leftString(sText, iLength);
return returnValue;
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppString(theCompilerEnvironment);
return STRING_TYPE;
}
virtual bool compileCppString(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "CGRuntime::leftString(";
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
(*cursor)->compileCppString(theCompilerEnvironment);
CW_BODY_STREAM << ", ";
++cursor;
(*cursor)->compileCppInt(theCompilerEnvironment);
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptLeftString;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptLeftString::_iCounter = 0;
class ExprScriptLengthString : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptLengthString() {
}
public:
virtual ~ExprScriptLengthString() { }
virtual const char* getName() const { return "lengthString"; }
virtual unsigned int getArity() const { return 1; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
if (iIndex == 0) return VALUE_EXPRTYPE;
return UNKNOWN_EXPRTYPE;
}
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
std::string sText = (*cursor)->getValue(visibility);
int returnValue = CGRuntime::lengthString(sText);
char tcNumber[16];
sprintf(tcNumber, "%d", returnValue);
return tcNumber;
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppInt(theCompilerEnvironment);
return INT_TYPE;
}
virtual bool compileCppDouble(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "(double) ";
return compileCppInt(theCompilerEnvironment);
}
virtual bool compileCppString(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "CGRuntime::toString(";
bool bSuccess = compileCppInt(theCompilerEnvironment);
if (bSuccess) CW_BODY_STREAM << ")";
return bSuccess;
}
virtual bool compileCppInt(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "CGRuntime::lengthString(";
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
(*cursor)->compileCppString(theCompilerEnvironment);
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptLengthString;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptLengthString::_iCounter = 0;
class ExprScriptLoadBinaryFile : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptLoadBinaryFile() {
}
public:
virtual ~ExprScriptLoadBinaryFile() { }
virtual const char* getName() const { return "loadBinaryFile"; }
virtual unsigned int getArity() const { return 2; }
virtual unsigned int getMinArity() const { return 1; }
virtual ExprScriptExpression* getDefaultParameter(unsigned int iIndex) const {
static ExprScriptConstant _internallength(-1);
if (iIndex == 1) return &_internallength;
return NULL;
}
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
if (iIndex == 0) return VALUE_EXPRTYPE;
if (iIndex == 1) return VALUE_EXPRTYPE;
return UNKNOWN_EXPRTYPE;
}
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
std::string sFile = (*cursor)->getValue(visibility);
++cursor;
std::string sLength = (*cursor)->getValue(visibility);
int iLength = atoi(sLength.c_str());
std::string returnValue = CGRuntime::loadBinaryFile(sFile, iLength);
return returnValue;
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppString(theCompilerEnvironment);
return STRING_TYPE;
}
virtual bool compileCppString(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "CGRuntime::loadBinaryFile(";
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
(*cursor)->compileCppString(theCompilerEnvironment);
CW_BODY_STREAM << ", ";
++cursor;
(*cursor)->compileCppInt(theCompilerEnvironment);
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptLoadBinaryFile;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptLoadBinaryFile::_iCounter = 0;
class ExprScriptLoadFile : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptLoadFile() {
}
public:
virtual ~ExprScriptLoadFile() { }
virtual const char* getName() const { return "loadFile"; }
virtual unsigned int getArity() const { return 2; }
virtual unsigned int getMinArity() const { return 1; }
virtual ExprScriptExpression* getDefaultParameter(unsigned int iIndex) const {
static ExprScriptConstant _internallength(-1);
if (iIndex == 1) return &_internallength;
return NULL;
}
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
if (iIndex == 0) return VALUE_EXPRTYPE;
if (iIndex == 1) return VALUE_EXPRTYPE;
return UNKNOWN_EXPRTYPE;
}
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
std::string sFile = (*cursor)->getValue(visibility);
++cursor;
std::string sLength = (*cursor)->getValue(visibility);
int iLength = atoi(sLength.c_str());
std::string returnValue = CGRuntime::loadFile(sFile, iLength);
return returnValue;
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppString(theCompilerEnvironment);
return STRING_TYPE;
}
virtual bool compileCppString(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "CGRuntime::loadFile(";
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
(*cursor)->compileCppString(theCompilerEnvironment);
CW_BODY_STREAM << ", ";
++cursor;
(*cursor)->compileCppInt(theCompilerEnvironment);
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptLoadFile;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptLoadFile::_iCounter = 0;
class ExprScriptLoadVirtualFile : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptLoadVirtualFile() {
}
public:
virtual ~ExprScriptLoadVirtualFile() { }
virtual const char* getName() const { return "loadVirtualFile"; }
virtual unsigned int getArity() const { return 1; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
if (iIndex == 0) return VALUE_EXPRTYPE;
return UNKNOWN_EXPRTYPE;
}
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
std::string sHandle = (*cursor)->getValue(visibility);
std::string returnValue = CGRuntime::loadVirtualFile(sHandle);
return returnValue;
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppString(theCompilerEnvironment);
return STRING_TYPE;
}
virtual bool compileCppString(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "CGRuntime::loadVirtualFile(";
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
(*cursor)->compileCppString(theCompilerEnvironment);
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptLoadVirtualFile;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptLoadVirtualFile::_iCounter = 0;
class ExprScriptLog : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptLog() {
}
public:
virtual ~ExprScriptLog() { }
virtual const char* getName() const { return "log"; }
virtual unsigned int getArity() const { return 1; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
if (iIndex == 0) return VALUE_EXPRTYPE;
return UNKNOWN_EXPRTYPE;
}
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
std::string sX = (*cursor)->getValue(visibility);
double dX = atof(sX.c_str());
double returnValue = CGRuntime::log(dX);
return CGRuntime::toString(returnValue);
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppDouble(theCompilerEnvironment);
return DOUBLE_TYPE;
}
virtual bool compileCppInt(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "(int) ";
return compileCppDouble(theCompilerEnvironment);
}
virtual bool compileCppString(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "CGRuntime::toString(";
bool bSuccess = compileCppDouble(theCompilerEnvironment);
if (bSuccess) CW_BODY_STREAM << ")";
return bSuccess;
}
virtual bool compileCppDouble(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "CGRuntime::log(";
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
(*cursor)->compileCppDouble(theCompilerEnvironment);
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptLog;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptLog::_iCounter = 0;
class ExprScriptLongToBytes : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptLongToBytes() {
}
public:
virtual ~ExprScriptLongToBytes() { }
virtual const char* getName() const { return "longToBytes"; }
virtual unsigned int getArity() const { return 1; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
if (iIndex == 0) return VALUE_EXPRTYPE;
return UNKNOWN_EXPRTYPE;
}
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
std::string sLong = (*cursor)->getValue(visibility);
char* tcLong;
unsigned long ulLong = strtoul(sLong.c_str(), &tcLong, 10);
std::string returnValue = CGRuntime::longToBytes(ulLong);
return returnValue;
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppString(theCompilerEnvironment);
return STRING_TYPE;
}
virtual bool compileCppString(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "CGRuntime::longToBytes(";
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
(*cursor)->compileCppUnsignedLong(theCompilerEnvironment);
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptLongToBytes;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptLongToBytes::_iCounter = 0;
class ExprScriptMidString : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptMidString() {
}
public:
virtual ~ExprScriptMidString() { }
virtual const char* getName() const { return "midString"; }
virtual unsigned int getArity() const { return 3; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
if (iIndex == 0) return VALUE_EXPRTYPE;
if (iIndex == 1) return VALUE_EXPRTYPE;
if (iIndex == 2) return VALUE_EXPRTYPE;
return UNKNOWN_EXPRTYPE;
}
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
std::string sText = (*cursor)->getValue(visibility);
++cursor;
std::string sPos = (*cursor)->getValue(visibility);
int iPos = atoi(sPos.c_str());
++cursor;
std::string sLength = (*cursor)->getValue(visibility);
int iLength = atoi(sLength.c_str());
std::string returnValue = CGRuntime::midString(sText, iPos, iLength);
return returnValue;
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppString(theCompilerEnvironment);
return STRING_TYPE;
}
virtual bool compileCppString(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "CGRuntime::midString(";
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
(*cursor)->compileCppString(theCompilerEnvironment);
CW_BODY_STREAM << ", ";
++cursor;
(*cursor)->compileCppInt(theCompilerEnvironment);
CW_BODY_STREAM << ", ";
++cursor;
(*cursor)->compileCppInt(theCompilerEnvironment);
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptMidString;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptMidString::_iCounter = 0;
class ExprScriptMod : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptMod() {
}
public:
virtual ~ExprScriptMod() { }
virtual const char* getName() const { return "mod"; }
virtual unsigned int getArity() const { return 2; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
if (iIndex == 0) return VALUE_EXPRTYPE;
if (iIndex == 1) return VALUE_EXPRTYPE;
return UNKNOWN_EXPRTYPE;
}
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
std::string sDividend = (*cursor)->getValue(visibility);
int iDividend = atoi(sDividend.c_str());
++cursor;
std::string sDivisor = (*cursor)->getValue(visibility);
int iDivisor = atoi(sDivisor.c_str());
int returnValue = CGRuntime::mod(iDividend, iDivisor);
char tcNumber[16];
sprintf(tcNumber, "%d", returnValue);
return tcNumber;
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppInt(theCompilerEnvironment);
return INT_TYPE;
}
virtual bool compileCppDouble(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "(double) ";
return compileCppInt(theCompilerEnvironment);
}
virtual bool compileCppString(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "CGRuntime::toString(";
bool bSuccess = compileCppInt(theCompilerEnvironment);
if (bSuccess) CW_BODY_STREAM << ")";
return bSuccess;
}
virtual bool compileCppInt(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "CGRuntime::mod(";
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
(*cursor)->compileCppInt(theCompilerEnvironment);
CW_BODY_STREAM << ", ";
++cursor;
(*cursor)->compileCppInt(theCompilerEnvironment);
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptMod;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptMod::_iCounter = 0;
class ExprScriptMult : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptMult() {
}
public:
virtual ~ExprScriptMult() { }
virtual const char* getName() const { return "mult"; }
virtual unsigned int getArity() const { return 2; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
if (iIndex == 0) return VALUE_EXPRTYPE;
if (iIndex == 1) return VALUE_EXPRTYPE;
return UNKNOWN_EXPRTYPE;
}
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
std::string sLeft = (*cursor)->getValue(visibility);
double dLeft = atof(sLeft.c_str());
++cursor;
std::string sRight = (*cursor)->getValue(visibility);
double dRight = atof(sRight.c_str());
double returnValue = CGRuntime::mult(dLeft, dRight);
return CGRuntime::toString(returnValue);
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppDouble(theCompilerEnvironment);
return DOUBLE_TYPE;
}
virtual bool compileCppInt(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "(int) ";
return compileCppDouble(theCompilerEnvironment);
}
virtual bool compileCppString(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "CGRuntime::toString(";
bool bSuccess = compileCppDouble(theCompilerEnvironment);
if (bSuccess) CW_BODY_STREAM << ")";
return bSuccess;
}
virtual bool compileCppDouble(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "CGRuntime::mult(";
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
(*cursor)->compileCppDouble(theCompilerEnvironment);
CW_BODY_STREAM << ", ";
++cursor;
(*cursor)->compileCppDouble(theCompilerEnvironment);
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptMult;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptMult::_iCounter = 0;
class ExprScriptNetworkLongToHost : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptNetworkLongToHost() {
}
public:
virtual ~ExprScriptNetworkLongToHost() { }
virtual const char* getName() const { return "networkLongToHost"; }
virtual unsigned int getArity() const { return 1; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
if (iIndex == 0) return VALUE_EXPRTYPE;
return UNKNOWN_EXPRTYPE;
}
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
std::string sBytes = (*cursor)->getValue(visibility);
std::string returnValue = CGRuntime::networkLongToHost(sBytes);
return returnValue;
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppString(theCompilerEnvironment);
return STRING_TYPE;
}
virtual bool compileCppString(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "CGRuntime::networkLongToHost(";
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
(*cursor)->compileCppString(theCompilerEnvironment);
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptNetworkLongToHost;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptNetworkLongToHost::_iCounter = 0;
class ExprScriptNetworkShortToHost : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptNetworkShortToHost() {
}
public:
virtual ~ExprScriptNetworkShortToHost() { }
virtual const char* getName() const { return "networkShortToHost"; }
virtual unsigned int getArity() const { return 1; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
if (iIndex == 0) return VALUE_EXPRTYPE;
return UNKNOWN_EXPRTYPE;
}
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
std::string sBytes = (*cursor)->getValue(visibility);
std::string returnValue = CGRuntime::networkShortToHost(sBytes);
return returnValue;
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppString(theCompilerEnvironment);
return STRING_TYPE;
}
virtual bool compileCppString(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "CGRuntime::networkShortToHost(";
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
(*cursor)->compileCppString(theCompilerEnvironment);
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptNetworkShortToHost;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptNetworkShortToHost::_iCounter = 0;
class ExprScriptOctalToDecimal : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptOctalToDecimal() {
}
public:
virtual ~ExprScriptOctalToDecimal() { }
virtual const char* getName() const { return "octalToDecimal"; }
virtual unsigned int getArity() const { return 1; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
if (iIndex == 0) return VALUE_EXPRTYPE;
return UNKNOWN_EXPRTYPE;
}
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
std::string sOctalNumber = (*cursor)->getValue(visibility);
int returnValue = CGRuntime::octalToDecimal(sOctalNumber);
char tcNumber[16];
sprintf(tcNumber, "%d", returnValue);
return tcNumber;
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppInt(theCompilerEnvironment);
return INT_TYPE;
}
virtual bool compileCppDouble(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "(double) ";
return compileCppInt(theCompilerEnvironment);
}
virtual bool compileCppString(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "CGRuntime::toString(";
bool bSuccess = compileCppInt(theCompilerEnvironment);
if (bSuccess) CW_BODY_STREAM << ")";
return bSuccess;
}
virtual bool compileCppInt(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "CGRuntime::octalToDecimal(";
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
(*cursor)->compileCppString(theCompilerEnvironment);
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptOctalToDecimal;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptOctalToDecimal::_iCounter = 0;
class ExprScriptParseFreeQuiet : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptParseFreeQuiet(GrfBlock& block) {
//##protect##"parseFreeQuiet::constructor"
_pParseFree = new GrfParseFree;
_pParseFree->setParent(&block);
//##protect##"parseFreeQuiet::constructor"
}
private:
//##protect##"parseFreeQuiet::attributes"
GrfParseFree* _pParseFree;
//##protect##"parseFreeQuiet::attributes"
public:
virtual ~ExprScriptParseFreeQuiet() {
//##protect##"parseFreeQuiet::destructor"
delete _pParseFree;
//##protect##"parseFreeQuiet::destructor"
}
virtual const char* getName() const { return "parseFreeQuiet"; }
virtual unsigned int getArity() const { return 3; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
if (iIndex == 0) return VALUE_EXPRTYPE;
if (iIndex == 1) return NODE_EXPRTYPE;
if (iIndex == 2) return VALUE_EXPRTYPE;
return UNKNOWN_EXPRTYPE;
}
virtual void initializationDone() {
//##protect##"parseFreeQuiet::initializationDone"
_pParseFree->setDesignFileName(_parameters[0]);
_pParseFree->setThis((ExprScriptVariable*) _parameters[1]);
_pParseFree->setInputFileName(_parameters[2]);
_parameters = std::vector<ExprScriptExpression*>();
//##protect##"parseFreeQuiet::initializationDone"
}
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
std::string returnValue;
//##protect##"parseFreeQuiet::execute"
CGQuietOutput quiet;
_pParseFree->execute(visibility);
returnValue = quiet.getOutput();
//##protect##"parseFreeQuiet::execute"
return returnValue;
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppString(theCompilerEnvironment);
return STRING_TYPE;
}
virtual bool compileCppString(CppCompilerEnvironment& theCompilerEnvironment) const {
//##protect##"parseFreeQuiet::compileCppString"
int iCursor = theCompilerEnvironment.newCursor();
char tcFunction[80];
sprintf(tcFunction, "_compiler_internal_parseFreeQuiet%d", iCursor);
std::string sDefinition = "std::string ";
sDefinition += tcFunction;
sDefinition += "(CppParsingTree_var pThisTree, const std::string& sFilename) {\n";
sDefinition += "\tCGQuietOutput quiet;\n";
ScpStream* pOwner;
CW_BODY_STREAM.insertText(sDefinition, CW_BODY_STREAM.getFloatingLocation("INSERT AREA", pOwner));
CW_BODY_STREAM << tcFunction << "(";
_pParseFree->getThis()->compileCpp(theCompilerEnvironment);
CW_BODY_STREAM << ", ";
_pParseFree->getInputFileName()->compileCppString(theCompilerEnvironment);
CW_BODY_STREAM << ")";
int iLocation = CW_BODY_STREAM.getOutputLocation();
_pParseFree->compileCppForQuiet(theCompilerEnvironment);
sDefinition = CW_BODY_STREAM.readBuffer() + iLocation;
CW_BODY_STREAM.resize(iLocation);
sDefinition += "\treturn quiet.getOutput();\n}\n";
CW_BODY_STREAM.insertText(sDefinition, CW_BODY_STREAM.getFloatingLocation("INSERT AREA", pOwner));
//##protect##"parseFreeQuiet::compileCppString"
return true;
}
static ExprScriptFunction* create(GrfBlock& block) {
return new ExprScriptParseFreeQuiet(block);
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptParseFreeQuiet::_iCounter = 0;
class ExprScriptPathFromPackage : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptPathFromPackage() {
}
public:
virtual ~ExprScriptPathFromPackage() { }
virtual const char* getName() const { return "pathFromPackage"; }
virtual unsigned int getArity() const { return 1; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
if (iIndex == 0) return VALUE_EXPRTYPE;
return UNKNOWN_EXPRTYPE;
}
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
std::string sPackage = (*cursor)->getValue(visibility);
std::string returnValue = CGRuntime::pathFromPackage(sPackage);
return returnValue;
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppString(theCompilerEnvironment);
return STRING_TYPE;
}
virtual bool compileCppString(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "CGRuntime::pathFromPackage(";
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
(*cursor)->compileCppString(theCompilerEnvironment);
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptPathFromPackage;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptPathFromPackage::_iCounter = 0;
class ExprScriptPostHTTPRequest : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptPostHTTPRequest() {
}
public:
virtual ~ExprScriptPostHTTPRequest() { }
virtual const char* getName() const { return "postHTTPRequest"; }
virtual unsigned int getArity() const { return 3; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
if (iIndex == 0) return VALUE_EXPRTYPE;
if (iIndex == 1) return NODE_EXPRTYPE;
if (iIndex == 2) return NODE_EXPRTYPE;
return UNKNOWN_EXPRTYPE;
}
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
std::string sURL = (*cursor)->getValue(visibility);
++cursor;
DtaScriptVariable* pHTTPSession = visibility.getExistingVariable(*dynamic_cast<ExprScriptVariable*>(*cursor));
++cursor;
DtaScriptVariable* pArguments = visibility.getExistingVariable(*dynamic_cast<ExprScriptVariable*>(*cursor));
std::string returnValue = CGRuntime::postHTTPRequest(sURL, pHTTPSession, pArguments);
return returnValue;
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppString(theCompilerEnvironment);
return STRING_TYPE;
}
virtual bool compileCppString(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "CGRuntime::postHTTPRequest(";
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
(*cursor)->compileCppString(theCompilerEnvironment);
CW_BODY_STREAM << ", ";
++cursor;
(*cursor)->compileCpp(theCompilerEnvironment);
CW_BODY_STREAM << ", ";
++cursor;
(*cursor)->compileCpp(theCompilerEnvironment);
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptPostHTTPRequest;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptPostHTTPRequest::_iCounter = 0;
class ExprScriptPow : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptPow() {
}
public:
virtual ~ExprScriptPow() { }
virtual const char* getName() const { return "pow"; }
virtual unsigned int getArity() const { return 2; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
if (iIndex == 0) return VALUE_EXPRTYPE;
if (iIndex == 1) return VALUE_EXPRTYPE;
return UNKNOWN_EXPRTYPE;
}
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
std::string sX = (*cursor)->getValue(visibility);
double dX = atof(sX.c_str());
++cursor;
std::string sY = (*cursor)->getValue(visibility);
double dY = atof(sY.c_str());
double returnValue = CGRuntime::pow(dX, dY);
return CGRuntime::toString(returnValue);
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppDouble(theCompilerEnvironment);
return DOUBLE_TYPE;
}
virtual bool compileCppInt(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "(int) ";
return compileCppDouble(theCompilerEnvironment);
}
virtual bool compileCppString(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "CGRuntime::toString(";
bool bSuccess = compileCppDouble(theCompilerEnvironment);
if (bSuccess) CW_BODY_STREAM << ")";
return bSuccess;
}
virtual bool compileCppDouble(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "CGRuntime::pow(";
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
(*cursor)->compileCppDouble(theCompilerEnvironment);
CW_BODY_STREAM << ", ";
++cursor;
(*cursor)->compileCppDouble(theCompilerEnvironment);
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptPow;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptPow::_iCounter = 0;
class ExprScriptRandomInteger : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptRandomInteger() {
}
public:
virtual ~ExprScriptRandomInteger() { }
virtual const char* getName() const { return "randomInteger"; }
virtual unsigned int getArity() const { return 0; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
return UNKNOWN_EXPRTYPE;
}
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
int returnValue = CGRuntime::randomInteger();
char tcNumber[16];
sprintf(tcNumber, "%d", returnValue);
return tcNumber;
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppInt(theCompilerEnvironment);
return INT_TYPE;
}
virtual bool compileCppDouble(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "(double) ";
return compileCppInt(theCompilerEnvironment);
}
virtual bool compileCppString(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "CGRuntime::toString(";
bool bSuccess = compileCppInt(theCompilerEnvironment);
if (bSuccess) CW_BODY_STREAM << ")";
return bSuccess;
}
virtual bool compileCppInt(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "CGRuntime::randomInteger(";
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptRandomInteger;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptRandomInteger::_iCounter = 0;
class ExprScriptReceiveBinaryFromSocket : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptReceiveBinaryFromSocket() {
}
public:
virtual ~ExprScriptReceiveBinaryFromSocket() { }
virtual const char* getName() const { return "receiveBinaryFromSocket"; }
virtual unsigned int getArity() const { return 2; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
if (iIndex == 0) return VALUE_EXPRTYPE;
if (iIndex == 1) return VALUE_EXPRTYPE;
return UNKNOWN_EXPRTYPE;
}
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
std::string sSocket = (*cursor)->getValue(visibility);
int iSocket = atoi(sSocket.c_str());
++cursor;
std::string sLength = (*cursor)->getValue(visibility);
int iLength = atoi(sLength.c_str());
std::string returnValue = CGRuntime::receiveBinaryFromSocket(iSocket, iLength);
return returnValue;
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppString(theCompilerEnvironment);
return STRING_TYPE;
}
virtual bool compileCppString(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "CGRuntime::receiveBinaryFromSocket(";
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
(*cursor)->compileCppInt(theCompilerEnvironment);
CW_BODY_STREAM << ", ";
++cursor;
(*cursor)->compileCppInt(theCompilerEnvironment);
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptReceiveBinaryFromSocket;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptReceiveBinaryFromSocket::_iCounter = 0;
class ExprScriptReceiveFromSocket : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptReceiveFromSocket() {
}
public:
virtual ~ExprScriptReceiveFromSocket() { }
virtual const char* getName() const { return "receiveFromSocket"; }
virtual unsigned int getArity() const { return 2; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
if (iIndex == 0) return VALUE_EXPRTYPE;
if (iIndex == 1) return NODE_EXPRTYPE;
return UNKNOWN_EXPRTYPE;
}
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
std::string sSocket = (*cursor)->getValue(visibility);
int iSocket = atoi(sSocket.c_str());
++cursor;
DtaScriptVariable* pIsText = visibility.getVariable(*dynamic_cast<ExprScriptVariable*>(*cursor));
bool bIsText = pIsText->getBooleanValue();
std::string returnValue = CGRuntime::receiveFromSocket(iSocket, bIsText);
pIsText->setValue(bIsText);
return returnValue;
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppString(theCompilerEnvironment);
return STRING_TYPE;
}
virtual bool compileCppString(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "CGRuntime::receiveFromSocket(";
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
(*cursor)->compileCppInt(theCompilerEnvironment);
CW_BODY_STREAM << ", ";
++cursor;
dynamic_cast<ExprScriptVariable*>(*cursor)->compileCppForSet(theCompilerEnvironment);
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptReceiveFromSocket;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptReceiveFromSocket::_iCounter = 0;
class ExprScriptReceiveTextFromSocket : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptReceiveTextFromSocket() {
}
public:
virtual ~ExprScriptReceiveTextFromSocket() { }
virtual const char* getName() const { return "receiveTextFromSocket"; }
virtual unsigned int getArity() const { return 2; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
if (iIndex == 0) return VALUE_EXPRTYPE;
if (iIndex == 1) return VALUE_EXPRTYPE;
return UNKNOWN_EXPRTYPE;
}
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
std::string sSocket = (*cursor)->getValue(visibility);
int iSocket = atoi(sSocket.c_str());
++cursor;
std::string sLength = (*cursor)->getValue(visibility);
int iLength = atoi(sLength.c_str());
std::string returnValue = CGRuntime::receiveTextFromSocket(iSocket, iLength);
return returnValue;
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppString(theCompilerEnvironment);
return STRING_TYPE;
}
virtual bool compileCppString(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "CGRuntime::receiveTextFromSocket(";
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
(*cursor)->compileCppInt(theCompilerEnvironment);
CW_BODY_STREAM << ", ";
++cursor;
(*cursor)->compileCppInt(theCompilerEnvironment);
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptReceiveTextFromSocket;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptReceiveTextFromSocket::_iCounter = 0;
class ExprScriptRelativePath : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptRelativePath() {
}
public:
virtual ~ExprScriptRelativePath() { }
virtual const char* getName() const { return "relativePath"; }
virtual unsigned int getArity() const { return 2; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
if (iIndex == 0) return VALUE_EXPRTYPE;
if (iIndex == 1) return VALUE_EXPRTYPE;
return UNKNOWN_EXPRTYPE;
}
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
std::string sPath = (*cursor)->getValue(visibility);
++cursor;
std::string sReference = (*cursor)->getValue(visibility);
std::string returnValue = CGRuntime::relativePath(sPath, sReference);
return returnValue;
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppString(theCompilerEnvironment);
return STRING_TYPE;
}
virtual bool compileCppString(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "CGRuntime::relativePath(";
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
(*cursor)->compileCppString(theCompilerEnvironment);
CW_BODY_STREAM << ", ";
++cursor;
(*cursor)->compileCppString(theCompilerEnvironment);
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptRelativePath;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptRelativePath::_iCounter = 0;
class ExprScriptRemoveDirectory : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptRemoveDirectory() {
}
public:
virtual ~ExprScriptRemoveDirectory() { }
virtual const char* getName() const { return "removeDirectory"; }
virtual unsigned int getArity() const { return 1; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
if (iIndex == 0) return VALUE_EXPRTYPE;
return UNKNOWN_EXPRTYPE;
}
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
std::string sPath = (*cursor)->getValue(visibility);
bool returnValue = CGRuntime::removeDirectory(sPath);
return (returnValue ? "true" : "");
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppBoolean(theCompilerEnvironment, false);
return BOOL_TYPE;
}
virtual bool compileCppBoolean(CppCompilerEnvironment& theCompilerEnvironment, bool bNegative) const {
if (bNegative) CW_BODY_STREAM << "!";
CW_BODY_STREAM << "CGRuntime::removeDirectory(";
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
(*cursor)->compileCppString(theCompilerEnvironment);
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptRemoveDirectory;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptRemoveDirectory::_iCounter = 0;
class ExprScriptRemoveGenerationTagsHandler : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptRemoveGenerationTagsHandler() {
}
public:
virtual ~ExprScriptRemoveGenerationTagsHandler() { }
virtual const char* getName() const { return "removeGenerationTagsHandler"; }
virtual unsigned int getArity() const { return 1; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
if (iIndex == 0) return VALUE_EXPRTYPE;
return UNKNOWN_EXPRTYPE;
}
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
std::string sKey = (*cursor)->getValue(visibility);
bool returnValue = CGRuntime::removeGenerationTagsHandler(sKey);
return (returnValue ? "true" : "");
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppBoolean(theCompilerEnvironment, false);
return BOOL_TYPE;
}
virtual bool compileCppBoolean(CppCompilerEnvironment& theCompilerEnvironment, bool bNegative) const {
if (bNegative) CW_BODY_STREAM << "!";
CW_BODY_STREAM << "CGRuntime::removeGenerationTagsHandler(";
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
(*cursor)->compileCppString(theCompilerEnvironment);
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptRemoveGenerationTagsHandler;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptRemoveGenerationTagsHandler::_iCounter = 0;
class ExprScriptRepeatString : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptRepeatString() {
}
public:
virtual ~ExprScriptRepeatString() { }
virtual const char* getName() const { return "repeatString"; }
virtual unsigned int getArity() const { return 2; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
if (iIndex == 0) return VALUE_EXPRTYPE;
if (iIndex == 1) return VALUE_EXPRTYPE;
return UNKNOWN_EXPRTYPE;
}
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
std::string sText = (*cursor)->getValue(visibility);
++cursor;
std::string sOccurrences = (*cursor)->getValue(visibility);
int iOccurrences = atoi(sOccurrences.c_str());
std::string returnValue = CGRuntime::repeatString(sText, iOccurrences);
return returnValue;
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppString(theCompilerEnvironment);
return STRING_TYPE;
}
virtual bool compileCppString(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "CGRuntime::repeatString(";
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
(*cursor)->compileCppString(theCompilerEnvironment);
CW_BODY_STREAM << ", ";
++cursor;
(*cursor)->compileCppInt(theCompilerEnvironment);
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptRepeatString;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptRepeatString::_iCounter = 0;
class ExprScriptReplaceString : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptReplaceString() {
}
public:
virtual ~ExprScriptReplaceString() { }
virtual const char* getName() const { return "replaceString"; }
virtual unsigned int getArity() const { return 3; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
if (iIndex == 0) return VALUE_EXPRTYPE;
if (iIndex == 1) return VALUE_EXPRTYPE;
if (iIndex == 2) return VALUE_EXPRTYPE;
return UNKNOWN_EXPRTYPE;
}
virtual int getThisPosition() const { return 2; }
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
std::string sOld = (*cursor)->getValue(visibility);
++cursor;
std::string sNew = (*cursor)->getValue(visibility);
++cursor;
std::string sText = (*cursor)->getValue(visibility);
std::string returnValue = CGRuntime::replaceString(sOld, sNew, sText);
return returnValue;
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppString(theCompilerEnvironment);
return STRING_TYPE;
}
virtual bool compileCppString(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "CGRuntime::replaceString(";
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
(*cursor)->compileCppString(theCompilerEnvironment);
CW_BODY_STREAM << ", ";
++cursor;
(*cursor)->compileCppString(theCompilerEnvironment);
CW_BODY_STREAM << ", ";
++cursor;
(*cursor)->compileCppString(theCompilerEnvironment);
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptReplaceString;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptReplaceString::_iCounter = 0;
class ExprScriptReplaceTabulations : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptReplaceTabulations() {
}
public:
virtual ~ExprScriptReplaceTabulations() { }
virtual const char* getName() const { return "replaceTabulations"; }
virtual unsigned int getArity() const { return 2; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
if (iIndex == 0) return VALUE_EXPRTYPE;
if (iIndex == 1) return VALUE_EXPRTYPE;
return UNKNOWN_EXPRTYPE;
}
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
std::string sText = (*cursor)->getValue(visibility);
++cursor;
std::string sTab = (*cursor)->getValue(visibility);
int iTab = atoi(sTab.c_str());
std::string returnValue = CGRuntime::replaceTabulations(sText, iTab);
return returnValue;
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppString(theCompilerEnvironment);
return STRING_TYPE;
}
virtual bool compileCppString(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "CGRuntime::replaceTabulations(";
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
(*cursor)->compileCppString(theCompilerEnvironment);
CW_BODY_STREAM << ", ";
++cursor;
(*cursor)->compileCppInt(theCompilerEnvironment);
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptReplaceTabulations;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptReplaceTabulations::_iCounter = 0;
class ExprScriptResolveFilePath : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptResolveFilePath() {
}
public:
virtual ~ExprScriptResolveFilePath() { }
virtual const char* getName() const { return "resolveFilePath"; }
virtual unsigned int getArity() const { return 1; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
if (iIndex == 0) return VALUE_EXPRTYPE;
return UNKNOWN_EXPRTYPE;
}
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
std::string sFilename = (*cursor)->getValue(visibility);
std::string returnValue = CGRuntime::resolveFilePath(sFilename);
return returnValue;
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppString(theCompilerEnvironment);
return STRING_TYPE;
}
virtual bool compileCppString(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "CGRuntime::resolveFilePath(";
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
(*cursor)->compileCppString(theCompilerEnvironment);
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptResolveFilePath;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptResolveFilePath::_iCounter = 0;
class ExprScriptRightString : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptRightString() {
}
public:
virtual ~ExprScriptRightString() { }
virtual const char* getName() const { return "rightString"; }
virtual unsigned int getArity() const { return 2; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
if (iIndex == 0) return VALUE_EXPRTYPE;
if (iIndex == 1) return VALUE_EXPRTYPE;
return UNKNOWN_EXPRTYPE;
}
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
std::string sText = (*cursor)->getValue(visibility);
++cursor;
std::string sLength = (*cursor)->getValue(visibility);
int iLength = atoi(sLength.c_str());
std::string returnValue = CGRuntime::rightString(sText, iLength);
return returnValue;
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppString(theCompilerEnvironment);
return STRING_TYPE;
}
virtual bool compileCppString(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "CGRuntime::rightString(";
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
(*cursor)->compileCppString(theCompilerEnvironment);
CW_BODY_STREAM << ", ";
++cursor;
(*cursor)->compileCppInt(theCompilerEnvironment);
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptRightString;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptRightString::_iCounter = 0;
class ExprScriptRsubString : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptRsubString() {
}
public:
virtual ~ExprScriptRsubString() { }
virtual const char* getName() const { return "rsubString"; }
virtual unsigned int getArity() const { return 2; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
if (iIndex == 0) return VALUE_EXPRTYPE;
if (iIndex == 1) return VALUE_EXPRTYPE;
return UNKNOWN_EXPRTYPE;
}
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
std::string sText = (*cursor)->getValue(visibility);
++cursor;
std::string sPos = (*cursor)->getValue(visibility);
int iPos = atoi(sPos.c_str());
std::string returnValue = CGRuntime::rsubString(sText, iPos);
return returnValue;
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppString(theCompilerEnvironment);
return STRING_TYPE;
}
virtual bool compileCppString(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "CGRuntime::rsubString(";
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
(*cursor)->compileCppString(theCompilerEnvironment);
CW_BODY_STREAM << ", ";
++cursor;
(*cursor)->compileCppInt(theCompilerEnvironment);
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptRsubString;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptRsubString::_iCounter = 0;
class ExprScriptScanDirectories : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptScanDirectories() {
}
public:
virtual ~ExprScriptScanDirectories() { }
virtual const char* getName() const { return "scanDirectories"; }
virtual unsigned int getArity() const { return 3; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
if (iIndex == 0) return NODE_EXPRTYPE;
if (iIndex == 1) return VALUE_EXPRTYPE;
if (iIndex == 2) return VALUE_EXPRTYPE;
return UNKNOWN_EXPRTYPE;
}
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
DtaScriptVariable* pDirectory = visibility.getVariable(*dynamic_cast<ExprScriptVariable*>(*cursor));
++cursor;
std::string sPath = (*cursor)->getValue(visibility);
++cursor;
std::string sPattern = (*cursor)->getValue(visibility);
bool returnValue = CGRuntime::scanDirectories(pDirectory, sPath, sPattern);
return (returnValue ? "true" : "");
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppBoolean(theCompilerEnvironment, false);
return BOOL_TYPE;
}
virtual bool compileCppBoolean(CppCompilerEnvironment& theCompilerEnvironment, bool bNegative) const {
if (bNegative) CW_BODY_STREAM << "!";
CW_BODY_STREAM << "CGRuntime::scanDirectories(";
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
(*cursor)->compileCpp(theCompilerEnvironment);
CW_BODY_STREAM << ", ";
++cursor;
(*cursor)->compileCppString(theCompilerEnvironment);
CW_BODY_STREAM << ", ";
++cursor;
(*cursor)->compileCppString(theCompilerEnvironment);
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptScanDirectories;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptScanDirectories::_iCounter = 0;
class ExprScriptScanFiles : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptScanFiles() {
}
public:
virtual ~ExprScriptScanFiles() { }
virtual const char* getName() const { return "scanFiles"; }
virtual unsigned int getArity() const { return 4; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
if (iIndex == 0) return NODE_EXPRTYPE;
if (iIndex == 1) return VALUE_EXPRTYPE;
if (iIndex == 2) return VALUE_EXPRTYPE;
if (iIndex == 3) return VALUE_EXPRTYPE;
return UNKNOWN_EXPRTYPE;
}
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
DtaScriptVariable* pFiles = visibility.getVariable(*dynamic_cast<ExprScriptVariable*>(*cursor));
++cursor;
std::string sPath = (*cursor)->getValue(visibility);
++cursor;
std::string sPattern = (*cursor)->getValue(visibility);
++cursor;
std::string sSubfolders = (*cursor)->getValue(visibility);
bool bSubfolders = !sSubfolders.empty();
bool returnValue = CGRuntime::scanFiles(pFiles, sPath, sPattern, bSubfolders);
return (returnValue ? "true" : "");
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppBoolean(theCompilerEnvironment, false);
return BOOL_TYPE;
}
virtual bool compileCppBoolean(CppCompilerEnvironment& theCompilerEnvironment, bool bNegative) const {
if (bNegative) CW_BODY_STREAM << "!";
CW_BODY_STREAM << "CGRuntime::scanFiles(";
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
(*cursor)->compileCpp(theCompilerEnvironment);
CW_BODY_STREAM << ", ";
++cursor;
(*cursor)->compileCppString(theCompilerEnvironment);
CW_BODY_STREAM << ", ";
++cursor;
(*cursor)->compileCppString(theCompilerEnvironment);
CW_BODY_STREAM << ", ";
++cursor;
(*cursor)->compileCppBoolean(theCompilerEnvironment, false);
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptScanFiles;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptScanFiles::_iCounter = 0;
class ExprScriptSendBinaryToSocket : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptSendBinaryToSocket() {
}
public:
virtual ~ExprScriptSendBinaryToSocket() { }
virtual const char* getName() const { return "sendBinaryToSocket"; }
virtual unsigned int getArity() const { return 2; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
if (iIndex == 0) return VALUE_EXPRTYPE;
if (iIndex == 1) return VALUE_EXPRTYPE;
return UNKNOWN_EXPRTYPE;
}
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
std::string sSocket = (*cursor)->getValue(visibility);
int iSocket = atoi(sSocket.c_str());
++cursor;
std::string sBytes = (*cursor)->getValue(visibility);
bool returnValue = CGRuntime::sendBinaryToSocket(iSocket, sBytes);
return (returnValue ? "true" : "");
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppBoolean(theCompilerEnvironment, false);
return BOOL_TYPE;
}
virtual bool compileCppBoolean(CppCompilerEnvironment& theCompilerEnvironment, bool bNegative) const {
if (bNegative) CW_BODY_STREAM << "!";
CW_BODY_STREAM << "CGRuntime::sendBinaryToSocket(";
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
(*cursor)->compileCppInt(theCompilerEnvironment);
CW_BODY_STREAM << ", ";
++cursor;
(*cursor)->compileCppString(theCompilerEnvironment);
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptSendBinaryToSocket;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptSendBinaryToSocket::_iCounter = 0;
class ExprScriptSendHTTPRequest : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptSendHTTPRequest() {
}
public:
virtual ~ExprScriptSendHTTPRequest() { }
virtual const char* getName() const { return "sendHTTPRequest"; }
virtual unsigned int getArity() const { return 2; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
if (iIndex == 0) return VALUE_EXPRTYPE;
if (iIndex == 1) return NODE_EXPRTYPE;
return UNKNOWN_EXPRTYPE;
}
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
std::string sURL = (*cursor)->getValue(visibility);
++cursor;
DtaScriptVariable* pHTTPSession = visibility.getExistingVariable(*dynamic_cast<ExprScriptVariable*>(*cursor));
std::string returnValue = CGRuntime::sendHTTPRequest(sURL, pHTTPSession);
return returnValue;
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppString(theCompilerEnvironment);
return STRING_TYPE;
}
virtual bool compileCppString(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "CGRuntime::sendHTTPRequest(";
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
(*cursor)->compileCppString(theCompilerEnvironment);
CW_BODY_STREAM << ", ";
++cursor;
(*cursor)->compileCpp(theCompilerEnvironment);
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptSendHTTPRequest;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptSendHTTPRequest::_iCounter = 0;
class ExprScriptSendTextToSocket : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptSendTextToSocket() {
}
public:
virtual ~ExprScriptSendTextToSocket() { }
virtual const char* getName() const { return "sendTextToSocket"; }
virtual unsigned int getArity() const { return 2; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
if (iIndex == 0) return VALUE_EXPRTYPE;
if (iIndex == 1) return VALUE_EXPRTYPE;
return UNKNOWN_EXPRTYPE;
}
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
std::string sSocket = (*cursor)->getValue(visibility);
int iSocket = atoi(sSocket.c_str());
++cursor;
std::string sText = (*cursor)->getValue(visibility);
bool returnValue = CGRuntime::sendTextToSocket(iSocket, sText);
return (returnValue ? "true" : "");
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppBoolean(theCompilerEnvironment, false);
return BOOL_TYPE;
}
virtual bool compileCppBoolean(CppCompilerEnvironment& theCompilerEnvironment, bool bNegative) const {
if (bNegative) CW_BODY_STREAM << "!";
CW_BODY_STREAM << "CGRuntime::sendTextToSocket(";
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
(*cursor)->compileCppInt(theCompilerEnvironment);
CW_BODY_STREAM << ", ";
++cursor;
(*cursor)->compileCppString(theCompilerEnvironment);
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptSendTextToSocket;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptSendTextToSocket::_iCounter = 0;
class ExprScriptSelectGenerationTagsHandler : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptSelectGenerationTagsHandler() {
}
public:
virtual ~ExprScriptSelectGenerationTagsHandler() { }
virtual const char* getName() const { return "selectGenerationTagsHandler"; }
virtual unsigned int getArity() const { return 1; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
if (iIndex == 0) return VALUE_EXPRTYPE;
return UNKNOWN_EXPRTYPE;
}
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
std::string sKey = (*cursor)->getValue(visibility);
bool returnValue = CGRuntime::selectGenerationTagsHandler(sKey);
return (returnValue ? "true" : "");
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppBoolean(theCompilerEnvironment, false);
return BOOL_TYPE;
}
virtual bool compileCppBoolean(CppCompilerEnvironment& theCompilerEnvironment, bool bNegative) const {
if (bNegative) CW_BODY_STREAM << "!";
CW_BODY_STREAM << "CGRuntime::selectGenerationTagsHandler(";
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
(*cursor)->compileCppString(theCompilerEnvironment);
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptSelectGenerationTagsHandler;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptSelectGenerationTagsHandler::_iCounter = 0;
class ExprScriptShortToBytes : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptShortToBytes() {
}
public:
virtual ~ExprScriptShortToBytes() { }
virtual const char* getName() const { return "shortToBytes"; }
virtual unsigned int getArity() const { return 1; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
if (iIndex == 0) return VALUE_EXPRTYPE;
return UNKNOWN_EXPRTYPE;
}
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
std::string sShort = (*cursor)->getValue(visibility);
unsigned short ulShort = (unsigned short) atoi(sShort.c_str());
std::string returnValue = CGRuntime::shortToBytes(ulShort);
return returnValue;
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppString(theCompilerEnvironment);
return STRING_TYPE;
}
virtual bool compileCppString(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "CGRuntime::shortToBytes(";
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
(*cursor)->compileCppUnsignedShort(theCompilerEnvironment);
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptShortToBytes;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptShortToBytes::_iCounter = 0;
class ExprScriptSqrt : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptSqrt() {
}
public:
virtual ~ExprScriptSqrt() { }
virtual const char* getName() const { return "sqrt"; }
virtual unsigned int getArity() const { return 1; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
if (iIndex == 0) return VALUE_EXPRTYPE;
return UNKNOWN_EXPRTYPE;
}
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
std::string sX = (*cursor)->getValue(visibility);
double dX = atof(sX.c_str());
double returnValue = CGRuntime::sqrt(dX);
return CGRuntime::toString(returnValue);
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppDouble(theCompilerEnvironment);
return DOUBLE_TYPE;
}
virtual bool compileCppInt(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "(int) ";
return compileCppDouble(theCompilerEnvironment);
}
virtual bool compileCppString(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "CGRuntime::toString(";
bool bSuccess = compileCppDouble(theCompilerEnvironment);
if (bSuccess) CW_BODY_STREAM << ")";
return bSuccess;
}
virtual bool compileCppDouble(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "CGRuntime::sqrt(";
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
(*cursor)->compileCppDouble(theCompilerEnvironment);
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptSqrt;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptSqrt::_iCounter = 0;
class ExprScriptStartString : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptStartString() {
}
public:
virtual ~ExprScriptStartString() { }
virtual const char* getName() const { return "startString"; }
virtual unsigned int getArity() const { return 2; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
if (iIndex == 0) return VALUE_EXPRTYPE;
if (iIndex == 1) return VALUE_EXPRTYPE;
return UNKNOWN_EXPRTYPE;
}
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
std::string sText = (*cursor)->getValue(visibility);
++cursor;
std::string sStart = (*cursor)->getValue(visibility);
bool returnValue = CGRuntime::startString(sText, sStart);
return (returnValue ? "true" : "");
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppBoolean(theCompilerEnvironment, false);
return BOOL_TYPE;
}
virtual bool compileCppBoolean(CppCompilerEnvironment& theCompilerEnvironment, bool bNegative) const {
if (bNegative) CW_BODY_STREAM << "!";
CW_BODY_STREAM << "CGRuntime::startString(";
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
(*cursor)->compileCppString(theCompilerEnvironment);
CW_BODY_STREAM << ", ";
++cursor;
(*cursor)->compileCppString(theCompilerEnvironment);
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptStartString;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptStartString::_iCounter = 0;
class ExprScriptSub : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptSub() {
}
public:
virtual ~ExprScriptSub() { }
virtual const char* getName() const { return "sub"; }
virtual unsigned int getArity() const { return 2; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
if (iIndex == 0) return VALUE_EXPRTYPE;
if (iIndex == 1) return VALUE_EXPRTYPE;
return UNKNOWN_EXPRTYPE;
}
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
std::string sLeft = (*cursor)->getValue(visibility);
double dLeft = atof(sLeft.c_str());
++cursor;
std::string sRight = (*cursor)->getValue(visibility);
double dRight = atof(sRight.c_str());
double returnValue = CGRuntime::sub(dLeft, dRight);
return CGRuntime::toString(returnValue);
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppDouble(theCompilerEnvironment);
return DOUBLE_TYPE;
}
virtual bool compileCppInt(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "(int) ";
return compileCppDouble(theCompilerEnvironment);
}
virtual bool compileCppString(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "CGRuntime::toString(";
bool bSuccess = compileCppDouble(theCompilerEnvironment);
if (bSuccess) CW_BODY_STREAM << ")";
return bSuccess;
}
virtual bool compileCppDouble(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "CGRuntime::sub(";
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
(*cursor)->compileCppDouble(theCompilerEnvironment);
CW_BODY_STREAM << ", ";
++cursor;
(*cursor)->compileCppDouble(theCompilerEnvironment);
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptSub;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptSub::_iCounter = 0;
class ExprScriptSubString : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptSubString() {
}
public:
virtual ~ExprScriptSubString() { }
virtual const char* getName() const { return "subString"; }
virtual unsigned int getArity() const { return 2; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
if (iIndex == 0) return VALUE_EXPRTYPE;
if (iIndex == 1) return VALUE_EXPRTYPE;
return UNKNOWN_EXPRTYPE;
}
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
std::string sText = (*cursor)->getValue(visibility);
++cursor;
std::string sPos = (*cursor)->getValue(visibility);
int iPos = atoi(sPos.c_str());
std::string returnValue = CGRuntime::subString(sText, iPos);
return returnValue;
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppString(theCompilerEnvironment);
return STRING_TYPE;
}
virtual bool compileCppString(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "CGRuntime::subString(";
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
(*cursor)->compileCppString(theCompilerEnvironment);
CW_BODY_STREAM << ", ";
++cursor;
(*cursor)->compileCppInt(theCompilerEnvironment);
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptSubString;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptSubString::_iCounter = 0;
class ExprScriptSup : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptSup() {
}
public:
virtual ~ExprScriptSup() { }
virtual const char* getName() const { return "sup"; }
virtual unsigned int getArity() const { return 2; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
if (iIndex == 0) return VALUE_EXPRTYPE;
if (iIndex == 1) return VALUE_EXPRTYPE;
return UNKNOWN_EXPRTYPE;
}
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
std::string sLeft = (*cursor)->getValue(visibility);
double dLeft = atof(sLeft.c_str());
++cursor;
std::string sRight = (*cursor)->getValue(visibility);
double dRight = atof(sRight.c_str());
bool returnValue = CGRuntime::sup(dLeft, dRight);
return (returnValue ? "true" : "");
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppBoolean(theCompilerEnvironment, false);
return BOOL_TYPE;
}
virtual bool compileCppBoolean(CppCompilerEnvironment& theCompilerEnvironment, bool bNegative) const {
if (bNegative) CW_BODY_STREAM << "!";
CW_BODY_STREAM << "CGRuntime::sup(";
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
(*cursor)->compileCppDouble(theCompilerEnvironment);
CW_BODY_STREAM << ", ";
++cursor;
(*cursor)->compileCppDouble(theCompilerEnvironment);
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptSup;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptSup::_iCounter = 0;
class ExprScriptSystem : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptSystem() {
}
public:
virtual ~ExprScriptSystem() { }
virtual const char* getName() const { return "system"; }
virtual unsigned int getArity() const { return 1; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
if (iIndex == 0) return VALUE_EXPRTYPE;
return UNKNOWN_EXPRTYPE;
}
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
std::string sCommand = (*cursor)->getValue(visibility);
std::string returnValue = CGRuntime::system(sCommand);
return returnValue;
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppString(theCompilerEnvironment);
return STRING_TYPE;
}
virtual bool compileCppString(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "CGRuntime::system(";
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
(*cursor)->compileCppString(theCompilerEnvironment);
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptSystem;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptSystem::_iCounter = 0;
class ExprScriptToLowerString : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptToLowerString() {
}
public:
virtual ~ExprScriptToLowerString() { }
virtual const char* getName() const { return "toLowerString"; }
virtual unsigned int getArity() const { return 1; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
if (iIndex == 0) return VALUE_EXPRTYPE;
return UNKNOWN_EXPRTYPE;
}
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
std::string sText = (*cursor)->getValue(visibility);
std::string returnValue = CGRuntime::toLowerString(sText);
return returnValue;
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppString(theCompilerEnvironment);
return STRING_TYPE;
}
virtual bool compileCppString(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "CGRuntime::toLowerString(";
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
(*cursor)->compileCppString(theCompilerEnvironment);
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptToLowerString;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptToLowerString::_iCounter = 0;
class ExprScriptToUpperString : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptToUpperString() {
}
public:
virtual ~ExprScriptToUpperString() { }
virtual const char* getName() const { return "toUpperString"; }
virtual unsigned int getArity() const { return 1; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
if (iIndex == 0) return VALUE_EXPRTYPE;
return UNKNOWN_EXPRTYPE;
}
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
std::string sText = (*cursor)->getValue(visibility);
std::string returnValue = CGRuntime::toUpperString(sText);
return returnValue;
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppString(theCompilerEnvironment);
return STRING_TYPE;
}
virtual bool compileCppString(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "CGRuntime::toUpperString(";
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
(*cursor)->compileCppString(theCompilerEnvironment);
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptToUpperString;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptToUpperString::_iCounter = 0;
class ExprScriptTranslateString : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptTranslateString(GrfBlock& block) {
//##protect##"translateString::constructor"
_pTranslateString = new GrfTranslate;
_pTranslateString->setParent(&block);
//##protect##"translateString::constructor"
}
private:
//##protect##"translateString::attributes"
GrfTranslate* _pTranslateString;
//##protect##"translateString::attributes"
public:
virtual ~ExprScriptTranslateString() {
//##protect##"translateString::destructor"
delete _pTranslateString;
//##protect##"translateString::destructor"
}
virtual const char* getName() const { return "translateString"; }
virtual unsigned int getArity() const { return 3; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
if (iIndex == 0) return SCRIPTFILE_TRANSLATE_EXPRTYPE;
if (iIndex == 1) return NODE_EXPRTYPE;
if (iIndex == 2) return VALUE_EXPRTYPE;
return UNKNOWN_EXPRTYPE;
}
virtual void initializationDone() {
//##protect##"translateString::initializationDone"
_pTranslateString->setPatternFileName((ExprScriptScriptFile*) _parameters[0]);
_pTranslateString->setThis((ExprScriptVariable*) _parameters[1]);
_pTranslateString->setInputFileName(_parameters[2]);
_parameters = std::vector<ExprScriptExpression*>();
//##protect##"translateString::initializationDone"
}
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
std::string returnValue;
//##protect##"translateString::execute"
returnValue = _pTranslateString->translateString(visibility);
//##protect##"translateString::execute"
return returnValue;
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppString(theCompilerEnvironment);
return STRING_TYPE;
}
virtual bool compileCppString(CppCompilerEnvironment& theCompilerEnvironment) const {
//##protect##"translateString::compileCppString"
//##protect##"translateString::compileCppString"
return true;
}
static ExprScriptFunction* create(GrfBlock& block) {
return new ExprScriptTranslateString(block);
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptTranslateString::_iCounter = 0;
class ExprScriptTrimLeft : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptTrimLeft() {
}
public:
virtual ~ExprScriptTrimLeft() { }
virtual const char* getName() const { return "trimLeft"; }
virtual unsigned int getArity() const { return 1; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
if (iIndex == 0) return NODE_EXPRTYPE;
return UNKNOWN_EXPRTYPE;
}
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
DtaScriptVariable* pString = visibility.getVariable(*dynamic_cast<ExprScriptVariable*>(*cursor));
std::string sString;
const char* tsString = pString->getValue();
if (tsString != NULL) sString = tsString;
int returnValue = CGRuntime::trimLeft(sString);
pString->setValue(sString.c_str());
char tcNumber[16];
sprintf(tcNumber, "%d", returnValue);
return tcNumber;
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppInt(theCompilerEnvironment);
return INT_TYPE;
}
virtual bool compileCppDouble(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "(double) ";
return compileCppInt(theCompilerEnvironment);
}
virtual bool compileCppString(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "CGRuntime::toString(";
bool bSuccess = compileCppInt(theCompilerEnvironment);
if (bSuccess) CW_BODY_STREAM << ")";
return bSuccess;
}
virtual bool compileCppInt(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "CGRuntime::trimLeft(";
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
dynamic_cast<ExprScriptVariable*>(*cursor)->compileCppForSet(theCompilerEnvironment);
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptTrimLeft;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptTrimLeft::_iCounter = 0;
class ExprScriptTrimRight : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptTrimRight() {
}
public:
virtual ~ExprScriptTrimRight() { }
virtual const char* getName() const { return "trimRight"; }
virtual unsigned int getArity() const { return 1; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
if (iIndex == 0) return NODE_EXPRTYPE;
return UNKNOWN_EXPRTYPE;
}
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
DtaScriptVariable* pString = visibility.getVariable(*dynamic_cast<ExprScriptVariable*>(*cursor));
std::string sString;
const char* tsString = pString->getValue();
if (tsString != NULL) sString = tsString;
int returnValue = CGRuntime::trimRight(sString);
pString->setValue(sString.c_str());
char tcNumber[16];
sprintf(tcNumber, "%d", returnValue);
return tcNumber;
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppInt(theCompilerEnvironment);
return INT_TYPE;
}
virtual bool compileCppDouble(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "(double) ";
return compileCppInt(theCompilerEnvironment);
}
virtual bool compileCppString(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "CGRuntime::toString(";
bool bSuccess = compileCppInt(theCompilerEnvironment);
if (bSuccess) CW_BODY_STREAM << ")";
return bSuccess;
}
virtual bool compileCppInt(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "CGRuntime::trimRight(";
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
dynamic_cast<ExprScriptVariable*>(*cursor)->compileCppForSet(theCompilerEnvironment);
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptTrimRight;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptTrimRight::_iCounter = 0;
class ExprScriptTrim : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptTrim() {
}
public:
virtual ~ExprScriptTrim() { }
virtual const char* getName() const { return "trim"; }
virtual unsigned int getArity() const { return 1; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
if (iIndex == 0) return NODE_EXPRTYPE;
return UNKNOWN_EXPRTYPE;
}
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
DtaScriptVariable* pString = visibility.getVariable(*dynamic_cast<ExprScriptVariable*>(*cursor));
std::string sString;
const char* tsString = pString->getValue();
if (tsString != NULL) sString = tsString;
int returnValue = CGRuntime::trim(sString);
pString->setValue(sString.c_str());
char tcNumber[16];
sprintf(tcNumber, "%d", returnValue);
return tcNumber;
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppInt(theCompilerEnvironment);
return INT_TYPE;
}
virtual bool compileCppDouble(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "(double) ";
return compileCppInt(theCompilerEnvironment);
}
virtual bool compileCppString(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "CGRuntime::toString(";
bool bSuccess = compileCppInt(theCompilerEnvironment);
if (bSuccess) CW_BODY_STREAM << ")";
return bSuccess;
}
virtual bool compileCppInt(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "CGRuntime::trim(";
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
dynamic_cast<ExprScriptVariable*>(*cursor)->compileCppForSet(theCompilerEnvironment);
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptTrim;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptTrim::_iCounter = 0;
class ExprScriptTruncateAfterString : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptTruncateAfterString() {
}
public:
virtual ~ExprScriptTruncateAfterString() { }
virtual const char* getName() const { return "truncateAfterString"; }
virtual unsigned int getArity() const { return 2; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
if (iIndex == 0) return NODE_EXPRTYPE;
if (iIndex == 1) return VALUE_EXPRTYPE;
return UNKNOWN_EXPRTYPE;
}
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
DtaScriptVariable* pVariable = visibility.getExistingVariable(*dynamic_cast<ExprScriptVariable*>(*cursor));
++cursor;
std::string sText = (*cursor)->getValue(visibility);
std::string returnValue = CGRuntime::truncateAfterString(pVariable, sText);
return returnValue;
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppString(theCompilerEnvironment);
return STRING_TYPE;
}
virtual bool compileCppString(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "CGRuntime::truncateAfterString(";
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
(*cursor)->compileCpp(theCompilerEnvironment);
CW_BODY_STREAM << ", ";
++cursor;
(*cursor)->compileCppString(theCompilerEnvironment);
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptTruncateAfterString;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptTruncateAfterString::_iCounter = 0;
class ExprScriptTruncateBeforeString : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptTruncateBeforeString() {
}
public:
virtual ~ExprScriptTruncateBeforeString() { }
virtual const char* getName() const { return "truncateBeforeString"; }
virtual unsigned int getArity() const { return 2; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
if (iIndex == 0) return NODE_EXPRTYPE;
if (iIndex == 1) return VALUE_EXPRTYPE;
return UNKNOWN_EXPRTYPE;
}
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
DtaScriptVariable* pVariable = visibility.getExistingVariable(*dynamic_cast<ExprScriptVariable*>(*cursor));
++cursor;
std::string sText = (*cursor)->getValue(visibility);
std::string returnValue = CGRuntime::truncateBeforeString(pVariable, sText);
return returnValue;
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppString(theCompilerEnvironment);
return STRING_TYPE;
}
virtual bool compileCppString(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "CGRuntime::truncateBeforeString(";
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
(*cursor)->compileCpp(theCompilerEnvironment);
CW_BODY_STREAM << ", ";
++cursor;
(*cursor)->compileCppString(theCompilerEnvironment);
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptTruncateBeforeString;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptTruncateBeforeString::_iCounter = 0;
class ExprScriptUUID : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptUUID() {
}
public:
virtual ~ExprScriptUUID() { }
virtual const char* getName() const { return "UUID"; }
virtual unsigned int getArity() const { return 0; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
return UNKNOWN_EXPRTYPE;
}
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
std::string returnValue = CGRuntime::UUID();
return returnValue;
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppString(theCompilerEnvironment);
return STRING_TYPE;
}
virtual bool compileCppString(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "CGRuntime::UUID(";
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptUUID;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptUUID::_iCounter = 0;
class ExprScriptCountInputCols : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptCountInputCols() {
}
public:
virtual ~ExprScriptCountInputCols() { }
virtual const char* getName() const { return "countInputCols"; }
virtual unsigned int getArity() const { return 0; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
return UNKNOWN_EXPRTYPE;
}
virtual bool isAParseFunction() const { return true; }
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
int returnValue = CGRuntime::countInputCols();
char tcNumber[16];
sprintf(tcNumber, "%d", returnValue);
return tcNumber;
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppInt(theCompilerEnvironment);
return INT_TYPE;
}
virtual bool compileCppDouble(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "(double) ";
return compileCppInt(theCompilerEnvironment);
}
virtual bool compileCppString(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "CGRuntime::toString(";
bool bSuccess = compileCppInt(theCompilerEnvironment);
if (bSuccess) CW_BODY_STREAM << ")";
return bSuccess;
}
virtual bool compileCppInt(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "CGRuntime::countInputCols(";
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptCountInputCols;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptCountInputCols::_iCounter = 0;
class ExprScriptCountInputLines : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptCountInputLines() {
}
public:
virtual ~ExprScriptCountInputLines() { }
virtual const char* getName() const { return "countInputLines"; }
virtual unsigned int getArity() const { return 0; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
return UNKNOWN_EXPRTYPE;
}
virtual bool isAParseFunction() const { return true; }
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
int returnValue = CGRuntime::countInputLines();
char tcNumber[16];
sprintf(tcNumber, "%d", returnValue);
return tcNumber;
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppInt(theCompilerEnvironment);
return INT_TYPE;
}
virtual bool compileCppDouble(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "(double) ";
return compileCppInt(theCompilerEnvironment);
}
virtual bool compileCppString(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "CGRuntime::toString(";
bool bSuccess = compileCppInt(theCompilerEnvironment);
if (bSuccess) CW_BODY_STREAM << ")";
return bSuccess;
}
virtual bool compileCppInt(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "CGRuntime::countInputLines(";
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptCountInputLines;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptCountInputLines::_iCounter = 0;
class ExprScriptGetInputFilename : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptGetInputFilename() {
}
public:
virtual ~ExprScriptGetInputFilename() { }
virtual const char* getName() const { return "getInputFilename"; }
virtual unsigned int getArity() const { return 0; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
return UNKNOWN_EXPRTYPE;
}
virtual bool isAParseFunction() const { return true; }
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
std::string returnValue = CGRuntime::getInputFilename();
return returnValue;
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppString(theCompilerEnvironment);
return STRING_TYPE;
}
virtual bool compileCppString(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "CGRuntime::getInputFilename(";
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptGetInputFilename;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptGetInputFilename::_iCounter = 0;
class ExprScriptGetLastReadChars : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptGetLastReadChars() {
}
public:
virtual ~ExprScriptGetLastReadChars() { }
virtual const char* getName() const { return "getLastReadChars"; }
virtual unsigned int getArity() const { return 1; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
if (iIndex == 0) return VALUE_EXPRTYPE;
return UNKNOWN_EXPRTYPE;
}
virtual bool isAParseFunction() const { return true; }
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
std::string sLength = (*cursor)->getValue(visibility);
int iLength = atoi(sLength.c_str());
std::string returnValue = CGRuntime::getLastReadChars(iLength);
return returnValue;
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppString(theCompilerEnvironment);
return STRING_TYPE;
}
virtual bool compileCppString(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "CGRuntime::getLastReadChars(";
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
(*cursor)->compileCppInt(theCompilerEnvironment);
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptGetLastReadChars;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptGetLastReadChars::_iCounter = 0;
class ExprScriptGetInputLocation : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptGetInputLocation() {
}
public:
virtual ~ExprScriptGetInputLocation() { }
virtual const char* getName() const { return "getInputLocation"; }
virtual unsigned int getArity() const { return 0; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
return UNKNOWN_EXPRTYPE;
}
virtual bool isAParseFunction() const { return true; }
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
int returnValue = CGRuntime::getInputLocation();
char tcNumber[16];
sprintf(tcNumber, "%d", returnValue);
return tcNumber;
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppInt(theCompilerEnvironment);
return INT_TYPE;
}
virtual bool compileCppDouble(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "(double) ";
return compileCppInt(theCompilerEnvironment);
}
virtual bool compileCppString(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "CGRuntime::toString(";
bool bSuccess = compileCppInt(theCompilerEnvironment);
if (bSuccess) CW_BODY_STREAM << ")";
return bSuccess;
}
virtual bool compileCppInt(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "CGRuntime::getInputLocation(";
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptGetInputLocation;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptGetInputLocation::_iCounter = 0;
class ExprScriptLookAhead : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptLookAhead() {
}
public:
virtual ~ExprScriptLookAhead() { }
virtual const char* getName() const { return "lookAhead"; }
virtual unsigned int getArity() const { return 1; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
if (iIndex == 0) return VALUE_EXPRTYPE;
return UNKNOWN_EXPRTYPE;
}
virtual bool isAParseFunction() const { return true; }
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
std::string sText = (*cursor)->getValue(visibility);
bool returnValue = CGRuntime::lookAhead(sText);
return (returnValue ? "true" : "");
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppBoolean(theCompilerEnvironment, false);
return BOOL_TYPE;
}
virtual bool compileCppBoolean(CppCompilerEnvironment& theCompilerEnvironment, bool bNegative) const {
if (bNegative) CW_BODY_STREAM << "!";
CW_BODY_STREAM << "CGRuntime::lookAhead(";
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
(*cursor)->compileCppString(theCompilerEnvironment);
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptLookAhead;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptLookAhead::_iCounter = 0;
class ExprScriptPeekChar : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptPeekChar() {
}
public:
virtual ~ExprScriptPeekChar() { }
virtual const char* getName() const { return "peekChar"; }
virtual unsigned int getArity() const { return 0; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
return UNKNOWN_EXPRTYPE;
}
virtual bool isAParseFunction() const { return true; }
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
std::string returnValue = CGRuntime::peekChar();
return returnValue;
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppString(theCompilerEnvironment);
return STRING_TYPE;
}
virtual bool compileCppString(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "CGRuntime::peekChar(";
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptPeekChar;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptPeekChar::_iCounter = 0;
class ExprScriptReadAdaString : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptReadAdaString() {
}
public:
virtual ~ExprScriptReadAdaString() { }
virtual const char* getName() const { return "readAdaString"; }
virtual unsigned int getArity() const { return 1; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
if (iIndex == 0) return NODE_EXPRTYPE;
return UNKNOWN_EXPRTYPE;
}
virtual bool isAParseFunction() const { return true; }
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
DtaScriptVariable* pText = visibility.getVariable(*dynamic_cast<ExprScriptVariable*>(*cursor));
std::string sText;
const char* tsText = pText->getValue();
if (tsText != NULL) sText = tsText;
bool returnValue = CGRuntime::readAdaString(sText);
pText->setValue(sText.c_str());
return (returnValue ? "true" : "");
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppBoolean(theCompilerEnvironment, false);
return BOOL_TYPE;
}
virtual bool compileCppBoolean(CppCompilerEnvironment& theCompilerEnvironment, bool bNegative) const {
if (bNegative) CW_BODY_STREAM << "!";
CW_BODY_STREAM << "CGRuntime::readAdaString(";
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
dynamic_cast<ExprScriptVariable*>(*cursor)->compileCppForSet(theCompilerEnvironment);
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptReadAdaString;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptReadAdaString::_iCounter = 0;
class ExprScriptReadByte : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptReadByte() {
}
public:
virtual ~ExprScriptReadByte() { }
virtual const char* getName() const { return "readByte"; }
virtual unsigned int getArity() const { return 0; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
return UNKNOWN_EXPRTYPE;
}
virtual bool isAParseFunction() const { return true; }
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
std::string returnValue = CGRuntime::readByte();
return returnValue;
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppString(theCompilerEnvironment);
return STRING_TYPE;
}
virtual bool compileCppString(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "CGRuntime::readByte(";
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptReadByte;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptReadByte::_iCounter = 0;
class ExprScriptReadBytes : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptReadBytes() {
}
public:
virtual ~ExprScriptReadBytes() { }
virtual const char* getName() const { return "readBytes"; }
virtual unsigned int getArity() const { return 1; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
if (iIndex == 0) return VALUE_EXPRTYPE;
return UNKNOWN_EXPRTYPE;
}
virtual bool isAParseFunction() const { return true; }
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
std::string sLength = (*cursor)->getValue(visibility);
int iLength = atoi(sLength.c_str());
std::string returnValue = CGRuntime::readBytes(iLength);
return returnValue;
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppString(theCompilerEnvironment);
return STRING_TYPE;
}
virtual bool compileCppString(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "CGRuntime::readBytes(";
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
(*cursor)->compileCppInt(theCompilerEnvironment);
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptReadBytes;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptReadBytes::_iCounter = 0;
class ExprScriptReadCChar : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptReadCChar() {
}
public:
virtual ~ExprScriptReadCChar() { }
virtual const char* getName() const { return "readCChar"; }
virtual unsigned int getArity() const { return 0; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
return UNKNOWN_EXPRTYPE;
}
virtual bool isAParseFunction() const { return true; }
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
std::string returnValue = CGRuntime::readCChar();
return returnValue;
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppString(theCompilerEnvironment);
return STRING_TYPE;
}
virtual bool compileCppString(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "CGRuntime::readCChar(";
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptReadCChar;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptReadCChar::_iCounter = 0;
class ExprScriptReadChar : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptReadChar() {
}
public:
virtual ~ExprScriptReadChar() { }
virtual const char* getName() const { return "readChar"; }
virtual unsigned int getArity() const { return 0; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
return UNKNOWN_EXPRTYPE;
}
virtual bool isAParseFunction() const { return true; }
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
std::string returnValue = CGRuntime::readChar();
return returnValue;
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppString(theCompilerEnvironment);
return STRING_TYPE;
}
virtual bool compileCppString(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "CGRuntime::readChar(";
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptReadChar;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptReadChar::_iCounter = 0;
class ExprScriptReadCharAsInt : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptReadCharAsInt() {
}
public:
virtual ~ExprScriptReadCharAsInt() { }
virtual const char* getName() const { return "readCharAsInt"; }
virtual unsigned int getArity() const { return 0; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
return UNKNOWN_EXPRTYPE;
}
virtual bool isAParseFunction() const { return true; }
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
int returnValue = CGRuntime::readCharAsInt();
char tcNumber[16];
sprintf(tcNumber, "%d", returnValue);
return tcNumber;
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppInt(theCompilerEnvironment);
return INT_TYPE;
}
virtual bool compileCppDouble(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "(double) ";
return compileCppInt(theCompilerEnvironment);
}
virtual bool compileCppString(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "CGRuntime::toString(";
bool bSuccess = compileCppInt(theCompilerEnvironment);
if (bSuccess) CW_BODY_STREAM << ")";
return bSuccess;
}
virtual bool compileCppInt(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "CGRuntime::readCharAsInt(";
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptReadCharAsInt;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptReadCharAsInt::_iCounter = 0;
class ExprScriptReadChars : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptReadChars() {
}
public:
virtual ~ExprScriptReadChars() { }
virtual const char* getName() const { return "readChars"; }
virtual unsigned int getArity() const { return 1; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
if (iIndex == 0) return VALUE_EXPRTYPE;
return UNKNOWN_EXPRTYPE;
}
virtual bool isAParseFunction() const { return true; }
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
std::string sLength = (*cursor)->getValue(visibility);
int iLength = atoi(sLength.c_str());
std::string returnValue = CGRuntime::readChars(iLength);
return returnValue;
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppString(theCompilerEnvironment);
return STRING_TYPE;
}
virtual bool compileCppString(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "CGRuntime::readChars(";
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
(*cursor)->compileCppInt(theCompilerEnvironment);
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptReadChars;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptReadChars::_iCounter = 0;
class ExprScriptReadIdentifier : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptReadIdentifier() {
}
public:
virtual ~ExprScriptReadIdentifier() { }
virtual const char* getName() const { return "readIdentifier"; }
virtual unsigned int getArity() const { return 0; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
return UNKNOWN_EXPRTYPE;
}
virtual bool isAParseFunction() const { return true; }
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
std::string returnValue = CGRuntime::readIdentifier();
return returnValue;
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppString(theCompilerEnvironment);
return STRING_TYPE;
}
virtual bool compileCppString(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "CGRuntime::readIdentifier(";
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptReadIdentifier;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptReadIdentifier::_iCounter = 0;
class ExprScriptReadIfEqualTo : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptReadIfEqualTo() {
}
public:
virtual ~ExprScriptReadIfEqualTo() { }
virtual const char* getName() const { return "readIfEqualTo"; }
virtual unsigned int getArity() const { return 1; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
if (iIndex == 0) return VALUE_EXPRTYPE;
return UNKNOWN_EXPRTYPE;
}
virtual bool isAParseFunction() const { return true; }
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
std::string sText = (*cursor)->getValue(visibility);
bool returnValue = CGRuntime::readIfEqualTo(sText);
return (returnValue ? "true" : "");
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppBoolean(theCompilerEnvironment, false);
return BOOL_TYPE;
}
virtual bool compileCppBoolean(CppCompilerEnvironment& theCompilerEnvironment, bool bNegative) const {
if (bNegative) CW_BODY_STREAM << "!";
CW_BODY_STREAM << "CGRuntime::readIfEqualTo(";
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
(*cursor)->compileCppString(theCompilerEnvironment);
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptReadIfEqualTo;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptReadIfEqualTo::_iCounter = 0;
class ExprScriptReadIfEqualToIgnoreCase : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptReadIfEqualToIgnoreCase() {
}
public:
virtual ~ExprScriptReadIfEqualToIgnoreCase() { }
virtual const char* getName() const { return "readIfEqualToIgnoreCase"; }
virtual unsigned int getArity() const { return 1; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
if (iIndex == 0) return VALUE_EXPRTYPE;
return UNKNOWN_EXPRTYPE;
}
virtual bool isAParseFunction() const { return true; }
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
std::string sText = (*cursor)->getValue(visibility);
bool returnValue = CGRuntime::readIfEqualToIgnoreCase(sText);
return (returnValue ? "true" : "");
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppBoolean(theCompilerEnvironment, false);
return BOOL_TYPE;
}
virtual bool compileCppBoolean(CppCompilerEnvironment& theCompilerEnvironment, bool bNegative) const {
if (bNegative) CW_BODY_STREAM << "!";
CW_BODY_STREAM << "CGRuntime::readIfEqualToIgnoreCase(";
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
(*cursor)->compileCppString(theCompilerEnvironment);
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptReadIfEqualToIgnoreCase;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptReadIfEqualToIgnoreCase::_iCounter = 0;
class ExprScriptReadIfEqualToIdentifier : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptReadIfEqualToIdentifier() {
}
public:
virtual ~ExprScriptReadIfEqualToIdentifier() { }
virtual const char* getName() const { return "readIfEqualToIdentifier"; }
virtual unsigned int getArity() const { return 1; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
if (iIndex == 0) return VALUE_EXPRTYPE;
return UNKNOWN_EXPRTYPE;
}
virtual bool isAParseFunction() const { return true; }
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
std::string sIdentifier = (*cursor)->getValue(visibility);
bool returnValue = CGRuntime::readIfEqualToIdentifier(sIdentifier);
return (returnValue ? "true" : "");
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppBoolean(theCompilerEnvironment, false);
return BOOL_TYPE;
}
virtual bool compileCppBoolean(CppCompilerEnvironment& theCompilerEnvironment, bool bNegative) const {
if (bNegative) CW_BODY_STREAM << "!";
CW_BODY_STREAM << "CGRuntime::readIfEqualToIdentifier(";
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
(*cursor)->compileCppString(theCompilerEnvironment);
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptReadIfEqualToIdentifier;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptReadIfEqualToIdentifier::_iCounter = 0;
class ExprScriptReadLine : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptReadLine() {
}
public:
virtual ~ExprScriptReadLine() { }
virtual const char* getName() const { return "readLine"; }
virtual unsigned int getArity() const { return 1; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
if (iIndex == 0) return NODE_EXPRTYPE;
return UNKNOWN_EXPRTYPE;
}
virtual bool isAParseFunction() const { return true; }
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
DtaScriptVariable* pText = visibility.getVariable(*dynamic_cast<ExprScriptVariable*>(*cursor));
std::string sText;
const char* tsText = pText->getValue();
if (tsText != NULL) sText = tsText;
bool returnValue = CGRuntime::readLine(sText);
pText->setValue(sText.c_str());
return (returnValue ? "true" : "");
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppBoolean(theCompilerEnvironment, false);
return BOOL_TYPE;
}
virtual bool compileCppBoolean(CppCompilerEnvironment& theCompilerEnvironment, bool bNegative) const {
if (bNegative) CW_BODY_STREAM << "!";
CW_BODY_STREAM << "CGRuntime::readLine(";
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
dynamic_cast<ExprScriptVariable*>(*cursor)->compileCppForSet(theCompilerEnvironment);
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptReadLine;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptReadLine::_iCounter = 0;
class ExprScriptReadNextText : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptReadNextText() {
}
public:
virtual ~ExprScriptReadNextText() { }
virtual const char* getName() const { return "readNextText"; }
virtual unsigned int getArity() const { return 1; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
if (iIndex == 0) return VALUE_EXPRTYPE;
return UNKNOWN_EXPRTYPE;
}
virtual bool isAParseFunction() const { return true; }
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
std::string sText = (*cursor)->getValue(visibility);
bool returnValue = CGRuntime::readNextText(sText);
return (returnValue ? "true" : "");
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppBoolean(theCompilerEnvironment, false);
return BOOL_TYPE;
}
virtual bool compileCppBoolean(CppCompilerEnvironment& theCompilerEnvironment, bool bNegative) const {
if (bNegative) CW_BODY_STREAM << "!";
CW_BODY_STREAM << "CGRuntime::readNextText(";
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
(*cursor)->compileCppString(theCompilerEnvironment);
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptReadNextText;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptReadNextText::_iCounter = 0;
class ExprScriptReadNumber : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptReadNumber() {
}
public:
virtual ~ExprScriptReadNumber() { }
virtual const char* getName() const { return "readNumber"; }
virtual unsigned int getArity() const { return 1; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
if (iIndex == 0) return NODE_EXPRTYPE;
return UNKNOWN_EXPRTYPE;
}
virtual bool isAParseFunction() const { return true; }
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
DtaScriptVariable* pNumber = visibility.getVariable(*dynamic_cast<ExprScriptVariable*>(*cursor));
double dNumber = pNumber->getDoubleValue();
bool returnValue = CGRuntime::readNumber(dNumber);
pNumber->setValue(dNumber);
return (returnValue ? "true" : "");
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppBoolean(theCompilerEnvironment, false);
return BOOL_TYPE;
}
virtual bool compileCppBoolean(CppCompilerEnvironment& theCompilerEnvironment, bool bNegative) const {
if (bNegative) CW_BODY_STREAM << "!";
CW_BODY_STREAM << "CGRuntime::readNumber(";
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
dynamic_cast<ExprScriptVariable*>(*cursor)->compileCppForSet(theCompilerEnvironment);
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptReadNumber;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptReadNumber::_iCounter = 0;
class ExprScriptReadPythonString : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptReadPythonString() {
}
public:
virtual ~ExprScriptReadPythonString() { }
virtual const char* getName() const { return "readPythonString"; }
virtual unsigned int getArity() const { return 1; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
if (iIndex == 0) return NODE_EXPRTYPE;
return UNKNOWN_EXPRTYPE;
}
virtual bool isAParseFunction() const { return true; }
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
DtaScriptVariable* pText = visibility.getVariable(*dynamic_cast<ExprScriptVariable*>(*cursor));
std::string sText;
const char* tsText = pText->getValue();
if (tsText != NULL) sText = tsText;
bool returnValue = CGRuntime::readPythonString(sText);
pText->setValue(sText.c_str());
return (returnValue ? "true" : "");
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppBoolean(theCompilerEnvironment, false);
return BOOL_TYPE;
}
virtual bool compileCppBoolean(CppCompilerEnvironment& theCompilerEnvironment, bool bNegative) const {
if (bNegative) CW_BODY_STREAM << "!";
CW_BODY_STREAM << "CGRuntime::readPythonString(";
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
dynamic_cast<ExprScriptVariable*>(*cursor)->compileCppForSet(theCompilerEnvironment);
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptReadPythonString;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptReadPythonString::_iCounter = 0;
class ExprScriptReadString : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptReadString() {
}
public:
virtual ~ExprScriptReadString() { }
virtual const char* getName() const { return "readString"; }
virtual unsigned int getArity() const { return 1; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
if (iIndex == 0) return NODE_EXPRTYPE;
return UNKNOWN_EXPRTYPE;
}
virtual bool isAParseFunction() const { return true; }
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
DtaScriptVariable* pText = visibility.getVariable(*dynamic_cast<ExprScriptVariable*>(*cursor));
std::string sText;
const char* tsText = pText->getValue();
if (tsText != NULL) sText = tsText;
bool returnValue = CGRuntime::readString(sText);
pText->setValue(sText.c_str());
return (returnValue ? "true" : "");
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppBoolean(theCompilerEnvironment, false);
return BOOL_TYPE;
}
virtual bool compileCppBoolean(CppCompilerEnvironment& theCompilerEnvironment, bool bNegative) const {
if (bNegative) CW_BODY_STREAM << "!";
CW_BODY_STREAM << "CGRuntime::readString(";
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
dynamic_cast<ExprScriptVariable*>(*cursor)->compileCppForSet(theCompilerEnvironment);
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptReadString;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptReadString::_iCounter = 0;
class ExprScriptReadUptoJustOneChar : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptReadUptoJustOneChar() {
}
public:
virtual ~ExprScriptReadUptoJustOneChar() { }
virtual const char* getName() const { return "readUptoJustOneChar"; }
virtual unsigned int getArity() const { return 1; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
if (iIndex == 0) return VALUE_EXPRTYPE;
return UNKNOWN_EXPRTYPE;
}
virtual bool isAParseFunction() const { return true; }
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
std::string sOneAmongChars = (*cursor)->getValue(visibility);
std::string returnValue = CGRuntime::readUptoJustOneChar(sOneAmongChars);
return returnValue;
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppString(theCompilerEnvironment);
return STRING_TYPE;
}
virtual bool compileCppString(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "CGRuntime::readUptoJustOneChar(";
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
(*cursor)->compileCppString(theCompilerEnvironment);
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptReadUptoJustOneChar;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptReadUptoJustOneChar::_iCounter = 0;
class ExprScriptReadWord : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptReadWord() {
}
public:
virtual ~ExprScriptReadWord() { }
virtual const char* getName() const { return "readWord"; }
virtual unsigned int getArity() const { return 0; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
return UNKNOWN_EXPRTYPE;
}
virtual bool isAParseFunction() const { return true; }
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
std::string returnValue = CGRuntime::readWord();
return returnValue;
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppString(theCompilerEnvironment);
return STRING_TYPE;
}
virtual bool compileCppString(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "CGRuntime::readWord(";
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptReadWord;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptReadWord::_iCounter = 0;
class ExprScriptSkipBlanks : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptSkipBlanks() {
}
public:
virtual ~ExprScriptSkipBlanks() { }
virtual const char* getName() const { return "skipBlanks"; }
virtual unsigned int getArity() const { return 0; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
return UNKNOWN_EXPRTYPE;
}
virtual bool isAParseFunction() const { return true; }
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
bool returnValue = CGRuntime::skipBlanks();
return (returnValue ? "true" : "");
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppBoolean(theCompilerEnvironment, false);
return BOOL_TYPE;
}
virtual bool compileCppBoolean(CppCompilerEnvironment& theCompilerEnvironment, bool bNegative) const {
if (bNegative) CW_BODY_STREAM << "!";
CW_BODY_STREAM << "CGRuntime::skipBlanks(";
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptSkipBlanks;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptSkipBlanks::_iCounter = 0;
class ExprScriptSkipSpaces : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptSkipSpaces() {
}
public:
virtual ~ExprScriptSkipSpaces() { }
virtual const char* getName() const { return "skipSpaces"; }
virtual unsigned int getArity() const { return 0; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
return UNKNOWN_EXPRTYPE;
}
virtual bool isAParseFunction() const { return true; }
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
bool returnValue = CGRuntime::skipSpaces();
return (returnValue ? "true" : "");
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppBoolean(theCompilerEnvironment, false);
return BOOL_TYPE;
}
virtual bool compileCppBoolean(CppCompilerEnvironment& theCompilerEnvironment, bool bNegative) const {
if (bNegative) CW_BODY_STREAM << "!";
CW_BODY_STREAM << "CGRuntime::skipSpaces(";
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptSkipSpaces;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptSkipSpaces::_iCounter = 0;
class ExprScriptSkipEmptyCpp : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptSkipEmptyCpp() {
}
public:
virtual ~ExprScriptSkipEmptyCpp() { }
virtual const char* getName() const { return "skipEmptyCpp"; }
virtual unsigned int getArity() const { return 0; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
return UNKNOWN_EXPRTYPE;
}
virtual bool isAParseFunction() const { return true; }
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
bool returnValue = CGRuntime::skipEmptyCpp();
return (returnValue ? "true" : "");
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppBoolean(theCompilerEnvironment, false);
return BOOL_TYPE;
}
virtual bool compileCppBoolean(CppCompilerEnvironment& theCompilerEnvironment, bool bNegative) const {
if (bNegative) CW_BODY_STREAM << "!";
CW_BODY_STREAM << "CGRuntime::skipEmptyCpp(";
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptSkipEmptyCpp;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptSkipEmptyCpp::_iCounter = 0;
class ExprScriptSkipEmptyCppExceptDoxygen : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptSkipEmptyCppExceptDoxygen() {
}
public:
virtual ~ExprScriptSkipEmptyCppExceptDoxygen() { }
virtual const char* getName() const { return "skipEmptyCppExceptDoxygen"; }
virtual unsigned int getArity() const { return 0; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
return UNKNOWN_EXPRTYPE;
}
virtual bool isAParseFunction() const { return true; }
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
bool returnValue = CGRuntime::skipEmptyCppExceptDoxygen();
return (returnValue ? "true" : "");
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppBoolean(theCompilerEnvironment, false);
return BOOL_TYPE;
}
virtual bool compileCppBoolean(CppCompilerEnvironment& theCompilerEnvironment, bool bNegative) const {
if (bNegative) CW_BODY_STREAM << "!";
CW_BODY_STREAM << "CGRuntime::skipEmptyCppExceptDoxygen(";
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptSkipEmptyCppExceptDoxygen;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptSkipEmptyCppExceptDoxygen::_iCounter = 0;
class ExprScriptSkipEmptyHTML : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptSkipEmptyHTML() {
}
public:
virtual ~ExprScriptSkipEmptyHTML() { }
virtual const char* getName() const { return "skipEmptyHTML"; }
virtual unsigned int getArity() const { return 0; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
return UNKNOWN_EXPRTYPE;
}
virtual bool isAParseFunction() const { return true; }
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
bool returnValue = CGRuntime::skipEmptyHTML();
return (returnValue ? "true" : "");
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppBoolean(theCompilerEnvironment, false);
return BOOL_TYPE;
}
virtual bool compileCppBoolean(CppCompilerEnvironment& theCompilerEnvironment, bool bNegative) const {
if (bNegative) CW_BODY_STREAM << "!";
CW_BODY_STREAM << "CGRuntime::skipEmptyHTML(";
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptSkipEmptyHTML;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptSkipEmptyHTML::_iCounter = 0;
class ExprScriptSkipEmptyLaTeX : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptSkipEmptyLaTeX() {
}
public:
virtual ~ExprScriptSkipEmptyLaTeX() { }
virtual const char* getName() const { return "skipEmptyLaTeX"; }
virtual unsigned int getArity() const { return 0; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
return UNKNOWN_EXPRTYPE;
}
virtual bool isAParseFunction() const { return true; }
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
bool returnValue = CGRuntime::skipEmptyLaTeX();
return (returnValue ? "true" : "");
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppBoolean(theCompilerEnvironment, false);
return BOOL_TYPE;
}
virtual bool compileCppBoolean(CppCompilerEnvironment& theCompilerEnvironment, bool bNegative) const {
if (bNegative) CW_BODY_STREAM << "!";
CW_BODY_STREAM << "CGRuntime::skipEmptyLaTeX(";
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptSkipEmptyLaTeX;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptSkipEmptyLaTeX::_iCounter = 0;
class ExprScriptCountOutputCols : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptCountOutputCols() {
}
public:
virtual ~ExprScriptCountOutputCols() { }
virtual const char* getName() const { return "countOutputCols"; }
virtual unsigned int getArity() const { return 0; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
return UNKNOWN_EXPRTYPE;
}
virtual bool isAGenerateFunction() const { return true; }
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
int returnValue = CGRuntime::countOutputCols();
char tcNumber[16];
sprintf(tcNumber, "%d", returnValue);
return tcNumber;
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppInt(theCompilerEnvironment);
return INT_TYPE;
}
virtual bool compileCppDouble(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "(double) ";
return compileCppInt(theCompilerEnvironment);
}
virtual bool compileCppString(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "CGRuntime::toString(";
bool bSuccess = compileCppInt(theCompilerEnvironment);
if (bSuccess) CW_BODY_STREAM << ")";
return bSuccess;
}
virtual bool compileCppInt(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "CGRuntime::countOutputCols(";
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptCountOutputCols;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptCountOutputCols::_iCounter = 0;
class ExprScriptCountOutputLines : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptCountOutputLines() {
}
public:
virtual ~ExprScriptCountOutputLines() { }
virtual const char* getName() const { return "countOutputLines"; }
virtual unsigned int getArity() const { return 0; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
return UNKNOWN_EXPRTYPE;
}
virtual bool isAGenerateFunction() const { return true; }
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
int returnValue = CGRuntime::countOutputLines();
char tcNumber[16];
sprintf(tcNumber, "%d", returnValue);
return tcNumber;
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppInt(theCompilerEnvironment);
return INT_TYPE;
}
virtual bool compileCppDouble(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "(double) ";
return compileCppInt(theCompilerEnvironment);
}
virtual bool compileCppString(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "CGRuntime::toString(";
bool bSuccess = compileCppInt(theCompilerEnvironment);
if (bSuccess) CW_BODY_STREAM << ")";
return bSuccess;
}
virtual bool compileCppInt(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "CGRuntime::countOutputLines(";
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptCountOutputLines;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptCountOutputLines::_iCounter = 0;
class ExprScriptDecrementIndentLevel : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptDecrementIndentLevel() {
}
public:
virtual ~ExprScriptDecrementIndentLevel() { }
virtual const char* getName() const { return "decrementIndentLevel"; }
virtual unsigned int getArity() const { return 1; }
virtual unsigned int getMinArity() const { return 0; }
virtual ExprScriptExpression* getDefaultParameter(unsigned int iIndex) const {
static ExprScriptConstant _internallevel(1);
if (iIndex == 0) return &_internallevel;
return NULL;
}
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
if (iIndex == 0) return VALUE_EXPRTYPE;
return UNKNOWN_EXPRTYPE;
}
virtual bool isAGenerateFunction() const { return true; }
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
std::string sLevel = (*cursor)->getValue(visibility);
int iLevel = atoi(sLevel.c_str());
bool returnValue = CGRuntime::decrementIndentLevel(iLevel);
return (returnValue ? "true" : "");
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppBoolean(theCompilerEnvironment, false);
return BOOL_TYPE;
}
virtual bool compileCppBoolean(CppCompilerEnvironment& theCompilerEnvironment, bool bNegative) const {
if (bNegative) CW_BODY_STREAM << "!";
CW_BODY_STREAM << "CGRuntime::decrementIndentLevel(";
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
(*cursor)->compileCppInt(theCompilerEnvironment);
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptDecrementIndentLevel;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptDecrementIndentLevel::_iCounter = 0;
class ExprScriptEqualLastWrittenChars : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptEqualLastWrittenChars() {
}
public:
virtual ~ExprScriptEqualLastWrittenChars() { }
virtual const char* getName() const { return "equalLastWrittenChars"; }
virtual unsigned int getArity() const { return 1; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
if (iIndex == 0) return VALUE_EXPRTYPE;
return UNKNOWN_EXPRTYPE;
}
virtual bool isAGenerateFunction() const { return true; }
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
std::string sText = (*cursor)->getValue(visibility);
bool returnValue = CGRuntime::equalLastWrittenChars(sText);
return (returnValue ? "true" : "");
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppBoolean(theCompilerEnvironment, false);
return BOOL_TYPE;
}
virtual bool compileCppBoolean(CppCompilerEnvironment& theCompilerEnvironment, bool bNegative) const {
if (bNegative) CW_BODY_STREAM << "!";
CW_BODY_STREAM << "CGRuntime::equalLastWrittenChars(";
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
(*cursor)->compileCppString(theCompilerEnvironment);
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptEqualLastWrittenChars;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptEqualLastWrittenChars::_iCounter = 0;
class ExprScriptExistFloatingLocation : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptExistFloatingLocation() {
}
public:
virtual ~ExprScriptExistFloatingLocation() { }
virtual const char* getName() const { return "existFloatingLocation"; }
virtual unsigned int getArity() const { return 2; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
if (iIndex == 0) return VALUE_EXPRTYPE;
if (iIndex == 1) return VALUE_EXPRTYPE;
return UNKNOWN_EXPRTYPE;
}
virtual bool isAGenerateFunction() const { return true; }
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
std::string sKey = (*cursor)->getValue(visibility);
++cursor;
std::string sParent = (*cursor)->getValue(visibility);
bool bParent = !sParent.empty();
bool returnValue = CGRuntime::existFloatingLocation(sKey, bParent);
return (returnValue ? "true" : "");
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppBoolean(theCompilerEnvironment, false);
return BOOL_TYPE;
}
virtual bool compileCppBoolean(CppCompilerEnvironment& theCompilerEnvironment, bool bNegative) const {
if (bNegative) CW_BODY_STREAM << "!";
CW_BODY_STREAM << "CGRuntime::existFloatingLocation(";
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
(*cursor)->compileCppString(theCompilerEnvironment);
CW_BODY_STREAM << ", ";
++cursor;
(*cursor)->compileCppBoolean(theCompilerEnvironment, false);
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptExistFloatingLocation;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptExistFloatingLocation::_iCounter = 0;
class ExprScriptGetFloatingLocation : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptGetFloatingLocation() {
}
public:
virtual ~ExprScriptGetFloatingLocation() { }
virtual const char* getName() const { return "getFloatingLocation"; }
virtual unsigned int getArity() const { return 1; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
if (iIndex == 0) return VALUE_EXPRTYPE;
return UNKNOWN_EXPRTYPE;
}
virtual bool isAGenerateFunction() const { return true; }
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
std::string sKey = (*cursor)->getValue(visibility);
int returnValue = CGRuntime::getFloatingLocation(sKey);
char tcNumber[16];
sprintf(tcNumber, "%d", returnValue);
return tcNumber;
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppInt(theCompilerEnvironment);
return INT_TYPE;
}
virtual bool compileCppDouble(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "(double) ";
return compileCppInt(theCompilerEnvironment);
}
virtual bool compileCppString(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "CGRuntime::toString(";
bool bSuccess = compileCppInt(theCompilerEnvironment);
if (bSuccess) CW_BODY_STREAM << ")";
return bSuccess;
}
virtual bool compileCppInt(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "CGRuntime::getFloatingLocation(";
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
(*cursor)->compileCppString(theCompilerEnvironment);
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptGetFloatingLocation;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptGetFloatingLocation::_iCounter = 0;
class ExprScriptGetLastWrittenChars : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptGetLastWrittenChars() {
}
public:
virtual ~ExprScriptGetLastWrittenChars() { }
virtual const char* getName() const { return "getLastWrittenChars"; }
virtual unsigned int getArity() const { return 1; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
if (iIndex == 0) return VALUE_EXPRTYPE;
return UNKNOWN_EXPRTYPE;
}
virtual bool isAGenerateFunction() const { return true; }
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
std::string sNbChars = (*cursor)->getValue(visibility);
int iNbChars = atoi(sNbChars.c_str());
std::string returnValue = CGRuntime::getLastWrittenChars(iNbChars);
return returnValue;
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppString(theCompilerEnvironment);
return STRING_TYPE;
}
virtual bool compileCppString(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "CGRuntime::getLastWrittenChars(";
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
(*cursor)->compileCppInt(theCompilerEnvironment);
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptGetLastWrittenChars;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptGetLastWrittenChars::_iCounter = 0;
class ExprScriptGetMarkupKey : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptGetMarkupKey() {
}
public:
virtual ~ExprScriptGetMarkupKey() { }
virtual const char* getName() const { return "getMarkupKey"; }
virtual unsigned int getArity() const { return 0; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
return UNKNOWN_EXPRTYPE;
}
virtual bool isAGenerateFunction() const { return true; }
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
std::string returnValue = CGRuntime::getMarkupKey();
return returnValue;
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppString(theCompilerEnvironment);
return STRING_TYPE;
}
virtual bool compileCppString(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "CGRuntime::getMarkupKey(";
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptGetMarkupKey;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptGetMarkupKey::_iCounter = 0;
class ExprScriptGetMarkupValue : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptGetMarkupValue() {
}
public:
virtual ~ExprScriptGetMarkupValue() { }
virtual const char* getName() const { return "getMarkupValue"; }
virtual unsigned int getArity() const { return 0; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
return UNKNOWN_EXPRTYPE;
}
virtual bool isAGenerateFunction() const { return true; }
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
std::string returnValue = CGRuntime::getMarkupValue();
return returnValue;
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppString(theCompilerEnvironment);
return STRING_TYPE;
}
virtual bool compileCppString(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "CGRuntime::getMarkupValue(";
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptGetMarkupValue;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptGetMarkupValue::_iCounter = 0;
class ExprScriptGetOutputFilename : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptGetOutputFilename() {
}
public:
virtual ~ExprScriptGetOutputFilename() { }
virtual const char* getName() const { return "getOutputFilename"; }
virtual unsigned int getArity() const { return 0; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
return UNKNOWN_EXPRTYPE;
}
virtual bool isAGenerateFunction() const { return true; }
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
std::string returnValue = CGRuntime::getOutputFilename();
return returnValue;
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppString(theCompilerEnvironment);
return STRING_TYPE;
}
virtual bool compileCppString(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "CGRuntime::getOutputFilename(";
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptGetOutputFilename;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptGetOutputFilename::_iCounter = 0;
class ExprScriptGetOutputLocation : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptGetOutputLocation() {
}
public:
virtual ~ExprScriptGetOutputLocation() { }
virtual const char* getName() const { return "getOutputLocation"; }
virtual unsigned int getArity() const { return 0; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
return UNKNOWN_EXPRTYPE;
}
virtual bool isAGenerateFunction() const { return true; }
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
int returnValue = CGRuntime::getOutputLocation();
char tcNumber[16];
sprintf(tcNumber, "%d", returnValue);
return tcNumber;
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppInt(theCompilerEnvironment);
return INT_TYPE;
}
virtual bool compileCppDouble(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "(double) ";
return compileCppInt(theCompilerEnvironment);
}
virtual bool compileCppString(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "CGRuntime::toString(";
bool bSuccess = compileCppInt(theCompilerEnvironment);
if (bSuccess) CW_BODY_STREAM << ")";
return bSuccess;
}
virtual bool compileCppInt(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "CGRuntime::getOutputLocation(";
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptGetOutputLocation;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptGetOutputLocation::_iCounter = 0;
class ExprScriptGetProtectedArea : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptGetProtectedArea() {
}
public:
virtual ~ExprScriptGetProtectedArea() { }
virtual const char* getName() const { return "getProtectedArea"; }
virtual unsigned int getArity() const { return 1; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
if (iIndex == 0) return VALUE_EXPRTYPE;
return UNKNOWN_EXPRTYPE;
}
virtual bool isAGenerateFunction() const { return true; }
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
std::string sProtection = (*cursor)->getValue(visibility);
std::string returnValue = CGRuntime::getProtectedArea(sProtection);
return returnValue;
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppString(theCompilerEnvironment);
return STRING_TYPE;
}
virtual bool compileCppString(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "CGRuntime::getProtectedArea(";
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
(*cursor)->compileCppString(theCompilerEnvironment);
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptGetProtectedArea;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptGetProtectedArea::_iCounter = 0;
class ExprScriptGetProtectedAreaKeys : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptGetProtectedAreaKeys() {
}
public:
virtual ~ExprScriptGetProtectedAreaKeys() { }
virtual const char* getName() const { return "getProtectedAreaKeys"; }
virtual unsigned int getArity() const { return 1; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
if (iIndex == 0) return NODE_EXPRTYPE;
return UNKNOWN_EXPRTYPE;
}
virtual bool isAGenerateFunction() const { return true; }
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
DtaScriptVariable* pKeys = visibility.getVariable(*dynamic_cast<ExprScriptVariable*>(*cursor));
int returnValue = CGRuntime::getProtectedAreaKeys(pKeys);
char tcNumber[16];
sprintf(tcNumber, "%d", returnValue);
return tcNumber;
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppInt(theCompilerEnvironment);
return INT_TYPE;
}
virtual bool compileCppDouble(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "(double) ";
return compileCppInt(theCompilerEnvironment);
}
virtual bool compileCppString(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "CGRuntime::toString(";
bool bSuccess = compileCppInt(theCompilerEnvironment);
if (bSuccess) CW_BODY_STREAM << ")";
return bSuccess;
}
virtual bool compileCppInt(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "CGRuntime::getProtectedAreaKeys(";
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
(*cursor)->compileCpp(theCompilerEnvironment);
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptGetProtectedAreaKeys;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptGetProtectedAreaKeys::_iCounter = 0;
class ExprScriptIndentText : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptIndentText() {
}
public:
virtual ~ExprScriptIndentText() { }
virtual const char* getName() const { return "indentText"; }
virtual unsigned int getArity() const { return 1; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
if (iIndex == 0) return VALUE_EXPRTYPE;
return UNKNOWN_EXPRTYPE;
}
virtual bool isAGenerateFunction() const { return true; }
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
std::string sMode = (*cursor)->getValue(visibility);
bool returnValue = CGRuntime::indentText(sMode);
return (returnValue ? "true" : "");
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppBoolean(theCompilerEnvironment, false);
return BOOL_TYPE;
}
virtual bool compileCppBoolean(CppCompilerEnvironment& theCompilerEnvironment, bool bNegative) const {
if (bNegative) CW_BODY_STREAM << "!";
CW_BODY_STREAM << "CGRuntime::indentText(";
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
(*cursor)->compileCppString(theCompilerEnvironment);
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptIndentText;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptIndentText::_iCounter = 0;
class ExprScriptNewFloatingLocation : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptNewFloatingLocation() {
}
public:
virtual ~ExprScriptNewFloatingLocation() { }
virtual const char* getName() const { return "newFloatingLocation"; }
virtual unsigned int getArity() const { return 1; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
if (iIndex == 0) return VALUE_EXPRTYPE;
return UNKNOWN_EXPRTYPE;
}
virtual bool isAGenerateFunction() const { return true; }
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
std::string sKey = (*cursor)->getValue(visibility);
bool returnValue = CGRuntime::newFloatingLocation(sKey);
return (returnValue ? "true" : "");
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppBoolean(theCompilerEnvironment, false);
return BOOL_TYPE;
}
virtual bool compileCppBoolean(CppCompilerEnvironment& theCompilerEnvironment, bool bNegative) const {
if (bNegative) CW_BODY_STREAM << "!";
CW_BODY_STREAM << "CGRuntime::newFloatingLocation(";
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
(*cursor)->compileCppString(theCompilerEnvironment);
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptNewFloatingLocation;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptNewFloatingLocation::_iCounter = 0;
class ExprScriptRemainingProtectedAreas : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptRemainingProtectedAreas() {
}
public:
virtual ~ExprScriptRemainingProtectedAreas() { }
virtual const char* getName() const { return "remainingProtectedAreas"; }
virtual unsigned int getArity() const { return 1; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
if (iIndex == 0) return NODE_EXPRTYPE;
return UNKNOWN_EXPRTYPE;
}
virtual bool isAGenerateFunction() const { return true; }
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
DtaScriptVariable* pKeys = visibility.getVariable(*dynamic_cast<ExprScriptVariable*>(*cursor));
int returnValue = CGRuntime::remainingProtectedAreas(pKeys);
char tcNumber[16];
sprintf(tcNumber, "%d", returnValue);
return tcNumber;
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppInt(theCompilerEnvironment);
return INT_TYPE;
}
virtual bool compileCppDouble(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "(double) ";
return compileCppInt(theCompilerEnvironment);
}
virtual bool compileCppString(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "CGRuntime::toString(";
bool bSuccess = compileCppInt(theCompilerEnvironment);
if (bSuccess) CW_BODY_STREAM << ")";
return bSuccess;
}
virtual bool compileCppInt(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "CGRuntime::remainingProtectedAreas(";
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
(*cursor)->compileCpp(theCompilerEnvironment);
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptRemainingProtectedAreas;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptRemainingProtectedAreas::_iCounter = 0;
class ExprScriptRemoveFloatingLocation : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptRemoveFloatingLocation() {
}
public:
virtual ~ExprScriptRemoveFloatingLocation() { }
virtual const char* getName() const { return "removeFloatingLocation"; }
virtual unsigned int getArity() const { return 1; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
if (iIndex == 0) return VALUE_EXPRTYPE;
return UNKNOWN_EXPRTYPE;
}
virtual bool isAGenerateFunction() const { return true; }
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
std::string sKey = (*cursor)->getValue(visibility);
int returnValue = CGRuntime::removeFloatingLocation(sKey);
char tcNumber[16];
sprintf(tcNumber, "%d", returnValue);
return tcNumber;
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppInt(theCompilerEnvironment);
return INT_TYPE;
}
virtual bool compileCppDouble(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "(double) ";
return compileCppInt(theCompilerEnvironment);
}
virtual bool compileCppString(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "CGRuntime::toString(";
bool bSuccess = compileCppInt(theCompilerEnvironment);
if (bSuccess) CW_BODY_STREAM << ")";
return bSuccess;
}
virtual bool compileCppInt(CppCompilerEnvironment& theCompilerEnvironment) const {
CW_BODY_STREAM << "CGRuntime::removeFloatingLocation(";
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
(*cursor)->compileCppString(theCompilerEnvironment);
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptRemoveFloatingLocation;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptRemoveFloatingLocation::_iCounter = 0;
class ExprScriptRemoveProtectedArea : public ExprScriptFunction {
private:
static unsigned int _iCounter;
ExprScriptRemoveProtectedArea() {
}
public:
virtual ~ExprScriptRemoveProtectedArea() { }
virtual const char* getName() const { return "removeProtectedArea"; }
virtual unsigned int getArity() const { return 1; }
virtual EXPRESSION_TYPE getParameterType(unsigned int iIndex) const {
if (iIndex == 0) return VALUE_EXPRTYPE;
return UNKNOWN_EXPRTYPE;
}
virtual bool isAGenerateFunction() const { return true; }
virtual std::string getValue(DtaScriptVariable& visibility) const {
_iCounter++;
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
std::string sProtectedAreaName = (*cursor)->getValue(visibility);
bool returnValue = CGRuntime::removeProtectedArea(sProtectedAreaName);
return (returnValue ? "true" : "");
}
virtual EXPRESSION_RETURN_TYPE compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
compileCppBoolean(theCompilerEnvironment, false);
return BOOL_TYPE;
}
virtual bool compileCppBoolean(CppCompilerEnvironment& theCompilerEnvironment, bool bNegative) const {
if (bNegative) CW_BODY_STREAM << "!";
CW_BODY_STREAM << "CGRuntime::removeProtectedArea(";
std::vector<ExprScriptExpression*>::const_iterator cursor = _parameters.begin();
(*cursor)->compileCppString(theCompilerEnvironment);
CW_BODY_STREAM << ")";
return true;
}
static ExprScriptFunction* create(GrfBlock&) {
return new ExprScriptRemoveProtectedArea;
}
static void registerFunction(DtaFunctionInfo& info) {
info.constructor = create;
info.pCounter = &_iCounter;
}
};
unsigned int ExprScriptRemoveProtectedArea::_iCounter = 0;
//##end##"declarations"
ExprScriptFunction::ExprScriptFunction(GrfFunction* pPrototype) : _pPrototype(pPrototype), _pTemplate(NULL), _bIsExternal(false) {
}
ExprScriptFunction::~ExprScriptFunction() {
clearParameters();
delete _pTemplate;
}
void ExprScriptFunction::clearParameters() {
for (std::vector<ExprScriptExpression*>::iterator i = _parameters.begin(); i != _parameters.end(); i++) delete (*i);
_parameters = std::vector<ExprScriptExpression*>();
}
std::map<std::string, DtaFunctionInfo>& ExprScriptFunction::getFunctionRegister() {
static std::map<std::string, DtaFunctionInfo> _functionRegister;
static bool _bInitialization = false;
if (!_bInitialization) {
_bInitialization = true;
//##markup##"registration"
//##begin##"registration"
ExprScriptFlushOutputToSocket::registerFunction(_functionRegister["flushOutputToSocket"]);
ExprScriptAcceptSocket::registerFunction(_functionRegister["acceptSocket"]);
ExprScriptAdd::registerFunction(_functionRegister["add"]);
ExprScriptAddGenerationTagsHandler::registerFunction(_functionRegister["addGenerationTagsHandler"]);
ExprScriptAddToDate::registerFunction(_functionRegister["addToDate"]);
ExprScriptByteToChar::registerFunction(_functionRegister["byteToChar"]);
ExprScriptBytesToLong::registerFunction(_functionRegister["bytesToLong"]);
ExprScriptBytesToShort::registerFunction(_functionRegister["bytesToShort"]);
ExprScriptCanonizePath::registerFunction(_functionRegister["canonizePath"]);
ExprScriptChangeDirectory::registerFunction(_functionRegister["changeDirectory"]);
ExprScriptChangeFileTime::registerFunction(_functionRegister["changeFileTime"]);
ExprScriptCharAt::registerFunction(_functionRegister["charAt"]);
ExprScriptCharToByte::registerFunction(_functionRegister["charToByte"]);
ExprScriptCharToInt::registerFunction(_functionRegister["charToInt"]);
ExprScriptChmod::registerFunction(_functionRegister["chmod"]);
ExprScriptCeil::registerFunction(_functionRegister["ceil"]);
ExprScriptCompareDate::registerFunction(_functionRegister["compareDate"]);
ExprScriptCompleteDate::registerFunction(_functionRegister["completeDate"]);
ExprScriptCompleteLeftSpaces::registerFunction(_functionRegister["completeLeftSpaces"]);
ExprScriptCompleteRightSpaces::registerFunction(_functionRegister["completeRightSpaces"]);
ExprScriptComposeAdaLikeString::registerFunction(_functionRegister["composeAdaLikeString"]);
ExprScriptComposeCLikeString::registerFunction(_functionRegister["composeCLikeString"]);
ExprScriptComposeHTMLLikeString::registerFunction(_functionRegister["composeHTMLLikeString"]);
ExprScriptComposeSQLLikeString::registerFunction(_functionRegister["composeSQLLikeString"]);
ExprScriptComputeMD5::registerFunction(_functionRegister["computeMD5"]);
ExprScriptCopySmartFile::registerFunction(_functionRegister["copySmartFile"]);
ExprScriptCoreString::registerFunction(_functionRegister["coreString"]);
ExprScriptCountStringOccurences::registerFunction(_functionRegister["countStringOccurences"]);
ExprScriptCreateDirectory::registerFunction(_functionRegister["createDirectory"]);
ExprScriptCreateINETClientSocket::registerFunction(_functionRegister["createINETClientSocket"]);
ExprScriptCreateINETServerSocket::registerFunction(_functionRegister["createINETServerSocket"]);
ExprScriptCreateIterator::registerFunction(_functionRegister["createIterator"]);
ExprScriptCreateReverseIterator::registerFunction(_functionRegister["createReverseIterator"]);
ExprScriptCreateVirtualFile::registerFunction(_functionRegister["createVirtualFile"]);
ExprScriptCreateVirtualTemporaryFile::registerFunction(_functionRegister["createVirtualTemporaryFile"]);
ExprScriptDecodeURL::registerFunction(_functionRegister["decodeURL"]);
ExprScriptDecrement::registerFunction(_functionRegister["decrement"]);
ExprScriptDeleteFile::registerFunction(_functionRegister["deleteFile"]);
ExprScriptDeleteVirtualFile::registerFunction(_functionRegister["deleteVirtualFile"]);
ExprScriptDiv::registerFunction(_functionRegister["div"]);
ExprScriptDuplicateIterator::registerFunction(_functionRegister["duplicateIterator"]);
ExprScriptEncodeURL::registerFunction(_functionRegister["encodeURL"]);
ExprScriptEndl::registerFunction(_functionRegister["endl"]);
ExprScriptEndString::registerFunction(_functionRegister["endString"]);
ExprScriptEqual::registerFunction(_functionRegister["equal"]);
ExprScriptEqualsIgnoreCase::registerFunction(_functionRegister["equalsIgnoreCase"]);
ExprScriptEqualTrees::registerFunction(_functionRegister["equalTrees"]);
ExprScriptExecuteStringQuiet::registerFunction(_functionRegister["executeStringQuiet"]);
ExprScriptExistDirectory::registerFunction(_functionRegister["existDirectory"]);
ExprScriptExistEnv::registerFunction(_functionRegister["existEnv"]);
ExprScriptExistFile::registerFunction(_functionRegister["existFile"]);
ExprScriptExistVirtualFile::registerFunction(_functionRegister["existVirtualFile"]);
ExprScriptExistVariable::registerFunction(_functionRegister["existVariable"]);
ExprScriptExp::registerFunction(_functionRegister["exp"]);
ExprScriptExploreDirectory::registerFunction(_functionRegister["exploreDirectory"]);
ExprScriptExtractGenerationHeader::registerFunction(_functionRegister["extractGenerationHeader"]);
ExprScriptFileCreation::registerFunction(_functionRegister["fileCreation"]);
ExprScriptFileLastAccess::registerFunction(_functionRegister["fileLastAccess"]);
ExprScriptFileLastModification::registerFunction(_functionRegister["fileLastModification"]);
ExprScriptFileLines::registerFunction(_functionRegister["fileLines"]);
ExprScriptFileMode::registerFunction(_functionRegister["fileMode"]);
ExprScriptFileSize::registerFunction(_functionRegister["fileSize"]);
ExprScriptFindElement::registerFunction(_functionRegister["findElement"]);
ExprScriptFindFirstChar::registerFunction(_functionRegister["findFirstChar"]);
ExprScriptFindFirstSubstringIntoKeys::registerFunction(_functionRegister["findFirstSubstringIntoKeys"]);
ExprScriptFindLastString::registerFunction(_functionRegister["findLastString"]);
ExprScriptFindNextString::registerFunction(_functionRegister["findNextString"]);
ExprScriptFindNextSubstringIntoKeys::registerFunction(_functionRegister["findNextSubstringIntoKeys"]);
ExprScriptFindString::registerFunction(_functionRegister["findString"]);
ExprScriptFirst::registerFunction(_functionRegister["first"]);
ExprScriptFloor::registerFunction(_functionRegister["floor"]);
ExprScriptFormatDate::registerFunction(_functionRegister["formatDate"]);
ExprScriptGetArraySize::registerFunction(_functionRegister["getArraySize"]);
ExprScriptGetCommentBegin::registerFunction(_functionRegister["getCommentBegin"]);
ExprScriptGetCommentEnd::registerFunction(_functionRegister["getCommentEnd"]);
ExprScriptGetCurrentDirectory::registerFunction(_functionRegister["getCurrentDirectory"]);
ExprScriptGetEnv::registerFunction(_functionRegister["getEnv"]);
ExprScriptGetGenerationHeader::registerFunction(_functionRegister["getGenerationHeader"]);
ExprScriptGetHTTPRequest::registerFunction(_functionRegister["getHTTPRequest"]);
ExprScriptGetIncludePath::registerFunction(_functionRegister["getIncludePath"]);
ExprScriptGetLastDelay::registerFunction(_functionRegister["getLastDelay"]);
ExprScriptGetNow::registerFunction(_functionRegister["getNow"]);
ExprScriptGetProperty::registerFunction(_functionRegister["getProperty"]);
ExprScriptGetShortFilename::registerFunction(_functionRegister["getShortFilename"]);
ExprScriptGetTextMode::registerFunction(_functionRegister["getTextMode"]);
ExprScriptGetVariableAttributes::registerFunction(_functionRegister["getVariableAttributes"]);
ExprScriptGetVersion::registerFunction(_functionRegister["getVersion"]);
ExprScriptGetWorkingPath::registerFunction(_functionRegister["getWorkingPath"]);
ExprScriptGetWriteMode::registerFunction(_functionRegister["getWriteMode"]);
ExprScriptHexaToDecimal::registerFunction(_functionRegister["hexaToDecimal"]);
ExprScriptHostToNetworkLong::registerFunction(_functionRegister["hostToNetworkLong"]);
ExprScriptHostToNetworkShort::registerFunction(_functionRegister["hostToNetworkShort"]);
ExprScriptIncrement::registerFunction(_functionRegister["increment"]);
ExprScriptIndentFile::registerFunction(_functionRegister["indentFile"]);
ExprScriptIndex::registerFunction(_functionRegister["index"]);
ExprScriptInf::registerFunction(_functionRegister["inf"]);
ExprScriptInputKey::registerFunction(_functionRegister["inputKey"]);
ExprScriptInputLine::registerFunction(_functionRegister["inputLine"]);
ExprScriptIsEmpty::registerFunction(_functionRegister["isEmpty"]);
ExprScriptIsIdentifier::registerFunction(_functionRegister["isIdentifier"]);
ExprScriptIsNegative::registerFunction(_functionRegister["isNegative"]);
ExprScriptIsNumeric::registerFunction(_functionRegister["isNumeric"]);
ExprScriptIsPositive::registerFunction(_functionRegister["isPositive"]);
ExprScriptJoinStrings::registerFunction(_functionRegister["joinStrings"]);
ExprScriptKey::registerFunction(_functionRegister["key"]);
ExprScriptLast::registerFunction(_functionRegister["last"]);
ExprScriptLeftString::registerFunction(_functionRegister["leftString"]);
ExprScriptLengthString::registerFunction(_functionRegister["lengthString"]);
ExprScriptLoadBinaryFile::registerFunction(_functionRegister["loadBinaryFile"]);
ExprScriptLoadFile::registerFunction(_functionRegister["loadFile"]);
ExprScriptLoadVirtualFile::registerFunction(_functionRegister["loadVirtualFile"]);
ExprScriptLog::registerFunction(_functionRegister["log"]);
ExprScriptLongToBytes::registerFunction(_functionRegister["longToBytes"]);
ExprScriptMidString::registerFunction(_functionRegister["midString"]);
ExprScriptMod::registerFunction(_functionRegister["mod"]);
ExprScriptMult::registerFunction(_functionRegister["mult"]);
ExprScriptNetworkLongToHost::registerFunction(_functionRegister["networkLongToHost"]);
ExprScriptNetworkShortToHost::registerFunction(_functionRegister["networkShortToHost"]);
ExprScriptNext::registerFunction(_functionRegister["next"]);
ExprScriptNot::registerFunction(_functionRegister["not"]);
ExprScriptOctalToDecimal::registerFunction(_functionRegister["octalToDecimal"]);
ExprScriptParseFreeQuiet::registerFunction(_functionRegister["parseFreeQuiet"]);
ExprScriptPathFromPackage::registerFunction(_functionRegister["pathFromPackage"]);
ExprScriptPostHTTPRequest::registerFunction(_functionRegister["postHTTPRequest"]);
ExprScriptPow::registerFunction(_functionRegister["pow"]);
ExprScriptPrec::registerFunction(_functionRegister["prec"]);
ExprScriptRandomInteger::registerFunction(_functionRegister["randomInteger"]);
ExprScriptReceiveBinaryFromSocket::registerFunction(_functionRegister["receiveBinaryFromSocket"]);
ExprScriptReceiveFromSocket::registerFunction(_functionRegister["receiveFromSocket"]);
ExprScriptReceiveTextFromSocket::registerFunction(_functionRegister["receiveTextFromSocket"]);
ExprScriptRelativePath::registerFunction(_functionRegister["relativePath"]);
ExprScriptRemoveDirectory::registerFunction(_functionRegister["removeDirectory"]);
ExprScriptRemoveGenerationTagsHandler::registerFunction(_functionRegister["removeGenerationTagsHandler"]);
ExprScriptRepeatString::registerFunction(_functionRegister["repeatString"]);
ExprScriptReplaceString::registerFunction(_functionRegister["replaceString"]);
ExprScriptReplaceTabulations::registerFunction(_functionRegister["replaceTabulations"]);
ExprScriptResolveFilePath::registerFunction(_functionRegister["resolveFilePath"]);
ExprScriptRightString::registerFunction(_functionRegister["rightString"]);
ExprScriptRsubString::registerFunction(_functionRegister["rsubString"]);
ExprScriptScanDirectories::registerFunction(_functionRegister["scanDirectories"]);
ExprScriptScanFiles::registerFunction(_functionRegister["scanFiles"]);
ExprScriptSendBinaryToSocket::registerFunction(_functionRegister["sendBinaryToSocket"]);
ExprScriptSendHTTPRequest::registerFunction(_functionRegister["sendHTTPRequest"]);
ExprScriptSendTextToSocket::registerFunction(_functionRegister["sendTextToSocket"]);
ExprScriptSelectGenerationTagsHandler::registerFunction(_functionRegister["selectGenerationTagsHandler"]);
ExprScriptShortToBytes::registerFunction(_functionRegister["shortToBytes"]);
ExprScriptSqrt::registerFunction(_functionRegister["sqrt"]);
ExprScriptStartString::registerFunction(_functionRegister["startString"]);
ExprScriptSub::registerFunction(_functionRegister["sub"]);
ExprScriptSubString::registerFunction(_functionRegister["subString"]);
ExprScriptSup::registerFunction(_functionRegister["sup"]);
ExprScriptSystem::registerFunction(_functionRegister["system"]);
ExprScriptToLowerString::registerFunction(_functionRegister["toLowerString"]);
ExprScriptToUpperString::registerFunction(_functionRegister["toUpperString"]);
ExprScriptTranslateString::registerFunction(_functionRegister["translateString"]);
ExprScriptTrimLeft::registerFunction(_functionRegister["trimLeft"]);
ExprScriptTrimRight::registerFunction(_functionRegister["trimRight"]);
ExprScriptTrim::registerFunction(_functionRegister["trim"]);
ExprScriptTruncateAfterString::registerFunction(_functionRegister["truncateAfterString"]);
ExprScriptTruncateBeforeString::registerFunction(_functionRegister["truncateBeforeString"]);
ExprScriptUUID::registerFunction(_functionRegister["UUID"]);
ExprScriptCountInputCols::registerFunction(_functionRegister["countInputCols"]);
ExprScriptCountInputLines::registerFunction(_functionRegister["countInputLines"]);
ExprScriptGetInputFilename::registerFunction(_functionRegister["getInputFilename"]);
ExprScriptGetLastReadChars::registerFunction(_functionRegister["getLastReadChars"]);
ExprScriptGetInputLocation::registerFunction(_functionRegister["getInputLocation"]);
ExprScriptLookAhead::registerFunction(_functionRegister["lookAhead"]);
ExprScriptPeekChar::registerFunction(_functionRegister["peekChar"]);
ExprScriptReadAdaString::registerFunction(_functionRegister["readAdaString"]);
ExprScriptReadByte::registerFunction(_functionRegister["readByte"]);
ExprScriptReadBytes::registerFunction(_functionRegister["readBytes"]);
ExprScriptReadCChar::registerFunction(_functionRegister["readCChar"]);
ExprScriptReadChar::registerFunction(_functionRegister["readChar"]);
ExprScriptReadCharAsInt::registerFunction(_functionRegister["readCharAsInt"]);
ExprScriptReadChars::registerFunction(_functionRegister["readChars"]);
ExprScriptReadIdentifier::registerFunction(_functionRegister["readIdentifier"]);
ExprScriptReadIfEqualTo::registerFunction(_functionRegister["readIfEqualTo"]);
ExprScriptReadIfEqualToIgnoreCase::registerFunction(_functionRegister["readIfEqualToIgnoreCase"]);
ExprScriptReadIfEqualToIdentifier::registerFunction(_functionRegister["readIfEqualToIdentifier"]);
ExprScriptReadLine::registerFunction(_functionRegister["readLine"]);
ExprScriptReadNextText::registerFunction(_functionRegister["readNextText"]);
ExprScriptReadNumber::registerFunction(_functionRegister["readNumber"]);
ExprScriptReadPythonString::registerFunction(_functionRegister["readPythonString"]);
ExprScriptReadString::registerFunction(_functionRegister["readString"]);
ExprScriptReadUptoJustOneChar::registerFunction(_functionRegister["readUptoJustOneChar"]);
ExprScriptReadWord::registerFunction(_functionRegister["readWord"]);
ExprScriptSkipBlanks::registerFunction(_functionRegister["skipBlanks"]);
ExprScriptSkipSpaces::registerFunction(_functionRegister["skipSpaces"]);
ExprScriptSkipEmptyCpp::registerFunction(_functionRegister["skipEmptyCpp"]);
ExprScriptSkipEmptyCppExceptDoxygen::registerFunction(_functionRegister["skipEmptyCppExceptDoxygen"]);
ExprScriptSkipEmptyHTML::registerFunction(_functionRegister["skipEmptyHTML"]);
ExprScriptSkipEmptyLaTeX::registerFunction(_functionRegister["skipEmptyLaTeX"]);
ExprScriptCountOutputCols::registerFunction(_functionRegister["countOutputCols"]);
ExprScriptCountOutputLines::registerFunction(_functionRegister["countOutputLines"]);
ExprScriptDecrementIndentLevel::registerFunction(_functionRegister["decrementIndentLevel"]);
ExprScriptEqualLastWrittenChars::registerFunction(_functionRegister["equalLastWrittenChars"]);
ExprScriptExistFloatingLocation::registerFunction(_functionRegister["existFloatingLocation"]);
ExprScriptGetFloatingLocation::registerFunction(_functionRegister["getFloatingLocation"]);
ExprScriptGetLastWrittenChars::registerFunction(_functionRegister["getLastWrittenChars"]);
ExprScriptGetMarkupKey::registerFunction(_functionRegister["getMarkupKey"]);
ExprScriptGetMarkupValue::registerFunction(_functionRegister["getMarkupValue"]);
ExprScriptGetOutputFilename::registerFunction(_functionRegister["getOutputFilename"]);
ExprScriptGetOutputLocation::registerFunction(_functionRegister["getOutputLocation"]);
ExprScriptGetProtectedArea::registerFunction(_functionRegister["getProtectedArea"]);
ExprScriptGetProtectedAreaKeys::registerFunction(_functionRegister["getProtectedAreaKeys"]);
ExprScriptIndentText::registerFunction(_functionRegister["indentText"]);
ExprScriptNewFloatingLocation::registerFunction(_functionRegister["newFloatingLocation"]);
ExprScriptRemainingProtectedAreas::registerFunction(_functionRegister["remainingProtectedAreas"]);
ExprScriptRemoveFloatingLocation::registerFunction(_functionRegister["removeFloatingLocation"]);
ExprScriptRemoveProtectedArea::registerFunction(_functionRegister["removeProtectedArea"]);
//##end##"registration"
}
return _functionRegister;
}
void ExprScriptFunction::addParameter(ExprScriptExpression* pParameter) {
_parameters.push_back(pParameter);
}
EXPRESSION_TYPE ExprScriptFunction::getParameterType(unsigned int iIndex) const {
if (_pPrototype != NULL) return _pPrototype->getParameterType(iIndex);
return UNKNOWN_EXPRTYPE;
}
ExprScriptExpression* ExprScriptFunction::getDefaultParameter(unsigned int iIndex) const {
if (_pPrototype != NULL) return _pPrototype->getDefaultParameter(iIndex);
return NULL;
}
unsigned int ExprScriptFunction::getArity() const {
if (_pPrototype != NULL) return _pPrototype->getArity();
throw UtlException("internal error in ExprScriptFunction::getArity(): this case shouldn't occur");
}
unsigned int ExprScriptFunction::getMinArity() const {
if (_pPrototype != NULL) return _pPrototype->getMinArity();
return getArity();
}
const char* ExprScriptFunction::getName() const {
if (_pPrototype != NULL) return _pPrototype->getFunctionName();
throw UtlException("internal error in ExprScriptFunction::getName(): this case shouldn't occur");
}
int ExprScriptFunction::getThisPosition() const { return 0; }
void ExprScriptFunction::initializationDone() {}
std::string ExprScriptFunction::getValue(DtaScriptVariable& visibility) const {
if (_pTemplate != NULL) {
std::string sInstantiationKey = _pTemplate->getValue(visibility);
GrfFunction* pFunction = _pPrototype->getInstantiatedFunction(visibility, sInstantiationKey);
if (pFunction != NULL) return pFunction->launchExecution(visibility, *this, sInstantiationKey);
throw UtlException("template function '" + _pPrototype->getName() + "<\"" + sInstantiationKey + "\">' hasn't been implemented");
}
if (_pPrototype == NULL) throw UtlException("ExprScriptFunction::getValue() -> must be implemented into derivated classes\nFor custom functions, see class GrfFunction");
return _pPrototype->launchExecution(visibility, *this);
}
ExprScriptFunction* ExprScriptFunction::create(GrfBlock& block, ScpStream& script, const std::string& sFunction, const std::string& sTemplate, bool bGenericKey) {
ExprScriptFunction* pFunction = NULL;
int iArity = -1;
std::string sFunctionName;
//##markup##"create::deprecated"
//##begin##"create::deprecated"
if (sFunction == "getVariableSize") {
std::string sErrorMessage = "warning: function 'getVariableSize' has been deprecated since version 1.30 -> replace it by function 'getArraySize'" + CGRuntime::endl();
sErrorMessage += DtaProject::getInstance().getTraceStack(script);
if (DtaProject::getInstance().addWarning(sErrorMessage) == 1) CGRuntime::traceLine(sErrorMessage);
sFunctionName = "getArraySize";
} else if (sFunction == "today") {
std::string sErrorMessage = "warning: function 'today' has been deprecated since version 2.09 -> replace it by function 'getNow'" + CGRuntime::endl();
sErrorMessage += DtaProject::getInstance().getTraceStack(script);
if (DtaProject::getInstance().addWarning(sErrorMessage) == 1) CGRuntime::traceLine(sErrorMessage);
sFunctionName = "getNow";
} else if (sFunction == "getDefineTarget") {
std::string sErrorMessage = "warning: function 'getDefineTarget' has been deprecated since version 1.30 -> replace it by function 'getProperty'" + CGRuntime::endl();
sErrorMessage += DtaProject::getInstance().getTraceStack(script);
if (DtaProject::getInstance().addWarning(sErrorMessage) == 1) CGRuntime::traceLine(sErrorMessage);
sFunctionName = "getProperty";
} else if (sFunction == "trimLeftString") {
std::string sErrorMessage = "warning: function 'trimLeftString' has been deprecated since version 1.40 -> replace it by function 'trimLeft'" + CGRuntime::endl();
sErrorMessage += DtaProject::getInstance().getTraceStack(script);
if (DtaProject::getInstance().addWarning(sErrorMessage) == 1) CGRuntime::traceLine(sErrorMessage);
sFunctionName = "trimLeft";
} else if (sFunction == "trimRightString") {
std::string sErrorMessage = "warning: function 'trimRightString' has been deprecated since version 1.40 -> replace it by function 'trimRight'" + CGRuntime::endl();
sErrorMessage += DtaProject::getInstance().getTraceStack(script);
if (DtaProject::getInstance().addWarning(sErrorMessage) == 1) CGRuntime::traceLine(sErrorMessage);
sFunctionName = "trimRight";
} else if (sFunction == "trimString") {
std::string sErrorMessage = "warning: function 'trimString' has been deprecated since version 1.40 -> replace it by function 'trim'" + CGRuntime::endl();
sErrorMessage += DtaProject::getInstance().getTraceStack(script);
if (DtaProject::getInstance().addWarning(sErrorMessage) == 1) CGRuntime::traceLine(sErrorMessage);
sFunctionName = "trim";
} else if (sFunction == "readLastChars") {
std::string sErrorMessage = "warning: function 'readLastChars' has been deprecated since version 1.30 -> replace it by function 'getLastReadChars'" + CGRuntime::endl();
sErrorMessage += DtaProject::getInstance().getTraceStack(script);
if (DtaProject::getInstance().addWarning(sErrorMessage) == 1) CGRuntime::traceLine(sErrorMessage);
sFunctionName = "getLastReadChars";
} else if (sFunction == "getLocation") {
std::string sErrorMessage = "warning: function 'getLocation' has been deprecated since version 3.7.1 -> replace it by function 'getInputLocation'" + CGRuntime::endl();
sErrorMessage += DtaProject::getInstance().getTraceStack(script);
if (DtaProject::getInstance().addWarning(sErrorMessage) == 1) CGRuntime::traceLine(sErrorMessage);
sFunctionName = "getInputLocation";
} else if (sFunction == "getMarkerKey") {
std::string sErrorMessage = "warning: function 'getMarkerKey' has been deprecated since version 2.14 -> replace it by function 'getMarkupKey'" + CGRuntime::endl();
sErrorMessage += DtaProject::getInstance().getTraceStack(script);
if (DtaProject::getInstance().addWarning(sErrorMessage) == 1) CGRuntime::traceLine(sErrorMessage);
sFunctionName = "getMarkupKey";
//##end##"create::deprecated"
} else sFunctionName = sFunction;
if (getFunctionRegister().find(sFunctionName) != getFunctionRegister().end()) {
if (!sTemplate.empty()) throw UtlException("predefined function '" + sFunction + "' cannot instantiate template function '" + sFunction + "<" + sTemplate + ">'");
pFunction = getFunctionRegister()[sFunctionName].constructor(block);
} else {
GrfFunction* pPrototype = block.getFunction(sFunctionName, sTemplate, bGenericKey);
if (pPrototype != NULL) {
pFunction = new ExprScriptFunction(pPrototype);
}
}
return pFunction;
}
ExprScriptFunction* ExprScriptFunction::createMethod(GrfBlock& block, ScpStream& script, const std::string& sFunction, const std::string& sTemplate, bool bGenericKey) {
//##markup##"createMethod"
//##begin##"createMethod"
if (sFunction == "size") return create(block, script, "getArraySize", sTemplate, bGenericKey);
if (sFunction == "length") return create(block, script, "lengthString", sTemplate, bGenericKey);
if (sFunction == "empty") return create(block, script, "isEmpty", sTemplate, bGenericKey);
//##end##"createMethod"
return create(block, script, sFunction, sTemplate, bGenericKey);
}
void ExprScriptFunction::clearCounters() {
for (std::map<std::string, DtaFunctionInfo>::iterator i = getFunctionRegister().begin(); i != getFunctionRegister().end(); i++) {
*(i->second.pCounter) = 0;
}
}
EXPRESSION_RETURN_TYPE ExprScriptFunction::compileCpp(CppCompilerEnvironment& theCompilerEnvironment) const {
bool bDispatchedYet = true;
if (_pPrototype != NULL) {
if (_pPrototype->isATemplateInstantiation()) {
CW_BODY_STREAM << DtaScript::convertFilenameAsIdentifier(CppCompilerEnvironment::getRadical(theCompilerEnvironment.getFunctionModule(_pPrototype->getFunctionName()))) << "::_compilerTemplateFunction_" << _pPrototype->getFunctionName() << "_compilerInstantiation_";
ExprScriptConstant* pConstant = dynamic_cast<ExprScriptConstant*>(_pTemplate);
DtaScriptVariable visibility;
if ((pConstant != NULL) && !pConstant->getConstant().empty() && (_pPrototype->getInstantiatedFunction(visibility, pConstant->getConstant()) != NULL)) {
CW_BODY_STREAM << theCompilerEnvironment.convertTemplateKey(pConstant->getConstant()) << "(";
} else {
CW_BODY_STREAM << "(";
_pTemplate->compileCppString(theCompilerEnvironment);
bDispatchedYet = false;
}
} else {
_pPrototype->compileCppFunctionNameForCalling(theCompilerEnvironment);
CW_BODY_STREAM << "(";
}
} else CW_BODY_STREAM << "CGRuntime::" << getName() << "(";
int iIndex = 0;
for (std::vector<ExprScriptExpression*>::const_iterator i = _parameters.begin(); i != _parameters.end(); i++) {
if ((i != _parameters.begin()) || !bDispatchedYet) CW_BODY_STREAM << ", ";
if ((getParameterType(iIndex) & 0x00FF) == VALUE_EXPRTYPE) (*i)->compileCpp(theCompilerEnvironment);
else dynamic_cast<ExprScriptVariable*>(*i)->compileCppForSet(theCompilerEnvironment);
iIndex++;
}
CW_BODY_STREAM << ")";
return STRING_TYPE;
}
bool ExprScriptFunction::compileCppBoolean(CppCompilerEnvironment& theCompilerEnvironment, bool bNegative) const {
if (!bNegative) CW_BODY_STREAM << "!";
compileCpp(theCompilerEnvironment);
CW_BODY_STREAM << ".empty()";
return (_pPrototype != NULL);
}
bool ExprScriptFunction::compileCppString(CppCompilerEnvironment& theCompilerEnvironment) const {
ScpStream* pOwner;
int iInsertAreaLocation = CW_BODY_STREAM.getFloatingLocation("INSERT AREA", pOwner);
int iLocation = CW_BODY_STREAM.getOutputLocation();
EXPRESSION_RETURN_TYPE returnType = compileCpp(theCompilerEnvironment);
if (returnType != STRING_TYPE) {
CW_BODY_STREAM.insertText("CGRuntime::toString(", iLocation + (CW_BODY_STREAM.getFloatingLocation("INSERT AREA", pOwner) - iInsertAreaLocation));
CW_BODY_STREAM << ")";
}
return (_pPrototype != NULL);
}
std::string ExprScriptFunction::toString() const {
std::string sSerialize;
if (_pPrototype != NULL) sSerialize = _pPrototype->getFunctionName();
else sSerialize = getName();
if (_pTemplate != NULL) sSerialize += "<" + _pTemplate->toString() + ">";
sSerialize += "(";
int iIndex = 0;
for (std::vector<ExprScriptExpression*>::const_iterator i = _parameters.begin(); i != _parameters.end(); i++) {
if (i != _parameters.begin()) sSerialize += ", ";
sSerialize += (*i)->toString();
iIndex++;
}
return sSerialize + ")";
}
}
| [
"cedric.p.r.lemaire@28b3f5f3-d42e-7560-b87f-5f53cf622bc4"
] | cedric.p.r.lemaire@28b3f5f3-d42e-7560-b87f-5f53cf622bc4 |
e53f1aefb818dd2e257f088c6f610b41186f3eae | 6a69d57c782e0b1b993e876ad4ca2927a5f2e863 | /vendor/samsung/common/packages/apps/SBrowser/src/chrome/common/url_constants.h | 090c529fb92707222396696caa9782463de2be76 | [
"BSD-3-Clause"
] | permissive | duki994/G900H-Platform-XXU1BOA7 | c8411ef51f5f01defa96b3381f15ea741aa5bce2 | 4f9307e6ef21893c9a791c96a500dfad36e3b202 | refs/heads/master | 2020-05-16T20:57:07.585212 | 2015-05-11T11:03:16 | 2015-05-11T11:03:16 | 35,418,464 | 2 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 20,880 | h | // Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Contains constants for known URLs and portions thereof.
#ifndef CHROME_COMMON_URL_CONSTANTS_H_
#define CHROME_COMMON_URL_CONSTANTS_H_
#include <string>
#include <vector>
#include "build/build_config.h"
#include "content/public/common/url_constants.h"
namespace chrome {
// chrome: URLs (including schemes). Should be kept in sync with the
// components below.
extern const char kChromeUIAboutURL[];
extern const char kChromeUIAppsURL[];
extern const char kChromeUIAppListStartPageURL[];
extern const char kChromeUIBookmarksURL[];
extern const char kChromeUICertificateViewerURL[];
extern const char kChromeUIChromeSigninURL[];
extern const char kChromeUIChromeURLsURL[];
extern const char kChromeUICloudPrintResourcesURL[];
extern const char kChromeUIComponentsURL[];
extern const char kChromeUIConflictsURL[];
extern const char kChromeUIConstrainedHTMLTestURL[];
extern const char kChromeUICrashesURL[];
extern const char kChromeUICreditsURL[];
extern const char kChromeUIDevicesURL[];
extern const char kChromeUIDevToolsURL[];
extern const char kChromeUIDownloadsURL[];
extern const char kChromeUIEditSearchEngineDialogURL[];
extern const char kChromeUIExtensionIconURL[];
extern const char kChromeUIExtensionInfoURL[];
extern const char kChromeUIExtensionsFrameURL[];
extern const char kChromeUIExtensionsURL[];
extern const char kChromeUIFaviconURL[];
extern const char kChromeUIFeedbackURL[];
extern const char kChromeUIFlagsURL[];
extern const char kChromeUIFlashURL[];
extern const char kChromeUIGCMInternalsURL[];
extern const char kChromeUIHelpFrameURL[];
extern const char kChromeUIHistoryURL[];
extern const char kChromeUIHistoryFrameURL[];
extern const char kChromeUIIdentityInternalsURL[];
extern const char kChromeUIInspectURL[];
extern const char kChromeUIInstantURL[];
extern const char kChromeUIInvalidationsURL[];
extern const char kChromeUIIPCURL[];
extern const char kChromeUIManagedUserPassphrasePageURL[];
extern const char kChromeUIMemoryRedirectURL[];
extern const char kChromeUIMemoryURL[];
extern const char kChromeUIMetroFlowURL[];
extern const char kChromeUINaClURL[];
extern const char kChromeUINetInternalsURL[];
extern const char kChromeUINewProfile[];
extern const char kChromeUINewTabURL[];
#if defined(ENABLE_WEBUI_OMNIBOX)
extern const char kChromeUIOmniboxURL[];
#endif
extern const char kChromeUIPerformanceMonitorURL[];
extern const char kChromeUIPluginsURL[];
extern const char kChromeUIPolicyURL[];
extern const char kChromeUIProfileSigninConfirmationURL[];
extern const char kChromeUIUserManagerURL[];
extern const char kChromeUIPrintURL[];
extern const char kChromeUIQuitURL[];
extern const char kChromeUIRestartURL[];
extern const char kChromeUISessionFaviconURL[];
extern const char kChromeUISettingsURL[];
extern const char kChromeUISettingsFrameURL[];
extern const char kChromeUISuggestionsInternalsURL[];
extern const char kChromeUISSLClientCertificateSelectorURL[];
extern const char kChromeUITaskManagerURL[];
extern const char kChromeUITermsURL[];
extern const char kChromeUIThemeURL[];
extern const char kChromeUIThumbnailURL[];
extern const char kChromeUIThumbnailListURL[];
extern const char kChromeUIUberURL[];
extern const char kChromeUIUberFrameURL[];
extern const char kChromeUIUserActionsURL[];
extern const char kChromeUIVersionURL[];
#if defined(OS_ANDROID)
extern const char kChromeUINativeNewTabURL[];
#if !defined(S_NATIVE_SUPPORT)
extern const char kChromeUIWelcomeURL[];
#endif
#endif
#if defined(OS_CHROMEOS)
extern const char kChromeUIActivationMessage[];
extern const char kChromeUIBluetoothPairingURL[];
extern const char kChromeUIChargerReplacementURL[];
extern const char kChromeUIChooseMobileNetworkURL[];
extern const char kChromeUIDiagnosticsURL[];
extern const char kChromeUIDiscardsURL[];
extern const char kChromeUIFirstRunURL[];
extern const char kChromeUIIdleLogoutDialogURL[];
extern const char kChromeUIImageBurnerURL[];
extern const char kChromeUIKeyboardOverlayURL[];
extern const char kChromeUILockScreenURL[];
extern const char kChromeUIMediaplayerURL[];
extern const char kChromeUIMobileSetupURL[];
extern const char kChromeUINfcDebugURL[];
extern const char kChromeUIOobeURL[];
extern const char kChromeUIOSCreditsURL[];
extern const char kChromeUIProxySettingsURL[];
extern const char kChromeUIScreenlockIconURL[];
extern const char kChromeUISimUnlockURL[];
extern const char kChromeUISlideshowURL[];
extern const char kChromeUISlowURL[];
extern const char kChromeUISystemInfoURL[];
extern const char kChromeUITermsOemURL[];
extern const char kChromeUIUserImageURL[];
#endif
#if defined(USE_AURA)
extern const char kChromeUIGestureConfigURL[];
extern const char kChromeUIGestureConfigHost[];
extern const char kChromeUISalsaURL[];
extern const char kChromeUISalsaHost[];
#endif
#if (defined(OS_LINUX) && defined(TOOLKIT_VIEWS)) || defined(USE_AURA)
extern const char kChromeUITabModalConfirmDialogURL[];
#endif
#if defined(ENABLE_WEBRTC)
extern const char kChromeUIWebRtcLogsURL[];
#endif
// chrome components of URLs. Should be kept in sync with the full URLs above.
extern const char kChromeUIAboutHost[];
extern const char kChromeUIAboutPageFrameHost[];
extern const char kChromeUIBlankHost[];
extern const char kChromeUIAppLauncherPageHost[];
extern const char kChromeUIAppListStartPageHost[];
extern const char kChromeUIBookmarksHost[];
extern const char kChromeUICacheHost[];
extern const char kChromeUICertificateViewerHost[];
extern const char kChromeUIChromeSigninHost[];
extern const char kChromeUIChromeURLsHost[];
extern const char kChromeUICloudPrintResourcesHost[];
extern const char kChromeUICloudPrintSetupHost[];
extern const char kChromeUIConflictsHost[];
extern const char kChromeUIConstrainedHTMLTestHost[];
extern const char kChromeUICrashesHost[];
extern const char kChromeUICrashHost[];
extern const char kChromeUICreditsHost[];
extern const char kChromeUIDefaultHost[];
extern const char kChromeUIDevicesHost[];
extern const char kChromeUIDevToolsHost[];
extern const char kChromeUIDevToolsBundledPath[];
extern const char kChromeUIDevToolsRemotePath[];
extern const char kChromeUIDNSHost[];
extern const char kChromeUIDownloadsHost[];
extern const char kChromeUIDriveInternalsHost[];
extern const char kChromeUIEditSearchEngineDialogHost[];
extern const char kChromeUIEnhancedBookmarksHost[];
extern const char kChromeUIExtensionIconHost[];
extern const char kChromeUIExtensionInfoHost[];
extern const char kChromeUIExtensionsFrameHost[];
extern const char kChromeUIExtensionsHost[];
extern const char kChromeUIFaviconHost[];
extern const char kChromeUIFeedbackHost[];
extern const char kChromeUIFlagsHost[];
extern const char kChromeUIFlashHost[];
extern const char kChromeUIGCMInternalsHost[];
extern const char kChromeUIHelpFrameHost[];
extern const char kChromeUIHelpHost[];
extern const char kChromeUIHangHost[];
extern const char kChromeUIHistoryHost[];
extern const char kChromeUIHistoryFrameHost[];
extern const char kChromeUIIdentityInternalsHost[];
extern const char kChromeUIInspectHost[];
extern const char kChromeUIInstantHost[];
extern const char kChromeUIInvalidationsHost[];
extern const char kChromeUIIPCHost[];
extern const char kChromeUIKillHost[];
extern const char kChromeUIManagedUserPassphrasePageHost[];
extern const char kChromeUIMemoryHost[];
extern const char kChromeUIMemoryInternalsHost[];
extern const char kChromeUIMemoryRedirectHost[];
extern const char kChromeUIMetroFlowHost[];
extern const char kChromeUINaClHost[];
extern const char kChromeUINetExportHost[];
extern const char kChromeUINetInternalsHost[];
extern const char kChromeUINewTabHost[];
#if defined(ENABLE_WEBUI_OMNIBOX)
extern const char kChromeUIOmniboxHost[];
#endif
extern const char kChromeUIPerformanceMonitorHost[];
extern const char kChromeUIPluginsHost[];
extern const char kChromeUIComponentsHost[];
extern const char kChromeUIPolicyHost[];
extern const char kChromeUIProfileSigninConfirmationHost[];
extern const char kChromeUIUserManagerHost[];
extern const char kChromeUIPredictorsHost[];
extern const char kChromeUIPrintHost[];
extern const char kChromeUIProfilerHost[];
extern const char kChromeUIQuotaInternalsHost[];
extern const char kChromeUIQuitHost[];
extern const char kChromeUIRestartHost[];
extern const char kChromeUISessionFaviconHost[];
extern const char kChromeUISettingsHost[];
extern const char kChromeUISettingsFrameHost[];
extern const char kChromeUIShorthangHost[];
extern const char kChromeUISignInInternalsHost[];
extern const char kChromeUISuggestionsInternalsHost[];
extern const char kChromeUISSLClientCertificateSelectorHost[];
extern const char kChromeUIStatsHost[];
extern const char kChromeUISyncHost[];
extern const char kChromeUISyncFileSystemInternalsHost[];
extern const char kChromeUISyncInternalsHost[];
extern const char kChromeUISyncResourcesHost[];
extern const char kChromeUISystemInfoHost[];
extern const char kChromeUITaskManagerHost[];
extern const char kChromeUITermsHost[];
extern const char kChromeUIThemeHost[];
extern const char kChromeUIThumbnailHost[];
extern const char kChromeUIThumbnailHost2[];
extern const char kChromeUIThumbnailListHost[];
extern const char kChromeUITouchIconHost[];
extern const char kChromeUITranslateInternalsHost[];
extern const char kChromeUIUberFrameHost[];
extern const char kChromeUIUberHost[];
extern const char kChromeUIUserActionsHost[];
extern const char kChromeUIVersionHost[];
extern const char kChromeUIWorkersHost[];
extern const char kChromeUIScreenshotPath[];
extern const char kChromeUIThemePath[];
#if defined(OS_ANDROID) && !defined(S_NATIVE_SUPPORT)
extern const char kChromeUIWelcomeHost[];
#endif
#if defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_ANDROID)
extern const char kChromeUILinuxProxyConfigHost[];
extern const char kChromeUISandboxHost[];
#endif
#if defined(OS_CHROMEOS)
extern const char kChromeUIActivationMessageHost[];
extern const char kChromeUIAppLaunchHost[];
extern const char kChromeUIBluetoothPairingHost[];
extern const char kChromeUIChargerReplacementHost[];
extern const char kChromeUIChooseMobileNetworkHost[];
extern const char kChromeUICryptohomeHost[];
extern const char kChromeUIDiagnosticsHost[];
extern const char kChromeUIDiscardsHost[];
extern const char kChromeUIFirstRunHost[];
extern const char kChromeUIIdleLogoutDialogHost[];
extern const char kChromeUIImageBurnerHost[];
extern const char kChromeUIKeyboardOverlayHost[];
extern const char kChromeUILockScreenHost[];
extern const char kChromeUILoginContainerHost[];
extern const char kChromeUILoginHost[];
extern const char kChromeUIMediaplayerHost[];
extern const char kChromeUIMobileSetupHost[];
extern const char kChromeUINetworkHost[];
extern const char kChromeUINfcDebugHost[];
extern const char kChromeUIOobeHost[];
extern const char kChromeUIOSCreditsHost[];
extern const char kChromeUIPowerHost[];
extern const char kChromeUIProxySettingsHost[];
extern const char kChromeUIRotateHost[];
extern const char kChromeUIScreenlockIconHost[];
extern const char kChromeUISimUnlockHost[];
extern const char kChromeUISlideshowHost[];
extern const char kChromeUISlowHost[];
extern const char kChromeUISlowTraceHost[];
extern const char kChromeUIUserImageHost[];
extern const char kChromeUIMenu[];
extern const char kChromeUINetworkMenu[];
extern const char kChromeUIWrenchMenu[];
extern const char kEULAPathFormat[];
extern const char kOemEulaURLPath[];
extern const char kOnlineEulaURLPath[];
#endif
#if (defined(OS_LINUX) && defined(TOOLKIT_VIEWS)) || defined(USE_AURA)
extern const char kChromeUITabModalConfirmDialogHost[];
#endif
#if defined(ENABLE_WEBRTC)
extern const char kChromeUIWebRtcLogsHost[];
#endif
// Options sub-pages.
extern const char kAutofillSubPage[];
extern const char kClearBrowserDataSubPage[];
extern const char kContentSettingsExceptionsSubPage[];
extern const char kContentSettingsSubPage[];
extern const char kCreateProfileSubPage[];
extern const char kExtensionsSubPage[];
extern const char kHandlerSettingsSubPage[];
extern const char kImportDataSubPage[];
extern const char kLanguageOptionsSubPage[];
extern const char kManagedUserSettingsSubPage[];
extern const char kManageProfileSubPage[];
extern const char kPasswordManagerSubPage[];
extern const char kResetProfileSettingsSubPage[];
extern const char kSearchEnginesSubPage[];
extern const char kSearchSubPage[];
extern const char kSearchUsersSubPage[];
extern const char kSyncSetupSubPage[];
#if defined(OS_CHROMEOS)
extern const char kInternetOptionsSubPage[];
extern const char kBluetoothAddDeviceSubPage[];
extern const char kChangeProfilePictureSubPage[];
#endif
// Extensions sub pages.
extern const char kExtensionConfigureCommandsSubPage[];
// URLs used to indicate that an extension resource load request
// was invalid.
extern const char kExtensionInvalidRequestURL[];
extern const char kExtensionResourceInvalidRequestURL[];
extern const char kSyncGoogleDashboardURL[];
// "Learn more" URL for the auto password generation.
extern const char kAutoPasswordGenerationLearnMoreURL[];
extern const char kPasswordManagerLearnMoreURL[];
// General help links for Chrome, opened using various actions.
extern const char kChromeHelpViaKeyboardURL[];
extern const char kChromeHelpViaMenuURL[];
extern const char kChromeHelpViaWebUIURL[];
#if defined(OS_CHROMEOS)
// Accessibility help link for Chrome.
extern const char kChromeAccessibilityHelpURL[];
// Accessibility settings link for Chrome.
extern const char kChromeAccessibilitySettingsURL[];
#endif
#if defined (ENABLE_ONE_CLICK_SIGNIN)
// "Learn more" URL for the one click signin infobar.
extern const char kChromeSyncLearnMoreURL[];
// "Learn more" URL for the "Sign in with a different account" confirmation
// dialog.
extern const char kChromeSyncMergeTroubleshootingURL[];
#endif
// "Learn more" URL for the enterprise sign-in confirmation dialog.
extern const char kChromeEnterpriseSignInLearnMoreURL[];
// "Learn more" URL for resetting profile preferences.
extern const char kResetProfileSettingsLearnMoreURL[];
// "Learn more" URL for when profile settings are automatically reset.
extern const char kAutomaticSettingsResetLearnMoreURL[];
// Management URL for the supervised users.
extern const char kSupervisedUserManagementURL[];
// Management URL for the supervised users - version without scheme, used
// for display.
extern const char kSupervisedUserManagementDisplayURL[];
// Help URL for the settings page's search feature.
extern const char kSettingsSearchHelpURL[];
// "About" URL for the translate bar's options menu.
extern const char kAboutGoogleTranslateURL[];
// Help URL for the Omnibox setting.
extern const char kOmniboxLearnMoreURL[];
// "What do these mean?" URL for the Page Info bubble.
extern const char kPageInfoHelpCenterURL[];
// "Learn more" URL for "Aw snap" page.
extern const char kCrashReasonURL[];
// "Learn more" URL for killed tab page.
extern const char kKillReasonURL[];
// "Learn more" URL for the Privacy section under Options.
extern const char kPrivacyLearnMoreURL[];
// "Learn more" URL for the "Do not track" setting in the privacy section.
extern const char kDoNotTrackLearnMoreURL[];
#if defined(OS_CHROMEOS)
// These URLs are currently ChromeOS only.
// "Learn more" URL for the attestation of content protection setting.
extern const char kAttestationForContentProtectionLearnMoreURL[];
// "Learn more" URL for the enhanced playback notification dialog.
extern const char kEnhancedPlaybackNotificationLearnMoreURL[];
#endif
// The URL for the Chromium project used in the About dialog.
extern const char kChromiumProjectURL[];
// The URL for the "Learn more" page for the usage/crash reporting option in the
// first run dialog.
extern const char kLearnMoreReportingURL[];
// The URL for the "Learn more" page for the outdated plugin infobar.
extern const char kOutdatedPluginLearnMoreURL[];
// The URL for the "Learn more" page for the blocked plugin infobar.
extern const char kBlockedPluginLearnMoreURL[];
// The URL for the "About Voice Recognition" menu item.
extern const char kSpeechInputAboutURL[];
// The URL for the "Learn more" page for hotword search voice trigger.
extern const char kHotwordLearnMoreURL[];
// The URL for the "Learn more" page for register protocol handler infobars.
extern const char kLearnMoreRegisterProtocolHandlerURL[];
// The URL for the "Learn more" page for sync setup on the personal stuff page.
extern const char kSyncLearnMoreURL[];
// The URL for the "Learn more" page for download scanning.
extern const char kDownloadScanningLearnMoreURL[];
// The URL for the "Learn more" page for interrupted downloads.
extern const char kDownloadInterruptedLearnMoreURL[];
// The URL for the "Learn more" page on the sync setup dialog, when syncing
// everything.
extern const char kSyncEverythingLearnMoreURL[];
// The URL for information on how to use the app launcher.
extern const char kAppLauncherHelpURL[];
// The URL for the "Learn more" page on sync encryption.
extern const char kSyncEncryptionHelpURL[];
// The URL for the "Learn more" link when there is a sync error.
extern const char kSyncErrorsHelpURL[];
#if defined(OS_CHROMEOS)
// The URL for the "Learn more" link for natural scrolling on ChromeOS.
extern const char kNaturalScrollHelpURL[];
// The URL for the Learn More page about enterprise enrolled devices.
extern const char kLearnMoreEnterpriseURL[];
#endif
// The URL for the Learn More link of the non-CWS bubble.
extern const char kRemoveNonCWSExtensionURL[];
extern const char kNotificationsHelpURL[];
// The Welcome Notification More Info URL.
extern const char kNotificationWelcomeLearnMoreURL[];
// Gets the hosts/domains that are shown in chrome://chrome-urls.
extern const char* const kChromeHostURLs[];
extern const size_t kNumberOfChromeHostURLs;
// "Debug" pages which are dangerous and not for general consumption.
extern const char* const kChromeDebugURLs[];
extern const int kNumberOfChromeDebugURLs;
// The chrome-native: scheme is used show pages rendered with platform specific
// widgets instead of using HTML.
extern const char kChromeNativeScheme[];
// The chrome-search: scheme is served by the same backend as chrome:. However,
// only specific URLDataSources are enabled to serve requests via the
// chrome-search: scheme. See |InstantIOContext::ShouldServiceRequest| and its
// callers for details. Note that WebUIBindings should never be granted to
// chrome-search: pages. chrome-search: pages are displayable but not readable
// by external search providers (that are rendered by Instant renderer
// processes), and neither displayable nor readable by normal (non-Instant) web
// pages. To summarize, a non-Instant process, when trying to access
// 'chrome-search://something', will bump up against the following:
//
// 1. Renderer: The display-isolated check in WebKit will deny the request,
// 2. Browser: Assuming they got by #1, the scheme checks in
// URLDataSource::ShouldServiceRequest will deny the request,
// 3. Browser: for specific sub-classes of URLDataSource, like ThemeSource
// there are additional Instant-PID checks that make sure the request is
// coming from a blessed Instant process, and deny the request.
extern const char kChromeSearchScheme[];
// Pages under chrome-search.
extern const char kChromeSearchLocalNtpHost[];
extern const char kChromeSearchLocalNtpUrl[];
extern const char kChromeSearchRemoteNtpHost[];
// Host and URL for most visited iframes used on the Instant Extended NTP.
extern const char kChromeSearchMostVisitedHost[];
extern const char kChromeSearchMostVisitedUrl[];
#if defined(OS_CHROMEOS)
extern const char kCrosScheme[];
extern const char kDriveScheme[];
#endif
// Scheme for the DOM Distiller component.
extern const char kDomDistillerScheme[];
// "Learn more" URL for the Cloud Print section under Options.
extern const char kCloudPrintLearnMoreURL[];
// "Learn more" URL for the Cloud Print Preview No Destinations Promotion.
extern const char kCloudPrintNoDestinationsLearnMoreURL[];
// Parameters that get appended to force SafeSearch.
extern const char kSafeSearchSafeParameter[];
extern const char kSafeSearchSsuiParameter[];
// The URL for the "Learn more" link in the media access infobar.
extern const char kMediaAccessLearnMoreUrl[];
// The URL for the "Learn more" link in the language settings.
extern const char kLanguageSettingsLearnMoreUrl[];
#if defined(OS_MACOSX)
// The URL for the 32-bit Mac deprecation help center article
extern const char kMac32BitDeprecationURL[];
#endif
#if defined(S_NATIVE_SUPPORT)
extern const char kReadingListPageURI[];
#endif // S_NATIVE_SUPPORT
} // namespace chrome
#endif // CHROME_COMMON_URL_CONSTANTS_H_
| [
"duki994@gmail.com"
] | duki994@gmail.com |
b386923a549a822fbac5c9b3cd93b6718869b349 | 2ccc32b50d365dc24842832338e8e70d4cb82d5b | /include/qvm_cuda.h | 553477de5cbbe54200e1560c4c029ab395e91fcb | [
"MIT"
] | permissive | MatthiasMichael/Geometry | 30779c7db311a0f4e3f37e356f25c9679eedf35e | d2308a39a8a2c693dbe4bc10260a352358ea291d | refs/heads/master | 2020-05-25T12:47:08.392849 | 2020-01-16T21:03:31 | 2020-01-16T21:03:31 | 187,806,508 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,751 | h | #pragma once
#include <boost/qvm/mat_traits.hpp>
#include <boost/qvm/vec_traits.hpp>
namespace boost
{
namespace qvm
{
namespace detail
{
template <typename scalar_type>
struct type_picker{ };
template<>
struct type_picker<float> { using type = float3; };
template<>
struct type_picker<double> { using type = double3; };
template<typename _scalar_type>
struct cuda_vec3_traits
{
static int const dim = 3;
using scalar_type = _scalar_type;
using Vec = typename type_picker<scalar_type>::type;
template<int I>
static inline scalar_type & write_element(Vec & v)
{
switch (I)
{
case 0: return v.x;
case 1: return v.y;
case 2: return v.z;
default: throw std::runtime_error("Wrong dim.");
}
}
template <int I>
static inline scalar_type read_element(Vec const & v)
{
switch (I)
{
case 0: return v.x;
case 1: return v.y;
case 2: return v.z;
default: throw std::runtime_error("Wrong dim.");
}
}
static inline scalar_type & write_element_idx(int i, Vec & v)
{
switch(i)
{
case 0: return v.x;
case 1: return v.y;
case 2: return v.z;
default: throw std::runtime_error("Wrong dim.");
}
} //optional
static inline scalar_type read_element_idx(int i, Vec const & v)
{
switch (i)
{
case 0: return v.x;
case 1: return v.y;
case 2: return v.z;
default: throw std::runtime_error("Wrong dim.");
}
} //optional
};
}
template<>
struct vec_traits<float3> : detail::cuda_vec3_traits<float>
{
};
template<>
struct vec_traits<double3> : detail::cuda_vec3_traits<double>
{
};
}
} | [
"matthias.michael@rub.de"
] | matthias.michael@rub.de |
39f3706c5ea51f84d2d323dd9d5a1e62db5595c6 | 7715ebc4a923709b7e5e1f4343fea386b0c8ad6c | /server/Configure.hpp | 586468b420fb7cae3abdb7d45465606d0ca9dd33 | [] | no_license | ongonginging/service | 09547dcb2adef77ea7404ccbdbee62f46f6f85ef | deb45be884aaf44d4081ad64c82d960538333eb4 | refs/heads/master | 2020-07-08T02:24:56.383443 | 2015-10-10T08:46:10 | 2015-10-10T08:46:10 | 40,586,888 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 767 | hpp |
#ifndef __CONFIGURE_HPP__
#define __CONFIGURE_HPP__
#include <map>
#include <memory>
#include <iostream>
class Configure{
private:
std::string className = "Configure";
std::string configFile;
std::map<std::string, std::string> configure;
public:
Configure();
Configure(bool flags);
Configure(std::string& configFile);
#if 1
~Configure(void);
#else
virtual ~Configure();
#endif
void set(const std::string& key, const std::string& value);
bool get(const std::string& key, std::string& value);
bool parseFromConfigFile();
};
class Test:public Configure{
private:
public:
Test();
Test(bool flags);
~Test();
};
#endif //__CONFIGURE_HPP__
| [
"ongonginging@gmail.com"
] | ongonginging@gmail.com |
6694d4625d1a254243e19570961f8473987e8fe5 | 3e39c4f9ecccc3a721025ca7842530cd5166d441 | /examples/custom-help.cpp | 8742590c1907f1117f4a2a757834748e24b615f0 | [
"MIT"
] | permissive | wlodzislav/args | 4a32b4b032334781a2fe55c83bfef90166ad6f2d | 793a87701e9e703db5044d2e1878a5668fa83fe5 | refs/heads/master | 2020-04-26T04:11:19.901372 | 2019-03-01T17:12:42 | 2019-03-01T18:07:43 | 173,293,287 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,881 | cpp | #include <stdexcept>
#include <iostream>
#include <string>
#include <cstdlib>
#include "../args.h"
using std::vector;
int main(int argc, const char** argv) {
auto a = ""s;
auto b = ""s;
auto c = ""s;
auto d = ""s;
auto carg1 = ""s;
auto crest = std::vector<std::string>{};
args::parser p = args::parser{}
.name("cli-cmd")
.command_required()
.option("-a", "Global option A", &a)
.option("-b", "--bb", "Global option B", &b);
p.command("list", "l", "List command")
.arg(args::required, "carg1", "List command arg1", &carg1)
.rest("crest", "List command rest args", &crest)
.option("-c", "Option C", &c)
.option(args::required, "-d", "--dd", "Option D", &d);
p.command("get", "g", "Get command")
.arg(args::required, "smt", "What to get", &carg1)
.option("-h", "How to get", &c);
p.help([&]() {
auto ind = " "s;
std::cout << "NAME\n";
std::cout << ind << "cli-cmd - Command that does nothing\n";
std::cout << "\n";
std::cout << "SYNOPSIS\n";
std::cout << p.format_usage(ind);
std::cout << "\n";
std::cout << "DESCRIPTION\n";
std::cout << ind << "Command that does nothing and more of nothing\n";
std::cout << "\n";
std::cout << "OPTIONS\n";
std::cout << p.format_options(ind);
std::cout << "\n";
std::cout << "COMMANDS\n";
std::cout << ind << "list - List something\n";
std::cout << p.format_command_usage("list", ind + ind);
std::cout << "\n";
std::cout << p.format_command_args("list", ind + ind);
std::cout << "\n";
std::cout << p.format_command_options("list", ind + ind);
std::cout << "\n";
std::cout << ind << "get - Get something\n";
std::cout << p.format_command_usage("get", ind + ind);
std::cout << "\n";
std::cout << p.format_command_args("get", ind + ind);
std::cout << "\n";
std::cout << p.format_command_options("get", ind + ind);
std::exit(0);
});
p.parse(argc, argv);
}
| [
"wlodzislav@ya.ru"
] | wlodzislav@ya.ru |
b40e34cb5a22151c0c17829320c7ac721abe02d5 | 1b60b1776df95e5769c868927840acf813fdd4f0 | /beginner/Array_Fill_III.cpp | f592faeb74295bafd03dd12c2bff8810fb88f189 | [] | no_license | paolocarrara/uri | 6d6bd6a06335b8a0ca9cf0278c40e4772a886ca1 | 3cd7f291a7dffcbeba85cf28015351a3863f0f5b | refs/heads/master | 2020-06-04T07:44:14.766159 | 2014-10-07T18:48:06 | 2014-10-07T18:48:06 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 171 | cpp | #include <stdio.h>
int main (void)
{
double n;
int i;
scanf ("%lf", &n);
for (i = 0; i < 100; i++, n /= 2.0) {
printf ("N[%i] = %0.4lf\n", i, n);
}
return 0;
}
| [
"paolocarraratux@gmail.com"
] | paolocarraratux@gmail.com |
f4af303fa390e7586b46a40638fde0edaf415f9d | e6559df51c2a14256962c3757073a491ea66de7c | /SPOJ/ARRAYSUB - subarrays.cpp | 02b374480d79c3b32989cefecadd4620fc818c12 | [] | no_license | Maycon708/Maratona | c30eaedc3ee39d69582b0ed1a60f31ad8d666d43 | b6d07582544c230e67c23a20e1a1be99d4b47576 | refs/heads/master | 2020-04-25T23:37:53.992330 | 2019-02-28T17:10:25 | 2019-02-28T17:10:25 | 143,191,679 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,676 | cpp | #include <bits/stdc++.h>
#define INF 0x3F3F3F3F
#define rep(i, a, b) for (int i = int(a); i < int(b); i++)
#define pb push_back
#define pi 3.1415926535897932384626433832795028841971
#define debug(x) cout << #x << " = " << x << endl;
#define debug2(x,y) cout << #x << " = " << x << " --- " << #y << " " << y << "\n";
#define debugM( x, l, c ) { rep( i, 0, l ){ rep( j, 0, c ) printf("%d ", x[i][j]); printf("\n");}}
#define all(S) (S).begin(), (S).end()
#define MAXV 1010000
#define MAXN 110
#define F first
#define S second
#define EPS 1e-9
#define mk make_pair
using namespace std;
typedef pair <int, int> ii;
typedef long long int ll;
int vet[500001];
int SEG[4*500001];
void build_tree(int node, int i, int j)
{
if (i == j)
{
SEG[node] = vet [i];
return;
}
int left = 2 * node;
int right = 2 * node + 1;
build_tree(left, i, (i + j)/2);
build_tree(right, 1 + (i + j)/2, j);
SEG[node] = max( SEG[left], SEG[right] );
}
int query(int node, int i, int j, int a, int b)
{
if (i > b || j < a || i > j) return -INF;
if (i >= a && j <= b) return SEG[node];
int left = 2 * node;
int right = 2 * node + 1;
int q1 = query(left, i, (i + j)/2, a, b);
int q2 = query(right, (i + j)/2 + 1, j, a, b);
return max( q1, q2 );
}
int main(){
int n, k;
while( scanf("%d", &n ) != EOF ){
rep( i, 0, n ) scanf("%d", &vet[i] );
build_tree( 1, 0, n );
scanf("%d", &k );
rep( i, 0, n-k ){
printf("%d ", query( 1, 0, n, i, i+k-1 ));
}
printf("%d\n", query( 1, 0, n, n-k, n-1 ));
}
}
| [
"mayconalves@gea.inatel.br"
] | mayconalves@gea.inatel.br |
383006c949e622fd250e686c199c74134af93475 | 128faaf313aa638aa83930dfd3c69713c6201de0 | /include/UDP.h | 458e2cfce4f60d2cd5cf37a465214a705c0cbfb9 | [] | no_license | hthuynh2/Simple_Distributed_File_System | c92c496ebf31724ee14a7240e21ff635d2c856fe | 59d3b4b93d54242b5e0512bf7e0c006d7ce3c233 | refs/heads/master | 2021-03-27T14:12:38.741113 | 2017-11-04T19:54:23 | 2017-11-04T19:54:23 | 109,214,014 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 835 | h | //
// UDP.hpp
//
//
// Created by Hieu Huynh on 10/7/17.
//
#ifndef UDP_hpp
#define UDP_hpp
#include <stdio.h>
#include "common.h"
using namespace std;
typedef std::chrono::high_resolution_clock clk;
typedef std::chrono::time_point<clk> timepnt;
typedef std::chrono::milliseconds unit_milliseconds;
typedef std::chrono::microseconds unit_microseconds;
typedef std::chrono::nanoseconds unit_nanoseconds;
#define MAX_BUF_SIZE 1024
using namespace std;
class UDP{
private:
char msg_buf[1024];
int msg_buf_idx;
queue<string> msg_q; //Message queue
public:
UDP();
string read_msg_non_block(int time_out);
string receive_msg();
void getlines_(int fd);
vector<string> buf_to_line(char* buf, int buf_size);
void send_msg(string dest_addr, string msg);
};
#endif /* UDP_hpp */
| [
"hthieu96@gmail.com"
] | hthieu96@gmail.com |
800dbc1433eaabdd68bf450877c41e2f167b65b9 | 2d8359a0edda3d6c518fed9ea9f1f0abda074722 | /embedded/led_pattern/led_pattern.ino | 6302ef627653cd38076e62d18dd6739c7a81b12f | [] | no_license | hemant-45/arduino-projects | fe38034c82249865ec36b91a8770dc139beef068 | 8a63eddc4475690af8abdc1d9939251608b44e84 | refs/heads/master | 2022-04-19T16:57:14.042582 | 2020-04-20T20:54:25 | 2020-04-20T20:54:25 | 257,391,032 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,032 | ino | void setup() {
pinMode(13,OUTPUT);
pinMode(12,OUTPUT) ;
pinMode(11,OUTPUT);
pinMode(10,OUTPUT);
pinMode(9,OUTPUT);
pinMode(8,OUTPUT);
pinMode(7,OUTPUT);
pinMode(6,OUTPUT);
// put your setup code here, to run once:
}
void loop() {
digitalWrite(13,HIGH);
digitalWrite(12,LOW);
digitalWrite(11,LOW);
digitalWrite(10,LOW);
digitalWrite(9,LOW);
digitalWrite(8,LOW);
digitalWrite(7,LOW);
digitalWrite(6,LOW);
delay(100);
digitalWrite(13,HIGH);
digitalWrite(12,HIGH);
digitalWrite(11,LOW);
digitalWrite(10,LOW);
digitalWrite(9,LOW);
digitalWrite(8,LOW);
digitalWrite(7,LOW);
digitalWrite(6,LOW);
delay(100);
digitalWrite(13,HIGH);
digitalWrite(12,HIGH);
digitalWrite(11,HIGH);
digitalWrite(10,LOW);
digitalWrite(9,LOW);
digitalWrite(8,LOW);
digitalWrite(7,LOW);
digitalWrite(6,LOW);
delay(100);
digitalWrite(13,HIGH);
digitalWrite(12,HIGH);
digitalWrite(11,HIGH);
digitalWrite(10,HIGH);
digitalWrite(9,LOW);
digitalWrite(8,LOW);
digitalWrite(7,LOW);
digitalWrite(6,LOW);
delay(100);
digitalWrite(13, HIGH);
digitalWrite(12,HIGH);
digitalWrite(11,HIGH);
digitalWrite(10,HIGH);
digitalWrite(9,HIGH);
digitalWrite(8,LOW);
digitalWrite(7,LOW);
digitalWrite(6,LOW);
delay(100);
digitalWrite(13, HIGH);
digitalWrite(12,HIGH);
digitalWrite(11,HIGH);
digitalWrite(10,HIGH);
digitalWrite(9,HIGH);
digitalWrite(8,HIGH);
digitalWrite(7,LOW);
digitalWrite(6,LOW);
delay(100);
digitalWrite(13, HIGH);
digitalWrite(12,HIGH);
digitalWrite(11,HIGH);
digitalWrite(10,HIGH);
digitalWrite(9,HIGH);
digitalWrite(8,HIGH);
digitalWrite(7,HIGH);
digitalWrite(6,LOW);
delay(100);
digitalWrite(13, HIGH);
digitalWrite(12,HIGH);
digitalWrite(11,HIGH);
digitalWrite(10,HIGH);
digitalWrite(9,HIGH);
digitalWrite(8,HIGH);
digitalWrite(7,HIGH);
digitalWrite(6,HIGH);
delay(500);
digitalWrite(13,LOW);
digitalWrite(12,LOW);
digitalWrite(11,LOW);
digitalWrite(10,LOW);
digitalWrite(9,LOW);
digitalWrite(8,LOW);
digitalWrite(7,LOW);
digitalWrite(6,LOW);
}
| [
"noreply@github.com"
] | hemant-45.noreply@github.com |
4b932280a6acfd6c4385fb282e9ea554f8ade7ba | 59fd65f5e53f0b7362c6831279855d85ffb1a01f | /gy02/osztalyzatok.cpp | 7c5b51d56dab06c91db08754de9c008dcfbd59f8 | [] | no_license | juditacs/villprog2-2017 | ddf18fe2b2b873cd87c468ed9c587f44c116c7aa | 6ff15a065774a8fcdae00833490e3fc438c984ad | refs/heads/master | 2023-08-27T06:12:24.144687 | 2017-05-08T12:42:10 | 2017-05-08T12:42:10 | 81,802,580 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 768 | cpp | /*
* osztalyzatok.cpp
* Copyright (C) 2017 Judit Acs <judit@sch.bme.hu>
*
* Distributed under terms of the MIT license.
*/
#include <stdio.h>
void indexedCount(int* eredmenyek, int n, int* hisztogram, int m) {
int i;
for (i=0; i<m; i++) hisztogram[i] = 0;
for (i=0; i<n; i++) hisztogram[eredmenyek[i]] ++;
}
void max(int* array, int n, int& place) {
place = n-1;
for (n=n-2; n>=0; n-- ) {
if (array[n] > array[place]) place = n;
}
}
int main() {
int zh[] = {0, 12, 50, 48, 48, 0, 1, 1, 3, 1, 5, 23, 26};
int pontszamok[51] = {0};
int place;
indexedCount(zh, 13, pontszamok, 51);
max(pontszamok, 51, place);
printf("Leggyakoribb pontszam: %d, %dx fordul elo\n", place, pontszamok[place]);
return 0;
}
| [
"judit@sch.bme.hu"
] | judit@sch.bme.hu |
efb6858e979550c90c3febd6e4e3f69cbd04d00b | 08b8cf38e1936e8cec27f84af0d3727321cec9c4 | /data/crawl/git/new_hunk_6377.cpp | 5b6062dbf579429ddbd317b5ca4122d252d8f9bf | [] | no_license | ccdxc/logSurvey | eaf28e9c2d6307140b17986d5c05106d1fd8e943 | 6b80226e1667c1e0760ab39160893ee19b0e9fb1 | refs/heads/master | 2022-01-07T21:31:55.446839 | 2018-04-21T14:12:43 | 2018-04-21T14:12:43 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 353 | cpp | return error("--all and --mirror are incompatible");
}
if (!refspec && !(flags & TRANSPORT_PUSH_ALL)) {
if (remote->push_refspec_nr) {
refspec = remote->push_refspec;
refspec_nr = remote->push_refspec_nr;
} else if (!(flags & TRANSPORT_PUSH_MIRROR))
setup_default_push_refspecs();
}
errs = 0;
for (i = 0; i < remote->url_nr; i++) {
| [
"993273596@qq.com"
] | 993273596@qq.com |
37dea14e907ee5b838a9c9ffeb507171cea087bc | 5d28a348a9c59e1fda604095021022d1835bbe05 | /MotocarroPhtCell.h | 3c64d325994090eed11711dd00c14af033cd59bc | [] | no_license | llucbrell/MOTO-CAR-ROBOT | dd6111a7e9404076d3028cda7260c94def71dd1a | da0cb33e21cb10c87faaa80524680f97740d98c9 | refs/heads/master | 2020-05-29T11:03:57.542769 | 2015-10-29T12:58:12 | 2015-10-29T12:58:12 | 43,798,172 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 429 | h | #include <Arduino.h>
class MotocarroEye {
private:
byte eye;
int eyeRef;
public:
void setEye(byte pinEye) {
// set pins
eye = pinEye;
// wake up pins!!!
pinMode(eye, INPUT);
eyeRef = analogRead(eye);
}
void setRef() {
eyeRef = analogRead(eye);
}
int getRef(){
return eyeRef;
}
int readLight() {
return analogRead(eye);
}
};
| [
"llucbrell@gmail.com"
] | llucbrell@gmail.com |
1ae6dd0bfc08d04bba3e27983a278af258bebb2c | 9b60cc1223d4a59fbab178986bdee1cb08c3ecb7 | /console.cpp | 2a6f7f4267b85237d3bcc3613017dadffdef370b | [
"MIT"
] | permissive | kingking888/Viking-Wpt | 633f7cb5276b479d7ac6ea6848d93070aa92cf29 | 0f204f2700e0c37e58b7f2efee5ace0a3ac892b2 | refs/heads/master | 2021-12-27T13:50:12.371597 | 2018-01-10T06:45:55 | 2018-01-10T06:45:55 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 5,974 | cpp | //==============================================================================
// Console.cpp
//==============================================================================
#include <windows.h>
#include <vector>
#include "console.h"
#include "client.h"
#include "stringfinder.h"
#include "interpreter.h"
#include "color.h"
#include "cvars.h"
#include "drawing.h"
#include "gui2.h"
// global
Console gConsole;
extern bool oglSubtractive;
void DrawBox(int x, int y);
void DrawMove(int x, int y);
//========================================================================================
void Console::draw(int con_x, int con_y, int con_w, int con_h)
{
if( !active ) return;
ColorEntry* color;
oglSubtractive=true;
gEngfuncs.pfnFillRGBA(con_x,con_y-16,con_w, 16,255,0,0,128);
gEngfuncs.pfnFillRGBA(con_x,con_y-0,con_w,con_h,0,0,255,128);
oglSubtractive=false;
// gui.Draw3DSmoothBoxAndSmoothHeaderWithFlatBorder(con_x,con_y-16,con_w,con_h,20,ubr,ubg,ubb,lbr,lbg,lbb,ba,uhr,uhg,uhb,lhr,lhg,lhb,ha,bor,bog,bob,boa,line);
DrawGlowHudString(con_x + con_w/3, con_y-18,20,20,50," - Viking Wpt -");
int x = con_x+3;
int y = con_y+con_h-14;
// advance blink:
if(blinkTimer.expired())
{
blink = !blink;
if(blink) { blinkTimer.countdown(0.2); }
else { blinkTimer.countdown(0.2); }
}
// draw cursor
if(blink)
{
// get len of text to cursor.
int length, height, ch_length;
char save;
save = cursorpos[0]; cursorpos[0]=0;
gEngfuncs.pfnDrawConsoleStringLen( editbuf, &length, &height );
cursorpos[0]=save;
// get cursor size:
save = cursorpos[1]; cursorpos[1]=0;
gEngfuncs.pfnDrawConsoleStringLen( cursorpos, &ch_length, &height );
cursorpos[1]=save;
if(!*cursorpos) ch_length=5;
gEngfuncs.pfnDrawSetTextColor(1,1,1);
gEngfuncs.pfnDrawConsoleString(x+length,y+1,"|"); // "con_text2"
// tintArea(x+length,y+2,ch_length,height-5, colorList.get(11)); // "con_text2"
}
color = colorList.get(24); // "con_edit"
tintArea(con_x, con_y+con_h-13,con_w,1,255,255,255,150);
gEngfuncs.pfnDrawSetTextColor(color->onebased_r,color->onebased_g,color->onebased_b);
gEngfuncs.pfnDrawConsoleString(x,y,editbuf);
lines.reset();
for(;;)
{
y-=14;
if(y<con_y) break;
string& curLine = lines.read();
lines.prev();
drawConsoleLine(curLine,x,y);
}
}
//========================================================================================
void Console::echo(const char *fmt, ... )
{
va_list va_alist;
char buf[384];
va_start (va_alist, fmt);
_vsnprintf (buf, sizeof(buf), fmt, va_alist);
va_end (va_alist);
lines.add( buf );
}
//========================================================================================
void Console::say(const char* text, const char* name, int team )
{
if(team==1) { echo("&r%s :", name); echo(" %s",text); }
else { echo("&b%s :", name); echo(" %s",text); }
}
//========================================================================================
void Console::setcolortag(unsigned char ch, int r, int g, int b)
{
ch -= 'a';
if(ch>=26) { echo("color tags must be labeled \'a\' to \'z\'"); return; }
colorTags[ch].r = r;
colorTags[ch].g = g;
colorTags[ch].b = b;
colorTags[ch].fill_missing();
}
//========================================================================================
void Console::drawConsoleLine( const string& str, int x, int y )
{
const char* line = str.c_str();
char buf[256];
char* bufpos;
for(;;)
{
// extract string part
bufpos=buf;
for(;;) { *bufpos=*line; if(!*line||*line=='&')break; ++line; ++bufpos; };
bufpos[0]=0;bufpos[1]=0;
// draw
int length, height;
gEngfuncs.pfnDrawConsoleStringLen( buf, &length, &height );
gEngfuncs.pfnDrawSetTextColor(colorTags[curColorTag].onebased_r,
colorTags[curColorTag].onebased_g,
colorTags[curColorTag].onebased_b);
gEngfuncs.pfnDrawConsoleString(x,y,buf);
// advance
x+=length;
if(*line=='&')
{
unsigned char ch = *++line - 'a';
if(ch<26) curColorTag=ch;
else break;
if(!*++line) break;
}
else
{
break;
}
}
curColorTag=0;
}
//========================================================================================
void Console::key(int ch)
{
char* pos;
switch(ch)
{
case -1: // backspace
if(cursorpos==editline) return;
pos = --cursorpos;
while(pos[0]) { pos[0]=pos[1]; ++pos; }
return;
case -2: // uparrow
if(hist_direction!=DIR_BACK) { history.prev(); history.prev(); hist_direction=DIR_BACK;}
strcpy(editline, history.read().c_str());
cursorpos = editline + strlen(editline);
history.prev();
return;
case -3: // downarrow
if(hist_direction==DIR_BACK) { history.next(); history.next(); hist_direction=DIR_FORWARD;}
strcpy(editline, history.read().c_str());
cursorpos = editline + strlen(editline);
history.next();
return;
case -4: // leftarrow
if(cursorpos!=editline) --cursorpos;
return;
case -5: // leftarrow
if(cursorpos!=(editline+strlen(editline))) ++cursorpos;
return;
case '\n':
if( !strcmp(editline,"===") )
{
if(mode==MODE_EXECUTE) { mode=MODE_CHAT; echo("&b*** &aCONSOLE: &wCHAT MODE &b***"); }
else { mode=MODE_EXECUTE; echo("&b*** &aCONSOLE: &wEXEC MODE &b***"); }
}
else if(mode==MODE_EXECUTE)
{
echo ( "&x%s",editbuf );
if(editline[0])
{
cmd.exec( editline );
history.add(editline);
history.reset();
}
}
else if(mode==MODE_CHAT)
{
char* text = editline; while(*text==' ')++text;
char buf[256];sprintf(buf,"say \"%s\"",text);
gEngfuncs.pfnClientCmd(buf);
}
editline[0]=0;
cursorpos = editline;
return;
default:
// insert character
if(strlen(editbuf)>(EDIT_MAX-4)) return;
if(!cursorpos[0]) { cursorpos[0]=ch; ++cursorpos; cursorpos[0]=0; return; }
pos = editbuf+strlen(editbuf)+1;
while(pos>cursorpos) { pos[0]=pos[-1]; --pos; }
*cursorpos = ch;
++cursorpos;
return;
}
} | [
"39935348@qq.com"
] | 39935348@qq.com |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.