blob_id stringlengths 40 40 | directory_id stringlengths 40 40 | path stringlengths 4 201 | content_id stringlengths 40 40 | detected_licenses listlengths 0 85 | license_type stringclasses 2
values | repo_name stringlengths 7 100 | snapshot_id stringlengths 40 40 | revision_id stringlengths 40 40 | branch_name stringclasses 260
values | visit_date timestamp[us] | revision_date timestamp[us] | committer_date timestamp[us] | github_id int64 11.4k 681M ⌀ | star_events_count int64 0 209k | fork_events_count int64 0 110k | gha_license_id stringclasses 17
values | gha_event_created_at timestamp[us] | gha_created_at timestamp[us] | gha_language stringclasses 80
values | src_encoding stringclasses 28
values | language stringclasses 1
value | is_vendor bool 1
class | is_generated bool 2
classes | length_bytes int64 8 9.86M | extension stringclasses 52
values | content stringlengths 8 9.86M | authors listlengths 1 1 | author stringlengths 0 119 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
44e573a01f3025e1d78a6f2e6a38bb8bb55bd20d | 7cc26385bc7d04f3c48be312e2a74be078788fba | /RealityPlus/Temp/il2cppOutput/il2cppOutput/System_Core_System_Collections_Generic_HashSet_1_L2021196357.h | 110ccee13ff17500c602e7da5323d779d8889c46 | [] | no_license | agharlab/demo | 9e8aa82dd02bb892abf9c516e309fa2523683f59 | 5df7e24c8d26b2264b21a455f469c6d25536086a | refs/heads/master | 2021-01-23T14:56:21.781557 | 2017-07-25T12:23:31 | 2017-07-25T12:23:31 | 93,263,213 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,350 | h | #pragma once
#include "il2cpp-config.h"
#ifndef _MSC_VER
# include <alloca.h>
#else
# include <malloc.h>
#endif
#include <stdint.h>
#include "mscorlib_System_ValueType3507792607.h"
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// System.Collections.Generic.HashSet`1/Link<Wikitude.TrackerBehaviour>
struct Link_t2021196357
{
public:
// System.Int32 System.Collections.Generic.HashSet`1/Link::HashCode
int32_t ___HashCode_0;
// System.Int32 System.Collections.Generic.HashSet`1/Link::Next
int32_t ___Next_1;
public:
inline static int32_t get_offset_of_HashCode_0() { return static_cast<int32_t>(offsetof(Link_t2021196357, ___HashCode_0)); }
inline int32_t get_HashCode_0() const { return ___HashCode_0; }
inline int32_t* get_address_of_HashCode_0() { return &___HashCode_0; }
inline void set_HashCode_0(int32_t value)
{
___HashCode_0 = value;
}
inline static int32_t get_offset_of_Next_1() { return static_cast<int32_t>(offsetof(Link_t2021196357, ___Next_1)); }
inline int32_t get_Next_1() const { return ___Next_1; }
inline int32_t* get_address_of_Next_1() { return &___Next_1; }
inline void set_Next_1(int32_t value)
{
___Next_1 = value;
}
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
| [
"sam@sams-MacBook-Air.local"
] | sam@sams-MacBook-Air.local |
36caf9566bc72d736d63b8d86cfcdf5e40bfdb23 | 654551391137a0893714997ca64462dbee563341 | /PongRecreation/ProcessEngine/ProcessEngine.h | 1b19483ec7f2235d783c5c8d05bb26b5fa7d55f0 | [] | no_license | ReschAndrewJ/UniversityOfCincinnati2021SummerEEPVulkanPrograms-AndrewResch | 6c6ba4fa9200e6499617ae74ace96f6b1d82c5cf | dcad6a88ec9f6dfe5cc069242a1d1f61a30c0ca1 | refs/heads/main | 2023-07-06T06:04:08.997330 | 2021-08-04T15:14:18 | 2021-08-04T15:14:18 | 388,821,694 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 756 | h | #pragma once
#define GLFW_INCLUDE_VULKAN
#include "GLFW/glfw3.h"
#include "../Objects/GenericObjects/GenericObjects.h"
#include "../ApplicationEngine/PassInfo.h"
#include <chrono>
class ProcessEngine
{
const int maxFPS = 60;
std::mutex inputCallbackMutex;
std::unordered_map<std::string, int> inputStates;
std::unordered_map<std::string, inputActions::inputStates> statesFromCallback;
std::chrono::steady_clock::time_point startOfLastFrame;
PassInfo* passData;
public:
void setup(PassInfo* sharedPass);
void keyCallback(int key, int action);
void processFrame(std::vector<BaseObject*> objectsTree);
private:
void setupInputs();
void advanceInputs();
void processCollisions();
};
| [
"noreply@github.com"
] | noreply@github.com |
f8bb2a67dbf3f92d6872fff7722b1a1def302324 | 093500f8a3938cf0013302b23e7f036c7ac7487c | /src/lms/ui/explore/SearchView.cpp | 6f37b4c6915fad8fea68f9df272deadc2313450e | [] | no_license | tazio/lms | 9aad43be866c75fd902bbe5794769613e50aa4fc | 1ce6aa781ec950ea00c082e99859a207a22369b0 | refs/heads/master | 2022-11-10T13:53:33.906564 | 2020-06-26T22:13:54 | 2020-06-28T21:49:39 | 268,320,019 | 0 | 0 | null | 2020-05-31T16:34:16 | 2020-05-31T16:34:16 | null | UTF-8 | C++ | false | false | 3,296 | cpp | /*
* Copyright (C) 2020 Emeric Poupon
*
* This file is part of LMS.
*
* LMS is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* LMS is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with LMS. If not, see <http://www.gnu.org/licenses/>.
*/
#include "SearchView.hpp"
#include <Wt/WAnchor.h>
#include <Wt/WImage.h>
#include "database/Artist.hpp"
#include "database/Release.hpp"
#include "database/Track.hpp"
#include "resource/ImageResource.hpp"
#include "ArtistListHelpers.hpp"
#include "Filters.hpp"
#include "LmsApplication.hpp"
#include "ReleaseListHelpers.hpp"
#include "TrackListHelpers.hpp"
static constexpr std::size_t maxEntries {6};
namespace UserInterface
{
SearchView::SearchView(Filters* filters)
: Wt::WTemplate {Wt::WString::tr("Lms.Explore.Search.template")}
, _filters {filters}
{
addFunction("tr", &Wt::WTemplate::Functions::tr);
_filters->updated().connect([=]
{
refreshView();
});
}
void
SearchView::refreshView(const std::string& searchText)
{
_keywords = StringUtils::splitString(searchText, " ");
refreshView();
}
void
SearchView::refreshView()
{
clear();
auto transaction {LmsApp->getDbSession().createSharedTransaction()};
searchArtists();
searchReleases();
searchTracks();
}
void
SearchView::searchArtists()
{
bool more;
const auto artists {Database::Artist::getByFilter(LmsApp->getDbSession(),
_filters->getClusterIds(),
_keywords,
std::nullopt,
Database::Artist::SortMethod::BySortName,
Database::Range {0, maxEntries}, more)};
if (!artists.empty())
{
setCondition("if-artists", true);
auto* container {bindNew<Wt::WContainerWidget>("artists")};
for (const Database::Artist::pointer& artist : artists)
container->addWidget(ArtistListHelpers::createEntrySmall(artist));
}
}
void
SearchView::searchReleases()
{
bool more;
const auto releases {Database::Release::getByFilter(LmsApp->getDbSession(),
_filters->getClusterIds(),
_keywords,
Database::Range {0, maxEntries}, more)};
if (!releases.empty())
{
setCondition("if-releases", true);
auto* container {bindNew<Wt::WContainerWidget>("releases")};
for (const Database::Release::pointer& release : releases)
container->addWidget(ReleaseListHelpers::createEntry(release));
}
}
void
SearchView::searchTracks()
{
bool more;
const auto tracks {Database::Track::getByFilter(LmsApp->getDbSession(),
_filters->getClusterIds(),
_keywords,
Database::Range {0, maxEntries}, more)};
if (!tracks.empty())
{
setCondition("if-tracks", true);
auto* container {bindNew<Wt::WContainerWidget>("tracks")};
for (const Database::Track::pointer& track : tracks)
container->addWidget(TrackListHelpers::createEntry(track));
}
}
} // namespace UserInterface
| [
"itmfr@yahoo.fr"
] | itmfr@yahoo.fr |
8837f3b5afdbe31b30dab59130ddb19dfe56d4bc | 07074962be026c67519a0ccfb3d48bd95ede38ed | /Reports/cr5mfgeneralreportfilter.h | c4c8b031ace346e33684097b06652749ee67cffa | [] | no_license | End1-1/Cafe5 | 2fa65c62f395c186e2204f3fb941a2f93fd3a653 | ba2b695c627cf59260a3ac1134927198c004fe53 | refs/heads/master | 2023-08-17T02:39:29.224396 | 2023-08-14T06:37:55 | 2023-08-14T06:37:55 | 151,380,276 | 2 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 625 | h | #ifndef CR5MFGENERALREPORTFILTER_H
#define CR5MFGENERALREPORTFILTER_H
#include "c5filterwidget.h"
namespace Ui {
class CR5MFGeneralReportFilter;
}
class CR5MFGeneralReportFilter : public C5FilterWidget
{
Q_OBJECT
public:
explicit CR5MFGeneralReportFilter(const QStringList &dbParams, QWidget *parent = nullptr);
~CR5MFGeneralReportFilter();
virtual QString condition();
virtual QString conditionText();
QString d1ms() const;
QString d2ms() const;
QString d1s() const;
QString d2s() const;
private:
Ui::CR5MFGeneralReportFilter *ui;
};
#endif // CR5MFGENERALREPORTFILTER_H
| [
"end1_1@yahoo.com"
] | end1_1@yahoo.com |
3e40bced92efd2a8bb6559ead88b5cad12b9c5c2 | 3544505f84aa1a1e5210291bdc249a4d5b48f66f | /Chapter05/BigProject/MainWindow.cpp | 47c76c2ce0c55ad6b76826ea608e49ea88ef30bb | [
"MIT"
] | permissive | PacktPublishing/Hands-On-Embedded-Programming-with-Qt | 40dc1657f776ebbbf4b22bb2dba2cd5f52008ab3 | d0516d094cc7532ba16582806f9e3a416e53fc78 | refs/heads/master | 2023-02-08T15:46:26.741412 | 2023-01-30T09:19:25 | 2023-01-30T09:19:25 | 160,319,211 | 33 | 28 | null | null | null | null | UTF-8 | C++ | false | false | 878 | cpp | #include "MainWindow.h"
#include "ui_MainWindow.h"
#include <QDateTime>
MainWindow::MainWindow(TemperatureSensorIF *tempSensor, QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow),
m_tempSensor(tempSensor)
{
ui->setupUi(this);
connect(m_tempSensor, &TemperatureSensorIF::newTemperature, this, &MainWindow::updateTempDisplay);
m_updateTimer.setSingleShot(false);
connect(&m_updateTimer, &QTimer::timeout, this, &MainWindow::updateDisplay);
m_updateTimer.setInterval(1000);
m_updateTimer.start();
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::updateDisplay()
{
QDateTime now = QDateTime::currentDateTime();
ui->currentDateTime->setText(now.toString());
}
void MainWindow::updateTempDisplay(QDateTime timestamp, float temperature)
{
ui->tempDisplay->setText(QString("%1 C").arg(temperature));
}
| [
"jwernerny@gmail.com"
] | jwernerny@gmail.com |
5573613aeed6c58f0d168579b1b3526202865fca | 42cc4eea7a2fa1b8c7e3510ebb9f8809fd746c78 | /Winters_Gate/Winters_GateMain.cpp | 3bae864894bb233bd9be02933e54187d25fa32ed | [] | no_license | carldibert/Winters-Gate | 67d21ca27db9a8b5e55c92ec029d127d2f9ada08 | d4a91f10985f57e2244823c649701c35cc0d2a45 | refs/heads/master | 2021-08-29T01:35:05.764607 | 2017-12-13T09:24:12 | 2017-12-13T09:24:12 | 112,974,686 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 9,627 | cpp | /***************************************************************
* Name: Winters_GateMain.cpp
* Purpose: Code for Application Frame
* Author: Carl Dibert ()
* Created: 2017-11-10
* Copyright: Carl Dibert ()
* License:
**************************************************************/
#include "Winters_GateMain.h"
#include <wx/msgdlg.h>
#include <wx/intl.h>
#include <wx/listctrl.h>
#include <wx/thread.h>
#include <boost/filesystem.hpp>
#include <boost/thread.hpp>
#include <fstream>
#include <string>
#include <vector>
#include <windows.h>
#include <stdlib.h>
//(*InternalHeaders(Winters_GateDialog)
#include <wx/intl.h>
#include <wx/string.h>
//*)
using namespace std;
using namespace boost::filesystem;
typedef std::vector<std::string> stringvec;
string fileName;
//helper functions
enum wxbuildinfoformat {
short_f, long_f };
wxString wxbuildinfo(wxbuildinfoformat format)
{
wxString wxbuild(wxVERSION_STRING);
if (format == long_f )
{
#if defined(__WXMSW__)
wxbuild << _T("-Windows");
#elif defined(__UNIX__)
wxbuild << _T("-Linux");
#endif
#if wxUSE_UNICODE
wxbuild << _T("-Unicode build");
#else
wxbuild << _T("-ANSI build");
#endif //wxUSE_UNICODE
}
return wxbuild;
}
//(*IdInit(Winters_GateDialog)
const long Winters_GateDialog::ID_LISTBOX2 = wxNewId();
const long Winters_GateDialog::ID_STATICTEXT1 = wxNewId();
const long Winters_GateDialog::ID_BUTTON2 = wxNewId();
const long Winters_GateDialog::ID_BUTTON1 = wxNewId();
//*)
BEGIN_EVENT_TABLE(Winters_GateDialog,wxDialog)
//(*EventTable(Winters_GateDialog)
//*)
END_EVENT_TABLE()
Winters_GateDialog::Winters_GateDialog(wxWindow* parent,wxWindowID id)
{
//(*Initialize(Winters_GateDialog)
wxBoxSizer* BoxSizer2;
wxBoxSizer* BoxSizer1;
wxBoxSizer* BoxSizer3;
Create(parent, wxID_ANY, _("Winter\'s Gate"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE, _T("wxID_ANY"));
SetMaxSize(wxSize(-1,-1));
BoxSizer1 = new wxBoxSizer(wxHORIZONTAL);
BoxSizer2 = new wxBoxSizer(wxVERTICAL);
LibraryListBox = new wxListBox(this, ID_LISTBOX2, wxDefaultPosition, wxSize(650,353), 0, 0, 0, wxDefaultValidator, _T("ID_LISTBOX2"));
BoxSizer2->Add(LibraryListBox, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
BoxSizer1->Add(BoxSizer2, 2, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
BoxSizer3 = new wxBoxSizer(wxVERTICAL);
StaticText1 = new wxStaticText(this, ID_STATICTEXT1, wxEmptyString, wxDefaultPosition, wxSize(265,186), 0, _T("ID_STATICTEXT1"));
BoxSizer3->Add(StaticText1, 2, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
PauseButton = new wxButton(this, ID_BUTTON2, _("Pause"), wxDefaultPosition, wxSize(114,88), 0, wxDefaultValidator, _T("ID_BUTTON2"));
PauseButton->Hide();
BoxSizer3->Add(PauseButton, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
StopButton = new wxButton(this, ID_BUTTON1, _("Stop"), wxDefaultPosition, wxSize(111,49), 0, wxDefaultValidator, _T("ID_BUTTON1"));
StopButton->Hide();
BoxSizer3->Add(StopButton, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
BoxSizer1->Add(BoxSizer3, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
SetSizer(BoxSizer1);
BoxSizer1->Fit(this);
BoxSizer1->SetSizeHints(this);
Center();
PopulateListBox();
Connect(ID_LISTBOX2,wxEVT_COMMAND_LISTBOX_SELECTED,(wxObjectEventFunction)&Winters_GateDialog::OnLibraryListBoxSelect);
Connect(ID_LISTBOX2,wxEVT_COMMAND_LISTBOX_DOUBLECLICKED,(wxObjectEventFunction)&Winters_GateDialog::OnLibraryListBoxDClick);
Connect(ID_BUTTON2,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&Winters_GateDialog::PauseButtonOnClick);
Connect(ID_BUTTON1,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&Winters_GateDialog::StopButtonOnClick);
//*)
}
Winters_GateDialog::~Winters_GateDialog()
{
//(*Destroy(Winters_GateDialog)
//*)
}
//action for the Pause Button
void Winters_GateDialog::PauseButtonOnClick(wxCommandEvent& event){
}
//action for the Stop Button
void Winters_GateDialog::StopButtonOnClick(wxCommandEvent& event){
}
//checks if file is a .mp3 file
bool checkIfMP3(string fileLocation){
int fileNameLength = fileLocation.length() - 4;
string fileType = fileLocation.substr(fileNameLength, 4);
if(fileType == ".mp3"){
return true;
} else {
return false;
}
}
//checks if file is a .WAV file
bool checkIfWAV(string fileLocation){
int fileNameLength = fileLocation.length() - 4;
string fileType = fileLocation.substr(fileNameLength, 4);
if(fileType == ".wav"){
return true;
} else {
return false;
}
}
//reads from directory and adds all files to a vector if the file is a mp3 file
void read_directory(const std::string& name, stringvec& v){
std::string pattern(name);
pattern.append("\\*");
WIN32_FIND_DATA data;
HANDLE hFind;
string file_location;
string file_location_explicit;
string file_location_parent;
if ((hFind = FindFirstFile(pattern.c_str(), &data)) != INVALID_HANDLE_VALUE){
do {
ostringstream convert;
convert <<name <<"\\"<<data.cFileName;
file_location = convert.str();
file_location_explicit = name + "\\.";
file_location_parent = name + "\\..";
path dir = file_location;
if(is_directory(dir) && file_location == file_location_explicit){
} else if(is_directory(dir) && file_location == file_location_parent){
} else if(is_directory(dir)){
read_directory(file_location, v);
} else {
if(checkIfMP3(file_location)){
v.push_back(file_location);
} else if (checkIfWAV(file_location)){
v.push_back(file_location);
}
}
}while(FindNextFile(hFind, &data) != 0);
FindClose(hFind);
}
}
//populates the library with all of the files
void Winters_GateDialog::PopulateListBox(){
string library_location = "C:\\Users\\Carl\\Music";
stringvec v;
read_directory(library_location, v);
int sizeOf = v.size();
for(int i=0; i<sizeOf; i++){
string stringStuff = v.at(i);
const char* chars = stringStuff.c_str();
wxString wxStringItem = wxString::FromUTF8(chars);
LibraryListBox->Append(wxStringItem);
}
}
//custom data type for the song
struct Song{
string title;
string artist;
string album;
string year;
string comment;
string fileLocation;
};
//outputs file size in bites
int getFileSize(FILE *file){
int loc = ftell(file);
fseek(file,0,SEEK_END);
int size = ftell(file);
fseek(file,loc,SEEK_SET);
return size;
};
//reads in blocks of 30 for artist album title and comments
string readInfo(FILE *file, int readLines){
char len[30];
fseek(file, readLines, SEEK_SET);
fread(len, 1, 30, file);
string result(len);
return result;
}
//reads for the year that the song was made
string readYear(FILE *file, int readLines){
char len[4];
fseek(file, readLines, SEEK_SET);
fread(len, 1, 4, file);
string result(len);
return result;
}
//reads information and puts it on the custom data type
void readFile(FILE* file, Song& song, string fileLocation){
int readLocation = getFileSize(file)-125;
song.title = readInfo(file, readLocation);
readLocation = readLocation + 30;
song.artist = readInfo(file, readLocation);
readLocation = readLocation + 30;
song.album = readInfo(file, readLocation);
readLocation = readLocation + 30;
string yearStringTemp = readYear(file, readLocation);
string tempYear = yearStringTemp.c_str();
string temp;
for(int i=0; i<4; i++){
temp += tempYear[i];
}
song.year = temp;
readLocation = readLocation + 4;
song.comment = readInfo(file, readLocation);
song.fileLocation = fileLocation;
}
//adds the song info for the info title to the right on single click
void Winters_GateDialog::OnLibraryListBoxSelect(wxCommandEvent& event){
string library_location = "C:\\Users\\Carl\\Music";
stringvec v;
read_directory(library_location, v);
int posOfLibrary = LibraryListBox->GetSelection();
string som = v.at(posOfLibrary);
FILE* sample = fopen(som.c_str(), "r");
Song song;
readFile(sample, song, som);
string songInfo = song.artist + "\n" + song.album + "\n" + song.title + "\n" + song.year;
const char* chars = songInfo.c_str();
wxString wxStringItem = wxString::FromUTF8(chars);
StaticText1->SetLabel(wxStringItem);
}
//plays selected song
void playMusic (string fileLocation){
const char* stuff = fileLocation.c_str();
size_t size = strlen(stuff);
wchar_t* arr = new wchar_t[size];
for(size_t i=0; i<size; i++){
arr[i] = stuff[i];
}
PlaySound(arr, NULL, SND_FILENAME);
}
//action for double clicking on a selection on the LibraryListView
void Winters_GateDialog::OnLibraryListBoxDClick(wxCommandEvent& event){
string library_location = "C:\\Users\\Carl\\Music";
stringvec v;
read_directory(library_location, v);
int posOfLibrary = LibraryListBox->GetSelection();
string som = v.at(posOfLibrary);
if(checkIfWAV(som)){
string stuff = "";
const char* chars = stuff.c_str();
wxString wxStringItem = wxString::FromUTF8(chars);
StaticText1->SetLabel(wxStringItem);
}
playMusic(som);
}
| [
"dibertcarl@gmail.com"
] | dibertcarl@gmail.com |
682d6578aff8a13732aba43f9d0bee551f925622 | 69d51f4d829f48d1e32b80484b2f0df74b32de62 | /ndk-android-project/XPlay/app/src/main/cpp/XLog.h | e6a1660be3cd23d763478ac7800ee42143c0c2de | [] | no_license | sengeiou/as-some-sample-project-to-github | 79a8b5975f41710d19567ac58bf78c52a3667ce2 | 66012d4380f7ce90bedb6c9d8967b11bb51673be | refs/heads/main | 2023-06-29T05:40:48.705120 | 2021-07-30T09:35:33 | 2021-07-30T09:35:33 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,937 | h | /*******************************************************************************
** **
** Jiedi(China nanjing)Ltd. **
** 创建:夏曹俊,此代码可用作为学习参考 **
*******************************************************************************/
/*****************************FILE INFOMATION***********************************
**
** Project : FFmpeg
** Description : FFMPEG项目创建示例
** Contact : xiacaojun@qq.com
** 博客 : http://blog.csdn.net/jiedichina
** 视频课程 : 网易云课堂 http://study.163.com/u/xiacaojun
腾讯课堂 https://jiedi.ke.qq.com/
csdn学院 http://edu.csdn.net/lecturer/lecturer_detail?lecturer_id=961
** 51cto学院 http://edu.51cto.com/lecturer/index/user_id-12016059.html
** 下载最新的ffmpeg版本 ffmpeg.club
**
** 安卓流媒体播放器 课程群 :23304930 加入群下载代码和交流
** 微信公众号 : jiedi2007
** 头条号 : 夏曹俊
**
*******************************************************************************/
//!!!!!!!!! 加群23304930下载代码和交流
//
// Created by Administrator on 2018-03-01.
//
#ifndef XPLAY_XLOG_H
#define XPLAY_XLOG_H
class XLog {
};
#ifdef ANDROID
#include <android/log.h>
#define XLOGD(...) __android_log_print(ANDROID_LOG_DEBUG,"XPlay",__VA_ARGS__)
#define XLOGI(...) __android_log_print(ANDROID_LOG_INFO,"XPlay",__VA_ARGS__)
#define XLOGE(...) __android_log_print(ANDROID_LOG_ERROR,"XPlay",__VA_ARGS__)
#else
#define XLOGD(...) printf("XPlay",__VA_ARGS__)
#define XLOGI(...) printf("XPlay",__VA_ARGS__)
#define XLOGE(...) printf("XPlay",__VA_ARGS__)
#endif
#endif //XPLAY_XLOG_H
| [
"juying2050@sina.cn"
] | juying2050@sina.cn |
9d0fe046527669e251e6656e68b3fdf00f7ff7de | 62bf789f19f500aa5aa20f6911573cc0c59902c7 | /cloudapi/src/model/DescribeAppAttributesRequest.cc | 93f7c7655755b6e55cc7d1ff5988b1fbada29902 | [
"Apache-2.0"
] | permissive | liuyuhua1984/aliyun-openapi-cpp-sdk | 0288f0241812e4308975a62a23fdef2403cfd13a | 600883d23a243eb204e39f15505f1f976df57929 | refs/heads/master | 2020-07-04T09:47:49.901987 | 2019-08-13T14:13:11 | 2019-08-13T14:13:11 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,181 | cc | /*
* Copyright 2009-2017 Alibaba Cloud All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <alibabacloud/cloudapi/model/DescribeAppAttributesRequest.h>
using AlibabaCloud::CloudAPI::Model::DescribeAppAttributesRequest;
DescribeAppAttributesRequest::DescribeAppAttributesRequest() :
RpcServiceRequest("cloudapi", "2016-07-14", "DescribeAppAttributes")
{}
DescribeAppAttributesRequest::~DescribeAppAttributesRequest()
{}
std::string DescribeAppAttributesRequest::getAppName()const
{
return appName_;
}
void DescribeAppAttributesRequest::setAppName(const std::string& appName)
{
appName_ = appName;
setCoreParameter("AppName", appName);
}
std::string DescribeAppAttributesRequest::getSecurityToken()const
{
return securityToken_;
}
void DescribeAppAttributesRequest::setSecurityToken(const std::string& securityToken)
{
securityToken_ = securityToken;
setCoreParameter("SecurityToken", securityToken);
}
long DescribeAppAttributesRequest::getAppId()const
{
return appId_;
}
void DescribeAppAttributesRequest::setAppId(long appId)
{
appId_ = appId;
setCoreParameter("AppId", std::to_string(appId));
}
int DescribeAppAttributesRequest::getPageSize()const
{
return pageSize_;
}
void DescribeAppAttributesRequest::setPageSize(int pageSize)
{
pageSize_ = pageSize;
setCoreParameter("PageSize", std::to_string(pageSize));
}
std::vector<DescribeAppAttributesRequest::Tag> DescribeAppAttributesRequest::getTag()const
{
return tag_;
}
void DescribeAppAttributesRequest::setTag(const std::vector<Tag>& tag)
{
tag_ = tag;
int i = 0;
for(int i = 0; i!= tag.size(); i++) {
auto obj = tag.at(i);
std::string str ="Tag."+ std::to_string(i);
setCoreParameter(str + ".Value", obj.value);
setCoreParameter(str + ".Key", obj.key);
}
}
bool DescribeAppAttributesRequest::getEnableTagAuth()const
{
return enableTagAuth_;
}
void DescribeAppAttributesRequest::setEnableTagAuth(bool enableTagAuth)
{
enableTagAuth_ = enableTagAuth;
setCoreParameter("EnableTagAuth", enableTagAuth ? "true" : "false");
}
int DescribeAppAttributesRequest::getPageNumber()const
{
return pageNumber_;
}
void DescribeAppAttributesRequest::setPageNumber(int pageNumber)
{
pageNumber_ = pageNumber;
setCoreParameter("PageNumber", std::to_string(pageNumber));
}
std::string DescribeAppAttributesRequest::getAccessKeyId()const
{
return accessKeyId_;
}
void DescribeAppAttributesRequest::setAccessKeyId(const std::string& accessKeyId)
{
accessKeyId_ = accessKeyId;
setCoreParameter("AccessKeyId", accessKeyId);
}
| [
"sdk-team@alibabacloud.com"
] | sdk-team@alibabacloud.com |
d1442fa3875011c1c359e0f95a12011c6ababfa1 | 714d5fb5cbd66af362991bc21281fb82bc94ddda | /src/ps3/rsxutil.cpp | a700862716969785eeae3516f6a9975bc0eeeb02 | [] | no_license | tmandersson/PS3Mandelbrot | 940afcd416e9fbf9690b8d60e23bb39bc235167c | c56492c935b2cec045c813c8fff843e76a463835 | refs/heads/master | 2020-12-24T17:26:10.915955 | 2012-04-09T20:32:49 | 2012-04-09T20:32:49 | 2,068,119 | 1 | 2 | null | null | null | null | UTF-8 | C++ | false | false | 4,949 | cpp | /*
* This software is distributed under the terms of the GNU General Public
* License ("GPL") version 3, as published by the Free Software Foundation.
*/
#include <ppu-lv2.h>
#include <stdio.h>
#include <malloc.h>
#include <string.h>
#include <unistd.h>
#include <sysutil/video.h>
#include <rsx/gcm_sys.h>
#include <rsx/rsx.h>
#include <io/pad.h>
#include <time.h>
#include <cairo/cairo.h>
#include <math.h>
#include "ps3/rsxutil.h"
#define GCM_LABEL_INDEX 255
static void waitRSXIdle(gcmContextData *context);
static u32 depth_pitch;
static u32 depth_offset;
static u32 *depth_buffer;
void
waitFlip ()
{
while (gcmGetFlipStatus () != 0)
usleep (200); /* Sleep, to not stress the cpu. */
gcmResetFlipStatus ();
}
int
flip (gcmContextData *context, s32 buffer)
{
if (gcmSetFlip (context, buffer) == 0) {
rsxFlushBuffer (context);
// Prevent the RSX from continuing until the flip has finished.
gcmSetWaitFlip (context);
return TRUE;
}
return FALSE;
}
int
makeBuffer (rsxBuffer * buffer, u16 width, u16 height, int id)
{
int depth = sizeof(u32);
int pitch = depth * width;
int size = depth * width * height;
buffer->ptr = (uint32_t*) rsxMemalign (64, size);
if (buffer->ptr == NULL)
goto error;
if (rsxAddressToOffset (buffer->ptr, &buffer->offset) != 0)
goto error;
/* Register the display buffer with the RSX */
if (gcmSetDisplayBuffer (id, buffer->offset, pitch, width, height) != 0)
goto error;
buffer->width = width;
buffer->height = height;
buffer->id = id;
return TRUE;
error:
if (buffer->ptr != NULL)
rsxFree (buffer->ptr);
return FALSE;
}
int
getResolution (u16 *width, u16 *height)
{
videoState state;
videoResolution resolution;
/* Get the state of the display */
if (videoGetState (0, 0, &state) == 0 &&
videoGetResolution (state.displayMode.resolution, &resolution) == 0) {
if (width)
*width = resolution.width;
if (height)
*height = resolution.height;
return TRUE;
}
return FALSE;
}
gcmContextData *
initScreen (void *host_addr, u32 size)
{
gcmContextData *context = NULL; /* Context to keep track of the RSX buffer. */
videoState state;
videoConfiguration vconfig;
videoResolution res; /* Screen Resolution */
/* Initilise Reality, which sets up the command buffer and shared IO memory */
context = rsxInit (CB_SIZE, size, host_addr);
if (context == NULL)
goto error;
/* Get the state of the display */
if (videoGetState (0, 0, &state) != 0)
goto error;
/* Make sure display is enabled */
if (state.state != 0)
goto error;
/* Get the current resolution */
if (videoGetResolution (state.displayMode.resolution, &res) != 0)
goto error;
/* Configure the buffer format to xRGB */
memset (&vconfig, 0, sizeof(videoConfiguration));
vconfig.resolution = state.displayMode.resolution;
vconfig.format = VIDEO_BUFFER_FORMAT_XRGB;
vconfig.pitch = res.width * sizeof(u32);
vconfig.aspect = state.displayMode.aspect;
waitRSXIdle(context);
if (videoConfigure (0, &vconfig, NULL, 0) != 0)
goto error;
if (videoGetState (0, 0, &state) != 0)
goto error;
gcmSetFlipMode (GCM_FLIP_VSYNC); // Wait for VSYNC to flip
depth_pitch = res.width * sizeof(u32);
depth_buffer = (u32 *) rsxMemalign (64, (res.height * depth_pitch)* 2);
rsxAddressToOffset (depth_buffer, &depth_offset);
gcmResetFlipStatus();
return context;
error:
if (context)
rsxFinish (context, 0);
if (host_addr)
free (host_addr);
return NULL;
}
static void
waitFinish(gcmContextData *context, u32 sLabelVal)
{
rsxSetWriteBackendLabel (context, GCM_LABEL_INDEX, sLabelVal);
rsxFlushBuffer (context);
while(*(vu32 *) gcmGetLabelAddress (GCM_LABEL_INDEX) != sLabelVal)
usleep(30);
sLabelVal++;
}
static void
waitRSXIdle(gcmContextData *context)
{
u32 sLabelVal = 1;
rsxSetWriteBackendLabel (context, GCM_LABEL_INDEX, sLabelVal);
rsxSetWaitLabel (context, GCM_LABEL_INDEX, sLabelVal);
sLabelVal++;
waitFinish(context, sLabelVal);
}
void
setRenderTarget(gcmContextData *context, rsxBuffer *buffer)
{
gcmSurface sf;
sf.colorFormat = GCM_TF_COLOR_X8R8G8B8;
sf.colorTarget = GCM_TF_TARGET_0;
sf.colorLocation[0] = GCM_LOCATION_RSX;
sf.colorOffset[0] = buffer->offset;
sf.colorPitch[0] = depth_pitch;
sf.colorLocation[1] = GCM_LOCATION_RSX;
sf.colorLocation[2] = GCM_LOCATION_RSX;
sf.colorLocation[3] = GCM_LOCATION_RSX;
sf.colorOffset[1] = 0;
sf.colorOffset[2] = 0;
sf.colorOffset[3] = 0;
sf.colorPitch[1] = 64;
sf.colorPitch[2] = 64;
sf.colorPitch[3] = 64;
sf.depthFormat = GCM_TF_ZETA_Z16;
sf.depthLocation = GCM_LOCATION_RSX;
sf.depthOffset = depth_offset;
sf.depthPitch = depth_pitch;
sf.type = GCM_TF_TYPE_LINEAR;
sf.antiAlias = GCM_TF_CENTER_1;
sf.width = buffer->width;
sf.height = buffer->height;
sf.x = 0;
sf.y = 0;
rsxSetSurface (context, &sf);
}
| [
"ltmandersson@gmail.com"
] | ltmandersson@gmail.com |
e6e8702f22e84e4fb4dfc688d5c6b0ca1196afb4 | c13b92b91c297243b3f0412900feb5c68d3478a1 | /6/test.cpp | 1abf78254873c691948c1d38bbb30ee9e7f920a0 | [] | no_license | zhanglinhahaha/PrimerCpp5th | 865d290007191813b6f436c315b280f113b5f9c8 | 4c44738d861671e45a958e431050a03de3778e29 | refs/heads/master | 2023-02-11T05:39:30.679244 | 2021-01-06T10:34:37 | 2021-01-06T10:34:37 | 314,511,812 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,786 | cpp | #include <iostream>
#include <vector>
void t610(int *p, int *q) {
int tmp = *p;
*p = *q;
*q = tmp;
}
//typedef int arrT[10];
using arrT = int[5];
//arrT *func0(int i);
int a[] = {1,2,3,4,5};
arrT* func0(int i) {
for(int i = 0; i < 5; i++) {
std::cout << a[i] << " ";
}
std::cout<<"\n"<< i << "\n";
return &a;
}
int (*func1(int i))[5] {
for(int i = 0; i < 5; i++) {
std::cout << a[i] << " ";
}
std::cout<<"\n"<< i << "\n";
return &a;
}
auto func2(int i) -> int (*)[5] {
for(int i = 0; i < 5; i++) {
std::cout << a[i] << " ";
}
std::cout<<"\n"<< i << "\n";
return &a;
}
int odd[] = {1,3,5,7,9};
int even[] = {0,2,4,6,8};
decltype(odd) *func3(int i) {
return (i % 2) ? &odd : &even;
}
void func() {
int n=0;
int (*p0)[5] = func0(n);
for(int i = 0; i < 5; i++) {
std::cout << (*p0)[i] << " ";
}
std::cout<<"func0 over\n";
int (*p1)[5] = func1(n);
for(int i = 0; i < 5; i++) {
std::cout << (*p1)[i] << " ";
}
std::cout<<"func1 over\n";
int (*p2)[5] = func2(n);
for(int i = 0; i < 5; i++) {
std::cout << (*p2)[i] << " ";
}
std::cout<<"func2 over\n";
int (*p)[5] = func3(n);
for(int i = 0; i < 5; i++) {
std::cout << (*p)[i] << " ";
}
std::cout<<"func3 over\n";
int test[5] = {0,1,0,1,2};
int (*q)[5] = &test;
for(int i = 0; i < 5; i++) {
std::cout << (*q)[i]<< " ";
}
std::cout<<"test over\n";
}
void cer() {
std::cerr << " Error " <<__FILE__<<"\n";
}
int main() {
std::vector<int> t = {0,1,2};
int n = 0, i = 1;
int *a = &n, *b = &i;
std::cout<< *a <<" "<<*b<<"\n";
t610(a, b);
std::cout<< *a <<" "<<*b<<"\n";
cer();
return 0;
}
| [
"zhanglin1@thundersoft.com"
] | zhanglin1@thundersoft.com |
1c425e433b9a0eb604d788d28a7a06cc90542d74 | 1266254e5763ec1dbbd861fa2045bcef1edbcec6 | /SurgSim/Testing/MockInputOutput.cpp | 32ff124f2a943c1588ee8d1230177772e9291d29 | [
"Bitstream-Vera",
"BSL-1.0",
"Apache-2.0",
"LicenseRef-scancode-public-domain"
] | permissive | simquest/opensurgsim | 0a443f8e54b276f4e41ed991b2fcb3d2b0c0b5a7 | bd30629f2fd83f823632293959b7654275552fa9 | refs/heads/master | 2022-02-13T15:05:47.744267 | 2020-11-24T14:27:19 | 2020-11-24T14:27:19 | 24,512,532 | 30 | 11 | Apache-2.0 | 2022-02-03T20:18:01 | 2014-09-26T19:25:40 | C++ | UTF-8 | C++ | false | false | 1,508 | cpp | // This file is a part of the OpenSurgSim project.
// Copyright 2013, SimQuest Solutions Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include "SurgSim/Testing/MockInputOutput.h"
using SurgSim::DataStructures::DataGroup;
namespace SurgSim
{
namespace Testing
{
MockInputOutput::MockInputOutput() :
m_numTimesInitializedInput(0),
m_numTimesReceivedInput(0),
m_numTimesRequestedOutput(0)
{
}
bool MockInputOutput::requestOutput(const std::string& device, DataGroup* outputData)
{
++m_numTimesRequestedOutput;
bool result = false;
if (m_output.hasValue())
{
*outputData = m_output.getValue();
result = true;
}
return result;
}
void MockInputOutput::handleInput(const std::string& device, const DataGroup& inputData)
{
++m_numTimesReceivedInput;
m_lastReceivedInput = inputData;
}
void MockInputOutput::initializeInput(const std::string& device, const DataGroup& inputData)
{
++m_numTimesInitializedInput;
m_lastReceivedInput = inputData;
}
}; // Testing
}; // SurgSim
| [
"rbeasley@simquest.com"
] | rbeasley@simquest.com |
a53cea09aa3f720aefb15ae660456ce82fb60b57 | 68361279f770168dde0de589fcd6f021d9e57d1a | /LRUCache146.cpp | 1b71214398642c63a589b6a472caf7a0dcc71ca8 | [] | no_license | jamiefy/leetcode | dfd07ca1c63cff882f3b16010c151dbaa66232bf | ea22148370817d04090ec670d33f4e5ba03f7221 | refs/heads/master | 2021-08-16T17:58:58.195559 | 2020-08-13T07:49:37 | 2020-08-13T07:49:37 | 213,283,342 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,908 | cpp | //
// Created by anranzhai on 2020/3/19.
//
#include <iostream>
#include <map>
#include <deque>
#include <algorithm>
#include <vector>
#include <unordered_map>
class LRUCache {
public:
LRUCache(int capacity) {
cap=capacity;
}
int get(int key) {
if(LRUMap.find(key)!=LRUMap.end()){
recentUsed.erase(std::find(recentUsed.begin(),recentUsed.end(),key));
recentUsed.push_back(key);
return LRUMap[key];
}
return -1;
}
void put(int key, int value) {
if(LRUMap.find(key)!=LRUMap.end()){
LRUMap[key]=value;
recentUsed.erase(std::find(recentUsed.begin(),recentUsed.end(),key));
recentUsed.push_back(key);
return;
}
if(LRUMap.size()>=cap){
if(recentUsed.empty())
return;
else{
LRUMap.erase(recentUsed.front());
recentUsed.erase(recentUsed.begin());
}
}
LRUMap[key]=value;
recentUsed.push_back(key);
}
private:
std::map<int,int> LRUMap;
std::vector<int> recentUsed;
std::size_t cap;
};
//哈希表unordered_map(哈希表无序)和双链表
struct DLinkedNode {
int key;
int value;
DLinkedNode* prev;
DLinkedNode* next;
DLinkedNode(int k,int v):key(k),value(v){prev=NULL;next=NULL;};
};
class LRUCacheImp {
public:
LRUCacheImp(int capacity) {
this->capacity = capacity;
head = new DLinkedNode(-1,-1);
head->prev = NULL;
tail = new DLinkedNode(-1,-1);
tail->next = NULL;
head->next = tail;
tail->prev = head;
}
void addNodeAfterHead(DLinkedNode* node) {
/**
* Always add the new node right after head.
*/
node->prev = head;
node->next = head->next;
head->next->prev = node;
head->next = node;
}
void removeNode(DLinkedNode* node) {
/**
* Remove an existing node from the linked list.
*/
DLinkedNode* prev = node->prev;
DLinkedNode* next = node->next;
prev->next = next;
next->prev = prev;
}
void moveToHead(DLinkedNode* node) {
/**
* Move certain node in between to the head.
*/
removeNode(node);
addNodeAfterHead(node);
}
DLinkedNode* popTail() {
/**
* Pop the current tail.
*/
DLinkedNode* res = tail->prev;
removeNode(res);
return res;
}
int get(int key) {
if(cache.find(key)==cache.end()){
return -1;
} else{
DLinkedNode* node=cache.find(key)->second;
moveToHead(node);
cache[key]=node;
return node->value;
}
}
void put(int key, int value) {
if(cache.find(key)==cache.end()){
if(cache.size()<capacity) {
DLinkedNode *node = new DLinkedNode(key, value);
addNodeAfterHead(node);
cache[key] = node;
} else {
cache.erase(popTail()->key);//pop的node也要从cache中删除
DLinkedNode* node=new DLinkedNode(key,value);
addNodeAfterHead(node);
cache[key]=node;
}
} else {
DLinkedNode* node=cache.find(key)->second;
node->value=value;
moveToHead(node);
cache[key]=node;
}
}
private:
std::unordered_map <int, DLinkedNode*> cache;
int size;
int capacity;
DLinkedNode* head, *tail;
};
int main(){
LRUCacheImp lruCache(2);
std::cout<<lruCache.get(2)<<std::endl;
lruCache.put(1,1);
lruCache.put(2,2);
std::cout<<lruCache.get(1)<<std::endl;
lruCache.put(3,3);
std::cout<<lruCache.get(2)<<std::endl;
std::cout<<lruCache.get(3)<<std::endl;
} | [
"1369296693@qq.com"
] | 1369296693@qq.com |
10a44f93099b2da8ce543fd2c58f2ccff2fc7008 | 8fe33fbaefd13ac9b9f4ff38060c6baa43d04e15 | /QtGuiApplication1/coordinatesdialog.h | 86bada89586e8731ebea328c4228f57522b5e85a | [] | no_license | rastosl/cb-cpp-or | ef3d28c4914dea0cafb52a928e869859e94e63c5 | 1d6c096a74e6fd2a22eb83f753d9b8ae880b8a31 | refs/heads/master | 2020-09-25T08:59:11.465782 | 2019-12-16T00:49:37 | 2019-12-16T00:49:37 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 480 | h | #ifndef _COORDINATES_DIALOG_H
#define _COORDINATES_DIALOG_H
#include <memory>
#include <QWidget>
#include "transformationmatrix4x4.h"
class CoordinatesDialog : public QWidget
{
Q_OBJECT
public:
CoordinatesDialog(QWidget *parent = nullptr);
~CoordinatesDialog();
void setCoordinates(const TransformationMatrix4x4 &coordsMatrix);
private:
class CoordinatesDialogImpl;
std::unique_ptr<CoordinatesDialogImpl> impl;
};
#endif // !_COORDINATES_DIALOG_H
| [
"rsgaleg@gmail.com"
] | rsgaleg@gmail.com |
ecab4c1f0178a66131f3ab0f6a61b3eb04fcebfa | ef515f207766506f3ebfa067d02fe73028b0b1d0 | /cpp/util.h | 6e1cc13cc947ae0eea1ceeaeb01aace03e8df0f5 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0"
] | permissive | cmuxstream/cmuxstream-core | ca9b7c51f4d2bfe9ecf9e3923254c44604ee7863 | 2220550f0805081069473609e7795705c57884e3 | refs/heads/master | 2021-03-24T12:52:42.533032 | 2018-05-25T15:35:41 | 2018-05-25T15:35:41 | 106,595,486 | 30 | 14 | null | null | null | null | UTF-8 | C++ | false | false | 473 | h | #ifndef XSTREAM_UTIL_H_
#define XSTREAM_UTIL_H_
#include <cmath>
#include <string>
#include <vector>
#include <iostream>
namespace std {
inline void
panic(string message) {
cout << message << endl;
exit(-1);
}
float
euclidean_distance(vector<float>& x, vector<float>& y) {
float dist = 0.0;
uint n = x.size();
for (uint i = 0; i < n; i++)
dist += (x[i] - y[i]) * (x[i] - y[i]);
dist = sqrt(dist);
return dist;
}
}
#endif
| [
"emaadmanzoor@gmail.com"
] | emaadmanzoor@gmail.com |
fb16c9b0a2ce1791cd7d65bc5bf40999f09a4ba6 | 99c8e6f2e6e8709ab47d845832c3eba5237e7980 | /protocol/BrokerReply.h | 63b42d3d127fa52292c34c773c2a43dc6db4f0ab | [] | no_license | Global-localhost/flowbroker-client | ac59249381b0061c70f0940080580180ed7bf9ed | eacf6c1949e891911c1237b69a039f0600630d6e | refs/heads/master | 2022-12-13T19:02:21.316690 | 2016-12-13T15:20:33 | 2016-12-13T15:20:33 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,723 | h | //
// Created by Markus Jungbluth on 13.06.16.
//
#ifndef BROKER_PROTOCOL_CLIENT_BROKERREPLY_H
#define BROKER_PROTOCOL_CLIENT_BROKERREPLY_H
#include <string>
#include <map>
using namespace std;
class BrokerReply {
public:
BrokerReply();
/**
* Returns all parameters of the reply
* @return Returns a map containing the key value pairs.
*/
map<string, string> getParameters() const{
return parameters;
}
/**
* Adds a parameter to the reply
* @param key
* @param value
*/
void addParameter(string key, string value) {
this->parameters[key] = value;
}
/**
* Returns the message of the reply
* @return A string containing the message of the reply
*/
string getMessage() const {
return this->message;
}
/**
* Sets the message of the reply.
* @param message
*/
void setMessage(string message) {
this->message = message;
}
/**
* Sets the status code of the reply.
* @param statusCode
*/
void setStatusCode(int statusCode) {
this->statusCode = statusCode;
}
/**
* Returns the status code of the reply.
* @return An integer containing the 3 digit status code
*/
int getStatusCode() {
return statusCode;
}
/**
* Returns a string not containing the Signature parameter.
* This method is used when verifying the HMAC of a reply.
* @return A string that is used by the BrokerSecurityModule
*/
string toStringForSignatureValidation() const;
private:
int statusCode;
string message;
map<string, string> parameters;
};
#endif //BROKER_PROTOCOL_CLIENT_BROKERREPLY_H
| [
"markusju@users.noreply.github.com"
] | markusju@users.noreply.github.com |
b52d0596abb574bab7746781089769d10a5170ee | 69416d808cdb41609874104401f25b084193eab8 | /CLion/P10837.cpp | dec8d1083fa729d4af06e583d71f2601717f7cb2 | [] | no_license | CubeDr/Bakejoon | 50196f5fcf063c651cebfc9a4f019aada474fa2d | 127f12196517ba834eb1b5bbe742625375a595d1 | refs/heads/master | 2020-03-29T11:43:41.497063 | 2019-10-20T06:03:39 | 2019-10-20T06:03:39 | 149,867,522 | 0 | 0 | null | null | null | null | WINDOWS-1252 | C++ | false | false | 562 | cpp | #include <cstdio>
int K;
bool ables[1001][1001];
bool canWin(int x, int y, int left) {
return x + left >= y;
}
void buildAbles(int m = 0, int n = 0) {
ables[m][n] = true;
int k = (m>n?m:n)+1;
int left = K-k;
if(!canWin(m,n,left) || !canWin(n,m,left)) return;
// 1. m °áÁ¤
// 1-1. m Á¡¼ö ¶¡
}
int main()
{
scanf("%d", &K);
buildAbles();
int C;
scanf("%d", &C);
int m, n;
for(int i=0; i<C; i++) {
scanf("%d %d", &m, &n);
printf("%d\n", able[m][n]? 1 : 0);
}
return 0;
}
| [
"spaceship00@naver.com"
] | spaceship00@naver.com |
37e52a3b3169eb908685268b9cfeb93e7017c114 | 24f05b7e58a7d6000f4e1e261c01396652640a5b | /cpp_practice/source.cpp | 494dbc896bdce4c37a9c66e312bfc1488090c3c3 | [] | no_license | Celox16/cpp_practice | 03f7f859de8058b415852fa736dd740b0ae940e2 | a6361353778d794e22873b6eb40dd1779fe56ce4 | refs/heads/master | 2023-06-24T12:48:30.382256 | 2021-07-23T08:51:22 | 2021-07-23T08:51:22 | 388,672,652 | 0 | 0 | null | null | null | null | UHC | C++ | false | false | 525 | cpp | #include <iostream>
using namespace std;
template <typename T>
class Data {
private:
T data;
public:
Data(T data) : data(data) { }
T getData() { return data; }
Data<T> operator /(const Data<T>& other) {
if (other.data == 0) {
throw 0;
}
return Data(data / other.data);
}
};
int main(void) {
try {
Data<int> a(7);
Data<int> b(0);
Data<int> result = a / b;
cout << result.getData() << endl;
}
catch (int e) {
if (e == 0) {
cout << "0으로 나눌 수 없습니다." << endl;
}
}
return 0;
} | [
"sck04184@naver.com"
] | sck04184@naver.com |
cbe95c8ed8dd4a87b70d555112e4cd897dccab6e | 9160d5980d55c64c2bbc7933337e5e1f4987abb0 | /base/src/sgpp/base/operation/hash/OperationEvalHessianFundamentalSplineNaive.cpp | f64d825c1afd42781c9654acdded6dc3811e4a92 | [
"LicenseRef-scancode-generic-exception",
"BSD-3-Clause"
] | permissive | SGpp/SGpp | 55e82ecd95ac98efb8760d6c168b76bc130a4309 | 52f2718e3bbca0208e5e08b3c82ec7c708b5ec06 | refs/heads/master | 2022-08-07T12:43:44.475068 | 2021-10-20T08:50:38 | 2021-10-20T08:50:38 | 123,916,844 | 68 | 44 | NOASSERTION | 2022-06-23T08:28:45 | 2018-03-05T12:33:52 | C++ | UTF-8 | C++ | false | false | 5,093 | cpp | // Copyright (C) 2008-today The SG++ project
// This file is part of the SG++ project. For conditions of distribution and
// use, please see the copyright notice provided with SG++ or at
// sgpp.sparsegrids.org
#include <sgpp/globaldef.hpp>
#include <sgpp/base/operation/hash/OperationEvalHessianFundamentalSplineNaive.hpp>
#include <vector>
namespace sgpp {
namespace base {
double OperationEvalHessianFundamentalSplineNaive::evalHessian(const DataVector& alpha,
const DataVector& point,
DataVector& gradient,
DataMatrix& hessian) {
const size_t n = storage.getSize();
const size_t d = storage.getDimension();
double result = 0.0;
pointInUnitCube = point;
storage.getBoundingBox()->transformPointToUnitCube(pointInUnitCube);
for (size_t t = 0; t < d; t++) {
innerDerivative[t] = 1.0 / storage.getBoundingBox()->getIntervalWidth(t);
}
gradient.resize(d);
gradient.setAll(0.0);
hessian = DataMatrix(d, d);
DataVector curGradient(d);
DataMatrix curHessian(d, d);
for (size_t i = 0; i < n; i++) {
const GridPoint& gp = storage[i];
double curValue = 1.0;
curGradient.setAll(alpha[i]);
curHessian.setAll(alpha[i]);
for (size_t t = 0; t < d; t++) {
const double val1d = base.eval(gp.getLevel(t), gp.getIndex(t), pointInUnitCube[t]);
const double dx1d = base.evalDx(gp.getLevel(t), gp.getIndex(t), pointInUnitCube[t]) *
innerDerivative[t];
const double dxdx1d = base.evalDxDx(gp.getLevel(t), gp.getIndex(t), pointInUnitCube[t]) *
innerDerivative[t] * innerDerivative[t];
curValue *= val1d;
for (size_t t2 = 0; t2 < d; t2++) {
if (t2 == t) {
curGradient[t2] *= dx1d;
for (size_t t3 = 0; t3 < d; t3++) {
if (t3 == t) {
curHessian(t2, t3) *= dxdx1d;
} else {
curHessian(t2, t3) *= dx1d;
}
}
} else {
curGradient[t2] *= val1d;
for (size_t t3 = 0; t3 < d; t3++) {
if (t3 == t) {
curHessian(t2, t3) *= dx1d;
} else {
curHessian(t2, t3) *= val1d;
}
}
}
}
}
result += alpha[i] * curValue;
gradient.add(curGradient);
hessian.add(curHessian);
}
return result;
}
void OperationEvalHessianFundamentalSplineNaive::evalHessian(const DataMatrix& alpha,
const DataVector& point,
DataVector& value,
DataMatrix& gradient,
std::vector<DataMatrix>& hessian) {
const size_t n = storage.getSize();
const size_t d = storage.getDimension();
const size_t m = alpha.getNcols();
pointInUnitCube = point;
storage.getBoundingBox()->transformPointToUnitCube(pointInUnitCube);
for (size_t t = 0; t < d; t++) {
innerDerivative[t] = 1.0 / storage.getBoundingBox()->getIntervalWidth(t);
}
value.resize(m);
value.setAll(0.0);
gradient.resize(m, d);
gradient.setAll(0.0);
if (hessian.size() != m) {
hessian.resize(m);
}
for (size_t j = 0; j < m; j++) {
hessian[j].resize(d, d);
hessian[j].setAll(0.0);
}
DataVector curGradient(d);
DataMatrix curHessian(d, d);
for (size_t i = 0; i < n; i++) {
const GridPoint& gp = storage[i];
double curValue = 1.0;
curGradient.setAll(1.0);
curHessian.setAll(1.0);
for (size_t t = 0; t < d; t++) {
const double val1d = base.eval(gp.getLevel(t), gp.getIndex(t), pointInUnitCube[t]);
const double dx1d = base.evalDx(gp.getLevel(t), gp.getIndex(t), pointInUnitCube[t]) *
innerDerivative[t];
const double dxdx1d = base.evalDxDx(gp.getLevel(t), gp.getIndex(t), pointInUnitCube[t]) *
innerDerivative[t] * innerDerivative[t];
curValue *= val1d;
for (size_t t2 = 0; t2 < d; t2++) {
if (t2 == t) {
curGradient[t2] *= dx1d;
for (size_t t3 = 0; t3 < d; t3++) {
if (t3 == t) {
curHessian(t2, t3) *= dxdx1d;
} else {
curHessian(t2, t3) *= dx1d;
}
}
} else {
curGradient[t2] *= val1d;
for (size_t t3 = 0; t3 < d; t3++) {
if (t3 == t) {
curHessian(t2, t3) *= dx1d;
} else {
curHessian(t2, t3) *= val1d;
}
}
}
}
}
for (size_t j = 0; j < m; j++) {
value[j] += alpha(i, j) * curValue;
for (size_t t = 0; t < d; t++) {
gradient(j, t) += alpha(i, j) * curGradient[t];
for (size_t t2 = 0; t2 < d; t2++) {
hessian[j](t, t2) += alpha(i, j) * curHessian(t, t2);
}
}
}
}
}
} // namespace base
} // namespace sgpp
| [
"julian.valentin@ipvs.uni-stuttgart.de"
] | julian.valentin@ipvs.uni-stuttgart.de |
a663c9ae311c9b91f0d1d3a65bf850e267b80204 | 648fc20bb41cb03b9c1b70204824af53b814dd42 | /URI/uri1071-CASTILHO.cpp | 9538b68730976b84e7a59709299840559c8f30b2 | [] | no_license | joaopaulocastilho/aBNT-Codes | a2a9c3a87e20ff3e219efeccfe42eade4470e485 | 5af8fe1b789efbbcf3d293656e47ec674377bc5b | refs/heads/master | 2021-03-27T12:30:58.405856 | 2019-10-24T18:15:56 | 2019-10-24T18:15:56 | 104,107,658 | 1 | 2 | null | 2019-10-24T18:15:58 | 2017-09-19T17:43:30 | C++ | UTF-8 | C++ | false | false | 265 | cpp | #include<stdio.h>
int main(void) {
int inf, sup, aux, i, soma = 0;
scanf("%d %d", &inf, &sup);
if (inf > sup) {
aux = inf;
inf = sup;
sup = aux;
}
for (i = inf + 1; i < sup; i++) soma += (i & 1) ? i : 0;
printf("%d\n", soma);
return 0;
}
| [
"joao.pkc@gmail.com"
] | joao.pkc@gmail.com |
74427b41577e31772b1cc6f71522e35d97d7b972 | efb416524a5e01f25594f2dd5cdeb646489f93e1 | /FindPathInGraph/Floyd.cpp | 286b202d8cb9717607a69330cd9d667f5fb1950c | [] | no_license | whosxavierwu/LeetCodeSolution | fcb0d7efb9414acc91cfe7272bb4ddf23900d73f | 5925901375c9b1e43e8d65a64ff31564c42dfdf1 | refs/heads/master | 2023-08-11T01:20:25.934236 | 2023-07-23T10:00:34 | 2023-07-23T10:00:34 | 195,152,346 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 301 | cpp | #include <vector>
using namespace std;
void floyd(vector<vector<int>>& a){
int n = a.size();
for (int k = 0; k < n; ++k){
for (int i = 0; i < n; ++i){
for (int j = 0; j < n; ++j) {
a[i][j] = min(a[i][j], a[i][k] + a[k][j]);
}
}
}
}
| [
"whosxavierwu@gmail.com"
] | whosxavierwu@gmail.com |
9c5d2cb52fb6006ef03e35a90c28fdfe3e5a16e4 | 9ca3af416c8c6cb6c7f3658bbfa0ec9062b8a593 | /Must Do Coding Questions For Interviews/Heap/4. Rearrange_characters.cpp | ab0aa2474940fbbf3dc6b73ad247fb9db77f02e6 | [] | no_license | parthgoyal123/GeeksForGeeks | 31940debe7de36aba11fe1d2f20a39cff74a5b80 | 17b0e464ab8474b52d5737fac446c407033b13bb | refs/heads/master | 2020-06-13T12:47:05.701558 | 2019-09-20T11:42:32 | 2019-09-20T11:42:32 | 194,659,113 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,172 | cpp | #include <bits/stdc++.h>
using namespace std;
#define ll long long
#define md 1000000007
#define loop(i,a,b) for(int i=a; i<b; i++)
#define lloop(i,a,b) for (long long i=a; i<b; i++)
#define loopr(i,a,b) for(int i = a; i>=b; i--)
#define iterate(it, v) for (auto it = v.begin(); it!= v.end(); it++)
#define mk make_pair
#define pb push_back
template <typename T>
void printArray(T *arr, int n){
loop(i,0,n){
cout << arr[i] << " ";
} cout << endl;
}
template <typename T>
void printMatrix(T **arr, int n, int m){
loop(i,0,n){
loop(j,0,m) {
cout << arr[i][j] << " ";
}
cout << endl;
}
cout << endl;
}
struct Key {
char c;
int count;
bool operator<(const Key &k1) const {
return this->count < k1.count;
}
};
/* check if we can rearrange string such that no two same character are adjacent*/
bool canRearrangeCharacters(string &str) {
int n = str.length();
// store frequency in hash table
int hash[26] = {0};
int max_freq = 0;
// construct the frequency table
for(int i = 0; i<str.length(); i++) {
hash[str[i]-'a']++;
}
priority_queue <Key> pq;
for(int i = 0; i<26; i++) {
char ch = i + 'a';
if(hash[i] > 0) pq.push(Key{ch, hash[i]});
}
// final string
str = "";
// remember the previous Key
Key prev{'#', -1};
// traverse queue
while(!pq.empty()) {
// get the top character and append it to final string
Key top = pq.top();
pq.pop();
str = str + top.c;
// cout << top.c << " " << top.count << endl;
// push to queue if previous count is > 0
if(prev.count > 0) pq.push(prev);
// decrease the count of the top element and update prev
(top.count)--;
prev = top;
}
if(n != str.length()) return false;
return true;
}
int main(){
ios_base::sync_with_stdio(false);
int t;
cin >> t;
while(t--){
string str;
cin >> str;
cout << canRearrangeCharacters(str) << endl;
}
} | [
"goyal.parth99@gmail.com"
] | goyal.parth99@gmail.com |
e8bcccfa1f987612cfb20484250a7ca4624f0c58 | 6c2997d8df0feae2af63c8b6f08855dcdd786cef | /framework/PVRVk/DescriptorSetVk.h | d57011bdebc41fe5ba871510c770e8f170989362 | [
"MIT"
] | permissive | hliatis/Native_SDK | 44eefd95da0b5a3a96f32f56e7cb801d96def6af | 3664fbd6f0cd8a2b9ca2d772af173802f5d5b4fc | refs/heads/master | 2020-06-12T03:38:48.556293 | 2019-06-27T14:17:50 | 2019-06-27T14:17:50 | 194,182,487 | 0 | 0 | MIT | 2019-06-28T00:57:29 | 2019-06-28T00:57:28 | null | UTF-8 | C++ | false | false | 33,110 | h | /*!
\brief The DescriptorSet class, representing a "directory" of shader-accessible objects
like Buffers and Images
\file PVRVk/DescriptorSetVk.h
\author PowerVR by Imagination, Developer Technology Team
\copyright Copyright (c) Imagination Technologies Limited.
*/
#pragma once
#include "PVRVk/DeviceVk.h"
#include "PVRVk/PipelineConfigVk.h"
#include "PVRVk/BufferVk.h"
namespace pvrvk {
/// <summary>Contains all information required to create a Descriptor Set Layout. This is the number of Textures,
/// Samplers, Uniform Buffer Objects, and Shader Storage Buffer Objects bound for any shader stage.</summary>
struct DescriptorSetLayoutCreateInfo
{
private:
struct DescriptorSetLayoutBinding
{
uint16_t binding;
pvrvk::DescriptorType descriptorType;
uint16_t descriptorCount;
pvrvk::ShaderStageFlags stageFlags;
Sampler immutableSampler;
DescriptorSetLayoutBinding() : descriptorCount(1), stageFlags(pvrvk::ShaderStageFlags::e_ALL), descriptorType(pvrvk::DescriptorType::e_MAX_ENUM) {}
DescriptorSetLayoutBinding(uint16_t bindIndex, pvrvk::DescriptorType descType, uint16_t descriptorCount = 1,
pvrvk::ShaderStageFlags stageFlags = pvrvk::ShaderStageFlags::e_ALL, const Sampler& immutableSampler = Sampler())
: binding(bindIndex), descriptorType(descType), descriptorCount(descriptorCount), stageFlags(stageFlags), immutableSampler(immutableSampler)
{}
bool operator==(const DescriptorSetLayoutBinding& rhs) const
{
return binding == rhs.binding && descriptorType == rhs.descriptorType && descriptorCount == rhs.descriptorCount && stageFlags == rhs.stageFlags;
}
bool operator!=(const DescriptorSetLayoutBinding& rhs) const
{
return !(*this == rhs);
}
};
std::vector<DescriptorSetLayoutBinding> descLayoutInfo;
public:
/// <summary>Set the buffer binding of Descriptor Objects in the specified shader stages.</summary>
/// <param name="binding">The index to which the binding will be added</param>
/// <param name="descriptorType">The type of descriptor</param>
/// <param name="descriptorCount">The number of descriptors to add starting at that index</param>
/// <param name="stageFlags">The shader stages for which the number of bindings is set to (count)</param>
/// <param name="immutableSampler">If an immutable sampler is set, pass it here. See vulkan spec</param>
/// <returns>This object (allows chaining of calls)</returns>
DescriptorSetLayoutCreateInfo& setBinding(uint16_t binding, pvrvk::DescriptorType descriptorType, uint16_t descriptorCount = 1,
pvrvk::ShaderStageFlags stageFlags = pvrvk::ShaderStageFlags::e_ALL, Sampler immutableSampler = Sampler())
{
const DescriptorSetLayoutBinding layoutBinding(binding, descriptorType, descriptorCount, stageFlags, immutableSampler);
auto it = std::find_if(descLayoutInfo.begin(), descLayoutInfo.end(), [&](const DescriptorSetLayoutBinding& info) { return info.binding == layoutBinding.binding; });
if (it != descLayoutInfo.end())
{
(*it) = layoutBinding;
}
else
{
descLayoutInfo.emplace_back(layoutBinding);
}
return *this;
}
/// <summary>Clear all entries</summary>
/// <returns>Return this for chaining</returns>
DescriptorSetLayoutCreateInfo& clear()
{
descLayoutInfo.clear();
return *this;
}
/// <summary>Return the number of images in this object</summary>
/// <returns>the number of images in this object</returns>
uint16_t getNumBindings() const
{
return static_cast<uint16_t>(descLayoutInfo.size());
}
/// <summary>Equality operator. Does deep comparison of the contents.</summary>
/// <param name="rhs">The right-hand side argument of the operator.</param>
/// <returns>True if the layouts have identical bindings</returns>
bool operator==(const DescriptorSetLayoutCreateInfo& rhs) const
{
if (getNumBindings() != rhs.getNumBindings())
{
return false;
}
for (uint32_t i = 0; i < getNumBindings(); ++i)
{
if (descLayoutInfo[i] != rhs.descLayoutInfo[i])
{
return false;
}
}
return true;
}
/// <summary>Get descriptor binding</summary>
/// <param name="bindingId">Binding Index</param>
/// <returns>The binding layout object (DescriptorBindingLayout)</returns>
const DescriptorSetLayoutBinding* getBinding(uint16_t bindingId) const
{
auto it = std::find_if(descLayoutInfo.begin(), descLayoutInfo.end(), [&](const DescriptorSetLayoutBinding& info) { return info.binding == bindingId; });
if (it != descLayoutInfo.end())
{
return &(*it);
}
return nullptr;
}
/// <summary>Get all layout bindings</summary>
/// <returns>const DescriptorSetLayoutBinding*</returns>
const DescriptorSetLayoutBinding* getAllBindings() const
{
return descLayoutInfo.data();
}
private:
friend class ::pvrvk::impl::DescriptorSetLayout_;
friend struct ::pvrvk::WriteDescriptorSet;
};
namespace impl {
/// <summary>Constructor. . Vulkan implementation of a DescriptorSet.</summary>
class DescriptorSetLayout_ : public PVRVkDeviceObjectBase<VkDescriptorSetLayout, ObjectType::e_DESCRIPTOR_SET_LAYOUT>, public DeviceObjectDebugUtils<DescriptorSetLayout_>
{
private:
friend class Device_;
class make_shared_enabler
{
protected:
make_shared_enabler() = default;
friend class DescriptorSetLayout_;
};
static DescriptorSetLayout constructShared(const DeviceWeakPtr& device, const DescriptorSetLayoutCreateInfo& createInfo)
{
return std::make_shared<DescriptorSetLayout_>(make_shared_enabler{}, device, createInfo);
}
DescriptorSetLayoutCreateInfo _createInfo;
public:
//!\cond NO_DOXYGEN
DECLARE_NO_COPY_SEMANTICS(DescriptorSetLayout_)
~DescriptorSetLayout_();
DescriptorSetLayout_(make_shared_enabler, const DeviceWeakPtr& device, const DescriptorSetLayoutCreateInfo& createInfo);
//!\endcond
/// <summary>Get the DescriptorSetCreateInfo object that was used to create this layout.</summary>
/// <returns>The DescriptorSetCreateInfo object that was used to create this layout.</returns>
const DescriptorSetLayoutCreateInfo& getCreateInfo() const
{
return _createInfo;
}
/// <summary>Clear the descriptor set layout create param list.</summary>
void clearCreateInfo()
{
_createInfo.clear();
}
};
/// <summary>Internal class</summary>
template<typename T, uint32_t ArraySize>
class DescriptorStore
{
//!\cond NO_DOXYGEN
public:
DescriptorStore() : _ptr(_tArray), _numItems(0) {}
// Copy Constructor
DescriptorStore(const DescriptorStore& descStore) : _numItems(descStore._numItems), _tVector(descStore._tVector)
{
// Copy _tArray elements
std::copy(std::begin(descStore._tArray), std::end(descStore._tArray), _tArray);
// Point towards _tVector.data() if _tVector is being used else point towards _tArray
_ptr = !_tVector.empty() ? _tVector.data() : _tArray;
}
// Destructor
~DescriptorStore() = default;
// Add swap functionality
friend void swap(DescriptorStore& first, DescriptorStore& second)
{
using std::swap;
// IF second._ptr is pointing to the array then point to MY array
// If second._ptr is pointing to the vector then point to seconds vector
T* tempPtr1 = second._ptr == second._tArray ? first._tArray : second._tVector.data();
first._ptr = tempPtr1;
// IF first._ptr is pointing to the array then point to MY array
// If first._ptr is pointing to the vector then point to firsts vector
T* tempPtr2 = first._ptr == first._tArray ? second._tArray : first._tVector.data();
second._ptr = tempPtr2;
swap(first._numItems, second._numItems);
swap(first._tVector, second._tVector);
swap(first._tArray, second._tArray);
}
// Assignment Operator
DescriptorStore& operator=(DescriptorStore other)
{
swap(*this, other);
return *this;
}
// Move Assignment Operator
DescriptorStore& operator=(DescriptorStore&& other)
{
swap(other);
return *this;
}
// Move constructor
DescriptorStore(DescriptorStore&& other) noexcept : DescriptorStore()
{
swap(*this, other);
}
void clear()
{
// Reset each of the items
std::fill(std::begin(_tArray), std::end(_tArray), T());
_tVector.clear();
_ptr = _tArray;
_numItems = 0;
}
void set(uint32_t index, const T& obj)
{
// Move to overflow when the number of items reaches the limit of the limited storage array
if (_tVector.empty() && index >= ArraySize)
{
// Move the limited storage array into the vector
moveToOverFlow();
}
// Determine whether we should grow the container
if (!_tVector.empty() && index >= _tVector.size())
{
// Grow by ArraySize to reduce the number of times we call resize
_tVector.resize(index + ArraySize);
_ptr = _tVector.data();
}
_numItems = std::max(_numItems, index + 1);
_ptr[index] = obj;
// Ensure _ptr is pointing at either _tArray or _tVector.data() depending on the index currently being set
assert(index < ArraySize ? _ptr == _tArray : true && "Pointer must be pointing at _tArray");
assert(index >= ArraySize ? _ptr == _tVector.data() : true && "Pointer must be pointing at _tVector.data()");
}
uint32_t size() const
{
return _numItems;
}
const T* begin() const
{
return _ptr;
}
const T* end() const
{
return _ptr + _numItems;
}
const T& operator[](uint32_t index) const
{
return get(index);
}
const T& get(uint32_t index) const
{
return _ptr[index];
}
private:
void moveToOverFlow()
{
_tVector.reserve(ArraySize * 2);
_tVector.assign(std::begin(_tArray), std::end(_tArray));
// The pointer now points to the head of the vector
_ptr = _tVector.data();
}
T _tArray[ArraySize];
std::vector<T> _tVector;
T* _ptr;
uint32_t _numItems;
//!\endcond
};
} // namespace impl
/// <summary>Descriptor Pool create parameter.</summary>
struct DescriptorPoolCreateInfo
{
private:
std::pair<pvrvk::DescriptorType, uint16_t> _descriptorTypes[static_cast<uint32_t>(pvrvk::DescriptorType::e_RANGE_SIZE)];
uint16_t _numDescriptorTypes;
uint16_t _maxSets;
public:
/// <summary>Constructor</summary>
DescriptorPoolCreateInfo() : _numDescriptorTypes(0), _maxSets(200) {}
/// <summary>Constructor</summary>
/// <param name="maxSets">The maximum number of descriptor sets which can be allocated by this descriptor pool</param>
/// <param name="combinedImageSamplers">The maximum number of combined image samplers descriptor types which can be used in descriptor sets allocated by this descriptor
/// pool.</param> <param name="inputAttachments">The maximum number of input attachment descriptor types which can be used in descriptor sets allocated by this descriptor
/// pool.</param> <param name="staticUbos">The maximum number of uniform buffer descriptor types which can be used in descriptor sets allocated by this descriptor
/// pool.</param> <param name="dynamicUbos">The maximum number of dynamic uniform buffers descriptor types which can be used in descriptor sets allocated by this descriptor
/// pool.</param> <param name="staticSsbos">The maximum number of storage buffer descriptor types which can be used in descriptor sets allocated by this descriptor
/// pool.</param> <param name="dynamicSsbos">The maximum number of dynamic storage buffer descriptor types which can be used in descriptor sets allocated by this descriptor
/// pool.</param>
explicit DescriptorPoolCreateInfo(uint16_t maxSets, uint16_t combinedImageSamplers = 32, uint16_t inputAttachments = 0, uint16_t staticUbos = 32, uint16_t dynamicUbos = 32,
uint16_t staticSsbos = 0, uint16_t dynamicSsbos = 0)
: _numDescriptorTypes(0), _maxSets(maxSets)
{
if (combinedImageSamplers != 0)
{
addDescriptorInfo(pvrvk::DescriptorType::e_COMBINED_IMAGE_SAMPLER, combinedImageSamplers);
}
if (inputAttachments != 0)
{
addDescriptorInfo(pvrvk::DescriptorType::e_INPUT_ATTACHMENT, inputAttachments);
}
if (staticUbos != 0)
{
addDescriptorInfo(pvrvk::DescriptorType::e_UNIFORM_BUFFER, staticUbos);
}
if (dynamicUbos != 0)
{
addDescriptorInfo(pvrvk::DescriptorType::e_UNIFORM_BUFFER_DYNAMIC, dynamicUbos);
}
if (staticSsbos != 0)
{
addDescriptorInfo(pvrvk::DescriptorType::e_STORAGE_BUFFER, staticSsbos);
}
if (dynamicSsbos != 0)
{
addDescriptorInfo(pvrvk::DescriptorType::e_STORAGE_BUFFER_DYNAMIC, dynamicSsbos);
}
}
/// <summary>Add the maximum number of the specified descriptor types that the pool will contain.</summary>
/// <param name="descType">Descriptor type</param>
/// <param name="count">Maximum number of descriptors of (type)</param>
/// <returns>this (allow chaining)</returns>
DescriptorPoolCreateInfo& addDescriptorInfo(pvrvk::DescriptorType descType, uint16_t count)
{
_descriptorTypes[_numDescriptorTypes] = std::make_pair(descType, count);
_numDescriptorTypes++;
return *this;
}
/// <summary>Set the maximum number of descriptor sets.</summary>
/// <param name="maxSets">The maximum number of descriptor sets</param>
/// <returns>this (allow chaining)</returns>
DescriptorPoolCreateInfo& setMaxDescriptorSets(uint16_t maxSets)
{
this->_maxSets = maxSets;
return *this;
}
/// <summary>Get the number of allocations of a descriptor type is supported on this pool (const).</summary>
/// <param name="descType">DescriptorType</param>
/// <returns>Number of allocations.</returns>
uint16_t getNumDescriptorTypes(pvrvk::DescriptorType descType) const
{
for (uint16_t i = 0; i < _numDescriptorTypes; i++)
{
if (_descriptorTypes[i].first == descType)
{
return _descriptorTypes[i].second;
}
}
return 0;
}
/// <summary>Get maximum sets supported on this pool.</summary>
/// <returns>uint32_t</returns>
uint16_t getMaxDescriptorSets() const
{
return _maxSets;
}
};
/// <summary>This class contains all the information necessary to populate a Descriptor Set with the actual API
/// objects. Use with the method update of the DescriptorSet. Populate this object with actual Descriptor objects
/// (UBOs, textures etc).</summary>
struct DescriptorImageInfo
{
Sampler sampler; //!< Sampler handle, and is used in descriptor updates for types pvrvk::DescriptorType::e_SAMPLER and pvrvk::DescriptorType::e_COMBINED_IMAGE_SAMPLER if the
//!< binding being updated does not use immutable samplers
ImageView imageView; //!< Image view handle, and is used in descriptor updates for types pvrvk::DescriptorType::e_SAMPLED_IMAGE, pvrvk::DescriptorType::e_STORAGE_IMAGE,
//!< pvrvk::DescriptorType::e_COMBINED_IMAGE_SAMPLER, and pvrvk::DescriptorType::e_INPUT_ATTACHMENT
pvrvk::ImageLayout imageLayout; //!< Layout that the image subresources accessible from imageView will be in at the time this descriptor is accessed. imageLayout is used in
//!< descriptor updates for types pvrvk::DescriptorType::e_SAMPLED_IMAGE, pvrvk::DescriptorType::e_STORAGE_IMAGE,
//!< pvrvk::DescriptorType::e_COMBINED_IMAGE_SAMPLER, and pvrvk::DescriptorType::e_INPUT_ATTACHMENT
/// <summary>Constructor. Initalizes to pvrvk::ImageLayout::e_UNDEFINED</summary>
DescriptorImageInfo() : imageLayout(pvrvk::ImageLayout::e_UNDEFINED) {}
/// <summary>Constructor from a sampler object.</summary>
/// <param name="sampler">Sampler handle, and is used in descriptor updates for types
/// pvrvk::DescriptorType::e_SAMPLER and pvrvk::DescriptorType::e_COMBINED_IMAGE_SAMPLER if the binding being
/// updated does not use immutable samplers</param>
explicit DescriptorImageInfo(const Sampler& sampler) : sampler(sampler), imageLayout(pvrvk::ImageLayout::e_UNDEFINED) {}
/// <summary>Constructor from all elements</summary>
/// <param name="imageView">Image view handle, and is used in descriptor updates for types
/// pvrvk::DescriptorType::e_SAMPLED_IMAGE, pvrvk::DescriptorType::e_STORAGE_IMAGE,
/// pvrvk::DescriptorType::e_COMBINED_IMAGE_SAMPLER, and pvrvk::DescriptorType::e_INPUT_ATTACHMENT</param>
/// <param name="sampler">Sampler handle, and is used in descriptor updates for types
/// pvrvk::DescriptorType::e_SAMPLER and pvrvk::DescriptorType::e_COMBINED_IMAGE_SAMPLER if the binding
/// being updated does not use immutable samplers</param>
/// <param name="imageLayout">Layout that the image subresources accessible from imageView
/// will be in at the time this descriptor is accessed. imageLayout is used in descriptor
/// updates for types pvrvk::DescriptorType::e_SAMPLED_IMAGE, pvrvk::DescriptorType::e_STORAGE_IMAGE,
/// pvrvk::DescriptorType::e_COMBINED_IMAGE_SAMPLER, and pvrvk::DescriptorType::e_INPUT_ATTACHMENT</param>
DescriptorImageInfo(const ImageView& imageView, const Sampler& sampler, pvrvk::ImageLayout imageLayout = pvrvk::ImageLayout::e_SHADER_READ_ONLY_OPTIMAL)
: sampler(sampler), imageView(imageView), imageLayout(imageLayout)
{}
/// <summary>Constructor from all elements except sampler</summary>
/// <param name="imageView">Image view handle, and is used in descriptor updates for types
/// pvrvk::DescriptorType::e_SAMPLED_IMAGE, pvrvk::DescriptorType::e_STORAGE_IMAGE,
/// pvrvk::DescriptorType::e_COMBINED_IMAGE_SAMPLER, and pvrvk::DescriptorType::e_INPUT_ATTACHMENT</param>
/// <param name="imageLayout">Layout that the image subresources accessible from imageView
/// will be in at the time this descriptor is accessed. imageLayout is used in descriptor
/// updates for types pvrvk::DescriptorType::e_SAMPLED_IMAGE, pvrvk::DescriptorType::e_STORAGE_IMAGE,
/// pvrvk::DescriptorType::e_COMBINED_IMAGE_SAMPLER, and pvrvk::DescriptorType::e_INPUT_ATTACHMENT</param>
DescriptorImageInfo(const ImageView& imageView, pvrvk::ImageLayout imageLayout = pvrvk::ImageLayout::e_SHADER_READ_ONLY_OPTIMAL)
: imageView(imageView), imageLayout(imageLayout)
{}
};
/// <summary>A struct describing a descriptor buffer binding</summary>
struct DescriptorBufferInfo
{
Buffer buffer; //!< The buffer object
VkDeviceSize offset; //!< The offset into the buffer
VkDeviceSize range; //!< The range of the buffer
/// <summary>Constructor. Zero initialize.</summary>
DescriptorBufferInfo() : offset(0), range(0) {}
/// <summary>Constructor. Individual elements.</summary>
/// <param name="buffer">The referenced buffer</param>
/// <param name="offset">An offset into the buffer, if the buffer is piecemally bound</param>
/// <param name="range">A range of the buffer, if the buffer is piecemally bound</param>
DescriptorBufferInfo(const Buffer& buffer, VkDeviceSize offset, VkDeviceSize range) : buffer(buffer), offset(offset), range(range) {}
};
/// <summary>Contains information for an initialization/update of a descriptor set. This class
/// contains both the update AND the descriptor set to be updated, so that multiple descriptor
/// sets can be updated in a single call to Device::updateDescriptorSets</summary>
struct WriteDescriptorSet
{
/// <summary>Constructor. Undefined values</summary>
WriteDescriptorSet() : _infos() {}
/// <summary>Constructor. Initializes with a specified descriptor into a set</summary>
/// <param name="descType">The descriptor type of this write</param>
/// <param name="descSet">The descriptor set which to update</param>
/// <param name="dstBinding">The binding to update</param>
/// <param name="descType">The descriptor type of this write</param>
/// <param name="dstArrayElement">If the destination is an array, the array index to update</param>
WriteDescriptorSet(pvrvk::DescriptorType descType, DescriptorSet descSet, uint32_t dstBinding = 0, uint32_t dstArrayElement = 0)
: _descType(descType), _descSet(descSet), _dstBinding(dstBinding), _dstArrayElement(dstArrayElement), _infos()
{
set(descType, descSet, dstBinding, dstArrayElement);
}
/// <summary>Set the descriptor type</summary>
/// <param name="descType">The descriptor type</param>
/// <returns>This object (allow chaining)</returns>
WriteDescriptorSet& setDescriptorType(pvrvk::DescriptorType descType)
{
_descType = descType;
if ((_descType >= pvrvk::DescriptorType::e_SAMPLER && _descType <= pvrvk::DescriptorType::e_STORAGE_IMAGE) || _descType == pvrvk::DescriptorType::e_INPUT_ATTACHMENT)
{
_infoType = InfoType::ImageInfo;
}
else if (_descType >= pvrvk::DescriptorType::e_UNIFORM_BUFFER && _descType <= pvrvk::DescriptorType::e_STORAGE_BUFFER_DYNAMIC)
{
_infoType = InfoType::BufferInfo;
}
else if (_descType == pvrvk::DescriptorType::e_UNIFORM_TEXEL_BUFFER || _descType == pvrvk::DescriptorType::e_STORAGE_TEXEL_BUFFER)
{
_infoType = InfoType::TexelBufferView;
}
else
{
assert(false && "Cannot resolve Info type from descriptor type");
}
return *this;
}
/// <summary>Set the descriptor set</summary>
/// <param name="descriptorSet">The descriptor set that will be updated</param>
/// <returns>This object (allow chaining)</returns>
WriteDescriptorSet& setDescriptorSet(DescriptorSet& descriptorSet)
{
_descSet = descriptorSet;
return *this;
}
/// <summary>Set the destination binding</summary>
/// <param name="binding">The binding into the descriptor set</param>
/// <returns>This object (allow chaining)</returns>
WriteDescriptorSet& setDestBinding(uint32_t binding)
{
_dstBinding = binding;
return *this;
}
/// <summary>Set destination array element</summary>
/// <param name="arrayElement">Array element.</param>
/// <returns>This object (allow chaining)</returns>
WriteDescriptorSet& setDestArrayElement(uint32_t arrayElement)
{
_dstArrayElement = arrayElement;
return *this;
}
/// <summary>Sets all the data of this write</summary>
/// <param name="newDescType">The new descriptor type</param>
/// <param name="descSet">The new descriptor set</param>
/// <param name="dstBinding">The new destination Binding in spir-v</param>
/// <param name="dstArrayElement">If the target descriptor is an array,
/// the index to update.</param>
/// <returns>This object (allow chaining)</returns>
WriteDescriptorSet& set(pvrvk::DescriptorType newDescType, const DescriptorSet& descSet, uint32_t dstBinding = 0, uint32_t dstArrayElement = 0)
{
setDescriptorType(newDescType);
_descSet = descSet;
_dstBinding = dstBinding;
_dstArrayElement = dstArrayElement;
_infos.clear();
return *this;
}
/// <summary>If the target descriptor is an image, set the image info image info</summary>
/// <param name="arrayIndex">The target array index</param>
/// <param name="imageInfo">The image info to set</param>
/// <returns>This object (allow chaining)</returns>
WriteDescriptorSet& setImageInfo(uint32_t arrayIndex, const DescriptorImageInfo& imageInfo)
{
#ifdef DEBUG
// VALIDATE DESCRIPTOR TYPE
assert(((_descType >= pvrvk::DescriptorType::e_SAMPLER) && (_descType <= pvrvk::DescriptorType::e_STORAGE_IMAGE)) || (_descType == pvrvk::DescriptorType::e_INPUT_ATTACHMENT));
if (_descType == pvrvk::DescriptorType::e_COMBINED_IMAGE_SAMPLER)
{
assert(imageInfo.sampler && imageInfo.imageView && "Sampler and ImageView must be valid");
}
#endif
DescriptorInfos info;
info.imageInfo = imageInfo;
_infos.set(arrayIndex, info);
return *this;
}
/// <summary>If the target descriptor is a buffer, sets the buffer info</summary>
/// <param name="arrayIndex">If an array, the target array index</param>
/// <param name="bufferInfo">The buffer info to set</param>
/// <returns>This object(allow chaining)</returns>
WriteDescriptorSet& setBufferInfo(uint32_t arrayIndex, const DescriptorBufferInfo& bufferInfo)
{
#ifdef DEBUG
assert(_descType >= pvrvk::DescriptorType::e_UNIFORM_BUFFER && _descType <= pvrvk::DescriptorType::e_STORAGE_BUFFER_DYNAMIC);
assert(bufferInfo.buffer && "Buffer must be valid");
#endif
DescriptorInfos info;
info.bufferInfo = bufferInfo;
_infos.set(arrayIndex, info);
return *this;
}
/// <summary>If the target descriptor is a Texel buffer, set the Texel Buffer info</summary>
/// <param name="arrayIndex">If an array, the target array index</param>
/// <param name="bufferView">The Texel Buffer view to set</param>
/// <returns>This object(allow chaining)</returns>
WriteDescriptorSet& setTexelBufferInfo(uint32_t arrayIndex, const BufferView& bufferView)
{
#ifdef DEBUG
assert(_descType >= pvrvk::DescriptorType::e_UNIFORM_TEXEL_BUFFER && _descType <= pvrvk::DescriptorType::e_STORAGE_TEXEL_BUFFER);
assert(bufferView && "Texel BufferView must be valid");
#endif
DescriptorInfos info;
info.texelBuffer = bufferView;
_infos.set(arrayIndex, info);
return *this;
}
/// <summary>Clear all info of this object</summary>
/// <returns>This object(allow chaining)</returns>
WriteDescriptorSet& clearAllInfos()
{
_infos.clear();
return *this;
}
/// <summary>Get the number of descriptors being updated</summary>
/// <returns>The the number of descriptors</returns>
uint32_t getNumDescriptors() const
{
return _infos.size();
}
/// <summary>Get descriptor type</summary>
/// <returns>The descriptor type</returns>
pvrvk::DescriptorType getDescriptorType() const
{
return _descType;
}
/// <summary>Get descriptor set to update</summary>
/// <returns>The descriptor set</returns>
DescriptorSet getDescriptorSet()
{
return _descSet;
}
/// <summary>Get the descriptor set to update</summary>
/// <returns>The descriptor set</returns>
const DescriptorSet& getDescriptorSet() const
{
return _descSet;
}
/// <summary>If an array, get the destination array element</summary>
/// <returns>The destination array element</returns>
uint32_t getDestArrayElement() const
{
return _dstArrayElement;
}
/// <summary>Get the destination binding indiex</summary>
/// <returns>The destination binding index</returns>
uint32_t getDestBinding() const
{
return _dstBinding;
}
private:
friend class ::pvrvk::impl::Device_;
pvrvk::DescriptorType _descType;
DescriptorSet _descSet;
uint32_t _dstBinding;
uint32_t _dstArrayElement;
struct DescriptorInfos
{
DescriptorImageInfo imageInfo;
DescriptorBufferInfo bufferInfo;
BufferView texelBuffer;
DescriptorInfos() = default;
bool isValid() const
{
return imageInfo.imageView || imageInfo.sampler || bufferInfo.buffer || texelBuffer;
}
};
impl::DescriptorStore<DescriptorInfos, 4> _infos;
enum InfoType
{
ImageInfo,
BufferInfo,
TexelBufferView
};
InfoType _infoType;
// CALL THIS ONE FROM THE DEVICE - CPU SIDE KEEPING ALIVE OF THE DESCRIPTORS IN THIS SET
void updateKeepAliveIntoDestinationDescriptorSet() const;
};
/// <summary>Copy descriptor set</summary>
struct CopyDescriptorSet
{
DescriptorSet srcSet; //!< Source descriptor set to copy from
uint32_t srcBinding; //!< source binding to copy
uint32_t srcArrayElement; //!< source array element to copy from
DescriptorSet dstSet; //!< Destination descriptor set
uint32_t dstBinding; //!< Destination binding to copy in to.
uint32_t dstArrayElement; //!< Destination array element to copy into
uint32_t descriptorCount; //!< Number of descriptor to copy
};
namespace impl {
/// <summary>A descriptor pool - an object used to allocate (and recycle) Descriptor Sets.</summary>
class DescriptorPool_ : public PVRVkDeviceObjectBase<VkDescriptorPool, ObjectType::e_DESCRIPTOR_POOL>,
public DeviceObjectDebugUtils<DescriptorPool_>,
public std::enable_shared_from_this<DescriptorPool_>
{
private:
friend class Device_;
class make_shared_enabler
{
protected:
make_shared_enabler() = default;
friend class DescriptorPool_;
};
static DescriptorPool constructShared(const DeviceWeakPtr& device, const DescriptorPoolCreateInfo& createInfo)
{
return std::make_shared<DescriptorPool_>(make_shared_enabler{}, device, createInfo);
}
DescriptorPoolCreateInfo _createInfo;
public:
//!\cond NO_DOXYGEN
DECLARE_NO_COPY_SEMANTICS(DescriptorPool_)
~DescriptorPool_();
DescriptorPool_(make_shared_enabler, const DeviceWeakPtr& device, const DescriptorPoolCreateInfo& createInfo);
//!\endcond
/// <summary>Allocate descriptor set</summary>
/// <param name="layout">Descriptor set layout</param>
/// <returns>Return DescriptorSet else null if fails.</returns>
DescriptorSet allocateDescriptorSet(const DescriptorSetLayout& layout);
/// <summary>Return the descriptor pool create info from which this descriptor pool was allocated</summary>
/// <returns>The descriptor pool create info</returns>
const DescriptorPoolCreateInfo& getCreateInfo() const
{
return _createInfo;
}
};
/// <summary>Vulkan implementation of a DescriptorSet.</summary>
class DescriptorSet_ : public PVRVkDeviceObjectBase<VkDescriptorSet, ObjectType::e_DESCRIPTOR_SET>, public DeviceObjectDebugUtils<DescriptorSet_>
{
private:
friend struct ::pvrvk::WriteDescriptorSet;
friend class DescriptorPool_;
class make_shared_enabler
{
protected:
make_shared_enabler() = default;
friend class DescriptorSet_;
};
static DescriptorSet constructShared(const DescriptorSetLayout& descSetLayout, DescriptorPool& pool)
{
return std::make_shared<DescriptorSet_>(make_shared_enabler{}, descSetLayout, pool);
}
mutable std::vector<std::vector<std::shared_ptr<void> /**/> /**/> _keepAlive;
DescriptorSetLayout _descSetLayout;
DescriptorPool _descPool;
public:
//!\cond NO_DOXYGEN
DECLARE_NO_COPY_SEMANTICS(DescriptorSet_)
DescriptorSet_(make_shared_enabler, const DescriptorSetLayout& descSetLayout, DescriptorPool& pool)
: PVRVkDeviceObjectBase(pool->getDevice()), DeviceObjectDebugUtils(), _descSetLayout(descSetLayout), _descPool(pool)
{
// Create the Vulkan VkDescriptorSetAllocateInfo structure
VkDescriptorSetAllocateInfo allocInfo = {};
allocInfo.sType = static_cast<VkStructureType>(pvrvk::StructureType::e_DESCRIPTOR_SET_ALLOCATE_INFO);
allocInfo.pSetLayouts = &getDescriptorSetLayout()->getVkHandle();
allocInfo.descriptorSetCount = 1;
allocInfo.descriptorPool = getDescriptorPool()->getVkHandle();
// For appropriate smart reference counting we need to keep alive the bindings
const auto& allBindings = _descSetLayout->getCreateInfo().getAllBindings();
uint16_t maxBinding = 0;
uint32_t i = 0, size = _descSetLayout->getCreateInfo().getNumBindings();
// Loop through the descriptor set bindings and determine the maximum binding
for (; i < size; ++i)
{
maxBinding = std::max(allBindings[i].binding, maxBinding);
}
// Use the maximum binding + 1 to resize the keepAlive array
_keepAlive.resize(maxBinding + 1);
// Now use the descriptor count for each descriptor binding to determine the total number of entries
for (i = 0; i < size; ++i)
{
auto& entry = allBindings[i];
auto& aliveEntry = _keepAlive[entry.binding];
aliveEntry.resize(entry.descriptorCount);
}
vkThrowIfFailed(getDevice()->getVkBindings().vkAllocateDescriptorSets(_descSetLayout->getDevice()->getVkHandle(), &allocInfo, &_vkHandle), "Allocate Descriptor Set failed");
}
~DescriptorSet_()
{
_keepAlive.clear();
if (getVkHandle() != VK_NULL_HANDLE)
{
if (getDescriptorPool()->getDevice())
{
getDevice()->getVkBindings().vkFreeDescriptorSets(getDescriptorPool()->getDevice()->getVkHandle(), getDescriptorPool()->getVkHandle(), 1, &getVkHandle());
_vkHandle = VK_NULL_HANDLE;
}
else
{
reportDestroyedAfterDevice();
}
_descSetLayout.reset();
}
}
//!\endcond
/// <summary>Return the layout of this DescriptorSet.</summary>
/// <returns>This DescriptorSet's DescriptorSetLayout</returns>
const DescriptorSetLayout& getDescriptorSetLayout() const
{
return _descSetLayout;
}
/// <summary>Return the descriptor pool from which this descriptor set was allocated</summary>
/// <returns>The descriptor pool</returns>
const DescriptorPool& getDescriptorPool() const
{
return _descPool;
}
/// <summary>Return the descriptor pool from which this descriptor set was allocated</summary>
/// <returns>The descriptor pool</returns>
DescriptorPool& getDescriptorPool()
{
return _descPool;
}
};
} // namespace impl
// For smart pointer reference counting we need to keep alive the descriptor set binding entries to do this we place them in an array kept alive by the DescriptorSet itself
// This means that the caller application can let resources go out scope and the Descriptor set "keepAlive" array will keep them alive as long as needed
inline void WriteDescriptorSet::updateKeepAliveIntoDestinationDescriptorSet() const
{
// Get the keep alive entry for the current binding
auto& keepAlive = getDescriptorSet()->_keepAlive[this->_dstBinding];
// Handle BufferInfo entries
if (_infoType == InfoType::BufferInfo)
{
for (uint32_t i = 0; i < _infos.size(); ++i)
{
// Ensure the into entry is valid
if (_infos[i].isValid())
{
keepAlive[i] = _infos[i].bufferInfo.buffer;
}
}
}
// Handle ImageInfo entries
else if (_infoType == InfoType::ImageInfo)
{
for (uint32_t i = 0; i < _infos.size(); ++i)
{
// Ensure the into entry is valid
if (_infos[i].isValid())
{
auto newpair = std::make_shared<std::pair<Sampler, ImageView> /**/>();
newpair->first = _infos[i].imageInfo.sampler;
newpair->second = _infos[i].imageInfo.imageView;
keepAlive[i] = newpair;
}
}
}
// Handle TexelBufferView entries
else if (_infoType == InfoType::TexelBufferView)
{
for (uint32_t i = 0; i < _infos.size(); ++i)
{
// Ensure the into entry is valid
if (_infos[i].isValid())
{
keepAlive[i] = _infos[i].texelBuffer;
}
}
}
}
} // namespace pvrvk
| [
"omarzohdi@gmail.com"
] | omarzohdi@gmail.com |
6164000f26b0bcaba499a8779c89bb85e38e832b | f340a30b0da81576f0ce6ae1c1148c10b51a3c73 | /NetworkData.cpp | cb649d7f537a3b5989c5bb73067d6616983f48ad | [] | no_license | koboldul/Football | 95e3a2c91c2c19038c842927e2d4d613c432b04b | f52d2d24969a1d3681dc6bd2188baac9ccd5534e | refs/heads/master | 2021-01-19T11:37:17.534076 | 2016-01-27T01:40:05 | 2016-01-27T01:40:05 | 9,425,160 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 156 | cpp | #include "NetworkData.h"
NetworkData::NetworkData()
{
_data = new std::map<int, float>();
}
NetworkData::~NetworkData()
{
_data = NULL;
delete _data;
} | [
"koboldul@gmail.com"
] | koboldul@gmail.com |
b24ab267518c7bd0e5d54225eaf9f0e46d40e5de | e763b855be527d69fb2e824dfb693d09e59cdacb | /aws-cpp-sdk-support/source/model/DescribeTrustedAdvisorCheckSummariesResult.cpp | 2de7bd97a9625cd76d80729024047012e7166e7a | [
"MIT",
"Apache-2.0",
"JSON"
] | permissive | 34234344543255455465/aws-sdk-cpp | 47de2d7bde504273a43c99188b544e497f743850 | 1d04ff6389a0ca24361523c58671ad0b2cde56f5 | refs/heads/master | 2023-06-10T16:15:54.618966 | 2018-05-07T23:32:08 | 2018-05-07T23:32:08 | 132,632,360 | 1 | 0 | Apache-2.0 | 2023-06-01T23:20:47 | 2018-05-08T15:56:35 | C++ | UTF-8 | C++ | false | false | 1,770 | cpp | /*
* 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.
*/
#include <aws/support/model/DescribeTrustedAdvisorCheckSummariesResult.h>
#include <aws/core/utils/json/JsonSerializer.h>
#include <aws/core/AmazonWebServiceResult.h>
#include <aws/core/utils/StringUtils.h>
#include <aws/core/utils/UnreferencedParam.h>
#include <utility>
using namespace Aws::Support::Model;
using namespace Aws::Utils::Json;
using namespace Aws::Utils;
using namespace Aws;
DescribeTrustedAdvisorCheckSummariesResult::DescribeTrustedAdvisorCheckSummariesResult()
{
}
DescribeTrustedAdvisorCheckSummariesResult::DescribeTrustedAdvisorCheckSummariesResult(const Aws::AmazonWebServiceResult<JsonValue>& result)
{
*this = result;
}
DescribeTrustedAdvisorCheckSummariesResult& DescribeTrustedAdvisorCheckSummariesResult::operator =(const Aws::AmazonWebServiceResult<JsonValue>& result)
{
const JsonValue& jsonValue = result.GetPayload();
if(jsonValue.ValueExists("summaries"))
{
Array<JsonValue> summariesJsonList = jsonValue.GetArray("summaries");
for(unsigned summariesIndex = 0; summariesIndex < summariesJsonList.GetLength(); ++summariesIndex)
{
m_summaries.push_back(summariesJsonList[summariesIndex].AsObject());
}
}
return *this;
}
| [
"henso@amazon.com"
] | henso@amazon.com |
6a13307b09decbfb2d7a32718369eee2f68ea52a | e785aa73bb8581f3f76a68e00b4ef7d8f4768ce8 | /Input Data.cpp | 4575f374e337c5ea515988ecf7bc8e5ded27b9e1 | [] | no_license | Jodisaputro/Bahasa-Pemrogaman | 2a94dcf513104dfae8009fbd06c640fb3783b2c0 | 493a448e40d2cd890fe9a409b7b3f5045d928b7e | refs/heads/master | 2020-03-22T20:57:19.246305 | 2018-07-12T01:57:06 | 2018-07-12T01:57:06 | 140,645,336 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 648 | cpp | #include<iostream>
#include<conio.h>
int main(){
using namespace std;
char nama[32];
char nim[12];
char jeniskelamin[15];
char angkatan[12];
char alamat[50];
char prodi [25];
char fakultas [40];
cout<<"Input Data Mahasiswa \n\n";
cout<<"Nama\t\t: ";
cin.getline(nama,32);
cout<<"NIM\t\t: ";
cin.getline(nim,12);
cout<<"Jenis Kelamin\t:";
cin.getline(jeniskelamin,15);
cout<<"Angkatan\t: ";
cin.getline(angkatan,12);
cout<<"Alamat\t\t: ";
cin.getline(alamat,50);
cout<<"Prodi\t\t: ";
cin.getline(prodi,25);
cout<<"Fakultas\t:";
cin.getline(fakultas,40);
cout<<"\n\nTerimakasih telah mengisi Input Data Mahasiswa";
getch();
}
| [
"jodisaputro53@gmail.com"
] | jodisaputro53@gmail.com |
08baba89120931e908278df58203e258eb569c91 | ba35d3ee22cdcdf64d70e339506e710a141be69f | /SolarSystem/Engine/ImageLoader.h | 7a2c1e9f14320f48b018a63b82ed110385103cc4 | [] | no_license | sebradle/SolarSystem | e51ede456a99b532e2244e8ddfe4f288c65a86d8 | 8772bde067adc3d65374b8237f77ae23f8676d64 | refs/heads/master | 2021-01-12T02:22:27.953604 | 2017-01-03T21:57:08 | 2017-01-03T21:57:08 | 77,956,349 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 158 | h | #pragma once
#include "Texture.h"
#include <string>
namespace Engine {
class ImageLoader
{
public:
static GLTexture loadPNG(std::string filePath);
};
} | [
"sebra@DESKTOP-6GF7MQR"
] | sebra@DESKTOP-6GF7MQR |
944abe455383582359989061adc87c1186025383 | c6a877fb5eb035f0821abd559db1d7a1ba71b63d | /Library/Source/Blocks/SIBlock.h | 3f08b4ff77ad1e90b35a1d76e49420171fd383af | [
"Zlib",
"MIT",
"ISC",
"BSL-1.0",
"BSD-2-Clause"
] | permissive | AutomotiveDevOps/mdf4-converters | 8f4e11ee5703db5196c30c5b70be7a3986b1937e | 5c6624ca0a56317ce296233cb3fc80362b07a175 | refs/heads/master | 2022-12-03T20:34:43.940888 | 2020-08-14T22:31:39 | 2020-08-14T22:31:39 | 287,635,711 | 0 | 0 | MIT | 2020-08-14T22:30:37 | 2020-08-14T22:30:36 | null | UTF-8 | C++ | false | false | 727 | h | #ifndef MDFSIMPLECONVERTERS_SIBLOCK_H
#define MDFSIMPLECONVERTERS_SIBLOCK_H
#include "MdfBlock.h"
#include "MDBlock.h"
namespace mdf {
enum struct SIBlockBusType : uint8_t {
CAN = 0x02u,
LIN = 0x03u
};
SIBlockBusType operator&(SIBlockBusType const& lhs, SIBlockBusType const& rhs);
struct SIBlock : MdfBlock {
[[nodiscard]] SIBlockBusType getBusType() const;
[[nodiscard]] std::shared_ptr<MDBlock> getComment() const;
protected:
bool load(uint8_t const* dataPtr) override;
bool saveBlockData(uint8_t * dataPtr) override;
private:
uint8_t busType;
uint8_t flags;
uint8_t type;
};
}
#endif //MDFSIMPLECONVERTERS_SIBLOCK_H
| [
"mf@csselectronics.com"
] | mf@csselectronics.com |
874d642b51e23efeb4182bb5ae1f8c0ac0a95f40 | 25eef06802ef20cbd02327d5fc5a0012a5d6e1ec | /src/test/test.h | 1ffa1e70652ce5903d7a8b1fbf1f6a1de4ea7d66 | [
"BSD-3-Clause",
"MIT",
"BSL-1.0",
"Apache-2.0",
"LicenseRef-scancode-public-domain",
"BSD-2-Clause"
] | permissive | fotono/core-master | dab4420528ff55c429516f8d18c9e7bde2580e59 | 22b8130367a53aa1442f1cbff012cacf6a38b8d6 | refs/heads/master | 2020-04-04T22:50:12.085586 | 2018-11-06T06:38:16 | 2018-11-06T06:38:16 | 156,337,660 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,509 | h | #pragma once
// Copyright 2014 fotono Development Foundation and contributors. Licensed
// under the Apache License, Version 2.0. See the COPYING file at the root
// of this distribution or at http://www.apache.org/licenses/LICENSE-2.0
#include "main/Config.h"
#include "test/TestPrinter.h"
#include "util/Logging.h"
namespace fotono
{
class Application;
class Config;
Config const& getTestConfig(int instanceNumber = 0,
Config::TestDbMode mode = Config::TESTDB_DEFAULT);
int test(int argc, char* const* argv, el::Level logLevel,
std::vector<std::string> const& metrics);
extern bool force_sqlite;
void for_versions_to(uint32 to, Application& app,
std::function<void(void)> const& f);
void for_versions_from(uint32 from, Application& app,
std::function<void(void)> const& f);
void for_versions_from(std::vector<uint32> const& versions, Application& app,
std::function<void(void)> const& f);
void for_all_versions(Application& app, std::function<void(void)> const& f);
void for_versions(uint32 from, uint32 to, Application& app,
std::function<void(void)> const& f);
void for_versions(std::vector<uint32> const& versions, Application& app,
std::function<void(void)> const& f);
void for_all_versions_except(std::vector<uint32> const& versions,
Application& app,
std::function<void(void)> const& f);
}
| [
"41225745+link-money-dev@users.noreply.github.com"
] | 41225745+link-money-dev@users.noreply.github.com |
243dcb75a55b475c4c6b8015959e3cb355deec09 | 8b20c6ef83d66c241b5c2ba28a62146531c78a0e | /ch09/ex9_50.cpp | d31b7b41ad48dd425c29cf7a9b29db599ca60747 | [] | no_license | Ilikecoding/cpp_primer | ab849d02fa1e55faff74d1d79c370c01e0e70e5c | 51493c95a6c3c1563501dc179d39d160eb39afc3 | refs/heads/master | 2016-09-05T12:21:27.853909 | 2015-01-08T15:45:57 | 2015-01-08T15:45:57 | 27,260,335 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 938 | cpp | /*---------------------------------------------------------------
ex9_50:
Write a program to process a vector<string>s whose elements
represent integral values. Produce the sum of all the elements
in that vector. Change the program so that it sums of strings
that represent floating-point values.
---------------------------------------------------------------*/
#include <iostream>
#include <vector>
#include <string>
using namespace std;
int sum_of_int(vector<string> &svec);
float sum_of_float(vector<string> &svec);
int main(int argc, char const *argv[])
{
vector<string> svec = {"11", "12", "13.5"};
cout << sum_of_int(svec) << endl;
cout << sum_of_float(svec) << endl;
return 0;
}
int sum_of_int(vector<string> &svec)
{
int sum = 0;
for(auto i : svec)
{
sum += stoi(i);
}
return sum;
}
float sum_of_float(vector<string> &svec)
{
float sum = 0.0;
for(auto i : svec)
{
sum += stof(i);
}
return sum;
} | [
"2426984972@qq.com"
] | 2426984972@qq.com |
bb6db04d06b048679ece1745958c7dc7b2b9df07 | fa5ed7b1b68130cf84051026c549bd5fb83d1c1c | /print_server.cpp | 01969de01200c32899665c094163315d7866f3ab | [] | no_license | fenghuicheng/epollserver | d5ce3b63974d96fd579755d23fe2d0b5f1577501 | 3e5ad5a2a914824786c71cd5c1fbe40c9225a798 | refs/heads/master | 2021-01-02T09:07:59.228321 | 2013-10-20T11:12:53 | 2013-10-20T11:12:53 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,237 | cpp | #include "include.h"
/*header for `epoll_create()`, etc */
#include <sys/epoll.h>
int listenfd = 0;
int epollfd = 0;
/*socket, bind and listen*/
void socket_setup()
{
typedef struct sockaddr SA;
int value = 0;
socklen_t length = 0;
listenfd = socket(AF_INET, SOCK_STREAM, 0);
QUIT_IF_FAIL(listenfd);
struct sockaddr_in homeaddr;
bzero((void*)&homeaddr, sizeof(homeaddr));
homeaddr.sin_family = AF_INET;
homeaddr.sin_port = htons(2000);
inet_pton(AF_INET, "127.0.0.1", &homeaddr.sin_addr);
value = 1;
length = sizeof(value);
value = setsockopt(listenfd, SOL_SOCKET, SO_REUSEADDR, (void*)&value, length);
QUIT_IF_FAIL(listenfd);
value = bind(listenfd, (SA*)&homeaddr, sizeof(homeaddr));
QUIT_IF_FAIL(value);
value = listen(listenfd, SOMAXCONN);
QUIT_IF_FAIL(value);
}
/*wait for working process's termination.*/
void sig_chld(int signo)
{
pid_t pid = 0;
int stat = 0;
while((pid = waitpid(-1, &stat, WNOHANG)) > 0)
printf("child procss %d exit\n", pid);
return;
}
/*serve the client connected by socket `conn_fd`*/
void work(int conn_fd)
{
if (conn_fd == 0)
return;
printf("conn_fd = %d\n", conn_fd);
char buffer[BUFFSIZE] = {0};
int count = 0;
again:
while((count = read(conn_fd, &buffer, sizeof(buffer))) > 0)
{
printf("packsize = %d;\n", count);
buffer[count] = '\0';
printf("%s\n", buffer);
write(conn_fd, &buffer, count);
}
if (count < 0 && errno == SIGINT)
goto again;
int value = epoll_ctl(epollfd, EPOLL_CTL_DEL, conn_fd, NULL);
QUIT_IF_FAIL(value);
close(conn_fd);
}
/*initialize the epoll family.*/
void init()
{
epollfd = epoll_create(1);
QUIT_IF_FAIL(epollfd);
struct epoll_event event;
bzero(&event, sizeof(event));
event.events = EPOLLIN;
event.data.fd = listenfd;
int value = epoll_ctl(epollfd, EPOLL_CTL_ADD, listenfd, &event);
QUIT_IF_FAIL(value);
/* process the SIGCHLD signal for `fork` model. */
/*
struct sigaction act, oldact;
sigemptyset(&act.sa_mask);
act.sa_flags = 0;
act.sa_handler = &sig_chld;
sigaction(SIGCHLD, &act, &oldact);
*/
}
/*close employed file descriptors.*/
void clean()
{
if (0 != listenfd)
close(listenfd);
listenfd = 0;
if (0 != epollfd)
close(epollfd);
epollfd = 0;
}
int main()
{
pid_t pid = 0;
socket_setup();
init();
struct epoll_event event[MAXEPOLLFD];
while(1)
{
struct sockaddr_in clientsock;
socklen_t clientlen = 0;
int value = epoll_wait(epollfd, (epoll_event*)&event, ARRAYCOUNT(event), -1);
#ifndef SA_RESTART
if (value < 0 && errno == EINTR)
continue;
else if(value < 0)
#endif
QUIT_IF_FAIL(value);
for (int i = 0; i < value; i++)
{
if (event[i].data.fd == listenfd)
{
int connectfd = accept(listenfd, NULL, NULL);
if (connectfd < 0)
{
#ifndef SA_RESTART
if (errno != EINTR)
#endif
close(connectfd);
perror("print_server connect");
continue;
}
printf("connet with %d\n", connectfd);
struct epoll_event newevent;
bzero(&newevent, sizeof(newevent));
newevent.events = EPOLLIN;
newevent.data.fd = connectfd;
value = epoll_ctl(epollfd, EPOLL_CTL_ADD, connectfd, &newevent);
QUIT_IF_FAIL(value);
}
else
{
work(event[i].data.fd);
}
}
}
clean();
return 0;
}
| [
"fenghuicheng.coder@gmail.com"
] | fenghuicheng.coder@gmail.com |
d7d8375d9c235e28c10ded908a03869618507c42 | ac5a54246dbe963a8406ac9f58db539c814fc1d0 | /QuickStartDU/QuickStartDU.ino | 0ad68e6511841f785c525e582a8667c8fbdd2870 | [] | no_license | kadu/robofiles | 042c0eb74cf19cd639fddd96d3a1a68b9ebeba8a | 2f3dce9c2874a2a80f6abb41b390378b84337b54 | refs/heads/master | 2021-01-01T17:52:31.395346 | 2012-07-30T02:24:52 | 2012-07-30T02:24:52 | 1,515,597 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,863 | ino | // Quick hardware test
#include <SdFat.h>
// Test with reduced SPI speed for breadboards.
// Change spiSpeed to SPI_FULL_SPEED for better performance
// Use SPI_QUARTER_SPEED for even slower SPI bus speed
const uint8_t spiSpeed = SPI_HALF_SPEED;
//------------------------------------------------------------------------------
// Normally SdFat is used in applications in place
// of Sd2Card, SdVolume, and SdFile for root.
Sd2Card card;
SdVolume volume;
SdFile root;
// Serial streams
ArduinoOutStream cout(Serial);
// input buffer for line
char cinBuf[40];
ArduinoInStream cin(Serial, cinBuf, sizeof(cinBuf));
// Change the value of chipSelect if your hardware does
// not use the default value, SS_PIN. Common values are:
// Arduino Ethernet shield: pin 4
// Sparkfun SD shield: pin 8
// Adafruit SD shields and modules: pin 10
//int chipSelect = SS_PIN;
int chipSelect = 8;
void cardOrSpeed() {
cout << pstr(
"Try another SD card or reduce the SPI bus speed.\n"
"The current SPI speed is: ");
uint8_t divisor = 1;
for (uint8_t i = 0; i < spiSpeed; i++) divisor *= 2;
cout << F_CPU * 0.5e-6 / divisor << pstr(" MHz\n");
cout << pstr("Edit spiSpeed in this sketch to change it.\n");
}
void reformatMsg() {
cout << pstr("Try reformatting the card. For best results use\n");
cout << pstr("the SdFormatter sketch in SdFat/examples or download\n");
cout << pstr("and use SDFormatter from www.sdcard.org/consumer.\n");
}
void setup() {
Serial.begin(9600);
cout << pstr(
"SD chip select is the key hardware option.\n"
"Common values are:\n"
"Arduino Ethernet shield, pin 4\n"
"Sparkfun SD shield, pin 8\n"
"Adafruit SD shields and modules, pin 10\n"
"The default chip select pin number is pin ");
cout << int(SS_PIN) << endl;
}
bool firstTry = true;
void loop() {
if (!firstTry) cout << pstr("\nRestarting\n");
firstTry = false;
cout << pstr("\nEnter the chip select pin number: ");
cin.readline();
if (cin >> chipSelect) {
cout << chipSelect << endl;
} else {
cout << pstr("\nInvalid pin number\n");
return;
}
if (!card.init(spiSpeed, chipSelect)) {
cout << pstr(
"\nSD initialization failed.\n"
"Is the card correctly inserted?\n"
"Is chipSelect set to the correct value?\n"
"Is there a wiring/soldering problem?\n");
return;
}
cout << pstr("\nCard successfully initialized.\n");
cout << endl;
uint32_t size = card.cardSize();
if (size == 0) {
cout << pstr("Can't determine the card size.\n");
cardOrSpeed();
return;
}
uint32_t sizeMB = 0.000512 * size + 0.5;
cout << pstr("Card size: ") << sizeMB;
cout << pstr(" MB (MB = 1000000 bytes)\n");
cout << endl;
if (!volume.init(&card)) {
if (card.errorCode()) {
cout << pstr("Can't read the card.\n");
cardOrSpeed();
} else {
cout << pstr("Can't find a valid FAT16/FAT32 partition.\n");
reformatMsg();
}
return;
}
cout << pstr("Volume is FAT") << int(volume.fatType());
cout << pstr(", Cluster size (bytes): ") << 512L * volume.blocksPerCluster();
cout << endl << endl;
root.close();
if (!root.openRoot(&volume)) {
cout << pstr("Can't open root directory.\n");
reformatMsg();
return;
}
cout << pstr("Files found (name date time size):\n");
root.ls(LS_R | LS_DATE | LS_SIZE);
if ((sizeMB > 1100 && volume.blocksPerCluster() < 64)
|| (sizeMB < 2200 && volume.fatType() == 32)) {
cout << pstr("\nThis card should be reformatted for best performance.\n");
cout << pstr("Use a cluster size of 32 KB for cards larger than 1 GB.\n");
cout << pstr("Only cards larger than 2 GB should be formatted FAT32.\n");
reformatMsg();
return;
}
Serial.flush();
cout << pstr("\nSuccess! Type any character to restart.\n");
while (!Serial.available());
Serial.flush();
}
| [
"kadu@kadu.com.br"
] | kadu@kadu.com.br |
6d319a574329f11787ad65a9bc29cf936da43ccb | 1c9d3f941f3b2d2a43395765c463cea469137517 | /DataStructure/sortablesegtree.hpp | f2f09e307f6a7a045110fee6923fad0ed054ac95 | [] | no_license | tko919/library | ab97cb246d3c65ed441097a1691fd39e9ca2afa1 | fd31658c12fd547301992a1bbdacc6818dc8d45f | refs/heads/main | 2023-06-21T22:24:50.462875 | 2023-06-14T06:19:08 | 2023-06-14T06:19:08 | 442,397,837 | 4 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 4,208 | hpp | #pragma once
#include "DataStructure/segtree.hpp"
template<typename M,typename N,M (*f)(M,M),M (*g)(M,N),M (*m1)(),int LG=30>struct SortableSegmentTree{
SortableSegmentTree(){}
SortableSegmentTree(vector<int>& ks,vector<M>& vs):n(ks.size()),seg(n),Es(n){
rep(i,0,n){
Ls.insert(i);
Es[i]=new Elem(ks[i],vs[i]);
seg.set(i,vs[i]);
}
Ls.insert(n);
}
void update(int i,int key,M val){
split(i);
split(i+1);
Es[i]=new Elem(key,val);
seg.set(i,val);
}
M query(int L,int R){
split(L);
split(R);
return seg.query(L,R);
}
void sort(int L,int R,bool rev=false){
split(L);
split(R);
int pos=L;
for(;;){
pos=*(Ls.upper_bound(pos));
if(pos>=R)break;
Es[L]=meld(Es[L],Es[pos]);
Es[pos]=new Elem();
seg.set(pos,m1());
Ls.erase(pos);
}
Es[L]->set(rev);
seg.set(L,Es[L]->value());
}
private:
struct Trie{
Trie *cp[2];
int sz;
M val,lav;
Trie(){cp[0]=cp[1]=nullptr;}
Trie(int key,M v){cp[0]=cp[1]=nullptr,init(key,v);}
void init(int key,M v,int lg=LG){
sz=1;
val=lav=v;
if(lg==-1)return;
if(!cp[key>>lg&1])cp[key>>lg&1]=new Trie();
cp[key>>lg&1]->init(key,v,lg-1);
}
void update(){
if(!cp[0] and !cp[1])return;
sz=0;
val=lav=m1();
if(cp[0]){
sz+=cp[0]->sz;
val=f(val,cp[0]->val);
lav=f(cp[0]->lav,lav);
}
if(cp[1]){
sz+=cp[1]->sz;
val=f(val,cp[1]->val);
lav=f(cp[1]->lav,lav);
}
}
void apply(N x){
assert(sz==1);
val=lav=g(val,x);
if(cp[0])cp[0]->apply(x);
if(cp[1])cp[1]->apply(x);
}
};
using Tp=Trie*;
int sz(Tp t){return t?t->sz:0;}
Tp meld(Tp a,Tp b){
if(!a)return b;
if(!b)return a;
a->cp[0]=meld(a->cp[0],b->cp[0]);
a->cp[1]=meld(a->cp[1],b->cp[1]);
a->update();
return a;
}
pair<Tp,Tp> split(Tp t,int k){
if(k==0)return {nullptr,t};
if(k==sz(t))return {t,nullptr};
if(k<sz(t->cp[0])){
auto [l,tmp]=split(t->cp[0],k);
auto L=new Trie();
L->cp[0]=l;
L->update();
auto R=new Trie();
R->cp[0]=tmp,R->cp[1]=t->cp[1];
R->update();
return {L,R};
}
else{
auto [tmp,r]=split(t->cp[1],k-sz(t->cp[0]));
auto L=new Trie();
auto R=new Trie();
L->cp[0]=t->cp[0],L->cp[1]=tmp;
L->update();
R->cp[1]=r;
R->update();
return {L,R};
}
}
struct Elem{
Tp node;
bool rev;
Elem():node(nullptr),rev(0){}
Elem(int key,M x):node(new Trie(key,x)),rev(0){}
Elem(Tp t,bool r):node(t),rev(r){}
void set(bool r){rev=r;}
void apply(N x){node->apply(x);}
M value(){return rev?node->lav:node->val;}
};
using Ep=Elem*;
Ep meld(Ep s,Ep t){
return new Elem(meld(s->node,t->node),0);
}
pair<Ep,Ep> split(Ep t,int k){
if(t->rev)k=sz(t->node)-k;
auto [L,R]=split(t->node,k);
if(t->rev)swap(L,R);
auto LE=new Elem(L,t->rev);
auto RE=new Elem(R,t->rev);
return {LE,RE};
}
const int n;
SegmentTree<M,N,f,g,m1> seg;
set<int> Ls;
vector<Ep> Es;
void split(int k){
if(k>=n)return;
int pos=*(--Ls.upper_bound(k));
if(pos==k)return;
auto [L,R]=split(Es[pos],k-pos);
Es[pos]=L,Es[k]=R;
seg.set(pos,Es[pos]->value());
seg.set(k,Es[k]->value());
Ls.insert(k);
}
};
/**
* @brief Sortable Segment Tree
*/ | [
"laplace2758@gmail.com"
] | laplace2758@gmail.com |
f0c40433c28c6a73a54b38842eeb505406f3e7b4 | a618b024adf4b005f8dfcabf9c2b8cbf49eea61a | /SparseTable.cpp | 9caf5342971ce2ffe77f3bbd625cb4b0974666f2 | [] | no_license | rvrston/lib | a847243f6ec3ad5f2dec9635ae75f7ebaa312ed4 | 012709a0dd5e9323f1bd213f8c2a49d2b10ba35c | refs/heads/master | 2021-07-21T05:17:08.080356 | 2021-07-14T14:24:12 | 2021-07-14T14:24:12 | 252,157,977 | 0 | 0 | null | 2021-07-14T14:24:13 | 2020-04-01T11:40:21 | C++ | UTF-8 | C++ | false | false | 1,997 | cpp | #include <bits/stdc++.h>
using namespace std;
template <typename T>
struct SparseTable{
// 冪等で結合的な演算(非可換でもOK) (ex: min, max, lcm, gcd, and, or)
// 前処理:O(NlogN), 区間クエリ:O(1), 要素の更新はNG
vector<vector<T>> m_ST;
T idempotent_op(const T &a, const T &b) const{ // 冪等で結合的な演算(非可換でもOK) (ex: min, max, lcm, gcd, and, or)
return min(a, b);
}
SparseTable(const vector<T> &data): m_ST(1, data){
int N= data.size();
for(int d=1; (1<<d) <= N; d++){
m_ST.emplace_back(vector<T>(N-(1<<d)+1));
for(size_t i=0; i<m_ST.back().size(); i++){
m_ST.back().at(i)= idempotent_op(m_ST.at(d-1).at(i), m_ST.at(d-1).at(i+(1<<(d-1))));
}
}
}
T range(int left, int right) const{ // 半開区間[l, r)に対するクエリ
#ifdef __GNUC__
int logLen= 31- __builtin_clz(right- left);
#else
int len= right- left;
assert(len > 0);
int logLen= 0;
if(len >= (1<<16)){ logLen+= 16; len >>= 16; }
if(len >= (1<< 8)){ logLen+= 8; len >>= 8; }
if(len >= (1<< 4)){ logLen+= 4; len >>= 4; }
if(len >= (1<< 2)){ logLen+= 2; len >>= 2; }
if(len >= (1<< 1)){ logLen+= 1; len >>= 1; }
#endif
// 計算のアイディア: [l,r)= [l,l+k)∪[r-k,r) なるkを一つ取ると、
// ∧[l,r)= ∧[l,r-k) ∧ ∧[r-k,l+k) ∧ ∧[l+k,r) (∵結合律)
// = ∧[l,r-k) ∧ ∧[r-k,l+k) ∧ ∧[r-k,l+k) ∧ ∧[l+k,r) (∵冪等性)
// = ∧[l,l+k) ∧ ∧[r-k,r) (∵結合律)
return idempotent_op(m_ST.at(logLen).at(left), m_ST.at(logLen).at(right-(1<<logLen)));
}
};
int main() {
int N,Q;
cin >> N >> Q;
vector<int> data(N);
for(int i=0; i<N; i++){
cin >> data.at(i);
}
SparseTable<int> st(data);
int left,right;
for(int i=0; i<Q; i++){
cin >> left >> right;
cout << st.range(left, right) << endl;
}
}
| [
"noreply@github.com"
] | noreply@github.com |
9db49986d4005985c5fe490288935dfe19d7ee3f | f0bd42c8ae869dee511f6d41b1bc255cb32887d5 | /Codeforces/441A - Valera and Antique Items.cpp | ef69c51720555d81bcbb04d40686d1e7a456138f | [] | no_license | osamahatem/CompetitiveProgramming | 3c68218a181d4637c09f31a7097c62f20977ffcd | a5b54ae8cab47b2720a64c68832a9c07668c5ffb | refs/heads/master | 2021-06-10T10:21:13.879053 | 2020-07-07T14:59:44 | 2020-07-07T14:59:44 | 113,673,720 | 3 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 534 | cpp | #include<bits/stdc++.h>
using namespace std;
int main(){
int n,v,k,x;
vector<int> ans;
scanf("%d%d",&n,&v);
for(int i=0;i<n;i++){
bool flag=0;
scanf("%d",&k);
for(int j=0;j<k;j++){
scanf("%d",&x);
if(x<v)
flag=1;
}
if(flag)
ans.push_back(i+1);
}
printf("%d\n",ans.size());
for(int i=0;i<ans.size();i++){
if(i)
printf(" ");
printf("%d",ans[i]);
}
printf("\n");
return 0;
}
| [
"osama@elysian.team"
] | osama@elysian.team |
5b809780008b992b8f9bd91f90999dc04af30953 | 8442f074cfeecb4ca552ff0d6e752f939d6326f0 | /1417A.cpp | 652002ca77aa68dae2cd2bd5b45ad767c2fc9bcd | [] | no_license | abufarhad/Codeforces-Problems-Solution | 197d3f351fc01231bfefd1c4057be80643472502 | b980371e887f62040bee340a8cf4af61a29eac26 | refs/heads/master | 2021-06-15T16:35:07.327687 | 2021-03-23T17:29:49 | 2021-03-23T17:29:49 | 170,741,904 | 43 | 32 | null | null | null | null | UTF-8 | C++ | false | false | 4,579 | cpp | //! Bismillahi-Rahamanirahim.
/** ========================================**
** @Author: Md. Abu Farhad ( RUET, CSE'15)
** @Category:
/** ========================================**/
#include<bits/stdc++.h>
#include<stdio.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
using namespace std;
#define ll long long
#define scl(n) scanf("%lld",&n)
#define scll(n, m) scanf("%lld%lld",&n, &m)
#define scc(c) scanf("%c",&c)
#define fr(i,n) for (ll i=0;i<n;i++)
#define fr1(i,n) for(ll i=1;i<=n;i++)
#define pfl(x) printf("%lld\n",x)
#define pb push_back
#define debug cout<<"I am here"<<endl;
#define pno cout<<"NO"<<endl
#define pys cout<<"YES"<<endl
#define tcas(i,t) for(ll i=1;i<=t;i++)
#define all(x) (x).begin(), (x).end()
#define allrev(x) (x).rbegin(),(x).rend()
#define pr pair<ll, ll>
#define ff first
#define ss second
#define pn printf("\n")
#define l(s) s.size()
#define asort(a) sort(a,a+n)
#define dsort(a) sort(a,a+n,greater<int>())
#define uniquee(x) x.erase(unique(x.begin(), x.end()),x.end())
#define el cout<<endl
#define md 1000000007
#define inf 1e18
#define ps cout<<" ";
#define Pai acos(-1.0)
#define mem(a,i) memset(a, i, sizeof(a))
#define pcas(i) cout<<"Case "<<i<<": "<<endl;
#define seg_tree(n) ll left=n*2,right=l+1,mid=(l+r)/2
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define conv_string(n) to_string(n)
//ll x[10]= {0,-1,-1,1,1,-2,-2,2,2};
//ll y[10]= {0,-2,2,-2,2,-1,1,-1,1};
/*.....Kings path....*/
//ll dx[]={-1,-1,-1,0,1,1,1,0};
//ll dy[]={-1,0,1,1,1,0,-1,-1};
// sscanf(c, "%s %s", s,s1); // take string buffer and then distribute all value , here take 2 value and distribute
///cin.ignore(); // Need when we take input as a string line before getline(cin,s)
//ll bigmd(ll b, ll p){ ll res=1, rem=b; while(p) { if(p%2==1 ) {res=res*rem%md ; p--;} rem=rem*rem%md; p>>=1; } return res;}
//ll find_all_divisor(ll n){ fr1(i,sqrt(n)){ ll x; if(n % i == 0) { x = n / i; v.pb(i); if(i != x) v.pb(x);}}}
///Every even integer greater than 2 can be represented as the sum of two primes numbers.
//count item in array : count(arr,arr+n,'I');
//bool cmp(ll i, ll j){ if( fac[i]==fac[j])return i>j; return fac[i]< fac[j]; }
/*-----------------------Bitmask------------------*/
//int Set(int N,int pos){return N=N | (1<<pos);}
//int reset(int N,int pos){return N= N & ~(1<<pos);}
//bool check(int N,int pos){return (bool)(N & (1<<pos));}
/*------------------------------------------------*/
//__builtin_popcount(n) ; return number of set bit // can check number is power of two because if power of two has only 1 set bit
// lower_bound = greater then or equal
// upper_bound = greater then
//lcm=max_element(dp+1, dp+m+1 )-dp; //return the index of max elements
// set_intersection(v.begin(), v.end(), v1.begin(), v1.end(), inserter(v2 ,v2.begin()));
//Check if number is power of 2 ---> ans = (n&(n-1) == 0).
//string_to_dec , hex , bin => stoll(dec_num, nullptr, 10)
//digits in a factorial => log( n! ) = log(1*2*3....... * n)
//SumOfDivisorFormula= SOD(p^a) = (p^(a+1) minus 1)/(p minus 1)
//bitset<12>(n).to_string(); //to binary
//bitset<8>(binary_string).to_ulong(); //to_decimal
//next_permutation(str.begin(), str.end()) , prev_permutation(str.begin(), str.end())
// long double 10 byte=80 bit - long long 8 byte
//string to int => std::istringstream(s) >> num
//right_most_1= ( i & -i );
//cei (n/a) == (n + a-1)/a
//sum of power of 2(2^0+2^1+....) = 2^(n+1) - 1
//Grace Hopper and Margaret Hamilton
#define N 200005
int main()
{
ll t;
cin>>t;
//t=1;
tcas(cs, t)
{
ll m,n,b,c,d,i,j,k,x,y,z,l,r, p, q;
string s,s1, s2, s3, s4;
ll cnt=0,cn=0,ans=0,sum=0 ;
cin>>n>>k;
ll a[n];
fr(i,n)cin>>a[i];
asort(a);
fr1(i , n-1)
{
if(k>a[i] ) ans+=( k-a[i] )/a[0];
}
cout<<ans;pn;
}
return 0;
}
/// **************************Before submit****************************
/// ****Please check all base case output and printing " YES or NO " ***
/// *check for integer overflow,array bounds
/// *check for n=1
| [
"abufarhad15@gmail.com"
] | abufarhad15@gmail.com |
541413e696e462ed396c5516bc24b85e86687430 | ff4ca2811be1119ac625a042c7472680080dd6c9 | /clang-4679922/include/llvm/IR/DebugInfoMetadata.h | 232a7d6abc43794e68834e6ce16a9b17a333a1a4 | [
"LicenseRef-scancode-generic-cla",
"MIT",
"NCSA",
"LicenseRef-scancode-arm-llvm-sga"
] | permissive | westcripp/clang-host-darwin-x86 | a5e281eba897d22c3d29205782724873959cde6b | d59e393e512795383ddb8bde49df55782cc22e0c | refs/heads/master | 2021-09-28T23:09:37.117257 | 2018-11-14T21:23:10 | 2018-11-14T21:23:10 | 158,430,890 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 115,828 | h | //===- llvm/IR/DebugInfoMetadata.h - Debug info metadata --------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// Declarations for metadata specific to debug info.
//
//===----------------------------------------------------------------------===//
#ifndef LLVM_IR_DEBUGINFOMETADATA_H
#define LLVM_IR_DEBUGINFOMETADATA_H
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/BitmaskEnum.h"
#include "llvm/ADT/None.h"
#include "llvm/ADT/Optional.h"
#include "llvm/ADT/PointerUnion.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/iterator_range.h"
#include "llvm/BinaryFormat/Dwarf.h"
#include "llvm/IR/Constants.h"
#include "llvm/IR/Metadata.h"
#include "llvm/Support/Casting.h"
#include <cassert>
#include <climits>
#include <cstddef>
#include <cstdint>
#include <iterator>
#include <type_traits>
#include <vector>
// Helper macros for defining get() overrides.
#define DEFINE_MDNODE_GET_UNPACK_IMPL(...) __VA_ARGS__
#define DEFINE_MDNODE_GET_UNPACK(ARGS) DEFINE_MDNODE_GET_UNPACK_IMPL ARGS
#define DEFINE_MDNODE_GET_DISTINCT_TEMPORARY(CLASS, FORMAL, ARGS) \
static CLASS *getDistinct(LLVMContext &Context, \
DEFINE_MDNODE_GET_UNPACK(FORMAL)) { \
return getImpl(Context, DEFINE_MDNODE_GET_UNPACK(ARGS), Distinct); \
} \
static Temp##CLASS getTemporary(LLVMContext &Context, \
DEFINE_MDNODE_GET_UNPACK(FORMAL)) { \
return Temp##CLASS( \
getImpl(Context, DEFINE_MDNODE_GET_UNPACK(ARGS), Temporary)); \
}
#define DEFINE_MDNODE_GET(CLASS, FORMAL, ARGS) \
static CLASS *get(LLVMContext &Context, DEFINE_MDNODE_GET_UNPACK(FORMAL)) { \
return getImpl(Context, DEFINE_MDNODE_GET_UNPACK(ARGS), Uniqued); \
} \
static CLASS *getIfExists(LLVMContext &Context, \
DEFINE_MDNODE_GET_UNPACK(FORMAL)) { \
return getImpl(Context, DEFINE_MDNODE_GET_UNPACK(ARGS), Uniqued, \
/* ShouldCreate */ false); \
} \
DEFINE_MDNODE_GET_DISTINCT_TEMPORARY(CLASS, FORMAL, ARGS)
namespace llvm {
/// Holds a subclass of DINode.
///
/// FIXME: This class doesn't currently make much sense. Previously it was a
/// union beteen MDString (for ODR-uniqued types) and things like DIType. To
/// support CodeView work, it wasn't deleted outright when MDString-based type
/// references were deleted; we'll soon need a similar concept for CodeView
/// DITypeIndex.
template <class T> class TypedDINodeRef {
const Metadata *MD = nullptr;
public:
TypedDINodeRef() = default;
TypedDINodeRef(std::nullptr_t) {}
TypedDINodeRef(const T *MD) : MD(MD) {}
explicit TypedDINodeRef(const Metadata *MD) : MD(MD) {
assert((!MD || isa<T>(MD)) && "Expected valid type ref");
}
template <class U>
TypedDINodeRef(
const TypedDINodeRef<U> &X,
typename std::enable_if<std::is_convertible<U *, T *>::value>::type * =
nullptr)
: MD(X) {}
operator Metadata *() const { return const_cast<Metadata *>(MD); }
T *resolve() const { return const_cast<T *>(cast_or_null<T>(MD)); }
bool operator==(const TypedDINodeRef<T> &X) const { return MD == X.MD; }
bool operator!=(const TypedDINodeRef<T> &X) const { return MD != X.MD; }
};
using DINodeRef = TypedDINodeRef<DINode>;
using DIScopeRef = TypedDINodeRef<DIScope>;
using DITypeRef = TypedDINodeRef<DIType>;
class DITypeRefArray {
const MDTuple *N = nullptr;
public:
DITypeRefArray() = default;
DITypeRefArray(const MDTuple *N) : N(N) {}
explicit operator bool() const { return get(); }
explicit operator MDTuple *() const { return get(); }
MDTuple *get() const { return const_cast<MDTuple *>(N); }
MDTuple *operator->() const { return get(); }
MDTuple &operator*() const { return *get(); }
// FIXME: Fix callers and remove condition on N.
unsigned size() const { return N ? N->getNumOperands() : 0u; }
DITypeRef operator[](unsigned I) const { return DITypeRef(N->getOperand(I)); }
class iterator : std::iterator<std::input_iterator_tag, DITypeRef,
std::ptrdiff_t, void, DITypeRef> {
MDNode::op_iterator I = nullptr;
public:
iterator() = default;
explicit iterator(MDNode::op_iterator I) : I(I) {}
DITypeRef operator*() const { return DITypeRef(*I); }
iterator &operator++() {
++I;
return *this;
}
iterator operator++(int) {
iterator Temp(*this);
++I;
return Temp;
}
bool operator==(const iterator &X) const { return I == X.I; }
bool operator!=(const iterator &X) const { return I != X.I; }
};
// FIXME: Fix callers and remove condition on N.
iterator begin() const { return N ? iterator(N->op_begin()) : iterator(); }
iterator end() const { return N ? iterator(N->op_end()) : iterator(); }
};
/// Tagged DWARF-like metadata node.
///
/// A metadata node with a DWARF tag (i.e., a constant named \c DW_TAG_*,
/// defined in llvm/BinaryFormat/Dwarf.h). Called \a DINode because it's
/// potentially used for non-DWARF output.
class DINode : public MDNode {
friend class LLVMContextImpl;
friend class MDNode;
protected:
DINode(LLVMContext &C, unsigned ID, StorageType Storage, unsigned Tag,
ArrayRef<Metadata *> Ops1, ArrayRef<Metadata *> Ops2 = None)
: MDNode(C, ID, Storage, Ops1, Ops2) {
assert(Tag < 1u << 16);
SubclassData16 = Tag;
}
~DINode() = default;
template <class Ty> Ty *getOperandAs(unsigned I) const {
return cast_or_null<Ty>(getOperand(I));
}
StringRef getStringOperand(unsigned I) const {
if (auto *S = getOperandAs<MDString>(I))
return S->getString();
return StringRef();
}
static MDString *getCanonicalMDString(LLVMContext &Context, StringRef S) {
if (S.empty())
return nullptr;
return MDString::get(Context, S);
}
/// Allow subclasses to mutate the tag.
void setTag(unsigned Tag) { SubclassData16 = Tag; }
public:
unsigned getTag() const { return SubclassData16; }
/// Debug info flags.
///
/// The three accessibility flags are mutually exclusive and rolled together
/// in the first two bits.
enum DIFlags : uint32_t {
#define HANDLE_DI_FLAG(ID, NAME) Flag##NAME = ID,
#define DI_FLAG_LARGEST_NEEDED
#include "llvm/IR/DebugInfoFlags.def"
FlagAccessibility = FlagPrivate | FlagProtected | FlagPublic,
FlagPtrToMemberRep = FlagSingleInheritance | FlagMultipleInheritance |
FlagVirtualInheritance,
LLVM_MARK_AS_BITMASK_ENUM(FlagLargest)
};
static DIFlags getFlag(StringRef Flag);
static StringRef getFlagString(DIFlags Flag);
/// Split up a flags bitfield.
///
/// Split \c Flags into \c SplitFlags, a vector of its components. Returns
/// any remaining (unrecognized) bits.
static DIFlags splitFlags(DIFlags Flags,
SmallVectorImpl<DIFlags> &SplitFlags);
static bool classof(const Metadata *MD) {
switch (MD->getMetadataID()) {
default:
return false;
case GenericDINodeKind:
case DISubrangeKind:
case DIEnumeratorKind:
case DIBasicTypeKind:
case DIDerivedTypeKind:
case DICompositeTypeKind:
case DISubroutineTypeKind:
case DIFileKind:
case DICompileUnitKind:
case DISubprogramKind:
case DILexicalBlockKind:
case DILexicalBlockFileKind:
case DINamespaceKind:
case DITemplateTypeParameterKind:
case DITemplateValueParameterKind:
case DIGlobalVariableKind:
case DILocalVariableKind:
case DIObjCPropertyKind:
case DIImportedEntityKind:
case DIModuleKind:
return true;
}
}
};
template <class T> struct simplify_type<const TypedDINodeRef<T>> {
using SimpleType = Metadata *;
static SimpleType getSimplifiedValue(const TypedDINodeRef<T> &MD) {
return MD;
}
};
template <class T>
struct simplify_type<TypedDINodeRef<T>>
: simplify_type<const TypedDINodeRef<T>> {};
/// Generic tagged DWARF-like metadata node.
///
/// An un-specialized DWARF-like metadata node. The first operand is a
/// (possibly empty) null-separated \a MDString header that contains arbitrary
/// fields. The remaining operands are \a dwarf_operands(), and are pointers
/// to other metadata.
class GenericDINode : public DINode {
friend class LLVMContextImpl;
friend class MDNode;
GenericDINode(LLVMContext &C, StorageType Storage, unsigned Hash,
unsigned Tag, ArrayRef<Metadata *> Ops1,
ArrayRef<Metadata *> Ops2)
: DINode(C, GenericDINodeKind, Storage, Tag, Ops1, Ops2) {
setHash(Hash);
}
~GenericDINode() { dropAllReferences(); }
void setHash(unsigned Hash) { SubclassData32 = Hash; }
void recalculateHash();
static GenericDINode *getImpl(LLVMContext &Context, unsigned Tag,
StringRef Header, ArrayRef<Metadata *> DwarfOps,
StorageType Storage, bool ShouldCreate = true) {
return getImpl(Context, Tag, getCanonicalMDString(Context, Header),
DwarfOps, Storage, ShouldCreate);
}
static GenericDINode *getImpl(LLVMContext &Context, unsigned Tag,
MDString *Header, ArrayRef<Metadata *> DwarfOps,
StorageType Storage, bool ShouldCreate = true);
TempGenericDINode cloneImpl() const {
return getTemporary(
getContext(), getTag(), getHeader(),
SmallVector<Metadata *, 4>(dwarf_op_begin(), dwarf_op_end()));
}
public:
unsigned getHash() const { return SubclassData32; }
DEFINE_MDNODE_GET(GenericDINode, (unsigned Tag, StringRef Header,
ArrayRef<Metadata *> DwarfOps),
(Tag, Header, DwarfOps))
DEFINE_MDNODE_GET(GenericDINode, (unsigned Tag, MDString *Header,
ArrayRef<Metadata *> DwarfOps),
(Tag, Header, DwarfOps))
/// Return a (temporary) clone of this.
TempGenericDINode clone() const { return cloneImpl(); }
unsigned getTag() const { return SubclassData16; }
StringRef getHeader() const { return getStringOperand(0); }
MDString *getRawHeader() const { return getOperandAs<MDString>(0); }
op_iterator dwarf_op_begin() const { return op_begin() + 1; }
op_iterator dwarf_op_end() const { return op_end(); }
op_range dwarf_operands() const {
return op_range(dwarf_op_begin(), dwarf_op_end());
}
unsigned getNumDwarfOperands() const { return getNumOperands() - 1; }
const MDOperand &getDwarfOperand(unsigned I) const {
return getOperand(I + 1);
}
void replaceDwarfOperandWith(unsigned I, Metadata *New) {
replaceOperandWith(I + 1, New);
}
static bool classof(const Metadata *MD) {
return MD->getMetadataID() == GenericDINodeKind;
}
};
/// Array subrange.
///
/// TODO: Merge into node for DW_TAG_array_type, which should have a custom
/// type.
class DISubrange : public DINode {
friend class LLVMContextImpl;
friend class MDNode;
int64_t LowerBound;
DISubrange(LLVMContext &C, StorageType Storage, Metadata *Node,
int64_t LowerBound, ArrayRef<Metadata *> Ops)
: DINode(C, DISubrangeKind, Storage, dwarf::DW_TAG_subrange_type, Ops),
LowerBound(LowerBound) {}
~DISubrange() = default;
static DISubrange *getImpl(LLVMContext &Context, int64_t Count,
int64_t LowerBound, StorageType Storage,
bool ShouldCreate = true);
static DISubrange *getImpl(LLVMContext &Context, Metadata *CountNode,
int64_t LowerBound, StorageType Storage,
bool ShouldCreate = true);
TempDISubrange cloneImpl() const {
return getTemporary(getContext(), getRawCountNode(), getLowerBound());
}
public:
DEFINE_MDNODE_GET(DISubrange, (int64_t Count, int64_t LowerBound = 0),
(Count, LowerBound))
DEFINE_MDNODE_GET(DISubrange, (Metadata *CountNode, int64_t LowerBound = 0),
(CountNode, LowerBound))
TempDISubrange clone() const { return cloneImpl(); }
int64_t getLowerBound() const { return LowerBound; }
Metadata *getRawCountNode() const {
return getOperand(0).get();
}
typedef PointerUnion<ConstantInt*, DIVariable*> CountType;
CountType getCount() const {
if (auto *MD = dyn_cast<ConstantAsMetadata>(getRawCountNode()))
return CountType(cast<ConstantInt>(MD->getValue()));
if (auto *DV = dyn_cast<DIVariable>(getRawCountNode()))
return CountType(DV);
return CountType();
}
static bool classof(const Metadata *MD) {
return MD->getMetadataID() == DISubrangeKind;
}
};
/// Enumeration value.
///
/// TODO: Add a pointer to the context (DW_TAG_enumeration_type) once that no
/// longer creates a type cycle.
class DIEnumerator : public DINode {
friend class LLVMContextImpl;
friend class MDNode;
int64_t Value;
DIEnumerator(LLVMContext &C, StorageType Storage, int64_t Value,
bool IsUnsigned, ArrayRef<Metadata *> Ops)
: DINode(C, DIEnumeratorKind, Storage, dwarf::DW_TAG_enumerator, Ops),
Value(Value) {
SubclassData32 = IsUnsigned;
}
~DIEnumerator() = default;
static DIEnumerator *getImpl(LLVMContext &Context, int64_t Value,
bool IsUnsigned, StringRef Name,
StorageType Storage, bool ShouldCreate = true) {
return getImpl(Context, Value, IsUnsigned,
getCanonicalMDString(Context, Name), Storage, ShouldCreate);
}
static DIEnumerator *getImpl(LLVMContext &Context, int64_t Value,
bool IsUnsigned, MDString *Name,
StorageType Storage, bool ShouldCreate = true);
TempDIEnumerator cloneImpl() const {
return getTemporary(getContext(), getValue(), isUnsigned(), getName());
}
public:
DEFINE_MDNODE_GET(DIEnumerator, (int64_t Value, bool IsUnsigned, StringRef Name),
(Value, IsUnsigned, Name))
DEFINE_MDNODE_GET(DIEnumerator, (int64_t Value, bool IsUnsigned, MDString *Name),
(Value, IsUnsigned, Name))
TempDIEnumerator clone() const { return cloneImpl(); }
int64_t getValue() const { return Value; }
bool isUnsigned() const { return SubclassData32; }
StringRef getName() const { return getStringOperand(0); }
MDString *getRawName() const { return getOperandAs<MDString>(0); }
static bool classof(const Metadata *MD) {
return MD->getMetadataID() == DIEnumeratorKind;
}
};
/// Base class for scope-like contexts.
///
/// Base class for lexical scopes and types (which are also declaration
/// contexts).
///
/// TODO: Separate the concepts of declaration contexts and lexical scopes.
class DIScope : public DINode {
protected:
DIScope(LLVMContext &C, unsigned ID, StorageType Storage, unsigned Tag,
ArrayRef<Metadata *> Ops)
: DINode(C, ID, Storage, Tag, Ops) {}
~DIScope() = default;
public:
DIFile *getFile() const { return cast_or_null<DIFile>(getRawFile()); }
inline StringRef getFilename() const;
inline StringRef getDirectory() const;
inline Optional<StringRef> getSource() const;
StringRef getName() const;
DIScopeRef getScope() const;
/// Return the raw underlying file.
///
/// A \a DIFile is a \a DIScope, but it doesn't point at a separate file (it
/// \em is the file). If \c this is an \a DIFile, we need to return \c this.
/// Otherwise, return the first operand, which is where all other subclasses
/// store their file pointer.
Metadata *getRawFile() const {
return isa<DIFile>(this) ? const_cast<DIScope *>(this)
: static_cast<Metadata *>(getOperand(0));
}
static bool classof(const Metadata *MD) {
switch (MD->getMetadataID()) {
default:
return false;
case DIBasicTypeKind:
case DIDerivedTypeKind:
case DICompositeTypeKind:
case DISubroutineTypeKind:
case DIFileKind:
case DICompileUnitKind:
case DISubprogramKind:
case DILexicalBlockKind:
case DILexicalBlockFileKind:
case DINamespaceKind:
case DIModuleKind:
return true;
}
}
};
/// File.
///
/// TODO: Merge with directory/file node (including users).
/// TODO: Canonicalize paths on creation.
class DIFile : public DIScope {
friend class LLVMContextImpl;
friend class MDNode;
public:
/// Which algorithm (e.g. MD5) a checksum was generated with.
///
/// The encoding is explicit because it is used directly in Bitcode. The
/// value 0 is reserved to indicate the absence of a checksum in Bitcode.
enum ChecksumKind {
// The first variant was originally CSK_None, encoded as 0. The new
// internal representation removes the need for this by wrapping the
// ChecksumInfo in an Optional, but to preserve Bitcode compatibility the 0
// encoding is reserved.
CSK_MD5 = 1,
CSK_SHA1 = 2,
CSK_Last = CSK_SHA1 // Should be last enumeration.
};
/// A single checksum, represented by a \a Kind and a \a Value (a string).
template <typename T>
struct ChecksumInfo {
/// The kind of checksum which \a Value encodes.
ChecksumKind Kind;
/// The string value of the checksum.
T Value;
ChecksumInfo(ChecksumKind Kind, T Value) : Kind(Kind), Value(Value) { }
~ChecksumInfo() = default;
bool operator==(const ChecksumInfo<T> &X) const {
return Kind == X.Kind && Value == X.Value;
}
bool operator!=(const ChecksumInfo<T> &X) const { return !(*this == X); }
StringRef getKindAsString() const { return getChecksumKindAsString(Kind); }
};
private:
Optional<ChecksumInfo<MDString *>> Checksum;
Optional<MDString *> Source;
DIFile(LLVMContext &C, StorageType Storage,
Optional<ChecksumInfo<MDString *>> CS, Optional<MDString *> Src,
ArrayRef<Metadata *> Ops)
: DIScope(C, DIFileKind, Storage, dwarf::DW_TAG_file_type, Ops),
Checksum(CS), Source(Src) {}
~DIFile() = default;
static DIFile *getImpl(LLVMContext &Context, StringRef Filename,
StringRef Directory,
Optional<ChecksumInfo<StringRef>> CS,
Optional<StringRef> Source,
StorageType Storage, bool ShouldCreate = true) {
Optional<ChecksumInfo<MDString *>> MDChecksum;
if (CS)
MDChecksum.emplace(CS->Kind, getCanonicalMDString(Context, CS->Value));
return getImpl(Context, getCanonicalMDString(Context, Filename),
getCanonicalMDString(Context, Directory), MDChecksum,
Source ? Optional<MDString *>(getCanonicalMDString(Context, *Source)) : None,
Storage, ShouldCreate);
}
static DIFile *getImpl(LLVMContext &Context, MDString *Filename,
MDString *Directory,
Optional<ChecksumInfo<MDString *>> CS,
Optional<MDString *> Source, StorageType Storage,
bool ShouldCreate = true);
TempDIFile cloneImpl() const {
return getTemporary(getContext(), getFilename(), getDirectory(),
getChecksum(), getSource());
}
public:
DEFINE_MDNODE_GET(DIFile, (StringRef Filename, StringRef Directory,
Optional<ChecksumInfo<StringRef>> CS = None,
Optional<StringRef> Source = None),
(Filename, Directory, CS, Source))
DEFINE_MDNODE_GET(DIFile, (MDString * Filename, MDString *Directory,
Optional<ChecksumInfo<MDString *>> CS = None,
Optional<MDString *> Source = None),
(Filename, Directory, CS, Source))
TempDIFile clone() const { return cloneImpl(); }
StringRef getFilename() const { return getStringOperand(0); }
StringRef getDirectory() const { return getStringOperand(1); }
Optional<ChecksumInfo<StringRef>> getChecksum() const {
Optional<ChecksumInfo<StringRef>> StringRefChecksum;
if (Checksum)
StringRefChecksum.emplace(Checksum->Kind, Checksum->Value->getString());
return StringRefChecksum;
}
Optional<StringRef> getSource() const {
return Source ? Optional<StringRef>((*Source)->getString()) : None;
}
MDString *getRawFilename() const { return getOperandAs<MDString>(0); }
MDString *getRawDirectory() const { return getOperandAs<MDString>(1); }
Optional<ChecksumInfo<MDString *>> getRawChecksum() const { return Checksum; }
Optional<MDString *> getRawSource() const { return Source; }
static StringRef getChecksumKindAsString(ChecksumKind CSKind);
static Optional<ChecksumKind> getChecksumKind(StringRef CSKindStr);
static bool classof(const Metadata *MD) {
return MD->getMetadataID() == DIFileKind;
}
};
StringRef DIScope::getFilename() const {
if (auto *F = getFile())
return F->getFilename();
return "";
}
StringRef DIScope::getDirectory() const {
if (auto *F = getFile())
return F->getDirectory();
return "";
}
Optional<StringRef> DIScope::getSource() const {
if (auto *F = getFile())
return F->getSource();
return None;
}
/// Base class for types.
///
/// TODO: Remove the hardcoded name and context, since many types don't use
/// them.
/// TODO: Split up flags.
class DIType : public DIScope {
unsigned Line;
DIFlags Flags;
uint64_t SizeInBits;
uint64_t OffsetInBits;
uint32_t AlignInBits;
protected:
DIType(LLVMContext &C, unsigned ID, StorageType Storage, unsigned Tag,
unsigned Line, uint64_t SizeInBits, uint32_t AlignInBits,
uint64_t OffsetInBits, DIFlags Flags, ArrayRef<Metadata *> Ops)
: DIScope(C, ID, Storage, Tag, Ops) {
init(Line, SizeInBits, AlignInBits, OffsetInBits, Flags);
}
~DIType() = default;
void init(unsigned Line, uint64_t SizeInBits, uint32_t AlignInBits,
uint64_t OffsetInBits, DIFlags Flags) {
this->Line = Line;
this->Flags = Flags;
this->SizeInBits = SizeInBits;
this->AlignInBits = AlignInBits;
this->OffsetInBits = OffsetInBits;
}
/// Change fields in place.
void mutate(unsigned Tag, unsigned Line, uint64_t SizeInBits,
uint32_t AlignInBits, uint64_t OffsetInBits, DIFlags Flags) {
assert(isDistinct() && "Only distinct nodes can mutate");
setTag(Tag);
init(Line, SizeInBits, AlignInBits, OffsetInBits, Flags);
}
public:
TempDIType clone() const {
return TempDIType(cast<DIType>(MDNode::clone().release()));
}
unsigned getLine() const { return Line; }
uint64_t getSizeInBits() const { return SizeInBits; }
uint32_t getAlignInBits() const { return AlignInBits; }
uint32_t getAlignInBytes() const { return getAlignInBits() / CHAR_BIT; }
uint64_t getOffsetInBits() const { return OffsetInBits; }
DIFlags getFlags() const { return Flags; }
DIScopeRef getScope() const { return DIScopeRef(getRawScope()); }
StringRef getName() const { return getStringOperand(2); }
Metadata *getRawScope() const { return getOperand(1); }
MDString *getRawName() const { return getOperandAs<MDString>(2); }
void setFlags(DIFlags NewFlags) {
assert(!isUniqued() && "Cannot set flags on uniqued nodes");
Flags = NewFlags;
}
bool isPrivate() const {
return (getFlags() & FlagAccessibility) == FlagPrivate;
}
bool isProtected() const {
return (getFlags() & FlagAccessibility) == FlagProtected;
}
bool isPublic() const {
return (getFlags() & FlagAccessibility) == FlagPublic;
}
bool isForwardDecl() const { return getFlags() & FlagFwdDecl; }
bool isAppleBlockExtension() const { return getFlags() & FlagAppleBlock; }
bool isBlockByrefStruct() const { return getFlags() & FlagBlockByrefStruct; }
bool isVirtual() const { return getFlags() & FlagVirtual; }
bool isArtificial() const { return getFlags() & FlagArtificial; }
bool isObjectPointer() const { return getFlags() & FlagObjectPointer; }
bool isObjcClassComplete() const {
return getFlags() & FlagObjcClassComplete;
}
bool isVector() const { return getFlags() & FlagVector; }
bool isBitField() const { return getFlags() & FlagBitField; }
bool isStaticMember() const { return getFlags() & FlagStaticMember; }
bool isLValueReference() const { return getFlags() & FlagLValueReference; }
bool isRValueReference() const { return getFlags() & FlagRValueReference; }
bool isTypePassByValue() const { return getFlags() & FlagTypePassByValue; }
bool isTypePassByReference() const {
return getFlags() & FlagTypePassByReference;
}
static bool classof(const Metadata *MD) {
switch (MD->getMetadataID()) {
default:
return false;
case DIBasicTypeKind:
case DIDerivedTypeKind:
case DICompositeTypeKind:
case DISubroutineTypeKind:
return true;
}
}
};
/// Basic type, like 'int' or 'float'.
///
/// TODO: Split out DW_TAG_unspecified_type.
/// TODO: Drop unused accessors.
class DIBasicType : public DIType {
friend class LLVMContextImpl;
friend class MDNode;
unsigned Encoding;
DIBasicType(LLVMContext &C, StorageType Storage, unsigned Tag,
uint64_t SizeInBits, uint32_t AlignInBits, unsigned Encoding,
ArrayRef<Metadata *> Ops)
: DIType(C, DIBasicTypeKind, Storage, Tag, 0, SizeInBits, AlignInBits, 0,
FlagZero, Ops),
Encoding(Encoding) {}
~DIBasicType() = default;
static DIBasicType *getImpl(LLVMContext &Context, unsigned Tag,
StringRef Name, uint64_t SizeInBits,
uint32_t AlignInBits, unsigned Encoding,
StorageType Storage, bool ShouldCreate = true) {
return getImpl(Context, Tag, getCanonicalMDString(Context, Name),
SizeInBits, AlignInBits, Encoding, Storage, ShouldCreate);
}
static DIBasicType *getImpl(LLVMContext &Context, unsigned Tag,
MDString *Name, uint64_t SizeInBits,
uint32_t AlignInBits, unsigned Encoding,
StorageType Storage, bool ShouldCreate = true);
TempDIBasicType cloneImpl() const {
return getTemporary(getContext(), getTag(), getName(), getSizeInBits(),
getAlignInBits(), getEncoding());
}
public:
DEFINE_MDNODE_GET(DIBasicType, (unsigned Tag, StringRef Name),
(Tag, Name, 0, 0, 0))
DEFINE_MDNODE_GET(DIBasicType,
(unsigned Tag, StringRef Name, uint64_t SizeInBits,
uint32_t AlignInBits, unsigned Encoding),
(Tag, Name, SizeInBits, AlignInBits, Encoding))
DEFINE_MDNODE_GET(DIBasicType,
(unsigned Tag, MDString *Name, uint64_t SizeInBits,
uint32_t AlignInBits, unsigned Encoding),
(Tag, Name, SizeInBits, AlignInBits, Encoding))
TempDIBasicType clone() const { return cloneImpl(); }
unsigned getEncoding() const { return Encoding; }
static bool classof(const Metadata *MD) {
return MD->getMetadataID() == DIBasicTypeKind;
}
};
/// Derived types.
///
/// This includes qualified types, pointers, references, friends, typedefs, and
/// class members.
///
/// TODO: Split out members (inheritance, fields, methods, etc.).
class DIDerivedType : public DIType {
friend class LLVMContextImpl;
friend class MDNode;
/// \brief The DWARF address space of the memory pointed to or referenced by a
/// pointer or reference type respectively.
Optional<unsigned> DWARFAddressSpace;
DIDerivedType(LLVMContext &C, StorageType Storage, unsigned Tag,
unsigned Line, uint64_t SizeInBits, uint32_t AlignInBits,
uint64_t OffsetInBits, Optional<unsigned> DWARFAddressSpace,
DIFlags Flags, ArrayRef<Metadata *> Ops)
: DIType(C, DIDerivedTypeKind, Storage, Tag, Line, SizeInBits,
AlignInBits, OffsetInBits, Flags, Ops),
DWARFAddressSpace(DWARFAddressSpace) {}
~DIDerivedType() = default;
static DIDerivedType *getImpl(LLVMContext &Context, unsigned Tag,
StringRef Name, DIFile *File, unsigned Line,
DIScopeRef Scope, DITypeRef BaseType,
uint64_t SizeInBits, uint32_t AlignInBits,
uint64_t OffsetInBits,
Optional<unsigned> DWARFAddressSpace,
DIFlags Flags, Metadata *ExtraData,
StorageType Storage, bool ShouldCreate = true) {
return getImpl(Context, Tag, getCanonicalMDString(Context, Name), File,
Line, Scope, BaseType, SizeInBits, AlignInBits, OffsetInBits,
DWARFAddressSpace, Flags, ExtraData, Storage, ShouldCreate);
}
static DIDerivedType *getImpl(LLVMContext &Context, unsigned Tag,
MDString *Name, Metadata *File, unsigned Line,
Metadata *Scope, Metadata *BaseType,
uint64_t SizeInBits, uint32_t AlignInBits,
uint64_t OffsetInBits,
Optional<unsigned> DWARFAddressSpace,
DIFlags Flags, Metadata *ExtraData,
StorageType Storage, bool ShouldCreate = true);
TempDIDerivedType cloneImpl() const {
return getTemporary(getContext(), getTag(), getName(), getFile(), getLine(),
getScope(), getBaseType(), getSizeInBits(),
getAlignInBits(), getOffsetInBits(),
getDWARFAddressSpace(), getFlags(), getExtraData());
}
public:
DEFINE_MDNODE_GET(DIDerivedType,
(unsigned Tag, MDString *Name, Metadata *File,
unsigned Line, Metadata *Scope, Metadata *BaseType,
uint64_t SizeInBits, uint32_t AlignInBits,
uint64_t OffsetInBits,
Optional<unsigned> DWARFAddressSpace, DIFlags Flags,
Metadata *ExtraData = nullptr),
(Tag, Name, File, Line, Scope, BaseType, SizeInBits,
AlignInBits, OffsetInBits, DWARFAddressSpace, Flags,
ExtraData))
DEFINE_MDNODE_GET(DIDerivedType,
(unsigned Tag, StringRef Name, DIFile *File, unsigned Line,
DIScopeRef Scope, DITypeRef BaseType, uint64_t SizeInBits,
uint32_t AlignInBits, uint64_t OffsetInBits,
Optional<unsigned> DWARFAddressSpace, DIFlags Flags,
Metadata *ExtraData = nullptr),
(Tag, Name, File, Line, Scope, BaseType, SizeInBits,
AlignInBits, OffsetInBits, DWARFAddressSpace, Flags,
ExtraData))
TempDIDerivedType clone() const { return cloneImpl(); }
/// Get the base type this is derived from.
DITypeRef getBaseType() const { return DITypeRef(getRawBaseType()); }
Metadata *getRawBaseType() const { return getOperand(3); }
/// \returns The DWARF address space of the memory pointed to or referenced by
/// a pointer or reference type respectively.
Optional<unsigned> getDWARFAddressSpace() const { return DWARFAddressSpace; }
/// Get extra data associated with this derived type.
///
/// Class type for pointer-to-members, objective-c property node for ivars,
/// or global constant wrapper for static members.
///
/// TODO: Separate out types that need this extra operand: pointer-to-member
/// types and member fields (static members and ivars).
Metadata *getExtraData() const { return getRawExtraData(); }
Metadata *getRawExtraData() const { return getOperand(4); }
/// Get casted version of extra data.
/// @{
DITypeRef getClassType() const {
assert(getTag() == dwarf::DW_TAG_ptr_to_member_type);
return DITypeRef(getExtraData());
}
DIObjCProperty *getObjCProperty() const {
return dyn_cast_or_null<DIObjCProperty>(getExtraData());
}
Constant *getStorageOffsetInBits() const {
assert(getTag() == dwarf::DW_TAG_member && isBitField());
if (auto *C = cast_or_null<ConstantAsMetadata>(getExtraData()))
return C->getValue();
return nullptr;
}
Constant *getConstant() const {
assert(getTag() == dwarf::DW_TAG_member && isStaticMember());
if (auto *C = cast_or_null<ConstantAsMetadata>(getExtraData()))
return C->getValue();
return nullptr;
}
Constant *getDiscriminantValue() const {
assert(getTag() == dwarf::DW_TAG_member && !isStaticMember());
if (auto *C = cast_or_null<ConstantAsMetadata>(getExtraData()))
return C->getValue();
return nullptr;
}
/// @}
static bool classof(const Metadata *MD) {
return MD->getMetadataID() == DIDerivedTypeKind;
}
};
/// Composite types.
///
/// TODO: Detach from DerivedTypeBase (split out MDEnumType?).
/// TODO: Create a custom, unrelated node for DW_TAG_array_type.
class DICompositeType : public DIType {
friend class LLVMContextImpl;
friend class MDNode;
unsigned RuntimeLang;
DICompositeType(LLVMContext &C, StorageType Storage, unsigned Tag,
unsigned Line, unsigned RuntimeLang, uint64_t SizeInBits,
uint32_t AlignInBits, uint64_t OffsetInBits, DIFlags Flags,
ArrayRef<Metadata *> Ops)
: DIType(C, DICompositeTypeKind, Storage, Tag, Line, SizeInBits,
AlignInBits, OffsetInBits, Flags, Ops),
RuntimeLang(RuntimeLang) {}
~DICompositeType() = default;
/// Change fields in place.
void mutate(unsigned Tag, unsigned Line, unsigned RuntimeLang,
uint64_t SizeInBits, uint32_t AlignInBits,
uint64_t OffsetInBits, DIFlags Flags) {
assert(isDistinct() && "Only distinct nodes can mutate");
assert(getRawIdentifier() && "Only ODR-uniqued nodes should mutate");
this->RuntimeLang = RuntimeLang;
DIType::mutate(Tag, Line, SizeInBits, AlignInBits, OffsetInBits, Flags);
}
static DICompositeType *
getImpl(LLVMContext &Context, unsigned Tag, StringRef Name, Metadata *File,
unsigned Line, DIScopeRef Scope, DITypeRef BaseType,
uint64_t SizeInBits, uint32_t AlignInBits, uint64_t OffsetInBits,
DIFlags Flags, DINodeArray Elements, unsigned RuntimeLang,
DITypeRef VTableHolder, DITemplateParameterArray TemplateParams,
StringRef Identifier, DIDerivedType *Discriminator,
StorageType Storage, bool ShouldCreate = true) {
return getImpl(
Context, Tag, getCanonicalMDString(Context, Name), File, Line, Scope,
BaseType, SizeInBits, AlignInBits, OffsetInBits, Flags, Elements.get(),
RuntimeLang, VTableHolder, TemplateParams.get(),
getCanonicalMDString(Context, Identifier), Discriminator, Storage, ShouldCreate);
}
static DICompositeType *
getImpl(LLVMContext &Context, unsigned Tag, MDString *Name, Metadata *File,
unsigned Line, Metadata *Scope, Metadata *BaseType,
uint64_t SizeInBits, uint32_t AlignInBits, uint64_t OffsetInBits,
DIFlags Flags, Metadata *Elements, unsigned RuntimeLang,
Metadata *VTableHolder, Metadata *TemplateParams,
MDString *Identifier, Metadata *Discriminator,
StorageType Storage, bool ShouldCreate = true);
TempDICompositeType cloneImpl() const {
return getTemporary(getContext(), getTag(), getName(), getFile(), getLine(),
getScope(), getBaseType(), getSizeInBits(),
getAlignInBits(), getOffsetInBits(), getFlags(),
getElements(), getRuntimeLang(), getVTableHolder(),
getTemplateParams(), getIdentifier(), getDiscriminator());
}
public:
DEFINE_MDNODE_GET(DICompositeType,
(unsigned Tag, StringRef Name, DIFile *File, unsigned Line,
DIScopeRef Scope, DITypeRef BaseType, uint64_t SizeInBits,
uint32_t AlignInBits, uint64_t OffsetInBits,
DIFlags Flags, DINodeArray Elements, unsigned RuntimeLang,
DITypeRef VTableHolder,
DITemplateParameterArray TemplateParams = nullptr,
StringRef Identifier = "", DIDerivedType *Discriminator = nullptr),
(Tag, Name, File, Line, Scope, BaseType, SizeInBits,
AlignInBits, OffsetInBits, Flags, Elements, RuntimeLang,
VTableHolder, TemplateParams, Identifier, Discriminator))
DEFINE_MDNODE_GET(DICompositeType,
(unsigned Tag, MDString *Name, Metadata *File,
unsigned Line, Metadata *Scope, Metadata *BaseType,
uint64_t SizeInBits, uint32_t AlignInBits,
uint64_t OffsetInBits, DIFlags Flags, Metadata *Elements,
unsigned RuntimeLang, Metadata *VTableHolder,
Metadata *TemplateParams = nullptr,
MDString *Identifier = nullptr,
Metadata *Discriminator = nullptr),
(Tag, Name, File, Line, Scope, BaseType, SizeInBits,
AlignInBits, OffsetInBits, Flags, Elements, RuntimeLang,
VTableHolder, TemplateParams, Identifier, Discriminator))
TempDICompositeType clone() const { return cloneImpl(); }
/// Get a DICompositeType with the given ODR identifier.
///
/// If \a LLVMContext::isODRUniquingDebugTypes(), gets the mapped
/// DICompositeType for the given ODR \c Identifier. If none exists, creates
/// a new node.
///
/// Else, returns \c nullptr.
static DICompositeType *
getODRType(LLVMContext &Context, MDString &Identifier, unsigned Tag,
MDString *Name, Metadata *File, unsigned Line, Metadata *Scope,
Metadata *BaseType, uint64_t SizeInBits, uint32_t AlignInBits,
uint64_t OffsetInBits, DIFlags Flags, Metadata *Elements,
unsigned RuntimeLang, Metadata *VTableHolder,
Metadata *TemplateParams, Metadata *Discriminator);
static DICompositeType *getODRTypeIfExists(LLVMContext &Context,
MDString &Identifier);
/// Build a DICompositeType with the given ODR identifier.
///
/// Looks up the mapped DICompositeType for the given ODR \c Identifier. If
/// it doesn't exist, creates a new one. If it does exist and \a
/// isForwardDecl(), and the new arguments would be a definition, mutates the
/// the type in place. In either case, returns the type.
///
/// If not \a LLVMContext::isODRUniquingDebugTypes(), this function returns
/// nullptr.
static DICompositeType *
buildODRType(LLVMContext &Context, MDString &Identifier, unsigned Tag,
MDString *Name, Metadata *File, unsigned Line, Metadata *Scope,
Metadata *BaseType, uint64_t SizeInBits, uint32_t AlignInBits,
uint64_t OffsetInBits, DIFlags Flags, Metadata *Elements,
unsigned RuntimeLang, Metadata *VTableHolder,
Metadata *TemplateParams, Metadata *Discriminator);
DITypeRef getBaseType() const { return DITypeRef(getRawBaseType()); }
DINodeArray getElements() const {
return cast_or_null<MDTuple>(getRawElements());
}
DITypeRef getVTableHolder() const { return DITypeRef(getRawVTableHolder()); }
DITemplateParameterArray getTemplateParams() const {
return cast_or_null<MDTuple>(getRawTemplateParams());
}
StringRef getIdentifier() const { return getStringOperand(7); }
unsigned getRuntimeLang() const { return RuntimeLang; }
Metadata *getRawBaseType() const { return getOperand(3); }
Metadata *getRawElements() const { return getOperand(4); }
Metadata *getRawVTableHolder() const { return getOperand(5); }
Metadata *getRawTemplateParams() const { return getOperand(6); }
MDString *getRawIdentifier() const { return getOperandAs<MDString>(7); }
Metadata *getRawDiscriminator() const { return getOperand(8); }
DIDerivedType *getDiscriminator() const { return getOperandAs<DIDerivedType>(8); }
/// Replace operands.
///
/// If this \a isUniqued() and not \a isResolved(), on a uniquing collision
/// this will be RAUW'ed and deleted. Use a \a TrackingMDRef to keep track
/// of its movement if necessary.
/// @{
void replaceElements(DINodeArray Elements) {
#ifndef NDEBUG
for (DINode *Op : getElements())
assert(is_contained(Elements->operands(), Op) &&
"Lost a member during member list replacement");
#endif
replaceOperandWith(4, Elements.get());
}
void replaceVTableHolder(DITypeRef VTableHolder) {
replaceOperandWith(5, VTableHolder);
}
void replaceTemplateParams(DITemplateParameterArray TemplateParams) {
replaceOperandWith(6, TemplateParams.get());
}
/// @}
static bool classof(const Metadata *MD) {
return MD->getMetadataID() == DICompositeTypeKind;
}
};
/// Type array for a subprogram.
///
/// TODO: Fold the array of types in directly as operands.
class DISubroutineType : public DIType {
friend class LLVMContextImpl;
friend class MDNode;
/// The calling convention used with DW_AT_calling_convention. Actually of
/// type dwarf::CallingConvention.
uint8_t CC;
DISubroutineType(LLVMContext &C, StorageType Storage, DIFlags Flags,
uint8_t CC, ArrayRef<Metadata *> Ops)
: DIType(C, DISubroutineTypeKind, Storage, dwarf::DW_TAG_subroutine_type,
0, 0, 0, 0, Flags, Ops),
CC(CC) {}
~DISubroutineType() = default;
static DISubroutineType *getImpl(LLVMContext &Context, DIFlags Flags,
uint8_t CC, DITypeRefArray TypeArray,
StorageType Storage,
bool ShouldCreate = true) {
return getImpl(Context, Flags, CC, TypeArray.get(), Storage, ShouldCreate);
}
static DISubroutineType *getImpl(LLVMContext &Context, DIFlags Flags,
uint8_t CC, Metadata *TypeArray,
StorageType Storage,
bool ShouldCreate = true);
TempDISubroutineType cloneImpl() const {
return getTemporary(getContext(), getFlags(), getCC(), getTypeArray());
}
public:
DEFINE_MDNODE_GET(DISubroutineType,
(DIFlags Flags, uint8_t CC, DITypeRefArray TypeArray),
(Flags, CC, TypeArray))
DEFINE_MDNODE_GET(DISubroutineType,
(DIFlags Flags, uint8_t CC, Metadata *TypeArray),
(Flags, CC, TypeArray))
TempDISubroutineType clone() const { return cloneImpl(); }
uint8_t getCC() const { return CC; }
DITypeRefArray getTypeArray() const {
return cast_or_null<MDTuple>(getRawTypeArray());
}
Metadata *getRawTypeArray() const { return getOperand(3); }
static bool classof(const Metadata *MD) {
return MD->getMetadataID() == DISubroutineTypeKind;
}
};
/// Compile unit.
class DICompileUnit : public DIScope {
friend class LLVMContextImpl;
friend class MDNode;
public:
enum DebugEmissionKind : unsigned {
NoDebug = 0,
FullDebug,
LineTablesOnly,
LastEmissionKind = LineTablesOnly
};
static Optional<DebugEmissionKind> getEmissionKind(StringRef Str);
static const char *EmissionKindString(DebugEmissionKind EK);
private:
unsigned SourceLanguage;
bool IsOptimized;
unsigned RuntimeVersion;
unsigned EmissionKind;
uint64_t DWOId;
bool SplitDebugInlining;
bool DebugInfoForProfiling;
bool GnuPubnames;
DICompileUnit(LLVMContext &C, StorageType Storage, unsigned SourceLanguage,
bool IsOptimized, unsigned RuntimeVersion,
unsigned EmissionKind, uint64_t DWOId, bool SplitDebugInlining,
bool DebugInfoForProfiling, bool GnuPubnames, ArrayRef<Metadata *> Ops)
: DIScope(C, DICompileUnitKind, Storage, dwarf::DW_TAG_compile_unit, Ops),
SourceLanguage(SourceLanguage), IsOptimized(IsOptimized),
RuntimeVersion(RuntimeVersion), EmissionKind(EmissionKind),
DWOId(DWOId), SplitDebugInlining(SplitDebugInlining),
DebugInfoForProfiling(DebugInfoForProfiling), GnuPubnames(GnuPubnames) {
assert(Storage != Uniqued);
}
~DICompileUnit() = default;
static DICompileUnit *
getImpl(LLVMContext &Context, unsigned SourceLanguage, DIFile *File,
StringRef Producer, bool IsOptimized, StringRef Flags,
unsigned RuntimeVersion, StringRef SplitDebugFilename,
unsigned EmissionKind, DICompositeTypeArray EnumTypes,
DIScopeArray RetainedTypes,
DIGlobalVariableExpressionArray GlobalVariables,
DIImportedEntityArray ImportedEntities, DIMacroNodeArray Macros,
uint64_t DWOId, bool SplitDebugInlining, bool DebugInfoForProfiling,
bool GnuPubnames, StorageType Storage, bool ShouldCreate = true) {
return getImpl(
Context, SourceLanguage, File, getCanonicalMDString(Context, Producer),
IsOptimized, getCanonicalMDString(Context, Flags), RuntimeVersion,
getCanonicalMDString(Context, SplitDebugFilename), EmissionKind,
EnumTypes.get(), RetainedTypes.get(), GlobalVariables.get(),
ImportedEntities.get(), Macros.get(), DWOId, SplitDebugInlining,
DebugInfoForProfiling, GnuPubnames, Storage, ShouldCreate);
}
static DICompileUnit *
getImpl(LLVMContext &Context, unsigned SourceLanguage, Metadata *File,
MDString *Producer, bool IsOptimized, MDString *Flags,
unsigned RuntimeVersion, MDString *SplitDebugFilename,
unsigned EmissionKind, Metadata *EnumTypes, Metadata *RetainedTypes,
Metadata *GlobalVariables, Metadata *ImportedEntities,
Metadata *Macros, uint64_t DWOId, bool SplitDebugInlining,
bool DebugInfoForProfiling, bool GnuPubnames, StorageType Storage,
bool ShouldCreate = true);
TempDICompileUnit cloneImpl() const {
return getTemporary(getContext(), getSourceLanguage(), getFile(),
getProducer(), isOptimized(), getFlags(),
getRuntimeVersion(), getSplitDebugFilename(),
getEmissionKind(), getEnumTypes(), getRetainedTypes(),
getGlobalVariables(), getImportedEntities(),
getMacros(), DWOId, getSplitDebugInlining(),
getDebugInfoForProfiling(), getGnuPubnames());
}
public:
static void get() = delete;
static void getIfExists() = delete;
DEFINE_MDNODE_GET_DISTINCT_TEMPORARY(
DICompileUnit,
(unsigned SourceLanguage, DIFile *File, StringRef Producer,
bool IsOptimized, StringRef Flags, unsigned RuntimeVersion,
StringRef SplitDebugFilename, DebugEmissionKind EmissionKind,
DICompositeTypeArray EnumTypes, DIScopeArray RetainedTypes,
DIGlobalVariableExpressionArray GlobalVariables,
DIImportedEntityArray ImportedEntities, DIMacroNodeArray Macros,
uint64_t DWOId, bool SplitDebugInlining, bool DebugInfoForProfiling,
bool GnuPubnames),
(SourceLanguage, File, Producer, IsOptimized, Flags, RuntimeVersion,
SplitDebugFilename, EmissionKind, EnumTypes, RetainedTypes,
GlobalVariables, ImportedEntities, Macros, DWOId, SplitDebugInlining,
DebugInfoForProfiling, GnuPubnames))
DEFINE_MDNODE_GET_DISTINCT_TEMPORARY(
DICompileUnit,
(unsigned SourceLanguage, Metadata *File, MDString *Producer,
bool IsOptimized, MDString *Flags, unsigned RuntimeVersion,
MDString *SplitDebugFilename, unsigned EmissionKind, Metadata *EnumTypes,
Metadata *RetainedTypes, Metadata *GlobalVariables,
Metadata *ImportedEntities, Metadata *Macros, uint64_t DWOId,
bool SplitDebugInlining, bool DebugInfoForProfiling, bool GnuPubnames),
(SourceLanguage, File, Producer, IsOptimized, Flags, RuntimeVersion,
SplitDebugFilename, EmissionKind, EnumTypes, RetainedTypes,
GlobalVariables, ImportedEntities, Macros, DWOId, SplitDebugInlining,
DebugInfoForProfiling, GnuPubnames))
TempDICompileUnit clone() const { return cloneImpl(); }
unsigned getSourceLanguage() const { return SourceLanguage; }
bool isOptimized() const { return IsOptimized; }
unsigned getRuntimeVersion() const { return RuntimeVersion; }
DebugEmissionKind getEmissionKind() const {
return (DebugEmissionKind)EmissionKind;
}
bool getDebugInfoForProfiling() const { return DebugInfoForProfiling; }
bool getGnuPubnames() const { return GnuPubnames; }
StringRef getProducer() const { return getStringOperand(1); }
StringRef getFlags() const { return getStringOperand(2); }
StringRef getSplitDebugFilename() const { return getStringOperand(3); }
DICompositeTypeArray getEnumTypes() const {
return cast_or_null<MDTuple>(getRawEnumTypes());
}
DIScopeArray getRetainedTypes() const {
return cast_or_null<MDTuple>(getRawRetainedTypes());
}
DIGlobalVariableExpressionArray getGlobalVariables() const {
return cast_or_null<MDTuple>(getRawGlobalVariables());
}
DIImportedEntityArray getImportedEntities() const {
return cast_or_null<MDTuple>(getRawImportedEntities());
}
DIMacroNodeArray getMacros() const {
return cast_or_null<MDTuple>(getRawMacros());
}
uint64_t getDWOId() const { return DWOId; }
void setDWOId(uint64_t DwoId) { DWOId = DwoId; }
bool getSplitDebugInlining() const { return SplitDebugInlining; }
void setSplitDebugInlining(bool SplitDebugInlining) {
this->SplitDebugInlining = SplitDebugInlining;
}
MDString *getRawProducer() const { return getOperandAs<MDString>(1); }
MDString *getRawFlags() const { return getOperandAs<MDString>(2); }
MDString *getRawSplitDebugFilename() const {
return getOperandAs<MDString>(3);
}
Metadata *getRawEnumTypes() const { return getOperand(4); }
Metadata *getRawRetainedTypes() const { return getOperand(5); }
Metadata *getRawGlobalVariables() const { return getOperand(6); }
Metadata *getRawImportedEntities() const { return getOperand(7); }
Metadata *getRawMacros() const { return getOperand(8); }
/// Replace arrays.
///
/// If this \a isUniqued() and not \a isResolved(), it will be RAUW'ed and
/// deleted on a uniquing collision. In practice, uniquing collisions on \a
/// DICompileUnit should be fairly rare.
/// @{
void replaceEnumTypes(DICompositeTypeArray N) {
replaceOperandWith(4, N.get());
}
void replaceRetainedTypes(DITypeArray N) {
replaceOperandWith(5, N.get());
}
void replaceGlobalVariables(DIGlobalVariableExpressionArray N) {
replaceOperandWith(6, N.get());
}
void replaceImportedEntities(DIImportedEntityArray N) {
replaceOperandWith(7, N.get());
}
void replaceMacros(DIMacroNodeArray N) { replaceOperandWith(8, N.get()); }
/// @}
static bool classof(const Metadata *MD) {
return MD->getMetadataID() == DICompileUnitKind;
}
};
/// A scope for locals.
///
/// A legal scope for lexical blocks, local variables, and debug info
/// locations. Subclasses are \a DISubprogram, \a DILexicalBlock, and \a
/// DILexicalBlockFile.
class DILocalScope : public DIScope {
protected:
DILocalScope(LLVMContext &C, unsigned ID, StorageType Storage, unsigned Tag,
ArrayRef<Metadata *> Ops)
: DIScope(C, ID, Storage, Tag, Ops) {}
~DILocalScope() = default;
public:
/// Get the subprogram for this scope.
///
/// Return this if it's an \a DISubprogram; otherwise, look up the scope
/// chain.
DISubprogram *getSubprogram() const;
/// Get the first non DILexicalBlockFile scope of this scope.
///
/// Return this if it's not a \a DILexicalBlockFIle; otherwise, look up the
/// scope chain.
DILocalScope *getNonLexicalBlockFileScope() const;
static bool classof(const Metadata *MD) {
return MD->getMetadataID() == DISubprogramKind ||
MD->getMetadataID() == DILexicalBlockKind ||
MD->getMetadataID() == DILexicalBlockFileKind;
}
};
/// Debug location.
///
/// A debug location in source code, used for debug info and otherwise.
class DILocation : public MDNode {
friend class LLVMContextImpl;
friend class MDNode;
DILocation(LLVMContext &C, StorageType Storage, unsigned Line,
unsigned Column, ArrayRef<Metadata *> MDs);
~DILocation() { dropAllReferences(); }
static DILocation *getImpl(LLVMContext &Context, unsigned Line,
unsigned Column, Metadata *Scope,
Metadata *InlinedAt, StorageType Storage,
bool ShouldCreate = true);
static DILocation *getImpl(LLVMContext &Context, unsigned Line,
unsigned Column, DILocalScope *Scope,
DILocation *InlinedAt, StorageType Storage,
bool ShouldCreate = true) {
return getImpl(Context, Line, Column, static_cast<Metadata *>(Scope),
static_cast<Metadata *>(InlinedAt), Storage, ShouldCreate);
}
/// With a given unsigned int \p U, use up to 13 bits to represent it.
/// old_bit 1~5 --> new_bit 1~5
/// old_bit 6~12 --> new_bit 7~13
/// new_bit_6 is 0 if higher bits (7~13) are all 0
static unsigned getPrefixEncodingFromUnsigned(unsigned U) {
U &= 0xfff;
return U > 0x1f ? (((U & 0xfe0) << 1) | (U & 0x1f) | 0x20) : U;
}
/// Reverse transformation as getPrefixEncodingFromUnsigned.
static unsigned getUnsignedFromPrefixEncoding(unsigned U) {
return (U & 0x20) ? (((U >> 1) & 0xfe0) | (U & 0x1f)) : (U & 0x1f);
}
/// Returns the next component stored in discriminator.
static unsigned getNextComponentInDiscriminator(unsigned D) {
if ((D & 1) == 0)
return D >> ((D & 0x40) ? 14 : 7);
else
return D >> 1;
}
TempDILocation cloneImpl() const {
// Get the raw scope/inlinedAt since it is possible to invoke this on
// a DILocation containing temporary metadata.
return getTemporary(getContext(), getLine(), getColumn(), getRawScope(),
getRawInlinedAt());
}
public:
// Disallow replacing operands.
void replaceOperandWith(unsigned I, Metadata *New) = delete;
DEFINE_MDNODE_GET(DILocation,
(unsigned Line, unsigned Column, Metadata *Scope,
Metadata *InlinedAt = nullptr),
(Line, Column, Scope, InlinedAt))
DEFINE_MDNODE_GET(DILocation,
(unsigned Line, unsigned Column, DILocalScope *Scope,
DILocation *InlinedAt = nullptr),
(Line, Column, Scope, InlinedAt))
/// Return a (temporary) clone of this.
TempDILocation clone() const { return cloneImpl(); }
unsigned getLine() const { return SubclassData32; }
unsigned getColumn() const { return SubclassData16; }
DILocalScope *getScope() const { return cast<DILocalScope>(getRawScope()); }
DILocation *getInlinedAt() const {
return cast_or_null<DILocation>(getRawInlinedAt());
}
DIFile *getFile() const { return getScope()->getFile(); }
StringRef getFilename() const { return getScope()->getFilename(); }
StringRef getDirectory() const { return getScope()->getDirectory(); }
Optional<StringRef> getSource() const { return getScope()->getSource(); }
/// Get the scope where this is inlined.
///
/// Walk through \a getInlinedAt() and return \a getScope() from the deepest
/// location.
DILocalScope *getInlinedAtScope() const {
if (auto *IA = getInlinedAt())
return IA->getInlinedAtScope();
return getScope();
}
/// Check whether this can be discriminated from another location.
///
/// Check \c this can be discriminated from \c RHS in a linetable entry.
/// Scope and inlined-at chains are not recorded in the linetable, so they
/// cannot be used to distinguish basic blocks.
bool canDiscriminate(const DILocation &RHS) const {
return getLine() != RHS.getLine() ||
getColumn() != RHS.getColumn() ||
getDiscriminator() != RHS.getDiscriminator() ||
getFilename() != RHS.getFilename() ||
getDirectory() != RHS.getDirectory();
}
/// Get the DWARF discriminator.
///
/// DWARF discriminators distinguish identical file locations between
/// instructions that are on different basic blocks.
///
/// There are 3 components stored in discriminator, from lower bits:
///
/// Base discriminator: assigned by AddDiscriminators pass to identify IRs
/// that are defined by the same source line, but
/// different basic blocks.
/// Duplication factor: assigned by optimizations that will scale down
/// the execution frequency of the original IR.
/// Copy Identifier: assigned by optimizations that clones the IR.
/// Each copy of the IR will be assigned an identifier.
///
/// Encoding:
///
/// The above 3 components are encoded into a 32bit unsigned integer in
/// order. If the lowest bit is 1, the current component is empty, and the
/// next component will start in the next bit. Otherwise, the current
/// component is non-empty, and its content starts in the next bit. The
/// length of each components is either 5 bit or 12 bit: if the 7th bit
/// is 0, the bit 2~6 (5 bits) are used to represent the component; if the
/// 7th bit is 1, the bit 2~6 (5 bits) and 8~14 (7 bits) are combined to
/// represent the component.
inline unsigned getDiscriminator() const;
/// Returns a new DILocation with updated \p Discriminator.
inline const DILocation *cloneWithDiscriminator(unsigned Discriminator) const;
/// Returns a new DILocation with updated base discriminator \p BD.
inline const DILocation *setBaseDiscriminator(unsigned BD) const;
/// Returns the duplication factor stored in the discriminator.
inline unsigned getDuplicationFactor() const;
/// Returns the copy identifier stored in the discriminator.
inline unsigned getCopyIdentifier() const;
/// Returns the base discriminator stored in the discriminator.
inline unsigned getBaseDiscriminator() const;
/// Returns a new DILocation with duplication factor \p DF encoded in the
/// discriminator.
inline const DILocation *cloneWithDuplicationFactor(unsigned DF) const;
/// When two instructions are combined into a single instruction we also
/// need to combine the original locations into a single location.
///
/// When the locations are the same we can use either location. When they
/// differ, we need a third location which is distinct from either. If
/// they have the same file/line but have a different discriminator we
/// could create a location with a new discriminator. If they are from
/// different files/lines the location is ambiguous and can't be
/// represented in a single line entry. In this case, no location
/// should be set, unless the merged instruction is a call, which we will
/// set the merged debug location as line 0 of the nearest common scope
/// where 2 locations are inlined from. This only applies to Instruction;
/// for MachineInstruction, as it is post-inline, we will treat the call
/// instruction the same way as other instructions.
///
/// \p ForInst: The Instruction the merged DILocation is for. If the
/// Instruction is unavailable or non-existent, use nullptr.
static const DILocation *
getMergedLocation(const DILocation *LocA, const DILocation *LocB,
const Instruction *ForInst = nullptr);
/// Returns the base discriminator for a given encoded discriminator \p D.
static unsigned getBaseDiscriminatorFromDiscriminator(unsigned D) {
if ((D & 1) == 0)
return getUnsignedFromPrefixEncoding(D >> 1);
else
return 0;
}
/// Returns the duplication factor for a given encoded discriminator \p D.
static unsigned getDuplicationFactorFromDiscriminator(unsigned D) {
D = getNextComponentInDiscriminator(D);
if (D == 0 || (D & 1))
return 1;
else
return getUnsignedFromPrefixEncoding(D >> 1);
}
/// Returns the copy identifier for a given encoded discriminator \p D.
static unsigned getCopyIdentifierFromDiscriminator(unsigned D) {
return getUnsignedFromPrefixEncoding(getNextComponentInDiscriminator(
getNextComponentInDiscriminator(D)));
}
Metadata *getRawScope() const { return getOperand(0); }
Metadata *getRawInlinedAt() const {
if (getNumOperands() == 2)
return getOperand(1);
return nullptr;
}
static bool classof(const Metadata *MD) {
return MD->getMetadataID() == DILocationKind;
}
};
/// Subprogram description.
///
/// TODO: Remove DisplayName. It's always equal to Name.
/// TODO: Split up flags.
class DISubprogram : public DILocalScope {
friend class LLVMContextImpl;
friend class MDNode;
unsigned Line;
unsigned ScopeLine;
unsigned VirtualIndex;
/// In the MS ABI, the implicit 'this' parameter is adjusted in the prologue
/// of method overrides from secondary bases by this amount. It may be
/// negative.
int ThisAdjustment;
// Virtuality can only assume three values, so we can pack
// in 2 bits (none/pure/pure_virtual).
unsigned Virtuality : 2;
// These are boolean flags so one bit is enough.
// MSVC starts a new container field every time the base
// type changes so we can't use 'bool' to ensure these bits
// are packed.
unsigned IsLocalToUnit : 1;
unsigned IsDefinition : 1;
unsigned IsOptimized : 1;
unsigned Padding : 3;
DIFlags Flags;
DISubprogram(LLVMContext &C, StorageType Storage, unsigned Line,
unsigned ScopeLine, unsigned Virtuality, unsigned VirtualIndex,
int ThisAdjustment, DIFlags Flags, bool IsLocalToUnit,
bool IsDefinition, bool IsOptimized, ArrayRef<Metadata *> Ops)
: DILocalScope(C, DISubprogramKind, Storage, dwarf::DW_TAG_subprogram,
Ops),
Line(Line), ScopeLine(ScopeLine), VirtualIndex(VirtualIndex),
ThisAdjustment(ThisAdjustment), Virtuality(Virtuality),
IsLocalToUnit(IsLocalToUnit), IsDefinition(IsDefinition),
IsOptimized(IsOptimized), Flags(Flags) {
static_assert(dwarf::DW_VIRTUALITY_max < 4, "Virtuality out of range");
assert(Virtuality < 4 && "Virtuality out of range");
}
~DISubprogram() = default;
static DISubprogram *
getImpl(LLVMContext &Context, DIScopeRef Scope, StringRef Name,
StringRef LinkageName, DIFile *File, unsigned Line,
DISubroutineType *Type, bool IsLocalToUnit, bool IsDefinition,
unsigned ScopeLine, DITypeRef ContainingType, unsigned Virtuality,
unsigned VirtualIndex, int ThisAdjustment, DIFlags Flags,
bool IsOptimized, DICompileUnit *Unit,
DITemplateParameterArray TemplateParams, DISubprogram *Declaration,
DILocalVariableArray Variables, DITypeArray ThrownTypes,
StorageType Storage, bool ShouldCreate = true) {
return getImpl(Context, Scope, getCanonicalMDString(Context, Name),
getCanonicalMDString(Context, LinkageName), File, Line, Type,
IsLocalToUnit, IsDefinition, ScopeLine, ContainingType,
Virtuality, VirtualIndex, ThisAdjustment, Flags, IsOptimized,
Unit, TemplateParams.get(), Declaration, Variables.get(),
ThrownTypes.get(), Storage, ShouldCreate);
}
static DISubprogram *
getImpl(LLVMContext &Context, Metadata *Scope, MDString *Name,
MDString *LinkageName, Metadata *File, unsigned Line, Metadata *Type,
bool IsLocalToUnit, bool IsDefinition, unsigned ScopeLine,
Metadata *ContainingType, unsigned Virtuality, unsigned VirtualIndex,
int ThisAdjustment, DIFlags Flags, bool IsOptimized, Metadata *Unit,
Metadata *TemplateParams, Metadata *Declaration, Metadata *Variables,
Metadata *ThrownTypes, StorageType Storage, bool ShouldCreate = true);
TempDISubprogram cloneImpl() const {
return getTemporary(getContext(), getScope(), getName(), getLinkageName(),
getFile(), getLine(), getType(), isLocalToUnit(),
isDefinition(), getScopeLine(), getContainingType(),
getVirtuality(), getVirtualIndex(), getThisAdjustment(),
getFlags(), isOptimized(), getUnit(),
getTemplateParams(), getDeclaration(), getVariables(),
getThrownTypes());
}
public:
DEFINE_MDNODE_GET(DISubprogram,
(DIScopeRef Scope, StringRef Name, StringRef LinkageName,
DIFile *File, unsigned Line, DISubroutineType *Type,
bool IsLocalToUnit, bool IsDefinition, unsigned ScopeLine,
DITypeRef ContainingType, unsigned Virtuality,
unsigned VirtualIndex, int ThisAdjustment, DIFlags Flags,
bool IsOptimized, DICompileUnit *Unit,
DITemplateParameterArray TemplateParams = nullptr,
DISubprogram *Declaration = nullptr,
DILocalVariableArray Variables = nullptr,
DITypeArray ThrownTypes = nullptr),
(Scope, Name, LinkageName, File, Line, Type, IsLocalToUnit,
IsDefinition, ScopeLine, ContainingType, Virtuality,
VirtualIndex, ThisAdjustment, Flags, IsOptimized, Unit,
TemplateParams, Declaration, Variables, ThrownTypes))
DEFINE_MDNODE_GET(
DISubprogram,
(Metadata * Scope, MDString *Name, MDString *LinkageName, Metadata *File,
unsigned Line, Metadata *Type, bool IsLocalToUnit, bool IsDefinition,
unsigned ScopeLine, Metadata *ContainingType, unsigned Virtuality,
unsigned VirtualIndex, int ThisAdjustment, DIFlags Flags,
bool IsOptimized, Metadata *Unit, Metadata *TemplateParams = nullptr,
Metadata *Declaration = nullptr, Metadata *Variables = nullptr,
Metadata *ThrownTypes = nullptr),
(Scope, Name, LinkageName, File, Line, Type, IsLocalToUnit, IsDefinition,
ScopeLine, ContainingType, Virtuality, VirtualIndex, ThisAdjustment,
Flags, IsOptimized, Unit, TemplateParams, Declaration, Variables,
ThrownTypes))
TempDISubprogram clone() const { return cloneImpl(); }
public:
unsigned getLine() const { return Line; }
unsigned getVirtuality() const { return Virtuality; }
unsigned getVirtualIndex() const { return VirtualIndex; }
int getThisAdjustment() const { return ThisAdjustment; }
unsigned getScopeLine() const { return ScopeLine; }
DIFlags getFlags() const { return Flags; }
bool isLocalToUnit() const { return IsLocalToUnit; }
bool isDefinition() const { return IsDefinition; }
bool isOptimized() const { return IsOptimized; }
bool isArtificial() const { return getFlags() & FlagArtificial; }
bool isPrivate() const {
return (getFlags() & FlagAccessibility) == FlagPrivate;
}
bool isProtected() const {
return (getFlags() & FlagAccessibility) == FlagProtected;
}
bool isPublic() const {
return (getFlags() & FlagAccessibility) == FlagPublic;
}
bool isExplicit() const { return getFlags() & FlagExplicit; }
bool isPrototyped() const { return getFlags() & FlagPrototyped; }
bool isMainSubprogram() const { return getFlags() & FlagMainSubprogram; }
/// Check if this is reference-qualified.
///
/// Return true if this subprogram is a C++11 reference-qualified non-static
/// member function (void foo() &).
bool isLValueReference() const { return getFlags() & FlagLValueReference; }
/// Check if this is rvalue-reference-qualified.
///
/// Return true if this subprogram is a C++11 rvalue-reference-qualified
/// non-static member function (void foo() &&).
bool isRValueReference() const { return getFlags() & FlagRValueReference; }
/// Check if this is marked as noreturn.
///
/// Return true if this subprogram is C++11 noreturn or C11 _Noreturn
bool isNoReturn() const { return getFlags() & FlagNoReturn; }
DIScopeRef getScope() const { return DIScopeRef(getRawScope()); }
StringRef getName() const { return getStringOperand(2); }
StringRef getLinkageName() const { return getStringOperand(3); }
DISubroutineType *getType() const {
return cast_or_null<DISubroutineType>(getRawType());
}
DITypeRef getContainingType() const {
return DITypeRef(getRawContainingType());
}
DICompileUnit *getUnit() const {
return cast_or_null<DICompileUnit>(getRawUnit());
}
void replaceUnit(DICompileUnit *CU) { replaceOperandWith(5, CU); }
DITemplateParameterArray getTemplateParams() const {
return cast_or_null<MDTuple>(getRawTemplateParams());
}
DISubprogram *getDeclaration() const {
return cast_or_null<DISubprogram>(getRawDeclaration());
}
DILocalVariableArray getVariables() const {
return cast_or_null<MDTuple>(getRawVariables());
}
DITypeArray getThrownTypes() const {
return cast_or_null<MDTuple>(getRawThrownTypes());
}
Metadata *getRawScope() const { return getOperand(1); }
MDString *getRawName() const { return getOperandAs<MDString>(2); }
MDString *getRawLinkageName() const { return getOperandAs<MDString>(3); }
Metadata *getRawType() const { return getOperand(4); }
Metadata *getRawUnit() const { return getOperand(5); }
Metadata *getRawDeclaration() const { return getOperand(6); }
Metadata *getRawVariables() const { return getOperand(7); }
Metadata *getRawContainingType() const {
return getNumOperands() > 8 ? getOperandAs<Metadata>(8) : nullptr;
}
Metadata *getRawTemplateParams() const {
return getNumOperands() > 9 ? getOperandAs<Metadata>(9) : nullptr;
}
Metadata *getRawThrownTypes() const {
return getNumOperands() > 10 ? getOperandAs<Metadata>(10) : nullptr;
}
/// Check if this subprogram describes the given function.
///
/// FIXME: Should this be looking through bitcasts?
bool describes(const Function *F) const;
static bool classof(const Metadata *MD) {
return MD->getMetadataID() == DISubprogramKind;
}
};
class DILexicalBlockBase : public DILocalScope {
protected:
DILexicalBlockBase(LLVMContext &C, unsigned ID, StorageType Storage,
ArrayRef<Metadata *> Ops)
: DILocalScope(C, ID, Storage, dwarf::DW_TAG_lexical_block, Ops) {}
~DILexicalBlockBase() = default;
public:
DILocalScope *getScope() const { return cast<DILocalScope>(getRawScope()); }
Metadata *getRawScope() const { return getOperand(1); }
static bool classof(const Metadata *MD) {
return MD->getMetadataID() == DILexicalBlockKind ||
MD->getMetadataID() == DILexicalBlockFileKind;
}
};
class DILexicalBlock : public DILexicalBlockBase {
friend class LLVMContextImpl;
friend class MDNode;
unsigned Line;
uint16_t Column;
DILexicalBlock(LLVMContext &C, StorageType Storage, unsigned Line,
unsigned Column, ArrayRef<Metadata *> Ops)
: DILexicalBlockBase(C, DILexicalBlockKind, Storage, Ops), Line(Line),
Column(Column) {
assert(Column < (1u << 16) && "Expected 16-bit column");
}
~DILexicalBlock() = default;
static DILexicalBlock *getImpl(LLVMContext &Context, DILocalScope *Scope,
DIFile *File, unsigned Line, unsigned Column,
StorageType Storage,
bool ShouldCreate = true) {
return getImpl(Context, static_cast<Metadata *>(Scope),
static_cast<Metadata *>(File), Line, Column, Storage,
ShouldCreate);
}
static DILexicalBlock *getImpl(LLVMContext &Context, Metadata *Scope,
Metadata *File, unsigned Line, unsigned Column,
StorageType Storage, bool ShouldCreate = true);
TempDILexicalBlock cloneImpl() const {
return getTemporary(getContext(), getScope(), getFile(), getLine(),
getColumn());
}
public:
DEFINE_MDNODE_GET(DILexicalBlock, (DILocalScope * Scope, DIFile *File,
unsigned Line, unsigned Column),
(Scope, File, Line, Column))
DEFINE_MDNODE_GET(DILexicalBlock, (Metadata * Scope, Metadata *File,
unsigned Line, unsigned Column),
(Scope, File, Line, Column))
TempDILexicalBlock clone() const { return cloneImpl(); }
unsigned getLine() const { return Line; }
unsigned getColumn() const { return Column; }
static bool classof(const Metadata *MD) {
return MD->getMetadataID() == DILexicalBlockKind;
}
};
class DILexicalBlockFile : public DILexicalBlockBase {
friend class LLVMContextImpl;
friend class MDNode;
unsigned Discriminator;
DILexicalBlockFile(LLVMContext &C, StorageType Storage,
unsigned Discriminator, ArrayRef<Metadata *> Ops)
: DILexicalBlockBase(C, DILexicalBlockFileKind, Storage, Ops),
Discriminator(Discriminator) {}
~DILexicalBlockFile() = default;
static DILexicalBlockFile *getImpl(LLVMContext &Context, DILocalScope *Scope,
DIFile *File, unsigned Discriminator,
StorageType Storage,
bool ShouldCreate = true) {
return getImpl(Context, static_cast<Metadata *>(Scope),
static_cast<Metadata *>(File), Discriminator, Storage,
ShouldCreate);
}
static DILexicalBlockFile *getImpl(LLVMContext &Context, Metadata *Scope,
Metadata *File, unsigned Discriminator,
StorageType Storage,
bool ShouldCreate = true);
TempDILexicalBlockFile cloneImpl() const {
return getTemporary(getContext(), getScope(), getFile(),
getDiscriminator());
}
public:
DEFINE_MDNODE_GET(DILexicalBlockFile, (DILocalScope * Scope, DIFile *File,
unsigned Discriminator),
(Scope, File, Discriminator))
DEFINE_MDNODE_GET(DILexicalBlockFile,
(Metadata * Scope, Metadata *File, unsigned Discriminator),
(Scope, File, Discriminator))
TempDILexicalBlockFile clone() const { return cloneImpl(); }
// TODO: Remove these once they're gone from DILexicalBlockBase.
unsigned getLine() const = delete;
unsigned getColumn() const = delete;
unsigned getDiscriminator() const { return Discriminator; }
static bool classof(const Metadata *MD) {
return MD->getMetadataID() == DILexicalBlockFileKind;
}
};
unsigned DILocation::getDiscriminator() const {
if (auto *F = dyn_cast<DILexicalBlockFile>(getScope()))
return F->getDiscriminator();
return 0;
}
const DILocation *
DILocation::cloneWithDiscriminator(unsigned Discriminator) const {
DIScope *Scope = getScope();
// Skip all parent DILexicalBlockFile that already have a discriminator
// assigned. We do not want to have nested DILexicalBlockFiles that have
// mutliple discriminators because only the leaf DILexicalBlockFile's
// dominator will be used.
for (auto *LBF = dyn_cast<DILexicalBlockFile>(Scope);
LBF && LBF->getDiscriminator() != 0;
LBF = dyn_cast<DILexicalBlockFile>(Scope))
Scope = LBF->getScope();
DILexicalBlockFile *NewScope =
DILexicalBlockFile::get(getContext(), Scope, getFile(), Discriminator);
return DILocation::get(getContext(), getLine(), getColumn(), NewScope,
getInlinedAt());
}
unsigned DILocation::getBaseDiscriminator() const {
return getBaseDiscriminatorFromDiscriminator(getDiscriminator());
}
unsigned DILocation::getDuplicationFactor() const {
return getDuplicationFactorFromDiscriminator(getDiscriminator());
}
unsigned DILocation::getCopyIdentifier() const {
return getCopyIdentifierFromDiscriminator(getDiscriminator());
}
const DILocation *DILocation::setBaseDiscriminator(unsigned D) const {
if (D == 0)
return this;
else
return cloneWithDiscriminator(getPrefixEncodingFromUnsigned(D) << 1);
}
const DILocation *DILocation::cloneWithDuplicationFactor(unsigned DF) const {
DF *= getDuplicationFactor();
if (DF <= 1)
return this;
unsigned BD = getBaseDiscriminator();
unsigned CI = getCopyIdentifier() << (DF > 0x1f ? 14 : 7);
unsigned D = CI | (getPrefixEncodingFromUnsigned(DF) << 1);
if (BD == 0)
D = (D << 1) | 1;
else
D = (D << (BD > 0x1f ? 14 : 7)) | (getPrefixEncodingFromUnsigned(BD) << 1);
return cloneWithDiscriminator(D);
}
class DINamespace : public DIScope {
friend class LLVMContextImpl;
friend class MDNode;
unsigned ExportSymbols : 1;
DINamespace(LLVMContext &Context, StorageType Storage, bool ExportSymbols,
ArrayRef<Metadata *> Ops)
: DIScope(Context, DINamespaceKind, Storage, dwarf::DW_TAG_namespace,
Ops),
ExportSymbols(ExportSymbols) {}
~DINamespace() = default;
static DINamespace *getImpl(LLVMContext &Context, DIScope *Scope,
StringRef Name, bool ExportSymbols,
StorageType Storage, bool ShouldCreate = true) {
return getImpl(Context, Scope, getCanonicalMDString(Context, Name),
ExportSymbols, Storage, ShouldCreate);
}
static DINamespace *getImpl(LLVMContext &Context, Metadata *Scope,
MDString *Name, bool ExportSymbols,
StorageType Storage, bool ShouldCreate = true);
TempDINamespace cloneImpl() const {
return getTemporary(getContext(), getScope(), getName(),
getExportSymbols());
}
public:
DEFINE_MDNODE_GET(DINamespace,
(DIScope *Scope, StringRef Name, bool ExportSymbols),
(Scope, Name, ExportSymbols))
DEFINE_MDNODE_GET(DINamespace,
(Metadata *Scope, MDString *Name, bool ExportSymbols),
(Scope, Name, ExportSymbols))
TempDINamespace clone() const { return cloneImpl(); }
bool getExportSymbols() const { return ExportSymbols; }
DIScope *getScope() const { return cast_or_null<DIScope>(getRawScope()); }
StringRef getName() const { return getStringOperand(2); }
Metadata *getRawScope() const { return getOperand(1); }
MDString *getRawName() const { return getOperandAs<MDString>(2); }
static bool classof(const Metadata *MD) {
return MD->getMetadataID() == DINamespaceKind;
}
};
/// A (clang) module that has been imported by the compile unit.
///
class DIModule : public DIScope {
friend class LLVMContextImpl;
friend class MDNode;
DIModule(LLVMContext &Context, StorageType Storage, ArrayRef<Metadata *> Ops)
: DIScope(Context, DIModuleKind, Storage, dwarf::DW_TAG_module, Ops) {}
~DIModule() = default;
static DIModule *getImpl(LLVMContext &Context, DIScope *Scope,
StringRef Name, StringRef ConfigurationMacros,
StringRef IncludePath, StringRef ISysRoot,
StorageType Storage, bool ShouldCreate = true) {
return getImpl(Context, Scope, getCanonicalMDString(Context, Name),
getCanonicalMDString(Context, ConfigurationMacros),
getCanonicalMDString(Context, IncludePath),
getCanonicalMDString(Context, ISysRoot),
Storage, ShouldCreate);
}
static DIModule *getImpl(LLVMContext &Context, Metadata *Scope,
MDString *Name, MDString *ConfigurationMacros,
MDString *IncludePath, MDString *ISysRoot,
StorageType Storage, bool ShouldCreate = true);
TempDIModule cloneImpl() const {
return getTemporary(getContext(), getScope(), getName(),
getConfigurationMacros(), getIncludePath(),
getISysRoot());
}
public:
DEFINE_MDNODE_GET(DIModule, (DIScope *Scope, StringRef Name,
StringRef ConfigurationMacros, StringRef IncludePath,
StringRef ISysRoot),
(Scope, Name, ConfigurationMacros, IncludePath, ISysRoot))
DEFINE_MDNODE_GET(DIModule,
(Metadata *Scope, MDString *Name, MDString *ConfigurationMacros,
MDString *IncludePath, MDString *ISysRoot),
(Scope, Name, ConfigurationMacros, IncludePath, ISysRoot))
TempDIModule clone() const { return cloneImpl(); }
DIScope *getScope() const { return cast_or_null<DIScope>(getRawScope()); }
StringRef getName() const { return getStringOperand(1); }
StringRef getConfigurationMacros() const { return getStringOperand(2); }
StringRef getIncludePath() const { return getStringOperand(3); }
StringRef getISysRoot() const { return getStringOperand(4); }
Metadata *getRawScope() const { return getOperand(0); }
MDString *getRawName() const { return getOperandAs<MDString>(1); }
MDString *getRawConfigurationMacros() const { return getOperandAs<MDString>(2); }
MDString *getRawIncludePath() const { return getOperandAs<MDString>(3); }
MDString *getRawISysRoot() const { return getOperandAs<MDString>(4); }
static bool classof(const Metadata *MD) {
return MD->getMetadataID() == DIModuleKind;
}
};
/// Base class for template parameters.
class DITemplateParameter : public DINode {
protected:
DITemplateParameter(LLVMContext &Context, unsigned ID, StorageType Storage,
unsigned Tag, ArrayRef<Metadata *> Ops)
: DINode(Context, ID, Storage, Tag, Ops) {}
~DITemplateParameter() = default;
public:
StringRef getName() const { return getStringOperand(0); }
DITypeRef getType() const { return DITypeRef(getRawType()); }
MDString *getRawName() const { return getOperandAs<MDString>(0); }
Metadata *getRawType() const { return getOperand(1); }
static bool classof(const Metadata *MD) {
return MD->getMetadataID() == DITemplateTypeParameterKind ||
MD->getMetadataID() == DITemplateValueParameterKind;
}
};
class DITemplateTypeParameter : public DITemplateParameter {
friend class LLVMContextImpl;
friend class MDNode;
DITemplateTypeParameter(LLVMContext &Context, StorageType Storage,
ArrayRef<Metadata *> Ops)
: DITemplateParameter(Context, DITemplateTypeParameterKind, Storage,
dwarf::DW_TAG_template_type_parameter, Ops) {}
~DITemplateTypeParameter() = default;
static DITemplateTypeParameter *getImpl(LLVMContext &Context, StringRef Name,
DITypeRef Type, StorageType Storage,
bool ShouldCreate = true) {
return getImpl(Context, getCanonicalMDString(Context, Name), Type, Storage,
ShouldCreate);
}
static DITemplateTypeParameter *getImpl(LLVMContext &Context, MDString *Name,
Metadata *Type, StorageType Storage,
bool ShouldCreate = true);
TempDITemplateTypeParameter cloneImpl() const {
return getTemporary(getContext(), getName(), getType());
}
public:
DEFINE_MDNODE_GET(DITemplateTypeParameter, (StringRef Name, DITypeRef Type),
(Name, Type))
DEFINE_MDNODE_GET(DITemplateTypeParameter, (MDString * Name, Metadata *Type),
(Name, Type))
TempDITemplateTypeParameter clone() const { return cloneImpl(); }
static bool classof(const Metadata *MD) {
return MD->getMetadataID() == DITemplateTypeParameterKind;
}
};
class DITemplateValueParameter : public DITemplateParameter {
friend class LLVMContextImpl;
friend class MDNode;
DITemplateValueParameter(LLVMContext &Context, StorageType Storage,
unsigned Tag, ArrayRef<Metadata *> Ops)
: DITemplateParameter(Context, DITemplateValueParameterKind, Storage, Tag,
Ops) {}
~DITemplateValueParameter() = default;
static DITemplateValueParameter *getImpl(LLVMContext &Context, unsigned Tag,
StringRef Name, DITypeRef Type,
Metadata *Value, StorageType Storage,
bool ShouldCreate = true) {
return getImpl(Context, Tag, getCanonicalMDString(Context, Name), Type,
Value, Storage, ShouldCreate);
}
static DITemplateValueParameter *getImpl(LLVMContext &Context, unsigned Tag,
MDString *Name, Metadata *Type,
Metadata *Value, StorageType Storage,
bool ShouldCreate = true);
TempDITemplateValueParameter cloneImpl() const {
return getTemporary(getContext(), getTag(), getName(), getType(),
getValue());
}
public:
DEFINE_MDNODE_GET(DITemplateValueParameter, (unsigned Tag, StringRef Name,
DITypeRef Type, Metadata *Value),
(Tag, Name, Type, Value))
DEFINE_MDNODE_GET(DITemplateValueParameter, (unsigned Tag, MDString *Name,
Metadata *Type, Metadata *Value),
(Tag, Name, Type, Value))
TempDITemplateValueParameter clone() const { return cloneImpl(); }
Metadata *getValue() const { return getOperand(2); }
static bool classof(const Metadata *MD) {
return MD->getMetadataID() == DITemplateValueParameterKind;
}
};
/// Base class for variables.
class DIVariable : public DINode {
unsigned Line;
uint32_t AlignInBits;
protected:
DIVariable(LLVMContext &C, unsigned ID, StorageType Storage, unsigned Line,
ArrayRef<Metadata *> Ops, uint32_t AlignInBits = 0)
: DINode(C, ID, Storage, dwarf::DW_TAG_variable, Ops), Line(Line),
AlignInBits(AlignInBits) {}
~DIVariable() = default;
public:
unsigned getLine() const { return Line; }
DIScope *getScope() const { return cast_or_null<DIScope>(getRawScope()); }
StringRef getName() const { return getStringOperand(1); }
DIFile *getFile() const { return cast_or_null<DIFile>(getRawFile()); }
DITypeRef getType() const { return DITypeRef(getRawType()); }
uint32_t getAlignInBits() const { return AlignInBits; }
uint32_t getAlignInBytes() const { return getAlignInBits() / CHAR_BIT; }
/// Determines the size of the variable's type.
Optional<uint64_t> getSizeInBits() const;
StringRef getFilename() const {
if (auto *F = getFile())
return F->getFilename();
return "";
}
StringRef getDirectory() const {
if (auto *F = getFile())
return F->getDirectory();
return "";
}
Optional<StringRef> getSource() const {
if (auto *F = getFile())
return F->getSource();
return None;
}
Metadata *getRawScope() const { return getOperand(0); }
MDString *getRawName() const { return getOperandAs<MDString>(1); }
Metadata *getRawFile() const { return getOperand(2); }
Metadata *getRawType() const { return getOperand(3); }
static bool classof(const Metadata *MD) {
return MD->getMetadataID() == DILocalVariableKind ||
MD->getMetadataID() == DIGlobalVariableKind;
}
};
/// DWARF expression.
///
/// This is (almost) a DWARF expression that modifies the location of a
/// variable, or the location of a single piece of a variable, or (when using
/// DW_OP_stack_value) is the constant variable value.
///
/// TODO: Co-allocate the expression elements.
/// TODO: Separate from MDNode, or otherwise drop Distinct and Temporary
/// storage types.
class DIExpression : public MDNode {
friend class LLVMContextImpl;
friend class MDNode;
std::vector<uint64_t> Elements;
DIExpression(LLVMContext &C, StorageType Storage, ArrayRef<uint64_t> Elements)
: MDNode(C, DIExpressionKind, Storage, None),
Elements(Elements.begin(), Elements.end()) {}
~DIExpression() = default;
static DIExpression *getImpl(LLVMContext &Context,
ArrayRef<uint64_t> Elements, StorageType Storage,
bool ShouldCreate = true);
TempDIExpression cloneImpl() const {
return getTemporary(getContext(), getElements());
}
public:
DEFINE_MDNODE_GET(DIExpression, (ArrayRef<uint64_t> Elements), (Elements))
TempDIExpression clone() const { return cloneImpl(); }
ArrayRef<uint64_t> getElements() const { return Elements; }
unsigned getNumElements() const { return Elements.size(); }
uint64_t getElement(unsigned I) const {
assert(I < Elements.size() && "Index out of range");
return Elements[I];
}
/// Determine whether this represents a standalone constant value.
bool isConstant() const;
using element_iterator = ArrayRef<uint64_t>::iterator;
element_iterator elements_begin() const { return getElements().begin(); }
element_iterator elements_end() const { return getElements().end(); }
/// A lightweight wrapper around an expression operand.
///
/// TODO: Store arguments directly and change \a DIExpression to store a
/// range of these.
class ExprOperand {
const uint64_t *Op = nullptr;
public:
ExprOperand() = default;
explicit ExprOperand(const uint64_t *Op) : Op(Op) {}
const uint64_t *get() const { return Op; }
/// Get the operand code.
uint64_t getOp() const { return *Op; }
/// Get an argument to the operand.
///
/// Never returns the operand itself.
uint64_t getArg(unsigned I) const { return Op[I + 1]; }
unsigned getNumArgs() const { return getSize() - 1; }
/// Return the size of the operand.
///
/// Return the number of elements in the operand (1 + args).
unsigned getSize() const;
};
/// An iterator for expression operands.
class expr_op_iterator
: public std::iterator<std::input_iterator_tag, ExprOperand> {
ExprOperand Op;
public:
expr_op_iterator() = default;
explicit expr_op_iterator(element_iterator I) : Op(I) {}
element_iterator getBase() const { return Op.get(); }
const ExprOperand &operator*() const { return Op; }
const ExprOperand *operator->() const { return &Op; }
expr_op_iterator &operator++() {
increment();
return *this;
}
expr_op_iterator operator++(int) {
expr_op_iterator T(*this);
increment();
return T;
}
/// Get the next iterator.
///
/// \a std::next() doesn't work because this is technically an
/// input_iterator, but it's a perfectly valid operation. This is an
/// accessor to provide the same functionality.
expr_op_iterator getNext() const { return ++expr_op_iterator(*this); }
bool operator==(const expr_op_iterator &X) const {
return getBase() == X.getBase();
}
bool operator!=(const expr_op_iterator &X) const {
return getBase() != X.getBase();
}
private:
void increment() { Op = ExprOperand(getBase() + Op.getSize()); }
};
/// Visit the elements via ExprOperand wrappers.
///
/// These range iterators visit elements through \a ExprOperand wrappers.
/// This is not guaranteed to be a valid range unless \a isValid() gives \c
/// true.
///
/// \pre \a isValid() gives \c true.
/// @{
expr_op_iterator expr_op_begin() const {
return expr_op_iterator(elements_begin());
}
expr_op_iterator expr_op_end() const {
return expr_op_iterator(elements_end());
}
iterator_range<expr_op_iterator> expr_ops() const {
return {expr_op_begin(), expr_op_end()};
}
/// @}
bool isValid() const;
static bool classof(const Metadata *MD) {
return MD->getMetadataID() == DIExpressionKind;
}
/// Return whether the first element a DW_OP_deref.
bool startsWithDeref() const {
return getNumElements() > 0 && getElement(0) == dwarf::DW_OP_deref;
}
/// Holds the characteristics of one fragment of a larger variable.
struct FragmentInfo {
uint64_t SizeInBits;
uint64_t OffsetInBits;
};
/// Retrieve the details of this fragment expression.
static Optional<FragmentInfo> getFragmentInfo(expr_op_iterator Start,
expr_op_iterator End);
/// Retrieve the details of this fragment expression.
Optional<FragmentInfo> getFragmentInfo() const {
return getFragmentInfo(expr_op_begin(), expr_op_end());
}
/// Return whether this is a piece of an aggregate variable.
bool isFragment() const { return getFragmentInfo().hasValue(); }
/// Append \p Ops with operations to apply the \p Offset.
static void appendOffset(SmallVectorImpl<uint64_t> &Ops, int64_t Offset);
/// If this is a constant offset, extract it. If there is no expression,
/// return true with an offset of zero.
bool extractIfOffset(int64_t &Offset) const;
/// Constants for DIExpression::prepend.
enum { NoDeref = false, WithDeref = true, WithStackValue = true };
/// Prepend \p DIExpr with a deref and offset operation and optionally turn it
/// into a stack value.
static DIExpression *prepend(const DIExpression *DIExpr, bool DerefBefore,
int64_t Offset = 0, bool DerefAfter = false,
bool StackValue = false);
/// Prepend \p DIExpr with the given opcodes and optionally turn it into a
/// stack value.
static DIExpression *doPrepend(const DIExpression *DIExpr,
SmallVectorImpl<uint64_t> &Ops,
bool StackValue = false);
/// Create a DIExpression to describe one part of an aggregate variable that
/// is fragmented across multiple Values. The DW_OP_LLVM_fragment operation
/// will be appended to the elements of \c Expr. If \c Expr already contains
/// a \c DW_OP_LLVM_fragment \c OffsetInBits is interpreted as an offset
/// into the existing fragment.
///
/// \param OffsetInBits Offset of the piece in bits.
/// \param SizeInBits Size of the piece in bits.
/// \return Creating a fragment expression may fail if \c Expr
/// contains arithmetic operations that would be truncated.
static Optional<DIExpression *>
createFragmentExpression(const DIExpression *Expr, unsigned OffsetInBits,
unsigned SizeInBits);
};
/// Global variables.
///
/// TODO: Remove DisplayName. It's always equal to Name.
class DIGlobalVariable : public DIVariable {
friend class LLVMContextImpl;
friend class MDNode;
bool IsLocalToUnit;
bool IsDefinition;
DIGlobalVariable(LLVMContext &C, StorageType Storage, unsigned Line,
bool IsLocalToUnit, bool IsDefinition, uint32_t AlignInBits,
ArrayRef<Metadata *> Ops)
: DIVariable(C, DIGlobalVariableKind, Storage, Line, Ops, AlignInBits),
IsLocalToUnit(IsLocalToUnit), IsDefinition(IsDefinition) {}
~DIGlobalVariable() = default;
static DIGlobalVariable *getImpl(LLVMContext &Context, DIScope *Scope,
StringRef Name, StringRef LinkageName,
DIFile *File, unsigned Line, DITypeRef Type,
bool IsLocalToUnit, bool IsDefinition,
DIDerivedType *StaticDataMemberDeclaration,
uint32_t AlignInBits, StorageType Storage,
bool ShouldCreate = true) {
return getImpl(Context, Scope, getCanonicalMDString(Context, Name),
getCanonicalMDString(Context, LinkageName), File, Line, Type,
IsLocalToUnit, IsDefinition, StaticDataMemberDeclaration,
AlignInBits, Storage, ShouldCreate);
}
static DIGlobalVariable *
getImpl(LLVMContext &Context, Metadata *Scope, MDString *Name,
MDString *LinkageName, Metadata *File, unsigned Line, Metadata *Type,
bool IsLocalToUnit, bool IsDefinition,
Metadata *StaticDataMemberDeclaration, uint32_t AlignInBits,
StorageType Storage, bool ShouldCreate = true);
TempDIGlobalVariable cloneImpl() const {
return getTemporary(getContext(), getScope(), getName(), getLinkageName(),
getFile(), getLine(), getType(), isLocalToUnit(),
isDefinition(), getStaticDataMemberDeclaration(),
getAlignInBits());
}
public:
DEFINE_MDNODE_GET(DIGlobalVariable,
(DIScope * Scope, StringRef Name, StringRef LinkageName,
DIFile *File, unsigned Line, DITypeRef Type,
bool IsLocalToUnit, bool IsDefinition,
DIDerivedType *StaticDataMemberDeclaration,
uint32_t AlignInBits),
(Scope, Name, LinkageName, File, Line, Type, IsLocalToUnit,
IsDefinition, StaticDataMemberDeclaration, AlignInBits))
DEFINE_MDNODE_GET(DIGlobalVariable,
(Metadata * Scope, MDString *Name, MDString *LinkageName,
Metadata *File, unsigned Line, Metadata *Type,
bool IsLocalToUnit, bool IsDefinition,
Metadata *StaticDataMemberDeclaration,
uint32_t AlignInBits),
(Scope, Name, LinkageName, File, Line, Type, IsLocalToUnit,
IsDefinition, StaticDataMemberDeclaration, AlignInBits))
TempDIGlobalVariable clone() const { return cloneImpl(); }
bool isLocalToUnit() const { return IsLocalToUnit; }
bool isDefinition() const { return IsDefinition; }
StringRef getDisplayName() const { return getStringOperand(4); }
StringRef getLinkageName() const { return getStringOperand(5); }
DIDerivedType *getStaticDataMemberDeclaration() const {
return cast_or_null<DIDerivedType>(getRawStaticDataMemberDeclaration());
}
MDString *getRawLinkageName() const { return getOperandAs<MDString>(5); }
Metadata *getRawStaticDataMemberDeclaration() const { return getOperand(6); }
static bool classof(const Metadata *MD) {
return MD->getMetadataID() == DIGlobalVariableKind;
}
};
/// Local variable.
///
/// TODO: Split up flags.
class DILocalVariable : public DIVariable {
friend class LLVMContextImpl;
friend class MDNode;
unsigned Arg : 16;
DIFlags Flags;
DILocalVariable(LLVMContext &C, StorageType Storage, unsigned Line,
unsigned Arg, DIFlags Flags, uint32_t AlignInBits,
ArrayRef<Metadata *> Ops)
: DIVariable(C, DILocalVariableKind, Storage, Line, Ops, AlignInBits),
Arg(Arg), Flags(Flags) {
assert(Arg < (1 << 16) && "DILocalVariable: Arg out of range");
}
~DILocalVariable() = default;
static DILocalVariable *getImpl(LLVMContext &Context, DIScope *Scope,
StringRef Name, DIFile *File, unsigned Line,
DITypeRef Type, unsigned Arg, DIFlags Flags,
uint32_t AlignInBits, StorageType Storage,
bool ShouldCreate = true) {
return getImpl(Context, Scope, getCanonicalMDString(Context, Name), File,
Line, Type, Arg, Flags, AlignInBits, Storage, ShouldCreate);
}
static DILocalVariable *getImpl(LLVMContext &Context, Metadata *Scope,
MDString *Name, Metadata *File, unsigned Line,
Metadata *Type, unsigned Arg, DIFlags Flags,
uint32_t AlignInBits, StorageType Storage,
bool ShouldCreate = true);
TempDILocalVariable cloneImpl() const {
return getTemporary(getContext(), getScope(), getName(), getFile(),
getLine(), getType(), getArg(), getFlags(),
getAlignInBits());
}
public:
DEFINE_MDNODE_GET(DILocalVariable,
(DILocalScope * Scope, StringRef Name, DIFile *File,
unsigned Line, DITypeRef Type, unsigned Arg,
DIFlags Flags, uint32_t AlignInBits),
(Scope, Name, File, Line, Type, Arg, Flags, AlignInBits))
DEFINE_MDNODE_GET(DILocalVariable,
(Metadata * Scope, MDString *Name, Metadata *File,
unsigned Line, Metadata *Type, unsigned Arg,
DIFlags Flags, uint32_t AlignInBits),
(Scope, Name, File, Line, Type, Arg, Flags, AlignInBits))
TempDILocalVariable clone() const { return cloneImpl(); }
/// Get the local scope for this variable.
///
/// Variables must be defined in a local scope.
DILocalScope *getScope() const {
return cast<DILocalScope>(DIVariable::getScope());
}
bool isParameter() const { return Arg; }
unsigned getArg() const { return Arg; }
DIFlags getFlags() const { return Flags; }
bool isArtificial() const { return getFlags() & FlagArtificial; }
bool isObjectPointer() const { return getFlags() & FlagObjectPointer; }
/// Check that a location is valid for this variable.
///
/// Check that \c DL exists, is in the same subprogram, and has the same
/// inlined-at location as \c this. (Otherwise, it's not a valid attachment
/// to a \a DbgInfoIntrinsic.)
bool isValidLocationForIntrinsic(const DILocation *DL) const {
return DL && getScope()->getSubprogram() == DL->getScope()->getSubprogram();
}
static bool classof(const Metadata *MD) {
return MD->getMetadataID() == DILocalVariableKind;
}
};
class DIObjCProperty : public DINode {
friend class LLVMContextImpl;
friend class MDNode;
unsigned Line;
unsigned Attributes;
DIObjCProperty(LLVMContext &C, StorageType Storage, unsigned Line,
unsigned Attributes, ArrayRef<Metadata *> Ops)
: DINode(C, DIObjCPropertyKind, Storage, dwarf::DW_TAG_APPLE_property,
Ops),
Line(Line), Attributes(Attributes) {}
~DIObjCProperty() = default;
static DIObjCProperty *
getImpl(LLVMContext &Context, StringRef Name, DIFile *File, unsigned Line,
StringRef GetterName, StringRef SetterName, unsigned Attributes,
DITypeRef Type, StorageType Storage, bool ShouldCreate = true) {
return getImpl(Context, getCanonicalMDString(Context, Name), File, Line,
getCanonicalMDString(Context, GetterName),
getCanonicalMDString(Context, SetterName), Attributes, Type,
Storage, ShouldCreate);
}
static DIObjCProperty *getImpl(LLVMContext &Context, MDString *Name,
Metadata *File, unsigned Line,
MDString *GetterName, MDString *SetterName,
unsigned Attributes, Metadata *Type,
StorageType Storage, bool ShouldCreate = true);
TempDIObjCProperty cloneImpl() const {
return getTemporary(getContext(), getName(), getFile(), getLine(),
getGetterName(), getSetterName(), getAttributes(),
getType());
}
public:
DEFINE_MDNODE_GET(DIObjCProperty,
(StringRef Name, DIFile *File, unsigned Line,
StringRef GetterName, StringRef SetterName,
unsigned Attributes, DITypeRef Type),
(Name, File, Line, GetterName, SetterName, Attributes,
Type))
DEFINE_MDNODE_GET(DIObjCProperty,
(MDString * Name, Metadata *File, unsigned Line,
MDString *GetterName, MDString *SetterName,
unsigned Attributes, Metadata *Type),
(Name, File, Line, GetterName, SetterName, Attributes,
Type))
TempDIObjCProperty clone() const { return cloneImpl(); }
unsigned getLine() const { return Line; }
unsigned getAttributes() const { return Attributes; }
StringRef getName() const { return getStringOperand(0); }
DIFile *getFile() const { return cast_or_null<DIFile>(getRawFile()); }
StringRef getGetterName() const { return getStringOperand(2); }
StringRef getSetterName() const { return getStringOperand(3); }
DITypeRef getType() const { return DITypeRef(getRawType()); }
StringRef getFilename() const {
if (auto *F = getFile())
return F->getFilename();
return "";
}
StringRef getDirectory() const {
if (auto *F = getFile())
return F->getDirectory();
return "";
}
Optional<StringRef> getSource() const {
if (auto *F = getFile())
return F->getSource();
return None;
}
MDString *getRawName() const { return getOperandAs<MDString>(0); }
Metadata *getRawFile() const { return getOperand(1); }
MDString *getRawGetterName() const { return getOperandAs<MDString>(2); }
MDString *getRawSetterName() const { return getOperandAs<MDString>(3); }
Metadata *getRawType() const { return getOperand(4); }
static bool classof(const Metadata *MD) {
return MD->getMetadataID() == DIObjCPropertyKind;
}
};
/// An imported module (C++ using directive or similar).
class DIImportedEntity : public DINode {
friend class LLVMContextImpl;
friend class MDNode;
unsigned Line;
DIImportedEntity(LLVMContext &C, StorageType Storage, unsigned Tag,
unsigned Line, ArrayRef<Metadata *> Ops)
: DINode(C, DIImportedEntityKind, Storage, Tag, Ops), Line(Line) {}
~DIImportedEntity() = default;
static DIImportedEntity *getImpl(LLVMContext &Context, unsigned Tag,
DIScope *Scope, DINodeRef Entity,
DIFile *File, unsigned Line, StringRef Name,
StorageType Storage,
bool ShouldCreate = true) {
return getImpl(Context, Tag, Scope, Entity, File, Line,
getCanonicalMDString(Context, Name), Storage, ShouldCreate);
}
static DIImportedEntity *getImpl(LLVMContext &Context, unsigned Tag,
Metadata *Scope, Metadata *Entity,
Metadata *File, unsigned Line,
MDString *Name, StorageType Storage,
bool ShouldCreate = true);
TempDIImportedEntity cloneImpl() const {
return getTemporary(getContext(), getTag(), getScope(), getEntity(),
getFile(), getLine(), getName());
}
public:
DEFINE_MDNODE_GET(DIImportedEntity,
(unsigned Tag, DIScope *Scope, DINodeRef Entity,
DIFile *File, unsigned Line, StringRef Name = ""),
(Tag, Scope, Entity, File, Line, Name))
DEFINE_MDNODE_GET(DIImportedEntity,
(unsigned Tag, Metadata *Scope, Metadata *Entity,
Metadata *File, unsigned Line, MDString *Name),
(Tag, Scope, Entity, File, Line, Name))
TempDIImportedEntity clone() const { return cloneImpl(); }
unsigned getLine() const { return Line; }
DIScope *getScope() const { return cast_or_null<DIScope>(getRawScope()); }
DINodeRef getEntity() const { return DINodeRef(getRawEntity()); }
StringRef getName() const { return getStringOperand(2); }
DIFile *getFile() const { return cast_or_null<DIFile>(getRawFile()); }
Metadata *getRawScope() const { return getOperand(0); }
Metadata *getRawEntity() const { return getOperand(1); }
MDString *getRawName() const { return getOperandAs<MDString>(2); }
Metadata *getRawFile() const { return getOperand(3); }
static bool classof(const Metadata *MD) {
return MD->getMetadataID() == DIImportedEntityKind;
}
};
/// A pair of DIGlobalVariable and DIExpression.
class DIGlobalVariableExpression : public MDNode {
friend class LLVMContextImpl;
friend class MDNode;
DIGlobalVariableExpression(LLVMContext &C, StorageType Storage,
ArrayRef<Metadata *> Ops)
: MDNode(C, DIGlobalVariableExpressionKind, Storage, Ops) {}
~DIGlobalVariableExpression() = default;
static DIGlobalVariableExpression *
getImpl(LLVMContext &Context, Metadata *Variable, Metadata *Expression,
StorageType Storage, bool ShouldCreate = true);
TempDIGlobalVariableExpression cloneImpl() const {
return getTemporary(getContext(), getVariable(), getExpression());
}
public:
DEFINE_MDNODE_GET(DIGlobalVariableExpression,
(Metadata * Variable, Metadata *Expression),
(Variable, Expression))
TempDIGlobalVariableExpression clone() const { return cloneImpl(); }
Metadata *getRawVariable() const { return getOperand(0); }
DIGlobalVariable *getVariable() const {
return cast_or_null<DIGlobalVariable>(getRawVariable());
}
Metadata *getRawExpression() const { return getOperand(1); }
DIExpression *getExpression() const {
return cast<DIExpression>(getRawExpression());
}
static bool classof(const Metadata *MD) {
return MD->getMetadataID() == DIGlobalVariableExpressionKind;
}
};
/// Macro Info DWARF-like metadata node.
///
/// A metadata node with a DWARF macro info (i.e., a constant named
/// \c DW_MACINFO_*, defined in llvm/BinaryFormat/Dwarf.h). Called \a
/// DIMacroNode
/// because it's potentially used for non-DWARF output.
class DIMacroNode : public MDNode {
friend class LLVMContextImpl;
friend class MDNode;
protected:
DIMacroNode(LLVMContext &C, unsigned ID, StorageType Storage, unsigned MIType,
ArrayRef<Metadata *> Ops1, ArrayRef<Metadata *> Ops2 = None)
: MDNode(C, ID, Storage, Ops1, Ops2) {
assert(MIType < 1u << 16);
SubclassData16 = MIType;
}
~DIMacroNode() = default;
template <class Ty> Ty *getOperandAs(unsigned I) const {
return cast_or_null<Ty>(getOperand(I));
}
StringRef getStringOperand(unsigned I) const {
if (auto *S = getOperandAs<MDString>(I))
return S->getString();
return StringRef();
}
static MDString *getCanonicalMDString(LLVMContext &Context, StringRef S) {
if (S.empty())
return nullptr;
return MDString::get(Context, S);
}
public:
unsigned getMacinfoType() const { return SubclassData16; }
static bool classof(const Metadata *MD) {
switch (MD->getMetadataID()) {
default:
return false;
case DIMacroKind:
case DIMacroFileKind:
return true;
}
}
};
class DIMacro : public DIMacroNode {
friend class LLVMContextImpl;
friend class MDNode;
unsigned Line;
DIMacro(LLVMContext &C, StorageType Storage, unsigned MIType, unsigned Line,
ArrayRef<Metadata *> Ops)
: DIMacroNode(C, DIMacroKind, Storage, MIType, Ops), Line(Line) {}
~DIMacro() = default;
static DIMacro *getImpl(LLVMContext &Context, unsigned MIType, unsigned Line,
StringRef Name, StringRef Value, StorageType Storage,
bool ShouldCreate = true) {
return getImpl(Context, MIType, Line, getCanonicalMDString(Context, Name),
getCanonicalMDString(Context, Value), Storage, ShouldCreate);
}
static DIMacro *getImpl(LLVMContext &Context, unsigned MIType, unsigned Line,
MDString *Name, MDString *Value, StorageType Storage,
bool ShouldCreate = true);
TempDIMacro cloneImpl() const {
return getTemporary(getContext(), getMacinfoType(), getLine(), getName(),
getValue());
}
public:
DEFINE_MDNODE_GET(DIMacro, (unsigned MIType, unsigned Line, StringRef Name,
StringRef Value = ""),
(MIType, Line, Name, Value))
DEFINE_MDNODE_GET(DIMacro, (unsigned MIType, unsigned Line, MDString *Name,
MDString *Value),
(MIType, Line, Name, Value))
TempDIMacro clone() const { return cloneImpl(); }
unsigned getLine() const { return Line; }
StringRef getName() const { return getStringOperand(0); }
StringRef getValue() const { return getStringOperand(1); }
MDString *getRawName() const { return getOperandAs<MDString>(0); }
MDString *getRawValue() const { return getOperandAs<MDString>(1); }
static bool classof(const Metadata *MD) {
return MD->getMetadataID() == DIMacroKind;
}
};
class DIMacroFile : public DIMacroNode {
friend class LLVMContextImpl;
friend class MDNode;
unsigned Line;
DIMacroFile(LLVMContext &C, StorageType Storage, unsigned MIType,
unsigned Line, ArrayRef<Metadata *> Ops)
: DIMacroNode(C, DIMacroFileKind, Storage, MIType, Ops), Line(Line) {}
~DIMacroFile() = default;
static DIMacroFile *getImpl(LLVMContext &Context, unsigned MIType,
unsigned Line, DIFile *File,
DIMacroNodeArray Elements, StorageType Storage,
bool ShouldCreate = true) {
return getImpl(Context, MIType, Line, static_cast<Metadata *>(File),
Elements.get(), Storage, ShouldCreate);
}
static DIMacroFile *getImpl(LLVMContext &Context, unsigned MIType,
unsigned Line, Metadata *File, Metadata *Elements,
StorageType Storage, bool ShouldCreate = true);
TempDIMacroFile cloneImpl() const {
return getTemporary(getContext(), getMacinfoType(), getLine(), getFile(),
getElements());
}
public:
DEFINE_MDNODE_GET(DIMacroFile, (unsigned MIType, unsigned Line, DIFile *File,
DIMacroNodeArray Elements),
(MIType, Line, File, Elements))
DEFINE_MDNODE_GET(DIMacroFile, (unsigned MIType, unsigned Line,
Metadata *File, Metadata *Elements),
(MIType, Line, File, Elements))
TempDIMacroFile clone() const { return cloneImpl(); }
void replaceElements(DIMacroNodeArray Elements) {
#ifndef NDEBUG
for (DIMacroNode *Op : getElements())
assert(is_contained(Elements->operands(), Op) &&
"Lost a macro node during macro node list replacement");
#endif
replaceOperandWith(1, Elements.get());
}
unsigned getLine() const { return Line; }
DIFile *getFile() const { return cast_or_null<DIFile>(getRawFile()); }
DIMacroNodeArray getElements() const {
return cast_or_null<MDTuple>(getRawElements());
}
Metadata *getRawFile() const { return getOperand(0); }
Metadata *getRawElements() const { return getOperand(1); }
static bool classof(const Metadata *MD) {
return MD->getMetadataID() == DIMacroFileKind;
}
};
} // end namespace llvm
#undef DEFINE_MDNODE_GET_UNPACK_IMPL
#undef DEFINE_MDNODE_GET_UNPACK
#undef DEFINE_MDNODE_GET
#endif // LLVM_IR_DEBUGINFOMETADATA_H
| [
"chh@google.com"
] | chh@google.com |
a4f43d037df0645bbf685e3c16ab4425d2e58910 | 1431eafb0edf9c2cc3cda7d405dc6d3995226bc5 | /MyVC4/MyVC4Doc.h | 1aecd247b45cb973d8c0f91da193d075646990c5 | [] | no_license | ShulinLiu/MFCProgram | f50916208f62ebe370b409b147e1e5c11f4f0c3b | e0ec287bc4ef0eb88f3e81d45cb7c6c24dd2ca5c | refs/heads/master | 2021-06-16T18:37:57.243687 | 2017-05-11T08:28:13 | 2017-05-11T08:28:13 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,464 | h | // MyVC4Doc.h : interface of the CMyVC4Doc class
//
/////////////////////////////////////////////////////////////////////////////
#if !defined(AFX_MYVC4DOC_H__741124B0_7453_47EB_B530_B0DB3B0D179C__INCLUDED_)
#define AFX_MYVC4DOC_H__741124B0_7453_47EB_B530_B0DB3B0D179C__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
class CMyVC4Doc : public CDocument
{
protected: // create from serialization only
CMyVC4Doc();
DECLARE_DYNCREATE(CMyVC4Doc)
// Attributes
public:
// Operations
public:
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CMyVC4Doc)
public:
virtual BOOL OnNewDocument();
virtual void Serialize(CArchive& ar);
//}}AFX_VIRTUAL
// Implementation
public:
virtual ~CMyVC4Doc();
#ifdef _DEBUG
virtual void AssertValid() const;
virtual void Dump(CDumpContext& dc) const;
#endif
protected:
// Generated message map functions
protected:
//{{AFX_MSG(CMyVC4Doc)
// NOTE - the ClassWizard will add and remove member functions here.
// DO NOT EDIT what you see in these blocks of generated code !
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_MYVC4DOC_H__741124B0_7453_47EB_B530_B0DB3B0D179C__INCLUDED_)
| [
"shulin_liu@foxmail.com"
] | shulin_liu@foxmail.com |
1a8381090f855cac62af8543351bd34d299b21e4 | f06a170ddd029ab4537ad6634c8eb1bb65dff8e2 | /57_DeleteDuplication.cpp | 6ea9cce6bb00fa92350457120200a76078b163ee | [] | no_license | wenmingxing1/offer_code_for_github | 561be102f9f82d4058926734037aacbb2ceb2dd8 | 587ac26c17c8323cd73791ac08f9b181a04032af | refs/heads/master | 2021-01-22T09:47:12.595296 | 2018-04-19T08:14:49 | 2018-04-19T08:14:49 | 102,329,781 | 2 | 0 | null | null | null | null | GB18030 | C++ | false | false | 1,975 | cpp | /*
struct ListNode {
int val;
struct ListNode *next;
ListNode(int x) :
val(x), next(NULL) {
}
};
*/
class Solution {
public:
ListNode* deleteDuplication(ListNode* pHead)
{
if (pHead == NULL)
return NULL;
ListNode* pPre = NULL;
ListNode* pNode = pHead;
while (pNode != NULL){
ListNode* pNext = pNode->next;
bool del = false;
if (pNext != NULL && pNext->val == pNode->val)
del = true;
if (!del){ //不需要删除
pPre = pNode;
pNode = pNode->next;
}
else{ //需要删除
int value = pNode->val;
ListNode* pToBeDel = pNode;
while (pToBeDel != NULL && pToBeDel->val == value){
pNext = pToBeDel->next;
delete pToBeDel;
pToBeDel = NULL;
pToBeDel = pNext;
}
if(pPre == NULL)
pHead = pNext;
else
pPre->next = pNext;
pNode = pNext;
}
}
return pHead;
}
};
class Solution2 {
public:
ListNode* deleteDuplication(ListNode* pHead)
{
ListNode* first = new ListNode(-1); //设置一个起始位置,并初始化为负数
first->next = pHead;
ListNode* pNode = pHead;
ListNode* pre = first;
while (pNode != NULL && pNode->next != NULL){
if (pNode->val == pNode->next->val){
//跳过重复元素
int val = pNode->val;
while (pNode != NULL && val == pNode->val){
pNode = pNode->next;
}
pre->next = pNode;
}
else{
pre = pNode;
pNode = pNode->next;
}
}
return first->next;
}
};
| [
"1793701192@qq.com"
] | 1793701192@qq.com |
945c1df2fa5a632be1dcaef72b116c20a4a6ad16 | d655b54747775c2828bc70761d431e11bc8911d0 | /初级算法/二叉树的最大深度.cpp | 046df068ea491d6084b83624f227cabda45b8ae5 | [] | no_license | ChangWenWu/Leetcode | 1857e05ff406f9e15f8d0318ccdebc25b7b7574b | 9b2899e12ab1a791fdd0acd2e5d83ddcaddc4a53 | refs/heads/master | 2021-07-20T02:35:43.726269 | 2018-11-29T03:24:37 | 2018-11-29T03:24:37 | 141,366,124 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 357 | cpp | //
// 二叉树的最大深度.cpp
// Leetcode
//
// Created by jarvis on 2018/7/26.
//
#include <stdio.h>
//递归思想分解问题,计算一个节点的左子树和右子树的深度
class Solution {
public:
int maxDepth(TreeNode* root) {
if(!root) return 0;
return 1 + max(maxDepth(root->left),maxDepth(root->right));
}
};
| [
"wucw@fsmeeting.com"
] | wucw@fsmeeting.com |
292176e95b8247e1ea1bb278a22d842126c3ad59 | 057e2ef24d823f95784650ff3ec9c36b4de612c7 | /core/CScriptEng/stringObj.cpp | aae5b2183ccb05925d4dc8425d90a2e6200bca7f | [] | no_license | mz02005/CScript | 945a1f97f499977b336ea862b7a5dcda549b2fda | de0b7672cfc526be86443d96b5368c50f633d047 | refs/heads/master | 2020-04-16T02:15:16.616365 | 2017-11-01T02:56:59 | 2017-11-01T02:56:59 | 58,175,732 | 6 | 2 | null | null | null | null | GB18030 | C++ | false | false | 17,610 | cpp | #include "stdafx.h"
#include "vm.h"
#include <regex>
#include "arrayType.h"
#include "notstd/stringHelper.h"
#include "BufferObject.h"
namespace runtime {
///////////////////////////////////////////////////////////////////////////////
stringObject::stringObject()
: mVal(new std::string)
{
}
stringObject::~stringObject()
{
delete mVal;
}
uint32_t stringObject::GetObjectTypeId() const
{
return DT_string;
}
runtimeObjectBase* stringObject::Add(const runtimeObjectBase *obj)
{
if (mIsConst)
{
SCRIPT_TRACE_(scriptLog::LogTool::TraceException)("add on const variable");
return NULL;
}
runtimeObjectBase *r = NULL;
uint32_t typeId = obj->GetObjectTypeId();
if (typeId == DT_string)
{
stringObject *val = new ObjectModule<stringObject>;
*val->mVal = *mVal + *static_cast<const stringObject*>(obj)->mVal;
r = val;
}
else if (typeId == DT_null)
{
return this;
}
else
return NULL;
return r;
}
runtimeObjectBase* stringObject::Sub(const runtimeObjectBase *obj)
{
return NULL;
}
runtimeObjectBase* stringObject::Mul(const runtimeObjectBase *obj)
{
NullTypeObject *nullRet = NullTypeObject::CreateNullTypeObject();
if (mIsConst)
{
SCRIPT_TRACE_(scriptLog::LogTool::TraceException)("add on const variable");
return nullRet;
}
runtimeObjectBase *r = NULL;
if (isIntegerType(obj))
{
int32_t c = getObjectDataOrig<int32_t>(obj);
if (c > 0)
{
// 通过乘法运算,能够迅速的构造重复的字符串
stringObject *val = new ObjectModule<stringObject>;
int count = static_cast<const intObject*>(obj)->mVal;
for (int32_t i = 0; i < count; i++)
val->mVal->append(mVal->c_str(), mVal->size());
r = val;
delete nullRet;
return r;
}
}
SCRIPT_TRACE("string.*: string count must larger than 0.\n");
return nullRet;
}
runtimeObjectBase* stringObject::Div(const runtimeObjectBase *obj)
{
return NULL;
}
runtimeObjectBase* stringObject::SetValue(runtimeObjectBase *obj)
{
if (mIsConst)
{
SCRIPT_TRACE_(scriptLog::LogTool::TraceException)("add on const variable");
return NULL;
}
uint32_t typeId = obj->GetObjectTypeId();
if (typeId == DT_string)
{
*mVal = *static_cast<const stringObject*>(obj)->mVal;
return this;
}
return NULL;
}
stringObject* stringObject::CreateStringObject(const std::string &s)
{
auto r = new ObjectModule<stringObject>;
*r->mVal = s;
return r;
}
class String_formatObj : public runtime::baseObjDefault
{
friend class stringObject;
private:
stringObject *mStringObj;
struct StringFormatInfo {
// 是否是左对齐
uint32_t alignLeft : 1;
// 填充字符,缺省为' '
uint32_t fillChar : 8;
// 小数点位数
uint32_t prec : 7;
// 长度
uint32_t len : 8;
};
inline std::string GetFloatString(float v, StringFormatInfo *sfi)
{
std::string s, r;
// f
if (sfi->len)
notstd::StringHelper::Format(s, "%%%c%d.%df", (char)sfi->fillChar,
(int)sfi->len, (int)sfi->prec);
else
notstd::StringHelper::Format(s, "%%.%df", (int)sfi->prec);
return notstd::StringHelper::Format(r, s.c_str(), v);
}
inline void AppendString(const std::string &s, StringFormatInfo *sfi)
{
size_t ll = s.size();
if (sfi->alignLeft)
{
mStringObj->mVal->append(s);
if (ll < sfi->len)
{
int x = 0, tf = sfi->len - ll;
for (; x < tf; x++)
*mStringObj->mVal += sfi->fillChar;
}
}
else
{
if (ll < sfi->len)
{
int x = 0, tf = sfi->len - ll;
for (; x < tf; x++)
*mStringObj->mVal += sfi->fillChar;
}
mStringObj->mVal->append(s);
}
}
public:
String_formatObj()
: mStringObj(nullptr)
{
}
// 实现format函数
// 本format实现了一部分《Format Specification Syntax: printf and wprintf Functions》
// 规定的格式信息,所有和标准不符合的部分都以本函数的实际输出为准
virtual runtimeObjectBase* doCall(doCallContext *context)
{
runtime::NullTypeObject *nullRet = runtime::NullTypeObject::CreateNullTypeObject();
const char *p1;
union
{
const char *ss;
uint32_t u32Val;
};
if (context->GetParamCount() < 1
|| !(p1 = context->GetStringParam(0)))
{
SCRIPT_TRACE("string.format(formatString, ...\n");
return nullRet;
}
StringFormatInfo formatInfo;
enum FormatParseStage
{
FPS_FLAG,
FPS_WIDTH,
FPS_PRECISION,
//FPS_SIZE,
FPS_TYPE,
};
FormatParseStage parseStage;
//bool flagOK;
//bool widthOK;
//bool precisionOK;
uint32_t paramCount = 1;
mStringObj->mVal->clear();
for (; *p1 != 0; p1++)
{
switch (*p1)
{
case '%':
if (*++p1 == 0)
{
SCRIPT_TRACE("string.format: more information expected.\n");
return nullRet;
}
if (*p1 != '%' && context->GetParamCount() < ++paramCount)
{
SCRIPT_TRACE("string.format: parameter count out of range.\n");
return nullRet;
}
memset(&formatInfo, 0, sizeof(formatInfo));
formatInfo.fillChar = ' ';
parseStage = FPS_FLAG;
for (; *p1 != 0;)
{
if (parseStage <= FPS_FLAG)
{
if (*p1 == '-')
{
formatInfo.alignLeft = 1;
char c = *(p1 + 1);
if (c == ' ' || c == '0') {
formatInfo.fillChar = c;
p1 += 2;
}
else
p1++;
}
else if (*p1 == '+')
{
p1++;
}
else if (*p1 == '0')
{
formatInfo.fillChar = '0';
p1++;
}
}
if (parseStage <= FPS_WIDTH)
{
if (*p1 >= '1' && *p1 <= '9')
{
uint32_t width = *p1 - '0';
while (*++p1 && *p1 >= '0' && *p1 <= '9')
{
width *= 10;
width += *p1 - '0';
}
formatInfo.len = width;
parseStage = FPS_PRECISION;
}
else if (*p1 == '*')
{
if (context->GetParamCount() < ++paramCount)
{
SCRIPT_TRACE("string.format: more information expected.\n");
return nullRet;
}
try {
formatInfo.len = context->GetInt32Param(paramCount - 2);
}
catch (...)
{
SCRIPT_TRACE("string.format: integer parameter expected for item length.\n");
return nullRet;
}
p1++;
parseStage = FPS_PRECISION;
}
}
if (parseStage <= FPS_PRECISION)
{
if (*p1 == '.')
{
uint32_t prec = 0;
while (*++p1 && *p1 >= '0' && *p1 <= '9')
{
prec *= 10;
prec += *p1 - '0';
}
formatInfo.prec = prec;
parseStage = FPS_TYPE;
}
}
if (*p1 == '%')
{
*mStringObj->mVal += '%';
p1++;
break;
}
else if (*p1 == 'c')
{
runtimeObjectBase *o = context->GetParam(paramCount - 1);
uint32_t ot = o->GetObjectTypeId();
std::string v;
if (ot == DT_string)
{
v.append(static_cast<stringObject*>(o)->mVal->c_str(), 1);
}
else if (isIntegerType(o))
{
int iv = getObjectDataOrig<int>(o);
if (iv < 0)
{
SCRIPT_TRACE("string.format: %%c type switch must use integer parameter larger or equal to 0\n");
return nullRet;
}
v = std::to_string(iv);
}
else
{
SCRIPT_TRACE("string.format: %%c type switch muse use integer or string parameter.\n");
return nullRet;
}
AppendString(v, &formatInfo);
break;
}
else if (*p1 == 's')
{
if ((ss = context->GetStringParam(paramCount - 1)) == nullptr)
{
SCRIPT_TRACE("string.format: string parameter expected at position %u\n", paramCount - 1);
return nullRet;
}
AppendString(ss, &formatInfo);
break;
}
else if (*p1 == 'd')
{
try {
u32Val = context->GetInt32Param(paramCount - 1);
}
catch (...)
{
SCRIPT_TRACE("string.format: integer parameter expected at position %u\n", paramCount - 1);
return nullRet;
}
std::string v = std::to_string(u32Val);
AppendString(v, &formatInfo);
break;
}
else if (*p1 == 'f')
{
float f;
try {
f = context->GetFloatParam(paramCount - 1);
}
catch (...)
{
SCRIPT_TRACE("string.format: float parameter expected at position %u\n", paramCount - 1);
return nullRet;
}
std::string v = GetFloatString(f, &formatInfo);
AppendString(v, &formatInfo);
break;
}
else if (*p1 == 'X' || *p1 == 'x')
{
int v;
try
{
v = context->GetInt32Param(paramCount - 1);
}
catch (...)
{
SCRIPT_TRACE("string.format: integer parameter expected at position %u.\n", paramCount - 1);
return nullRet;
}
std::string ss;
notstd::StringHelper::Format(ss, *p1 == 'X' ? "%X" : "%x", v);
AppendString(ss, &formatInfo);
break;
}
else if (*p1 == 'u')
{
int v;
try
{
v = context->GetUint32Param(paramCount - 1);
}
catch (...)
{
SCRIPT_TRACE("string.format: unsigned integer parameter expected at position %u.\n", paramCount - 1);
return nullRet;
}
AppendString(notstd::StringHelper::Format("%u", v), &formatInfo);
break;
}
else
{
SCRIPT_TRACE("string.format: invalid format type %c\n", *p1);
return nullRet;
}
}
break;
default:
*mStringObj->mVal += *p1;
break;
}
}
delete nullRet;
return mStringObj;
}
};
class String_substrObj : public runtime::baseObjDefault
{
friend class stringObject;
private:
stringObject *mStringObj;
public:
String_substrObj()
: mStringObj(nullptr)
{
}
virtual runtimeObjectBase* doCall(runtime::doCallContext *context)
{
uint32_t c = context->GetParamCount();
if (c > 2 || c < 1)
{
SCRIPT_TRACE("string.substr(int,int)\n"
"string.substr(int)\n");
return this;
}
int32_t i = context->GetInt32Param(0);
std::string::size_type sc = -1;
if (c == 2)
sc = context->GetUint32Param(1);
stringObject *r = new runtime::ObjectModule<stringObject>;
*r->mVal = notstd::StringHelper::Mid(*mStringObj->mVal, i, sc);
return r;
}
};
class String_isMatchObj : public runtime::baseObjDefault
{
friend class stringObject;
private:
stringObject *mStringObj;
public:
String_isMatchObj()
: mStringObj(nullptr)
{
}
virtual runtimeObjectBase* doCall(doCallContext *context)
{
intObject *r = new ObjectModule<intObject>;
uint32_t c = context->GetParamCount();
if (c != 1)
return r;
const char *s = context->GetStringParam(0);
if (!s)
return r;
try {
std::regex sm(s);
r->mVal = std::regex_match(*mStringObj->mVal, sm);
}
catch (std::regex_error &e)
{
SCRIPT_TRACE("Invalid regex exp: %s(%s)\n", s, e.what());
}
return r;
}
};
class String_splitObj : public runtime::baseObjDefault
{
friend class stringObject;
private:
stringObject *mStringObj;
public:
String_splitObj()
: mStringObj(nullptr)
{
}
virtual runtimeObjectBase* doCall(doCallContext *context)
{
arrayObject *a = new ObjectModule<arrayObject>;
if (context->GetParamCount() != 1)
return a;
const char *s = context->GetStringParam(0);
if (!s)
return a;
notstd::StringHelper::StringArray sa = notstd::StringHelper::SplitString(*mStringObj->mVal, s);
for (auto iter = sa.begin(); iter != sa.end(); iter++)
{
stringObject *ss = new ObjectModule<stringObject>;
*ss->mVal = *iter;
a->AddSub(ss);
}
return a;
}
};
class StringCodecObj : public runtime::baseObjDefault
{
friend class stringObject;
private:
enum {
CC_NULL,
CC_MBCS2UNICODE,
CC_UNICODE2MBCS,
CC_UTF82UNICODE,
CC_UNICODE2UTF8,
} mConvType;
stringObject *mStringObj;
public:
StringCodecObj()
: mStringObj(nullptr)
, mConvType(CC_NULL)
{
}
virtual ~StringCodecObj()
{
if (mStringObj)
mStringObj->Release();
}
virtual runtimeObjectBase* doCall(doCallContext *context) override
{
do {
if (context->GetParamCount() != 0)
break;
std::string rr;
if (CC_MBCS2UNICODE == mConvType)
{
auto temp = notstd::ICONVext::mbcsToUnicode(*mStringObj->mVal);
rr.append(reinterpret_cast<const char*>(temp.c_str()), temp.size() * 2);
}
else if (CC_UNICODE2MBCS == mConvType)
{
std::wstring temp(reinterpret_cast<const wchar_t*>(mStringObj->mVal->c_str()), mStringObj->mVal->size() / 2);
rr = notstd::ICONVext::unicodeToMbcs(temp);
}
else if (CC_UTF82UNICODE == mConvType)
{
auto temp = notstd::ICONVext::utf8ToUnicode(*mStringObj->mVal);
rr.append(reinterpret_cast<const char*>(temp.c_str()), temp.size() * 2);
}
else if (CC_UNICODE2UTF8 == mConvType)
{
std::wstring temp(reinterpret_cast<const wchar_t*>(mStringObj->mVal->c_str()), mStringObj->mVal->size() / 2);
rr = notstd::ICONVext::unicodeToUtf8(temp);
}
else
break;
auto bo = new runtime::ObjectModule<BufferObject>;
bo->mBuffer = rr;
return bo;
} while (0);
return runtime::NullTypeObject::CreateNullTypeObject();
}
};
class String_replaceObj : public runtime::baseObjDefault
{
friend class stringObject;
private:
stringObject *mStringObj;
public:
String_replaceObj()
: mStringObj(nullptr)
{
}
virtual runtimeObjectBase* doCall(doCallContext *context)
{
if (context->GetParamCount() != 2)
return mStringObj;
const char *pat = context->GetStringParam(0);
const char *dest = context->GetStringParam(1);
if (!pat || !dest)
return mStringObj;
notstd::StringHelper::Replace(*mStringObj->mVal, pat, dest);
return mStringObj;
}
};
runtimeObjectBase* stringObject::GetMember(const char *memName)
{
if (!strcmp(memName, "len"))
{
uintObject *obj = baseTypeObject::CreateBaseTypeObject<uintObject>(false);
obj->mVal = static_cast<decltype(obj->mVal)>(mVal->size());
return obj;
}
else if (!strcmp(memName, "format"))
{
String_formatObj *o = new runtime::ContainModule<String_formatObj>(this);
o->mStringObj = this;
return o;
}
else if (!strcmp(memName, "substr"))
{
String_substrObj *o = new runtime::ContainModule<String_substrObj>(this);
o->mStringObj = this;
return o;
}
else if (!strcmp(memName, "split"))
{
String_splitObj *o = new ContainModule<String_splitObj>(this);
o->mStringObj = this;
return o;
}
else if (!strcmp(memName, "isMatch"))
{
String_isMatchObj *o = new ContainModule<String_isMatchObj>(this);
o->mStringObj = this;
return o;
}
else if (!strcmp(memName, "replace"))
{
String_replaceObj *o = new ContainModule<String_replaceObj>(this);
o->mStringObj = this;
return o;
}
else if (!strcmp(memName, "mbcs2unicode"))
{
auto sc = new ObjectModule<StringCodecObj>;
sc->mStringObj = this;
sc->mConvType = StringCodecObj::CC_MBCS2UNICODE;
AddRef();
return sc;
}
else if (!strcmp(memName, "unicode2mbcs"))
{
auto sc = new ObjectModule<StringCodecObj>;
sc->mStringObj = this;
sc->mConvType = StringCodecObj::CC_UNICODE2MBCS;
AddRef();
return sc;
}
else if (!strcmp(memName, "unicode2utf8"))
{
auto sc = new ObjectModule<StringCodecObj>;
sc->mStringObj = this;
sc->mConvType = StringCodecObj::CC_UNICODE2UTF8;
AddRef();
return sc;
}
else if (!strcmp(memName, "utf82unicode"))
{
auto sc = new ObjectModule<StringCodecObj>;
sc->mStringObj = this;
sc->mConvType = StringCodecObj::CC_UTF82UNICODE;
AddRef();
return sc;
}
return baseTypeObject::GetMember(memName);
}
runtimeObjectBase* stringObject::doCall(doCallContext *context)
{
return NULL;
}
runtimeObjectBase* stringObject::getIndex(int i)
{
std::string::size_type l = mVal->size();
if (i < 0 || i >= (int)l)
return NULL;
intObject *r = new runtime::ObjectModule<intObject>;
r->mVal = (int)mVal->operator[](i);
return r;
}
stringObject* stringObject::toString()
{
//AddRef();
stringObject *r = new runtime::ObjectModule<stringObject>;
*r->mVal = *mVal;
return r;
}
bool stringObject::isGreaterThan(runtimeObjectBase *obj)
{
return obj->GetObjectTypeId() == DT_string ? *mVal > getObjectData<stringObject>(obj) : false;
}
bool stringObject::isEqual(runtimeObjectBase *obj)
{
return obj->GetObjectTypeId() == DT_string ? *mVal == getObjectData<stringObject>(obj) : false;
}
///////////////////////////////////////////////////////////////////////////////
}
| [
"mz02005@gmail.com"
] | mz02005@gmail.com |
ef2401a38f0bc1704a656059d19e072fde0ee746 | 6b2a8dd202fdce77c971c412717e305e1caaac51 | /solutions_5709773144064000_0/C++/pieprzu/b.cpp | 63ec75a5877ebd981771a36a250ee3e06e84f819 | [] | 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 | 1,670 | cpp | //Krzysztof Pieprzak
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <list>
#include <deque>
#include <stack>
#include <map>
#include <ctime>
#include <cassert>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef pair<long long, long long> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
#define Size(x) (int)x.size()
#define VAR(v,n) typeof(n)v = (n)
#define FOR(i,a,b) for(VAR(i,a); i < (b); ++i)
#define FORE(i,a,b) for(VAR(i,a); i <= (b); ++i)
#define FORREV(i,a,b) for(VAR(i,b); i >= (a); --i)
#define FORSTEP(i,a,b,step) for(VAR(i,a); i < (b); i += (step))
#define FOREACH(i,c) for(VAR(i,(c).begin()); i != (c).end(); ++i)
#define ALL(x) x.begin(),x.end()
#define CLEAR(t) memset(t, 0, sizeof(t))
#define F first
#define S second
#define MP make_pair
#define PUB push_back
#define POB pop_back
#define pieprzu ios_base::sync_with_stdio(0);
const int INF = 1000000001;
const double EPS = 10e-9;
void rob(int cs)
{
ld c,f,x;
cin >> c >> f >> x;
ld curTime = 0;
ld d = 2;
ld best = x/d;
while (d <= x*5)
{
curTime += c/d;
d += f;
best = min(best, curTime+x/d);
}
cout << "Case #" << cs << ": ";
cout.precision(10);
cout << best << endl;
}
int main()
{
int test = 1;
scanf("%d", &test);
FOR (i, 0, test) rob(i+1);
return 0;
}
| [
"eewestman@gmail.com"
] | eewestman@gmail.com |
68dc2133fc212336b148fe287208fdd0c2f9f159 | 5ada4c8e50a27f506a08a60379c92140a7e846f5 | /codeforces/ecf68/ddforce.cpp | 8295a98e60df8d5489ed26969bed635b6a246a16 | [] | no_license | Ryan0v0/ACM-codes | 598dd884a161ca5bc319a5e949738c940900a67e | 27245bb13f82b9492e0fe0e68e2687923116560d | refs/heads/master | 2023-08-23T19:30:26.312670 | 2023-07-20T11:50:10 | 2023-07-20T11:50:10 | 203,974,731 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,328 | cpp | //
// Created by 赵婉如 on 2019-09-27.
//
#include<bits/stdc++.h>
using namespace std;
int a[10], d[40][3], vis[12], ans;
void init()
{
int cnt = 0;
for(int i = 1; i <= 9; i++)
for(int j = 1; j +i <= 9; j++)
{
d[cnt][0] = i;
d[cnt][1] = j;
d[cnt++][2] = i+j;
vis[i]++;vis[j]++;vis[i+j]++;
}
}
bool check(int x)
{
if(a[d[x][0]] < 0 || a[d[x][1]] < 0 || a[d[x][2]] < 0) return false;
return true;
}
void add(int x, int val)
{
a[d[x][0]] += val;
a[d[x][1]] += val;
a[d[x][2]] += val;
}
void dfs(int deep, int cnt)
{
if(36 - deep + cnt <= ans || deep == 36) return ;
add(deep, -1);
if(check(deep))
{
ans = max(ans, cnt+1);
dfs(deep+1, cnt+1);
}
add(deep, 1);
dfs(deep+1, cnt);
}
int main()
{
int t;
init();
scanf("%d", &t);
for(int kase = 1; kase <= t; kase++)
{
bool ok = true;
for(int i = 1; i <= 9; i++)
{
scanf("%d", &a[i]);
a[i] = min(a[i], 17 - i);
if(a[i] < 17 - i) ok = false;
}
if(ok)
printf("Case #%d: %d\n", kase, 36);
else
{
ans = 0;
dfs(0, 0);
printf("Case #%d: %d\n", kase, ans);
}
}
return 0;
} | [
"sxxhgz@163.com"
] | sxxhgz@163.com |
95eb505d525fa06335c26cc3385d96f6453cffdf | a13127feb4129f044dda377cbf1e0c92b8fc8b08 | /Generated Files/Scenario2.g.h | 7fdf149a8eaf77b1ddb1e756efe00bd2c736a3c9 | [] | no_license | royzxq/UWP_AUDIO_MANAGER | 75b0870557892926c086878b1bdff32e82b170fd | d06cbe0f9420ea1d5d0e7350c1b50a1ece9a4302 | refs/heads/master | 2021-01-10T04:29:45.260339 | 2016-03-02T19:22:09 | 2016-03-02T19:22:09 | 50,609,631 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,616 | h | #pragma once
//------------------------------------------------------------------------------
// This code was generated by a tool.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
//------------------------------------------------------------------------------
namespace Windows {
namespace UI {
namespace Xaml {
namespace Controls {
ref class Grid;
ref class ListBox;
ref class Button;
}
}
}
}
namespace SDKTemplate
{
namespace WASAPIAudio
{
[::Windows::Foundation::Metadata::WebHostHidden]
partial ref class Scenario2 : public ::Windows::UI::Xaml::Controls::Page,
public ::Windows::UI::Xaml::Markup::IComponentConnector,
public ::Windows::UI::Xaml::Markup::IComponentConnector2
{
public:
void InitializeComponent();
virtual void Connect(int connectionId, ::Platform::Object^ target);
virtual ::Windows::UI::Xaml::Markup::IComponentConnector^ GetBindingConnector(int connectionId, ::Platform::Object^ target);
private:
bool _contentLoaded;
private: ::Windows::UI::Xaml::Controls::Grid^ LayoutRoot;
private: ::Windows::UI::Xaml::Controls::Grid^ Input;
private: ::Windows::UI::Xaml::Controls::Grid^ Output;
private: ::Windows::UI::Xaml::Controls::ListBox^ DevicesList;
private: ::Windows::UI::Xaml::Controls::Button^ Enumerate;
};
}
}
| [
"royzxq@gmail.com"
] | royzxq@gmail.com |
4764fa7169848abb9b265a2f677bdde880d3330a | 1922aa4b3987fd0c0658407e404bcfbddea02d71 | /JustBusiness/Source/Project/Project.cpp | e6414c15e81e5e9b60692873acd814067ebfefeb | [] | no_license | ser432poly/Group3 | ef21e3eb43f51e11b65b5e5cb9c03114e1f46def | 387c6e54e42424a66911d72241ca6306b6687f36 | refs/heads/master | 2021-01-21T13:20:57.274193 | 2016-04-12T19:51:52 | 2016-04-12T19:51:52 | 51,237,900 | 0 | 0 | null | 2016-03-22T20:12:17 | 2016-02-07T06:17:08 | C++ | UTF-8 | C++ | false | false | 194 | cpp | // Copyright 1998-2015 Epic Games, Inc. All Rights Reserved.
#include "Project.h"
IMPLEMENT_PRIMARY_GAME_MODULE(FDefaultGameModuleImpl, Project, "Project");
DEFINE_LOG_CATEGORY(LogFlying)
| [
"kole9273@gmail.com"
] | kole9273@gmail.com |
e00a118d15520cbf09c1264e2f58b9fcb80a70e4 | 1cb0a7510bd47788e0c053f8c88e1fd478562fa4 | /Multiply_Command.h | ed98847f728dbbdd8a743a3fee1938ab2a113449 | [] | no_license | cahuizar/Calculator1.0 | 225a53865b98e3eab3aaa9bc7fb6e7611d1c27b1 | 77d2942786b66cb879914a11333a2e57eff0eca2 | refs/heads/master | 2021-01-12T14:08:22.587625 | 2016-10-01T18:19:14 | 2016-10-01T18:19:14 | 69,755,290 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 586 | h | //==============================================================================
/**
* Honor Pledge:
*
* I pledge that I have neither given nor received any help
* on this assignment.
*/
//==============================================================================
#ifndef _CS507_MULTIPLY_COMMAND_H_
#define _CS507_MULTIPLY_COMMAND_H_
#include "Binary_Op_Command.h"
#include "Stack.h"
class Multiply_Command : public Binary_Op_Command
{
public:
Multiply_Command();
int evaluate(int n1, int n2) const;
int priority(void);
};
#endif // _CS507_MULTIPLY_COMMAND_H_
| [
"cahuizar@github.iu.edu"
] | cahuizar@github.iu.edu |
88eee89583c0513f3bdc209ae538ff0709a19eef | 38c10c01007624cd2056884f25e0d6ab85442194 | /third_party/WebKit/Source/platform/geometry/FloatRoundedRect.cpp | fa8af1c09b2c81ea596147fb3e1ed7862f16640b | [
"BSD-3-Clause",
"LGPL-2.0-or-later",
"LicenseRef-scancode-warranty-disclaimer",
"LGPL-2.1-only",
"GPL-1.0-or-later",
"GPL-2.0-only",
"LGPL-2.0-only",
"BSD-2-Clause",
"LicenseRef-scancode-other-copyleft",
"MIT",
"Apache-2.0"
] | permissive | zenoalbisser/chromium | 6ecf37b6c030c84f1b26282bc4ef95769c62a9b2 | e71f21b9b4b9b839f5093301974a45545dad2691 | refs/heads/master | 2022-12-25T14:23:18.568575 | 2016-07-14T21:49:52 | 2016-07-23T08:02:51 | 63,980,627 | 0 | 2 | BSD-3-Clause | 2022-12-12T12:43:41 | 2016-07-22T20:14:04 | null | UTF-8 | C++ | false | false | 13,922 | cpp | /*
* Copyright (C) 2013 Adobe Systems Incorporated. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above
* copyright notice, this list of conditions and the following
* disclaimer.
* 2. Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT 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 "config.h"
#include "platform/geometry/FloatRoundedRect.h"
#include "platform/geometry/FloatQuad.h"
#include <algorithm>
#ifndef NDEBUG
#include <stdio.h>
#endif
namespace blink {
FloatRoundedRect::FloatRoundedRect(float x, float y, float width, float height)
: m_rect(x, y, width, height)
{
}
FloatRoundedRect::FloatRoundedRect(const FloatRect& rect, const Radii& radii)
: m_rect(rect)
, m_radii(radii)
{
}
FloatRoundedRect::FloatRoundedRect(const FloatRect& rect, const FloatSize& topLeft, const FloatSize& topRight, const FloatSize& bottomLeft, const FloatSize& bottomRight)
: m_rect(rect)
, m_radii(topLeft, topRight, bottomLeft, bottomRight)
{
}
bool FloatRoundedRect::Radii::isZero() const
{
return m_topLeft.isZero() && m_topRight.isZero() && m_bottomLeft.isZero() && m_bottomRight.isZero();
}
void FloatRoundedRect::Radii::scale(float factor)
{
if (factor == 1)
return;
// If either radius on a corner becomes zero, reset both radii on that corner.
m_topLeft.scale(factor);
if (!m_topLeft.width() || !m_topLeft.height())
m_topLeft = FloatSize();
m_topRight.scale(factor);
if (!m_topRight.width() || !m_topRight.height())
m_topRight = FloatSize();
m_bottomLeft.scale(factor);
if (!m_bottomLeft.width() || !m_bottomLeft.height())
m_bottomLeft = FloatSize();
m_bottomRight.scale(factor);
if (!m_bottomRight.width() || !m_bottomRight.height())
m_bottomRight = FloatSize();
}
void FloatRoundedRect::Radii::scaleAndFloor(float factor)
{
if (factor == 1)
return;
// If either radius on a corner becomes zero, reset both radii on that corner.
m_topLeft.scaleAndFloor(factor);
if (!m_topLeft.width() || !m_topLeft.height())
m_topLeft = FloatSize();
m_topRight.scaleAndFloor(factor);
if (!m_topRight.width() || !m_topRight.height())
m_topRight = FloatSize();
m_bottomLeft.scaleAndFloor(factor);
if (!m_bottomLeft.width() || !m_bottomLeft.height())
m_bottomLeft = FloatSize();
m_bottomRight.scaleAndFloor(factor);
if (!m_bottomRight.width() || !m_bottomRight.height())
m_bottomRight = FloatSize();
}
void FloatRoundedRect::Radii::shrink(float topWidth, float bottomWidth, float leftWidth, float rightWidth)
{
ASSERT(topWidth >= 0 && bottomWidth >= 0 && leftWidth >= 0 && rightWidth >= 0);
m_topLeft.setWidth(std::max<float>(0, m_topLeft.width() - leftWidth));
m_topLeft.setHeight(std::max<float>(0, m_topLeft.height() - topWidth));
m_topRight.setWidth(std::max<float>(0, m_topRight.width() - rightWidth));
m_topRight.setHeight(std::max<float>(0, m_topRight.height() - topWidth));
m_bottomLeft.setWidth(std::max<float>(0, m_bottomLeft.width() - leftWidth));
m_bottomLeft.setHeight(std::max<float>(0, m_bottomLeft.height() - bottomWidth));
m_bottomRight.setWidth(std::max<float>(0, m_bottomRight.width() - rightWidth));
m_bottomRight.setHeight(std::max<float>(0, m_bottomRight.height() - bottomWidth));
}
void FloatRoundedRect::Radii::expand(float topWidth, float bottomWidth, float leftWidth, float rightWidth)
{
ASSERT(topWidth >= 0 && bottomWidth >= 0 && leftWidth >= 0 && rightWidth >= 0);
if (m_topLeft.width() > 0 && m_topLeft.height() > 0) {
m_topLeft.setWidth(m_topLeft.width() + leftWidth);
m_topLeft.setHeight(m_topLeft.height() + topWidth);
}
if (m_topRight.width() > 0 && m_topRight.height() > 0) {
m_topRight.setWidth(m_topRight.width() + rightWidth);
m_topRight.setHeight(m_topRight.height() + topWidth);
}
if (m_bottomLeft.width() > 0 && m_bottomLeft.height() > 0) {
m_bottomLeft.setWidth(m_bottomLeft.width() + leftWidth);
m_bottomLeft.setHeight(m_bottomLeft.height() + bottomWidth);
}
if (m_bottomRight.width() > 0 && m_bottomRight.height() > 0) {
m_bottomRight.setWidth(m_bottomRight.width() + rightWidth);
m_bottomRight.setHeight(m_bottomRight.height() + bottomWidth);
}
}
#ifndef NDEBUG
void FloatRoundedRect::Radii::show() const
{
fprintf(stderr, "topLeft=[%f,%f], topRight=[%f,%f], bottomLeft=[%f,%f], bottomRight=[%f,%f]\n",
topLeft().width(), topLeft().height(), topRight().width(), topRight().height(),
bottomLeft().width(), bottomLeft().height(), bottomRight().width(), bottomRight().height());
}
#endif
static inline float cornerRectIntercept(float y, const FloatRect& cornerRect)
{
ASSERT(cornerRect.height() > 0);
return cornerRect.width() * sqrt(1 - (y * y) / (cornerRect.height() * cornerRect.height()));
}
FloatRect FloatRoundedRect::radiusCenterRect() const
{
FloatRectOutsets maximumRadiusInsets(
-std::max(m_radii.topLeft().height(), m_radii.topRight().height()),
-std::max(m_radii.topRight().width(), m_radii.bottomRight().width()),
-std::max(m_radii.bottomLeft().height(), m_radii.bottomRight().height()),
-std::max(m_radii.topLeft().width(), m_radii.bottomLeft().width()));
FloatRect centerRect(m_rect);
centerRect.expand(maximumRadiusInsets);
return centerRect;
}
bool FloatRoundedRect::xInterceptsAtY(float y, float& minXIntercept, float& maxXIntercept) const
{
if (y < rect().y() || y > rect().maxY())
return false;
if (!isRounded()) {
minXIntercept = rect().x();
maxXIntercept = rect().maxX();
return true;
}
const FloatRect& topLeftRect = topLeftCorner();
const FloatRect& bottomLeftRect = bottomLeftCorner();
if (!topLeftRect.isEmpty() && y >= topLeftRect.y() && y < topLeftRect.maxY())
minXIntercept = topLeftRect.maxX() - cornerRectIntercept(topLeftRect.maxY() - y, topLeftRect);
else if (!bottomLeftRect.isEmpty() && y >= bottomLeftRect.y() && y <= bottomLeftRect.maxY())
minXIntercept = bottomLeftRect.maxX() - cornerRectIntercept(y - bottomLeftRect.y(), bottomLeftRect);
else
minXIntercept = m_rect.x();
const FloatRect& topRightRect = topRightCorner();
const FloatRect& bottomRightRect = bottomRightCorner();
if (!topRightRect.isEmpty() && y >= topRightRect.y() && y <= topRightRect.maxY())
maxXIntercept = topRightRect.x() + cornerRectIntercept(topRightRect.maxY() - y, topRightRect);
else if (!bottomRightRect.isEmpty() && y >= bottomRightRect.y() && y <= bottomRightRect.maxY())
maxXIntercept = bottomRightRect.x() + cornerRectIntercept(y - bottomRightRect.y(), bottomRightRect);
else
maxXIntercept = m_rect.maxX();
return true;
}
void FloatRoundedRect::inflateWithRadii(int size)
{
FloatRect old = m_rect;
m_rect.inflate(size);
// Considering the inflation factor of shorter size to scale the radii seems appropriate here
float factor;
if (m_rect.width() < m_rect.height())
factor = old.width() ? (float)m_rect.width() / old.width() : int(0);
else
factor = old.height() ? (float)m_rect.height() / old.height() : int(0);
m_radii.scale(factor);
}
bool FloatRoundedRect::intersectsQuad(const FloatQuad& quad) const
{
if (!quad.intersectsRect(m_rect))
return false;
const FloatSize& topLeft = m_radii.topLeft();
if (!topLeft.isEmpty()) {
FloatRect rect(m_rect.x(), m_rect.y(), topLeft.width(), topLeft.height());
if (quad.intersectsRect(rect)) {
FloatPoint center(m_rect.x() + topLeft.width(), m_rect.y() + topLeft.height());
FloatSize size(topLeft.width(), topLeft.height());
if (!quad.intersectsEllipse(center, size))
return false;
}
}
const FloatSize& topRight = m_radii.topRight();
if (!topRight.isEmpty()) {
FloatRect rect(m_rect.maxX() - topRight.width(), m_rect.y(), topRight.width(), topRight.height());
if (quad.intersectsRect(rect)) {
FloatPoint center(m_rect.maxX() - topRight.width(), m_rect.y() + topRight.height());
FloatSize size(topRight.width(), topRight.height());
if (!quad.intersectsEllipse(center, size))
return false;
}
}
const FloatSize& bottomLeft = m_radii.bottomLeft();
if (!bottomLeft.isEmpty()) {
FloatRect rect(m_rect.x(), m_rect.maxY() - bottomLeft.height(), bottomLeft.width(), bottomLeft.height());
if (quad.intersectsRect(rect)) {
FloatPoint center(m_rect.x() + bottomLeft.width(), m_rect.maxY() - bottomLeft.height());
FloatSize size(bottomLeft.width(), bottomLeft.height());
if (!quad.intersectsEllipse(center, size))
return false;
}
}
const FloatSize& bottomRight = m_radii.bottomRight();
if (!bottomRight.isEmpty()) {
FloatRect rect(m_rect.maxX() - bottomRight.width(), m_rect.maxY() - bottomRight.height(), bottomRight.width(), bottomRight.height());
if (quad.intersectsRect(rect)) {
FloatPoint center(m_rect.maxX() - bottomRight.width(), m_rect.maxY() - bottomRight.height());
FloatSize size(bottomRight.width(), bottomRight.height());
if (!quad.intersectsEllipse(center, size))
return false;
}
}
return true;
}
void FloatRoundedRect::Radii::includeLogicalEdges(const FloatRoundedRect::Radii& edges, bool isHorizontal, bool includeLogicalLeftEdge, bool includeLogicalRightEdge)
{
if (includeLogicalLeftEdge) {
if (isHorizontal)
m_bottomLeft = edges.bottomLeft();
else
m_topRight = edges.topRight();
m_topLeft = edges.topLeft();
}
if (includeLogicalRightEdge) {
if (isHorizontal)
m_topRight = edges.topRight();
else
m_bottomLeft = edges.bottomLeft();
m_bottomRight = edges.bottomRight();
}
}
float calcBorderRadiiConstraintScaleFor(const FloatRect& rect, const FloatRoundedRect::Radii& radii)
{
float factor = 1;
float radiiSum;
// top
radiiSum = radii.topLeft().width() + radii.topRight().width(); // Casts to avoid integer overflow.
if (radiiSum > rect.width())
factor = std::min(rect.width() / radiiSum, factor);
// bottom
radiiSum = radii.bottomLeft().width() + radii.bottomRight().width();
if (radiiSum > rect.width())
factor = std::min(rect.width() / radiiSum, factor);
// left
radiiSum = radii.topLeft().height() + radii.bottomLeft().height();
if (radiiSum > rect.height())
factor = std::min(rect.height() / radiiSum, factor);
// right
radiiSum = radii.topRight().height() + radii.bottomRight().height();
if (radiiSum > rect.height())
factor = std::min(rect.height() / radiiSum, factor);
ASSERT(factor <= 1);
return factor;
}
void FloatRoundedRect::constrainRadii()
{
m_radii.scaleAndFloor(calcBorderRadiiConstraintScaleFor(rect(), radii()));
}
void FloatRoundedRect::includeLogicalEdges(const Radii& edges, bool isHorizontal, bool includeLogicalLeftEdge, bool includeLogicalRightEdge)
{
m_radii.includeLogicalEdges(edges, isHorizontal, includeLogicalLeftEdge, includeLogicalRightEdge);
}
bool FloatRoundedRect::isRenderable() const
{
// FIXME: remove the 0.0001 slop once this class is converted to layout units.
return m_radii.topLeft().width() + m_radii.topRight().width() <= m_rect.width() + 0.0001
&& m_radii.bottomLeft().width() + m_radii.bottomRight().width() <= m_rect.width() + 0.0001
&& m_radii.topLeft().height() + m_radii.bottomLeft().height() <= m_rect.height() + 0.0001
&& m_radii.topRight().height() + m_radii.bottomRight().height() <= m_rect.height() + 0.0001;
}
void FloatRoundedRect::adjustRadii()
{
float maxRadiusWidth = std::max(m_radii.topLeft().width() + m_radii.topRight().width(), m_radii.bottomLeft().width() + m_radii.bottomRight().width());
float maxRadiusHeight = std::max(m_radii.topLeft().height() + m_radii.bottomLeft().height(), m_radii.topRight().height() + m_radii.bottomRight().height());
if (maxRadiusWidth <= 0 || maxRadiusHeight <= 0) {
m_radii.scale(0.0f);
return;
}
float widthRatio = static_cast<float>(m_rect.width()) / maxRadiusWidth;
float heightRatio = static_cast<float>(m_rect.height()) / maxRadiusHeight;
m_radii.scale(widthRatio < heightRatio ? widthRatio : heightRatio);
}
#ifndef NDEBUG
void FloatRoundedRect::show() const
{
fprintf(stderr, "FloatRoundedRect:\n rect: ");
m_rect.show();
fprintf(stderr, " radii: ");
m_radii.show();
}
#endif
} // namespace blink
| [
"zeno.albisser@hemispherian.com"
] | zeno.albisser@hemispherian.com |
c7b8dbf8216797c21323fdb105c93736ecac7095 | 30c4a4cf3f1302298ddf47c81b9ace8a61eed5a4 | /src/resources.h | 66fd5d8f47f2c3399df0a6e7b85151fb07cc5909 | [] | no_license | ArgonBeryllium/ld49 | e6172449666481a73d00b5f6e74e55969109a20a | e11613130bb7e051d39e7a04045714dcdba2b4ed | refs/heads/main | 2023-08-22T21:17:31.365630 | 2021-10-09T10:32:07 | 2021-10-09T10:32:07 | 413,216,034 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,697 | h | #pragma once
#include <SDL2/SDL_mixer.h>
#include <SDL2/SDL_render.h>
#include <cumt/cumt.h>
#include <SDL2/SDL_image.h>
#include <cumt/cumt_render.h>
static inline SDL_Colour hexc(int c) { return {Uint8(c>>16), Uint8((c>>8) & 0xFF), Uint8(c & 0xFF),255}; }
inline SDL_Texture* SHEET_LOGO,
*T_PLATFORM, *T_P_IDLE, **T_P_RUN, *T_P_PUNCH, *T_P_CROUCH, *T_P_AIRBORNE, *T_P_FALL,
*T_B_IDLE, **T_B_RUN, *T_B_PUNCH, *T_B_AIRBORNE,
*T_BG, *T_MT, *T_HAZARD;
inline SDL_Colour C_BG = hexc(0xff7777), C_WHITE = hexc(0xffffff), C_BLACK = hexc(0x0000000);
inline Mix_Chunk* S_SPLASH, *S_TEXT_BLEEP, *S_BEEP, *S_BOOP, *S_JUMP, *S_SWING, *S_HIT, *S_DIE, *S_HAZARD_HIT;
inline cumt::render::TextData TD_DEF_L, TD_DEF_C, TD_DEF_R, TD_HL;
inline SDL_Texture* loadTexture(const char* path)
{
SDL_Texture* out = IMG_LoadTexture(shitrndr::ren, (std::string("res/")+path).c_str());
if(!out) std::cerr << "couldn't load texture: " << IMG_GetError() << '\n';
return out;
}
inline Mix_Chunk* loadSound(const char* path)
{
Mix_Chunk* out = Mix_LoadWAV((std::string("res/")+path).c_str());
if(!out) std::cerr << "couldn't load chunk: " << Mix_GetError() << '\n';
return out;
}
inline void loadResources()
{
using namespace cumt;
audio::init();
SHEET_LOGO = loadTexture("logo.png");
S_SPLASH = loadSound("splash.wav");
S_BEEP = loadSound("beep.wav");
S_BOOP = loadSound("boop.wav");
S_TEXT_BLEEP = S_BOOP;
S_JUMP = loadSound("Jump.wav");
S_SWING = loadSound("swing.wav");
S_HIT = loadSound("Hit.wav");
S_DIE = loadSound("Die.wav");
S_HAZARD_HIT = loadSound("Hazard_Hit.wav");
T_PLATFORM = loadTexture("platform.png");
T_BG = loadTexture("bg.png");
T_MT = loadTexture("mt.png");
T_HAZARD = loadTexture("hazard.png");
T_P_IDLE = loadTexture("player1.png");
T_P_RUN = new SDL_Texture*[2]{loadTexture("player2.png"), loadTexture("player3.png")};
T_P_PUNCH = loadTexture("player4.png");
T_P_CROUCH = loadTexture("player5.png");
T_P_AIRBORNE = loadTexture("player6.png");
T_P_FALL = loadTexture("player7.png");
T_B_IDLE = loadTexture("brute1.png");
T_B_RUN = new SDL_Texture*[2]{loadTexture("brute2.png"), loadTexture("brute3.png")};
T_B_PUNCH = loadTexture("brute4.png");
T_B_AIRBORNE = loadTexture("brute5.png");
RenderData::loadFont("res/ProggyTiny.ttf", 16);
RenderData::loadFont("res/m6x11.ttf", 14);
TD_DEF_L = render::TextData{0, render::TextData::LEFT };//, {1,1}, 0, {0,0,0,255}};
TD_DEF_C = render::TextData{0, render::TextData::CENTRE};//, {1,1}, 0, {0,0,0,255}};
TD_DEF_R = render::TextData{0, render::TextData::RIGHT };//, {1,1}, 0, {0,0,0,255}};
TD_HL = render::TextData{1, render::TextData::CENTRE, {1,1}, 0, C_BG};
}
| [
"argon-beryllium@protonmail.com"
] | argon-beryllium@protonmail.com |
21d575b419bbe875522c98c139cec055eb8beefa | 580a465000f9d53c5238e74932d01e3d3829958c | /lesson-27/Test/IntArray.cpp | fe21efbcc67b4088fd112da695f61aa9c20f6c76 | [] | no_license | eglrp/C_Plus_Plus | 367629d5e5c2f46d9c7fedd2c5f7e103cb924f48 | be9eb64bd753a6b1837df786ae6e04e66d3910c8 | refs/heads/master | 2022-04-09T12:31:01.732179 | 2020-03-19T14:38:45 | 2020-03-19T14:38:45 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 994 | cpp | #include "IntArray.h"
#include <stdio.h>
IntArray::IntArray(int len) {
mlen = len;
// mp = new int[len];
}
IntArray::~IntArray()
{
delete []mp;
}
bool IntArray::get(int index, int &value)
{
bool ret = true;
if (index >= mlen) {
ret = false;
} else {
value = mp[index];
}
return ret;
}
bool IntArray::set(int index, int value)
{
bool ret = true;
// bool ret = (index >= 0) && (index < length());
if (index >= mlen) {
ret = false;
} else {
mp[index] = value;
}
return ret;
}
int IntArray::length()
{
return mlen;
}
bool IntArray::construct(int len)
{
mp = new int[len];
return (mp == NULL) ? false : true;
}
IntArray* IntArray::NewInstance(int len) // 注意在类声明时时该函数有static,但是在定义时不能有static
{
IntArray * ret = new IntArray(len);
if (!(ret && ret->construct(len))) {
delete ret;
ret = NULL;
}
return ret;
} | [
"18855480967@163.com"
] | 18855480967@163.com |
3294ce6cbad2c44f85e52506ee1244975c29bd18 | dac5254630fefae851da7c843dcab7f6a6af9703 | /MacOS/Sources/Plugins/Spelling/CSpellChooseDictDialog.h | c25f8603d04cac618dc0ce4da8b90ea6d1aba35d | [
"Apache-2.0"
] | permissive | gpreviato/Mulberry-Mail | dd4e3618468fff36361bd2aeb0a725593faa0f8d | ce5c56ca7044e5ea290af8d3d2124c1d06f36f3a | refs/heads/master | 2021-01-20T03:31:39.515653 | 2017-09-21T13:09:55 | 2017-09-21T13:09:55 | 18,178,314 | 5 | 2 | null | null | null | null | UTF-8 | C++ | false | false | 1,559 | h | /*
Copyright (c) 2007 Cyrus Daboo. 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.
*/
// Header for CSpellChooseDictDialog class
#ifndef __CSPELLCHOOSEDICTDIALOG__MULBERRY__
#define __CSPELLCHOOSEDICTDIALOG__MULBERRY__
#include <LDialogBox.h>
// Constants
// Panes
const PaneIDT paneid_SpellChooseDictDialog = 20500;
const PaneIDT paneid_SpellChooseDictDictionaries = 'DICT';
// Resources
// Classes
class LPopupButton;
class CSpellPlugin;
class CSpellChooseDictDialog : public LDialogBox
{
public:
enum { class_ID = 'SpCh' };
CSpellChooseDictDialog();
CSpellChooseDictDialog(LStream *inStream);
virtual ~CSpellChooseDictDialog();
static bool PoseDialog(CSpellPlugin* speller);
protected:
virtual void FinishCreateSelf(void); // Do odds & ends
private:
LPopupButton* mDictionaries;
void SetSpeller(CSpellPlugin* speller); // Set the speller
void GetOptions(CSpellPlugin* speller); // Update options
void InitDictionaries(CSpellPlugin* speller);
};
#endif
| [
"svnusers@a91246af-f21b-0410-bd1c-c3c7fc455132"
] | svnusers@a91246af-f21b-0410-bd1c-c3c7fc455132 |
b1aa4f8c878dad03ffdf5b04575cc0dd4ee88fc8 | d269301d6dd4038b3f7de6c4ffd1fe75d1af95c8 | /mt6570/hal/imgsensor_metadata/ov5693_mipi_raw_2/camera_tuning_para_ov5693mipiraw_2.cpp | e80a2654f5b48cd91ae96879b33e3a77181f1b1c | [] | no_license | Skyrimus/camera_hals_5015D_5010D | 435d712e972db6c5940051625058069541cbd1ce | 2ab5f5826ced1a10e298886ff2ee3e1221610c2a | refs/heads/master | 2020-03-27T10:56:08.783761 | 2018-08-28T14:10:54 | 2018-08-28T14:10:56 | 146,454,642 | 2 | 1 | null | 2018-09-09T19:41:12 | 2018-08-28T13:50:15 | C | UTF-8 | C++ | false | false | 85,919 | cpp | /* Copyright Statement:
*
* This software/firmware and related documentation ("MediaTek Software") are
* protected under relevant copyright laws. The information contained herein
* is confidential and proprietary to MediaTek Inc. and/or its licensors.
* Without the prior written permission of MediaTek inc. and/or its licensors,
* any reproduction, modification, use or disclosure of MediaTek Software,
* and information contained herein, in whole or in part, shall be strictly prohibited.
*/
/* MediaTek Inc. (C) 2010. All rights reserved.
*
* BY OPENING THIS FILE, RECEIVER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO RECEIVER ON
* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND RECEIVER AGREES TO LOOK ONLY TO SUCH
* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. RECEIVER EXPRESSLY ACKNOWLEDGES
* THAT IT IS RECEIVER'S SOLE RESPONSIBILITY TO OBTAIN FROM ANY THIRD PARTY ALL PROPER LICENSES
* CONTAINED IN MEDIATEK SOFTWARE. MEDIATEK SHALL ALSO NOT BE RESPONSIBLE FOR ANY MEDIATEK
* SOFTWARE RELEASES MADE TO RECEIVER'S SPECIFICATION OR TO CONFORM TO A PARTICULAR
* STANDARD OR OPEN FORUM. RECEIVER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND
* CUMULATIVE LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY RECEIVER TO
* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
*
* The following software/firmware and/or related documentation ("MediaTek Software")
* have been modified by MediaTek Inc. All revisions are subject to any receiver's
* applicable license agreements with MediaTek Inc.
*/
/********************************************************************************************
* LEGAL DISCLAIMER
*
* (Header of MediaTek Software/Firmware Release or Documentation)
*
* BY OPENING OR USING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE") RECEIVED
* FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON AN "AS-IS" BASIS
* ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES, EXPRESS OR IMPLIED,
* INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR
* A PARTICULAR PURPOSE OR NONINFRINGEMENT. NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY
* WHATSOEVER WITH RESPECT TO THE SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY,
* INCORPORATED IN, OR SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK
* ONLY TO SUCH THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S SPECIFICATION
* OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
*
* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE LIABILITY WITH
* RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE, AT MEDIATEK'S OPTION,
* TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE, OR REFUND ANY SOFTWARE LICENSE
* FEES OR SERVICE CHARGE PAID BY BUYER TO MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
*
* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE WITH THE LAWS
* OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF LAWS PRINCIPLES.
************************************************************************************************/
#include <utils/Log.h>
#include <fcntl.h>
#include <math.h>
#include <string.h>
#include "camera_custom_nvram.h"
#include "camera_custom_sensor.h"
#include "image_sensor.h"
#include "kd_imgsensor_define.h"
#include "camera_AE_PLineTable_ov5693mipiraw_2.h"
#include "camera_info_ov5693mipiraw_2.h"
#include "camera_custom_AEPlinetable.h"
#include "camera_custom_tsf_tbl.h"
const NVRAM_CAMERA_ISP_PARAM_STRUCT CAMERA_ISP_DEFAULT_VALUE =
{{
//Version
Version: NVRAM_CAMERA_PARA_FILE_VERSION,
//SensorId
SensorId: SENSOR_ID,
ISPComm:{
{
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
}
},
ISPPca: {
#include INCLUDE_FILENAME_ISP_PCA_PARAM
},
ISPRegs:{
#include INCLUDE_FILENAME_ISP_REGS_PARAM
},
ISPMfbMixer:{{
{//00: MFB mixer for ISO 100
0x00000000, 0x00000000
},
{//01: MFB mixer for ISO 200
0x00000000, 0x00000000
},
{//02: MFB mixer for ISO 400
0x00000000, 0x00000000
},
{//03: MFB mixer for ISO 800
0x00000000, 0x00000000
},
{//04: MFB mixer for ISO 1600
0x00000000, 0x00000000
},
{//05: MFB mixer for ISO 2400
0x00000000, 0x00000000
},
{//06: MFB mixer for ISO 3200
0x00000000, 0x00000000
}
}},
ISPMulitCCM:{
Poly22:{
118496, // i4R_AVG
1, // i4R_STD
72246, // i4B_AVG
1, // i4B_STD
4095, // i4R_MAX
512, // i4R_MIN
4095, // i4G_MAX
512, // i4G_MIN
4095, // i4B_MAX
512, // i4B_MIN
{ // i4P00[9]
2560312, -3588750, 3588438, 198938, 2560000, -198938, 3612188, -3612188, 2560000
},
{ // i4P10[9]
0, 0, 0, 0, 0, 0, 0, 0, 0
},
{ // i4P01[9]
0, 0, 0, 0, 0, 0, 0, 0, 0
},
{ // i4P20[9]
0, 0, 0, 0, 0, 0, 0, 0, 0
},
{ // i4P11[9]
0, 0, 0, 0, 0, 0, 0, 0, 0
},
{ // i4P02[9]
0, 0, 0, 0, 0, 0, 0, 0, 0
}
},
AWBGain:{
// Strobe
{
512, // i4R
512, // i4G
512 // i4B
},
// A
{
632, // i4R
512, // i4G
1145 // i4B
},
// TL84
{
755, // i4R
512, // i4G
952 // i4B
},
// CWF
{
841, // i4R
512, // i4G
1012 // i4B
},
// D65
{
1040, // i4R
512, // i4G
638 // i4B
},
// Reserved 1
{
512, // i4R
512, // i4G
512 // i4B
},
// Reserved 2
{
512, // i4R
512, // i4G
512 // i4B
},
// Reserved 3
{
512, // i4R
512, // i4G
512 // i4B
}
},
Weight:{
1, // Strobe
1, // A
1, // TL84
1, // CWF
1, // D65
1, // Reserved 1
1, // Reserved 2
1 // Reserved 3
}
},
//bInvokeSmoothCCM
bInvokeSmoothCCM: MFALSE
}};
const NVRAM_CAMERA_3A_STRUCT CAMERA_3A_NVRAM_DEFAULT_VALUE =
{
NVRAM_CAMERA_3A_FILE_VERSION, // u4Version
SENSOR_ID, // SensorId
// AE NVRAM
{
// rDevicesInfo
{
1144, // u4MinGain, 1024 base = 1x
8192, // u4MaxGain, 16x
93, // u4MiniISOGain, ISOxx
128, // u4GainStepUnit, 1x/8
20593, // u4PreExpUnit
30, // u4PreMaxFrameRate
10434, // u4VideoExpUnit
30, // u4VideoMaxFrameRate
1024, // u4Video2PreRatio, 1024 base = 1x
10434, // u4CapExpUnit
29, // u4CapMaxFrameRate
1024, // u4Cap2PreRatio, 1024 base = 1x
10434, // u4Video1ExpUnit
120, // u4Video1MaxFrameRate
1024, // u4Video12PreRatio, 1024 base = 1x
20593, // u4Video2ExpUnit
30, // u4Video2MaxFrameRate
1024, // u4Video22PreRatio, 1024 base = 1x
19770, // u4Custom1ExpUnit
30, // u4Custom1MaxFrameRate
1024, // u4Custom12PreRatio, 1024 base = 1x
19770, // u4Custom2ExpUnit
30, // u4Custom2MaxFrameRate
1024, // u4Custom22PreRatio, 1024 base = 1x
19770, // u4Custom3ExpUnit
30, // u4Custom3MaxFrameRate
1024, // u4Custom32PreRatio, 1024 base = 1x
19770, // u4Custom4ExpUnit
30, // u4Custom4MaxFrameRate
1024, // u4Custom42PreRatio, 1024 base = 1x
19770, // u4Custom5ExpUnit
30, // u4Custom5MaxFrameRate
1024, // u4Custom52PreRatio, 1024 base = 1x
20, // u4LensFno, Fno = 2.8
350 // u4FocusLength_100x
},
// rHistConfig
{
4, // 2, // u4HistHighThres
40, // u4HistLowThres
2, // u4MostBrightRatio
1, // u4MostDarkRatio
160, // u4CentralHighBound
20, // u4CentralLowBound
{240, 230, 220, 210, 200}, // u4OverExpThres[AE_CCT_STRENGTH_NUM]
{62, 70, 82, 108, 141}, // u4HistStretchThres[AE_CCT_STRENGTH_NUM]
{18, 22, 26, 30, 34} // u4BlackLightThres[AE_CCT_STRENGTH_NUM]
},
// rCCTConfig
{
TRUE, // bEnableBlackLight
TRUE, // bEnableHistStretch
TRUE, // bEnableAntiOverExposure
TRUE, // bEnableTimeLPF
TRUE, // bEnableCaptureThres
TRUE, // bEnableVideoThres
TRUE, // bEnableVideo1Thres
TRUE, // bEnableVideo2Thres
TRUE, // bEnableCustom1Thres
TRUE, // bEnableCustom2Thres
TRUE, // bEnableCustom3Thres
TRUE, // bEnableCustom4Thres
TRUE, // bEnableCustom5Thres
TRUE, // bEnableStrobeThres
47, // u4AETarget
47, // u4StrobeAETarget
50, // u4InitIndex
4, // u4BackLightWeight
32, // u4HistStretchWeight
4, // u4AntiOverExpWeight
2, // u4BlackLightStrengthIndex
2, // 2, // u4HistStretchStrengthIndex
2, // u4AntiOverExpStrengthIndex
2, // u4TimeLPFStrengthIndex
{1, 3, 5, 7, 8}, // u4LPFConvergeTable[AE_CCT_STRENGTH_NUM]
90, // u4InDoorEV = 9.0, 10 base
-10, // i4BVOffset delta BV = -2.3
64, // u4PreviewFlareOffset
64, // u4CaptureFlareOffset
3, // u4CaptureFlareThres
64, // u4VideoFlareOffset
3, // u4VideoFlareThres
64, // u4CustomFlareOffset
3, // u4CustomFlareThres
64, // u4StrobeFlareOffset
3, // u4StrobeFlareThres
160, // u4PrvMaxFlareThres
0, // u4PrvMinFlareThres
160, // u4VideoMaxFlareThres
0, // u4VideoMinFlareThres
18, // u4FlatnessThres // 10 base for flatness condition.
75, // u4FlatnessStrength
//rMeteringSpec
{
//rHS_Spec
{
TRUE,//bEnableHistStretch // enable histogram stretch
1024,//u4HistStretchWeight // Histogram weighting value
40,//u4Pcent // 1%=10, 0~1000
160,//u4Thd // 0~255
75,//u4FlatThd // 0~255
120,//u4FlatBrightPcent
120,//u4FlatDarkPcent
//sFlatRatio
{
1000, //i4X1
1024, //i4Y1
2400, //i4X2
0 //i4Y2
},
TRUE, //bEnableGreyTextEnhance
1800, //u4GreyTextFlatStart, > sFlatRatio.i4X1, < sFlatRatio.i4X2
{
10, //i4X1
1024, //i4Y1
80, //i4X2
0 //i4Y2
}
},
//rAOE_Spec
{
TRUE,//bEnableAntiOverExposure
1024,//u4AntiOverExpWeight
10,//u4Pcent
200,//u4Thd
TRUE,//bEnableCOEP
1,//u4COEPcent
106,//u4COEThd
0, // u4BVCompRatio
//sCOEYRatio; // the outer y ratio
{
23, //i4X1
1024, //i4Y1
47, //i4X2
0 //i4Y2
},
//sCOEDiffRatio; // inner/outer y difference ratio
{
1500, //i4X1
0, //i4Y1
2100, //i4X2
1024 //i4Y2
}
},
//rABL_Spec
{
TRUE,//bEnableBlackLigh
1024,//u4BackLightWeigh
400,//u4Pcent
22,//u4Thd,
255, // center luminance
256, // final target limitation, 256/128 = 2x
//sFgBgEVRatio
{
2200, //i4X1
0, //i4Y1
4000, //i4X2
1024 //i4Y2
},
//sBVRatio
{
3800,//i4X1
0, //i4Y1
5000,//i4X2
1024 //i4Y2
}
},
//rNS_Spec
{
TRUE, // bEnableNightScene
5, //u4Pcent
170, //u4Thd
72, //u4FlatThd
200, //u4BrightTonePcent
92, //u4BrightToneThdMul; // bright tone THD 1x=1024, m_u4AETarget*u4BrightToneThdMul/1024
500, //u4LowBndPcent
5, //u4LowBndThdMul, <1024, u4AETarget*u4LowBndThdMul/1024
26, //u4LowBndThdLimitMul, <1024, u4AETarget*u4LowBndThdLimitMul/1024
50, //u4FlatBrightPcent;
300, //u4FlatDarkPcent;
//sFlatRatio
{
1200, //i4X1
1024, //i4Y1
2400,//i4X2
0 //i4Y2
},
//sBVRatio
{
-500, //i4X1
1024, //i4Y1
3000, //i4X2
0 //i4Y2
},
TRUE, // bEnableNightSkySuppresion
//sSkyBVRatio
{
-4000, //i4X1
1024, //i4X2
-2000, //i4Y1
0 //i4Y2
}
},
// rTOUCHFD_Spec
{
40,
50,
40,
50,
3,
120,
80,
}
}, //End rMeteringSpec
// rFlareSpec
{
{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
96,
48,
0,
4,
0,
1800,
0,
},
//rAEMoveRatio =
{
100, //u4SpeedUpRatio
100, //u4GlobalRatio
190, //u4Bright2TargetEnd
20, //u4Dark2TargetStart
90, //u4B2TEnd
70, //u4B2TStart
60, //u4D2TEnd
90, //u4D2TStart
},
//rAEVideoMoveRatio =
{
100, //u4SpeedUpRatio
100, //u4GlobalRatio
150, //u4Bright2TargetEnd
20, //u4Dark2TargetStart
90, //u4B2TEnd
10, //u4B2TStart
10, //u4D2TEnd
90, //u4D2TStart
},
//rAEVideo1MoveRatio =
{
100, //u4SpeedUpRatio
100, //u4GlobalRatio
150, //u4Bright2TargetEnd
20, //u4Dark2TargetStart
90, //u4B2TEnd
10, //u4B2TStart
10, //u4D2TEnd
90, //u4D2TStart
},
//rAEVideo2MoveRatio =
{
100, //u4SpeedUpRatio
100, //u4GlobalRatio
150, //u4Bright2TargetEnd
20, //u4Dark2TargetStart
90, //u4B2TEnd
10, //u4B2TStart
10, //u4D2TEnd
90, //u4D2TStart
},
//rAECustom1MoveRatio =
{
100, //u4SpeedUpRatio
100, //u4GlobalRatio
150, //u4Bright2TargetEnd
20, //u4Dark2TargetStart
90, //u4B2TEnd
10, //u4B2TStart
10, //u4D2TEnd
90, //u4D2TStart
},
//rAECustom2MoveRatio =
{
100, //u4SpeedUpRatio
100, //u4GlobalRatio
150, //u4Bright2TargetEnd
20, //u4Dark2TargetStart
90, //u4B2TEnd
40, //u4B2TStart
40, //u4D2TEnd
90, //u4D2TStart
},
//rAECustom3MoveRatio =
{
100, //u4SpeedUpRatio
100, //u4GlobalRatio
150, //u4Bright2TargetEnd
20, //u4Dark2TargetStart
90, //u4B2TEnd
10, //u4B2TStart
10, //u4D2TEnd
90, //u4D2TStart
},
//rAECustom4MoveRatio =
{
100, //u4SpeedUpRatio
100, //u4GlobalRatio
150, //u4Bright2TargetEnd
20, //u4Dark2TargetStart
90, //u4B2TEnd
10, //u4B2TStart
10, //u4D2TEnd
90, //u4D2TStart
},
//rAECustom5MoveRatio =
{
100, //u4SpeedUpRatio
100, //u4GlobalRatio
150, //u4Bright2TargetEnd
20, //u4Dark2TargetStart
90, //u4B2TEnd
10, //u4B2TStart
10, //u4D2TEnd
90, //u4D2TStart
},
//rAEFaceMoveRatio =
{
100, //u4SpeedUpRatio
100, //u4GlobalRatio
190, //u4Bright2TargetEnd
10, //u4Dark2TargetStart
80, //u4B2TEnd
30, //u4B2TStart
20, //u4D2TEnd
60, //u4D2TStart
},
//rAETrackingMoveRatio =
{
100, //u4SpeedUpRatio
100, //u4GlobalRatio
190, //u4Bright2TargetEnd
10, //u4Dark2TargetStart
80, //u4B2TEnd
30, //u4B2TStart
20, //u4D2TEnd
60, //u4D2TStart
},
//rAEAOENVRAMParam =
{
1, // i4AOEStrengthIdx: 0 / 1 / 2
130, // u4BVCompRatio
{
{
47, //u4Y_Target
10, //u4AOE_OE_percent
160, //u4AOE_OEBound
15, //u4AOE_DarkBound
950, //u4AOE_LowlightPrecent
5, //u4AOE_LowlightBound
100, //u4AOESceneLV_L
150, //u4AOESceneLV_H
40, //u4AOE_SWHdrLE_Bound
},
{
47, //u4Y_Target
10, //u4AOE_OE_percent
180, //u4AOE_OEBound
20, //u4AOE_DarkBound
950, //u4AOE_LowlightPrecent
10, //u4AOE_LowlightBound
100, //u4AOESceneLV_L
150, //u4AOESceneLV_H
40, //u4AOE_SWHdrLE_Bound
},
{
47, //u4Y_Target
10, //u4AOE_OE_percent
200, //u4AOE_OEBound
25, //u4AOE_DarkBound
950, //u4AOE_LowlightPrecent
15, //u4AOE_LowlightBound
100, //u4AOESceneLV_L
150, //u4AOESceneLV_H
40, //u4AOE_SWHdrLE_Bound
}
}
}
}
},
// AWB NVRAM
{
{
{
// AWB calibration data
{
// rUnitGain (unit gain: 1.0 = 512)
{
0, // UnitGain_R
0, // UnitGain_G
0 // UnitGain_B
},
// rGoldenGain (golden sample gain: 1.0 = 512)
{
0, // GoldenGain_R
0, // GoldenGain_G
0 // GoldenGain_B
},
// rTuningUnitGain (Tuning sample unit gain: 1.0 = 512)
{
0, // TuningUnitGain_R
0, // TuningUnitGain_G
0 // TuningUnitGain_B
},
// rD65Gain (D65 WB gain: 1.0 = 512)
{
1024, // D65Gain_R
512, // D65Gain_G
695 // D65Gain_B
}
},
// Original XY coordinate of AWB light source
{
// Strobe
{
0, // OriX_Strobe
0 // OriY_Strobe
},
// Horizon
{
-434, // OriX_Hor
-375 // OriY_Hor
},
// A
{
-302, // OriX_A
-385 // OriY_A
},
// TL84
{
-141, // OriX_TL84
-372 // OriY_TL84
},
// CWF
{
-121, // OriX_CWF
-466 // OriY_CWF
},
// DNP
{
-10, // OriX_DNP
-400 // OriY_DNP
},
// D65
{
143, // OriX_D65
-369 // OriY_D65
},
// DF
{
0, // OriX_DF
0 // OriY_DF
}
},
// Rotated XY coordinate of AWB light source
{
// Strobe
{
0, // RotX_Strobe
0 // RotY_Strobe
},
// Horizon
{
-440, // RotX_Hor
-368 // RotY_Hor
},
// A
{
-308, // RotX_A
-380 // RotY_A
},
// TL84
{
-147, // RotX_TL84
-370 // RotY_TL84
},
// CWF
{
-128, // RotX_CWF
-464 // RotY_CWF
},
// DNP
{
-16, // RotX_DNP
-400 // RotY_DNP
},
// D65
{
137, // RotX_D65
-371 // RotY_D65
},
// DF
{
116, // RotX_DF
-453 // RotY_DF
}
},
// AWB gain of AWB light source
{
// Strobe
{
512, // AWBGAIN_STROBE_R
512, // AWBGAIN_STROBE_G
512 // AWBGAIN_STROBE_B
},
// Horizon
{
512, // AWBGAIN_HOR_R
555, // AWBGAIN_HOR_G
1660 // AWBGAIN_HOR_B
},
// A
{
573, // AWBGAIN_A_R
512, // AWBGAIN_A_G
1297 // AWBGAIN_A_B
},
// TL84
{
700, // AWBGAIN_TL84_R
512, // AWBGAIN_TL84_G
1026 // AWBGAIN_TL84_B
},
// CWF
{
817, // AWBGAIN_CWF_R
512, // AWBGAIN_CWF_G
1134 // AWBGAIN_CWF_B
},
// DNP
{
869, // AWBGAIN_DNP_R
512, // AWBGAIN_DNP_G
892 // AWBGAIN_DNP_B
},
// D65
{
1024, // AWBGAIN_D65_R
512, // AWBGAIN_D65_G
695 // AWBGAIN_D65_B
},
// DF
{
512, // AWBGAIN_DF_R
512, // AWBGAIN_DF_G
512 // AWBGAIN_DF_B
}
},
// Rotation matrix parameter
{
1, // RotationAngle
256, // Cos
4 // Sin
},
// Daylight locus parameter
{
-133, // SlopeNumerator
128 // SlopeDenominator
},
// Predictor gain
{
101, // i4PrefRatio100
// DaylightLocus_L
{
994, // i4R
530, // i4G
715 // i4B
},
// DaylightLocus_H
{
811, // i4R
512, // i4G
884 // i4B
},
// Temporal General
{
1024, // i4R
512, // i4G
695 // i4B
},
// AWB LSC
{
811, // i4R
512, // i4G
884 // i4B
}
},
// AWB light area
{
// Strobe
{
0, // StrobeRightBound
0, // StrobeLeftBound
0, // StrobeUpperBound
0 // StrobeLowerBound
},
// Tungsten
{
-211, // TungRightBound
-840, // TungLeftBound
-313, // TungUpperBound
-375 // TungLowerBound
},
// Warm fluorescent
{
-211, // WFluoRightBound
-840, // WFluoLeftBound
-375, // WFluoUpperBound
-504 // WFluoLowerBound
},
// Fluorescent
{
-59, // FluoRightBound
-211, // FluoLeftBound
-311, // FluoUpperBound
-417 // FluoLowerBound
},
// CWF
{
-30, // CWFRightBound
-211, // CWFLeftBound
-417, // CWFUpperBound
-519 // CWFLowerBound
},
// Daylight
{
167, // DayRightBound
-59, // DayLeftBound
-311, // DayUpperBound
-417 // DayLowerBound
},
// Shade
{
497, // ShadeRightBound
167, // ShadeLeftBound
-311, // ShadeUpperBound
-408 // ShadeLowerBound
},
// Daylight Fluorescent
{
167, // DFRightBound
-30, // DFLeftBound
-417, // DFUpperBound
-519 // DFLowerBound
}
},
// PWB light area
{
// Reference area
{
497, // PRefRightBound
-840, // PRefLeftBound
-286, // PRefUpperBound
-519 // PRefLowerBound
},
// Daylight
{
192, // PDayRightBound
-59, // PDayLeftBound
-311, // PDayUpperBound
-417 // PDayLowerBound
},
// Cloudy daylight
{
292, // PCloudyRightBound
117, // PCloudyLeftBound
-311, // PCloudyUpperBound
-417 // PCloudyLowerBound
},
// Shade
{
392, // PShadeRightBound
117, // PShadeLeftBound
-311, // PShadeUpperBound
-417 // PShadeLowerBound
},
// Twilight
{
-59, // PTwiRightBound
-219, // PTwiLeftBound
-311, // PTwiUpperBound
-417 // PTwiLowerBound
},
// Fluorescent
{
187, // PFluoRightBound
-247, // PFluoLeftBound
-320, // PFluoUpperBound
-514 // PFluoLowerBound
},
// Warm fluorescent
{
-208, // PWFluoRightBound
-408, // PWFluoLeftBound
-320, // PWFluoUpperBound
-514 // PWFluoLowerBound
},
// Incandescent
{
-208, // PIncaRightBound
-408, // PIncaLeftBound
-311, // PIncaUpperBound
-417 // PIncaLowerBound
},
// Gray World
{
5000, // PGWRightBound
-5000, // PGWLeftBound
5000, // PGWUpperBound
-5000 // PGWLowerBound
}
},
// PWB default gain
{
// Daylight
{
923, // PWB_Day_R
512, // PWB_Day_G
759 // PWB_Day_B
},
// Cloudy daylight
{
1109, // PWB_Cloudy_R
512, // PWB_Cloudy_G
628 // PWB_Cloudy_B
},
// Shade
{
1185, // PWB_Shade_R
512, // PWB_Shade_G
586 // PWB_Shade_B
},
// Twilight
{
702, // PWB_Twi_R
512, // PWB_Twi_G
1007 // PWB_Twi_B
},
// Fluorescent
{
873, // PWB_Fluo_R
512, // PWB_Fluo_G
930 // PWB_Fluo_B
},
// Warm fluorescent
{
603, // PWB_WFluo_R
512, // PWB_WFluo_G
1363 // PWB_WFluo_B
},
// Incandescent
{
560, // PWB_Inca_R
512, // PWB_Inca_G
1270 // PWB_Inca_B
},
// Gray World
{
512, // PWB_GW_R
512, // PWB_GW_G
512 // PWB_GW_B
}
},
// AWB preference color
{
// Tungsten
{
40, // TUNG_SLIDER
4942 // TUNG_OFFS
},
// Warm fluorescent
{
40, // WFluo_SLIDER
4942 // WFluo_OFFS
},
// Shade
{
50, // Shade_SLIDER
909 // Shade_OFFS
},
// Sunset Area
{
17, // i4Sunset_BoundXr_Thr
-400 // i4Sunset_BoundXr_Thr
},
// Sunset Vertex
{
17, // i4Sunset_VertexXr_Thr
-400 // i4Sunset_VertexXr_Thr
},
// Shade F Area
{
-211, // i4Sunset_BoundXr_Thr
-374 // i4Sunset_BoundXr_Thr
},
// Shade F Vertex
{
-211, // i4Sunset_VertexXr_Thr
-396 // i4Sunset_VertexXr_Thr
},
// Shade CWF Area
{
-211, // i4Sunset_BoundXr_Thr
-468 // i4Sunset_BoundXr_Thr
},
// Shade CWF Vertex
{
-211, // i4Sunset_VertexXr_Thr
-494 // i4Sunset_VertexXr_Thr
},
// Low CCT Area
{
-460, // i4Sunset_BoundXr_Thr
65 // i4Sunset_BoundXr_Thr
},
// Low CCT Vertex
{
-460, // i4Sunset_VertexXr_Thr
65 // i4Sunset_VertexXr_Thr
}
},
// CCT estimation
{
// CCT
{
2300, // CCT0
2850, // CCT1
3750, // CCT2
5100, // CCT3
6500 // CCT4
},
// Rotated X coordinate
{
-577, // RotatedXCoordinate0
-445, // RotatedXCoordinate1
-284, // RotatedXCoordinate2
-153, // RotatedXCoordinate3
0 // RotatedXCoordinate4
}
}
},
// Algorithm Tuning Paramter
{
// AWB Backup Enable
0,
// Daylight locus offset LUTs for tungsten
{
21,// i4Size: LUT dimension
{0, 500, 1000, 1500, 2000, 2500, 3000, 3500, 4000, 4500, 5000, 5500, 6000, 6500, 7000, 7500, 8000, 8500, 9000, 9500, 10000}, // i4LUTIn
{0, 350, 700, 1224, 1224, 1224, 1225, 1225, 1226, 1226, 1227, 1227, 1228, 1228, 1228, 1229, 1229, 1230, 1230, 1231, 1231} // i4LUTOut
},
// Daylight locus offset LUTs for WF
{
21,// i4Size: LUT dimension
{0, 500, 1000, 1500, 2000, 2500, 3000, 3500, 4000, 4500, 5000, 5500, 6000, 6500, 7000, 7500, 8000, 8500, 9000, 9500, 10000}, // i4LUTIn
{0, 350, 700, 850, 1200, 1224, 1225, 1225, 1226, 1226, 1227, 1227, 1228, 1228, 1228, 1229, 1229, 1230, 1230, 1231, 1231} // i4LUTOut
},
// Daylight locus offset LUTs for Shade
{
21,// i4Size: LUT dimension
{0, 500, 1000, 1500, 2000, 2500, 3000, 3500, 4000, 4500, 5000, 5500, 6000, 6500, 7000, 7500, 8000, 8500, 9000, 9500, 10000}, // i4LUTIn
{0, 500, 1000, 1500, 2000, 2500, 3000, 3500, 4000, 4500, 5000, 5500, 6000, 6500, 7000, 7500, 8000, 8500, 9000, 9500, 10000} // i4LUTOut
},
// Preference gain for each light source
{
{
// LV0 LV1 LV2 LV3 LV4 LV5 LV6 LV7 LV8 LV9
{512, 512, 512}, {512, 512, 512}, {512, 512, 512}, {512, 512, 512}, {512, 512, 512}, {512, 512, 512}, {512, 512, 512}, {512, 512, 512}, {512, 512, 512}, {512, 512, 512},
// LV10 LV11 LV12 LV13 LV14 LV15 LV16 LV17 LV18
{512, 512, 512}, {512, 512, 512}, {512, 512, 512}, {512, 512, 512}, {512, 512, 512}, {512, 512, 512}, {512, 512, 512}, {512, 512, 512}, {512, 512, 512}
}, // STROBE
{
// LV0 LV1 LV2 LV3 LV4 LV5 LV6 LV7 LV8 LV9
{530, 530, 480}, {530, 530, 480}, {530, 530, 480}, {530, 530, 480}, {530, 530, 480}, {520, 520, 496}, {512, 512, 512}, {512, 512, 512}, {512, 512, 512}, {512, 512, 512},
// LV10 LV11 LV12 LV13 LV14 LV15 LV16 LV17 LV18
{512, 512, 512}, {512, 512, 512}, {512, 512, 512}, {512, 512, 512}, {512, 512, 512}, {512, 512, 512}, {512, 512, 512}, {512, 512, 512}, {512, 512, 512}
}, // TUNGSTEN
{
// LV0 LV1 LV2 LV3 LV4 LV5 LV6 LV7 LV8 LV9
{512, 512, 508}, {512, 512, 508}, {512, 512, 508}, {512, 512, 508}, {512, 512, 508}, {512, 512, 508}, {512, 512, 508}, {512, 512, 508}, {512, 512, 508}, {512, 512, 508},
// LV10 LV11 LV12 LV13 LV14 LV15 LV16 LV17 LV18
{512, 512, 508}, {512, 512, 512}, {512, 512, 512}, {512, 512, 512}, {512, 512, 512}, {512, 512, 512}, {512, 512, 512}, {512, 512, 512}, {512, 512, 512}
}, // WARM F
{
// LV0 LV1 LV2 LV3 LV4 LV5 LV6 LV7 LV8 LV9
{512, 512, 512}, {512, 512, 512}, {512, 512, 512}, {512, 512, 512}, {512, 512, 512}, {512, 512, 512}, {512, 512, 512}, {512, 512, 512}, {512, 512, 512}, {512, 512, 512},
// LV10 LV11 LV12 LV13 LV14 LV15 LV16 LV17 LV18
{512, 512, 512}, {512, 512, 512}, {512, 512, 512}, {512, 512, 512}, {502, 512, 512}, {502, 512, 512}, {502, 512, 512}, {502, 512, 512}, {502, 512, 512}
}, // F
{
// LV0 LV1 LV2 LV3 LV4 LV5 LV6 LV7 LV8 LV9
{512, 512, 512}, {512, 512, 512}, {512, 512, 512}, {512, 512, 512}, {512, 512, 512}, {512, 512, 512}, {512, 512, 512}, {512, 512, 512}, {512, 512, 512}, {512, 512, 512},
// LV10 LV11 LV12 LV13 LV14 LV15 LV16 LV17 LV18
{512, 512, 512}, {512, 512, 512}, {512, 512, 512}, {512, 512, 512}, {512, 512, 512}, {512, 512, 512}, {512, 512, 512}, {512, 512, 512}, {512, 512, 512}
}, // CWF
{
// LV0 LV1 LV2 LV3 LV4 LV5 LV6 LV7 LV8 LV9
{512, 512, 512}, {512, 512, 512}, {512, 512, 512}, {512, 512, 512}, {512, 512, 512}, {512, 512, 512}, {512, 512, 512}, {512, 512, 512}, {512, 512, 512}, {512, 512, 512},
// LV10 LV11 LV12 LV13 LV14 LV15 LV16 LV17 LV18
{512, 512, 512}, {512, 512, 512}, {512, 512, 512}, {512, 512, 512}, {502, 512, 512}, {502, 512, 512}, {502, 512, 512}, {502, 512, 512}, {502, 512, 512}
}, // DAYLIGHT
{
// LV0 LV1 LV2 LV3 LV4 LV5 LV6 LV7 LV8 LV9
{512, 512, 512}, {512, 512, 512}, {512, 512, 512}, {512, 512, 512}, {512, 512, 512}, {512, 512, 512}, {512, 512, 512}, {512, 512, 512}, {512, 512, 512}, {512, 512, 512},
// LV10 LV11 LV12 LV13 LV14 LV15 LV16 LV17 LV18
{512, 512, 512}, {512, 512, 512}, {512, 512, 512}, {512, 512, 512}, {512, 512, 512}, {512, 512, 512}, {512, 512, 512}, {512, 512, 512}, {512, 512, 512}
}, // SHADE
{
// LV0 LV1 LV2 LV3 LV4 LV5 LV6 LV7 LV8 LV9
{512, 512, 512}, {512, 512, 512}, {512, 512, 512}, {512, 512, 512}, {512, 512, 512}, {512, 512, 512}, {512, 512, 512}, {512, 512, 512}, {512, 512, 512}, {512, 512, 512},
// LV10 LV11 LV12 LV13 LV14 LV15 LV16 LV17 LV18
{512, 512, 512}, {512, 512, 512}, {512, 512, 512}, {512, 512, 512}, {512, 512, 512}, {512, 512, 512}, {512, 512, 512}, {512, 512, 512}, {512, 512, 512}
} // DAYLIGHT F
},
// Parent block weight parameter
{
1, // bEnable
6 // i4ScalingFactor: [6] 1~12, [7] 1~6, [8] 1~3, [9] 1~2, [>=10]: 1
},
// AWB LV threshold for predictor
{
115, // i4InitLVThr_L
155, // i4InitLVThr_H
100 // i4EnqueueLVThr
},
// AWB number threshold for temporal predictor
{
65, // i4Neutral_ParentBlk_Thr
//LV0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
{ 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 50, 25, 2, 2, 2, 2, 2, 2, 2} // i4CWFDF_LUTThr
},
// AWB light neutral noise reduction for outdoor
{
//LV0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
// Non neutral
{ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 5, 10, 10, 10, 10, 10, 10, 10, 10}, //
// Flurescent
{ 0, 0, 0, 0, 0, 3, 5, 5, 5, 5, 5, 10, 10, 10, 10, 10, 10, 10, 10}, //
// CWF
{ 0, 0, 0, 0, 0, 3, 5, 5, 5, 5, 5, 10, 10, 10, 10, 10, 10, 10, 10}, //
// Daylight
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 2, 2, 2, 2, 2}, //
// DF
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 10, 10, 10, 10, 10, 10, 10, 10} //
},
// AWB feature detection
{
// Sunset Prop
{
1, // i4Enable
120, // i4LVThr_L
130, // i4LVThr_H
10, // i4SunsetCountThr
0, // i4SunsetCountRatio_L
171 // i4SunsetCountRatio_H
},
// Shade F Detection
{
1, // i4Enable
55, // i4LVThr_L
70, // i4LVThr_H
96 // i4DaylightProb
},
// Shade CWF Detection
{
1, // i4Enable
55, // i4LVThr_L
70, // i4LVThr_H
192 // i4DaylightProb
},
// Low CCT
{
0, // i4Enable
256 // i4SpeedRatio
}
},
// AWB non-neutral probability for spatial and temporal weighting look-up table (Max: 100; Min: 0)
{
//LV0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
{ 0, 33, 66, 100, 100, 100, 100, 100, 100, 100, 100, 70, 30, 20, 10, 0, 0, 0, 0}
},
// AWB daylight locus probability look-up table (Max: 100; Min: 0)
{
//LV0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
{ 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 50, 25, 0, 0, 0, 0}, // Strobe
{ 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 75, 50, 25, 0, 0, 0}, // Tungsten
{ 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 75, 50, 25, 25, 25, 0, 0, 0}, // Warm fluorescent
{ 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 95, 75, 50, 25, 25, 25, 0, 0, 0}, // Fluorescent
{ 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 80, 55, 30, 30, 30, 30, 0, 0, 0}, // CWF
{ 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 75, 50, 40, 30, 20}, // Daylight
{ 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 75, 50, 25, 0, 0, 0, 0}, // Shade
{ 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 80, 55, 30, 30, 30, 30, 0, 0, 0} // Daylight fluorescent
}
}
},
{
{
// AWB calibration data
{
// rUnitGain (unit gain: 1.0 = 512)
{
0, // UnitGain_R
0, // UnitGain_G
0 // UnitGain_B
},
// rGoldenGain (golden sample gain: 1.0 = 512)
{
0, // GoldenGain_R
0, // GoldenGain_G
0 // GoldenGain_B
},
// rTuningUnitGain (Tuning sample unit gain: 1.0 = 512)
{
0, // TuningUnitGain_R
0, // TuningUnitGain_G
0 // TuningUnitGain_B
},
// rD65Gain (D65 WB gain: 1.0 = 512)
{
1024, // D65Gain_R
512, // D65Gain_G
695 // D65Gain_B
}
},
// Original XY coordinate of AWB light source
{
// Strobe
{
0, // OriX_Strobe
0 // OriY_Strobe
},
// Horizon
{
-434, // OriX_Hor
-375 // OriY_Hor
},
// A
{
-302, // OriX_A
-385 // OriY_A
},
// TL84
{
-141, // OriX_TL84
-372 // OriY_TL84
},
// CWF
{
-121, // OriX_CWF
-466 // OriY_CWF
},
// DNP
{
-10, // OriX_DNP
-400 // OriY_DNP
},
// D65
{
143, // OriX_D65
-369 // OriY_D65
},
// DF
{
0, // OriX_DF
0 // OriY_DF
}
},
// Rotated XY coordinate of AWB light source
{
// Strobe
{
0, // RotX_Strobe
0 // RotY_Strobe
},
// Horizon
{
-440, // RotX_Hor
-368 // RotY_Hor
},
// A
{
-308, // RotX_A
-380 // RotY_A
},
// TL84
{
-147, // RotX_TL84
-370 // RotY_TL84
},
// CWF
{
-128, // RotX_CWF
-464 // RotY_CWF
},
// DNP
{
-16, // RotX_DNP
-400 // RotY_DNP
},
// D65
{
137, // RotX_D65
-371 // RotY_D65
},
// DF
{
116, // RotX_DF
-453 // RotY_DF
}
},
// AWB gain of AWB light source
{
// Strobe
{
512, // AWBGAIN_STROBE_R
512, // AWBGAIN_STROBE_G
512 // AWBGAIN_STROBE_B
},
// Horizon
{
512, // AWBGAIN_HOR_R
555, // AWBGAIN_HOR_G
1660 // AWBGAIN_HOR_B
},
// A
{
573, // AWBGAIN_A_R
512, // AWBGAIN_A_G
1297 // AWBGAIN_A_B
},
// TL84
{
700, // AWBGAIN_TL84_R
512, // AWBGAIN_TL84_G
1026 // AWBGAIN_TL84_B
},
// CWF
{
817, // AWBGAIN_CWF_R
512, // AWBGAIN_CWF_G
1134 // AWBGAIN_CWF_B
},
// DNP
{
869, // AWBGAIN_DNP_R
512, // AWBGAIN_DNP_G
892 // AWBGAIN_DNP_B
},
// D65
{
1024, // AWBGAIN_D65_R
512, // AWBGAIN_D65_G
695 // AWBGAIN_D65_B
},
// DF
{
512, // AWBGAIN_DF_R
512, // AWBGAIN_DF_G
512 // AWBGAIN_DF_B
}
},
// Rotation matrix parameter
{
1, // RotationAngle
256, // Cos
4 // Sin
},
// Daylight locus parameter
{
-133, // SlopeNumerator
128 // SlopeDenominator
},
// Predictor gain
{
101, // i4PrefRatio100
// DaylightLocus_L
{
994, // i4R
530, // i4G
715 // i4B
},
// DaylightLocus_H
{
811, // i4R
512, // i4G
884 // i4B
},
// Temporal General
{
1024, // i4R
512, // i4G
695 // i4B
},
// AWB LSC
{
811, // i4R
512, // i4G
884 // i4B
}
},
// AWB light area
{
// Strobe
{
0, // StrobeRightBound
0, // StrobeLeftBound
0, // StrobeUpperBound
0 // StrobeLowerBound
},
// Tungsten
{
-211, // TungRightBound
-840, // TungLeftBound
-313, // TungUpperBound
-375 // TungLowerBound
},
// Warm fluorescent
{
-211, // WFluoRightBound
-840, // WFluoLeftBound
-375, // WFluoUpperBound
-504 // WFluoLowerBound
},
// Fluorescent
{
-59, // FluoRightBound
-211, // FluoLeftBound
-311, // FluoUpperBound
-417 // FluoLowerBound
},
// CWF
{
-30, // CWFRightBound
-211, // CWFLeftBound
-417, // CWFUpperBound
-519 // CWFLowerBound
},
// Daylight
{
167, // DayRightBound
-59, // DayLeftBound
-311, // DayUpperBound
-417 // DayLowerBound
},
// Shade
{
497, // ShadeRightBound
167, // ShadeLeftBound
-311, // ShadeUpperBound
-408 // ShadeLowerBound
},
// Daylight Fluorescent
{
167, // DFRightBound
-30, // DFLeftBound
-417, // DFUpperBound
-519 // DFLowerBound
}
},
// PWB light area
{
// Reference area
{
497, // PRefRightBound
-840, // PRefLeftBound
-286, // PRefUpperBound
-519 // PRefLowerBound
},
// Daylight
{
192, // PDayRightBound
-59, // PDayLeftBound
-311, // PDayUpperBound
-417 // PDayLowerBound
},
// Cloudy daylight
{
292, // PCloudyRightBound
117, // PCloudyLeftBound
-311, // PCloudyUpperBound
-417 // PCloudyLowerBound
},
// Shade
{
392, // PShadeRightBound
117, // PShadeLeftBound
-311, // PShadeUpperBound
-417 // PShadeLowerBound
},
// Twilight
{
-59, // PTwiRightBound
-219, // PTwiLeftBound
-311, // PTwiUpperBound
-417 // PTwiLowerBound
},
// Fluorescent
{
187, // PFluoRightBound
-247, // PFluoLeftBound
-320, // PFluoUpperBound
-514 // PFluoLowerBound
},
// Warm fluorescent
{
-208, // PWFluoRightBound
-408, // PWFluoLeftBound
-320, // PWFluoUpperBound
-514 // PWFluoLowerBound
},
// Incandescent
{
-208, // PIncaRightBound
-408, // PIncaLeftBound
-311, // PIncaUpperBound
-417 // PIncaLowerBound
},
// Gray World
{
5000, // PGWRightBound
-5000, // PGWLeftBound
5000, // PGWUpperBound
-5000 // PGWLowerBound
}
},
// PWB default gain
{
// Daylight
{
923, // PWB_Day_R
512, // PWB_Day_G
759 // PWB_Day_B
},
// Cloudy daylight
{
1109, // PWB_Cloudy_R
512, // PWB_Cloudy_G
628 // PWB_Cloudy_B
},
// Shade
{
1185, // PWB_Shade_R
512, // PWB_Shade_G
586 // PWB_Shade_B
},
// Twilight
{
702, // PWB_Twi_R
512, // PWB_Twi_G
1007 // PWB_Twi_B
},
// Fluorescent
{
873, // PWB_Fluo_R
512, // PWB_Fluo_G
930 // PWB_Fluo_B
},
// Warm fluorescent
{
603, // PWB_WFluo_R
512, // PWB_WFluo_G
1363 // PWB_WFluo_B
},
// Incandescent
{
560, // PWB_Inca_R
512, // PWB_Inca_G
1270 // PWB_Inca_B
},
// Gray World
{
512, // PWB_GW_R
512, // PWB_GW_G
512 // PWB_GW_B
}
},
// AWB preference color
{
// Tungsten
{
40, // TUNG_SLIDER
4942 // TUNG_OFFS
},
// Warm fluorescent
{
40, // WFluo_SLIDER
4942 // WFluo_OFFS
},
// Shade
{
50, // Shade_SLIDER
909 // Shade_OFFS
},
// Sunset Area
{
17, // i4Sunset_BoundXr_Thr
-400 // i4Sunset_BoundXr_Thr
},
// Sunset Vertex
{
17, // i4Sunset_VertexXr_Thr
-400 // i4Sunset_VertexXr_Thr
},
// Shade F Area
{
-211, // i4Sunset_BoundXr_Thr
-374 // i4Sunset_BoundXr_Thr
},
// Shade F Vertex
{
-211, // i4Sunset_VertexXr_Thr
-396 // i4Sunset_VertexXr_Thr
},
// Shade CWF Area
{
-211, // i4Sunset_BoundXr_Thr
-468 // i4Sunset_BoundXr_Thr
},
// Shade CWF Vertex
{
-211, // i4Sunset_VertexXr_Thr
-494 // i4Sunset_VertexXr_Thr
},
// Low CCT Area
{
-460, // i4Sunset_BoundXr_Thr
65 // i4Sunset_BoundXr_Thr
},
// Low CCT Vertex
{
-460, // i4Sunset_VertexXr_Thr
65 // i4Sunset_VertexXr_Thr
}
},
// CCT estimation
{
// CCT
{
2300, // CCT0
2850, // CCT1
3750, // CCT2
5100, // CCT3
6500 // CCT4
},
// Rotated X coordinate
{
-577, // RotatedXCoordinate0
-445, // RotatedXCoordinate1
-284, // RotatedXCoordinate2
-153, // RotatedXCoordinate3
0 // RotatedXCoordinate4
}
}
},
// Algorithm Tuning Paramter
{
// AWB Backup Enable
0,
// Daylight locus offset LUTs for tungsten
{
21,// i4Size: LUT dimension
{0, 500, 1000, 1500, 2000, 2500, 3000, 3500, 4000, 4500, 5000, 5500, 6000, 6500, 7000, 7500, 8000, 8500, 9000, 9500, 10000}, // i4LUTIn
{0, 350, 700, 1224, 1224, 1224, 1225, 1225, 1226, 1226, 1227, 1227, 1228, 1228, 1228, 1229, 1229, 1230, 1230, 1231, 1231} // i4LUTOut
},
// Daylight locus offset LUTs for WF
{
21,// i4Size: LUT dimension
{0, 500, 1000, 1500, 2000, 2500, 3000, 3500, 4000, 4500, 5000, 5500, 6000, 6500, 7000, 7500, 8000, 8500, 9000, 9500, 10000}, // i4LUTIn
{0, 350, 700, 850, 1200, 1224, 1225, 1225, 1226, 1226, 1227, 1227, 1228, 1228, 1228, 1229, 1229, 1230, 1230, 1231, 1231} // i4LUTOut
},
// Daylight locus offset LUTs for Shade
{
21,// i4Size: LUT dimension
{0, 500, 1000, 1500, 2000, 2500, 3000, 3500, 4000, 4500, 5000, 5500, 6000, 6500, 7000, 7500, 8000, 8500, 9000, 9500, 10000}, // i4LUTIn
{0, 500, 1000, 1500, 2000, 2500, 3000, 3500, 4000, 4500, 5000, 5500, 6000, 6500, 7000, 7500, 8000, 8500, 9000, 9500, 10000} // i4LUTOut
},
// Preference gain for each light source
{
{
// LV0 LV1 LV2 LV3 LV4 LV5 LV6 LV7 LV8 LV9
{512, 512, 512}, {512, 512, 512}, {512, 512, 512}, {512, 512, 512}, {512, 512, 512}, {512, 512, 512}, {512, 512, 512}, {512, 512, 512}, {512, 512, 512}, {512, 512, 512},
// LV10 LV11 LV12 LV13 LV14 LV15 LV16 LV17 LV18
{512, 512, 512}, {512, 512, 512}, {512, 512, 512}, {512, 512, 512}, {512, 512, 512}, {512, 512, 512}, {512, 512, 512}, {512, 512, 512}, {512, 512, 512}
}, // STROBE
{
// LV0 LV1 LV2 LV3 LV4 LV5 LV6 LV7 LV8 LV9
{530, 530, 480}, {530, 530, 480}, {530, 530, 480}, {530, 530, 480}, {530, 530, 480}, {520, 520, 496}, {512, 512, 512}, {512, 512, 512}, {512, 512, 512}, {512, 512, 512},
// LV10 LV11 LV12 LV13 LV14 LV15 LV16 LV17 LV18
{512, 512, 512}, {512, 512, 512}, {512, 512, 512}, {512, 512, 512}, {512, 512, 512}, {512, 512, 512}, {512, 512, 512}, {512, 512, 512}, {512, 512, 512}
}, // TUNGSTEN
{
// LV0 LV1 LV2 LV3 LV4 LV5 LV6 LV7 LV8 LV9
{512, 512, 508}, {512, 512, 508}, {512, 512, 508}, {512, 512, 508}, {512, 512, 508}, {512, 512, 508}, {512, 512, 508}, {512, 512, 508}, {512, 512, 508}, {512, 512, 508},
// LV10 LV11 LV12 LV13 LV14 LV15 LV16 LV17 LV18
{512, 512, 508}, {512, 512, 512}, {512, 512, 512}, {512, 512, 512}, {512, 512, 512}, {512, 512, 512}, {512, 512, 512}, {512, 512, 512}, {512, 512, 512}
}, // WARM F
{
// LV0 LV1 LV2 LV3 LV4 LV5 LV6 LV7 LV8 LV9
{512, 512, 512}, {512, 512, 512}, {512, 512, 512}, {512, 512, 512}, {512, 512, 512}, {512, 512, 512}, {512, 512, 512}, {512, 512, 512}, {512, 512, 512}, {512, 512, 512},
// LV10 LV11 LV12 LV13 LV14 LV15 LV16 LV17 LV18
{512, 512, 512}, {512, 512, 512}, {512, 512, 512}, {512, 512, 512}, {502, 512, 512}, {502, 512, 512}, {502, 512, 512}, {502, 512, 512}, {502, 512, 512}
}, // F
{
// LV0 LV1 LV2 LV3 LV4 LV5 LV6 LV7 LV8 LV9
{512, 512, 512}, {512, 512, 512}, {512, 512, 512}, {512, 512, 512}, {512, 512, 512}, {512, 512, 512}, {512, 512, 512}, {512, 512, 512}, {512, 512, 512}, {512, 512, 512},
// LV10 LV11 LV12 LV13 LV14 LV15 LV16 LV17 LV18
{512, 512, 512}, {512, 512, 512}, {512, 512, 512}, {512, 512, 512}, {512, 512, 512}, {512, 512, 512}, {512, 512, 512}, {512, 512, 512}, {512, 512, 512}
}, // CWF
{
// LV0 LV1 LV2 LV3 LV4 LV5 LV6 LV7 LV8 LV9
{512, 512, 512}, {512, 512, 512}, {512, 512, 512}, {512, 512, 512}, {512, 512, 512}, {512, 512, 512}, {512, 512, 512}, {512, 512, 512}, {512, 512, 512}, {512, 512, 512},
// LV10 LV11 LV12 LV13 LV14 LV15 LV16 LV17 LV18
{512, 512, 512}, {512, 512, 512}, {512, 512, 512}, {512, 512, 512}, {502, 512, 512}, {502, 512, 512}, {502, 512, 512}, {502, 512, 512}, {502, 512, 512}
}, // DAYLIGHT
{
// LV0 LV1 LV2 LV3 LV4 LV5 LV6 LV7 LV8 LV9
{512, 512, 512}, {512, 512, 512}, {512, 512, 512}, {512, 512, 512}, {512, 512, 512}, {512, 512, 512}, {512, 512, 512}, {512, 512, 512}, {512, 512, 512}, {512, 512, 512},
// LV10 LV11 LV12 LV13 LV14 LV15 LV16 LV17 LV18
{512, 512, 512}, {512, 512, 512}, {512, 512, 512}, {512, 512, 512}, {512, 512, 512}, {512, 512, 512}, {512, 512, 512}, {512, 512, 512}, {512, 512, 512}
}, // SHADE
{
// LV0 LV1 LV2 LV3 LV4 LV5 LV6 LV7 LV8 LV9
{512, 512, 512}, {512, 512, 512}, {512, 512, 512}, {512, 512, 512}, {512, 512, 512}, {512, 512, 512}, {512, 512, 512}, {512, 512, 512}, {512, 512, 512}, {512, 512, 512},
// LV10 LV11 LV12 LV13 LV14 LV15 LV16 LV17 LV18
{512, 512, 512}, {512, 512, 512}, {512, 512, 512}, {512, 512, 512}, {512, 512, 512}, {512, 512, 512}, {512, 512, 512}, {512, 512, 512}, {512, 512, 512}
} // DAYLIGHT F
},
// Parent block weight parameter
{
1, // bEnable
6 // i4ScalingFactor: [6] 1~12, [7] 1~6, [8] 1~3, [9] 1~2, [>=10]: 1
},
// AWB LV threshold for predictor
{
115, // i4InitLVThr_L
155, // i4InitLVThr_H
100 // i4EnqueueLVThr
},
// AWB number threshold for temporal predictor
{
65, // i4Neutral_ParentBlk_Thr
//LV0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
{ 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 50, 25, 2, 2, 2, 2, 2, 2, 2} // i4CWFDF_LUTThr
},
// AWB light neutral noise reduction for outdoor
{
//LV0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
// Non neutral
{ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 5, 10, 10, 10, 10, 10, 10, 10, 10}, //
// Flurescent
{ 0, 0, 0, 0, 0, 3, 5, 5, 5, 5, 5, 10, 10, 10, 10, 10, 10, 10, 10}, //
// CWF
{ 0, 0, 0, 0, 0, 3, 5, 5, 5, 5, 5, 10, 10, 10, 10, 10, 10, 10, 10}, //
// Daylight
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 2, 2, 2, 2, 2}, //
// DF
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 10, 10, 10, 10, 10, 10, 10, 10} //
},
// AWB feature detection
{
// Sunset Prop
{
1, // i4Enable
120, // i4LVThr_L
130, // i4LVThr_H
10, // i4SunsetCountThr
0, // i4SunsetCountRatio_L
171 // i4SunsetCountRatio_H
},
// Shade F Detection
{
1, // i4Enable
55, // i4LVThr_L
70, // i4LVThr_H
96 // i4DaylightProb
},
// Shade CWF Detection
{
1, // i4Enable
55, // i4LVThr_L
70, // i4LVThr_H
192 // i4DaylightProb
},
// Low CCT
{
0, // i4Enable
256 // i4SpeedRatio
}
},
// AWB non-neutral probability for spatial and temporal weighting look-up table (Max: 100; Min: 0)
{
//LV0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
{ 0, 33, 66, 100, 100, 100, 100, 100, 100, 100, 100, 70, 30, 20, 10, 0, 0, 0, 0}
},
// AWB daylight locus probability look-up table (Max: 100; Min: 0)
{
//LV0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
{ 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 50, 25, 0, 0, 0, 0}, // Strobe
{ 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 75, 50, 25, 0, 0, 0}, // Tungsten
{ 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 75, 50, 25, 25, 25, 0, 0, 0}, // Warm fluorescent
{ 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 95, 75, 50, 25, 25, 25, 0, 0, 0}, // Fluorescent
{ 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 80, 55, 30, 30, 30, 30, 0, 0, 0}, // CWF
{ 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 75, 50, 40, 30, 20}, // Daylight
{ 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 75, 50, 25, 0, 0, 0, 0}, // Shade
{ 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 80, 55, 30, 30, 30, 30, 0, 0, 0} // Daylight fluorescent
}
}
}
},
// Flash AWB NVRAM
{
#include INCLUDE_FILENAME_FLASH_AWB_PARA
},
{0} //FIXED
};
#include INCLUDE_FILENAME_ISP_LSC_PARAM
//}; // namespace
const CAMERA_TSF_TBL_STRUCT CAMERA_TSF_DEFAULT_VALUE =
{
{
1, // isTsfEn
2, // tsfCtIdx
{20, 2000, -110, -110, 512, 512, 512, 0} // rAWBInput[8]
},
#include INCLUDE_FILENAME_TSF_PARA
#include INCLUDE_FILENAME_TSF_DATA
};
typedef NSFeature::RAWSensorInfo<SENSOR_ID> SensorInfoSingleton_T;
namespace NSFeature {
template <>
UINT32
SensorInfoSingleton_T::
impGetDefaultData(CAMERA_DATA_TYPE_ENUM const CameraDataType, VOID*const pDataBuf, UINT32 const size) const
{
UINT32 dataSize[CAMERA_DATA_TYPE_NUM] = {sizeof(NVRAM_CAMERA_ISP_PARAM_STRUCT),
sizeof(NVRAM_CAMERA_3A_STRUCT),
sizeof(NVRAM_CAMERA_SHADING_STRUCT),
sizeof(NVRAM_LENS_PARA_STRUCT),
sizeof(AE_PLINETABLE_T),
0,
sizeof(CAMERA_TSF_TBL_STRUCT)};
if (CameraDataType > CAMERA_DATA_TSF_TABLE || NULL == pDataBuf || (size < dataSize[CameraDataType]))
{
return 1;
}
switch(CameraDataType)
{
case CAMERA_NVRAM_DATA_ISP:
memcpy(pDataBuf,&CAMERA_ISP_DEFAULT_VALUE,sizeof(NVRAM_CAMERA_ISP_PARAM_STRUCT));
break;
case CAMERA_NVRAM_DATA_3A:
memcpy(pDataBuf,&CAMERA_3A_NVRAM_DEFAULT_VALUE,sizeof(NVRAM_CAMERA_3A_STRUCT));
break;
case CAMERA_NVRAM_DATA_SHADING:
memcpy(pDataBuf,&CAMERA_SHADING_DEFAULT_VALUE,sizeof(NVRAM_CAMERA_SHADING_STRUCT));
break;
case CAMERA_DATA_AE_PLINETABLE:
memcpy(pDataBuf,&g_PlineTableMapping,sizeof(AE_PLINETABLE_T));
break;
case CAMERA_DATA_TSF_TABLE:
memcpy(pDataBuf,&CAMERA_TSF_DEFAULT_VALUE,sizeof(CAMERA_TSF_TBL_STRUCT));
break;
default:
return 1;
}
return 0;
}}; // NSFeature
| [
"skyrimus@yandex.ru"
] | skyrimus@yandex.ru |
bd17bc9a80ab7ce4d601218330bd0c23b5fecb85 | 06eb60c98f4d106fc3bb3d0b7e990828b87d714d | /Source/WebCore/html/HTMLTableCaptionElement.cpp | afddb0850cb0257302b31043f2efec70daa44134 | [] | no_license | snyh/dui | 9486a81d97ec1173b161b6aef8fcea21066aebff | c4464629f1efdecae792ed3abc2a7fc9ce9b88db | refs/heads/master | 2021-01-25T08:28:55.224303 | 2013-10-23T00:42:02 | 2013-10-23T00:42:02 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,285 | cpp | /*
* Copyright (C) 1997 Martin Jones (mjones@kde.org)
* (C) 1997 Torben Weis (weis@kde.org)
* (C) 1998 Waldo Bastian (bastian@kde.org)
* (C) 1999 Lars Knoll (knoll@kde.org)
* (C) 1999 Antti Koivisto (koivisto@kde.org)
* Copyright (C) 2003, 2004, 2005, 2006, 2010 Apple Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#include "config.h"
#include "html/HTMLTableCaptionElement.h"
#include "dom/Attribute.h"
#include "CSSPropertyNames.h"
#include "HTMLNames.h"
namespace WebCore {
using namespace HTMLNames;
inline HTMLTableCaptionElement::HTMLTableCaptionElement(const QualifiedName& tagName, Document* document)
: HTMLElement(tagName, document)
{
ASSERT(hasTagName(captionTag));
}
PassRefPtr<HTMLTableCaptionElement> HTMLTableCaptionElement::create(const QualifiedName& tagName, Document* document)
{
return adoptRef(new HTMLTableCaptionElement(tagName, document));
}
bool HTMLTableCaptionElement::isPresentationAttribute(const QualifiedName& name) const
{
if (name == alignAttr)
return true;
return HTMLElement::isPresentationAttribute(name);
}
void HTMLTableCaptionElement::collectStyleForPresentationAttribute(const QualifiedName& name, const AtomicString& value, MutableStylePropertySet* style)
{
if (name == alignAttr) {
if (!value.isEmpty())
addPropertyToPresentationAttributeStyle(style, CSSPropertyCaptionSide, value);
} else
HTMLElement::collectStyleForPresentationAttribute(name, value, style);
}
}
| [
"snyh@snyh.org"
] | snyh@snyh.org |
38033a94d654f1e6edf3374cc2b333d188b83dd5 | 67d1423c1f69e2c98655d0c401c1ef3b1c1f9801 | /OpenCV_app/template/src/main.cpp | d6e8aeeb8c3575d2a65377b11a35bc44635738c9 | [] | no_license | biotrump/VinjinGit | 7065639434b2c88fe6bd83f04c14b6ac3fb351a9 | b079df0d121b8381e44af788f9d8ab67f2ea1666 | refs/heads/master | 2021-01-21T04:00:13.032124 | 2012-06-13T09:01:28 | 2012-06-13T09:01:28 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 355 | cpp | #include "../../../_common/vOpenCV/OpenCV.h"
VideoInput input;
using namespace cv;
int main(int argc, char** argv )
{
if (input.init(argc,argv))
{
while (true)
{
IplImage* _raw = input.get_frame();
if (!_raw)
break;
Mat raw = _raw;
show_mat(raw);
int key = waitKey(1);
if (key == 0x1B)
break;
}
}
return 0;
}
| [
"pluto4332@gmail.com"
] | pluto4332@gmail.com |
6f2627b56c1b4a349b83b343fc31a9022379095d | 0031755c0b6b1575af666b07b0e86ba0825f6bb7 | /LeetCode problems/Binary Search/Search in Rotated Sorted Array.cpp | fbfcb2b7036b4af9f9ba716fbe4752ec09985b08 | [] | no_license | lalshrikant12/Competitive-Coding- | 871c79d07037435ecb1e394b3355664276b23fcd | c7f69ad13680d6fc2efd5e22f19d2a8860e27d66 | refs/heads/master | 2023-06-07T04:21:10.048630 | 2021-06-17T19:30:42 | 2021-06-17T19:30:42 | 208,581,485 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 685 | cpp | class Solution {
public:
int search(vector<int>& nums, int target) {
int l=0;
int u=nums.size()-1;
while(l<=u)
{
int mid=l+(u-l)/2;
if(nums[mid]==target)
return mid;
else if(nums[mid]>=nums[l])
{
if(target<=nums[mid] && target>=nums[l])
{u=mid-1;}
else
l=mid+1;
}
else
{ if(target>=nums[mid] && target<=nums[u])
l=mid+1;
else
u=mid-1;
}
}
return -1;
}
};
| [
"noreply@github.com"
] | noreply@github.com |
74308bfc6131072df2379afa34ccb2ab16b9588a | 9e34e84c20760a9a37512c675074974ac7e56275 | /more-source/arithmetics/085_edinichnyi_nod.cpp | 3753d26aebedd64255723bea50900c1b6562f214 | [] | no_license | Slava/competitiveProgramming | 2b7f26bf24143b459c6e2625ef1ea343a926bb76 | b68391720b9f9efc4162a66ca07d9448cffc1453 | refs/heads/master | 2021-01-21T12:40:40.053352 | 2020-01-06T19:21:45 | 2020-01-06T19:21:45 | 9,552,080 | 8 | 6 | null | null | null | null | UTF-8 | C++ | false | false | 424 | cpp | // Kim Vyacheslav Karaganda KTL
// 2010
#include <cstdio>
int n, m, a;
int nod (int a, int b)
{
while (a && b)
{
if (a > b)
a %= b;
else b %= a;
}
return a + b;
}
int main ()
{
freopen ("input.txt", "r", stdin);
freopen ("output.txt", "w", stdout);
scanf ("%d%d", &n, &m);
a = nod (n, m);
for (int i = 0; i < a; i++)
printf ("1");
return 0;
}
| [
"slava@meteor.com"
] | slava@meteor.com |
ba2b767c3ea9edf088c3e177eb842886b06c390f | df3844b430da6a81183698146d73dab225f71d93 | /src/tilenode.h | edfbbdd7c949bf100d201b5fa0bdb7d228534552 | [] | no_license | AlienKevin/Tiles | 54a70284d63581ad968d3f0ab56d2950ecf01f23 | f09d1670c2085f42b98f22c322599ff2b7d31309 | refs/heads/master | 2020-06-30T19:51:23.027485 | 2019-08-07T01:58:16 | 2019-08-07T01:58:16 | 200,935,362 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,198 | h | /*
* CS 106B/X Tiles
* This file contains the declaration of the TileNode structure.
*
* Please DO NOT MODIFY this provided file. Your turned-in files should work
* with an unmodified version of all provided code files.
*
* @author Marty Stepp
* @version 2019/05/16
* - 19sp 106B initial version
* @version 2018/11/01
* - 18au 106B initial version
* @version 2016/11/03
* - 16au 106X version
*/
#ifndef _tilenode_h
#define _tilenode_h
#include <iostream>
#include <string>
#include "gobjects.h"
#include "gwindow.h"
/**
* Each TileNode structure represents a single rectangular tile in the simulation.
* A tile knows its position, size, and color.
* It contains members that can draw itself, tell you whether it touches a
* given x/y pixel, and print it on the console for debugging.
* Tile nodes have prev/next pointers so they can be used in a doubly-linked list.
*/
struct TileNode {
public:
int x; // (x, y) position of tile's top-left corner
int y;
int width; // tile's dimensions in pixels
int height;
std::string color; // tile's color as a hex RRGGBB string like "#ff00ff" for purple
TileNode* prev; // previous tile node pointer, if any
TileNode* next; // next tile node pointer, if any
/**
* Constructor initializes all members to have the given values.
* All parameters are optional;
* any omitted parameters will be set to zero-equivalent values.
*
* Examples:
* TileNode* node1 = new TileNode(x, y, w, h, color);
* TileNode* node2 = new TileNode(x, y, w, h, color, prev, next);
*/
TileNode(int x = 0,
int y = 0,
int width = 0,
int height = 0,
std::string color = "",
TileNode* prev = nullptr,
TileNode* next = nullptr);
/** Destructor; called implicitly when nodes are deleted. */
~TileNode();
/** Returns true if the given x/y coordinate is found inside the tile. */
bool contains(int x, int y) const;
/** Draws the tile on the given window. */
void draw(GWindow& window) const;
/**
* Returns a string representation of the tile in the format of operator <<.
*/
std::string toString() const;
private:
// unique number of each node; set internally
const int number;
// counters of all nodes that have ever been created; not for student use
static int nextNodeNumber;
static int instanceCount;
// declare operator << as friend so it can see node number variable
friend std::ostream& operator <<(std::ostream& out, const TileNode& node);
// helper methods for grading; not for student use
static int getInstanceCount();
static void resetInstanceCount();
};
/**
* Outputs the given tile to the given output stream (e.g. cout) in the same
* format as returned by its toString member function.
* The tile's memory address, data, and next pointer are all printed.
*
* If you have a non-null pointer TileNode* p, you can print the node by writing:
* cout << *p << endl;
*/
std::ostream& operator <<(std::ostream& out, const TileNode& node);
#endif // _tilenode_h
| [
"kevinli020508@gmail.com"
] | kevinli020508@gmail.com |
351d3f56c0bd6fffde030feb75927d1714be12d6 | 45e0fbd9a9dbcdd4fbe6aaa2fdb2aed296f81e33 | /FindSecret/Classes/Native/Mono_Security_Mono_Security_X509_X509StoreManager1046782375.h | a515c427d252a669e381050905211aa1fd613407 | [
"MIT"
] | permissive | GodIsWord/NewFindSecret | d4a5d2d810ee1f9d6b3bc91168895cc808bac817 | 4f98f316d29936380f9665d6a6d89962d9ee5478 | refs/heads/master | 2020-03-24T09:54:50.239014 | 2018-10-27T05:22:11 | 2018-10-27T05:22:11 | 142,641,511 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,931 | h | #pragma once
#include "il2cpp-config.h"
#ifndef _MSC_VER
# include <alloca.h>
#else
# include <malloc.h>
#endif
#include <stdint.h>
#include "mscorlib_System_Object3080106164.h"
// Mono.Security.X509.X509Stores
struct X509Stores_t1373936238;
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// Mono.Security.X509.X509StoreManager
struct X509StoreManager_t1046782376 : public Il2CppObject
{
public:
public:
};
struct X509StoreManager_t1046782376_StaticFields
{
public:
// Mono.Security.X509.X509Stores Mono.Security.X509.X509StoreManager::_userStore
X509Stores_t1373936238 * ____userStore_0;
// Mono.Security.X509.X509Stores Mono.Security.X509.X509StoreManager::_machineStore
X509Stores_t1373936238 * ____machineStore_1;
public:
inline static int32_t get_offset_of__userStore_0() { return static_cast<int32_t>(offsetof(X509StoreManager_t1046782376_StaticFields, ____userStore_0)); }
inline X509Stores_t1373936238 * get__userStore_0() const { return ____userStore_0; }
inline X509Stores_t1373936238 ** get_address_of__userStore_0() { return &____userStore_0; }
inline void set__userStore_0(X509Stores_t1373936238 * value)
{
____userStore_0 = value;
Il2CppCodeGenWriteBarrier(&____userStore_0, value);
}
inline static int32_t get_offset_of__machineStore_1() { return static_cast<int32_t>(offsetof(X509StoreManager_t1046782376_StaticFields, ____machineStore_1)); }
inline X509Stores_t1373936238 * get__machineStore_1() const { return ____machineStore_1; }
inline X509Stores_t1373936238 ** get_address_of__machineStore_1() { return &____machineStore_1; }
inline void set__machineStore_1(X509Stores_t1373936238 * value)
{
____machineStore_1 = value;
Il2CppCodeGenWriteBarrier(&____machineStore_1, value);
}
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
| [
"zhangyide@9fbank.cc"
] | zhangyide@9fbank.cc |
38503c1bf8c562ff9eaed261e55f7416afafc0d3 | 1b06ceff42b0aba24ed17d95198d14b52aeddd8d | /mpu6050_driver/src/MPU6050.cpp | 81df81c932e78c05bf7100dda9fc4290850683a6 | [] | no_license | TaiAreerob/MPU6050_eigen_ros | e583c3dcdb360c8743c2fd7721ee431d9cca4e5a | bd55b986848532c4f7d791ba43dac0f82fb7a4a2 | refs/heads/master | 2021-07-16T02:38:29.547757 | 2017-10-19T12:46:06 | 2017-10-19T12:46:06 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,337 | cpp | #include "MPU6050.h"
#include <Eigen/Core>
// Eigen 几何模块
#include <Eigen/Geometry>
float InvSqrt(float number)
{
volatile long i;
volatile float x, y;
volatile const float f = 1.5F;
x = number * 0.5F;
y = number;
i = * (( long * ) &y);
i = 0x5f375a86 - ( i >> 1 );
y = * (( float * ) &i);
y = y * ( f - ( x * y * y ) );
return y;
}
Eigen::Matrix4d get_Rw( Eigen::Vector3d w)
{
Eigen::Matrix4d Rw;
Rw << 0, -w(0),-w(1),-w(2),
w(0), 0, -w(2), w(1),
w(1), w(2), 0, -w(0),
w(2),-w(1), w(0), 0;
return Rw;
}
MPU6050::MPU6050()
{
data_ready = false;
mpu6050_bias_initialized = false;
error_sum.setZero();
set_bias(Eigen::Vector3d(0,0,0), Eigen::Vector3d(0,0,0));
q.w() = 1;
q.x() = 0;
q.y() = 0;
q.z() = 0;
}
MPU6050::~MPU6050()
{
}
void MPU6050::reset(void)
{
data_ready = false;
mpu6050_bias_initialized = false;
error_sum.setZero();
}
void MPU6050::set_bias(Eigen::Vector3d accel, Eigen::Vector3d gyro)
{
acc_bias = accel;
gyro_bias = gyro;
mpu6050_bias_initialized = true;
}
void MPU6050::data_received(Eigen::Vector3d accel, Eigen::Vector3d gyro, unsigned int t)
{
acceleration = accel;
gyroscope = gyro;
stamp = t;
}
Eigen::Vector3d MPU6050::get_RPY(void)
{
return RPY;
}
Eigen::Quaterniond MPU6050::get_q(void)
{
return q;
}
void MPU6050::estimate_gestureByAccel(Eigen::Vector3d accel)
{
if(mpu6050_bias_initialized)
{
accel -= acc_bias;
}
//用加速度计数据来估计初始状态
}
bool MPU6050::MahonyUpdate(Eigen::Vector3d accel, Eigen::Vector3d gyro)
{
double dt = 0.005; //s
double Kp = 0.5, Ki = 0.025;
if(mpu6050_bias_initialized)
{
gyro -= gyro_bias;
//accel -= acc_bias;
}
if( !((accel(0) == 0.0f) && (accel(1) == 0.0f) && (accel(2) == 0.0f)) )
{
//这里参考向量是重力,假设物体只受重力加速度,忽略其他加速度
//先把重力g_navigation(0,0,1)转换到载体坐标系g_b
//g_b再与在载体坐标系下测得的accel对比
accel = -accel;
accel /= accel.norm();
Eigen::Matrix3d rotation_matrix_b2n(q);
Eigen::Vector3d g_n(0.0, 0.0, 1.0);
Eigen::Vector3d g_b = rotation_matrix_b2n.transpose()* g_n;
Eigen::Vector3d error = g_b.cross(accel);
error_sum = error*Ki;
gyro += error*Kp + error_sum;
}
float qw = q.w(), qx = q.x(), qy = q.y(), qz = q.z();
//后面等式的+=中,q的数据已经变了,所以上面定义四个变量存储
q.w() += 0.5*dt*(-qx * gyro(0) - qy * gyro(1) - qz * gyro(2));
q.x() += 0.5*dt*(qw * gyro(0) + qy * gyro(2) - qz * gyro(1));
q.y() += 0.5*dt*(qw * gyro(1) - qx * gyro(2) + qz * gyro(0));
q.z() += 0.5*dt*(qw * gyro(2) + qx * gyro(1) - qy * gyro(0));
q.normalized();
RPY(0) = atan2(2 * q.y() * q.z() + 2 * q.w() * q.x(), -2 * q.x() * q.x() - 2 * q.y()* q.y() + 1)* 57.3; // roll
RPY(1) = asin(-2 * q.x() * q.z() + 2 * q.w()* q.y())* 57.3; // pitch
RPY(2) = atan2(2 * q.x() * q.y() + 2 * q.w() * q.z(), -2 * q.y()*q.y() - 2 * q.z()* q.z() + 1)* 57.3; // yaw
if(RPY(2) >= 0.0f)
RPY(2) = 180 - RPY(2);
else
RPY(2) = -180 - RPY(2);
return true;
}
| [
"noreply@github.com"
] | noreply@github.com |
db9f7af1c22aa9725130d54c8dc5b03500e1a07f | b9bb550998dbe02e388ad0a378a80e99c4304a55 | /Entwicklung/17.8.2020/swTimer - local/src/Ultraschall.h | 9b50cdf3155c7b37bd1cff039afe2ad4b25b2646 | [] | no_license | geisterfahrerSOS/IFM_wettbewerb | f5690f9ab9578673572332e8e4568dae5eb7db3f | bdc952ee1c5718e4b08ba18c5302fbe94fec7f00 | refs/heads/master | 2022-11-30T20:26:38.080077 | 2020-08-06T00:19:26 | 2020-08-06T00:19:26 | 240,559,420 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 283 | h | /*
get distance
*/
#ifndef Ultraschall_h
#define Ultraschall_h
#include <Arduino.h>
class Ultraschall
{
private:
public:
int echo, trigger;
Ultraschall();
Ultraschall(int aEcho, int aTrigger);
float getDistanz();
};
#endif | [
"nils@hoelzle-wangen.de"
] | nils@hoelzle-wangen.de |
d48441772e8623e6e15a3d252f6fdd55a5524c18 | 74cbdb5e8cd695ad9eb3ae701d7fc6bf4455bb4c | /5.Estructura-SWITCH/27.Signo-Zodiacal/main.cpp | 89118e442c0299b88d1153fc7d79fd9870b88938 | [] | no_license | salvador-murillo/Fundamentos-Programacion | d13b6a621751422bbfc44396c41f3f9ee4d5fff6 | b8a34dee6233889986cd1d83dfaa64b937b784e5 | refs/heads/master | 2023-03-13T18:43:38.030535 | 2021-03-09T06:45:31 | 2021-03-09T06:45:31 | 345,779,079 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,498 | cpp | /*FUNDAMENTOS DE PROGRAMACION
Practica 27 - Signo Zodiacal
Salvador Murillo Arias
*/
// cout << "\033[2J\033[0;0H";//Limpia Pantalla
#include <iostream>
using namespace std;
int main() {
int mes, dia;
cout << "\033[2J\033[0;0H";
cout << "\t\tSIGNO ZODIACAL\n\n";
cout << "Ingresa el dia en que naciste (#): ";
cin >> dia;
if (dia>=1 && dia<=31){
cout << "Ingresa el mes en que naciste (#): ";
cin >> mes;
if(mes>=1 && mes<=12){
switch (mes){
case 1:
if(dia>=1 && dia<=19){
cout << "\nTu signo es CAPRICORNIO";
}else if(dia>=20 && dia<=31){
cout << "\nTu signo es ACUARIO";
}
break;
case 2:
if(dia>=1 && dia<=18){
cout << "\nTu signo es ACUARIO";
}else if(dia>=19 && dia<=29){
cout << "\nTu signo es PISCIS";
}else{
cout << "\nQue verbo eres, no existe este dia xD.";
}
break;
case 3:
if(dia>=1 && dia<=20){
cout << "\nTu signo es PISCIS";
}else if(dia>=21 && dia<=31){
cout << "\nTu signo es ARIES";
}
break;
case 4:
if(dia>=1 && dia<=19){
cout << "\nTu signo es ARIES";
}else if(dia>=20 && dia<=30){
cout << "\nTu signo es TAURO";
}else{
cout << "\nQue verbo eres, no existe este dia xD.";
}
break;
case 5:
if(dia>=1 && dia<=20){
cout << "\nTu signo es TAURO";
}else if(dia>=21 && dia<=31){
cout << "\nTu signo es GEMINIS";
}
break;
case 6:
if(dia>=1 && dia<=20){
cout << "\nTu signo es GEMINIS";
}else if(dia>=21 && dia<=30){
cout << "\nTu signo es CANCER";
}else{
cout << "\nQue verbo eres, no existe este dia xD.";
}
break;
case 7:
if(dia>=1 && dia<=22){
cout << "\nTu signo es CANCER";
}else if(dia>=23 && dia<=31){
cout << "\nTu signo es LEO";
}
break;
case 8:
if(dia>=1 && dia<=22){
cout << "\nTu signo es LEO";
}else if(dia>=23 && dia<=31){
cout << "\nTu signo es VIRGO";
}
break;
case 9:
if(dia>=1 && dia<=22){
cout << "\nTu signo es VIRGO";
}else if(dia>=23 && dia<=30){
cout << "\nTu signo es LIBRA";
}else{
cout << "\nQue verbo eres, no existe este dia xD.";
}
break;
case 10:
if(dia>=1 && dia<=22){
cout << "\nTu signo es LIBRA";
}else if(dia>=23 && dia<=31){
cout << "\nTu signo es ESCORPION";
}
break;
case 11:
if(dia>=1 && dia<=21){
cout << "\nTu signo es ESCORPION";
}else if(dia>=22 && dia<=30){
cout << "\nTu signo es SAGITARIO";
}else{
cout << "\nQue verbo eres, no existe este dia xD.";
}
break;
case 12:
if(dia>=1 && dia<=21){
cout << "\nTu signo es SAGITARIO";
}else if(dia>=22 && dia<=31){
cout << "\nTu signo es CAPRICORNIO";
}
break;
}
}else{
cout << "\nEl mes ingresado no es valido.";
}
}else{
cout << "\nEl dia ingresado no es valido.";
}
}
| [
"murilloariass@hotmail.com"
] | murilloariass@hotmail.com |
bd6ac267f9fd2b7ca46c862e22550c531eb5847e | e360c74cd0719b34dfe022dce3e0ec01ffc69941 | /ODESolve/Source/h/ODESolve.h | 8d2bc9c7ebb8ddfbaa7cc6a022c57b77b757b04a | [] | no_license | jve18/Numerical-Methods-Library-cpp- | 47cf83cadaef6da253c22a85cfe05404b570f8e3 | 2a88fa8f4542e3f3d6a7b9e054e8f537497d40b4 | refs/heads/master | 2021-07-22T18:56:08.812953 | 2020-04-25T15:35:29 | 2020-04-25T15:35:29 | 146,024,785 | 0 | 0 | null | 2018-09-26T02:54:41 | 2018-08-24T18:11:01 | C++ | UTF-8 | C++ | false | false | 168 | h | #include <cmath>
#include <vector>
using namespace std;
vector <double> ODESolve_RK4(double (*dy)(double, double), double x0, double y0, double xmax, double dx); | [
"noreply@github.com"
] | noreply@github.com |
18dc67b1d40eb0f25b94be79864313923a29dd30 | 6fd51dff02b695d2411f4bed44f929ba608a818f | /weiboitcast/weiboitcast02/jni/cocos2dx/platform/android/CCEGLView_android.cpp | 535c3d22d8eb3c1f26115e5d69cf258307e38b45 | [] | no_license | yeungeek/LearnDroid | ae28b6c11751fa42bd7c661a0fa30f21d28eb300 | 38b9a12e8169183ac94c719643e78aa191a7c698 | refs/heads/master | 2021-01-25T07:28:14.369564 | 2014-11-05T15:07:43 | 2014-11-05T15:07:43 | 4,771,042 | 2 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 5,011 | cpp | /****************************************************************************
Copyright (c) 2010 cocos2d-x.org
http://www.cocos2d-x.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
#include "CCEGLView_android.h"
#include "GLES/gl.h"
#include "CCSet.h"
#include "CCDirector.h"
#include "ccMacros.h"
#include "CCTouchDispatcher.h"
#include "Cocos2dJni.h"
#include <stdlib.h>
namespace cocos2d {
CCEGLView::CCEGLView()
: m_bNotHVGA(false),
m_pDelegate(NULL),
m_fScreenScaleFactor(1.0)
{
}
void CCEGLView::setFrameWidthAndHeight(int width, int height)
{
m_sSizeInPixel.width = width;
m_sSizeInPixel.height = height;
}
void CCEGLView::create(int width, int height)
{
if (width == 0 || height == 0)
{
return;
}
m_sSizeInPoint.width = width;
m_sSizeInPoint.height = height;
// calculate the factor and the rect of viewport
m_fScreenScaleFactor = MIN((float)m_sSizeInPixel.width / m_sSizeInPoint.width,
(float)m_sSizeInPixel.height / m_sSizeInPoint.height);
int viewPortW = (int)(m_sSizeInPoint.width * m_fScreenScaleFactor);
int viewPortH = (int)(m_sSizeInPoint.height * m_fScreenScaleFactor);
m_rcViewPort.origin.x = (m_sSizeInPixel.width - viewPortW) / 2;
m_rcViewPort.origin.y = (m_sSizeInPixel.height - viewPortH) / 2;
m_rcViewPort.size.width = viewPortW;
m_rcViewPort.size.height = viewPortH;
m_bNotHVGA = true;
}
CCEGLView::~CCEGLView()
{
CC_SAFE_DELETE(m_pDelegate);
}
CCSize CCEGLView::getSize()
{
if (m_bNotHVGA)
{
CCSize size(m_sSizeInPoint.width, m_sSizeInPoint.height);
return size;
}
else
{
CCSize size(m_sSizeInPixel.width, m_sSizeInPixel.height);
return size;
}
}
bool CCEGLView::isOpenGLReady()
{
return (m_sSizeInPixel.width != 0 && m_sSizeInPixel.height != 0);
}
void CCEGLView::release()
{
exit(0);
}
void CCEGLView::setTouchDelegate(EGLTouchDelegate * pDelegate)
{
m_pDelegate = pDelegate;
}
EGLTouchDelegate* CCEGLView::getDelegate(void)
{
return m_pDelegate;
}
void CCEGLView::swapBuffers()
{
}
bool CCEGLView::canSetContentScaleFactor()
{
// can scale content?
return false;
}
void CCEGLView::setContentScaleFactor(float contentScaleFactor)
{
m_fScreenScaleFactor = contentScaleFactor;
}
void CCEGLView::setViewPortInPoints(float x, float y, float w, float h)
{
if (m_bNotHVGA)
{
float factor = m_fScreenScaleFactor / CC_CONTENT_SCALE_FACTOR();
glViewport((GLint)(x * factor) + m_rcViewPort.origin.x,
(GLint)(y * factor) + m_rcViewPort.origin.y,
(GLint)(w * factor),
(GLint)(h * factor));
}
else
{
glViewport((GLint)x,
(GLint)y,
(GLint)w,
(GLint)h);
}
}
void CCEGLView::setScissorInPoints(float x, float y, float w, float h)
{
if (m_bNotHVGA)
{
float factor = m_fScreenScaleFactor / CC_CONTENT_SCALE_FACTOR();
glScissor((GLint)(x * factor) + m_rcViewPort.origin.x,
(GLint)(y * factor) + m_rcViewPort.origin.y,
(GLint)(w * factor),
(GLint)(h * factor));
}
else
{
glScissor((GLint)x,
(GLint)y,
(GLint)w,
(GLint)h);
}
}
CCEGLView& CCEGLView::sharedOpenGLView()
{
static CCEGLView instance;
return instance;
}
float CCEGLView::getScreenScaleFactor()
{
return m_fScreenScaleFactor;
}
CCRect CCEGLView::getViewPort()
{
if (m_bNotHVGA)
{
return m_rcViewPort;
}
else
{
CCRect rect(0, 0, 0, 0);
return rect;
}
}
void CCEGLView::setIMEKeyboardState(bool bOpen)
{
setKeyboardStateJNI((int)bOpen);
}
} // end of namespace cocos2d
| [
"yeungeek@yeungeek.(none)"
] | yeungeek@yeungeek.(none) |
6a23840e7f031edeef9db5cb05e336159ed874c8 | e359db0e752a11c5d677e3a82574065831bab447 | /app/demo/touchgfx_demo2014_480x272/generated/texts/src/TypedTextDatabase.cpp | 36b9b99419e5f775a724baaf67ef0f65bc418343 | [] | no_license | chichtlm/TouchGFX | 694936495ba49b4baba4fb56fd1165f424518c94 | 09cfdf466ae98fa61f54d55548248134a007871f | refs/heads/master | 2020-05-10T00:07:11.813953 | 2016-12-14T06:55:22 | 2016-12-14T06:55:22 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 12,511 | cpp | /* DO NOT EDIT THIS FILE */
/* This file is autogenerated by the text-database code generator */
#include <touchgfx/InternalFlashFont.hpp>
#include <touchgfx/TypedText.hpp>
#include <texts/TypedTextDatabase.hpp>
#ifndef NO_USING_NAMESPACE_TOUCHGFX
using namespace touchgfx;
#endif
extern touchgfx::InternalFlashFont& getFont_Asap_Regular_36_4bpp();
extern touchgfx::InternalFlashFont& getFont_Asap_Regular_15_4bpp();
extern touchgfx::InternalFlashFont& getFont_Asap_Regular_20_4bpp();
extern touchgfx::InternalFlashFont& getFont_Asap_Regular_22_4bpp();
extern touchgfx::InternalFlashFont& getFont_RobotoCondensed_Regular_14_4bpp();
extern touchgfx::InternalFlashFont& getFont_SourceSansPro_Regular_26_4bpp();
extern touchgfx::InternalFlashFont& getFont_SourceSansPro_Regular_16_4bpp();
extern touchgfx::InternalFlashFont& getFont_RobotoCondensed_Regular_12_4bpp();
extern touchgfx::InternalFlashFont& getFont_SourceSansPro_Regular_100_4bpp();
extern touchgfx::InternalFlashFont& getFont_SourceSansPro_Regular_18_4bpp();
extern touchgfx::InternalFlashFont& getFont_SourceSansPro_Regular_14_4bpp();
extern touchgfx::InternalFlashFont& getFont_RobotoCondensed_Regular_26_4bpp();
const touchgfx::Font* const _fonts[] = {
&(getFont_Asap_Regular_36_4bpp()),
&(getFont_Asap_Regular_15_4bpp()),
&(getFont_Asap_Regular_20_4bpp()),
&(getFont_Asap_Regular_22_4bpp()),
&(getFont_RobotoCondensed_Regular_14_4bpp()),
&(getFont_SourceSansPro_Regular_26_4bpp()),
&(getFont_SourceSansPro_Regular_16_4bpp()),
&(getFont_RobotoCondensed_Regular_12_4bpp()),
&(getFont_SourceSansPro_Regular_100_4bpp()),
&(getFont_SourceSansPro_Regular_18_4bpp()),
&(getFont_SourceSansPro_Regular_14_4bpp()),
&(getFont_RobotoCondensed_Regular_26_4bpp()),
};
TEXT_LOCATION_FLASH_PRAGMA
const touchgfx::TypedText::TypedTextData typedText_database_DEFAULT[] TEXT_LOCATION_FLASH_ATTRIBUTE = {
{ 4, touchgfx::CENTER, touchgfx::TEXT_DIRECTION_LTR },
{ 4, touchgfx::CENTER, touchgfx::TEXT_DIRECTION_LTR },
{ 5, touchgfx::LEFT, touchgfx::TEXT_DIRECTION_LTR },
{ 6, touchgfx::LEFT, touchgfx::TEXT_DIRECTION_LTR },
{ 5, touchgfx::LEFT, touchgfx::TEXT_DIRECTION_LTR },
{ 6, touchgfx::LEFT, touchgfx::TEXT_DIRECTION_LTR },
{ 5, touchgfx::LEFT, touchgfx::TEXT_DIRECTION_LTR },
{ 6, touchgfx::LEFT, touchgfx::TEXT_DIRECTION_LTR },
{ 5, touchgfx::LEFT, touchgfx::TEXT_DIRECTION_LTR },
{ 6, touchgfx::LEFT, touchgfx::TEXT_DIRECTION_LTR },
{ 5, touchgfx::LEFT, touchgfx::TEXT_DIRECTION_LTR },
{ 6, touchgfx::LEFT, touchgfx::TEXT_DIRECTION_LTR },
{ 5, touchgfx::LEFT, touchgfx::TEXT_DIRECTION_LTR },
{ 6, touchgfx::LEFT, touchgfx::TEXT_DIRECTION_LTR },
{ 5, touchgfx::LEFT, touchgfx::TEXT_DIRECTION_LTR },
{ 6, touchgfx::LEFT, touchgfx::TEXT_DIRECTION_LTR },
{ 5, touchgfx::LEFT, touchgfx::TEXT_DIRECTION_LTR },
{ 6, touchgfx::LEFT, touchgfx::TEXT_DIRECTION_LTR },
{ 5, touchgfx::LEFT, touchgfx::TEXT_DIRECTION_LTR },
{ 6, touchgfx::LEFT, touchgfx::TEXT_DIRECTION_LTR },
{ 5, touchgfx::LEFT, touchgfx::TEXT_DIRECTION_LTR },
{ 6, touchgfx::LEFT, touchgfx::TEXT_DIRECTION_LTR },
{ 5, touchgfx::LEFT, touchgfx::TEXT_DIRECTION_LTR },
{ 6, touchgfx::LEFT, touchgfx::TEXT_DIRECTION_LTR },
{ 5, touchgfx::LEFT, touchgfx::TEXT_DIRECTION_LTR },
{ 6, touchgfx::LEFT, touchgfx::TEXT_DIRECTION_LTR },
{ 7, touchgfx::CENTER, touchgfx::TEXT_DIRECTION_LTR },
{ 7, touchgfx::CENTER, touchgfx::TEXT_DIRECTION_LTR },
{ 7, touchgfx::CENTER, touchgfx::TEXT_DIRECTION_LTR },
{ 8, touchgfx::LEFT, touchgfx::TEXT_DIRECTION_LTR },
{ 8, touchgfx::LEFT, touchgfx::TEXT_DIRECTION_LTR },
{ 9, touchgfx::LEFT, touchgfx::TEXT_DIRECTION_LTR },
{ 9, touchgfx::LEFT, touchgfx::TEXT_DIRECTION_LTR },
{ 9, touchgfx::LEFT, touchgfx::TEXT_DIRECTION_LTR },
{ 9, touchgfx::LEFT, touchgfx::TEXT_DIRECTION_LTR },
{ 10, touchgfx::LEFT, touchgfx::TEXT_DIRECTION_LTR },
{ 10, touchgfx::LEFT, touchgfx::TEXT_DIRECTION_LTR },
{ 10, touchgfx::LEFT, touchgfx::TEXT_DIRECTION_LTR },
{ 10, touchgfx::LEFT, touchgfx::TEXT_DIRECTION_LTR },
{ 10, touchgfx::LEFT, touchgfx::TEXT_DIRECTION_LTR },
{ 10, touchgfx::LEFT, touchgfx::TEXT_DIRECTION_LTR },
{ 10, touchgfx::LEFT, touchgfx::TEXT_DIRECTION_LTR },
{ 10, touchgfx::LEFT, touchgfx::TEXT_DIRECTION_LTR },
{ 10, touchgfx::LEFT, touchgfx::TEXT_DIRECTION_LTR },
{ 10, touchgfx::LEFT, touchgfx::TEXT_DIRECTION_LTR },
{ 10, touchgfx::LEFT, touchgfx::TEXT_DIRECTION_LTR },
{ 10, touchgfx::LEFT, touchgfx::TEXT_DIRECTION_LTR },
{ 10, touchgfx::LEFT, touchgfx::TEXT_DIRECTION_LTR },
{ 4, touchgfx::LEFT, touchgfx::TEXT_DIRECTION_LTR },
{ 4, touchgfx::LEFT, touchgfx::TEXT_DIRECTION_LTR },
{ 4, touchgfx::LEFT, touchgfx::TEXT_DIRECTION_LTR },
{ 4, touchgfx::LEFT, touchgfx::TEXT_DIRECTION_LTR },
{ 4, touchgfx::LEFT, touchgfx::TEXT_DIRECTION_LTR },
{ 4, touchgfx::LEFT, touchgfx::TEXT_DIRECTION_LTR },
{ 11, touchgfx::LEFT, touchgfx::TEXT_DIRECTION_LTR },
{ 11, touchgfx::LEFT, touchgfx::TEXT_DIRECTION_LTR },
{ 11, touchgfx::LEFT, touchgfx::TEXT_DIRECTION_LTR },
{ 11, touchgfx::LEFT, touchgfx::TEXT_DIRECTION_LTR },
{ 11, touchgfx::LEFT, touchgfx::TEXT_DIRECTION_LTR },
{ 11, touchgfx::LEFT, touchgfx::TEXT_DIRECTION_LTR },
{ 4, touchgfx::LEFT, touchgfx::TEXT_DIRECTION_LTR },
{ 4, touchgfx::LEFT, touchgfx::TEXT_DIRECTION_LTR },
{ 4, touchgfx::LEFT, touchgfx::TEXT_DIRECTION_LTR },
{ 4, touchgfx::LEFT, touchgfx::TEXT_DIRECTION_LTR },
{ 4, touchgfx::LEFT, touchgfx::TEXT_DIRECTION_LTR },
{ 4, touchgfx::LEFT, touchgfx::TEXT_DIRECTION_LTR },
{ 4, touchgfx::LEFT, touchgfx::TEXT_DIRECTION_LTR },
{ 4, touchgfx::LEFT, touchgfx::TEXT_DIRECTION_LTR },
{ 4, touchgfx::LEFT, touchgfx::TEXT_DIRECTION_LTR },
{ 4, touchgfx::LEFT, touchgfx::TEXT_DIRECTION_LTR },
{ 4, touchgfx::LEFT, touchgfx::TEXT_DIRECTION_LTR },
{ 4, touchgfx::LEFT, touchgfx::TEXT_DIRECTION_LTR },
{ 4, touchgfx::LEFT, touchgfx::TEXT_DIRECTION_LTR },
{ 4, touchgfx::LEFT, touchgfx::TEXT_DIRECTION_LTR },
{ 4, touchgfx::LEFT, touchgfx::TEXT_DIRECTION_LTR },
{ 4, touchgfx::LEFT, touchgfx::TEXT_DIRECTION_LTR },
{ 4, touchgfx::LEFT, touchgfx::TEXT_DIRECTION_LTR },
{ 4, touchgfx::LEFT, touchgfx::TEXT_DIRECTION_LTR },
{ 4, touchgfx::LEFT, touchgfx::TEXT_DIRECTION_LTR },
{ 4, touchgfx::LEFT, touchgfx::TEXT_DIRECTION_LTR },
{ 4, touchgfx::LEFT, touchgfx::TEXT_DIRECTION_LTR },
{ 4, touchgfx::LEFT, touchgfx::TEXT_DIRECTION_LTR },
{ 4, touchgfx::LEFT, touchgfx::TEXT_DIRECTION_LTR },
{ 4, touchgfx::LEFT, touchgfx::TEXT_DIRECTION_LTR },
{ 4, touchgfx::LEFT, touchgfx::TEXT_DIRECTION_LTR },
{ 4, touchgfx::LEFT, touchgfx::TEXT_DIRECTION_LTR },
{ 4, touchgfx::LEFT, touchgfx::TEXT_DIRECTION_LTR },
{ 4, touchgfx::LEFT, touchgfx::TEXT_DIRECTION_LTR },
{ 4, touchgfx::LEFT, touchgfx::TEXT_DIRECTION_LTR },
{ 4, touchgfx::LEFT, touchgfx::TEXT_DIRECTION_LTR },
{ 4, touchgfx::LEFT, touchgfx::TEXT_DIRECTION_LTR },
{ 4, touchgfx::LEFT, touchgfx::TEXT_DIRECTION_LTR },
{ 4, touchgfx::LEFT, touchgfx::TEXT_DIRECTION_LTR },
{ 4, touchgfx::LEFT, touchgfx::TEXT_DIRECTION_LTR },
{ 4, touchgfx::LEFT, touchgfx::TEXT_DIRECTION_LTR },
{ 4, touchgfx::LEFT, touchgfx::TEXT_DIRECTION_LTR },
{ 4, touchgfx::LEFT, touchgfx::TEXT_DIRECTION_LTR },
{ 4, touchgfx::LEFT, touchgfx::TEXT_DIRECTION_LTR },
{ 4, touchgfx::LEFT, touchgfx::TEXT_DIRECTION_LTR },
{ 4, touchgfx::LEFT, touchgfx::TEXT_DIRECTION_LTR },
{ 4, touchgfx::LEFT, touchgfx::TEXT_DIRECTION_LTR },
{ 4, touchgfx::LEFT, touchgfx::TEXT_DIRECTION_LTR },
{ 4, touchgfx::LEFT, touchgfx::TEXT_DIRECTION_LTR },
{ 4, touchgfx::LEFT, touchgfx::TEXT_DIRECTION_LTR },
{ 4, touchgfx::LEFT, touchgfx::TEXT_DIRECTION_LTR },
{ 4, touchgfx::LEFT, touchgfx::TEXT_DIRECTION_LTR },
{ 4, touchgfx::LEFT, touchgfx::TEXT_DIRECTION_LTR },
{ 4, touchgfx::LEFT, touchgfx::TEXT_DIRECTION_LTR },
{ 4, touchgfx::LEFT, touchgfx::TEXT_DIRECTION_LTR },
{ 4, touchgfx::LEFT, touchgfx::TEXT_DIRECTION_LTR },
{ 4, touchgfx::LEFT, touchgfx::TEXT_DIRECTION_LTR },
{ 4, touchgfx::LEFT, touchgfx::TEXT_DIRECTION_LTR },
{ 4, touchgfx::LEFT, touchgfx::TEXT_DIRECTION_LTR },
{ 4, touchgfx::LEFT, touchgfx::TEXT_DIRECTION_LTR },
{ 4, touchgfx::LEFT, touchgfx::TEXT_DIRECTION_LTR },
{ 4, touchgfx::LEFT, touchgfx::TEXT_DIRECTION_LTR },
{ 4, touchgfx::LEFT, touchgfx::TEXT_DIRECTION_LTR },
{ 4, touchgfx::LEFT, touchgfx::TEXT_DIRECTION_LTR },
{ 4, touchgfx::LEFT, touchgfx::TEXT_DIRECTION_LTR },
{ 4, touchgfx::LEFT, touchgfx::TEXT_DIRECTION_LTR },
{ 4, touchgfx::LEFT, touchgfx::TEXT_DIRECTION_LTR },
{ 4, touchgfx::LEFT, touchgfx::TEXT_DIRECTION_LTR },
{ 4, touchgfx::LEFT, touchgfx::TEXT_DIRECTION_LTR },
{ 4, touchgfx::LEFT, touchgfx::TEXT_DIRECTION_LTR },
{ 4, touchgfx::LEFT, touchgfx::TEXT_DIRECTION_LTR },
{ 4, touchgfx::LEFT, touchgfx::TEXT_DIRECTION_LTR },
{ 4, touchgfx::RIGHT, touchgfx::TEXT_DIRECTION_LTR },
{ 4, touchgfx::RIGHT, touchgfx::TEXT_DIRECTION_LTR },
{ 4, touchgfx::RIGHT, touchgfx::TEXT_DIRECTION_LTR },
{ 4, touchgfx::RIGHT, touchgfx::TEXT_DIRECTION_LTR },
{ 4, touchgfx::RIGHT, touchgfx::TEXT_DIRECTION_LTR },
{ 4, touchgfx::RIGHT, touchgfx::TEXT_DIRECTION_LTR },
{ 4, touchgfx::RIGHT, touchgfx::TEXT_DIRECTION_LTR },
{ 4, touchgfx::RIGHT, touchgfx::TEXT_DIRECTION_LTR },
{ 4, touchgfx::RIGHT, touchgfx::TEXT_DIRECTION_LTR },
{ 4, touchgfx::RIGHT, touchgfx::TEXT_DIRECTION_LTR },
{ 4, touchgfx::RIGHT, touchgfx::TEXT_DIRECTION_LTR },
{ 4, touchgfx::RIGHT, touchgfx::TEXT_DIRECTION_LTR },
{ 4, touchgfx::RIGHT, touchgfx::TEXT_DIRECTION_LTR },
{ 4, touchgfx::RIGHT, touchgfx::TEXT_DIRECTION_LTR },
{ 0, touchgfx::CENTER, touchgfx::TEXT_DIRECTION_LTR },
{ 0, touchgfx::CENTER, touchgfx::TEXT_DIRECTION_LTR },
{ 1, touchgfx::LEFT, touchgfx::TEXT_DIRECTION_LTR },
{ 1, touchgfx::LEFT, touchgfx::TEXT_DIRECTION_LTR },
{ 1, touchgfx::LEFT, touchgfx::TEXT_DIRECTION_LTR },
{ 1, touchgfx::LEFT, touchgfx::TEXT_DIRECTION_LTR },
{ 1, touchgfx::LEFT, touchgfx::TEXT_DIRECTION_LTR },
{ 1, touchgfx::LEFT, touchgfx::TEXT_DIRECTION_LTR },
{ 1, touchgfx::LEFT, touchgfx::TEXT_DIRECTION_LTR },
{ 1, touchgfx::LEFT, touchgfx::TEXT_DIRECTION_LTR },
{ 1, touchgfx::LEFT, touchgfx::TEXT_DIRECTION_LTR },
{ 1, touchgfx::LEFT, touchgfx::TEXT_DIRECTION_LTR },
{ 1, touchgfx::LEFT, touchgfx::TEXT_DIRECTION_LTR },
{ 1, touchgfx::LEFT, touchgfx::TEXT_DIRECTION_LTR },
{ 1, touchgfx::LEFT, touchgfx::TEXT_DIRECTION_LTR },
{ 1, touchgfx::LEFT, touchgfx::TEXT_DIRECTION_LTR },
{ 1, touchgfx::LEFT, touchgfx::TEXT_DIRECTION_LTR },
{ 1, touchgfx::LEFT, touchgfx::TEXT_DIRECTION_LTR },
{ 2, touchgfx::RIGHT, touchgfx::TEXT_DIRECTION_LTR },
{ 2, touchgfx::RIGHT, touchgfx::TEXT_DIRECTION_LTR },
{ 3, touchgfx::CENTER, touchgfx::TEXT_DIRECTION_LTR },
{ 3, touchgfx::CENTER, touchgfx::TEXT_DIRECTION_LTR },
{ 3, touchgfx::CENTER, touchgfx::TEXT_DIRECTION_LTR },
{ 3, touchgfx::CENTER, touchgfx::TEXT_DIRECTION_LTR },
{ 3, touchgfx::CENTER, touchgfx::TEXT_DIRECTION_LTR },
{ 3, touchgfx::CENTER, touchgfx::TEXT_DIRECTION_LTR },
{ 3, touchgfx::CENTER, touchgfx::TEXT_DIRECTION_LTR },
{ 3, touchgfx::CENTER, touchgfx::TEXT_DIRECTION_LTR },
{ 1, touchgfx::LEFT, touchgfx::TEXT_DIRECTION_LTR },
{ 1, touchgfx::LEFT, touchgfx::TEXT_DIRECTION_LTR },
{ 1, touchgfx::LEFT, touchgfx::TEXT_DIRECTION_LTR },
{ 1, touchgfx::LEFT, touchgfx::TEXT_DIRECTION_LTR },
{ 1, touchgfx::LEFT, touchgfx::TEXT_DIRECTION_LTR },
{ 1, touchgfx::LEFT, touchgfx::TEXT_DIRECTION_LTR },
{ 1, touchgfx::LEFT, touchgfx::TEXT_DIRECTION_LTR },
{ 1, touchgfx::LEFT, touchgfx::TEXT_DIRECTION_LTR },
};
TEXT_LOCATION_FLASH_PRAGMA
const touchgfx::TypedText::TypedTextData* const typedTextDatabaseArray[] TEXT_LOCATION_FLASH_ATTRIBUTE =
{
typedText_database_DEFAULT,
};
namespace TypedTextDatabase
{
const touchgfx::TypedText::TypedTextData* getInstance(touchgfx::LanguageId id)
{
return typedTextDatabaseArray[id];
}
uint16_t getInstanceSize()
{
return sizeof(typedText_database_DEFAULT) / sizeof(touchgfx::TypedText::TypedTextData);
}
const touchgfx::Font* const * getFonts()
{
return _fonts;
}
}
| [
"2869905223@qq.com"
] | 2869905223@qq.com |
c4797a94be2267ace154d178f4cfa2fc2be0c5ff | 074fa23f1950a7e77e16eb61cbc0913a32bf13cd | /C++/Games/GameBase.h | 727a004ab2f27c8cb9c053a51d2f27b25f85706f | [] | no_license | attack-of-perl/personal | d9fb76da35409e9f070c1a020121bdecea72ccea | 2b4f48521b1b3d245d9f96043fa87152aaaa42b7 | refs/heads/master | 2021-09-16T15:21:09.958331 | 2018-06-21T20:18:31 | 2018-06-21T20:18:31 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,159 | h | #pragma once
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <memory>
#include "Lab4.h"
using namespace std;
//--------------------------------------------------------------------
struct gamePiece {
string display;
int size;
gamePiece(string a);
gamePiece(unsigned int anInt);
};
//--------------------------------------------------------------------
class gameBase {
protected:
int logestSize;
int player;
int height;
int width;
int turns;
int longestDisp;
bool playerX = true;
bool validPiece;
int realHeight;
int realWidth;
string currentDisp;
string inputDisp;
vector<gamePiece> pieceVector;
vector<gamePiece> pVectINIT;
static shared_ptr<gameBase> ptr;
public:
gameBase();
virtual bool done() = 0;
virtual bool draw() = 0;
virtual int prompt(int &a, int &b);
virtual int turn() = 0;
int play();
virtual void print() = 0;
void updateLongest(int a);
static void baseArgs(int argc, char* argv[]);
static shared_ptr<gameBase> instance();
int moveArray[600][3]; //arbitrarily large
bool isSudoku=false;
bool isFinished=false;
};
| [
"zach.perlman@wustl.edu"
] | zach.perlman@wustl.edu |
61daf8fc2cda30542769ceafeb7ad58b91fa8c3b | 11211916f39b9d98027b64d778e52743d0c519a1 | /L3/code/musicphotos/system/assignments/doc/tmp/main.cpp | d3edd1b2ed3ad4fc856e25e59ddacdc44ed0c6f1 | [] | no_license | mantasruigys3000/Group-Task | 87baf1bc2747323c0508f6f32ef733c3f4b50978 | 6790d74ae7fa0fe6b13733efcd75a9f4aca70ab0 | refs/heads/master | 2020-04-23T20:54:09.696659 | 2019-02-22T01:29:53 | 2019-02-22T01:29:53 | 171,454,102 | 0 | 0 | null | 2019-02-19T10:31:09 | 2019-02-19T10:31:08 | null | UTF-8 | C++ | false | false | 462 | cpp | Ipsum sed porro ipsum adipisci consectetur dolorem non.
Non amet amet aliquam dolorem.
Dolore neque neque quaerat.
Voluptatem numquam velit quisquam ipsum voluptatem dolore quisquam.
Etincidunt adipisci aliquam etincidunt voluptatem ut.
Username: Bert
Password: brooklyn
Quiquia numquam quisquam modi consectetur consectetur.
Adipisci porro tempora dolore consectetur.
Ipsum consectetur quisquam adipisci eius.
Sit adipisci tempora aliquam dolore amet adipisci.
| [
"mantasruigys101@gmail.com"
] | mantasruigys101@gmail.com |
b49acefc6200964da8816ddfe972202a6dd4dba1 | cd470ad61c4dbbd37ff004785fd6d75980987fe9 | /Codeforces/1406E Deleting Numbers/std.cpp | 967aa7389514c384f3bd2dd1cb412ff8bb655bb2 | [] | no_license | AutumnKite/Codes | d67c3770687f3d68f17a06775c79285edc59a96d | 31b7fc457bf8858424172bc3580389badab62269 | refs/heads/master | 2023-02-17T21:33:04.604104 | 2023-02-17T05:38:57 | 2023-02-17T05:38:57 | 202,944,952 | 3 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 1,605 | cpp | #include <bits/stdc++.h>
std::vector<int> init_prime(int n) {
std::vector<bool> vis(n + 1);
std::vector<int> prime;
for (int i = 2; i <= n; ++i) {
if (!vis[i]) {
prime.push_back(i);
}
for (int x : prime) {
if (x * i > n) {
break;
}
vis[x * i] = true;
if (i % x == 0) {
break;
}
}
}
return prime;
}
int query(int x) {
std::cout << "A " << x << std::endl;
int res;
std::cin >> res;
return res;
}
void erase(int x) {
std::cout << "B " << x << std::endl;
int res;
std::cin >> res;
}
void answer(int x) {
std::cout << "C " << x << std::endl;
}
int main() {
std::ios_base::sync_with_stdio(false);
std::cin.tie(0);
int n;
std::cin >> n;
std::vector<int> prime(init_prime(n));
int pos = 0;
while (pos < (int)prime.size() && 1ll * prime[pos] * prime[pos] <= n) {
++pos;
}
std::vector<int> p(prime.begin(), prime.begin() + pos);
std::vector<int> q(prime.begin() + pos, prime.end());
for (int x : p) {
erase(x);
}
int ans = 1;
for (int x : p) {
int v = x;
while (v <= n && query(v)) {
ans *= x;
v *= x;
}
}
if (ans == 1) {
int B = (int)sqrt(q.size()) + 1;
int lst = 0;
for (int i = 0; i <= (int)q.size(); ++i) {
if (i > 0 && (i % B == 0 || i == (int)q.size())) {
if (query(1) > (int)q.size() - i + 1) {
for (int j = lst; j < i; ++j) {
if (query(q[j])) {
ans *= q[j];
break;
}
}
break;
}
lst = i;
}
if (i < (int)q.size()) {
erase(q[i]);
}
}
answer(ans);
} else {
for (int x : q) {
if (query(x) > 1) {
ans *= x;
}
}
answer(ans);
}
}
| [
"1790397194@qq.com"
] | 1790397194@qq.com |
cbea4d0af2e9a541b7a3eb2fee649844f22e1ca3 | 582f2cc0cdbff7240741e2a5c3ece1f1dcee282c | /OIS/R1/sprei.cpp | f90da353e6484914c1ec23c3c9a438ba7c8ac424 | [] | no_license | moondemon68/cp | 7593057a124cdef51341bf75fb780a9b03b8ea12 | 3b5ebd39783253348763ea58f7e84608679c17c3 | refs/heads/master | 2022-02-23T21:04:30.962383 | 2022-02-04T16:31:41 | 2022-02-04T16:31:41 | 149,121,917 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 1,185 | cpp | #include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define MOD 1000000007
#define pii pair<int,int>
#define LL long long
using namespace std;
int main () {
//clock_t start = clock();
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int n,m,b;
cin >> n >> m >> b;
int a[n+5][m+5];
for (int i=1;i<=n;i++) {
for (int j=1;j<=m;j++) cin >> a[i][j];
}
int ans=INT_MAX;
for (int i=1;i<(1<<n);i++) {
int x=i;
vector<int> p;
while(p.size()<n) {
p.pb(x%2);
x/=2;
}
vector<int> q;
for (int j=0;j<n;j++) if (p[j]) q.pb(j+1);
bool y=1;
for (int j=0;j<q.size();j++) {
for (int k=j+1;k<q.size();k++) {
int cnt = 0;
for (int l=1;l<=m;l++) {
cnt += abs(a[q[j]][l]-a[q[k]][l]);
}
if (cnt<=1) y=0;
}
}
if (y) ans=min(ans, n-(int)q.size());
}
cout << ans << endl;
//cerr << fixed << setprecision(3) << (clock()-start)*1./CLOCKS_PER_SEC << endl;
return 0;
} | [
"moondemon68@gmail.com"
] | moondemon68@gmail.com |
339e16e059cf636bd7df9f1890e93c24de71b0a5 | 1c1696870a0de9d4b62c403f89abaf7158d628f9 | /DetectRecog/DetectRecog/textDetection/GroundDetect.cpp | 1041bf8a33cabf62686a190e7919a4eb67b1cf90 | [] | no_license | lewisgit/ACCRS | e07ac0a7e4adc4f09f0ba4ca2a73cea9c4259342 | a4ded4d36dd368201533bf19c8bbca11c6bfe707 | refs/heads/master | 2021-03-24T12:01:42.059353 | 2018-01-15T11:56:53 | 2018-01-15T11:56:53 | 113,961,716 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,124 | cpp | #include "GroundDetect.h"
void GroundDetect::readImageGroundTruth(const cv::Mat& image,const std::vector<std::string> gt)
{
pgts.clear();
cgts.clear();
candidateStore.clear();
image.copyTo(oriBgrImage_8UC3);
int xupdate = (oriBgrImage_8UC3.cols < 1280)?oriBgrImage_8UC3.cols:1280;
int yupdate = (oriBgrImage_8UC3.rows < 960)?oriBgrImage_8UC3.rows:960;
double xratio = double(xupdate)/oriBgrImage_8UC3.cols;
double yratio = double(yupdate)/oriBgrImage_8UC3.rows;
cv::resize(oriBgrImage_8UC3,oriBgrImage_8UC3,cv::Size(xupdate,yupdate));
for(int i = 0; i< gt.size();i++)
pgts.push_back(PolyGroundTruth(gt[i],xratio,yratio));
}
void GroundDetect::run()
{
this->candidateStore = this->getCandidate.run(this->oriBgrImage_8UC3);
this->cgts = this->linkCandidate.run(this->candidateStore);
this->cgts = this->vericaficationTextLine.run(this->cgts,this->oriBgrImage_8UC3);
}
std::string GroundDetect::calculateResult()
{
return this->fmeasure.run(cgts,pgts);
}
void GroundDetect::showPolyGroundTruthSet()
{
this->cgts.display(oriBgrImage_8UC3);
cv::imshow("Final Result",oriBgrImage_8UC3);
cv::waitKey(20);
}
| [
"sudolewis@163.com"
] | sudolewis@163.com |
9ff9a7091f285ccbb8890912c5e91fd227a153d3 | 4f364c395bef2342971d11f51a855b20f40c8243 | /library/tests/lib_tests/lserver_unittest.cpp | c294a69255d983b68edece944e05dbb87a29bcfd | [
"MIT"
] | permissive | guoyu07/loopy | 773c95f98d60f8b5f55a0ef70e1b4dedf1d66ff3 | 87f448e5f826ee6f07ced72e625fa35c47cbf76c | refs/heads/master | 2021-05-27T16:52:36.733053 | 2014-10-12T00:09:04 | 2014-10-12T00:09:04 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,970 | cpp | // Copyright 2005, Google Inc.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// test for lserver
#include <limits.h>
#include "../../third_party/googletest/include/gtest/gtest.h"
#include "../../sys/lserver.h"
using namespace loopy;
// make sure that the server singleton is working as expected
TEST(ServerSingletonTest, SameAddress) {
LServer& server = LServer::getInstance();
LServer& server2 = LServer::getInstance();
EXPECT_EQ(&server, &server2);
}
// test the serverRequests
| [
"youfychenbc5000@gmail.com"
] | youfychenbc5000@gmail.com |
226feb9598650f65cc5ac6c9ae50c84d75a54e65 | b0ed979f05c8c1abae214753790602acb3ce1f97 | /Other sources/OWL 2019 - KOL.cpp | 247363446710645332b60f9a117f15b3ff28cf9d | [] | no_license | r-d-s-l-w/competitive-programming | 1304d591b9c28390fcf2ceaa5f86aa8274efb41c | 21322d69ceed314135aeb6bbf3ec91ee70bc4f5b | refs/heads/master | 2022-11-24T10:07:06.720420 | 2020-08-06T11:25:58 | 2020-08-06T11:25:58 | 238,414,061 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,763 | cpp | #include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define ALL(x) (x).begin(),(x).end()
#define endl '\n'
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vll = vector<ll>;
using pi = pair<int,int>;
using pll = pair<ll,ll>;
struct color{
ll wartosc;
ll L;
ll R;
};
vector<color> col[200100];
ll n, m, q, T;
ll value(ll x, ll a){
ll sz = col[a].size();
if (x < col[a][0].wartosc){
//cout << 1111 << endl;
//cout << col[a][sz-1].L << endl;
return col[a][sz-1].L + sz * (col[a][0].wartosc - x);
}
if (x > col[a][sz-1].wartosc){
//cout << 2222 << endl;
return col[a][0].R + sz * (x - col[a][sz-1].wartosc);
}
ll l_ptr = 0, r_ptr = sz-1;
//cout << 3333 << endl;
while (r_ptr - l_ptr > 0){
ll mid = (r_ptr + l_ptr) / 2;
if (col[a][mid].wartosc < x)
l_ptr = mid + 1;
else r_ptr = mid;
}
ll ptr = l_ptr;
//cout << " " << ptr << endl;
return col[a][sz-1].L - col[a][ptr-1].L - (x - col[a][0].wartosc)*(sz-ptr)
+ col[a][0].R - col[a][ptr].R - ptr*(col[a][sz-1].wartosc - x);
}
ll sol(ll a, ll b){
ll res = 0; ll temp = a;
if (col[a].size() > col[b].size()){
a = b; b = temp;
}
for (int i=0; i<col[a].size(); ++i){
res += value(col[a][i].wartosc,b);
//cout << " " << res << endl;
}
return res;
}
void precompute(){
for (int i=0; i<=m; ++i){
for (int j=0; j<col[i].size(); ++j){
if (j!=0) col[i][j].L = col[i][j-1].L + (col[i][j].wartosc - col[i][0].wartosc);
else col[i][j].L = 0;
}
ll temp = col[i].size() - 1;
for (int j=temp; j>=0; --j){
if (j!=temp) col[i][j].R = col[i][j+1].R + (col[i][temp].wartosc - col[i][j].wartosc);
else col[i][j].R = 0;
}
/// 1 DEBUG - OK
/*
cout << " " << i << endl;
for (int j=0; j<col[i].size(); ++j){
cout << " " << j << ' ' << col[i][j].wartosc << ' ' <<
col[i][j].L << ' ' << col[i][j].R << endl;
}
cout << endl;
*/
}
}
void ini(){
for (int i=0; i<=m; ++i)
col[i].clear();
n = 0; m = 0; q = 0;
}
int main(){
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cin >> T;
while (T--){
ini();
ll x, a, b;
cin >> n >> m >> q;
for (int i=0; i<n; ++i){
cin >> x;
col[x].PB({i,0,0});
}
precompute();
while (q--){
cin >> a >> b;
cout << sol(a,b) << endl;
}
}
return 0;
}
| [
"noreply@github.com"
] | noreply@github.com |
77cc840b5389e1041399f7187725e61ce4a80e32 | 0c9c3c7cde1e8a78ffae1d1a1ea06e3c4ae63146 | /if.cpp | a1117576b4c65e0c244224999c9e915aed46e958 | [] | no_license | varun2001-vit/c-programming | 934db3c6ed4843af0260a5f09d4968f36dad9929 | 10d23dc367982b3b8d195d70a74afae421eff6e5 | refs/heads/main | 2023-05-02T05:34:19.529727 | 2021-05-19T04:00:19 | 2021-05-19T04:00:19 | 347,556,817 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 196 | cpp | #include<stdio.h>
int main()
{char c;
scanf("%c",&c);
if(c=='a')
printf("ass");
else if(c=='b')
printf("boat");
else if(c=='c')
printf("cruise");
else
printf("invalid");
return 0;
}
| [
"noreply@github.com"
] | noreply@github.com |
828c8dff298e193b5e3054b1e201902725e3f50c | bd1fea86d862456a2ec9f56d57f8948456d55ee6 | /000/068/527/CWE122_Heap_Based_Buffer_Overflow__cpp_CWE805_char_ncpy_84a.cpp | 6e6ba18e8d11ff7499d5a8d2988cedadefd95bf2 | [] | no_license | CU-0xff/juliet-cpp | d62b8485104d8a9160f29213368324c946f38274 | d8586a217bc94cbcfeeec5d39b12d02e9c6045a2 | refs/heads/master | 2021-03-07T15:44:19.446957 | 2020-03-10T12:45:40 | 2020-03-10T12:45:40 | 246,275,244 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 2,300 | cpp | /* TEMPLATE GENERATED TESTCASE FILE
Filename: CWE122_Heap_Based_Buffer_Overflow__cpp_CWE805_char_ncpy_84a.cpp
Label Definition File: CWE122_Heap_Based_Buffer_Overflow__cpp_CWE805.string.label.xml
Template File: sources-sink-84a.tmpl.cpp
*/
/*
* @description
* CWE: 122 Heap Based Buffer Overflow
* BadSource: Allocate using new[] and set data pointer to a small buffer
* GoodSource: Allocate using new[] and set data pointer to a large buffer
* Sinks: ncpy
* BadSink : Copy string to data using strncpy
* Flow Variant: 84 Data flow: data passed to class constructor and destructor by declaring the class object on the heap and deleting it after use
*
* */
#include "std_testcase.h"
#include "CWE122_Heap_Based_Buffer_Overflow__cpp_CWE805_char_ncpy_84.h"
namespace CWE122_Heap_Based_Buffer_Overflow__cpp_CWE805_char_ncpy_84
{
#ifndef OMITBAD
void bad()
{
char * data;
data = NULL;
CWE122_Heap_Based_Buffer_Overflow__cpp_CWE805_char_ncpy_84_bad * badObject = new CWE122_Heap_Based_Buffer_Overflow__cpp_CWE805_char_ncpy_84_bad(data);
delete badObject;
}
#endif /* OMITBAD */
#ifndef OMITGOOD
/* goodG2B uses the GoodSource with the BadSink */
static void goodG2B()
{
char * data;
data = NULL;
CWE122_Heap_Based_Buffer_Overflow__cpp_CWE805_char_ncpy_84_goodG2B * goodG2BObject = new CWE122_Heap_Based_Buffer_Overflow__cpp_CWE805_char_ncpy_84_goodG2B(data);
delete goodG2BObject;
}
void good()
{
goodG2B();
}
#endif /* OMITGOOD */
} /* close namespace */
/* Below is the main(). It is only used when building this testcase on
its own for testing or for building a binary to use in testing binary
analysis tools. It is not used when compiling all the testcases as one
application, which is how source code analysis tools are tested. */
#ifdef INCLUDEMAIN
using namespace CWE122_Heap_Based_Buffer_Overflow__cpp_CWE805_char_ncpy_84; /* so that we can use good and bad easily */
int main(int argc, char * argv[])
{
/* seed randomness */
srand( (unsigned)time(NULL) );
#ifndef OMITGOOD
printLine("Calling good()...");
good();
printLine("Finished good()");
#endif /* OMITGOOD */
#ifndef OMITBAD
printLine("Calling bad()...");
bad();
printLine("Finished bad()");
#endif /* OMITBAD */
return 0;
}
#endif
| [
"frank@fischer.com.mt"
] | frank@fischer.com.mt |
342926adfce8829b70156ca0d3f3026d2e99cf6a | d8fe0cd5d911d74f2a0b0832993a060f20eb4831 | /Without Projects/3rd sem Programs/Sessional practice/linked_list_linear_1.cpp | c5952bb3127eba28dcac618f52290dfcda9104e0 | [] | no_license | viscrisn/mit-algo-cpp | 8d1bb557d3123991d56bd2df0b5a3296b94acbb0 | 945652ebcaf117deec3ca0834bb3556175427ab7 | refs/heads/master | 2016-09-05T11:48:56.209389 | 2014-06-21T17:20:50 | 2014-06-21T17:20:50 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,406 | cpp | #include<stdio.h>
#include<stdlib.h>
#include<process.h>
struct node
{
int info;
struct node *llink;
struct node *rlink;
};
typedef node* NODEPTR;
NODEPTR getnode()
{
NODEPTR x=NULL;
x=(NODEPTR)malloc(sizeof(struct node));
if(x==NULL)
{
printf("Not enough memory");
exit(0);
}
return x;
}
NODEPTR insert_front(int item,NODEPTR head)
{
NODEPTR temp=getnode();
temp->info=item;
if(head->rlink==head)
{
temp->llink=head;
temp->rlink=head;
head->rlink=temp;
head->llink=temp;
return head;
}
NODEPTR cur=head->rlink;
head->rlink=temp;
temp->llink=head;
temp->rlink=cur;
cur->llink=temp;
return head;
}
void display(NODEPTR head)
{
if(head->rlink==head)
{
printf("List is empty");
}
else
{
NODEPTR cur=head->rlink;
while(cur!=head)
{
printf("%d\t",cur->info);
cur=cur->rlink;
}
}
return;
}
NODEPTR delete_last(NODEPTR head)
{
if(head->rlink==head)
{
printf("The list is empty");
return head;
}
NODEPTR cur,prev;
cur=head->rlink;
prev=cur;
if(cur->rlink==head)
{
printf("Deleted node is: %d",cur->info);
head->rlink=head;
free(cur);
cur=NULL;
return head;
}
while(cur->rlink->rlink!=head)
{
cur=cur->rlink;
prev=cur;
}
cur=cur->rlink;
printf("Deleted node is: %d\n",cur->info);
cur=NULL;
free(cur);
prev->rlink=head;
head->llink=prev;
return head;
}
int main()
{
NODEPTR head=getnode();
head->llink=head;
head->rlink=head;
head->info=0;
int item,choice;
while(1)
{
printf("Enter 1: Add front \n2: Display \n3: Delete last\n4: Exit\n");
scanf("%d",&choice);
switch(choice)
{
case 1:
printf("Enter the element:\n");
scanf("%d",&item);
head=insert_front(item,head);
break;
case 2:
display(head);
break;
case 3:
head=delete_last(head);
break;
case 4:
exit(0);
default:
printf("Wrong choice, Enter again\n");
break;
}
}
}
| [
"viscrisn@yahoo.co.in"
] | viscrisn@yahoo.co.in |
eb9d3a687d1fe1f87a86a1e15fa0490a131eac72 | 83fd474d6a906c00d82f7bd274f13d5294f26c12 | /Test/tests/RegisterTest.cpp | a6feb74239f0c162729e87ad00b2e17f93f78905 | [] | no_license | andre3pazo/Laboratorio-Paoletti | dc5076e1f945e323b61a226f62bab42d6f75d57a | d65a73a35b37c346c2b734ec8fa0e070e6d732a0 | refs/heads/master | 2021-02-17T15:45:17.725837 | 2020-04-18T14:55:12 | 2020-04-18T14:55:12 | 245,108,825 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,042 | cpp | //
// Created by andre on 30/03/2020.
//
#include "gtest/gtest.h"
#include "../../Register.h"
TEST(RegisterTest, CorrectActivitiesNumber) {
auto firstActivity = Activity();
auto secondActivity = Activity();
auto thirdActivity = Activity();
auto forthActivity = Activity();
Register firstRegister;
firstRegister.add(firstActivity);
firstRegister.add(secondActivity);
firstRegister.add(thirdActivity);
firstRegister.add(forthActivity);
ASSERT_EQ(4, firstRegister.getNumActivities());
}
TEST(RegisterTest, CorrectInsertRemove) {
auto firstDate = Date(2020, 3, 5);
auto secondDate = Date(2020, 4, 2);
auto firstActivity = Activity("", firstDate);
auto secondActivity = Activity("", secondDate);
auto reg = Register();
reg.add(firstActivity);
reg.add(secondActivity);
ASSERT_EQ(reg.getNumActivities(), 2);
reg.remove(secondActivity);
ASSERT_EQ(reg.getNumActivities(), 1);
ASSERT_TRUE(reg.search(firstActivity));
ASSERT_FALSE(reg.search(secondActivity));
}
| [
"61413176+andre3pazo@users.noreply.github.com"
] | 61413176+andre3pazo@users.noreply.github.com |
39712b28b14e3b2315f34ab6bd1b78be66be1562 | fc50a19c85e0ee6aa0e8c8146e38492bae1246ba | /tgv.cpp | 314ddeef106278e035d5ae7e0e02e984dea69ff4 | [] | no_license | trantrangntt/TINC | 7eb5b800bf515be4ff6e5683fc674cc4037b61f2 | 6f9df0ae1ac339965767f13b59bfbf89cb845889 | refs/heads/master | 2023-08-23T02:04:10.882005 | 2021-10-01T15:51:29 | 2021-10-01T15:51:29 | 412,525,803 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 147 | cpp | #include<stdio.h>
int main(){
int a;
scanf("%d",&a);
for (int i=0; i<a; i++){
for (int j=0; j<=i; j++)
printf("*");
printf("\n");
}
}
| [
"ngthutrang1107@gmail.com"
] | ngthutrang1107@gmail.com |
dd52d2cc5b77740b5524d4c5d0bc55a844cc575d | a753d4ce613a54ee8e9bbc9f42a0841fd79e13d6 | /FastWindows.UI.Composition/VisualCollection.cpp | 3154fb16fcc17fd4f4651bc4c398548ec05bd780 | [
"MIT"
] | permissive | principleWindows/Minesweeper | e47b44a1e08fdaedd28024e862e02363ffb5c2c5 | 6f28abab141d80725beb746073d994833075b862 | refs/heads/master | 2022-02-23T09:49:17.181240 | 2019-05-29T19:53:16 | 2019-05-29T19:53:16 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,540 | cpp | #include "pch.h"
#include "VisualCollection.h"
#include "VisualCollection.g.cpp"
#include "Visual.h"
namespace winrt::FastWindows::UI::Composition::implementation
{
Windows::Foundation::Collections::IIterator<FastWindows::UI::Composition::Visual> VisualCollection::First()
{
throw hresult_not_implemented();
}
int32_t VisualCollection::Count()
{
throw hresult_not_implemented();
}
void VisualCollection::InsertAbove(FastWindows::UI::Composition::Visual const& newChild, FastWindows::UI::Composition::Visual const& sibling)
{
m_object.InsertAbove(get_self<Visual>(newChild)->m_object, get_self<Visual>(sibling)->m_object);
}
void VisualCollection::InsertAtBottom(FastWindows::UI::Composition::Visual const& newChild)
{
m_object.InsertAtBottom(get_self<Visual>(newChild)->m_object);
}
void VisualCollection::InsertAtTop(FastWindows::UI::Composition::Visual const& newChild)
{
m_object.InsertAtTop(get_self<Visual>(newChild)->m_object);
}
void VisualCollection::InsertBelow(FastWindows::UI::Composition::Visual const& newChild, FastWindows::UI::Composition::Visual const& sibling)
{
m_object.InsertBelow(get_self<Visual>(newChild)->m_object, get_self<Visual>(sibling)->m_object);
}
void VisualCollection::Remove(FastWindows::UI::Composition::Visual const& child)
{
m_object.Remove(get_self<Visual>(child)->m_object);
}
void VisualCollection::RemoveAll()
{
m_object.RemoveAll();
}
}
| [
"kekerr@microsoft.com"
] | kekerr@microsoft.com |
86768119b09f4f4a946b948ab7984148161050c0 | e16ed44dd0a81c464f847fba80949eb5e80ac924 | /ARS/startup.h | 2e45226e304a9f157d81bc3435a0d801870f06f5 | [] | no_license | geiziry/Qt-Cpp-integration | e47485f368847687d69e65fde8dd4012d0b1f082 | 6b09a393f95f8087e5d78c47646f153aed27a3f1 | refs/heads/master | 2021-09-01T02:49:18.787353 | 2017-12-24T11:37:53 | 2017-12-24T11:37:53 | 114,532,079 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 301 | h | #ifndef STARTUP_H
#define STARTUP_H
#include <QObject>
class QQmlApplicationEngine;
class MainViewMgr;
class Startup:public QObject
{
Q_OBJECT
public:
explicit Startup(QObject* parent=0);
MainViewMgr& m_mainViewMgr;
private:
QQmlApplicationEngine& m_engine;
};
#endif // STARTUP_H
| [
"mahmoud.geiziry@hotmail.com"
] | mahmoud.geiziry@hotmail.com |
83b6fe160afe2107de41ef46c5d5100162b54b3a | 6c82f3599bc423c59df3ee6ed515c5a46efd0f82 | /CA1_Text_Engine/NPC.h | 312322725714ff62bf5edbb69dfd6992eaeda3c1 | [] | no_license | KieranK6/Text-Adventure | 44b43b655b167ee47bae4e3ffbf4b8534bd07813 | 8587fb6dddec7a5f71c9866d75e3cb5f414403b3 | refs/heads/master | 2020-07-18T12:51:01.847339 | 2016-11-16T12:56:27 | 2016-11-16T12:56:27 | 73,919,757 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 635 | h | #pragma once
#include "StaticInteractable.h"
#include "GenericMap.h"
#include <array>
#include "StringPair.h"
//Purpose: An interactable character
//Author: Kieran
//Version: 1.0
//Bugs: None known
//TODO: none
class NPC : public StaticInteractable
{
public:
NPC(std::string name, std::string description, std::string hi, std::string bye, std::array<StringPair, 3> dialogueArr);
NPC();
~NPC();
std::string hi;
std::string bye;
typedef std::array<StringPair, 3> DialogueArr;
void NPC::talkTo();
DialogueArr dialogueArr;
//GenericMap<Interactable> iMap;
//array<map(std::string, std::string)> conversations;
};
| [
"D00168624@student.dkit.ie"
] | D00168624@student.dkit.ie |
5b663d17b85b5597592b06748d10f3af7c5d7822 | 402511d388ad7b4f3633d44975c6037bd770a73c | /2875(대회 or 인턴)/2875(대회 or 인턴)/소스.cpp | a6bee44c73c2ad9a1d3f358f2bc25cb0ff0ff965 | [] | no_license | hg010303/Baekjoon | 33c9747f2b2adea66c5ac07fe5f444a4d1457dcc | 28b1df13aec07823d7ad0990bb94e4988e962094 | refs/heads/master | 2023-06-19T18:20:49.576626 | 2021-07-12T14:24:08 | 2021-07-12T14:24:08 | 278,156,857 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 255 | cpp | #include<iostream>
#include<algorithm>
using namespace std;
int ans = 0;
int main() {
int n, m, k;
cin >> n >> m >> k;
while (true) {
if (k <= (n + m - 3) && n >= 2 && m >= 1) {
n -= 2;
m -= 1;
ans++;
}
else break;
}
cout << ans;
} | [
"hg010303@naver.com"
] | hg010303@naver.com |
cbe7914faec9477cd10017e58048f33b317fb705 | 3ae80dbc18ed3e89bedf846d098b2a98d8e4b776 | /src/SSWR/AVIRead/AVIRSSLCertKeyForm.cpp | 1c5aa35243b89997689f2cdaf7585677123e4424 | [] | no_license | sswroom/SClass | deee467349ca249a7401f5d3c177cdf763a253ca | 9a403ec67c6c4dfd2402f19d44c6573e25d4b347 | refs/heads/main | 2023-09-01T07:24:58.907606 | 2023-08-31T11:24:34 | 2023-08-31T11:24:34 | 329,970,172 | 10 | 7 | null | null | null | null | UTF-8 | C++ | false | false | 8,621 | cpp | #include "Stdafx.h"
#include "IO/StmData/FileData.h"
#include "SSWR/AVIRead/AVIRSSLCertKeyForm.h"
#include "UI/FileDialog.h"
#include "UI/MessageDialog.h"
void __stdcall SSWR::AVIRead::AVIRSSLCertKeyForm::OnFormClosed(void *userObj, UI::GUIForm *frm)
{
SSWR::AVIRead::AVIRSSLCertKeyForm *me = (SSWR::AVIRead::AVIRSSLCertKeyForm*)userObj;
if (me->dialogResult != DR_OK)
{
SDEL_CLASS(me->cert);
SDEL_CLASS(me->key);
}
}
void __stdcall SSWR::AVIRead::AVIRSSLCertKeyForm::OnFileCertClicked(void *userObj)
{
SSWR::AVIRead::AVIRSSLCertKeyForm *me = (SSWR::AVIRead::AVIRSSLCertKeyForm*)userObj;
UI::FileDialog dlg(L"SSWR", L"AVIRead", L"AVIRSSLCert", false);
dlg.AddFilter(CSTR("*.crt"), CSTR("Cert file"));
dlg.SetAllowMultiSel(false);
if (dlg.ShowDialog(me->GetHandle()))
{
me->LoadFile(dlg.GetFileName()->ToCString());
}
}
void __stdcall SSWR::AVIRead::AVIRSSLCertKeyForm::OnFileKeyClicked(void *userObj)
{
SSWR::AVIRead::AVIRSSLCertKeyForm *me = (SSWR::AVIRead::AVIRSSLCertKeyForm*)userObj;
UI::FileDialog dlg(L"SSWR", L"AVIRead", L"AVIRSSLKey", false);
dlg.AddFilter(CSTR("*.kye"), CSTR("Key file"));
dlg.SetAllowMultiSel(false);
if (dlg.ShowDialog(me->GetHandle()))
{
me->LoadFile(dlg.GetFileName()->ToCString());
}
}
void __stdcall SSWR::AVIRead::AVIRSSLCertKeyForm::OnFileConfirmClicked(void *userObj)
{
SSWR::AVIRead::AVIRSSLCertKeyForm *me = (SSWR::AVIRead::AVIRSSLCertKeyForm*)userObj;
if (me->cert && me->key)
{
me->SetDialogResult(DR_OK);
}
}
void __stdcall SSWR::AVIRead::AVIRSSLCertKeyForm::OnGenerateClicked(void *userObj)
{
SSWR::AVIRead::AVIRSSLCertKeyForm *me = (SSWR::AVIRead::AVIRSSLCertKeyForm*)userObj;
Text::StringBuilderUTF8 sbCountry;
Text::StringBuilderUTF8 sbCompany;
Text::StringBuilderUTF8 sbCommonName;
me->txtGenCountry->GetText(sbCountry);
me->txtGenCompany->GetText(sbCompany);
me->txtGenCommonName->GetText(sbCommonName);
if (sbCountry.GetLength() != 2)
{
UI::MessageDialog::ShowDialog(CSTR("Country must be 2 characters"), CSTR("SSL Cert/Key"), me);
return;
}
if (sbCompany.GetLength() == 0)
{
UI::MessageDialog::ShowDialog(CSTR("Please enter company"), CSTR("SSL Cert/Key"), me);
return;
}
if (sbCommonName.GetLength() == 0)
{
UI::MessageDialog::ShowDialog(CSTR("Please enter common name"), CSTR("SSL Cert/Key"), me);
return;
}
Crypto::Cert::X509Cert *certASN1;
Crypto::Cert::X509File *keyASN1;
if (me->ssl->GenerateCert(sbCountry.ToCString(), sbCompany.ToCString(), sbCommonName.ToCString(), &certASN1, &keyASN1))
{
SDEL_CLASS(me->cert);
SDEL_CLASS(me->key);
me->cert = certASN1;
me->key = keyASN1;
me->SetDialogResult(DR_OK);
}
else
{
UI::MessageDialog::ShowDialog(CSTR("Error in generating certs"), CSTR("SSL Cert/Key"), me);
return;
}
}
void __stdcall SSWR::AVIRead::AVIRSSLCertKeyForm::OnFileDrop(void *userObj, NotNullPtr<Text::String> *files, UOSInt nFiles)
{
SSWR::AVIRead::AVIRSSLCertKeyForm *me = (SSWR::AVIRead::AVIRSSLCertKeyForm*)userObj;
UOSInt i = nFiles;
while (i-- > 0)
{
me->LoadFile(files[i]->ToCString());
}
}
void SSWR::AVIRead::AVIRSSLCertKeyForm::LoadFile(Text::CStringNN fileName)
{
Net::ASN1Data *asn1;
{
IO::StmData::FileData fd(fileName, false);
asn1 = (Net::ASN1Data*)this->core->GetParserList()->ParseFileType(fd, IO::ParserType::ASN1Data);
}
if (asn1 == 0)
{
UI::MessageDialog::ShowDialog(CSTR("Error in parsing file"), CSTR("SSL Cert/Key"), this);
return;
}
if (asn1->GetASN1Type() != Net::ASN1Data::ASN1Type::X509)
{
DEL_CLASS(asn1);
UI::MessageDialog::ShowDialog(CSTR("Error in parsing file"), CSTR("SSL Cert/Key"), this);
return;
}
Crypto::Cert::X509File *x509 = (Crypto::Cert::X509File*)asn1;
if (x509->GetFileType() == Crypto::Cert::X509File::FileType::Cert)
{
SDEL_CLASS(this->cert);
this->cert = (Crypto::Cert::X509Cert*)x509;
Text::StringBuilderUTF8 sb;
this->cert->ToShortString(sb);
this->lblFileCert->SetText(sb.ToCString());
this->tcMain->SetSelectedPage(this->tpFile);
}
else if (x509->GetFileType() == Crypto::Cert::X509File::FileType::PrivateKey || x509->GetFileType() == Crypto::Cert::X509File::FileType::Key)
{
SDEL_CLASS(this->key);
this->key = x509;
Text::StringBuilderUTF8 sb;
this->key->ToShortString(sb);
this->lblFileKey->SetText(sb.ToCString());
this->tcMain->SetSelectedPage(this->tpFile);
}
else
{
DEL_CLASS(x509);
}
}
SSWR::AVIRead::AVIRSSLCertKeyForm::AVIRSSLCertKeyForm(UI::GUIClientControl *parent, NotNullPtr<UI::GUICore> ui, NotNullPtr<SSWR::AVIRead::AVIRCore> core, Net::SSLEngine *ssl, Crypto::Cert::X509Cert *cert, Crypto::Cert::X509File *key) : UI::GUIForm(parent, 456, 200, ui)
{
this->SetText(CSTR("SSL Cert/Key"));
this->SetFont(0, 0, 8.25, false);
this->SetNoResize(true);
this->core = core;
this->ssl = ssl;
this->initCert = cert;
this->initKey = key;
this->cert = 0;
this->key = 0;
this->SetDPI(this->core->GetMonitorHDPI(this->GetHMonitor()), this->core->GetMonitorDDPI(this->GetHMonitor()));
this->HandleFormClosed(OnFormClosed, this);
NEW_CLASS(this->pnlCurr, UI::GUIPanel(ui, this));
this->pnlCurr->SetRect(0, 0, 100, 55, false);
this->pnlCurr->SetDockType(UI::GUIControl::DOCK_TOP);
NEW_CLASS(this->lblCurrCert, UI::GUILabel(ui, this->pnlCurr, CSTR("Curr Cert")));
this->lblCurrCert->SetRect(4, 4, 100, 23, false);
NEW_CLASS(this->txtCurrCert, UI::GUITextBox(ui, this->pnlCurr, CSTR("")));
this->txtCurrCert->SetRect(104, 4, 200, 23, false);
this->txtCurrCert->SetReadOnly(true);
NEW_CLASS(this->lblCurrKey, UI::GUILabel(ui, this->pnlCurr, CSTR("Curr Key")));
this->lblCurrKey->SetRect(4, 28, 100, 23, false);
NEW_CLASS(this->txtCurrKey, UI::GUITextBox(ui, this->pnlCurr, CSTR("")));
this->txtCurrKey->SetRect(104, 28, 200, 23, false);
this->txtCurrKey->SetReadOnly(true);
NEW_CLASS(this->tcMain, UI::GUITabControl(ui, this));
this->tcMain->SetDockType(UI::GUIControl::DOCK_FILL);
this->tpFile = this->tcMain->AddTabPage(CSTR("File"));
NEW_CLASS(this->btnFileCert, UI::GUIButton(ui, this->tpFile, CSTR("Cert")));
this->btnFileCert->SetRect(4, 4, 75, 23, false);
this->btnFileCert->HandleButtonClick(OnFileCertClicked, this);
NEW_CLASS(this->lblFileCert, UI::GUILabel(ui, this->tpFile, CSTR("")));
this->lblFileCert->SetRect(84, 4, 200, 23, false);
NEW_CLASS(this->btnFileKey, UI::GUIButton(ui, this->tpFile, CSTR("Key")));
this->btnFileKey->SetRect(4, 28, 75, 23, false);
this->btnFileKey->HandleButtonClick(OnFileKeyClicked, this);
NEW_CLASS(this->lblFileKey, UI::GUILabel(ui, this->tpFile, CSTR("")));
this->lblFileKey->SetRect(84, 28, 200, 23, false);
NEW_CLASS(this->btnFileConfirm, UI::GUIButton(ui, this->tpFile, CSTR("OK")));
this->btnFileConfirm->SetRect(4, 52, 75, 23, false);
this->btnFileConfirm->HandleButtonClick(OnFileConfirmClicked, this);
this->tpGenerate = this->tcMain->AddTabPage(CSTR("Generate"));
NEW_CLASS(this->lblGenCountry, UI::GUILabel(ui, this->tpGenerate, CSTR("Country")));
this->lblGenCountry->SetRect(4, 4, 100, 23, false);
NEW_CLASS(this->txtGenCountry, UI::GUITextBox(ui, this->tpGenerate, CSTR("HK")));
this->txtGenCountry->SetRect(104, 4, 60, 23, false);
NEW_CLASS(this->lblGenCompany, UI::GUILabel(ui, this->tpGenerate, CSTR("Company")));
this->lblGenCompany->SetRect(4, 28, 100, 23, false);
NEW_CLASS(this->txtGenCompany, UI::GUITextBox(ui, this->tpGenerate, CSTR("SSWR")));
this->txtGenCompany->SetRect(104, 28, 200, 23, false);
NEW_CLASS(this->lblGenCommonName, UI::GUILabel(ui, this->tpGenerate, CSTR("CommonName")));
this->lblGenCommonName->SetRect(4, 52, 100, 23, false);
NEW_CLASS(this->txtGenCommonName, UI::GUITextBox(ui, this->tpGenerate, CSTR("localhost")));
this->txtGenCommonName->SetRect(104, 52, 200, 23, false);
NEW_CLASS(this->btnGenerate, UI::GUIButton(ui, this->tpGenerate, CSTR("Generate")));
this->btnGenerate->SetRect(104, 76, 75, 23, false);
this->btnGenerate->HandleButtonClick(OnGenerateClicked, this);
Text::StringBuilderUTF8 sb;
if (this->initCert)
{
this->initCert->ToShortName(sb);
this->txtCurrCert->SetText(sb.ToCString());
}
if (this->initKey)
{
sb.ClearStr();
this->initKey->ToShortName(sb);
this->txtCurrKey->SetText(sb.ToCString());
}
this->HandleDropFiles(OnFileDrop, this);
}
SSWR::AVIRead::AVIRSSLCertKeyForm::~AVIRSSLCertKeyForm()
{
}
void SSWR::AVIRead::AVIRSSLCertKeyForm::OnMonitorChanged()
{
this->SetDPI(this->core->GetMonitorHDPI(this->GetHMonitor()), this->core->GetMonitorDDPI(this->GetHMonitor()));
}
Crypto::Cert::X509Cert *SSWR::AVIRead::AVIRSSLCertKeyForm::GetCert()
{
return this->cert;
}
Crypto::Cert::X509File *SSWR::AVIRead::AVIRSSLCertKeyForm::GetKey()
{
return this->key;
}
| [
"sswroom@yahoo.com"
] | sswroom@yahoo.com |
99e1752f9b6509fd845a0297da2ed6328b24e131 | 6c7f8e95840c18656aa77bd3fc6bf347d5af901d | /main.cpp | 74741a61523a3db2b33e34e46da7b1e40b70272d | [
"MIT"
] | permissive | hckr/tbb_mandelbrot | 08d28759e63b73c70efd965022ad117affc2b576 | 6f59ee2d7f55caecc866c2069ace3822ad19da8c | refs/heads/master | 2020-12-11T20:23:37.370747 | 2020-07-06T16:52:45 | 2020-07-06T16:52:45 | 233,950,125 | 1 | 0 | MIT | 2020-07-06T16:52:46 | 2020-01-14T22:41:09 | C++ | UTF-8 | C++ | false | false | 3,873 | cpp | #include "mandelbrot.hpp"
#include <cmath>
#include <iterator>
#include <tbb/flow_graph.h>
#include <vector>
template <typename T>
class vector_source {
std::vector<T>::const_iterator current, end;
public:
vector_source(const std::vector<T> &vec) : current(std::begin(vec)), end(std::end(vec)) {}
bool operator()(T &obj) {
if (current != end) {
obj = *current++;
return true;
} else {
return false;
}
}
};
struct pixels_with_args {
std::vector<png::rgb_pixel> pixels;
mandelbrot::image_args image_args;
};
int main() {
std::vector<mandelbrot::image_args> image_args_vec{
{.width = 512u,
.height = 512u,
.top_left = {-2.0, -1.25},
.bottom_right = {0.5, 1.25}},
{.width = 512u,
.height = 512u,
.top_left = {-0.5, -0.5},
.bottom_right = {0.5, 0.5}},
{.width = 512u,
.height = 512u,
.top_left = {0.25, -0.05},
.bottom_right = {0.35, 0.05}},
{.width = 512u,
.height = 512u,
.top_left = {-0.80, 0.05},
.bottom_right = {-0.70, 0.15}}};
tbb::flow::graph g;
tbb::flow::source_node<mandelbrot::image_args> source(g, vector_source(image_args_vec), false);
tbb::flow::function_node<mandelbrot::image_args, pixels_with_args> draw1(g, tbb::flow::serial, [](auto args) {
return pixels_with_args{mandelbrot::imagePixels(args, mandelbrot::get_colors), args};
});
tbb::flow::function_node<mandelbrot::image_args, pixels_with_args> draw2(g, tbb::flow::serial, [](auto args) {
return pixels_with_args{mandelbrot::imagePixels(args, mandelbrot::get_colors2), args};
});
tbb::flow::join_node<tbb::flow::tuple<pixels_with_args, pixels_with_args>> join(g);
tbb::flow::function_node<tbb::flow::tuple<pixels_with_args, pixels_with_args>, std::tuple<pixels_with_args, pixels_with_args, pixels_with_args>> merge(g, tbb::flow::serial, [](auto args_tuple) {
pixels_with_args &data1 = tbb::flow::get<0>(args_tuple);
pixels_with_args &data2 = tbb::flow::get<1>(args_tuple);
pixels_with_args merged = data1;
const std::size_t offset = 25;
const std::size_t pixels_size = merged.pixels.size();
for (std::size_t i = 0; i < pixels_size; ++i) {
const auto offset_i = (i + offset) % pixels_size;
merged.pixels[i].red += data2.pixels[offset_i].red;
merged.pixels[i].red /= 2;
merged.pixels[i].green += data2.pixels[offset_i].green;
merged.pixels[i].green /= 2;
merged.pixels[i].blue += data2.pixels[offset_i].blue;
merged.pixels[i].blue /= 2;
}
return std::tuple{data1, data2, merged};
});
tbb::flow::function_node<std::tuple<pixels_with_args, pixels_with_args, pixels_with_args>, int> save(g, tbb::flow::serial, [](auto results) {
auto &results1 = std::get<0>(results);
auto &results2 = std::get<1>(results);
auto &results3 = std::get<2>(results);
mandelbrot::imageFromPixels(results1.image_args, results1.pixels).write(results1.image_args.filename() + "_1.png");
mandelbrot::imageFromPixels(results2.image_args, results2.pixels).write(results2.image_args.filename() + "_2.png");
mandelbrot::imageFromPixels(results3.image_args, results3.pixels).write(results3.image_args.filename() + "_3.png");
return 1;
});
tbb::flow::make_edge(source, draw1);
tbb::flow::make_edge(source, draw2);
tbb::flow::make_edge(draw1, tbb::flow::get<0>(join.input_ports()));
tbb::flow::make_edge(draw2, tbb::flow::get<1>(join.input_ports()));
tbb::flow::make_edge(join, merge);
tbb::flow::make_edge(merge, save);
source.activate();
g.wait_for_all();
// image.write("mandelbrot.png");
}
| [
"luke@luke.co.pl"
] | luke@luke.co.pl |
d695e9f477ae2ba5596f2d4d87a1cf8243c2ce36 | 60472fe9ec8d7226641ffc4e69c5941105c30175 | /EngineLuke/src/ML_ENGINE/ML_ENGINE/UI/Q3Window.h | 3ce70a1f1980b5571d7767069d96b874410007c7 | [
"MIT"
] | permissive | Sandy4321/team.luke | 35abd84e06250c383eedbf787eccc18589096778 | 6354d8237227276316a8f1e4bb10486a9ab968bf | refs/heads/master | 2021-01-21T06:30:24.589220 | 2016-12-02T23:15:16 | 2016-12-02T23:15:16 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,067 | h | #pragma once
#include <memory>
#include <string>
#include "ML\Dataframe\Dataframe.h"
class DecisionTree;
class Dataframe;
class Q3Window
{
public:
Q3Window();
~Q3Window();
bool IsActive() const { return _active; }
void SetActive(bool active) { _active = active; }
void Update();
private:
bool LoadDataframe();
bool IsValidTrainingSet();
std::string GetTrainingSetFilename() const {
return "Data/wine_both_red_n_white.csv"; }
Dataframe LoadDataframe(
const std::string& filename,
const std::vector<size_t>& selectedFeatures = {});
void ImguiBuildDecisionTree();
void ImguiShowTree();
void ImguiTest();
void ImguiTestFile();
void ImguiTestInput();
void RandomizeInputInstance();
private:
bool _active;
std::unique_ptr<DecisionTree> _decisionTree;
std::unique_ptr<Dataframe> _dataframe;
std::string _errorWindowMessage;
std::string _outputGeneratedNotice;
std::vector<float> _mins;
std::vector<float> _maxes;
Instance _inputInstance;
char _trainingsetFilename[255];
size_t _outputGeneratedNoticeTickCount;
int _testType;
};
| [
"hanstar17@gmail.com"
] | hanstar17@gmail.com |
eb8cdc61f9d472d1e099da6dede5575c901e79ea | 431673661a775aa831e1b1b78166715330ee3c6b | /src/circuit/task/builder/RepairTask.h | 616bef6cff161981a448677a5637018911d1a80a | [] | no_license | abma/CircuitAI | 4db0a1ff6e05a646edb768c245be0270e389a532 | 1e4147a8614ea49c81b6129bfddb19f84128d6dc | refs/heads/master | 2020-04-02T02:00:32.879292 | 2015-11-08T15:28:20 | 2015-11-08T15:28:20 | 45,738,293 | 0 | 0 | null | 2015-11-07T13:51:04 | 2015-11-07T13:51:04 | null | UTF-8 | C++ | false | false | 999 | h | /*
* RepairTask.h
*
* Created on: Jan 29, 2015
* Author: rlcevg
*/
#ifndef SRC_CIRCUIT_TASK_REPAIRTASK_H_
#define SRC_CIRCUIT_TASK_REPAIRTASK_H_
#include "task/builder/BuilderTask.h"
#include "unit/CircuitUnit.h"
namespace circuit {
class CEconomyManager;
class CBRepairTask: public IBuilderTask {
public:
CBRepairTask(ITaskManager* mgr, Priority priority, CCircuitUnit* target = nullptr, int timeout = 0);
virtual ~CBRepairTask();
virtual void Execute(CCircuitUnit* unit);
virtual void Update();
protected:
virtual void Finish() override final;
virtual void Cancel() override final;
public:
virtual void OnUnitIdle(CCircuitUnit* unit);
virtual void OnUnitDamaged(CCircuitUnit* unit, CEnemyUnit* attacker);
virtual void SetTarget(CCircuitUnit* unit);
protected:
CCircuitUnit* FindUnitToAssist(CCircuitUnit* unit);
CCircuitUnit::Id targetId; // Ignore "target" variable because ally units are vivid
};
} // namespace circuit
#endif // SRC_CIRCUIT_TASK_REPAIRTASK_H_
| [
"rlcevg@gmail.com"
] | rlcevg@gmail.com |
aaa4f1f325a3adcef706901a7c855f75aaff6382 | 53e38f2e49945c4e8dc8c18999232a2e40a2e14f | /CS303 Projects/Program 2/Program 2/MemUtilities.h | ab2046ce64acabd2f0b871575b86127555b1d424 | [] | no_license | mlh758/School-Projects | c5fed88817dd480e789324124534d102ed8cd1be | caea9fd70feb926b4dbdd37e6dfef8acf9084f53 | refs/heads/master | 2021-01-10T19:04:35.637733 | 2014-11-11T23:35:26 | 2014-11-11T23:35:26 | 22,628,010 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,026 | h | #include<list>
#include<string>
#include "BST.h"
#include <sstream>
struct Block
{
Block(int x, int y) : start(x), end(y) {}
int start, end;
friend bool operator <(Block& ls, Block& rs);
bool compare(const Block& ls, const Block& rs);
};
struct File
{
//Constructors
File() : name(""), size(0) {}
File(std::string n) : name(n), size(0) {}
File(std::string n, int s) : name(n), size(s) {}
int size;
std::string name;
std::list<Block> sectors;
//Comparison Operators
friend bool operator ==(const File& ls, const File& rs);
friend bool operator <(const File& ls, const File& rs);
friend bool operator >(const File& ls, const File& rs);
friend bool operator <=(const File& ls, const File& rs);
friend bool operator >=(const File& ls, const File& rs);
//Output Operator
friend std::ostream& operator<<(std::ostream& out, const File& rs);
};
class Manager
{
public:
//Constructor
Manager(unsigned long size, unsigned int blockSize);
//@precondition: Memory is available in freeSpace
//@postcondition: freeSpace is reduced in size
//@returns: list of Blocks sufficient to store required amount of data
std::list<Block> Malloc(int bytes);
//Reduction of Malloc, returns single block for directories
Block getBlock();
//@precondition: None
//@postcondition: freeSpace is increased in size
void Free(std::list<Block> freeMe);
//Accessor
int getSize() {return freeSpace.size(); }
//Output operator
friend std::ostream& operator <<(std::ostream& out, const Manager& print);
private:
std::list<Block> freeSpace;
int blockSize;
unsigned long total;
};
class Directory
{
public:
//Constructors
Directory(Manager& man) : name(""), dirSize(0), maxSize(128) {sectors.push_front(man.getBlock());}
Directory(std::string n, Manager& man) : name(n), dirSize(0), maxSize(128) {sectors.push_front(man.getBlock());}
//@precondition: None
//@postcondition: File is added to directory at location specified in file path if it does not already exist
// Memory is taken from free store
void AddFile(File& file, Manager& man);
//@precondition: None
//@postcondition: File is removed from directory specified in fileName. Memory is returned to free store
void Delete(std::string fileName, Manager& man);
//@precondition: None
//@postcondition: directory is added under directory at location specified in file path if it does not already exist
// memory is taken from free store
bool MkDir(std::string dirName, Manager& man);
//@precondition: None
//@postcondition: directory is removed under directory at location specified in file path
// memory is taken from free store
bool RmDir(std::string dirName, Manager& man);
//Accessor functions
int numFiles() const { return Files.getSize(); }
int numDirs() const { return Directories.getSize(); }
//@returns: Number of active files and directories under this directory
int getSize() const { return Files.getSize() + Directories.getSize(); }
//Comparison Operators
friend bool operator ==(const Directory& ls, const Directory& rs);
friend bool operator <(const Directory& ls, const Directory& rs);
friend bool operator >(const Directory& ls, const Directory& rs);
friend bool operator <=(const Directory& ls, const Directory& rs);
friend bool operator >=(const Directory& ls, const Directory& rs);
friend std::ostream& operator<<(std::ostream& out, const Directory& rs);
private:
int dirSize;
//Conversion for find operators NOT allowed for public use
Directory(std::string n) : name(n) {}
int maxSize;
std::string name;
BST<File> Files;
BST<Directory> Directories;
std::list<Block> sectors;
//@precondition: None
//@postcondition: If directory has grown beyond base size and is less than 50% utilized
// Directory surrenders one block of memory to free store and shrinks the max size
void reduceDir(Manager& man);
//@precondition: Memory is available in free store
//@postcondition: If directory is at max size, one block of memory is added
// max size increases by 128
void biggifyDir(Manager& man);
};
| [
"osiris2918@gmail.com"
] | osiris2918@gmail.com |
4c26842f184abfcb6dceac3ba8d2d47cfd4b336c | a3d6556180e74af7b555f8d47d3fea55b94bcbda | /chrome/browser/profiles/android/profile_resolver.cc | 69c019eea9955c256f84630ea8e48a501b318fd1 | [
"BSD-3-Clause"
] | permissive | chromium/chromium | aaa9eda10115b50b0616d2f1aed5ef35d1d779d6 | a401d6cf4f7bf0e2d2e964c512ebb923c3d8832c | refs/heads/main | 2023-08-24T00:35:12.585945 | 2023-08-23T22:01:11 | 2023-08-23T22:01:11 | 120,360,765 | 17,408 | 7,102 | BSD-3-Clause | 2023-09-10T23:44:27 | 2018-02-05T20:55:32 | null | UTF-8 | C++ | false | false | 7,908 | cc | // Copyright 2021 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/profiles/android/profile_resolver.h"
#include "base/android/callback_android.h"
#include "base/android/jni_android.h"
#include "base/android/jni_string.h"
#include "base/android/scoped_java_ref.h"
#include "base/files/file_path.h"
#include "base/functional/bind.h"
#include "base/functional/callback.h"
#include "base/functional/callback_helpers.h"
#include "base/path_service.h"
#include "chrome/browser/android/profile_key_startup_accessor.h"
#include "chrome/browser/android/proto/profile_token.pb.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/profiles/android/jni_headers/ProfileResolver_jni.h"
#include "chrome/browser/profiles/profile_android.h"
#include "chrome/browser/profiles/profile_key.h"
#include "chrome/browser/profiles/profile_key_android.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/common/chrome_paths.h"
using base::android::ConvertJavaStringToUTF8;
using base::android::ConvertUTF8ToJavaString;
using base::android::JavaParamRef;
using base::android::JavaRef;
using base::android::ScopedJavaLocalRef;
namespace profile_resolver {
namespace {
base::FilePath GetUserDataDir() {
base::FilePath user_data_dir;
base::PathService::Get(chrome::DIR_USER_DATA, &user_data_dir);
return user_data_dir;
}
base::FilePath GetAbsoluteProfilePath(const std::string& relative_string) {
return GetUserDataDir().Append(relative_string);
}
base::FilePath GetRelativeProfilePath(const base::FilePath& profile_path) {
base::FilePath user_data_dir = GetUserDataDir();
base::FilePath relative_path;
bool success =
GetUserDataDir().AppendRelativePath(profile_path, &relative_path);
DCHECK(success);
return relative_path;
}
void OnProfileLoadedFromManager(ProfileToken token_proto,
ProfileCallback callback,
Profile* profile) {
if (profile && !token_proto.otr_profile_id().empty()) {
Profile::OTRProfileID otrProfileId =
Profile::OTRProfileID::Deserialize(token_proto.otr_profile_id());
profile = profile->GetOffTheRecordProfile(otrProfileId,
/*create_if_needed=*/false);
}
std::move(callback).Run(profile);
}
void LookupProfileByToken(ProfileToken token_proto, ProfileCallback callback) {
base::FilePath absolute_path =
GetAbsoluteProfilePath(token_proto.relative_path());
g_browser_process->profile_manager()->LoadProfileByPath(
absolute_path,
/*incognito=*/false,
base::BindOnce(&OnProfileLoadedFromManager, std::move(token_proto),
std::move(callback)));
}
void ProfileToProfileKey(ProfileKeyCallback callback, Profile* profile) {
std::move(callback).Run(profile ? profile->GetProfileKey() : nullptr);
}
void OnResolvedProfile(const JavaRef<jobject>& j_callback, Profile* profile) {
ScopedJavaLocalRef<jobject> j_profile;
if (profile) {
ProfileAndroid* profile_android = ProfileAndroid::FromProfile(profile);
j_profile = profile_android->GetJavaObject();
}
base::android::RunObjectCallbackAndroid(j_callback, j_profile);
}
void OnResolvedProfileKey(const JavaRef<jobject>& j_callback,
ProfileKey* profile_key) {
ScopedJavaLocalRef<jobject> j_profile_key;
if (profile_key) {
ProfileKeyAndroid* profile_key_android =
profile_key->GetProfileKeyAndroid();
j_profile_key = profile_key_android->GetJavaObject();
}
base::android::RunObjectCallbackAndroid(j_callback, j_profile_key);
}
} // namespace
void ResolveProfile(std::string token, ProfileCallback callback) {
ProfileToken token_proto;
token_proto.ParseFromString(token);
return LookupProfileByToken(std::move(token_proto), std::move(callback));
}
void ResolveProfileKey(std::string token, ProfileKeyCallback callback) {
ProfileToken token_proto;
token_proto.ParseFromString(token);
// This will be null if the profile infra has started up. It will be non null
// when we're in reduced mode and can only use ProfileKey/SimpleFactoryKey.
ProfileKey* startup_profile_key =
ProfileKeyStartupAccessor::GetInstance()->profile_key();
if (startup_profile_key) {
// TODO(https://crbug.com/1186324): Does not currently support OTR
// resolution without profile infra.
if (!token_proto.otr_profile_id().empty()) {
std::move(callback).Run(nullptr);
return;
}
// In reduced mode only the main profile's key can be returned. Other
// profiles will resolve to null.
std::string relative_path =
GetRelativeProfilePath(startup_profile_key->GetPath()).value();
if (relative_path != token_proto.relative_path()) {
std::move(callback).Run(nullptr);
return;
}
std::move(callback).Run(startup_profile_key);
} else {
// Profile infra has already initialized, get it from the Profile instead
// because this supports more general resolution.
LookupProfileByToken(
std::move(token_proto),
base::BindOnce(&ProfileToProfileKey, std::move(callback)));
}
}
std::string TokenizeProfile(Profile* profile) {
if (!profile) {
return std::string();
}
ProfileToken token_proto;
token_proto.set_relative_path(
GetRelativeProfilePath(profile->GetPath()).value());
if (profile->IsOffTheRecord()) {
token_proto.set_otr_profile_id(profile->GetOTRProfileID().Serialize());
}
std::string token_string;
token_proto.SerializeToString(&token_string);
return token_string;
}
std::string TokenizeProfileKey(ProfileKey* profile_key) {
if (!profile_key) {
return std::string();
}
// TODO(https://crbug.com/1186324): Does not currently support tokenization of
// OTR ProfileKeys. They don't hold a OTRProfileID value.
DCHECK(!profile_key->IsOffTheRecord());
ProfileToken token_proto;
token_proto.set_relative_path(
GetRelativeProfilePath(profile_key->GetPath()).value());
std::string token_string;
token_proto.SerializeToString(&token_string);
return token_string;
}
static void JNI_ProfileResolver_ResolveProfile(
JNIEnv* env,
const JavaParamRef<jstring>& j_token,
const JavaParamRef<jobject>& j_callback) {
if (!j_token.obj()) {
base::android::RunObjectCallbackAndroid(j_callback,
ScopedJavaLocalRef<jobject>());
return;
}
std::string token = ConvertJavaStringToUTF8(env, j_token);
ResolveProfile(
std::move(token),
base::BindOnce(&OnResolvedProfile,
base::android::ScopedJavaGlobalRef<jobject>(j_callback)));
}
static void JNI_ProfileResolver_ResolveProfileKey(
JNIEnv* env,
const JavaParamRef<jstring>& j_token,
const JavaParamRef<jobject>& j_callback) {
if (!j_token.obj()) {
base::android::RunObjectCallbackAndroid(j_callback,
ScopedJavaLocalRef<jobject>());
return;
}
std::string token = ConvertJavaStringToUTF8(env, j_token);
ResolveProfileKey(
std::move(token),
base::BindOnce(&OnResolvedProfileKey,
base::android::ScopedJavaGlobalRef<jobject>(j_callback)));
}
static ScopedJavaLocalRef<jstring> JNI_ProfileResolver_TokenizeProfile(
JNIEnv* env,
const JavaParamRef<jobject>& j_profile) {
Profile* profile = ProfileAndroid::FromProfileAndroid(j_profile);
return ConvertUTF8ToJavaString(env, TokenizeProfile(profile));
}
static ScopedJavaLocalRef<jstring> JNI_ProfileResolver_TokenizeProfileKey(
JNIEnv* env,
const JavaParamRef<jobject>& j_profile_key) {
ProfileKey* profile_key =
ProfileKeyAndroid::FromProfileKeyAndroid(j_profile_key);
return ConvertUTF8ToJavaString(env, TokenizeProfileKey(profile_key));
}
} // namespace profile_resolver
| [
"chromium-scoped@luci-project-accounts.iam.gserviceaccount.com"
] | chromium-scoped@luci-project-accounts.iam.gserviceaccount.com |
6b46be3d532f5987b8a81567ce88d1ccc9b5b695 | 38ed316428d2b1a1936ecc6bb5ff94867910bcba | /mugsy-seqan/projects/library/seqan/find/find_bom.h | df9c6ab84749a15b0d9dfb3dfa82095fea81d054 | [
"Artistic-2.0"
] | permissive | kloetzl/mugsy | f875119b2323bfd93f082acb93a9db5b421cf95f | 8ccdf32858a7a5ab2f7b9b084d2190970feb97ec | refs/heads/master | 2021-05-20T20:59:40.864925 | 2020-04-02T16:17:27 | 2020-04-02T16:17:27 | 252,414,682 | 3 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 7,065 | h | /*==========================================================================
SeqAn - The Library for Sequence Analysis
http://www.seqan.de
============================================================================
Copyright (C) 2007
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 3 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.
============================================================================
$Id: find_bom.h 2653 2008-09-05 10:34:13Z doering@PCPOOL.MI.FU-BERLIN.DE $
==========================================================================*/
#ifndef SEQAN_HEADER_FIND_BOM_H
#define SEQAN_HEADER_FIND_BOM_H
namespace SEQAN_NAMESPACE_MAIN
{
//////////////////////////////////////////////////////////////////////////////
// BomAlgo
//////////////////////////////////////////////////////////////////////////////
/**
.Spec.BFAM:
..summary:Backward Factor Automaton Matching algorithm.
..general:Class.Pattern
..cat:Searching
..signature:Pattern<TNeedle, BFAM<TAutomaton> >
..param.TNeedle:The needle type.
...type:Class.String
..param.TAutomaton:A tag that specifies the used automaton.
...default:@Spec.BFAM<Oracle>@
..remarks.text:To be used in combination with the default specialization of @Class.Finder@.
*/
/**
.Spec.BFAM<Oracle>:
..summary:Backward Oracle Matching algorithm.
..general:Class.BFAM
..cat:Searching
..signature:Pattern<TNeedle, BFAM<Oracle> >
..param.TNeedle:The needle type.
...type:Class.String
..remarks.text:To be used in combination with the default specialization of @Class.Finder@.
*/
/**
.Spec.BFAM<Trie>:
..summary:Backward Suffix Trie Matching algorithm.
..general:Class.BFAM
..cat:Searching
..signature:Pattern<TNeedle, BFAM<Trie> >
..param.TNeedle:The needle type.
...type:Class.String
..remarks.text:To be used in combination with the default specialization of @Class.Finder@.
*/
///.Class.Pattern.param.TSpec.type:Spec.BFAM
struct Oracle; //Oracle Tag => "BOM"
struct Trie; //Trie Tag => "BTM"
template <typename TSpec = Oracle>
struct BFAM; //backward factor automaton searching
typedef BFAM<Oracle> BomAlgo; //deprecated, still there for compatibility reasons
//////////////////////////////////////////////////////////////////////////////
template <typename TNeedle, typename TSpec>
class Pattern<TNeedle, BFAM<TSpec> > {
//____________________________________________________________________________
private:
Pattern(Pattern const& other);
Pattern const& operator=(Pattern const & other);
//____________________________________________________________________________
public:
typedef typename Value<TNeedle>::Type TAlphabet;
typedef typename Size<TNeedle>::Type TSize;
Holder<TNeedle> data_host;
TSize needleLength;
TSize haystackLength;
TSize step;
Graph<Automaton<TAlphabet, void, WithoutEdgeId> > automaton;
//____________________________________________________________________________
Pattern() {
}
template <typename TNeedle2>
Pattern(TNeedle2 const & ndl)
{
SEQAN_CHECKPOINT
setHost(*this, ndl);
}
~Pattern() {
SEQAN_CHECKPOINT
}
//____________________________________________________________________________
};
//////////////////////////////////////////////////////////////////////////////
// Host Metafunctions
//////////////////////////////////////////////////////////////////////////////
template <typename TNeedle>
struct Host< Pattern<TNeedle, BomAlgo> >
{
typedef TNeedle Type;
};
template <typename TNeedle>
struct Host< Pattern<TNeedle, BomAlgo> const>
{
typedef TNeedle const Type;
};
//////////////////////////////////////////////////////////////////////////////
// Functions
//////////////////////////////////////////////////////////////////////////////
//BFAM<Oracle>: BOM Algorithm
template <typename TNeedle, typename TNeedle2>
inline void
setHost (Pattern<TNeedle, BFAM<Oracle> > & me, TNeedle2 const& needle)
{
SEQAN_CHECKPOINT
me.needleLength = length(needle);
clear(me.automaton);
createOracleOnReverse(me.automaton,needle);
setValue(me.data_host, needle);
}
//BFAM<Trie>: BTM Algorithm (the same as BOM, but with an trie)
template <typename TNeedle, typename TNeedle2>
inline void
setHost (Pattern<TNeedle, BFAM<Trie> > & me, TNeedle2 const& needle)
{
SEQAN_CHECKPOINT
me.needleLength = length(needle);
clear(me.automaton);
String<String<unsigned int> > terminal_state_map; //dummy
typedef typename Value<TNeedle2 const>::Type TValue;
String<TValue> reverse_string = needle;
reverseInPlace(reverse_string);
createSuffixTrie(me.automaton, terminal_state_map, reverse_string);
setValue(me.data_host, needle);
}
template <typename TNeedle, typename TNeedle2, typename TSpec>
inline void
setHost (Pattern<TNeedle, BFAM<TSpec> > & me, TNeedle2 & needle)
{
setHost(me, reinterpret_cast<TNeedle2 const &>(needle));
}
//____________________________________________________________________________
template <typename TNeedle, typename TSpec>
inline void _patternInit (Pattern<TNeedle, BFAM<TSpec> > & me)
{
SEQAN_CHECKPOINT
me.step = 0;
}
//____________________________________________________________________________
template <typename TFinder, typename TNeedle, typename TSpec>
inline bool
find(TFinder & finder, Pattern<TNeedle, BFAM<TSpec> > & me)
{
SEQAN_CHECKPOINT
if (empty(finder)) {
_patternInit(me);
_setFinderLength(finder, length(needle(me)));
_finderSetNonEmpty(finder);
me.haystackLength = length(container(finder));
} else
finder+=me.step;
if (me.haystackLength < me.needleLength) return false;
typedef typename Value<TNeedle>::Type TAlphabet;
typedef Graph<Automaton<TAlphabet> > TOracle;
typedef typename Size<TNeedle>::Type TSize;
typedef typename VertexDescriptor<TOracle>::Type TVertexDescriptor;
typedef typename EdgeDescriptor<TOracle>::Type TEdgeDescriptor;
TVertexDescriptor nilVal = getNil<TVertexDescriptor>();
while (position(finder) <= me.haystackLength - me.needleLength) {
TVertexDescriptor current = getRoot(me.automaton);
TSize j = me.needleLength;
while ((j>0) && (current != nilVal))
{
TAlphabet c = *(finder+(j-1));
current = targetVertex(me.automaton, findEdge(me.automaton, current, c));
--j;
}
if (current != nilVal) {
me.step = j + 1;
_setFinderEnd(finder, position(finder) + me.needleLength);
return true;
}
finder += j + 1;
}
return false;
}
}// namespace SEQAN_NAMESPACE_MAIN
#endif //#ifndef SEQAN_HEADER_FIND_SHIFTAND_H
| [
"angiuoli@8aca55ff-8d62-4810-9032-67e444260ce4"
] | angiuoli@8aca55ff-8d62-4810-9032-67e444260ce4 |
7ebba6c365bb5d1d116b8be06ecc839a2adf214b | e9e98eb7ae7afd2e5dac03984765c24362bab735 | /problems/11_container_with_water/solution.cpp | fa4b96e7fef6da8b0d4ea00378b262a664ad2088 | [] | no_license | Benjaminyuan/LeetCode | aca5e97ad75412837036e935b6fe54d3837a07ae | cab33323af8a3734f7e4560865f51bd051d820b0 | refs/heads/master | 2020-09-08T13:07:44.735761 | 2020-04-28T15:41:10 | 2020-04-28T15:41:10 | 146,283,799 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 456 | cpp | #include<vector>
#include<string>
using namespace std;
class Solution {
public:
int maxArea(vector<int>& height) {
int i=0,j= height.size()-1;
int area = INT_MIN;
while(i<j){
if(height[i] < height[j]){
area = max(area,height[i]*(j-i));
i++;
}else{
area = max(area,height[j]*(j-i));
j--;
}
}
return area;
}
}; | [
"1459477412@qq.com"
] | 1459477412@qq.com |
93e1d1ed3fd6d1b832066b32f93b7fd59ffde254 | b4ddb4ded3fd705d140e5f18a313490f1ed8a1ed | /Events/customapp.h | 5872a70444c2c0bf83bad02d2680ce5918a4169a | [] | no_license | Zandriy/QML_tests | 8e5cf563a677374ca913960df808cb608e9f0b7c | 9802f32fa76eef40d249d0cd82ba75e4f6690691 | refs/heads/master | 2018-10-12T17:22:41.576650 | 2018-07-30T23:04:02 | 2018-07-30T23:04:02 | 117,446,357 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 257 | h | #ifndef CUSTOMAPP_H
#define CUSTOMAPP_H
#include <QGuiApplication>
class CustomApp : public QGuiApplication
{
public:
CustomApp(int &argc, char **argv);
protected:
bool notify(QObject *receiver, QEvent *event) override;
};
#endif // CUSTOMAPP_H
| [
"andriy@zhabura.com"
] | andriy@zhabura.com |
4c4564839d7e3768c64f152f30cb0c03ac6562b6 | 877fff5bb313ccd23d1d01bf23b1e1f2b13bb85a | /app/src/main/cpp/dir7941/dir22339/file22355.cpp | 34b04b84e3c62fb12fd3140982b445a473382ce1 | [] | no_license | tgeng/HugeProject | 829c3bdfb7cbaf57727c41263212d4a67e3eb93d | 4488d3b765e8827636ce5e878baacdf388710ef2 | refs/heads/master | 2022-08-21T16:58:54.161627 | 2020-05-28T01:54:03 | 2020-05-28T01:54:03 | 267,468,475 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 115 | cpp | #ifndef file22355
#error "macro file22355 must be defined"
#endif
static const char* file22355String = "file22355"; | [
"tgeng@google.com"
] | tgeng@google.com |
3359e347068662919e1546249521beb9215f0c78 | 2edd4d0d97c232affb8c8e2f03a4efa00cbdc0f4 | /src/imgproc/object.cc | bd2dc2a72554a0fb2f49a8f5cc43381820fe1043 | [
"MIT"
] | permissive | akshonesports/node-opencv | 57d370e75ee8f19197f76a97b0b9e7674c07d1ce | fe42999e9ee529f193b53006c261c8411fce50a1 | refs/heads/3.x | 2021-01-19T16:02:48.514339 | 2018-01-13T11:20:58 | 2018-01-13T11:40:41 | 100,984,793 | 0 | 4 | null | 2017-10-31T16:47:01 | 2017-08-21T19:20:57 | C++ | UTF-8 | C++ | false | false | 839 | cc | #include "object.h"
namespace ncv {
namespace imgproc {
void ObjectInit(Local<Object> &target) {
// template match modes
DEFINE_CONST_ENUM(TM_SQDIFF);
DEFINE_CONST_ENUM(TM_SQDIFF_NORMED);
DEFINE_CONST_ENUM(TM_CCORR);
DEFINE_CONST_ENUM(TM_CCORR_NORMED);
DEFINE_CONST_ENUM(TM_CCOEFF);
DEFINE_CONST_ENUM(TM_CCOEFF_NORMED);
Nan::SetMethod(target, "matchTemplate", MatchTemplate);
}
NAN_METHOD(MatchTemplate) {
Nan::HandleScope scope;
ASSERT_INPUTARRAY_FROM_ARGS(image, 0);
ASSERT_INPUTARRAY_FROM_ARGS(templ, 1);
ASSERT_OUTPUTARRAY_FROM_ARGS(result, 2);
ASSERT_INT_FROM_ARGS(method, 3);
DEFAULT_OUTPUTARRAY_FROM_ARGS(mask, 4, cv::noArray());
TRY_CATCH_THROW_OPENCV(cv::matchTemplate(image, templ, result, method, mask));
}
}
}
| [
"slam@akshonesports.com"
] | slam@akshonesports.com |
6dc35dfdf21402dc126172f68a2b14a8b175cd1a | f83ef53177180ebfeb5a3e230aa29794f52ce1fc | /ACE/ACE_wrappers/TAO/tests/Bug_1020_Regression/server.cpp | c8e74a999a7c967644519616eee5d4f87badc0db | [
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-proprietary-license",
"LicenseRef-scancode-sun-iiop"
] | permissive | msrLi/portingSources | fe7528b3fd08eed4a1b41383c88ee5c09c2294ef | 57d561730ab27804a3172b33807f2bffbc9e52ae | refs/heads/master | 2021-07-08T01:22:29.604203 | 2019-07-10T13:07:06 | 2019-07-10T13:07:06 | 196,183,165 | 2 | 1 | Apache-2.0 | 2020-10-13T14:30:53 | 2019-07-10T10:16:46 | null | UTF-8 | C++ | false | false | 3,497 | cpp | #include "Server_i.h"
#include "ORB_Task.h"
#include "tao/Messaging/Messaging.h"
#include "tao/ORB_Core.h"
#include "ace/Get_Opt.h"
const ACE_TCHAR *ior_output_file = ACE_TEXT("test.ior");
#if defined (ACE_OPENVMS)
// need this to circumvent link error on OpenVMS
// has to do with interference in template instantiations
// for the server build by previous compilation of TestX
// components in client build which are reused by server
// without recompilation
ACE_Time_Value dum = ACE_Time_Value::zero;
#endif
int
parse_args (int argc, ACE_TCHAR *argv[]);
int
ACE_TMAIN(int argc, ACE_TCHAR *argv[])
{
try
{
CORBA::ORB_var orb =
CORBA::ORB_init (argc, argv);
CORBA::Object_var poa_object =
orb->resolve_initial_references("RootPOA");
PortableServer::POA_var root_poa =
PortableServer::POA::_narrow (poa_object.in ());
if (CORBA::is_nil (root_poa.in ()))
ACE_ERROR_RETURN ((LM_ERROR,
" (%P|%t) Panic: nil RootPOA\n"),
1);
PortableServer::POAManager_var poa_manager =
root_poa->the_POAManager ();
CORBA::Object_var object =
orb->resolve_initial_references ("PolicyCurrent");
if (parse_args (argc, argv) != 0)
return 1;
PortableServer::Servant_var<Server> impl;
{
Server * tmp;
// ACE_NEW_RETURN is the worst possible way to handle
// exceptions (think: what if the constructor allocates memory
// and fails?), but I'm not in the mood to fight for a more
// reasonable way to handle allocation errors in ACE.
ACE_NEW_RETURN (tmp,
Server(orb.in()),
1);
impl = tmp;
}
PortableServer::ObjectId_var id =
root_poa->activate_object (impl.in ());
CORBA::Object_var object_act = root_poa->id_to_reference (id.in ());
Test::Server_var server =
Test::Server::_narrow (object_act.in ());
CORBA::String_var ior =
orb->object_to_string (server.in ());
// If the ior_output_file exists, output the ior to it
FILE *output_file= ACE_OS::fopen (ior_output_file, "w");
if (output_file == 0)
ACE_ERROR_RETURN ((LM_ERROR,
"Cannot open output file for writing IOR: %s",
ior_output_file),
1);
ACE_OS::fprintf (output_file, "%s", ior.in ());
ACE_OS::fclose (output_file);
poa_manager->activate ();
ORB_Task task(orb.in());
task.activate(THR_NEW_LWP | THR_JOINABLE, 4, 1);
task.wait();
ACE_DEBUG ((LM_DEBUG, "(%P|%t) server - event loop finished\n"));
root_poa->destroy (1, 1);
orb->destroy ();
}
catch (const CORBA::Exception& ex)
{
ex._tao_print_exception ("Exception caught:");
return 1;
}
return 0;
}
int
parse_args (int argc, ACE_TCHAR *argv[])
{
ACE_Get_Opt get_opts (argc, argv, ACE_TEXT("o:"));
int c;
while ((c = get_opts ()) != -1)
switch (c)
{
case 'o':
ior_output_file = get_opts.opt_arg ();
break;
case '?':
default:
ACE_ERROR_RETURN ((LM_ERROR,
"usage: %s "
"-o <iorfile> "
"\n",
argv [0]),
-1);
}
// Indicates successful parsing of the command line
return 0;
}
| [
"lihuibin705@163.com"
] | lihuibin705@163.com |
04b689814d0388b899c56a393ee15032816dd11d | 2c27dd8c10e5450dd638eb52a11428f8fc389f6f | /0-Distribution.d/src/kernel/jump.cpp | abc1c1ee74e069fc2ca42504eb91f1d705238f63 | [
"MIT"
] | permissive | wa1tnr/yaffa_samD51-exp | 30a7908b396ca9364bf0b1b19e0c446b7779b00f | 555f0e0bbba5c453366960d16573d368065f62f3 | refs/heads/master | 2020-07-14T07:24:03.474141 | 2019-08-30T04:36:10 | 2019-08-30T04:36:10 | 205,272,617 | 0 | 0 | MIT | 2019-08-30T04:44:40 | 2019-08-30T00:18:48 | C | UTF-8 | C++ | false | false | 251 | cpp | // Fri Jun 9 02:32:35 UTC 2017
// 4735-a0f
#include <Arduino.h>
#include "../../yaffa.h"
// #include "Error_Codes.h"
#ifdef EXT_KERN_JUMP
#include "jump.h"
const char jump_str[] = "jump";
void _jump(void) {
ip = (cell_t*)((size_t)*ip);
}
#endif
| [
"samsuanchen@gmail.com"
] | samsuanchen@gmail.com |
50535d5edc4556bab5fb11ae8264d98994cf5a9d | 163dc8d3c9be4e2c3cf713b1ca6e1bd3993bcac6 | /include/mixr/terrain/srtm/SrtmHgtFile.hpp | 7d98fa3bf040680da92f9ea170916dd32b4a5d9f | [] | no_license | azcbuell/mixr | 3091c75d0d4f489ee8385ea38612d7b4bfe5550c | b1ccf3166f1feb0c4c8822a18adb83e8d2ceee8a | refs/heads/master | 2021-01-20T05:34:39.662113 | 2017-09-08T23:03:00 | 2017-09-08T23:03:00 | 101,452,440 | 0 | 0 | null | 2017-08-26T00:44:34 | 2017-08-26T00:44:34 | null | UTF-8 | C++ | false | false | 2,118 | hpp |
#ifndef __mixr_terrain_SrtmHgtFile_H__
#define __mixr_terrain_SrtmHgtFile_H__
#include "mixr/terrain/DataFile.hpp"
#include <iostream>
namespace mixr {
namespace base { class Number; }
namespace terrain {
//------------------------------------------------------------------------------
// Class: SrtmHgtFile
//
// Description: SRTM data loader.
//
// Adapted from terrain::DtedFile
//
// MIXR version by Christopher Buell
//
// obtain SRTM data files from ftp://e0srp01u.ecs.nasa.gov/srtm/version2
//
// This class read 2 types of SRTM elevation data sets.
// SRTM3 - 3 arc second intervals, equivalent resolution to DTED Level 1
// SRTM1 - 1 arc second intervals, equivalent resolution to DTED Level 2
// Only the elevation data is contained in the data set file.
// The other metadata is interpreted from the file name and file size.
// The SRTM file name are of the format...
// N00W000.hgt
// N00E000.hgt
// S00W000.hgt
// S00E000.hgt
// where N00/S00 is the latitude of the SW corner
// and W000/E000 is the longitude of the SW corner
// N/S and E/W may be upper or lower case.
// The file extension must be ".hgt" or ".HGT".
// SRTM1 - will have a file size of 25934402 bytes.
// SRTM3 - will have a file size of 2884802 bytes.
// A file of any other size will fail.
//
// A file name must have at least 11 characters
// A file name may have addition path prepended.
// Only the last 11 characters of the file name will be parse for the SW corner.
//
// Factory name: SrtmHgtFile
// Slots:
// N/A
//
//------------------------------------------------------------------------------
class SrtmHgtFile : public DataFile
{
DECLARE_SUBCLASS(SrtmHgtFile, DataFile)
public:
SrtmHgtFile();
private:
// Interpret signed-magnitude values from SRTM file
static short readValue(const unsigned char hbyte, const unsigned char lbyte);
bool readSrtmData(std::istream& in);
bool determineSrtmInfo(const std::string& srtmFilename, std::streamoff size);
virtual bool loadData() override;
};
}
}
#endif
| [
"doug@openeaagles.org"
] | doug@openeaagles.org |
ebd4cb6e4233e2dd63d0207861e5832b2780ba00 | fffc8d8d48790e322615fde5c5f353d86c8ef30b | /include/Board.h | f86d69daefed21a8a205ebd15df80cd2d220c4f2 | [
"CC0-1.0"
] | permissive | CA-Lee/OOP03-PTT | 195fa86d46aa4e998399555ad9e3d43c48bd80af | cd5aa1b9e99b846f21d57a0bb81409ed85571e55 | refs/heads/main | 2023-04-26T05:10:57.704239 | 2021-06-07T08:48:27 | 2021-06-07T08:48:27 | 368,603,698 | 0 | 1 | CC0-1.0 | 2021-06-06T17:10:18 | 2021-05-18T16:49:00 | C++ | UTF-8 | C++ | false | false | 934 | h | #pragma once
#include <string>
#include <vector>
#include <list>
#include "boost/serialization/access.hpp"
#include "boost/serialization/list.hpp"
#include "boost/serialization/string.hpp"
#include "Post.h"
using std::list;
using std::string;
using std::vector;
class Board
{
list<Post> post_list;
string id;
int viewed;
friend class boost::serialization::access;
template <class Archive>
void serialize(Archive &ar, const unsigned int version)
{
ar &post_list &id;
}
public:
Board() {}
Board(string id);
string get_id() const { return id; }
const list<Post> get_post_list() const { return post_list; }
list<Post>::iterator find_post(string post_id);
Post *add_post(string title, string author, string content);
void delete_post(string post_id);
void view() { viewed++; }
int get_view() const { return viewed; }
};
| [
"email@calee.tw"
] | email@calee.tw |
47d1d21aaa712647bbe56062855b6d3f1d0c8172 | 021f1b03b7e9ab6dd2263fc1e1e38a3eb35bb164 | /GameObjectManager.h | f31dc3a5501e308b555a326d0d1f42786ffd0048 | [] | no_license | joekrump/2D_physics_engine | 8d6b76ca5c7b145b533ae85a02e7c89067bf74d4 | c2ef4408db1780e08a0a68d11d1f0e77f56d65d6 | refs/heads/master | 2021-01-20T04:33:11.260519 | 2014-08-12T16:11:20 | 2014-08-12T16:11:20 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 595 | h | #pragma once
#include "VisibleGameObject.h"
class GameObjectManager
{
public:
GameObjectManager();
~GameObjectManager();
void Add(std::string name, VisibleGameObject* gameObject);
void Remove(std::string name);
int GetObjectCount() const;
VisibleGameObject* Get(std::string name) const;
void DrawAll(sf::RenderWindow& renderWindow);
void UpdateAll();
private:
std::map<std::string, VisibleGameObject*> _gameObjects;
sf::Clock clock;
struct GameObjectDeallocator
{
void operator()(const std::pair<std::string,VisibleGameObject*> & p) const
{
delete p.second;
}
};
}; | [
"krump.joseph@gmail.com"
] | krump.joseph@gmail.com |
bb3d64abe8180013e244db024113840a4413978c | cc3d87484a254cf4fdb40a91f014a22a18f1ab2a | /OpenGL Template/src/utils/FileLoader.cpp | 43c2f3d943605173ee4d0f175f6eb94b22417a48 | [] | no_license | TrueRegin/OpenGL-Template | 9028fa992d1e0cf3e72fa33eee6885aa4189d0b7 | 7f78c9a5981a80690577c6cc39dc92b1d90b6d9f | refs/heads/master | 2022-11-24T18:25:28.236890 | 2020-07-29T22:02:43 | 2020-07-29T22:02:43 | 278,865,056 | 1 | 3 | null | null | null | null | UTF-8 | C++ | false | false | 366 | cpp | #include "FileLoader.h"
std::string readFile(const char* path) {
std::fstream file(path);
std::string line;
std::stringstream fileContents;
if (file.is_open()) {
while (std::getline(file, line)) {
fileContents << line << "\n";
}
}
else {
printf("FILELOADER ERROR: No file exists at path: %s\n", path);
}
file.close();
return fileContents.str();
} | [
"36866793+MoCreatureGuy@users.noreply.github.com"
] | 36866793+MoCreatureGuy@users.noreply.github.com |
bc1da0b6f948ee508fd115207b8f293557dc2382 | 0e988b5d0d0579931083abbd522e6ef3e10da9a3 | /Luogu/p3406.cpp | 578fa3e3de70e284ed73536ae219b19488c6b210 | [
"MIT"
] | permissive | odeinjul/Solutions_Old | fc1b5c56134f43fe9c4bcfb4fcab26475bb2294f | 45da91cc8d0e4d5f645fc93234914456e87d1391 | refs/heads/master | 2022-04-10T13:14:41.456133 | 2020-03-08T07:50:23 | 2020-03-08T07:50:23 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 710 | cpp | #include<iostream>
#define min(a,b) a<b?a:b
#define ll long long
using namespace std;
ll n,m,cost=0,ci[100010],t[100010],a[100010],c[100010],b[100010];
int main()
{
cin>>n>>m;
for(ll i=1;i<=m;i++)
{
cin>>t[i];
}
for(ll i=1;i<=m-1;i++)
{
if(t[i]<t[i+1])
{
ci[t[i]]++;
ci[t[i+1]+1]--;
}
else
{
ci[t[i+1]]++;
ci[t[i]+1]--;
}
}
for(ll i=1;i<=n;i++)
{
ci[i]+=ci[i-1];
}
for(ll i=1;i<=n-1;i++)
{
cin>>a[i]>>b[i]>>c[i];
cost+=min(a[i]*ci[i],c[i]+b[i]*ci[i]);
//cout<<i<<' '<<cost<<endl;
}
cout<<cost<<endl;
return 0;
} | [
"joshua007v@outlook.com"
] | joshua007v@outlook.com |
de309ed95be4361369db17347977c49171e4c75f | b5fc429abacd646acd18dd1a6573ce4afb9e313f | /collection/学习王保明设计模式/src/03dip.cpp | 68c009dd10d46c2c0731972c6158d8b73a91573f | [] | no_license | zhe-ma/Collection | 2148490db21ce71f9f92f52e0f3bd6924318a939 | b32db101fec2fecbb10ea184bbbbaca1b9bfdac7 | refs/heads/master | 2021-09-20T23:02:32.250681 | 2018-08-16T12:19:27 | 2018-08-16T12:19:27 | null | 0 | 0 | null | null | null | null | GB18030 | C++ | false | false | 1,590 | cpp | #include <iostream>
#include <string>
#include <vector>
#include <list>
using namespace std;
// Dependence Inversion Principle.
// 高层模块不应该依赖低层模块,二者都应该依赖其抽象;抽象不应该依赖细节;细节应该依赖抽象。
// 让Computer框架和具体的厂商进行解耦合。Computer依赖抽象Cpu等,而不依赖具体的某个厂商的Cpu。
// 所以无论换成哪个厂商的Cpu都不会影响Computer框架。
class Cpu {
public:
virtual void Work() = 0;
};
class Memory {
public:
virtual void Work() = 0;
};
class HardDisk {
public:
virtual void Work() = 0;
};
class Computer3 {
public:
Computer3(Cpu* cpu, Memory* memory, HardDisk* hard_disk)
: cpu_(cpu)
, memory_(memory)
, hard_disk_(hard_disk) {
}
~Computer3() {
if (cpu_ != NULL) {
delete cpu_;
}
if (memory_ != NULL) {
delete memory_;
}
if (hard_disk_ != NULL) {
delete hard_disk_;
}
}
void Work() {
cpu_->Work();
memory_->Work();
hard_disk_->Work();
}
private:
Cpu* cpu_;
Memory* memory_;
HardDisk* hard_disk_;
};
class IntelCpu : public Cpu {
public:
void Work() override {
cout << "I am Intel CPU!" << endl;
}
};
class XSHardDisk : public HardDisk {
public:
void Work() override {
cout << "I am XS Hard Disk!" << endl;
}
};
class JSDMemory : public Memory {
public:
void Work() override {
cout << "I am JSD Memory" << endl;
}
};
int main03() {
Computer3 computer(new IntelCpu, new JSDMemory, new XSHardDisk);
computer.Work();
return 0;
}
| [
"mailMazhe@163.com"
] | mailMazhe@163.com |
e0bf5f42b5aa6e17c3cc30c6c0c0e78590a1e53f | 45dd56794fb683b1ed99e477a5e385b5a91228f9 | /src/convolution_filter.h | 3b682953e81b3d0c10e79374ac122459277b0976 | [
"Unlicense"
] | permissive | derkreature/img2sky | 925c68e4bb820d1d1c757dffa62506bafea5d99f | affd6d8a237f92a777aafc60cada1eae62a3b608 | refs/heads/master | 2020-04-05T18:28:38.867207 | 2015-05-28T10:07:19 | 2015-05-28T10:07:19 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 471 | h | #ifndef __CONVOLUTION_FILTER_H__
#define __CONVOLUTION_FILTER_H__
namespace Edge_Detect {
// Main function for edge detection, All memory (for input AND output) should be allocated before calling this, and bBPP must be 1, 2, 3 or 4 (not multiples of 8).
void EdgeDetect_Filter(unsigned char* pOut, const unsigned char* pSourceData, const unsigned char bBPP, const long ulWidth, const long ulHeight, const float fConstant = 8.0f);
}
#endif // __CONVOLUTION_FILTER_H__
| [
"rlyeh.nospam@gmail.com"
] | rlyeh.nospam@gmail.com |
c8a7f668077f6df86ed08d598afef1bdaafc45ee | e91b16ab1799a614282fb0260ca696ddb6143b16 | /LeetCode/q0991_Basic_Calculator.cpp | 0f5705048e134f10f8f9a5a3c1aed013537867f1 | [] | no_license | bluesquanium/Algorithm | cde3b561aa05413fcd61fe5ce013fe3e8c122a9c | 9d87cbc4efc5a3382376fc74b82915832659e97b | refs/heads/master | 2022-06-24T10:55:58.011128 | 2022-05-29T09:50:58 | 2022-05-29T09:50:58 | 174,677,803 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 1,889 | cpp | #include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll, ll>
#define LINF 0x7fffffffffffffff
#define INF 0x7fffffff
using namespace std;
class Solution {
public:
int calculate(string s) {
vector<ll> st;
vector<ll> st_num;
ll num = 0, num_check = 0;
for (ll i = 0; i < s.size(); i++) {
if ('0' <= s[i] && s[i] <= '9') {
num_check = 1;
num *= 10;
num += s[i] - '0';
}
else if (s[i] != ' ') {
if (s[i] == '(') {
st.push_back(s[i]);
}
else if (s[i] == ')') {
if (num_check) {
st_num.push_back(num);
num = 0;
num_check = 0;
}
while (!st.empty()) {
char cmd = st.back();
st.pop_back();
if (cmd == '(') {
break;
}
ll t1 = st_num.back(); st_num.pop_back();
ll t2 = st_num.back(); st_num.pop_back();
if (cmd == '+') {
t2 += t1;
}
else {
t2 -= t1;
}
st_num.push_back(t2);
}
}
else {
if (num_check) {
st_num.push_back(num);
num = 0;
num_check = 0;
}
if (!st.empty() && st.back() != '(') {
char cmd = st.back();
st.pop_back();
ll t1 = st_num.back(); st_num.pop_back();
ll t2 = st_num.back(); st_num.pop_back();
if (cmd == '+') {
t2 += t1;
}
else {
t2 -= t1;
}
st_num.push_back(t2);
}
st.push_back(s[i]);
}
}
}
if (num_check == 1) {
st_num.push_back(num);
}
while (!st.empty()) {
char cmd = st.back();
st.pop_back();
ll t1 = st_num.back(); st_num.pop_back();
ll t2 = st_num.back(); st_num.pop_back();
if (cmd == '+') {
t2 += t1;
}
else {
t2 -= t1;
}
st_num.push_back(t2);
}
return st_num.back();
}
};
| [
"bluesquanium@gmail.com"
] | bluesquanium@gmail.com |
7d936f07dbb6a1759c37718bd04e9c0cc24e1e67 | bb170b52a1c136e403730cc843467ded4bfaf93f | /main.cpp | 580209cb2f033d84579bc730cb4aa6ced897f51c | [] | no_license | pangpangpang3/launcher-demo | 4599d9d50ab14d05dbd61d007b77f3909ebf942c | 06e582752311d4cbc2c621d18c708a143b1b315b | refs/heads/master | 2021-01-10T05:22:26.730434 | 2015-12-14T02:58:10 | 2015-12-14T02:58:10 | 47,802,492 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 167 | cpp | #include "launcher.h"
#include <QApplication>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
Launcher w;
w.show();
return a.exec();
}
| [
"penghui@linuxdeepin.com"
] | penghui@linuxdeepin.com |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.