blob_id stringlengths 40 40 | directory_id stringlengths 40 40 | path stringlengths 3 264 | content_id stringlengths 40 40 | detected_licenses listlengths 0 85 | license_type stringclasses 2 values | repo_name stringlengths 5 140 | snapshot_id stringlengths 40 40 | revision_id stringlengths 40 40 | branch_name stringclasses 905 values | visit_date timestamp[us]date 2015-08-09 11:21:18 2023-09-06 10:45:07 | revision_date timestamp[us]date 1997-09-14 05:04:47 2023-09-17 19:19:19 | committer_date timestamp[us]date 1997-09-14 05:04:47 2023-09-06 06:22:19 | github_id int64 3.89k 681M ⌀ | star_events_count int64 0 209k | fork_events_count int64 0 110k | gha_license_id stringclasses 22 values | gha_event_created_at timestamp[us]date 2012-06-07 00:51:45 2023-09-14 21:58:39 ⌀ | gha_created_at timestamp[us]date 2008-03-27 23:40:48 2023-08-21 23:17:38 ⌀ | gha_language stringclasses 141 values | src_encoding stringclasses 34 values | language stringclasses 1 value | is_vendor bool 1 class | is_generated bool 2 classes | length_bytes int64 3 10.4M | extension stringclasses 115 values | content stringlengths 3 10.4M | authors listlengths 1 1 | author_id stringlengths 0 158 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
b9f825e5275a53686416f347c1d14e9303d02e92 | 04fee3ff94cde55400ee67352d16234bb5e62712 | /8.3/test/num.cpp | 1744f4277c8e07d7f0d7ee80bd4e542541741335 | [] | no_license | zsq001/oi-code | 0bc09c839c9a27c7329c38e490c14bff0177b96e | 56f4bfed78fb96ac5d4da50ccc2775489166e47a | refs/heads/master | 2023-08-31T06:14:49.709105 | 2021-09-14T02:28:28 | 2021-09-14T02:28:28 | 218,049,685 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 475 | cpp | #include<iostream>
#include<queue>
typedef int int_;
#define int long long
using namespace std;
int a[20000*10000];
priority_queue<int> q;
int_ main()
{
freopen("num.in","r",stdin);
freopen("num.out","w",stdout);
int n,m,k;
int cnt=0;
cin>>n>>m>>k;
cnt=min(n,min(m,k));
for(int i=1;i<=cnt;i++)
{
for(int j=1;j<=cnt;j++)
{
a[i*j]++;
}
}
cnt=0;
while(k--)
{
if(a[cnt]==0)
cnt++;
a[cnt]--;
}
cout<<cnt;
return 0;
}
| [
"15276671309@163.com"
] | 15276671309@163.com |
2fb47cbc36038b9b969330cc56ebb210ad62e230 | 53d3217e7ad52b4f7861d77c1aa40f883b453b59 | /Database Systems and Applications/lab3/client.cpp | a61166bdbb77b377e1d890f2270964eebe3f8ef1 | [] | no_license | LazyTigerLi/Undergraduate_Programs | 0ba1af89294930c17d20ce6aeceabc9a25bd10ac | 109e9f40897532e91c8ecad7942fd6a982381050 | refs/heads/master | 2020-04-29T14:47:57.747961 | 2019-07-02T18:46:56 | 2019-07-02T18:46:56 | 176,207,897 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,185 | cpp | #include "client.h"
Client::Client(QSqlDatabase database, QVector<QString> tableName, QWidget *parent)
:Table(database,tableName,parent)
{
searchButton = new QPushButton("search",this);
id = new QLineEdit(this);
name = new QLineEdit(this);
telephone = new QLineEdit(this);
address = new QLineEdit(this);
staffID = new QLineEdit(this);
staffName = new QLineEdit(this);
idLabel = new QLabel("ID",this);
nameLabel = new QLabel("name",this);
telephoneLabel = new QLabel("telephone",this);
addressLabel = new QLabel("address",this);
staffIDLabel = new QLabel("staff ID",this);
staffNameLabel = new QLabel("staff name",this);
connect(searchButton,SIGNAL(clicked(bool)),this,SLOT(search()));
QHBoxLayout *layout = new QHBoxLayout;
layout->addWidget(idLabel);
layout->addWidget(id);
layout->addWidget(nameLabel);
layout->addWidget(name);
layout->addWidget(telephoneLabel);
layout->addWidget(telephone);
layout->addWidget(addressLabel);
layout->addWidget(address);
layout->addWidget(staffIDLabel);
layout->addWidget(staffID);
layout->addWidget(staffNameLabel);
layout->addWidget(staffName);
layout->addWidget(searchButton);
tableLayout[0]->addLayout(layout);
setLayout(mainLayout);
queryModel = new QSqlQueryModel(tableView[0]);
}
Client::~Client()
{}
void Client::search()
{
QString idQuery,nameQuery,telephoneQuery,addressQuery,
staffIDQuery,staffNameQuery;
if(id->text() == "")idQuery = "";
else idQuery = " `Client`.`ID` = '" + id->text() + "' and ";
if(name->text() == "")nameQuery = "";
else nameQuery = " `Client`.`Name` = '" + name->text() + "' and ";
if(telephone->text() == "")telephoneQuery = "";
else telephoneQuery = " `Client`.`telephone` = '" + telephone->text() + "' and ";
if(address->text() == "")addressQuery = "";
else addressQuery = " `Client`.`Address` like '%" + address->text() + "%' and ";
if(staffID->text() == "")staffIDQuery = "";
else staffIDQuery = " `Client`.`Staff ID` = '" + staffID->text() + "' and ";
if(staffName->text() == "")staffNameQuery = "";
else staffNameQuery = " `Staff`.`Name` = '" + staffName->text() + "' and ";
QString query;
if(staffID->text() == "" && staffName->text() == "")
query = "select * from `mydb`.`Client` where " + idQuery + nameQuery + telephoneQuery
+ addressQuery + " `Client`.`ID` is not null";
else query = "select `Client`.`ID`,`Client`.`Name`,`Client`.`Telephone`,`Client`.`Address`"
",`Client`.`Contact Name`,`Client`.`Contact Telephone`,`Client`.`Contact Email`"
",`Client`.`Relationship with Contact`,`Client`.`Staff ID`,`Staff`.`Name`"
",`Client`.`Relationship with Staff` from `mydb`.`Client`,`mydb`.`Staff` where"
" `Client`.`Staff ID` = `Staff`.`ID` and " + idQuery + nameQuery + telephoneQuery
+ addressQuery + staffIDQuery + staffNameQuery + " `Client`.`ID` is not null";
qDebug("%s",qPrintable(query));
queryModel->setQuery(QSqlQuery(query,db));
tableView[0]->setModel(queryModel);
}
| [
"ln2016@mail.ustc.edu.cn"
] | ln2016@mail.ustc.edu.cn |
4afa7351df8428b9971d9fb0eea31ea70466a4c4 | ed7e1851605dc417f471b24bceaa4efe3ebd577e | /Export/mac64/cpp/release/obj/include/lime/utils/Log.h | 31d230a8a69d247f95566a2b0611f3f1e1f27b79 | [] | no_license | matthewswallace/StableUITest | 60d88c31540b07b68fc5867cb42901676012cf31 | 8ad46db8245bb8a9bc38b3525dfcdfe90c78b845 | refs/heads/master | 2021-01-12T14:41:07.354460 | 2016-10-26T23:13:43 | 2016-10-26T23:13:43 | 72,050,029 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | true | 1,932 | h | // Generated by Haxe 3.3.0
#ifndef INCLUDED_lime_utils_Log
#define INCLUDED_lime_utils_Log
#ifndef HXCPP_H
#include <hxcpp.h>
#endif
HX_DECLARE_CLASS0(Sys)
HX_DECLARE_CLASS2(lime,utils,Log)
namespace lime{
namespace utils{
class HXCPP_CLASS_ATTRIBUTES Log_obj : public hx::Object
{
public:
typedef hx::Object super;
typedef Log_obj OBJ_;
Log_obj();
public:
void __construct();
inline void *operator new(size_t inSize, bool inContainer=false,const char *inName="lime.utils.Log")
{ return hx::Object::operator new(inSize,inContainer,inName); }
inline void *operator new(size_t inSize, int extra)
{ return hx::Object::operator new(inSize+extra,false,"lime.utils.Log"); }
static hx::ObjectPtr< Log_obj > __new();
static Dynamic __CreateEmpty();
static Dynamic __Create(hx::DynamicArray inArgs);
//~Log_obj();
HX_DO_RTTI_ALL;
static bool __GetStatic(const ::String &inString, Dynamic &outValue, hx::PropertyAccess inCallProp);
static bool __SetStatic(const ::String &inString, Dynamic &ioValue, hx::PropertyAccess inCallProp);
static void __register();
static void __init__();
::String __ToString() const { return HX_HCSTRING("Log","\x64","\x0c","\x3a","\x00"); }
static void __boot();
static Int level;
static void debug(::String message, ::Dynamic info);
static ::Dynamic debug_dyn();
static void error(::String message, ::Dynamic info);
static ::Dynamic error_dyn();
static void info(::String message, ::Dynamic info);
static ::Dynamic info_dyn();
static void print(::String message);
static ::Dynamic print_dyn();
static void println(::String message);
static ::Dynamic println_dyn();
static void verbose(::String message, ::Dynamic info);
static ::Dynamic verbose_dyn();
static void warn(::String message, ::Dynamic info);
static ::Dynamic warn_dyn();
};
} // end namespace lime
} // end namespace utils
#endif /* INCLUDED_lime_utils_Log */
| [
"matthew.wallace@riotgames.com"
] | matthew.wallace@riotgames.com |
094e18e212fba84fc17325d779c7276956ba7231 | b2527b0256448bba1795c3b3c766089b9e818c11 | /training/2015.8.2/H.cpp | 0eda9ce9a07050756619aa396cf9d9b50ad50132 | [] | no_license | zxok365/melody-of-canon | 0befe10647f2db88d852a2a9c7157578fea44e55 | 646b2df65cdeaa5aca28759dc0db4e1348b80a71 | refs/heads/master | 2016-09-16T17:03:47.020659 | 2016-03-29T12:13:46 | 2016-03-29T12:13:46 | 40,532,360 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 754 | cpp | #include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
using namespace std;
const int N = 50005, INF = 0x3f3f3f3f;
pair<int, int> link[N];
int ans[N];
int main()
{
int n, m, q, i, j, k;
while (scanf("%d%d%d", &n, &m, &q) == 3)
{
for (i = 1; i <= m; ++ i)
{
scanf("%d%d", &j, &k);
link[i] = make_pair(j,k);
}
sort(link + 1, link + m + 1);
int a = INF, b = INF, now = m;
for (i = n; i >= 1; -- i)
{
while (link[now].first == i && now > 0)
{
int c = link[now].second;
if (c <= a)
{
b = a;
a = c;
}
else if (c <= b)
{
b = c;
}
now--;
}
ans[i] = b;
}
for (i = 1; i <= q; ++ i)
{
scanf("%d", &j);
printf("%d\n", max(j - ans[j], 0));
}
}
}
| [
"zxjszy@126.com"
] | zxjszy@126.com |
b99bfdaaa627b4e13ebf69b5df0a29e9ba931c9d | fb0e651a452e469637d101deb0c2245591410bd8 | /SouthernForestBattle.cpp | cb9cd49d26f881b7570f477f58584dc6e12178df | [] | no_license | yabem/Vintage-RPG | a29e971cec37e4f33d2692c99d5a912d72b2e6c2 | 7ba44c6519329bb3a4d0b58b4984d9b595b0c4d5 | refs/heads/master | 2021-01-10T18:35:11.363008 | 2015-12-02T03:46:16 | 2015-12-02T03:46:16 | 27,652,933 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,230 | cpp | #include "SouthernForestBattle.h"
SouthernForestBattle::SouthernForestBattle(ImageStore *imageStore , int layoutSize) :
CustomAreaMap(imageStore , NULL , NULL , NULL , NULL , layoutSize){
}
SouthernForestBattle::~SouthernForestBattle(){
}
void SouthernForestBattle::loadLayers(){
Layer *backgroundLayer = new Layer(imageStore->getBitMap("desertRegion") ,
15 , 20 , this->backgroundLayerLayout , 300);
this->loadLayer(backgroundLayer);
}
void SouthernForestBattle::loadBackgroundLayerMapConfiguration(){
int backgroundLayerLayout[] ={
150,150,150,150,150,150,150,150,150,150,150,150,150,150,150,150,150,150,
150,150,
114,114,114,114,114,114,114,114,114,114,114,114,114,114,114,114,114,114,114,
114,
152,152,152,152,152,152,152,152,152,152,152,152,152,152,152,152,152,152,152,
152,
153,153,153,153,153,153,153,153,153,153,153,153,153,153,153,153,153,153,153,
153,
154,154,154,154,154,154,154,154,154,154,154,154,154,154,154,154,154,154,154,
154,
155,155,155,155,155,155,155,155,155,155,155,155,155,155,155,155,155,155,155,
155,
156,156,156,156,156,156,156,156,156,156,156,156,156,156,156,156,156,156,156,
156,
156,156,156,156,156,156,156,156,156,156,156,156,156,156,156,156,156,156,156,
156,
156,156,156,156,156,156,156,156,156,156,156,156,156,156,156,156,156,156,156,
156,
156,156,156,156,156,156,156,156,156,156,156,156,156,156,156,156,156,156,156,
156,
156,156,156,156,156,156,156,156,156,156,156,156,156,156,156,156,156,156,156,
156,
156,156,156,156,156,156,156,156,156,156,156,156,156,156,156,156,156,156,156,
156,
156,156,156,156,156,156,156,156,156,156,156,156,156,156,156,156,156,156,156,
156,
156,156,156,156,156,156,156,156,156,156,156,156,156,156,156,156,156,156,156,
156,
156,156,156,156,156,156,156,156,156,156,156,156,156,156,156,156,156,156,156,
156
};
this->backgroundLayerLayout = new int[this->layoutSize];
for(int i = 0 ; i < this->layoutSize ; i++)
this->backgroundLayerLayout[i] = backgroundLayerLayout[i];
} | [
"username@users.noreply.github.com"
] | username@users.noreply.github.com |
0d0f7a7484d51660d7ada9e5cd6f9c165b5ce9d1 | f9878ed3b5cc55b1951a7e96b7ef65e605a98a1d | /pal/__bits/platform_sdk | 303bec69c60e46f683b4927785c9ceb6745a2ed7 | [
"MIT"
] | permissive | svens/pal | f6064877421df42d135b75bf105b708ba7f0065b | f84e64eabe1ad7ed872bb27dbc132b8f763251f2 | refs/heads/master | 2023-08-03T06:05:34.217203 | 2022-09-16T19:04:32 | 2022-09-16T19:04:32 | 251,578,528 | 0 | 0 | MIT | 2023-03-21T18:08:26 | 2020-03-31T11:06:12 | C++ | UTF-8 | C++ | false | false | 763 | #pragma once // -*- C++ -*-
#if __pal_os_windows
// included from header: assume nothing, leak nothing
#if !defined(WIN32_LEAN_AND_MEAN)
#define pal_WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
#endif
#if !defined(NOMINMAX)
#define pal_NOMINMAX
#define NOMINMAX
#endif
#include <windows.h>
#if defined(pal_WIN32_LEAN_AND_MEAN)
#undef pal_WIN32_LEAN_AND_MEAN
#undef WIN32_LEAN_AND_MEAN
#endif
#if defined(pal_NOMINMAX)
#undef pal_NOMINMAX
#undef NOMINMAX
#endif
#else
// included from source, must be first
#if defined(_WIN32) || defined(_WIN64)
#define WIN32_LEAN_AND_MEAN
#define WIN32_NO_STATUS
#define NOMINMAX
#include <windows.h>
#undef WIN32_NO_STATUS
#include <winternl.h>
#include <ntstatus.h>
#endif
#endif
| [
"sven@alt.ee"
] | sven@alt.ee | |
6f45619619745a4f81100b8cc4789f1dbe9865d7 | caa72ac60e731d6982f310ac38838009f5de474e | /Opdracht9/insertNumbers.h | 62d475397cb5b05f541b811de6dcd0329197fd34 | [] | no_license | DannyvdMee/C-Plus-Plus--Portfolio | efe1f73ad116338141656178e988915748d190c5 | 0286d2534b019b5b9e3f7f05da0ba8eb1cbdc3f9 | refs/heads/master | 2020-03-28T23:34:25.905075 | 2018-09-25T07:07:59 | 2018-09-25T07:07:59 | 149,298,291 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 416 | h | //
// Created by Danny van der Mee on 02/03/18.
//
#include <iostream>
using namespace std;
int *insertNumbers();
int numbers[4] = {};
int *insertNumbers()
{
cout << "Insert A: ";
cin >> numbers[0];
cout << "\n";
cout << "Insert B: ";
cin >> numbers[1];
cout << "\n";
cout << "Insert C: ";
cin >> numbers[2];
cout << "\n";
cout << "Insert D: ";
cin >> numbers[3];
cout << "\n";
return numbers;
} | [
"danny.vandermee@edu-kw1c.nl"
] | danny.vandermee@edu-kw1c.nl |
207087d653d0e8ccac11f684cbdab7d4a1ba3d73 | b55a216d79994395c10392adbd36f362669fdbcb | /cpp/1746.cpp | 9776a07320b0fd29af554a39cdfa0bc02177be9f | [] | no_license | ronaksingh27/cses-solutions | 6186f9cb94727674c98915435eb58d8f1b987219 | 1b859e0adfb127021f3dae632e1b8c98984c83c3 | refs/heads/master | 2023-08-24T22:41:14.721383 | 2021-09-23T14:04:53 | 2021-09-23T14:04:53 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 965 | cpp | #include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7, N = 1e5 + 5, M = 105;
int n, m, x[N], f[N][M];
int main() {
ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
cin >> n >> m;
for (int i = 1; i <= n; ++i) {
cin >> x[i];
}
if (x[1]) {
f[1][x[1]] = 1;
} else {
fill(f[1] + 1, f[1] + 1 + m, 1);
}
for (int i = 2; i <= n; ++i) {
if (x[i]) {
f[i][x[i]] = f[i - 1][x[i]];
if (x[i] > 1) {
(f[i][x[i]] += f[i - 1][x[i] - 1]) %= MOD;
}
if (x[i] < m) {
(f[i][x[i]] += f[i - 1][x[i] + 1]) %= MOD;
}
} else {
for (int j = 1; j <= m; ++j) {
f[i][j] = f[i - 1][j];
if (j > 1) {
(f[i][j] += f[i - 1][j - 1]) %= MOD;
}
if (j < m) {
(f[i][j] += f[i - 1][j + 1]) %= MOD;
}
}
}
}
int ans = 0;
for (int j = 1; j <= m; ++j) {
(ans += f[n][j]) %= MOD;
}
cout << ans << "\n";
return 0;
}
| [
"baohiep2013@gmail.com"
] | baohiep2013@gmail.com |
6f1b566872da6e331712876b0577f0dd531d7949 | d63c4c79d0bf83ae646d0ac023ee0528a0f4a879 | /cs343/a6/keyboard.cc | 73f0247522c6a36ff634ef9d1c1c3fc8b21a9634 | [] | no_license | stratigoster/UW | 4dc31f08f7f1c9a958301105dcad481c39c5361f | 7a4bff4f1476607c43278c488f70d01077b1566b | refs/heads/master | 2021-07-07T04:52:01.543221 | 2011-08-15T05:08:48 | 2011-08-15T05:08:48 | 10,858,995 | 1 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 2,085 | cc | #include "keyboard.h"
#include "browser.h"
#include <iostream>
#include <map>
using namespace std;
Keyboard::Keyboard( Browser &browser ) : browser(browser) {}
void Keyboard::main() {
cout << "\t" << "KEYBOARD: starting" << endl;
// map chars to enums
map<char,Commands> kind;
kind['f'] = FindTopic, kind['d'] = DisplayFile, kind['p'] = PrintCache,
kind['c'] = ClearCache, kind['k'] = KillServer, kind['q'] = Quit;
char cmd;
string arg, rest;
int N;
// process commands
for (;;) {
cin >> cmd;
if ( cin.eof() ) {
cmd = 'q';
}
switch (cmd) {
case 'f':
case 'd':
cin >> arg;
cout << "\t" << "KEYBOARD: requesting "
<< (cmd == 'f' ? "topic information" : "url content")
<< " \"" << arg << "\"" << endl;
browser.keyboard( kind[cmd], arg );
break;
case 'p':
case 'c':
cout << "\t" << "KEYBOARD: " << (cmd == 'p' ? "printing" : "clearing") << " cache" << endl;
browser.keyboard( kind[cmd] );
break;
case 'k':
cin >> N;
if ( N >= 0 ) {
cout << "\t" << "KEYBOARD: request termination of server " << N << " from TNS" << endl;
browser.keyboard( kind[cmd], N );
} else {
cout << "\t" << "KEYBOARD: must specify a server id >= 0" << endl;
}
break;
case 'q':
cout << "\t" << "KEYBOARD: ending" << endl;
browser.keyboard( kind[cmd] );
break;
default:
cout << "\t" << "KEYBOARD: invalid command " << cmd << " ignoring line" << endl;
break;
}
// quit
if ( cmd == 'q' ) break;
// skip remaining text on line
getline(cin, rest);
if (rest != "") {
cout << "\t" << "KEYBOARD: skipping remaining text on line \""
<< rest << "\"" << endl;
}
}
browser.done();
}
| [
"nissan.pow@gmail.com"
] | nissan.pow@gmail.com |
2bfa5266ff361443bcb956e63a811c2df1e107b9 | 3a2e0625022ac1704b4a71a889bfdf2c9506eb85 | /parsing/Regex.hh | f7095f3601b4e997fe00d20ce17a11fcaf0c0c19 | [] | no_license | rusign/Plazza | 715074d380f2887036169a39d7b509f4588cf461 | afe392da3d4c50f83b01dce6c5592065d169d791 | refs/heads/master | 2020-05-01T19:22:35.336926 | 2019-03-25T19:20:59 | 2019-03-25T19:20:59 | 177,647,303 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 345 | hh | #ifndef REGEX_HH_
# define REGEX_HH_
#include "Regex.hh"
#include <regex.h>
#include <iostream>
#include <string>
class Regex
{
public :
Regex(void);
~Regex(void);
bool checkEmail(const std::string &email);
bool checkIp(const std::string &);
private :
regex_t _regexEmail;
regex_t _regexIp;
};
#endif
| [
"nicolas.rusig@epitech.eu"
] | nicolas.rusig@epitech.eu |
6d6845ad3571eba1aa88490dc8bd42e2d91a9671 | a9effd0e63e65382ab2c3c5fbb5c5116f4306033 | /OGE/light.cpp | 0a73a9c3f51328dc69d7e6918780dc9f61642b4e | [] | no_license | jwthomp/OGE | 7cdf8ce96d0c44ea1bfcac063b6a2a745cf23a60 | ddf059dea71c0879cb44c1c62ba4df1d6086b721 | refs/heads/master | 2022-11-19T21:54:57.073795 | 2020-07-22T17:21:16 | 2020-07-22T17:21:16 | 281,739,974 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 926 | cpp | #include "light.h"
#include "allocator_array.h"
#include "ref_counted.h"
#define LIGHT_MAX_NUMBER (512)
static ref_counted<light, LIGHT_MAX_NUMBER, allocator_array<ref_count_store<light, LIGHT_MAX_NUMBER>>> g_allocator_light;
light::light()
{
m_type = LIGHT_TYPE_NONE;
m_shadow_casting = false;
m_spot_direction.set(0.0f, 0.0f, 0.0f);
m_spot_exponent = 1.0f;
m_spot_cos_cutoff = 1.0f;
m_specular_power = 16.0f;
}
light::~light()
{
}
void light_system_init()
{
g_allocator_light.init(LIGHT_MAX_NUMBER);
}
void light_system_shutdown()
{
g_allocator_light.shutdown();
}
light * light_create(char *p_name)
{
return g_allocator_light.create(p_name);
}
void light_release(light *p_light)
{
g_allocator_light.release(p_light);
}
uint8 light_get_count()
{
return (uint8)g_allocator_light.get_allocated_count();
}
light * light_get_from_index(uint8 p_index)
{
return g_allocator_light.get_from_index(p_index);
} | [
"jeffthompson@granular.ag"
] | jeffthompson@granular.ag |
449bedf50e7a746e04757b52dd0d3c772c6fae5a | 786de89be635eb21295070a6a3452f3a7fe6712c | /psddl_pdsdata/tags/V00-05-03/include/cspad.ddl.h | 1f383ef8fb868706412e8f4e2b69e9492a815ef3 | [] | no_license | connectthefuture/psdmrepo | 85267cfe8d54564f99e17035efe931077c8f7a37 | f32870a987a7493e7bf0f0a5c1712a5a030ef199 | refs/heads/master | 2021-01-13T03:26:35.494026 | 2015-09-03T22:22:11 | 2015-09-03T22:22:11 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 51,631 | h | #ifndef PSDDLPDS_CSPAD_DDL_H
#define PSDDLPDS_CSPAD_DDL_H 1
// *** Do not edit this file, it is auto-generated ***
#include <vector>
#include <iosfwd>
#include <cstddef>
#include "pdsdata/xtc/TypeId.hh"
#include "ndarray/ndarray.h"
namespace PsddlPds {
namespace CsPad {
enum {
MaxQuadsPerSensor = 4 /**< Defines number of quadrants in a CsPad device. */
};
enum {
ASICsPerQuad = 16 /**< Total number of ASICs in one quadrant. */
};
enum {
RowsPerBank = 26 /**< Number of rows per readout bank? */
};
enum {
FullBanksPerASIC = 7 /**< Number of full readout banks per one ASIC? */
};
enum {
BanksPerASIC = 8 /**< Number of readout banks per one ASIC? */
};
enum {
ColumnsPerASIC = 185 /**< Number of columns readout by single ASIC. */
};
enum {
MaxRowsPerASIC = 194 /**< Maximum number of rows readout by single ASIC. */
};
enum {
PotsPerQuad = 80 /**< Number of POTs? per single quadrant. */
};
enum {
TwoByTwosPerQuad = 4 /**< Total number of 2x2s in single quadrant. */
};
enum {
SectorsPerQuad = 8 /**< Total number of sectors (2x1) per single quadrant. */
};
/** Enum specifying different running modes. */
enum RunModes {
NoRunning,
RunButDrop,
RunAndSendToRCE,
RunAndSendTriggeredByTTL,
ExternalTriggerSendToRCE,
ExternalTriggerDrop,
NumberOfRunModes,
};
/** Enum specifying different data collection modes. */
enum DataModes {
normal = 0,
shiftTest = 1,
testData = 2,
reserved = 3,
};
/** @class CsPadDigitalPotsCfg
Class defining configuration for CsPad POTs?
*/
class CsPadDigitalPotsCfg {
public:
/** Note: this overloaded method accepts shared pointer argument which must point to an object containing
this instance, the returned ndarray object can be used even after this instance disappears. */
template <typename T>
ndarray<const uint8_t, 1> pots(const boost::shared_ptr<T>& owner) const {
const uint8_t* data = &_pots[0];
return make_ndarray(boost::shared_ptr<const uint8_t>(owner, data), PotsPerQuad);
}
/** Note: this method returns ndarray instance which does not control lifetime
of the data, do not use returned ndarray after this instance disappears. */
ndarray<const uint8_t, 1> pots() const { return make_ndarray(&_pots[0], PotsPerQuad); }
static uint32_t _sizeof() { return ((((0+(1*(PotsPerQuad)))+1)-1)/1)*1; }
private:
uint8_t _pots[PotsPerQuad];
};
/** @class CsPadReadOnlyCfg
Class defining read-only configuration.
*/
class CsPadReadOnlyCfg {
public:
CsPadReadOnlyCfg()
{
}
CsPadReadOnlyCfg(uint32_t arg__shiftTest, uint32_t arg__version)
: _shiftTest(arg__shiftTest), _version(arg__version)
{
}
uint32_t shiftTest() const { return _shiftTest; }
uint32_t version() const { return _version; }
static uint32_t _sizeof() { return 8; }
private:
uint32_t _shiftTest;
uint32_t _version;
};
/** @class ProtectionSystemThreshold
*/
class ProtectionSystemThreshold {
public:
ProtectionSystemThreshold()
{
}
ProtectionSystemThreshold(uint32_t arg__adcThreshold, uint32_t arg__pixelCountThreshold)
: _adcThreshold(arg__adcThreshold), _pixelCountThreshold(arg__pixelCountThreshold)
{
}
uint32_t adcThreshold() const { return _adcThreshold; }
uint32_t pixelCountThreshold() const { return _pixelCountThreshold; }
static uint32_t _sizeof() { return 8; }
private:
uint32_t _adcThreshold;
uint32_t _pixelCountThreshold;
};
/** @class CsPadGainMapCfg
Class defining ASIC gain map.
*/
class CsPadGainMapCfg {
public:
/** Array with the gain map for single ASIC.
Note: this overloaded method accepts shared pointer argument which must point to an object containing
this instance, the returned ndarray object can be used even after this instance disappears. */
template <typename T>
ndarray<const uint16_t, 2> gainMap(const boost::shared_ptr<T>& owner) const {
const uint16_t* data = &_gainMap[0][0];
return make_ndarray(boost::shared_ptr<const uint16_t>(owner, data), ColumnsPerASIC, MaxRowsPerASIC);
}
/** Array with the gain map for single ASIC.
Note: this method returns ndarray instance which does not control lifetime
of the data, do not use returned ndarray after this instance disappears. */
ndarray<const uint16_t, 2> gainMap() const { return make_ndarray(&_gainMap[0][0], ColumnsPerASIC, MaxRowsPerASIC); }
static uint32_t _sizeof() { return ((((0+(2*(ColumnsPerASIC)*(MaxRowsPerASIC)))+2)-1)/2)*2; }
private:
uint16_t _gainMap[ColumnsPerASIC][MaxRowsPerASIC]; /**< Array with the gain map for single ASIC. */
};
/** @class ConfigV1QuadReg
Configuration data for single quadrant.
*/
class ConfigV1QuadReg {
public:
/** Note: this overloaded method accepts shared pointer argument which must point to an object containing
this instance, the returned ndarray object can be used even after this instance disappears. */
template <typename T>
ndarray<const uint32_t, 1> shiftSelect(const boost::shared_ptr<T>& owner) const {
const uint32_t* data = &_shiftSelect[0];
return make_ndarray(boost::shared_ptr<const uint32_t>(owner, data), TwoByTwosPerQuad);
}
/** Note: this method returns ndarray instance which does not control lifetime
of the data, do not use returned ndarray after this instance disappears. */
ndarray<const uint32_t, 1> shiftSelect() const { return make_ndarray(&_shiftSelect[0], TwoByTwosPerQuad); }
/** Note: this overloaded method accepts shared pointer argument which must point to an object containing
this instance, the returned ndarray object can be used even after this instance disappears. */
template <typename T>
ndarray<const uint32_t, 1> edgeSelect(const boost::shared_ptr<T>& owner) const {
const uint32_t* data = &_edgeSelect[0];
return make_ndarray(boost::shared_ptr<const uint32_t>(owner, data), TwoByTwosPerQuad);
}
/** Note: this method returns ndarray instance which does not control lifetime
of the data, do not use returned ndarray after this instance disappears. */
ndarray<const uint32_t, 1> edgeSelect() const { return make_ndarray(&_edgeSelect[0], TwoByTwosPerQuad); }
uint32_t readClkSet() const { return _readClkSet; }
uint32_t readClkHold() const { return _readClkHold; }
uint32_t dataMode() const { return _dataMode; }
uint32_t prstSel() const { return _prstSel; }
uint32_t acqDelay() const { return _acqDelay; }
uint32_t intTime() const { return _intTime; }
uint32_t digDelay() const { return _digDelay; }
uint32_t ampIdle() const { return _ampIdle; }
uint32_t injTotal() const { return _injTotal; }
uint32_t rowColShiftPer() const { return _rowColShiftPer; }
/** read-only configuration */
const CsPad::CsPadReadOnlyCfg& ro() const { return _readOnly; }
const CsPad::CsPadDigitalPotsCfg& dp() const { return _digitalPots; }
/** Gain map. */
const CsPad::CsPadGainMapCfg& gm() const { return _gainMap; }
static uint32_t _sizeof() { return ((((((((((((((((((0+(4*(TwoByTwosPerQuad)))+(4*(TwoByTwosPerQuad)))+4)+4)+4)+4)+4)+4)+4)+4)+4)+4)+(CsPad::CsPadReadOnlyCfg::_sizeof()))+(CsPad::CsPadDigitalPotsCfg::_sizeof()))+(CsPad::CsPadGainMapCfg::_sizeof()))+4)-1)/4)*4; }
private:
uint32_t _shiftSelect[TwoByTwosPerQuad];
uint32_t _edgeSelect[TwoByTwosPerQuad];
uint32_t _readClkSet;
uint32_t _readClkHold;
uint32_t _dataMode;
uint32_t _prstSel;
uint32_t _acqDelay;
uint32_t _intTime;
uint32_t _digDelay;
uint32_t _ampIdle;
uint32_t _injTotal;
uint32_t _rowColShiftPer;
CsPad::CsPadReadOnlyCfg _readOnly; /**< read-only configuration */
CsPad::CsPadDigitalPotsCfg _digitalPots;
CsPad::CsPadGainMapCfg _gainMap; /**< Gain map. */
};
/** @class ConfigV2QuadReg
Configuration data for single quadrant.
*/
class ConfigV2QuadReg {
public:
/** Note: this overloaded method accepts shared pointer argument which must point to an object containing
this instance, the returned ndarray object can be used even after this instance disappears. */
template <typename T>
ndarray<const uint32_t, 1> shiftSelect(const boost::shared_ptr<T>& owner) const {
const uint32_t* data = &_shiftSelect[0];
return make_ndarray(boost::shared_ptr<const uint32_t>(owner, data), TwoByTwosPerQuad);
}
/** Note: this method returns ndarray instance which does not control lifetime
of the data, do not use returned ndarray after this instance disappears. */
ndarray<const uint32_t, 1> shiftSelect() const { return make_ndarray(&_shiftSelect[0], TwoByTwosPerQuad); }
/** Note: this overloaded method accepts shared pointer argument which must point to an object containing
this instance, the returned ndarray object can be used even after this instance disappears. */
template <typename T>
ndarray<const uint32_t, 1> edgeSelect(const boost::shared_ptr<T>& owner) const {
const uint32_t* data = &_edgeSelect[0];
return make_ndarray(boost::shared_ptr<const uint32_t>(owner, data), TwoByTwosPerQuad);
}
/** Note: this method returns ndarray instance which does not control lifetime
of the data, do not use returned ndarray after this instance disappears. */
ndarray<const uint32_t, 1> edgeSelect() const { return make_ndarray(&_edgeSelect[0], TwoByTwosPerQuad); }
uint32_t readClkSet() const { return _readClkSet; }
uint32_t readClkHold() const { return _readClkHold; }
uint32_t dataMode() const { return _dataMode; }
uint32_t prstSel() const { return _prstSel; }
uint32_t acqDelay() const { return _acqDelay; }
uint32_t intTime() const { return _intTime; }
uint32_t digDelay() const { return _digDelay; }
uint32_t ampIdle() const { return _ampIdle; }
uint32_t injTotal() const { return _injTotal; }
uint32_t rowColShiftPer() const { return _rowColShiftPer; }
uint32_t ampReset() const { return _ampReset; }
uint32_t digCount() const { return _digCount; }
uint32_t digPeriod() const { return _digPeriod; }
/** read-only configuration */
const CsPad::CsPadReadOnlyCfg& ro() const { return _readOnly; }
const CsPad::CsPadDigitalPotsCfg& dp() const { return _digitalPots; }
/** Gain map. */
const CsPad::CsPadGainMapCfg& gm() const { return _gainMap; }
static uint32_t _sizeof() { return (((((((((((((((((((((0+(4*(TwoByTwosPerQuad)))+(4*(TwoByTwosPerQuad)))+4)+4)+4)+4)+4)+4)+4)+4)+4)+4)+4)+4)+4)+(CsPad::CsPadReadOnlyCfg::_sizeof()))+(CsPad::CsPadDigitalPotsCfg::_sizeof()))+(CsPad::CsPadGainMapCfg::_sizeof()))+4)-1)/4)*4; }
private:
uint32_t _shiftSelect[TwoByTwosPerQuad];
uint32_t _edgeSelect[TwoByTwosPerQuad];
uint32_t _readClkSet;
uint32_t _readClkHold;
uint32_t _dataMode;
uint32_t _prstSel;
uint32_t _acqDelay;
uint32_t _intTime;
uint32_t _digDelay;
uint32_t _ampIdle;
uint32_t _injTotal;
uint32_t _rowColShiftPer;
uint32_t _ampReset;
uint32_t _digCount;
uint32_t _digPeriod;
CsPad::CsPadReadOnlyCfg _readOnly; /**< read-only configuration */
CsPad::CsPadDigitalPotsCfg _digitalPots;
CsPad::CsPadGainMapCfg _gainMap; /**< Gain map. */
};
/** @class ConfigV3QuadReg
Configuration data for single quadrant.
*/
class ConfigV3QuadReg {
public:
/** Note: this overloaded method accepts shared pointer argument which must point to an object containing
this instance, the returned ndarray object can be used even after this instance disappears. */
template <typename T>
ndarray<const uint32_t, 1> shiftSelect(const boost::shared_ptr<T>& owner) const {
const uint32_t* data = &_shiftSelect[0];
return make_ndarray(boost::shared_ptr<const uint32_t>(owner, data), TwoByTwosPerQuad);
}
/** Note: this method returns ndarray instance which does not control lifetime
of the data, do not use returned ndarray after this instance disappears. */
ndarray<const uint32_t, 1> shiftSelect() const { return make_ndarray(&_shiftSelect[0], TwoByTwosPerQuad); }
/** Note: this overloaded method accepts shared pointer argument which must point to an object containing
this instance, the returned ndarray object can be used even after this instance disappears. */
template <typename T>
ndarray<const uint32_t, 1> edgeSelect(const boost::shared_ptr<T>& owner) const {
const uint32_t* data = &_edgeSelect[0];
return make_ndarray(boost::shared_ptr<const uint32_t>(owner, data), TwoByTwosPerQuad);
}
/** Note: this method returns ndarray instance which does not control lifetime
of the data, do not use returned ndarray after this instance disappears. */
ndarray<const uint32_t, 1> edgeSelect() const { return make_ndarray(&_edgeSelect[0], TwoByTwosPerQuad); }
uint32_t readClkSet() const { return _readClkSet; }
uint32_t readClkHold() const { return _readClkHold; }
uint32_t dataMode() const { return _dataMode; }
uint32_t prstSel() const { return _prstSel; }
uint32_t acqDelay() const { return _acqDelay; }
uint32_t intTime() const { return _intTime; }
uint32_t digDelay() const { return _digDelay; }
uint32_t ampIdle() const { return _ampIdle; }
uint32_t injTotal() const { return _injTotal; }
uint32_t rowColShiftPer() const { return _rowColShiftPer; }
uint32_t ampReset() const { return _ampReset; }
uint32_t digCount() const { return _digCount; }
uint32_t digPeriod() const { return _digPeriod; }
uint32_t biasTuning() const { return _biasTuning; }
uint32_t pdpmndnmBalance() const { return _pdpmndnmBalance; }
/** read-only configuration */
const CsPad::CsPadReadOnlyCfg& ro() const { return _readOnly; }
const CsPad::CsPadDigitalPotsCfg& dp() const { return _digitalPots; }
/** Gain map. */
const CsPad::CsPadGainMapCfg& gm() const { return _gainMap; }
static uint32_t _sizeof() { return (((((((((((((((((((((((0+(4*(TwoByTwosPerQuad)))+(4*(TwoByTwosPerQuad)))+4)+4)+4)+4)+4)+4)+4)+4)+4)+4)+4)+4)+4)+4)+4)+(CsPad::CsPadReadOnlyCfg::_sizeof()))+(CsPad::CsPadDigitalPotsCfg::_sizeof()))+(CsPad::CsPadGainMapCfg::_sizeof()))+4)-1)/4)*4; }
private:
uint32_t _shiftSelect[TwoByTwosPerQuad];
uint32_t _edgeSelect[TwoByTwosPerQuad];
uint32_t _readClkSet;
uint32_t _readClkHold;
uint32_t _dataMode;
uint32_t _prstSel;
uint32_t _acqDelay;
uint32_t _intTime;
uint32_t _digDelay;
uint32_t _ampIdle;
uint32_t _injTotal;
uint32_t _rowColShiftPer;
uint32_t _ampReset;
uint32_t _digCount;
uint32_t _digPeriod;
uint32_t _biasTuning;
uint32_t _pdpmndnmBalance;
CsPad::CsPadReadOnlyCfg _readOnly; /**< read-only configuration */
CsPad::CsPadDigitalPotsCfg _digitalPots;
CsPad::CsPadGainMapCfg _gainMap; /**< Gain map. */
};
/** @class ConfigV1
Configuration data for complete CsPad device.
*/
class ConfigV1 {
public:
enum { TypeId = Pds::TypeId::Id_CspadConfig /**< XTC type ID value (from Pds::TypeId class) */ };
enum { Version = 1 /**< XTC type version number */ };
uint32_t concentratorVersion() const { return _concentratorVersion; }
uint32_t runDelay() const { return _runDelay; }
uint32_t eventCode() const { return _eventCode; }
uint32_t inactiveRunMode() const { return _inactiveRunMode; }
uint32_t activeRunMode() const { return _activeRunMode; }
uint32_t tdi() const { return _testDataIndex; }
uint32_t payloadSize() const { return _payloadPerQuad; }
uint32_t badAsicMask0() const { return _badAsicMask0; }
uint32_t badAsicMask1() const { return _badAsicMask1; }
uint32_t asicMask() const { return _AsicMask; }
uint32_t quadMask() const { return _quadMask; }
const CsPad::ConfigV1QuadReg& quads(uint32_t i0) const { return _quads[i0]; }
uint32_t numAsicsRead() const;
uint32_t numQuads() const;
uint32_t numSect() const;
static uint32_t _sizeof() { return ((((44+(CsPad::ConfigV1QuadReg::_sizeof()*(MaxQuadsPerSensor)))+4)-1)/4)*4; }
/** Method which returns the shape (dimensions) of the data returned by quads() method. */
std::vector<int> quads_shape() const;
private:
uint32_t _concentratorVersion;
uint32_t _runDelay;
uint32_t _eventCode;
uint32_t _inactiveRunMode;
uint32_t _activeRunMode;
uint32_t _testDataIndex;
uint32_t _payloadPerQuad;
uint32_t _badAsicMask0;
uint32_t _badAsicMask1;
uint32_t _AsicMask;
uint32_t _quadMask;
CsPad::ConfigV1QuadReg _quads[MaxQuadsPerSensor];
};
/** @class ConfigV2
Configuration data for complete CsPad device.
*/
class ConfigV2 {
public:
enum { TypeId = Pds::TypeId::Id_CspadConfig /**< XTC type ID value (from Pds::TypeId class) */ };
enum { Version = 2 /**< XTC type version number */ };
uint32_t concentratorVersion() const { return _concentratorVersion; }
uint32_t runDelay() const { return _runDelay; }
uint32_t eventCode() const { return _eventCode; }
uint32_t inactiveRunMode() const { return _inactiveRunMode; }
uint32_t activeRunMode() const { return _activeRunMode; }
uint32_t tdi() const { return _testDataIndex; }
uint32_t payloadSize() const { return _payloadPerQuad; }
uint32_t badAsicMask0() const { return _badAsicMask0; }
uint32_t badAsicMask1() const { return _badAsicMask1; }
uint32_t asicMask() const { return _AsicMask; }
uint32_t quadMask() const { return _quadMask; }
uint32_t roiMasks() const { return _roiMask; }
const CsPad::ConfigV1QuadReg& quads(uint32_t i0) const { return _quads[i0]; }
uint32_t numAsicsRead() const;
/** ROI mask for given quadrant */
uint32_t roiMask(uint32_t iq) const;
/** Number of ASICs in given quadrant */
uint32_t numAsicsStored(uint32_t iq) const;
/** Total number of quadrants in setup */
uint32_t numQuads() const;
/** Total number of sections (2x1) in all quadrants */
uint32_t numSect() const;
static uint32_t _sizeof() { return ((((48+(CsPad::ConfigV1QuadReg::_sizeof()*(MaxQuadsPerSensor)))+4)-1)/4)*4; }
/** Method which returns the shape (dimensions) of the data returned by quads() method. */
std::vector<int> quads_shape() const;
private:
uint32_t _concentratorVersion;
uint32_t _runDelay;
uint32_t _eventCode;
uint32_t _inactiveRunMode;
uint32_t _activeRunMode;
uint32_t _testDataIndex;
uint32_t _payloadPerQuad;
uint32_t _badAsicMask0;
uint32_t _badAsicMask1;
uint32_t _AsicMask;
uint32_t _quadMask;
uint32_t _roiMask;
CsPad::ConfigV1QuadReg _quads[MaxQuadsPerSensor];
};
/** @class ConfigV3
Configuration data for complete CsPad device.
*/
class ConfigV3 {
public:
enum { TypeId = Pds::TypeId::Id_CspadConfig /**< XTC type ID value (from Pds::TypeId class) */ };
enum { Version = 3 /**< XTC type version number */ };
uint32_t concentratorVersion() const { return _concentratorVersion; }
uint32_t runDelay() const { return _runDelay; }
uint32_t eventCode() const { return _eventCode; }
/** Note: this overloaded method accepts shared pointer argument which must point to an object containing
this instance, the returned ndarray object can be used even after this instance disappears. */
template <typename T>
ndarray<const CsPad::ProtectionSystemThreshold, 1> protectionThresholds(const boost::shared_ptr<T>& owner) const {
const CsPad::ProtectionSystemThreshold* data = &_protectionThresholds[0];
return make_ndarray(boost::shared_ptr<const CsPad::ProtectionSystemThreshold>(owner, data), MaxQuadsPerSensor);
}
/** Note: this method returns ndarray instance which does not control lifetime
of the data, do not use returned ndarray after this instance disappears. */
ndarray<const CsPad::ProtectionSystemThreshold, 1> protectionThresholds() const { return make_ndarray(&_protectionThresholds[0], MaxQuadsPerSensor); }
uint32_t protectionEnable() const { return _protectionEnable; }
uint32_t inactiveRunMode() const { return _inactiveRunMode; }
uint32_t activeRunMode() const { return _activeRunMode; }
uint32_t tdi() const { return _testDataIndex; }
uint32_t payloadSize() const { return _payloadPerQuad; }
uint32_t badAsicMask0() const { return _badAsicMask0; }
uint32_t badAsicMask1() const { return _badAsicMask1; }
uint32_t asicMask() const { return _AsicMask; }
uint32_t quadMask() const { return _quadMask; }
uint32_t roiMasks() const { return _roiMask; }
const CsPad::ConfigV1QuadReg& quads(uint32_t i0) const { return _quads[i0]; }
uint32_t numAsicsRead() const;
/** ROI mask for given quadrant */
uint32_t roiMask(uint32_t iq) const;
/** Number of ASICs in given quadrant */
uint32_t numAsicsStored(uint32_t iq) const;
/** Total number of quadrants in setup */
uint32_t numQuads() const;
/** Total number of sections (2x1) in all quadrants */
uint32_t numSect() const;
static uint32_t _sizeof() { return (((((((((((((((12+(CsPad::ProtectionSystemThreshold::_sizeof()*(MaxQuadsPerSensor)))+4)+4)+4)+4)+4)+4)+4)+4)+4)+4)+(CsPad::ConfigV1QuadReg::_sizeof()*(MaxQuadsPerSensor)))+4)-1)/4)*4; }
/** Method which returns the shape (dimensions) of the data returned by quads() method. */
std::vector<int> quads_shape() const;
private:
uint32_t _concentratorVersion;
uint32_t _runDelay;
uint32_t _eventCode;
CsPad::ProtectionSystemThreshold _protectionThresholds[MaxQuadsPerSensor];
uint32_t _protectionEnable;
uint32_t _inactiveRunMode;
uint32_t _activeRunMode;
uint32_t _testDataIndex;
uint32_t _payloadPerQuad;
uint32_t _badAsicMask0;
uint32_t _badAsicMask1;
uint32_t _AsicMask;
uint32_t _quadMask;
uint32_t _roiMask;
CsPad::ConfigV1QuadReg _quads[MaxQuadsPerSensor];
};
/** @class ConfigV4
Configuration data for complete CsPad device.
*/
class ConfigV4 {
public:
enum { TypeId = Pds::TypeId::Id_CspadConfig /**< XTC type ID value (from Pds::TypeId class) */ };
enum { Version = 4 /**< XTC type version number */ };
uint32_t concentratorVersion() const { return _concentratorVersion; }
uint32_t runDelay() const { return _runDelay; }
uint32_t eventCode() const { return _eventCode; }
/** Note: this overloaded method accepts shared pointer argument which must point to an object containing
this instance, the returned ndarray object can be used even after this instance disappears. */
template <typename T>
ndarray<const CsPad::ProtectionSystemThreshold, 1> protectionThresholds(const boost::shared_ptr<T>& owner) const {
const CsPad::ProtectionSystemThreshold* data = &_protectionThresholds[0];
return make_ndarray(boost::shared_ptr<const CsPad::ProtectionSystemThreshold>(owner, data), MaxQuadsPerSensor);
}
/** Note: this method returns ndarray instance which does not control lifetime
of the data, do not use returned ndarray after this instance disappears. */
ndarray<const CsPad::ProtectionSystemThreshold, 1> protectionThresholds() const { return make_ndarray(&_protectionThresholds[0], MaxQuadsPerSensor); }
uint32_t protectionEnable() const { return _protectionEnable; }
uint32_t inactiveRunMode() const { return _inactiveRunMode; }
uint32_t activeRunMode() const { return _activeRunMode; }
uint32_t tdi() const { return _testDataIndex; }
uint32_t payloadSize() const { return _payloadPerQuad; }
uint32_t badAsicMask0() const { return _badAsicMask0; }
uint32_t badAsicMask1() const { return _badAsicMask1; }
uint32_t asicMask() const { return _AsicMask; }
uint32_t quadMask() const { return _quadMask; }
uint32_t roiMasks() const { return _roiMask; }
const CsPad::ConfigV2QuadReg& quads(uint32_t i0) const { return _quads[i0]; }
uint32_t numAsicsRead() const;
/** ROI mask for given quadrant */
uint32_t roiMask(uint32_t iq) const;
/** Number of ASICs in given quadrant */
uint32_t numAsicsStored(uint32_t iq) const;
/** Total number of quadrants in setup */
uint32_t numQuads() const;
/** Total number of sections (2x1) in all quadrants */
uint32_t numSect() const;
static uint32_t _sizeof() { return (((((((((((((((12+(CsPad::ProtectionSystemThreshold::_sizeof()*(MaxQuadsPerSensor)))+4)+4)+4)+4)+4)+4)+4)+4)+4)+4)+(CsPad::ConfigV2QuadReg::_sizeof()*(MaxQuadsPerSensor)))+4)-1)/4)*4; }
/** Method which returns the shape (dimensions) of the data returned by quads() method. */
std::vector<int> quads_shape() const;
private:
uint32_t _concentratorVersion;
uint32_t _runDelay;
uint32_t _eventCode;
CsPad::ProtectionSystemThreshold _protectionThresholds[MaxQuadsPerSensor];
uint32_t _protectionEnable;
uint32_t _inactiveRunMode;
uint32_t _activeRunMode;
uint32_t _testDataIndex;
uint32_t _payloadPerQuad;
uint32_t _badAsicMask0;
uint32_t _badAsicMask1;
uint32_t _AsicMask;
uint32_t _quadMask;
uint32_t _roiMask;
CsPad::ConfigV2QuadReg _quads[MaxQuadsPerSensor];
};
/** @class ConfigV5
Configuration data for complete CsPad device.
*/
class ConfigV5 {
public:
enum { TypeId = Pds::TypeId::Id_CspadConfig /**< XTC type ID value (from Pds::TypeId class) */ };
enum { Version = 5 /**< XTC type version number */ };
uint32_t concentratorVersion() const { return _concentratorVersion; }
uint32_t runDelay() const { return _runDelay; }
uint32_t eventCode() const { return _eventCode; }
/** Note: this overloaded method accepts shared pointer argument which must point to an object containing
this instance, the returned ndarray object can be used even after this instance disappears. */
template <typename T>
ndarray<const CsPad::ProtectionSystemThreshold, 1> protectionThresholds(const boost::shared_ptr<T>& owner) const {
const CsPad::ProtectionSystemThreshold* data = &_protectionThresholds[0];
return make_ndarray(boost::shared_ptr<const CsPad::ProtectionSystemThreshold>(owner, data), MaxQuadsPerSensor);
}
/** Note: this method returns ndarray instance which does not control lifetime
of the data, do not use returned ndarray after this instance disappears. */
ndarray<const CsPad::ProtectionSystemThreshold, 1> protectionThresholds() const { return make_ndarray(&_protectionThresholds[0], MaxQuadsPerSensor); }
uint32_t protectionEnable() const { return _protectionEnable; }
uint32_t inactiveRunMode() const { return _inactiveRunMode; }
uint32_t activeRunMode() const { return _activeRunMode; }
uint32_t internalTriggerDelay() const { return _internalTriggerDelay; }
uint32_t tdi() const { return _testDataIndex; }
uint32_t payloadSize() const { return _payloadPerQuad; }
uint32_t badAsicMask0() const { return _badAsicMask0; }
uint32_t badAsicMask1() const { return _badAsicMask1; }
uint32_t asicMask() const { return _AsicMask; }
uint32_t quadMask() const { return _quadMask; }
uint32_t roiMasks() const { return _roiMask; }
const CsPad::ConfigV3QuadReg& quads(uint32_t i0) const { return _quads[i0]; }
uint32_t numAsicsRead() const;
/** ROI mask for given quadrant */
uint32_t roiMask(uint32_t iq) const;
/** Number of ASICs in given quadrant */
uint32_t numAsicsStored(uint32_t iq) const;
/** Total number of quadrants in setup */
uint32_t numQuads() const;
/** Total number of sections (2x1) in all quadrants */
uint32_t numSect() const;
static uint32_t _sizeof() { return ((((((((((((((((12+(CsPad::ProtectionSystemThreshold::_sizeof()*(MaxQuadsPerSensor)))+4)+4)+4)+4)+4)+4)+4)+4)+4)+4)+4)+(CsPad::ConfigV3QuadReg::_sizeof()*(MaxQuadsPerSensor)))+4)-1)/4)*4; }
/** Method which returns the shape (dimensions) of the data returned by quads() method. */
std::vector<int> quads_shape() const;
private:
uint32_t _concentratorVersion;
uint32_t _runDelay;
uint32_t _eventCode;
CsPad::ProtectionSystemThreshold _protectionThresholds[MaxQuadsPerSensor];
uint32_t _protectionEnable;
uint32_t _inactiveRunMode;
uint32_t _activeRunMode;
uint32_t _internalTriggerDelay;
uint32_t _testDataIndex;
uint32_t _payloadPerQuad;
uint32_t _badAsicMask0;
uint32_t _badAsicMask1;
uint32_t _AsicMask;
uint32_t _quadMask;
uint32_t _roiMask;
CsPad::ConfigV3QuadReg _quads[MaxQuadsPerSensor];
};
/** @class ElementV1
CsPad data from single CsPad quadrant.
*/
class ConfigV1;
class ConfigV2;
class ConfigV3;
class ConfigV4;
class ConfigV5;
class ElementV1 {
public:
enum { Nsbtemp = 4 /**< Number of the elements in _sbtemp array. */ };
/** Virtual channel number. */
uint32_t virtual_channel() const { return uint32_t(this->_word0 & 0x3); }
/** Lane number. */
uint32_t lane() const { return uint32_t((this->_word0>>6) & 0x3); }
uint32_t tid() const { return uint32_t((this->_word0>>8) & 0xffffff); }
uint32_t acq_count() const { return uint32_t(this->_word1 & 0xffff); }
uint32_t op_code() const { return uint32_t((this->_word1>>16) & 0xff); }
/** Quadrant number. */
uint32_t quad() const { return uint32_t((this->_word1>>24) & 0x3); }
/** Counter incremented on every event. */
uint32_t seq_count() const { return _seq_count; }
uint32_t ticks() const { return _ticks; }
uint32_t fiducials() const { return _fiducials; }
/** Note: this overloaded method accepts shared pointer argument which must point to an object containing
this instance, the returned ndarray object can be used even after this instance disappears. */
template <typename T>
ndarray<const uint16_t, 1> sb_temp(const boost::shared_ptr<T>& owner) const {
const uint16_t* data = &_sbtemp[0];
return make_ndarray(boost::shared_ptr<const uint16_t>(owner, data), Nsbtemp);
}
/** Note: this method returns ndarray instance which does not control lifetime
of the data, do not use returned ndarray after this instance disappears. */
ndarray<const uint16_t, 1> sb_temp() const { return make_ndarray(&_sbtemp[0], Nsbtemp); }
uint32_t frame_type() const { return _frame_type; }
/** Note: this overloaded method accepts shared pointer argument which must point to an object containing
this instance, the returned ndarray object can be used even after this instance disappears. */
template <typename T>
ndarray<const int16_t, 3> data(const CsPad::ConfigV1& cfg, const boost::shared_ptr<T>& owner) const {
ptrdiff_t offset=32;
const int16_t* data = (const int16_t*)(((char*)this)+offset);
return make_ndarray(boost::shared_ptr<const int16_t>(owner, data), cfg.numAsicsRead()/2, ColumnsPerASIC, MaxRowsPerASIC*2);
}
/** Note: this overloaded method accepts shared pointer argument which must point to an object containing
this instance, the returned ndarray object can be used even after this instance disappears. */
template <typename T>
ndarray<const int16_t, 3> data(const CsPad::ConfigV2& cfg, const boost::shared_ptr<T>& owner) const {
ptrdiff_t offset=32;
const int16_t* data = (const int16_t*)(((char*)this)+offset);
return make_ndarray(boost::shared_ptr<const int16_t>(owner, data), cfg.numAsicsRead()/2, ColumnsPerASIC, MaxRowsPerASIC*2);
}
/** Note: this overloaded method accepts shared pointer argument which must point to an object containing
this instance, the returned ndarray object can be used even after this instance disappears. */
template <typename T>
ndarray<const int16_t, 3> data(const CsPad::ConfigV3& cfg, const boost::shared_ptr<T>& owner) const {
ptrdiff_t offset=32;
const int16_t* data = (const int16_t*)(((char*)this)+offset);
return make_ndarray(boost::shared_ptr<const int16_t>(owner, data), cfg.numAsicsRead()/2, ColumnsPerASIC, MaxRowsPerASIC*2);
}
/** Note: this overloaded method accepts shared pointer argument which must point to an object containing
this instance, the returned ndarray object can be used even after this instance disappears. */
template <typename T>
ndarray<const int16_t, 3> data(const CsPad::ConfigV4& cfg, const boost::shared_ptr<T>& owner) const {
ptrdiff_t offset=32;
const int16_t* data = (const int16_t*)(((char*)this)+offset);
return make_ndarray(boost::shared_ptr<const int16_t>(owner, data), cfg.numAsicsRead()/2, ColumnsPerASIC, MaxRowsPerASIC*2);
}
/** Note: this overloaded method accepts shared pointer argument which must point to an object containing
this instance, the returned ndarray object can be used even after this instance disappears. */
template <typename T>
ndarray<const int16_t, 3> data(const CsPad::ConfigV5& cfg, const boost::shared_ptr<T>& owner) const {
ptrdiff_t offset=32;
const int16_t* data = (const int16_t*)(((char*)this)+offset);
return make_ndarray(boost::shared_ptr<const int16_t>(owner, data), cfg.numAsicsRead()/2, ColumnsPerASIC, MaxRowsPerASIC*2);
}
/** Note: this method returns ndarray instance which does not control lifetime
of the data, do not use returned ndarray after this instance disappears. */
ndarray<const int16_t, 3> data(const CsPad::ConfigV1& cfg) const { ptrdiff_t offset=32;
const int16_t* data = (const int16_t*)(((char*)this)+offset);
return make_ndarray(data, cfg.numAsicsRead()/2, ColumnsPerASIC, MaxRowsPerASIC*2); }
/** Note: this method returns ndarray instance which does not control lifetime
of the data, do not use returned ndarray after this instance disappears. */
ndarray<const int16_t, 3> data(const CsPad::ConfigV2& cfg) const { ptrdiff_t offset=32;
const int16_t* data = (const int16_t*)(((char*)this)+offset);
return make_ndarray(data, cfg.numAsicsRead()/2, ColumnsPerASIC, MaxRowsPerASIC*2); }
/** Note: this method returns ndarray instance which does not control lifetime
of the data, do not use returned ndarray after this instance disappears. */
ndarray<const int16_t, 3> data(const CsPad::ConfigV3& cfg) const { ptrdiff_t offset=32;
const int16_t* data = (const int16_t*)(((char*)this)+offset);
return make_ndarray(data, cfg.numAsicsRead()/2, ColumnsPerASIC, MaxRowsPerASIC*2); }
/** Note: this method returns ndarray instance which does not control lifetime
of the data, do not use returned ndarray after this instance disappears. */
ndarray<const int16_t, 3> data(const CsPad::ConfigV4& cfg) const { ptrdiff_t offset=32;
const int16_t* data = (const int16_t*)(((char*)this)+offset);
return make_ndarray(data, cfg.numAsicsRead()/2, ColumnsPerASIC, MaxRowsPerASIC*2); }
/** Note: this method returns ndarray instance which does not control lifetime
of the data, do not use returned ndarray after this instance disappears. */
ndarray<const int16_t, 3> data(const CsPad::ConfigV5& cfg) const { ptrdiff_t offset=32;
const int16_t* data = (const int16_t*)(((char*)this)+offset);
return make_ndarray(data, cfg.numAsicsRead()/2, ColumnsPerASIC, MaxRowsPerASIC*2); }
/** Returns section mask for this quadrant. Mask can contain up to 8 bits in the lower byte,
total bit count gives the number of sections active. */
uint32_t sectionMask(const CsPad::ConfigV1& cfg) const;
/** Returns section mask for this quadrant. Mask can contain up to 8 bits in the lower byte,
total bit count gives the number of sections active. */
uint32_t sectionMask(const CsPad::ConfigV2& cfg) const;
/** Returns section mask for this quadrant. Mask can contain up to 8 bits in the lower byte,
total bit count gives the number of sections active. */
uint32_t sectionMask(const CsPad::ConfigV3& cfg) const;
/** Returns section mask for this quadrant. Mask can contain up to 8 bits in the lower byte,
total bit count gives the number of sections active. */
uint32_t sectionMask(const CsPad::ConfigV4& cfg) const;
/** Returns section mask for this quadrant. Mask can contain up to 8 bits in the lower byte,
total bit count gives the number of sections active. */
uint32_t sectionMask(const CsPad::ConfigV5& cfg) const;
/** Common mode value for a given section, section number can be 0 to config.numAsicsRead()/2.
Will return 0 for data read from XTC, may be non-zero after calibration. */
float common_mode(uint32_t section) const;
static uint32_t _sizeof(const CsPad::ConfigV1& cfg) { return (((((((20+(2*(Nsbtemp)))+4)+(2*(cfg.numAsicsRead()/2)*( ColumnsPerASIC)*( MaxRowsPerASIC*2)))+(2*(2)))+4)-1)/4)*4; }
static uint32_t _sizeof(const CsPad::ConfigV2& cfg) { return (((((((20+(2*(Nsbtemp)))+4)+(2*(cfg.numAsicsRead()/2)*( ColumnsPerASIC)*( MaxRowsPerASIC*2)))+(2*(2)))+4)-1)/4)*4; }
static uint32_t _sizeof(const CsPad::ConfigV3& cfg) { return (((((((20+(2*(Nsbtemp)))+4)+(2*(cfg.numAsicsRead()/2)*( ColumnsPerASIC)*( MaxRowsPerASIC*2)))+(2*(2)))+4)-1)/4)*4; }
static uint32_t _sizeof(const CsPad::ConfigV4& cfg) { return (((((((20+(2*(Nsbtemp)))+4)+(2*(cfg.numAsicsRead()/2)*( ColumnsPerASIC)*( MaxRowsPerASIC*2)))+(2*(2)))+4)-1)/4)*4; }
static uint32_t _sizeof(const CsPad::ConfigV5& cfg) { return (((((((20+(2*(Nsbtemp)))+4)+(2*(cfg.numAsicsRead()/2)*( ColumnsPerASIC)*( MaxRowsPerASIC*2)))+(2*(2)))+4)-1)/4)*4; }
private:
uint32_t _word0;
uint32_t _word1;
uint32_t _seq_count; /**< Counter incremented on every event. */
uint32_t _ticks;
uint32_t _fiducials;
uint16_t _sbtemp[Nsbtemp];
uint32_t _frame_type;
//int16_t _data[cfg.numAsicsRead()/2][ ColumnsPerASIC][ MaxRowsPerASIC*2];
//uint16_t _extra[2];
};
/** @class DataV1
CsPad data from whole detector.
*/
class ConfigV1;
class ConfigV2;
class ConfigV3;
class ConfigV4;
class ConfigV5;
class DataV1 {
public:
enum { TypeId = Pds::TypeId::Id_CspadElement /**< XTC type ID value (from Pds::TypeId class) */ };
enum { Version = 1 /**< XTC type version number */ };
/** Data objects, one element per quadrant. The size of the array is determined by
the numQuads() method of the configuration object. */
const CsPad::ElementV1& quads(const CsPad::ConfigV1& cfg, uint32_t i0) const { ptrdiff_t offset=0;
const CsPad::ElementV1* memptr = (const CsPad::ElementV1*)(((const char*)this)+offset);
size_t memsize = memptr->_sizeof(cfg);
return *(const CsPad::ElementV1*)((const char*)memptr + (i0)*memsize); }
/** Data objects, one element per quadrant. The size of the array is determined by
the numQuads() method of the configuration object. */
const CsPad::ElementV1& quads(const CsPad::ConfigV2& cfg, uint32_t i0) const { ptrdiff_t offset=0;
const CsPad::ElementV1* memptr = (const CsPad::ElementV1*)(((const char*)this)+offset);
size_t memsize = memptr->_sizeof(cfg);
return *(const CsPad::ElementV1*)((const char*)memptr + (i0)*memsize); }
/** Data objects, one element per quadrant. The size of the array is determined by
the numQuads() method of the configuration object. */
const CsPad::ElementV1& quads(const CsPad::ConfigV3& cfg, uint32_t i0) const { ptrdiff_t offset=0;
const CsPad::ElementV1* memptr = (const CsPad::ElementV1*)(((const char*)this)+offset);
size_t memsize = memptr->_sizeof(cfg);
return *(const CsPad::ElementV1*)((const char*)memptr + (i0)*memsize); }
/** Data objects, one element per quadrant. The size of the array is determined by
the numQuads() method of the configuration object. */
const CsPad::ElementV1& quads(const CsPad::ConfigV4& cfg, uint32_t i0) const { ptrdiff_t offset=0;
const CsPad::ElementV1* memptr = (const CsPad::ElementV1*)(((const char*)this)+offset);
size_t memsize = memptr->_sizeof(cfg);
return *(const CsPad::ElementV1*)((const char*)memptr + (i0)*memsize); }
/** Data objects, one element per quadrant. The size of the array is determined by
the numQuads() method of the configuration object. */
const CsPad::ElementV1& quads(const CsPad::ConfigV5& cfg, uint32_t i0) const { ptrdiff_t offset=0;
const CsPad::ElementV1* memptr = (const CsPad::ElementV1*)(((const char*)this)+offset);
size_t memsize = memptr->_sizeof(cfg);
return *(const CsPad::ElementV1*)((const char*)memptr + (i0)*memsize); }
static uint32_t _sizeof(const CsPad::ConfigV1& cfg) { return ((((0+(CsPad::ElementV1::_sizeof(cfg)*(cfg.numQuads())))+4)-1)/4)*4; }
static uint32_t _sizeof(const CsPad::ConfigV2& cfg) { return ((((0+(CsPad::ElementV1::_sizeof(cfg)*(cfg.numQuads())))+4)-1)/4)*4; }
static uint32_t _sizeof(const CsPad::ConfigV3& cfg) { return ((((0+(CsPad::ElementV1::_sizeof(cfg)*(cfg.numQuads())))+4)-1)/4)*4; }
static uint32_t _sizeof(const CsPad::ConfigV4& cfg) { return ((((0+(CsPad::ElementV1::_sizeof(cfg)*(cfg.numQuads())))+4)-1)/4)*4; }
static uint32_t _sizeof(const CsPad::ConfigV5& cfg) { return ((((0+(CsPad::ElementV1::_sizeof(cfg)*(cfg.numQuads())))+4)-1)/4)*4; }
/** Method which returns the shape (dimensions) of the data returned by quads() method. */
std::vector<int> quads_shape(const CsPad::ConfigV1& cfg) const;
/** Method which returns the shape (dimensions) of the data returned by quads() method. */
std::vector<int> quads_shape(const CsPad::ConfigV2& cfg) const;
/** Method which returns the shape (dimensions) of the data returned by quads() method. */
std::vector<int> quads_shape(const CsPad::ConfigV3& cfg) const;
/** Method which returns the shape (dimensions) of the data returned by quads() method. */
std::vector<int> quads_shape(const CsPad::ConfigV4& cfg) const;
/** Method which returns the shape (dimensions) of the data returned by quads() method. */
std::vector<int> quads_shape(const CsPad::ConfigV5& cfg) const;
private:
//CsPad::ElementV1 _quads[cfg.numQuads()];
};
/** @class ElementV2
CsPad data from single CsPad quadrant.
*/
class ConfigV2;
class ConfigV3;
class ConfigV4;
class ConfigV5;
class ElementV2 {
public:
enum { Nsbtemp = 4 /**< Number of the elements in _sbtemp array. */ };
/** Virtual channel number. */
uint32_t virtual_channel() const { return uint32_t(this->_word0 & 0x3); }
/** Lane number. */
uint32_t lane() const { return uint32_t((this->_word0>>6) & 0x3); }
uint32_t tid() const { return uint32_t((this->_word0>>8) & 0xffffff); }
uint32_t acq_count() const { return uint32_t(this->_word1 & 0xffff); }
uint32_t op_code() const { return uint32_t((this->_word1>>16) & 0xff); }
/** Quadrant number. */
uint32_t quad() const { return uint32_t((this->_word1>>24) & 0x3); }
uint32_t seq_count() const { return _seq_count; }
uint32_t ticks() const { return _ticks; }
uint32_t fiducials() const { return _fiducials; }
/** Note: this overloaded method accepts shared pointer argument which must point to an object containing
this instance, the returned ndarray object can be used even after this instance disappears. */
template <typename T>
ndarray<const uint16_t, 1> sb_temp(const boost::shared_ptr<T>& owner) const {
const uint16_t* data = &_sbtemp[0];
return make_ndarray(boost::shared_ptr<const uint16_t>(owner, data), Nsbtemp);
}
/** Note: this method returns ndarray instance which does not control lifetime
of the data, do not use returned ndarray after this instance disappears. */
ndarray<const uint16_t, 1> sb_temp() const { return make_ndarray(&_sbtemp[0], Nsbtemp); }
uint32_t frame_type() const { return _frame_type; }
/** Note: this overloaded method accepts shared pointer argument which must point to an object containing
this instance, the returned ndarray object can be used even after this instance disappears. */
template <typename T>
ndarray<const int16_t, 3> data(const CsPad::ConfigV2& cfg, const boost::shared_ptr<T>& owner) const {
ptrdiff_t offset=32;
const int16_t* data = (const int16_t*)(((char*)this)+offset);
return make_ndarray(boost::shared_ptr<const int16_t>(owner, data), cfg.numAsicsStored(this->quad())/2, ColumnsPerASIC, MaxRowsPerASIC*2);
}
/** Note: this overloaded method accepts shared pointer argument which must point to an object containing
this instance, the returned ndarray object can be used even after this instance disappears. */
template <typename T>
ndarray<const int16_t, 3> data(const CsPad::ConfigV3& cfg, const boost::shared_ptr<T>& owner) const {
ptrdiff_t offset=32;
const int16_t* data = (const int16_t*)(((char*)this)+offset);
return make_ndarray(boost::shared_ptr<const int16_t>(owner, data), cfg.numAsicsStored(this->quad())/2, ColumnsPerASIC, MaxRowsPerASIC*2);
}
/** Note: this overloaded method accepts shared pointer argument which must point to an object containing
this instance, the returned ndarray object can be used even after this instance disappears. */
template <typename T>
ndarray<const int16_t, 3> data(const CsPad::ConfigV4& cfg, const boost::shared_ptr<T>& owner) const {
ptrdiff_t offset=32;
const int16_t* data = (const int16_t*)(((char*)this)+offset);
return make_ndarray(boost::shared_ptr<const int16_t>(owner, data), cfg.numAsicsStored(this->quad())/2, ColumnsPerASIC, MaxRowsPerASIC*2);
}
/** Note: this overloaded method accepts shared pointer argument which must point to an object containing
this instance, the returned ndarray object can be used even after this instance disappears. */
template <typename T>
ndarray<const int16_t, 3> data(const CsPad::ConfigV5& cfg, const boost::shared_ptr<T>& owner) const {
ptrdiff_t offset=32;
const int16_t* data = (const int16_t*)(((char*)this)+offset);
return make_ndarray(boost::shared_ptr<const int16_t>(owner, data), cfg.numAsicsStored(this->quad())/2, ColumnsPerASIC, MaxRowsPerASIC*2);
}
/** Note: this method returns ndarray instance which does not control lifetime
of the data, do not use returned ndarray after this instance disappears. */
ndarray<const int16_t, 3> data(const CsPad::ConfigV2& cfg) const { ptrdiff_t offset=32;
const int16_t* data = (const int16_t*)(((char*)this)+offset);
return make_ndarray(data, cfg.numAsicsStored(this->quad())/2, ColumnsPerASIC, MaxRowsPerASIC*2); }
/** Note: this method returns ndarray instance which does not control lifetime
of the data, do not use returned ndarray after this instance disappears. */
ndarray<const int16_t, 3> data(const CsPad::ConfigV3& cfg) const { ptrdiff_t offset=32;
const int16_t* data = (const int16_t*)(((char*)this)+offset);
return make_ndarray(data, cfg.numAsicsStored(this->quad())/2, ColumnsPerASIC, MaxRowsPerASIC*2); }
/** Note: this method returns ndarray instance which does not control lifetime
of the data, do not use returned ndarray after this instance disappears. */
ndarray<const int16_t, 3> data(const CsPad::ConfigV4& cfg) const { ptrdiff_t offset=32;
const int16_t* data = (const int16_t*)(((char*)this)+offset);
return make_ndarray(data, cfg.numAsicsStored(this->quad())/2, ColumnsPerASIC, MaxRowsPerASIC*2); }
/** Note: this method returns ndarray instance which does not control lifetime
of the data, do not use returned ndarray after this instance disappears. */
ndarray<const int16_t, 3> data(const CsPad::ConfigV5& cfg) const { ptrdiff_t offset=32;
const int16_t* data = (const int16_t*)(((char*)this)+offset);
return make_ndarray(data, cfg.numAsicsStored(this->quad())/2, ColumnsPerASIC, MaxRowsPerASIC*2); }
/** Returns section mask for this quadrant. Mask can contain up to 8 bits in the lower byte,
total bit count gives the number of sections active. */
uint32_t sectionMask(const CsPad::ConfigV2& cfg) const;
/** Returns section mask for this quadrant. Mask can contain up to 8 bits in the lower byte,
total bit count gives the number of sections active. */
uint32_t sectionMask(const CsPad::ConfigV3& cfg) const;
/** Returns section mask for this quadrant. Mask can contain up to 8 bits in the lower byte,
total bit count gives the number of sections active. */
uint32_t sectionMask(const CsPad::ConfigV4& cfg) const;
/** Returns section mask for this quadrant. Mask can contain up to 8 bits in the lower byte,
total bit count gives the number of sections active. */
uint32_t sectionMask(const CsPad::ConfigV5& cfg) const;
/** Common mode value for a given section, section number can be 0 to config.numSect().
Will return 0 for data read from XTC, may be non-zero after calibration. */
float common_mode(uint32_t section) const;
uint32_t _sizeof(const CsPad::ConfigV2& cfg) const { return (((((((20+(2*(Nsbtemp)))+4)+(2*(cfg.numAsicsStored(this->quad())/2)*( ColumnsPerASIC)*( MaxRowsPerASIC*2)))+(2*(2)))+4)-1)/4)*4; }
uint32_t _sizeof(const CsPad::ConfigV3& cfg) const { return (((((((20+(2*(Nsbtemp)))+4)+(2*(cfg.numAsicsStored(this->quad())/2)*( ColumnsPerASIC)*( MaxRowsPerASIC*2)))+(2*(2)))+4)-1)/4)*4; }
uint32_t _sizeof(const CsPad::ConfigV4& cfg) const { return (((((((20+(2*(Nsbtemp)))+4)+(2*(cfg.numAsicsStored(this->quad())/2)*( ColumnsPerASIC)*( MaxRowsPerASIC*2)))+(2*(2)))+4)-1)/4)*4; }
uint32_t _sizeof(const CsPad::ConfigV5& cfg) const { return (((((((20+(2*(Nsbtemp)))+4)+(2*(cfg.numAsicsStored(this->quad())/2)*( ColumnsPerASIC)*( MaxRowsPerASIC*2)))+(2*(2)))+4)-1)/4)*4; }
private:
uint32_t _word0;
uint32_t _word1;
uint32_t _seq_count;
uint32_t _ticks;
uint32_t _fiducials;
uint16_t _sbtemp[Nsbtemp];
uint32_t _frame_type;
//int16_t _data[cfg.numAsicsStored(this->quad())/2][ ColumnsPerASIC][ MaxRowsPerASIC*2];
//uint16_t _extra[2];
};
/** @class DataV2
CsPad data from whole detector.
*/
class ConfigV2;
class ConfigV3;
class ConfigV4;
class ConfigV5;
class DataV2 {
public:
enum { TypeId = Pds::TypeId::Id_CspadElement /**< XTC type ID value (from Pds::TypeId class) */ };
enum { Version = 2 /**< XTC type version number */ };
/** Data objects, one element per quadrant. The size of the array is determined by
the numQuads() method of the configuration object. */
const CsPad::ElementV2& quads(const CsPad::ConfigV2& cfg, uint32_t i0) const { const char* memptr = ((const char*)this)+0;
for (uint32_t i=0; i != i0; ++ i) {
memptr += ((const CsPad::ElementV2*)memptr)->_sizeof(cfg);
}
return *(const CsPad::ElementV2*)(memptr); }
/** Data objects, one element per quadrant. The size of the array is determined by
the numQuads() method of the configuration object. */
const CsPad::ElementV2& quads(const CsPad::ConfigV3& cfg, uint32_t i0) const { const char* memptr = ((const char*)this)+0;
for (uint32_t i=0; i != i0; ++ i) {
memptr += ((const CsPad::ElementV2*)memptr)->_sizeof(cfg);
}
return *(const CsPad::ElementV2*)(memptr); }
/** Data objects, one element per quadrant. The size of the array is determined by
the numQuads() method of the configuration object. */
const CsPad::ElementV2& quads(const CsPad::ConfigV4& cfg, uint32_t i0) const { const char* memptr = ((const char*)this)+0;
for (uint32_t i=0; i != i0; ++ i) {
memptr += ((const CsPad::ElementV2*)memptr)->_sizeof(cfg);
}
return *(const CsPad::ElementV2*)(memptr); }
/** Data objects, one element per quadrant. The size of the array is determined by
the numQuads() method of the configuration object. */
const CsPad::ElementV2& quads(const CsPad::ConfigV5& cfg, uint32_t i0) const { const char* memptr = ((const char*)this)+0;
for (uint32_t i=0; i != i0; ++ i) {
memptr += ((const CsPad::ElementV2*)memptr)->_sizeof(cfg);
}
return *(const CsPad::ElementV2*)(memptr); }
/** Method which returns the shape (dimensions) of the data returned by quads() method. */
std::vector<int> quads_shape(const CsPad::ConfigV2& cfg) const;
/** Method which returns the shape (dimensions) of the data returned by quads() method. */
std::vector<int> quads_shape(const CsPad::ConfigV3& cfg) const;
/** Method which returns the shape (dimensions) of the data returned by quads() method. */
std::vector<int> quads_shape(const CsPad::ConfigV4& cfg) const;
/** Method which returns the shape (dimensions) of the data returned by quads() method. */
std::vector<int> quads_shape(const CsPad::ConfigV5& cfg) const;
private:
//CsPad::ElementV2 _quads[cfg.numQuads()];
};
} // namespace CsPad
} // namespace PsddlPds
#endif // PSDDLPDS_CSPAD_DDL_H
| [
"salnikov@SLAC.STANFORD.EDU@b967ad99-d558-0410-b138-e0f6c56caec7"
] | salnikov@SLAC.STANFORD.EDU@b967ad99-d558-0410-b138-e0f6c56caec7 |
6131c081c0dfbe5f5fb040d6f7b1d975eafba0f6 | 8e37ddb57473d73a9fdc8690c2f995d3d639fb01 | /src/Wallet/WalletRpcServer.cpp | b32adfcc5381f5e41a4d35f3463bfa1d44a956c1 | [] | no_license | banknotedev/banknote | 9c79f0be706af10c33b2c3df255cbb8bb22c5bf9 | bdd13c7b5cbd45a25944d05e37506386d8b30d32 | refs/heads/master | 2021-09-01T21:55:42.023694 | 2017-12-28T20:51:55 | 2017-12-28T20:51:55 | 115,658,375 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 11,168 | cpp | // Copyright (c) 2011-2016 The Cryptonote developers
// Copyright (c) 2014-2016 SDN developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include "WalletRpcServer.h"
#include <fstream>
#include "Common/CommandLine.h"
#include "Common/StringTools.h"
#include "CryptoNoteCore/CryptoNoteFormatUtils.h"
#include "CryptoNoteCore/Account.h"
#include "crypto/hash.h"
#include "WalletLegacy/WalletHelper.h"
// #include "wallet_errors.h"
#include "Rpc/JsonRpc.h"
using namespace Logging;
using namespace CryptoNote;
namespace Tools {
const command_line::arg_descriptor<uint16_t> wallet_rpc_server::arg_rpc_bind_port = { "rpc-bind-port", "Starts wallet as rpc server for wallet operations, sets bind port for server", 0, true };
const command_line::arg_descriptor<std::string> wallet_rpc_server::arg_rpc_bind_ip = { "rpc-bind-ip", "Specify ip to bind rpc server", "127.0.0.1" };
void wallet_rpc_server::init_options(boost::program_options::options_description& desc) {
command_line::add_arg(desc, arg_rpc_bind_ip);
command_line::add_arg(desc, arg_rpc_bind_port);
}
//------------------------------------------------------------------------------------------------------------------------------
wallet_rpc_server::wallet_rpc_server(
System::Dispatcher& dispatcher,
Logging::ILogger& log,
CryptoNote::IWalletLegacy&w,
CryptoNote::INode& n,
CryptoNote::Currency& currency,
const std::string& walletFile)
:
HttpServer(dispatcher, log),
logger(log, "WalletRpc"),
m_dispatcher(dispatcher),
m_stopComplete(dispatcher),
m_wallet(w),
m_node(n),
m_currency(currency),
m_walletFilename(walletFile) {
}
//------------------------------------------------------------------------------------------------------------------------------
bool wallet_rpc_server::run() {
start(m_bind_ip, m_port);
m_stopComplete.wait();
return true;
}
void wallet_rpc_server::send_stop_signal() {
m_dispatcher.remoteSpawn([this] {
std::cout << "wallet_rpc_server::send_stop_signal()" << std::endl;
stop();
m_stopComplete.set();
});
}
//------------------------------------------------------------------------------------------------------------------------------
bool wallet_rpc_server::handle_command_line(const boost::program_options::variables_map& vm) {
m_bind_ip = command_line::get_arg(vm, arg_rpc_bind_ip);
m_port = command_line::get_arg(vm, arg_rpc_bind_port);
return true;
}
//------------------------------------------------------------------------------------------------------------------------------
bool wallet_rpc_server::init(const boost::program_options::variables_map& vm) {
if (!handle_command_line(vm)) {
logger(ERROR) << "Failed to process command line in wallet_rpc_server";
return false;
}
return true;
}
void wallet_rpc_server::processRequest(const CryptoNote::HttpRequest& request, CryptoNote::HttpResponse& response) {
using namespace CryptoNote::JsonRpc;
JsonRpcRequest jsonRequest;
JsonRpcResponse jsonResponse;
try {
jsonRequest.parseRequest(request.getBody());
jsonResponse.setId(jsonRequest.getId());
static std::unordered_map<std::string, JsonMemberMethod> s_methods = {
{ "getbalance", makeMemberMethod(&wallet_rpc_server::on_getbalance) },
{ "transfer", makeMemberMethod(&wallet_rpc_server::on_transfer) },
{ "store", makeMemberMethod(&wallet_rpc_server::on_store) },
{ "get_payments", makeMemberMethod(&wallet_rpc_server::on_get_payments) },
{ "get_transfers", makeMemberMethod(&wallet_rpc_server::on_get_transfers) },
{ "get_height", makeMemberMethod(&wallet_rpc_server::on_get_height) },
{ "reset", makeMemberMethod(&wallet_rpc_server::on_reset) }
};
auto it = s_methods.find(jsonRequest.getMethod());
if (it == s_methods.end()) {
throw JsonRpcError(errMethodNotFound);
}
it->second(this, jsonRequest, jsonResponse);
} catch (const JsonRpcError& err) {
jsonResponse.setError(err);
} catch (const std::exception& e) {
jsonResponse.setError(JsonRpcError(WALLET_RPC_ERROR_CODE_UNKNOWN_ERROR, e.what()));
}
response.setBody(jsonResponse.getBody());
}
//------------------------------------------------------------------------------------------------------------------------------
bool wallet_rpc_server::on_getbalance(const wallet_rpc::COMMAND_RPC_GET_BALANCE::request& req, wallet_rpc::COMMAND_RPC_GET_BALANCE::response& res) {
res.locked_amount = m_wallet.pendingBalance();
res.available_balance = m_wallet.actualBalance();
res.balance = res.locked_amount + res.available_balance;
res.unlocked_balance = res.available_balance;
return true;
}
//------------------------------------------------------------------------------------------------------------------------------
bool wallet_rpc_server::on_transfer(const wallet_rpc::COMMAND_RPC_TRANSFER::request& req, wallet_rpc::COMMAND_RPC_TRANSFER::response& res) {
std::vector<CryptoNote::WalletLegacyTransfer> transfers;
for (auto it = req.destinations.begin(); it != req.destinations.end(); it++) {
CryptoNote::WalletLegacyTransfer transfer;
transfer.address = it->address;
transfer.amount = it->amount;
transfers.push_back(transfer);
}
std::vector<uint8_t> extra;
if (!req.payment_id.empty()) {
std::string payment_id_str = req.payment_id;
Crypto::Hash payment_id;
if (!CryptoNote::parsePaymentId(payment_id_str, payment_id)) {
throw JsonRpc::JsonRpcError(WALLET_RPC_ERROR_CODE_WRONG_PAYMENT_ID,
"Payment id has invalid format: \"" + payment_id_str + "\", expected 64-character string");
}
BinaryArray extra_nonce;
CryptoNote::setPaymentIdToTransactionExtraNonce(extra_nonce, payment_id);
if (!CryptoNote::addExtraNonceToTransactionExtra(extra, extra_nonce)) {
throw JsonRpc::JsonRpcError(WALLET_RPC_ERROR_CODE_WRONG_PAYMENT_ID,
"Something went wrong with payment_id. Please check its format: \"" + payment_id_str + "\", expected 64-character string");
}
}
std::vector<CryptoNote::TransactionMessage> messages;
for (auto& rpc_message : req.messages) {
messages.emplace_back(CryptoNote::TransactionMessage{ rpc_message.message, rpc_message.address });
}
std::string extraString;
std::copy(extra.begin(), extra.end(), std::back_inserter(extraString));
try {
CryptoNote::WalletHelper::SendCompleteResultObserver sent;
WalletHelper::IWalletRemoveObserverGuard removeGuard(m_wallet, sent);
CryptoNote::TransactionId tx = m_wallet.sendTransaction(transfers, req.fee, extraString, req.mixin, req.unlock_time, messages);
if (tx == WALLET_LEGACY_INVALID_TRANSACTION_ID) {
throw std::runtime_error("Couldn't send transaction");
}
std::error_code sendError = sent.wait(tx);
removeGuard.removeObserver();
if (sendError) {
throw std::system_error(sendError);
}
CryptoNote::WalletLegacyTransaction txInfo;
m_wallet.getTransaction(tx, txInfo);
res.tx_hash = Common::podToHex(txInfo.hash);
} catch (const std::exception& e) {
throw JsonRpc::JsonRpcError(WALLET_RPC_ERROR_CODE_GENERIC_TRANSFER_ERROR, e.what());
}
return true;
}
//------------------------------------------------------------------------------------------------------------------------------
bool wallet_rpc_server::on_store(const wallet_rpc::COMMAND_RPC_STORE::request& req, wallet_rpc::COMMAND_RPC_STORE::response& res) {
try {
WalletHelper::storeWallet(m_wallet, m_walletFilename);
} catch (std::exception& e) {
throw JsonRpc::JsonRpcError(WALLET_RPC_ERROR_CODE_UNKNOWN_ERROR, std::string("Couldn't save wallet: ") + e.what());
}
return true;
}
//------------------------------------------------------------------------------------------------------------------------------
bool wallet_rpc_server::on_get_payments(const wallet_rpc::COMMAND_RPC_GET_PAYMENTS::request& req, wallet_rpc::COMMAND_RPC_GET_PAYMENTS::response& res) {
PaymentId expectedPaymentId;
CryptoNote::BinaryArray payment_id_blob;
if (!Common::fromHex(req.payment_id, payment_id_blob)) {
throw JsonRpc::JsonRpcError(WALLET_RPC_ERROR_CODE_WRONG_PAYMENT_ID, "Payment ID has invald format");
}
if (sizeof(expectedPaymentId) != payment_id_blob.size()) {
throw JsonRpc::JsonRpcError(WALLET_RPC_ERROR_CODE_WRONG_PAYMENT_ID, "Payment ID has invalid size");
}
std::copy(std::begin(payment_id_blob), std::end(payment_id_blob), reinterpret_cast<char*>(&expectedPaymentId)); // no UB, char can alias any type
auto payments = m_wallet.getTransactionsByPaymentIds({expectedPaymentId});
assert(payments.size() == 1);
for (auto& transaction : payments[0].transactions) {
wallet_rpc::payment_details rpc_payment;
rpc_payment.tx_hash = Common::podToHex(transaction.hash);
rpc_payment.amount = transaction.totalAmount;
rpc_payment.block_height = transaction.blockHeight;
rpc_payment.unlock_time = transaction.unlockTime;
res.payments.push_back(rpc_payment);
}
return true;
}
bool wallet_rpc_server::on_get_transfers(const wallet_rpc::COMMAND_RPC_GET_TRANSFERS::request& req, wallet_rpc::COMMAND_RPC_GET_TRANSFERS::response& res) {
res.transfers.clear();
size_t transactionsCount = m_wallet.getTransactionCount();
for (size_t trantransactionNumber = 0; trantransactionNumber < transactionsCount; ++trantransactionNumber) {
WalletLegacyTransaction txInfo;
m_wallet.getTransaction(trantransactionNumber, txInfo);
if (txInfo.state != WalletLegacyTransactionState::Active || txInfo.blockHeight == WALLET_LEGACY_UNCONFIRMED_TRANSACTION_HEIGHT) {
continue;
}
std::string address = "";
if (txInfo.totalAmount < 0) {
if (txInfo.transferCount > 0) {
WalletLegacyTransfer tr;
m_wallet.getTransfer(txInfo.firstTransferId, tr);
address = tr.address;
}
}
wallet_rpc::Transfer transfer;
transfer.time = txInfo.timestamp;
transfer.output = txInfo.totalAmount < 0;
transfer.transactionHash = Common::podToHex(txInfo.hash);
transfer.amount = std::abs(txInfo.totalAmount);
transfer.fee = txInfo.fee;
transfer.address = address;
transfer.blockIndex = txInfo.blockHeight;
transfer.unlockTime = txInfo.unlockTime;
transfer.paymentId = "";
std::vector<uint8_t> extraVec;
extraVec.reserve(txInfo.extra.size());
std::for_each(txInfo.extra.begin(), txInfo.extra.end(), [&extraVec](const char el) { extraVec.push_back(el); });
Crypto::Hash paymentId;
transfer.paymentId = (getPaymentIdFromTxExtra(extraVec, paymentId) && paymentId != NULL_HASH ? Common::podToHex(paymentId) : "");
res.transfers.push_back(transfer);
}
return true;
}
bool wallet_rpc_server::on_get_height(const wallet_rpc::COMMAND_RPC_GET_HEIGHT::request& req, wallet_rpc::COMMAND_RPC_GET_HEIGHT::response& res) {
res.height = m_node.getLastLocalBlockHeight();
return true;
}
bool wallet_rpc_server::on_reset(const wallet_rpc::COMMAND_RPC_RESET::request& req, wallet_rpc::COMMAND_RPC_RESET::response& res) {
m_wallet.reset();
return true;
}
}
| [
"Nasser Sagoe"
] | Nasser Sagoe |
06bb4c1ffea1e0a2bad0e883bec65dd8c6b9b005 | db257feeb047692577d51d0f4e3085ef90ec8710 | /home_control_1/input_method/phrase/Big5phrase.cpp | b5f446e2ebac942ada3b8aeee43c5f27b86d267e | [] | no_license | yeefanwong/leelen_code | 975cf11d378529177ef7c406684fae8df46e8fbe | a37685ad6062221b5032608c98447db227bd4070 | refs/heads/master | 2023-03-16T03:45:04.024954 | 2017-09-04T09:55:16 | 2017-09-04T09:55:16 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 17,630 | cpp | #include "phrase/Big5phrase.h"
#include "public.h"
#include <map>
/////////////////////////////////////////////////////////////////////////
//utf8 <=> ucs-2 convertion
//
//from linux kernel fs/nls/nls_base.c
extern int utf8_mbtowc(ucs4_t *p, const __u8 *s, int n);
int utf8_mbstowcs(ucs4_t *pwcs, const __u8 *s, int n)
{
__u16 *op;
const __u8 *ip;
int size;
op = pwcs;
ip = s;
while (*ip && n > 0) {
if (*ip & 0x80) {
size = utf8_mbtowc(op, ip, n);
if (size == -1) {
/* Ignore character and move on */
ip++;
n--;
} else {
op++;
ip += size;
n -= size;
}
} else {
*op++ = *ip++;
}
}
return (op - pwcs);
}
extern int utf8_wctomb(__u8 *s, ucs4_t wc, int maxlen);
int utf8_wcstombs(__u8 *s, const ucs4_t *pwcs, int maxlen)
{
const __u16 *ip;
__u8 *op;
int size;
op = s;
ip = pwcs;
while (*ip && maxlen > 0) {
if (*ip > 0x7f) {
size = utf8_wctomb(op, *ip, maxlen);
if (size == -1) {
/* Ignore character and move on */
maxlen--;
} else {
op += size;
maxlen -= size;
}
} else {
*op++ = (__u8) *ip;
}
ip++;
}
return (op - s);
}
std::ostream& utf8_write_phase_string(std::ostream& os,PhraseString& str)
{
std::vector<__u8> s;
int size=str.size()*4;
s.reserve(size); //utf8
ucs4_t*p=&str[0];
int len=utf8_wcstombs(&s[0],p,size);
for(int i=0;i<len;i++){
os<<s[i];
}
return os;
}
/////////////////////////////////////////////////////////////////////////
// overrided operators
//
std::ifstream& operator >> (std::ifstream& is, uint32& value)
{
char buf[sizeof(uint32)];
for(unsigned int i=0;i<sizeof(buf);i++){
is>>buf[i];
}
value=*((uint32*)buf);
return is;
}
std::fstream& operator << (std::fstream& os, uint32& value)
{
char *p=(char*)(&value);
os.write(p,sizeof(uint32));
return os;
}
bool operator == (PhraseString& left,PhraseString& right)
{
unsigned int size=std::min(left.size(),right.size());
for(unsigned int i=0;i<size&&left[i]!=0&&right[i]!=0;i++){
if(left[i]!=right[i]) return false;
}
return true;
}
///////////////////////////////////////////////////////////////////////////////////
//
static const char murphytalk_Phrase_index_header [] = "MurphyTalk Pinyin Phrase Index Table";
static const char murphytalk_Phrase_index_version[] = "Ver "FILE_VERSION;
static const char murphutalk_Phrase_file [] =
"/home/myP/murphypinyindata/murphyPinyin/murphytalk_phrase.dat";
PinyinPhraseTable::PinyinPhraseTable(const char* indexfile)
{
load_index(indexfile);
}
PinyinPhraseTable::~PinyinPhraseTable()
{
}
bool PinyinPhraseTable::load_index(const char* indexfile)
{
std::ifstream ifs(indexfile);
if (!ifs) return false;
if (input (ifs) && m_phrases.size () != 0) return true;
return false;
}
bool PinyinPhraseTable::save_index(const char* indexfile)
{
std::fstream fs(murphutalk_Phrase_file,std::ios::in|std::ios::out);
if (!fs) return false;
printX86("updating phrase dat file for frequencies ...\n");
//update changed frequencies to phrase file
for(PhraseOffsetToFreqMap::iterator pos=m_recent_hit_cache.begin();
pos!=m_recent_hit_cache.end();pos++){
printX86("from hit cache -> offset %d,freq %d\n",pos->first,pos->second);
fs.seekp(pos->first,std::ios::beg);
fs<<pos->second;
}
m_recent_hit_cache.clear();
//append new phrases keys and offsets in phrase file to index
std::ofstream out(indexfile,std::ios::app|std::ios::out);
if (!out) return false;
printX86("updating phrase index ...\n");
for(PinyinPhraseEntryVector::iterator pos=m_new_phrases_cache.begin();
pos!=m_new_phrases_cache.end();pos++){
pos->output_text(out);
}
m_new_phrases_cache.clear();
return true;
}
#if 0
//rewrite the whole phrase index file,merge phrase entries with same key into the same line
bool PinyinPhraseTable::output (std::ostream &os)
{
os<<murphytalk_Phrase_index_header<<std::endl;
os<<murphytalk_Phrase_index_version<<std::endl;
os<<m_phrases.size()<<std::endl;
for(PinyinPhraseEntryVector::iterator pos=m_phrases.begin();pos!=m_phrases.end();pos++){
pos->output_text(os);
}
return true;
}
#endif
bool PinyinPhraseTable::input (std::istream &is)
{
char header [40];
if (!is) return false;
is.getline (header, 40);
if (strncmp (header,
murphytalk_Phrase_index_header,
strlen (murphytalk_Phrase_index_header)) != 0) {
std::cout<<"invalidate Phrase table index file"<<std::endl;
return false;
}
is.getline (header, 40);
if (strncmp (header,
murphytalk_Phrase_index_version,
strlen (murphytalk_Phrase_index_version)) != 0) {
std::cout<<"invalidate Phrase table index file version:"<<std::endl;
return false;
}
typedef std::map<String,unsigned int> ENTRY_MAP;
ENTRY_MAP lookup;
ENTRY_MAP::iterator lookup_pos;
#ifdef DEBUG
uint32 i=0;
#endif
while(!is.eof())
{
PinyinPhraseEntry phrase_entry(is);
if(phrase_entry.isValid()){
//is entry with same key avaliable?
String keystr=phrase_entry.get_key().get_key_string();
lookup_pos=lookup.find(keystr);
if(lookup_pos!=lookup.end()){
//got you!
printX86("-> %s ...",keystr.c_str());
//lookup_pos->second->append(phrase_entry);
m_phrases[lookup_pos->second].append(phrase_entry);
printX86("OK\n");
}
else{
m_phrases.push_back(phrase_entry);
//PinyinPhraseEntryVector::iterator last=m_phrases.end();
//last--;
lookup[keystr]=m_phrases.size()-1;
}
}
#ifdef DEBUG
i++;
#endif
if(!is||is.eof()){
#ifdef DEBUG
if(!is){
printf("No.%d,exception\n",i);
}
#endif
break;
}
}
std::sort(m_phrases.begin(),m_phrases.end(),PinyinPhraseKeyLessThan());
#ifdef DEBUG
for(PinyinPhraseEntryVector::iterator pos=m_phrases.begin();pos!=m_phrases.end();pos++){
printf("%s\n",pos->get_key().get_key_string().c_str());
}
printf("%d Phrases entries sorted\n",m_phrases.size());
#endif
m_last_matched_phrases_range.first=m_last_matched_phrases_range.second=m_phrases.end();
return true;
}
void PinyinPhraseTable::insert(PinyinPhraseEntry& phrase)
{
m_phrases.push_back(phrase);
std::sort(m_phrases.begin(),m_phrases.end(),PinyinPhraseKeyLessThan());
}
unsigned int PinyinPhraseTable::find_phrases(PhraseOffsetFrequencyPairVector& phrases,PinyinPhraseKey& pinyin)
{
phrases.clear ();
PinyinPhraseEntryVectorPosRangePair range =
std::equal_range(m_phrases.begin(), m_phrases.end(), pinyin,PinyinPhraseKeyLessThan());
m_last_matched_phrases_range=range;
for (PinyinPhraseEntryVector::const_iterator i = range.first; i!= range.second; i++) {
PinyinPhraseEntry& entry=const_cast<PinyinPhraseEntry&>(*i);
#ifdef X86
entry.get_key();
String s=entry.get_key().get_key_string();
printf("%s\n",s.c_str());
#endif
entry.get_all_phrases(phrases);
}
if (!phrases.size ()) return 0;
return phrases.size ();
}
unsigned int PinyinPhraseTable::get_phrases_by_offsets(PhraseOffsetFrequencyPairVector& phrases_pair,
PhraseStringVector& strs)
{
std::ifstream in(murphutalk_Phrase_file);
if(!in){
return 0;
}
else{
ucs4_t* p;
PhraseString temp;
String raw;
uint32 freq;
//read(from file or file hit cache) frequncies first
for(PhraseOffsetFrequencyPairVector::iterator pos=phrases_pair.begin();
pos!=phrases_pair.end();pos++){
//move to the right position
in.seekg(pos->first,std::ios::beg);
printX86("moved to offset %d ... ",(unsigned int)in.tellg());
//read the frequency
in>>freq;
printX86("freq in file is %d,file get position is %u\n",freq,(unsigned int)in.tellg());
//have we inputed this phrase(or:hit this phrase) before?
//check our recent hit cache
PhraseOffsetToFreqMap::iterator pos_cache = m_recent_hit_cache.find(pos->first);
if(pos_cache==m_recent_hit_cache.end()){
//not cached,use freq read from file
pos->second=freq;
}
else{
//use cached freq
pos->second=pos_cache->second;
printX86("use cached freq = %d\n",pos_cache->second);
}
}
//sort by frequency
std::sort (phrases_pair.begin (), phrases_pair.end (), PhraseOffsetFrequencyPairGreaterThanByFrequency ());
//now read phrase strings - in the right freqency order
strs.clear();
for(PhraseOffsetFrequencyPairVector::iterator pos=phrases_pair.begin();
pos!=phrases_pair.end();pos++){
//move to the right position
in.seekg(pos->first+sizeof(PhraseOffset),std::ios::beg);
printX86("get phrase : moved to offset %d\n",(unsigned int)in.tellg());
//read the phrase text,which is encoded in utf8
in>>raw;
//make enough room
temp.reserve(raw.size());
p=&temp[0];
//all set to zero
memset(p,0,raw.size());
int len=utf8_mbstowcs(p,(const __u8 *)raw.c_str(),raw.size());
strs.push_back(PhraseString(p,p+len));
}
return strs.size();
}
}
bool PinyinPhraseTable::append_phrase(PhraseString& str,const char* pinyin)
{
PinyinPhraseEntry entry(pinyin);
PinyinPhraseEntryVector::iterator pos=std::find(m_phrases.begin(),m_phrases.end(),entry);
if(pos!=m_phrases.end()){
//same entry
//we have same pinyin here,have to make sure we don't have the exactly same phrase
//read the matched phrases from file
PhraseStringVector strs;
PhraseOffsetFrequencyPairVector temp_phrases;
for(PhraseOffsetVector::iterator i=pos->m_phrases.begin();i!=pos->m_phrases.end();i++){
temp_phrases.push_back(std::make_pair(*i,0));
}
get_phrases_by_offsets(temp_phrases,strs);
for(PhraseStringVector::iterator pos_str=strs.begin();pos_str!=strs.end();pos_str++){
if(*pos_str==str){
//oops,already got this phrase
printX86("duplicated phrase\n");
return false;
}
}
}
//append phrase to phrase lib file
std::ofstream out(murphutalk_Phrase_file,std::ios::app|std::ios::out);
if(!out){
return false;
}
else{
//out.seekp(0,std::ios::end);
PhraseOffset offset = out.tellp();
//save offset to phrase entry
entry.insert(offset);
printX86("new phrase %s,offset is %u\n",pinyin,offset);
if(pos!=m_phrases.end()){
pos->insert(offset);
}
else{
insert(entry);
}
//put into new phrase cache
m_new_phrases_cache.push_back(entry);
//first of all output a frequency of 1
uint32 freq=1;
out.write((char*)&freq,sizeof(freq));
//this space is used to seperate this phrase with the next one
str.push_back(0x0020);
//terminate the string
str.push_back(0);
//convert to utf8 and append to file
utf8_write_phase_string(out,str);
return true;
}
}
void PinyinPhraseTable::set_frequency(uint32 offset,uint32 freq)
{
#if 0
if(m_last_matched_phrases_range.first!=m_phrases.end()&&
m_last_matched_phrases_range.second!=m_phrases.end()){
for (PinyinPhraseEntryVector::const_iterator i = m_last_matched_phrases_range.first;
i!= m_last_matched_phrases_range.second; i++) {
PinyinPhraseEntry& entry=const_cast<PinyinPhraseEntry&>(*i);
if(entry.set_frequency(offset,freq)) break;
}
}
#else
printX86("PinyinPhraseTable::set_frequency(%d,%d)\n",offset,freq);
//has this phrase's frequency been cached yet?
PhraseOffsetToFreqMap::iterator pos_cache = m_recent_hit_cache.find(offset);
if(pos_cache==m_recent_hit_cache.end()){
m_recent_hit_cache[offset]=freq;
}
else{
printX86("found in hit cache\n");
pos_cache->second=freq;
}
#endif
}
PinyinPhraseEntry::PinyinPhraseEntry(std::istream &is)
{
input_text(is);
}
PinyinPhraseEntry::PinyinPhraseEntry(const char*pinyin)
{
m_key.set_key(pinyin);
}
PinyinPhraseEntry::PinyinPhraseEntry(PinyinPhraseKey& key):m_key(key)
{
}
PinyinPhraseEntry::~PinyinPhraseEntry()
{
}
#if 0
bool PinyinPhraseEntry::set_frequency(uint32 offset,uint32 freq)
{
for(PhraseOffsetVector::iterator pos=m_phrases.begin();pos!=m_phrases.end();pos++){
if(*pos==offset){
pos->second=freq;
return true;
}
}
#ifdef X86
printf("offset %d -> not found this offset in last matched entry\n",offset);
#endif
return false;
}
#endif
std::istream& PinyinPhraseEntry::input_text (std::istream &is)
{
String keystr;
is>>keystr;
m_key.set_key(keystr.c_str());
if(m_key.isValid()){
PhraseOffset offset;
int count;
is>>count;
for(int i=0;i<count;i++){
is>>offset;
insert(offset);
}
}
return is;
}
std::ostream& PinyinPhraseEntry::output_text(std::ostream &os)
{
for(PinyinKeyVector::iterator pos=m_key.m_keys.begin();pos!=m_key.m_keys.end();pos++){
os<<pos->get_key_string();
}
os<<"\t"<<m_phrases.size()<<"\t";
for(PhraseOffsetVector::iterator pos=m_phrases.begin();pos!=m_phrases.end();pos++){
os<<*pos<<" ";
}
os<<std::endl;
return os;
}
unsigned int PinyinPhraseEntry::get_all_phrases(PhraseOffsetFrequencyPairVector& vect)
{
for(PhraseOffsetVector::iterator pos=m_phrases.begin();pos!=m_phrases.end();pos++){
vect.push_back(std::make_pair(*pos,0));
}
return 0;
}
PinyinPhraseKey::PinyinPhraseKey()
{
}
PinyinPhraseKey::PinyinPhraseKey(const char *keystr)
{
set_key(keystr);
}
PinyinPhraseKey::~PinyinPhraseKey()
{
}
void PinyinPhraseKey::set_key(const char *keystr)
{
PinyinKey::parse_pinyin_key(scim_default_pinyin_validator,m_keys,keystr);
}
String PinyinPhraseKey::get_key_string()
{
String s;
for(unsigned int i=0;i<m_keys.size();i++){
s+=m_keys[i].get_key_string()+" ";
}
return s;
}
| [
"yankaobi@sensenets.com"
] | yankaobi@sensenets.com |
249030829c7a834a2a162dd3d2fa42a76ec35cef | fb6c9780e08996b4d2aaa686c920285c4d0f6b70 | /Red De Programacion Competitiva/2019/03/G.cpp | d1a62862c1085b8dd8041c6931dfdf3acac5df90 | [] | no_license | Diegores14/CompetitiveProgramming | 7c05e241f48a44de0973cfb2f407d77dcbad7b59 | 466ee2ec9a8c17d58866129c6c12fc176cb9ba0c | refs/heads/master | 2021-06-25T08:21:45.341172 | 2020-10-14T03:39:11 | 2020-10-14T03:39:11 | 136,670,647 | 6 | 2 | null | 2018-10-26T23:36:43 | 2018-06-08T22:15:18 | C++ | UTF-8 | C++ | false | false | 601 | cpp | #include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false); cin.tie(NULL);
int x, y, x1, x2, y1, y2;
cin >> x >> y >> x1 >> y1 >> x2 >> y2;
cout << fixed << setprecision(3);
if(x1 <= x && x <= x2) {
cout << (long double)min(abs(y1-y), abs(y2-y)) << '\n';
return 0;
}
if(y1 <= y && y <= y2) {
cout << (long double)min(abs(x1-x), abs(x2-x)) << '\n';
return 0;
}
int a = min(abs(x-x1), abs(x-x2));
int b = min(abs(y-y1), abs(y-y2));
cout << (long double)sqrt(a*a + b*b) << '\n';
return 0;
} | [
"diegorestrepo68@utp.edu.co"
] | diegorestrepo68@utp.edu.co |
10db82a94202a11adc329a3355d1185a0333cb38 | 211a687a66efbf53a0c84f4068bd90bebb113203 | /Opdracht5.3/tests.cpp | 5165060580e8ce31c481ba4e9db7739d39d1e9ae | [] | no_license | StijnvanWijk98/CPSE1 | 0a80ed2e10bed4bb59d883b23a098c5c8b26de7f | d05f64bb3d3dd593e24b9aec8ddf885f440b84b3 | refs/heads/master | 2020-07-20T10:16:10.850571 | 2020-02-13T13:19:15 | 2020-02-13T13:19:15 | 206,623,665 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,989 | cpp | #include <sstream>
#include "catch.hpp"
#include "customArray.hpp"
using std::stringstream;
TEST_CASE("constructor : template <int,1>") {
set v = set<int, 1>();
stringstream s;
s << v;
REQUIRE(s.str() == "");
}
TEST_CASE("constructor : template <char,26>") {
set v = set<char, 26>();
stringstream s;
s << v;
REQUIRE(s.str() == "");
}
TEST_CASE("add, no duplicate : template <float,5>") {
set v = set<float, 5>();
stringstream s;
v.add(3.43);
s << v;
REQUIRE(s.str() == "3.43");
}
TEST_CASE("add, duplicate : template <float,3>") {
set v = set<float, 3>();
stringstream s;
v.add(5.54);
v.add(5.54);
v.add(5.23);
s << v;
REQUIRE(s.str() == "5.54,5.23");
}
TEST_CASE("add, no duplicate : template <char,5>") {
set v = set<char, 5>();
stringstream s;
v.add('h');
v.add('!');
s << v;
REQUIRE(s.str() == "h,!");
}
TEST_CASE("add, duplicate : template <char, 4>") {
set v = set<char, 4>();
stringstream s;
v.add('a');
v.add('a');
s << v;
REQUIRE(s.str() == "a");
}
TEST_CASE("add, full : template <int, 7>") {
set v = set<int, 7>();
stringstream s;
for (int i = 0; i <= 7; i++) {
v.add(i);
}
s << v;
REQUIRE(s.str() == "0,1,2,3,4,5,6");
}
TEST_CASE("add, full : template <float, 5>") {
set v = set<float, 5>();
stringstream s;
for (int i = 1; i <= 6; i++) {
v.add((i+i*0.1));
}
s << v;
REQUIRE(s.str() == "1.1,2.2,3.3,4.4,5.5");
}
TEST_CASE("remove, in array : template <char, 26>") {
set v = set<char, 26>();
stringstream s1;
stringstream s2;
v.add('a');
v.add('n');
v.add('o');
v.add('g');
s1 << v;
REQUIRE(s1.str() == "a,n,o,g");
v.remove('n');
s2 << v;
REQUIRE(s2.str() == "a,g,o");
}
TEST_CASE("remove, not in array : template <int, 5>") {
set v = set<int, 5>();
stringstream s1;
stringstream s2;
v.add(3);
s1 << v;
REQUIRE(s1.str() == "3");
v.remove(5);
s2 << v;
REQUIRE(s2.str() == "3");
}
TEST_CASE("max, filled array : template<int, 9>") {
set v = set<int, 9>();
stringstream s1;
v.add(6);
v.add(4);
v.add(7);
v.add(2);
s1 << v.max();
REQUIRE(s1.str() == "7");
}
TEST_CASE("max, filled array : template<char, 14>") {
set v = set<char, 14>();
stringstream s1;
v.add('!');
v.add('P');
v.add('h');
v.add('Q');
v.add('y');
s1 << v.max();
REQUIRE(s1.str() == "y");
}
TEST_CASE("max, empty array : template<float, 4>") {
set v = set<float, 4>();
stringstream s1;
s1 << v.max();
REQUIRE(s1.str() == "0");
}
TEST_CASE("max, empty array : template<char, 8>") {
set v = set<char, 8>();
stringstream s1;
stringstream s2;
s1 << v.max();
s2 << char(0);
REQUIRE(s1.str() == s2.str());
}
TEST_CASE("max, negative array : template<int,6>"){
set v = set<int, 6>();
stringstream s1;
v.add(-5);
v.add(-14);
v.add(-3);
v.add(-7);
s1 << v.max();
REQUIRE(s1.str() == "-3");
}
// TEST_CASE(", : template<,>") {
// set v = set<int, 5>();
// stringstream s1;
// s1 << v;
// REQUIRE(s1.str() == "");
// }
| [
"stijn.vanwijk@student.hu.nl"
] | stijn.vanwijk@student.hu.nl |
75a643edf8aacf41fcefb45acf0bff1ce4c7ae6b | c4dbc9a483519dd3a3c2c850f41a5f06078c13e4 | /VS/QZoneTest/QZoneTest/JsManager_bak.cpp | 8f20602d9573627bd6f0f050c365c1de243d5ed3 | [] | no_license | uvbs/vc | 73f92933398a60c8506a7850aeb453cd9b06d9de | 27c05a0d17129979980a5db95180daba594e8ff6 | refs/heads/master | 2021-01-19T12:40:21.343375 | 2016-11-03T06:25:13 | 2016-11-03T06:25:13 | null | 0 | 0 | null | null | null | null | GB18030 | C++ | false | false | 7,651 | cpp |
#include "JsManager.h"
Ctx_Map m_jsCtxMap;
////////////////////////////////////////////////////////////////////////////////
CJsArray::CJsArray(CJsManager *pMgr)
{
m_jsMgr = pMgr;
m_arrVal.clear();
}
CJsArray::~CJsArray()
{
}
jsval *CJsArray::getArrayData()
{
return (m_arrVal.size() > 0) ? &m_arrVal[0]: NULL;
}
unsigned int CJsArray::getArrayLength()
{
return m_arrVal.size();
}
void CJsArray::pushElement(int obj)
{
jsval vp = INT_TO_JSVAL(obj);
m_arrVal.push_back(vp);
}
void CJsArray::pushElement(double obj)
{
jsval vp = DOUBLE_TO_JSVAL(obj);
m_arrVal.push_back(vp);
}
bool CJsArray::pushElement(LPCTSTR obj)
{
if (!obj || _tcslen(obj) <= 0) return false;
USES_CONVERSION;
char *strObj = T2A(obj);
JSString *jsString = JS_NewStringCopyZ(m_jsMgr->m_ctx, strObj);
jsval vp = STRING_TO_JSVAL(jsString);
m_arrVal.push_back(vp);
return true;
}
bool CJsArray::FormatElements(TCHAR *fmt, ...)
{
TCHAR c, ch;
va_list ap = NULL;
va_start(ap, fmt);
while((c = *fmt))
{
switch(c)
{
case '%':
ch = *++fmt;
switch(ch)
{
case 'd':
case 'x':
{
int n = va_arg(ap, int);
pushElement(n);
break;
}
case 'f':
{
double f = va_arg(ap, double);
pushElement(f);
break;
}
case 'c':
{
TCHAR chr = va_arg(ap, TCHAR);
TCHAR szChar[2] = {chr};
pushElement(szChar);
break;
}
case 's':
{
TCHAR *p = va_arg(ap, TCHAR*);
pushElement(p);
break;
}
default:return false;
}
break;
default:return false;
}
fmt++;
}
va_end(ap);
return true;
}
////////////////////////////////////////////////////////////////////////////////
static JSClass global_class = {
"global", JSCLASS_GLOBAL_FLAGS,
JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, JS_StrictPropertyStub,
JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, JS_FinalizeStub,
JSCLASS_NO_OPTIONAL_MEMBERS
};
void report_error(JSContext *cx, const char *message, JSErrorReport *report)
{
char pBuffer[2048] = {0};
sprintf_s(pBuffer, 2048, "%s:%u:%s\n",
report->filename ? report->filename : "<no filename>",
(unsigned int)report->lineno,
message);
Ctx_Map::iterator itor = m_jsCtxMap.find(cx);
if(itor != m_jsCtxMap.end())
{
CJsManager *pJsMgr = itor->second;
if (pJsMgr)
{
pJsMgr->m_lastErrorString = pBuffer;
}
}
}
CJsManager::CJsManager(void)
{
m_rt = NULL;
m_ctx = NULL;
m_gObj = NULL;
m_bInitOk = false;
}
CJsManager::~CJsManager(void)
{
Ctx_Map::iterator itor;
itor = m_jsCtxMap.find(m_ctx);
if(itor != m_jsCtxMap.end())
{
m_jsCtxMap.erase(itor);
}
if (m_ctx) JS_DestroyContext(m_ctx);
if (m_rt) JS_DestroyRuntime(m_rt);
JS_ShutDown();
}
bool CJsManager::initGlobalContext(unsigned int contextSize, unsigned int runTimeSize)
{
bool bError = false;
do
{
m_rt = JS_NewRuntime(runTimeSize);
if (m_rt == NULL){
bError = true;
break;
}
m_ctx = JS_NewContext(m_rt, contextSize);
if (m_ctx == NULL){
bError = true;
break;
}
JS_SetOptions(m_ctx, JSOPTION_VAROBJFIX);
JS_SetErrorReporter(m_ctx, report_error);
m_gObj = JS_NewCompartmentAndGlobalObject(m_ctx, &global_class, NULL);
if (m_gObj == NULL){
bError = true;
break;
}
if (!JS_InitStandardClasses(m_ctx, m_gObj)){
bError = true;
break;
}
} while (0);
if (false != bError)
{
if (m_ctx) JS_DestroyContext(m_ctx);
if (m_rt) JS_DestroyRuntime(m_rt);
JS_ShutDown();
return false;
}
m_bInitOk = true;
m_jsCtxMap[m_ctx] = this;
return true;
}
bool CJsManager::runScriptString(LPCTSTR scriptString, jsval& retVal)
{
if (!m_bInitOk || !scriptString || _tcslen(scriptString) <= 0) return false;
JSBool jsRet = JS_FALSE;
#ifdef UNICODE
jsRet = JS_EvaluateUCScript(m_ctx, m_gObj, scriptString, _tcslen(scriptString), NULL, 0, &retVal);
#else
jsRet = JS_EvaluateScript(m_ctx, m_gObj, scriptString, _tcslen(scriptString), NULL, 0, &retVal);
#endif
if (jsRet == JS_FALSE) return false;
return true;
}
bool CJsManager::runScriptFile(LPCTSTR jsPath, jsval& retVal)
{
if (!m_bInitOk || !jsPath || _tcslen(jsPath) <= 0) return false;
USES_CONVERSION;
char *pszPath = T2A(jsPath);
JSObject *scriptObj = JS_CompileFile(m_ctx, m_gObj, pszPath);
if (scriptObj == NULL) return JS_FALSE;
JSBool retBool = JS_ExecuteScript(m_ctx, m_gObj, scriptObj, &retVal);
if (retBool == JS_FALSE) return false;
return true;
}
bool CJsManager::evalFunction(LPCTSTR funName, CJsArray* paramArray, jsval& retVal)
{
USES_CONVERSION;
char *pszFunName = T2A(funName);
int iParamCount = 0;
jsval *paramVal = NULL;
if (paramArray != NULL)
{
iParamCount = paramArray->getArrayLength();
if (iParamCount > 0)
{
paramVal = paramArray->getArrayData();
}
}
JSBool jsRet = JS_CallFunctionName(m_ctx, m_gObj, pszFunName, iParamCount, paramVal, &retVal);
if (!jsRet)return false;
return true;
}
//字符串分割函数
void split(string str, string pattern, vector<string>& outVector)
{
string::size_type pos, size;
str += pattern; //扩展字符串以方便操作
size = str.size();
for(string::size_type i = 0; i < size; ++i)
{
pos = str.find(pattern, i);
if(pos < size)
{
string s = str.substr(i, pos-i);
if (s.size() > 0)
{
outVector.push_back(s);
}
i = pos + pattern.size() - 1;
}
}
}
bool CJsManager::evalObjFunction(LPCTSTR objName, LPCTSTR funName, CJsArray* paramArray, jsval& retVal)
{
if (!objName || _tcslen(objName) <= 0 || !funName || _tcslen(funName) <= 0) return false;
USES_CONVERSION;
char *pObjName = T2A(objName);
char *pFunName = T2A(funName);
vector<string> outVector;
split(pObjName, ".", outVector);
jsval targetObjVal;
JSObject *pParentObj = m_gObj;
size_t objsLen = outVector.size();
for (size_t idx = 0; idx < objsLen; ++idx)
{
string objStep = outVector[idx];
JSBool jsRet = JS_GetProperty(m_ctx, pParentObj, objStep.c_str(), &targetObjVal);
if (!jsRet)return false;
pParentObj = JSVAL_TO_OBJECT(targetObjVal);
}
int iParamCount = 0;
jsval *paramVal = NULL;
if (paramArray != NULL)
{
iParamCount = paramArray->getArrayLength();
if (iParamCount > 0)
{
paramVal = paramArray->getArrayData();
}
}
JSBool jsRet = JS_CallFunctionName(m_ctx, pParentObj, pFunName, iParamCount, paramVal, &retVal);
if (!jsRet) return false;
return true;
}
bool CJsManager::jsval_to_int(jsval vp, int *outval)
{
JSBool jsRet = JS_TRUE;
jsdouble dp;
jsRet = JS_ValueToNumber(m_ctx, vp, &dp);
if (!jsRet) return false;
*outval = (int)dp;
return true;
}
bool CJsManager::jsval_to_uint(jsval vp, unsigned int *outval)
{
JSBool jsRet = JS_TRUE;
jsdouble dp;
jsRet = JS_ValueToNumber(m_ctx, vp, &dp);
if (!jsRet) return false;
*outval = (unsigned int)dp;
return true;
}
bool CJsManager::jsval_to_ushort(jsval vp, unsigned short *outval)
{
JSBool jsRet = JS_TRUE;
jsdouble dp;
jsRet = JS_ValueToNumber(m_ctx, vp, &dp);
if (!jsRet) return false;
*outval = (unsigned short)dp;
return true;
}
bool CJsManager::jsval_to_cstring_for_delete(jsval vp, char** outval)
{
JSString *jsString = JS_ValueToString(m_ctx, vp);
if (!jsString) return false;
size_t nLen = JS_GetStringEncodingLength(m_ctx, jsString);
if (nLen <= 0) return false;
++nLen;
*outval = new char[nLen];
memset(*outval, 0, nLen);
char *pszString = JS_EncodeString(m_ctx, jsString);
strcpy_s(*outval, nLen, pszString);
JS_free(m_ctx, pszString);
return true;
}
bool CJsManager::jsval_to_string(jsval vp, string &outval)
{
JSString *jsString = JS_ValueToString(m_ctx, vp);
if (!jsString) return false;
char *pszString = JS_EncodeString(m_ctx, jsString);\
outval = pszString;
return true;
} | [
"jmp666@126.com"
] | jmp666@126.com |
83d3155e69f7186205a8d4b1303941613d72c32f | 45ace3460f924d573b491de4daed6f1120bf6e6f | /NoTiE/src/Graphics/RenderSystem.h | 0ee7b3e0f045d254391de007c661adb0c57a5e01 | [] | no_license | Fresh-D101/NoTiE | 3c564c52451086c3f0a13e8741b2665e70ed2436 | 6def89dbca342ac9821254da240401700fc80598 | refs/heads/main | 2023-05-07T02:52:10.180368 | 2021-05-23T13:28:20 | 2021-05-23T13:28:20 | 370,042,243 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 318 | h | #pragma once
#include "../Core/System.h"
#include "../Core/Window.h"
class RenderSystem : public System
{
public:
RenderSystem();
void Begin();
void Draw();
void End();
Window& GetWindow();
static Window* GetActiveWindow() { return ActiveWindow; }
private:
Window window;
static Window* ActiveWindow;
}; | [
"42011482+Fresh-D101@users.noreply.github.com"
] | 42011482+Fresh-D101@users.noreply.github.com |
0d054db85c48f838ea83dfe10cc6fb9f080bb6f8 | b09f567815d297a169126d5235cfb1d8945e1faa | /kattis/CircuitCounting.cpp | a1acea88d0ab1bc851411b4b9da0fe5a78b79a2e | [] | no_license | alsuga/Maratones | c913c858e317047a3c4b2944627c814fc2084bd2 | 7271bda427a6ebddf0599d4f6b333d0ab81ecb71 | refs/heads/master | 2021-01-17T15:31:11.039085 | 2016-09-05T20:39:00 | 2016-09-05T20:39:00 | 8,393,509 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 648 | cpp | #include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
map<pii, long long> memo[41];
long long dp(int i, int x, int y, vi &X, vi &Y) {
if(i == X.size())
return(x == 0 and y == 0);
long long a, b;
pii tmp(x, y);
if(memo[i].count(tmp) == 0) {
a = dp(i + 1, x + X[i], y + Y[i], X, Y);
b = dp(i + 1, x, y, X ,Y);
memo[i][tmp] = a + b;
}
return memo[i][tmp];
}
int main() {
int pairs;
cin >> pairs;
vi X(pairs);
vi Y(pairs);
for(int i = 0; i < pairs; i++) {
cin >> X[i] >> Y[i];
}
long long ans = dp(0, 0, 0, X, Y) - 1;
cout << ans << endl;
return 0;
}
| [
"alejandro@sirius.utp.edu.co"
] | alejandro@sirius.utp.edu.co |
a126acc876b253b671e6ff275d88ffab2d40409f | 13a32b92b1ba8ffb07e810dcc8ccdf1b8b1671ab | /home--tommy--mypy/mypy/lib/python2.7/site-packages/pystan/stan/lib/stan_math/stan/math/prim/scal/prob/bernoulli_lccdf.hpp | a793fcdd6920913a0f69730fec36f57bb4fd7770 | [
"Unlicense",
"BSD-3-Clause",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | tommybutler/mlearnpy2 | 8ec52bcd03208c9771d8d02ede8eaa91a95bda30 | 9e5d377d0242ac5eb1e82a357e6701095a8ca1ff | refs/heads/master | 2022-10-24T23:30:18.705329 | 2022-10-17T15:41:37 | 2022-10-17T15:41:37 | 118,529,175 | 0 | 2 | Unlicense | 2022-10-15T23:32:18 | 2018-01-22T23:27:10 | Python | UTF-8 | C++ | false | false | 3,220 | hpp | #ifndef STAN_MATH_PRIM_SCAL_PROB_BERNOULLI_LCCDF_HPP
#define STAN_MATH_PRIM_SCAL_PROB_BERNOULLI_LCCDF_HPP
#include <stan/math/prim/scal/meta/is_constant_struct.hpp>
#include <stan/math/prim/scal/meta/partials_return_type.hpp>
#include <stan/math/prim/scal/meta/operands_and_partials.hpp>
#include <stan/math/prim/scal/err/check_consistent_sizes.hpp>
#include <stan/math/prim/scal/err/check_bounded.hpp>
#include <stan/math/prim/scal/err/check_finite.hpp>
#include <stan/math/prim/scal/err/check_not_nan.hpp>
#include <stan/math/prim/scal/fun/constants.hpp>
#include <stan/math/prim/scal/fun/inv_logit.hpp>
#include <stan/math/prim/scal/fun/log1m.hpp>
#include <stan/math/prim/scal/fun/value_of.hpp>
#include <stan/math/prim/scal/meta/include_summand.hpp>
#include <stan/math/prim/scal/meta/scalar_seq_view.hpp>
#include <boost/random/bernoulli_distribution.hpp>
#include <boost/random/variate_generator.hpp>
#include <cmath>
#include <string>
namespace stan {
namespace math {
/**
* Returns the log CCDF of the Bernoulli distribution. If containers are
* supplied, returns the log sum of the probabilities.
*
* @tparam T_n type of integer parameter
* @tparam T_prob type of chance of success parameter
* @param n integer parameter
* @param theta chance of success parameter
* @return log probability or log sum of probabilities
* @throw std::domain_error if theta is not a valid probability
* @throw std::invalid_argument if container sizes mismatch.
*/
template <typename T_n, typename T_prob>
typename return_type<T_prob>::type
bernoulli_lccdf(const T_n& n, const T_prob& theta) {
static const std::string function = "bernoulli_lccdf";
typedef typename stan::partials_return_type<T_n, T_prob>::type
T_partials_return;
if (!(stan::length(n) && stan::length(theta)))
return 0.0;
T_partials_return P(0.0);
check_finite(function, "Probability parameter", theta);
check_bounded(function, "Probability parameter", theta, 0.0, 1.0);
check_consistent_sizes(function,
"Random variable", n,
"Probability parameter", theta);
scalar_seq_view<T_n> n_vec(n);
scalar_seq_view<T_prob> theta_vec(theta);
size_t size = max_size(n, theta);
using std::log;
operands_and_partials<T_prob> ops_partials(theta);
// Explicit return for extreme values
// The gradients are technically ill-defined, but treated as zero
for (size_t i = 0; i < stan::length(n); i++) {
if (value_of(n_vec[i]) < 0)
return ops_partials.build(0.0);
}
for (size_t i = 0; i < size; i++) {
// Explicit results for extreme values
// The gradients are technically ill-defined, but treated as zero
if (value_of(n_vec[i]) >= 1) {
return ops_partials.build(negative_infinity());
} else {
const T_partials_return Pi = value_of(theta_vec[i]);
P += log(Pi);
if (!is_constant_struct<T_prob>::value)
ops_partials.edge1_.partials_[i] += 1 / Pi;
}
}
return ops_partials.build(P);
}
}
}
#endif
| [
"tbutler.github@internetalias.net"
] | tbutler.github@internetalias.net |
7ddc67dde7c1baec27382e13ccbb4a0b0a286330 | 034a605057a09730f0646014caae0783e4ac207f | /c++/src/example01_8127_xcs/src/Main/vidicon/icx274CCDCtl.cpp | d198ceaf6e10c63f1ad07cc61db108ac018ebba7 | [] | no_license | github188/hbl_test | e5ae977144d32c6be008599975e91aaba114d617 | 69f2c202b7ffb001feb0a40bd2abc258bb6d70a6 | refs/heads/master | 2020-03-25T01:28:51.800879 | 2017-11-06T10:14:00 | 2017-11-06T10:14:00 | null | 0 | 0 | null | null | null | null | GB18030 | C++ | false | false | 12,670 | cpp | /******************************************************************************
* sonyCCDCtl.cpp:
*
* Copyright 2009 - 2100 HANGZHOU PEGVISION Technology Co.,Ltd.
*
* DESCRIPTION:
*
* modification history
* --------------------
* 01a, 2010.06.28, wb Create
* --------------------
******************************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/ioctl.h>
#include <fcntl.h>
#include <string.h>
#include <math.h>
#include "icx274CCDCtl.h"
#include "xcsGlobalDef.h"
#include "SysHandle.h"
#include "SysConf.h"
#include "xcsCommDef.h"
#include "dsp.h"
#include "ispParam.h"
#include "ispV2Param.h"
#if !defined(CYC500XZD)&&!defined(CYC200XZD)
#define VPFE_WIN_1280X960 0
#define VPFE_WIN_1280X720 1
#define VPFE_WIN_720X576 2
#define VPFE_CMD_START (1)
#define DEV_VCAP "/dev/misc/vpif" //"/dev/misc/nwvpfe"
extern char g_cCCDCtlSta;
extern cam_info_t HDConf;
int g_icx274Ctl_Debug= 0xffff;
static int iIcxCcdFd =-1;
int icx274CtlDebugSwitch(int level)
{
g_icx274Ctl_Debug = level;
return 0;
}
int icx274RegCtlInit(void)
{
int ret = -1;
iIcxCcdFd = open(DEV_VCAP, O_RDONLY);
if (iIcxCcdFd < 0)
{
ICX274CTL_ERROR("nwvcap driver open failed!\n");
return -1;
}
ret = ioctl(iIcxCcdFd, VPFE_CMD_START, VPFE_WIN_1280X960);
if (ret < 0)
{
ICX274CTL_ERROR("vpif driver start failed!\n");
return -2;
}
else
{
ICX274CTL_INFO("vpif driver start ok!\n");
}
#if !NEW_PIC_ARITHC
ret = ispCCDParamInit();
if (ret < 0)
{
ICX274CTL_ERROR("ispCCDParamInit failed!\n");
return -3;
}
else
{
ICX274CTL_INFO("ispCCDParamInit ok!\n");
}
#endif
return ret;
}
int icx274RegCtlUnInit(void)
{
int ret = -1;
ret = close(iIcxCcdFd);
ICX274CTL_ERROR("vpif driver dev close ok!\n");
return ret;
}
#if 0
int ccdCamInfoGet(cam_info_t *pCamerainfo)
{
#if defined(CYC200KW)
pCamerainfo->image_width = 1920;
pCamerainfo->image_height = 1072;
#elif defined(CYC500XKW4C)||defined(CYC500XAW)
pCamerainfo->image_width = 2592;
pCamerainfo->image_height = 1932;
#elif defined(CYC800JX)
pCamerainfo->image_width = 3312;
pCamerainfo->image_height = 2432;
#elif defined(CYC800XKW4C)
pCamerainfo->image_width = 3200;
pCamerainfo->image_height = 2466;
#elif defined(CYC500JX)
pCamerainfo->image_width = 2496;
pCamerainfo->image_height = 2048;
#else
pCamerainfo->image_width = 1600;
pCamerainfo->image_height = 1200;
#endif
pCamerainfo->totalpixels = pCamerainfo->image_width*pCamerainfo->image_height;
#if NEW_PIC_ARITHC
pCamerainfo->MaxExposureValue = 255;
pCamerainfo->MinExposureValue = 0;
#else
pCamerainfo->MaxExposureValue = 255;
pCamerainfo->MinExposureValue = 0;
#endif
#if defined(CYC500XKW4C)||defined(CYC500XAW)
#if NEW_PIC_ARITHC
pCamerainfo->MaxShutterValue = 0.01;
pCamerainfo->MinShutterValue = 0.00001;
#else
pCamerainfo->MaxShutterValue = 0.05;
pCamerainfo->MinShutterValue = 0.00007;
#endif
#elif defined(CYC800JX)||defined(CYC500JX)
pCamerainfo->MaxShutterValue = 2;
pCamerainfo->MinShutterValue = 0.00001;
#else
pCamerainfo->MaxShutterValue = 0.05;
pCamerainfo->MinShutterValue = 0.00001;
#endif
#if defined(CYC800JX)||defined(CYC800XKW4C)||defined(CYC500JX)
pCamerainfo->MaxGainValue = 24;
pCamerainfo->MinGainValue = 0;
#else
#if NEW_PIC_ARITHC
pCamerainfo->MaxGainValue = 24;
pCamerainfo->MinGainValue = 6;
#else
pCamerainfo->MaxGainValue = 35;
pCamerainfo->MinGainValue = 0;
#endif
#endif
#if NEW_PIC_ARITHC
pCamerainfo->MaxBrightNessValue = 5;
pCamerainfo->MinBrightNessValue = 0;
#else
pCamerainfo->MaxBrightNessValue = 255;
pCamerainfo->MinBrightNessValue = 0;
#endif
#if NEW_PIC_ARITHC
pCamerainfo->MaxSharpNessValue = 4;
pCamerainfo->MinSharpNessValue = 2;
pCamerainfo->MaxSaturationValue = 5;
pCamerainfo->MinSaturationValue = 0;
#else
pCamerainfo->MaxSharpNessValue = 255;
pCamerainfo->MinSharpNessValue = 0;
pCamerainfo->MaxSaturationValue = 255;
pCamerainfo->MinSaturationValue = 0;
#endif
pCamerainfo->MaxContrastValue = 255;
pCamerainfo->MinContrastValue = 0;
#if NEW_PIC_ARITHC
pCamerainfo->MaxIsoValue = 5;
pCamerainfo->MinIsoValue = 0;
#else
pCamerainfo->MaxIsoValue = 255;
pCamerainfo->MinIsoValue = 0;
#endif
return 0;
}
#endif
#if 0
int icx274CamParamGet(int iType, int* piMode, int* pfFixVal, int* pfMinVal, int* pfMaxVal)
{
int ret =0;
camera274_param_t str274Param;
memset(&str274Param, 0, sizeof(str274Param));
str274Param.uiType = iType;
ret = cameraRunStaParamGet(0, &str274Param);
if(ret != 0)
{
ICX274CTL_INFO("cam 274 set type:%d failed\n", iType);
}
else
{
*pfMaxVal = str274Param.fMaxValue;
*pfMinVal = str274Param.fMinValue;
*pfFixVal = str274Param.fValue;
ICX274CTL_INFO("cam 274 get type:%d,mode:%d,fixVal:%f,minVal:%f,maxVal:%f!\n", \
iType, str274Param.uiMode, str274Param.fValue, str274Param.fMinValue, str274Param.fMaxValue);
}
return ret;
}
#endif
int icx274CamParamSet(int iMode, int iType, float fMinVal, float fMaxVal, float fFixVal)
{
int ret =0;
#if 0
//camera274_param_t str274Param;
//memset(&str274Param, 0, sizeof(str274Param));
//switch(iMode)
//{
// case FIX:
// str274Param.uiMode = 0;
// break;
// case INTERVAL:
// str274Param.uiMode = 1;
// break;
// case AUTO:
// str274Param.uiMode = 2;
// break;
// case DISABEL:
// str274Param.uiMode = 3;
// break;
// default:
// str274Param.uiMode = 0;
// break;
//}
//if(CAMERA_PARAM_MINSCALE == iType)
//{
// if( fFixVal <= 2)
// {
// fFixVal = 2;
// }
//}
//
//str274Param.uiType = iType;
//str274Param.fMaxValue = fMaxVal;
//str274Param.fMinValue = fMinVal;
//str274Param.fValue = fFixVal;
////ret = dsp_camera274_param_set(0, &str274Param);
//if(ret != 0)
//{
// ICX274CTL_INFO("cam 274 set type:%d failed\n", iType);
//}
//else
//{
// ICX274CTL_INFO("cam 274 set type:%d mode:%d,fixVal:%f,fMinVal:%f,fMaxVal:%f\n", iType, iMode, \
// str274Param.fValue, str274Param.fMinValue, str274Param.fMaxValue);
//}
#endif
return ret;
}
#if 0
int icx274CamParamGet(int iType, int* piMode, int* pfFixVal, int* pfMinVal, int* pfMaxVal)
{
int ret =0;
camera274_param_t str274Param;
memset(&str274Param, 0, sizeof(str274Param));
str274Param.uiType = iType;
ret = cameraRunStaParamGet(0, &str274Param);
if(ret != 0)
{
ICX274CTL_INFO("cam 274 set type:%d failed\n", iType);
}
else
{
*pfMaxVal = str274Param.fMaxValue;
*pfMinVal = str274Param.fMinValue;
*pfFixVal = str274Param.fValue;
ICX274CTL_INFO("cam 274 get type:%d,mode:%d,fixVal:%f,minVal:%f,maxVal:%f!\n", \
iType, str274Param.uiMode, str274Param.fValue, str274Param.fMinValue, str274Param.fMaxValue);
}
return ret;
}
#endif
float judgeCamCtlVal(unsigned int uiCamCtlType, float fVal)
{
if(g_cCCDCtlSta != 1)
return fVal;
switch (uiCamCtlType)
{
case ESHUTTER:
if( (fVal >= HDConf.MinShutterValue) && (fVal <= HDConf.MaxShutterValue) )
{
return fVal;
}
else if (fVal < HDConf.MinShutterValue)
{
return HDConf.MinShutterValue;
}
else
{
return HDConf.MaxShutterValue;
}
break;
case EGAIN:
if( (fVal >= HDConf.MinGainValue) && (fVal <= HDConf.MaxGainValue) )
{
return fVal;
}
else if ( fVal < HDConf.MinGainValue )
{
return HDConf.MinGainValue;
}
else
{
return HDConf.MaxGainValue;
}
break;
case EEXPOSURE:
if( (fVal >= HDConf.MinExposureValue) && (fVal <= HDConf.MaxExposureValue) )
{
return fVal;
}
else if ( fVal < HDConf.MinExposureValue )
{
return HDConf.MinExposureValue;
}
else
{
return HDConf.MaxExposureValue;
}
break;
case EBRIGHTNESS:
if( (fVal >= HDConf.MinBrightNessValue) && (fVal <= HDConf.MaxBrightNessValue) )
{
return fVal;
}
else if ( fVal < HDConf.MinBrightNessValue )
{
return HDConf.MinBrightNessValue;
}
else
{
return HDConf.MaxBrightNessValue;
}
break;
case ECONTRAST:
if( (fVal >= HDConf.MinContrastValue) && (fVal <= HDConf.MaxContrastValue) )
{
return fVal;
}
else if ( fVal < HDConf.MinContrastValue )
{
return HDConf.MinContrastValue;
}
else
{
return HDConf.MaxContrastValue;
}
break;
case ESHARPNESS:
if( (fVal >= HDConf.MinSharpNessValue) && (fVal <= HDConf.MaxSharpNessValue) )
{
return fVal;
}
else if ( fVal < HDConf.MinSharpNessValue )
{
return HDConf.MinSharpNessValue;
}
else
{
return HDConf.MaxSharpNessValue;
}
break;
case ESATURATION:
if( (fVal >= HDConf.MinSaturationValue) && (fVal <= HDConf.MaxSaturationValue) )
{
return fVal;
}
else if(fVal < HDConf.MinSaturationValue)
{
return HDConf.MinSaturationValue;
}
else
{
return HDConf.MaxSaturationValue;
}
break;
case EISO:
if( (fVal >= HDConf.MinIsoValue) && (fVal <= HDConf.MaxIsoValue) )
{
return fVal;
}
else if(fVal < HDConf.MinIsoValue)
{
return HDConf.MinIsoValue;
}
else
{
return HDConf.MaxIsoValue;
}
break;
default:
break;
}
return fVal;
}
int dspCameraInfoShow(void)
{
int ret =-1;
memset(&HDConf, 0, sizeof(cam_info_t));
ret = ccdCamInfoGet(&HDConf);
#if defined(CYC200MK)||defined(CYC200K3)||defined(CYC200K2)||defined(CYC200KT)
g_uiCamLaneSum = 2;
#elif defined(CYC500XKW4C)||defined(CYC500XAW)
g_uiCamLaneSum = 3;
#elif defined(CYC200KX3)||defined(CYC200XKW)
unsigned int uiTmp =0;
/* 注意:200万摄像头,右转90度 */
uiTmp = HDConf.image_height;
HDConf.image_height = HDConf.image_width;
HDConf.image_width = uiTmp;
g_uiCamLaneSum = 2;
#elif defined(CYC500XKW4C)||defined(CYC500XAW)
g_uiCamLaneSum = 3;
#else
g_uiCamLaneSum = 3;
#endif
ICX274CTL_INFO("icx274 Cam info:\n");
ICX274CTL_INFO("total pixels:%d width:%d height:%d \n", HDConf.totalpixels, HDConf.image_width, HDConf.image_height);
ICX274CTL_INFO("Grey minVal:%f maxVal:%f\n", HDConf.MinExposureValue, HDConf.MaxExposureValue);
ICX274CTL_INFO("Gain minVal:%f maxVal:%f\n", HDConf.MinGainValue, HDConf.MaxGainValue);
ICX274CTL_INFO("shutter minVal:%f maxVal:%f\n", HDConf.MinShutterValue, HDConf.MaxShutterValue);
ICX274CTL_INFO("BrightNess minVal:%f maxVal:%f\n", HDConf.MinBrightNessValue, HDConf.MaxBrightNessValue);
ICX274CTL_INFO("MinScal minVal:%f maxVal:%f\n", HDConf.MinSharpNessValue, HDConf.MaxSharpNessValue);
ICX274CTL_INFO("Colour adjust minVal:%f maxVal:%f\n", HDConf.MinSaturationValue, HDConf.MaxSaturationValue);
ICX274CTL_INFO("Auto white balance minVal:%f maxVal:%f\n", HDConf.MinContrastValue, HDConf.MaxContrastValue);
ICX274CTL_INFO("ISO minVal:%f maxVal:%f\n", HDConf.MinIsoValue, HDConf.MaxIsoValue);
return ret;
}
#endif
| [
"13738129702@163.com"
] | 13738129702@163.com |
bf194d2ff535b0b3799fb4312847ac759b6d1384 | 7eb63c1a3f53149a5a8791a762f036a90f12a989 | /src/Process/RGBToHSV.h | ebb39fe82fdcc1574651bbada68730df2c5f3ad2 | [] | no_license | PaperBirds/TinkerVision | 577c259bdb5431c17806c6b528d6b7132c512cc9 | e47d589a21eb027698f014a9a912d6558d260cf3 | refs/heads/master | 2022-08-11T12:14:38.046283 | 2020-05-23T17:19:26 | 2020-05-23T17:19:26 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 433 | h | #pragma once
#include "TinkerVision_export.h"
#include "../Core/ImageType.h"
#include "../Core/Image.h"
#include "../Core/ImageGPU.h"
namespace TnkrVis
{
namespace Process
{
class TINKERVISION_EXPORT RGBToHSV
{
private:
class Internal;
Internal* internal;
public:
RGBToHSV();
~RGBToHSV();
void Run(ImageGPU* input, ImageGPU* output);
void Run(Image* input, Image* output);
};
}
} | [
"reubenjcarter@gmail.com"
] | reubenjcarter@gmail.com |
3b9891d284bc1f87af9a7e73932763a1699f3342 | 79f3c7f0faa4685715b8fdc13b8dda7cf915e8d1 | /STM32F1xx_CPP_FW - PowerMonitor_V1_15_Jun_20/HW_Modules/SD/src/SD.cpp | ea454eeba90f22dc8c14985ee7d516f897a3aa7a | [] | no_license | amitandgithub/STM32F1xx_CPP_FW | fc155c2f0772b1b282388b6c2e2d24ebe8daf946 | b61816696109cb48d0eb4a0a0b9b1232881ea5c3 | refs/heads/master | 2023-02-11T16:55:30.247303 | 2020-12-26T16:56:47 | 2020-12-26T16:56:47 | 178,715,062 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 545 | cpp | /******************
** FILE: SD.cpp
**
** DESCRIPTION:
** SD card functionality
**
** CREATED: 10/31/2018, by Amit Chaudhary
******************/
#include "SD.h"
namespace BSP
{
SD::SD(SPIDrv_t* pSpiDriverSD , Port_t CSPort, PIN_t CSPin) : m_pSpiDriverSD(pSpiDriverSD), m_pSD_CS(CSPort,CSPin)
{
}
void SD::HwInit()
{
m_pSpiDriverSD->HwInit();
m_pSD_CS.HwInit();
}
uint8_t SD::spi_txrx(uint8_t data)
{
return m_pSpiDriverSD->TxRxPoll(data,1);
}
} // Namespace Peripherals
| [
"34563851+amitandgithub@users.noreply.github.com"
] | 34563851+amitandgithub@users.noreply.github.com |
339df9f6bc01aa4384fad79b8fae332f2f48469d | 32bb24a4c6ae272288f8652e0463c19a61e440f7 | /CTCI/test/arrays-and-strings-tests.cpp | 750532e7dadf1fc46dc2688a2281c2f78cc62894 | [] | no_license | thembones79/CTCI-CPP14 | 99b3ba3383587b7b31d2e949964da25c252a3eff | a043d3814bbee3521d8123a63d892001db2fe8df | refs/heads/master | 2020-05-27T10:44:16.996895 | 2018-03-15T05:33:34 | 2018-03-15T05:33:34 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,972 | cpp | #include "catch.hpp"
#include "../src/arrays-and-strings.cpp"
TEST_CASE( "Function `only_unique_chars` returns true if a string has only unique characters",
"[arraysandstrings][chapterone]" ) {
SECTION( "All unique chars present returns true" ) {
std::string str { "abcdefghijkl" };
REQUIRE( OnlyUniqueChars(&str) );
}
SECTION( "Duplicate chars present returns false" ) {
std::string str { "abcdefabcxef" };
REQUIRE_FALSE( OnlyUniqueChars(&str) );
}
SECTION( "Duplicate mixed-case chars present returns false" ) {
std::string str { "ABCabc" };
REQUIRE_FALSE( OnlyUniqueChars(&str) );
}
SECTION( "Empty string throws exception" ) {
std::string str;
REQUIRE_THROWS_WITH( OnlyUniqueChars(&str),
"Empty string is both unique and not unique." );
}
}
TEST_CASE( "Function `reverse` reverses the characters of a C-style string in place",
"[arraysandstrings][chapterone]" ) {
SECTION( "Normal string reverses as expected" ) {
char forwards[] = "Hello World";
char reversed[] = "dlroW olleH";
Reverse(forwards);
REQUIRE( strcmp(forwards,reversed) == 0 );
}
SECTION( "Empty string throws exception" ) {
char forwards[0];
REQUIRE_THROWS_WITH( Reverse(forwards),
"Empty string cannot be reversed." );
}
}
TEST_CASE( "Function `bad_compression` performs a bad compression",
"[arraysandstrings][chapterone]" ) {
SECTION( "Normal string compresses as expected" ) {
std::string uncompressed = "aabbbcc";
std::string act_compressed = BadCompression(uncompressed);
std::string exp_compressed = "a2b3c2";
REQUIRE( act_compressed == exp_compressed );
}
SECTION( "Compression is never longer" ) {
std::string test_cases[] {
"asdachbhjbhkhjjsdhbchee",
"hhagdndhddkdhehet",
"iiihsnwnwwwjfbche",
"qwertyqwertyqqwweerrttyy"
};
for (const std::string &str : test_cases) {
REQUIRE( BadCompression(str).length() <= str.length() );
}
}
SECTION( "No invalid characters are present, most importantly numbers" ) {
std::string str = "aa4bbb9cc";
REQUIRE_THROWS_WITH( BadCompression(str), "Invalid character in string." );
}
}
TEST_CASE( "Function `rotate_img` rotates a matrix 90degrees",
"[arraysandstrings][chapterone]" ) {
SECTION( "Small odd matrix is rotated as expected" ) {
int original_image[3][3] = {
{1,1,2},
{4,5,2},
{4,3,3}
};
int rotated_image[3][3] = {
{4,4,1},
{3,5,1},
{3,2,2}
};
RotateImg(original_image, 3);
bool are_equal = true;
for (size_t row = 0; row < 3; ++row) {
for (size_t col = 0; col < 3; ++col) {
if (original_image[row][col] != rotated_image[row][col]) {
are_equal = false;
}
}
}
REQUIRE( are_equal );
}
SECTION( "Medium even matrix is rotated as expected" ) {
int original_image[6][6] = {
{1,2,3,4,5,6},
{2,3,4,5,6,7},
{3,4,5,6,7,8},
{4,5,6,7,8,9},
{5,6,7,8,9,0},
{6,7,8,9,0,1}
};
int rotated_image[6][6] = {
{6,5,4,3,2,1},
{7,6,5,4,3,2},
{8,7,6,5,4,3},
{9,8,7,6,5,4},
{0,9,8,7,6,5},
{1,0,9,8,7,6}
};
RotateImg(original_image, 6);
bool are_equal = true;
for (size_t row = 0; row < 6; ++row) {
for (size_t col = 0; col < 6; ++col) {
if (original_image[row][col] != rotated_image[row][col]) {
are_equal = false;
}
}
}
REQUIRE( are_equal );
}
SECTION( "Four rotations preserves matrix " ) {
int original_image[3][3] = {
{1,1,2},
{4,5,2},
{4,3,3}
};
int original_image_copy[3][3] = {
{1,1,2},
{4,5,2},
{4,3,3}
};
RotateImg(original_image, 3);
RotateImg(original_image, 3);
RotateImg(original_image, 3);
RotateImg(original_image, 3);
bool are_equal = true;
for (size_t row = 0; row < 3; ++row) {
for (size_t col = 0; col < 3; ++col) {
if (original_image[row][col] != original_image_copy[row][col]) {
are_equal = false;
}
}
}
REQUIRE( are_equal );
}
}
TEST_CASE( "Function `zero_intercepts` zeros rows and cols which contain a zero",
"[arraysandstrings][chapterone]" ) {
SECTION( "Intercepts are zeroed as expected" ) {
int matrix[6][6] = {
{1,2,3,4,5,6},
{2,3,4,5,6,7},
{3,4,0,6,7,8},
{4,5,6,7,8,9},
{5,6,7,8,9,0},
{6,7,8,9,0,1}
};
int zeroed[6][6] = {
{1,2,0,4,0,0},
{2,3,0,5,0,0},
{0,0,0,0,0,0},
{4,5,0,7,0,0},
{0,0,0,0,0,0},
{0,0,0,0,0,0}
};
ZeroIntercepts(matrix);
bool are_equal = true;
for (size_t row = 0; row < 6; ++row) {
for (size_t col = 0; col < 6; ++col) {
if (matrix[row][col] != zeroed[row][col]) {
are_equal = false;
}
}
}
REQUIRE( are_equal );
}
}
| [
"JFLivengood@gmail.com"
] | JFLivengood@gmail.com |
6047f1cb2645476498c745b2071adb611eccdff6 | a9f025cb41418c2a52893ef8d17308e593f0201e | /cgds/canvas.cpp | ad48f9efdec3270b133bcc48fb6aec41bc230e73 | [] | no_license | billowen/cgds | 9b008a921ac2264cef04194d2a2fb5d26198cd8a | 94897d9694dd35369e2685b03409ecb94cd53794 | refs/heads/master | 2016-08-03T15:15:03.990599 | 2015-09-01T09:40:56 | 2015-09-01T09:40:56 | 41,073,180 | 1 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 617 | cpp | #include <assert.h>
#include "canvas.h"
#include "structures.h"
#include "graphicsitems.h"
namespace GDS
{
Canvas::Canvas(std::shared_ptr<Structure> cell, QWidget *parent)
: QGraphicsView(parent)
{
//assert(cell);
cell_ = cell;
setScene(new QGraphicsScene());
scale(1, -1);
for (size_t i = 0; i < cell_->size(); i++)
{
scene()->addItem(new ViewItem(cell_->get(i)));
}
// scene()->addItem(new QGraphicsLineItem(0, -5, 0, 5));
// scene()->addItem(new QGraphicsLineItem(-5, 0, 5, 0));
fitInView(scene()->sceneRect(), Qt::KeepAspectRatio);
}
Canvas::~Canvas()
{
}
}
| [
"billowen035@gmail.com"
] | billowen035@gmail.com |
996fff5395c5c8e33dc11f31e4a0f68ddecbfa34 | e69721183d32eb45177fa0918dfd51b883ecda2b | /dependencies/imgui/imgui.cpp | 387856a8e24f087de2e5d331322f2524ad077c36 | [
"MIT"
] | permissive | LuminousAme/Dam-Defense | 0520c32ea001a04c6bedb8a83fe90725b8cf9ddc | 86704cfc4215d4513cb50c6865490886a52d558e | refs/heads/main | 2023-04-16T06:16:50.833222 | 2021-04-12T21:09:09 | 2021-04-12T21:09:09 | 300,457,760 | 1 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 756,438 | cpp | // dear imgui, v1.73 WIP
// (main code and documentation)
// Call and read ImGui::ShowDemoWindow() in imgui_demo.cpp for demo code.
// Newcomers, read 'Programmer guide' below for notes on how to setup Dear ImGui in your codebase.
// Get latest version at https://github.com/ocornut/imgui
// Releases change-log at https://github.com/ocornut/imgui/releases
// Technical Support for Getting Started https://discourse.dearimgui.org/c/getting-started
// Gallery (please post your screenshots/video there!): https://github.com/ocornut/imgui/issues/2529
// Developed by Omar Cornut and every direct or indirect contributors to the GitHub.
// See LICENSE.txt for copyright and licensing details (standard MIT License).
// This library is free but I need your support to sustain development and maintenance.
// Businesses: you can support continued maintenance and development via support contracts or sponsoring, see docs/README.
// Individuals: you can support continued maintenance and development via donations or Patreon https://www.patreon.com/imgui.
// It is recommended that you don't modify imgui.cpp! It will become difficult for you to update the library.
// Note that 'ImGui::' being a namespace, you can add functions into the namespace from your own source files, without
// modifying imgui.h or imgui.cpp. You may include imgui_internal.h to access internal data structures, but it doesn't
// come with any guarantee of forward compatibility. Discussing your changes on the GitHub Issue Tracker may lead you
// to a better solution or official support for them.
/*
Index of this file:
DOCUMENTATION
- MISSION STATEMENT
- END-USER GUIDE
- PROGRAMMER GUIDE (read me!)
- Read first.
- How to update to a newer version of Dear ImGui.
- Getting started with integrating Dear ImGui in your code/engine.
- This is how a simple application may look like (2 variations).
- This is how a simple rendering function may look like.
- Using gamepad/keyboard navigation controls.
- API BREAKING CHANGES (read me when you update!)
- FREQUENTLY ASKED QUESTIONS (FAQ), TIPS
- Where is the documentation?
- Which version should I get?
- Who uses Dear ImGui?
- Why the odd dual naming, "Dear ImGui" vs "ImGui"?
- How can I tell whether to dispatch mouse/keyboard to imgui or to my application?
- How can I display an image? What is ImTextureID, how does it works?
- Why are multiple widgets reacting when I interact with a single one? How can I have
multiple widgets with the same label or with an empty label? A primer on labels and the ID Stack...
- How can I use my own math types instead of ImVec2/ImVec4?
- How can I load a different font than the default?
- How can I easily use icons in my application?
- How can I load multiple fonts?
- How can I display and input non-latin characters such as Chinese, Japanese, Korean, Cyrillic?
- How can I interact with standard C++ types (such as std::string and std::vector)?
- How can I use the drawing facilities without a Dear ImGui window? (using ImDrawList API)
- How can I use Dear ImGui on a platform that doesn't have a mouse or a keyboard? (input share, remoting, gamepad)
- I integrated Dear ImGui in my engine and the text or lines are blurry..
- I integrated Dear ImGui in my engine and some elements are clipping or disappearing when I move windows around..
- How can I help?
CODE
(search for "[SECTION]" in the code to find them)
// [SECTION] FORWARD DECLARATIONS
// [SECTION] CONTEXT AND MEMORY ALLOCATORS
// [SECTION] MAIN USER FACING STRUCTURES (ImGuiStyle, ImGuiIO)
// [SECTION] MISC HELPERS/UTILITIES (Maths, String, Format, Hash, File functions)
// [SECTION] MISC HELPERS/UTILITIES (ImText* functions)
// [SECTION] MISC HELPERS/UTILITIES (Color functions)
// [SECTION] ImGuiStorage
// [SECTION] ImGuiTextFilter
// [SECTION] ImGuiTextBuffer
// [SECTION] ImGuiListClipper
// [SECTION] RENDER HELPERS
// [SECTION] MAIN CODE (most of the code! lots of stuff, needs tidying up!)
// [SECTION] SCROLLING
// [SECTION] TOOLTIPS
// [SECTION] POPUPS
// [SECTION] KEYBOARD/GAMEPAD NAVIGATION
// [SECTION] DRAG AND DROP
// [SECTION] LOGGING/CAPTURING
// [SECTION] SETTINGS
// [SECTION] VIEWPORTS, PLATFORM WINDOWS
// [SECTION] DOCKING
// [SECTION] PLATFORM DEPENDENT HELPERS
// [SECTION] METRICS/DEBUG WINDOW
*/
//-----------------------------------------------------------------------------
// DOCUMENTATION
//-----------------------------------------------------------------------------
/*
MISSION STATEMENT
=================
- Easy to use to create code-driven and data-driven tools.
- Easy to use to create ad hoc short-lived tools and long-lived, more elaborate tools.
- Easy to hack and improve.
- Minimize screen real-estate usage.
- Minimize setup and maintenance.
- Minimize state storage on user side.
- Portable, minimize dependencies, run on target (consoles, phones, etc.).
- Efficient runtime and memory consumption (NB- we do allocate when "growing" content e.g. creating a window,.
opening a tree node for the first time, etc. but a typical frame should not allocate anything).
Designed for developers and content-creators, not the typical end-user! Some of the weaknesses includes:
- Doesn't look fancy, doesn't animate.
- Limited layout features, intricate layouts are typically crafted in code.
END-USER GUIDE
==============
- Double-click on title bar to collapse window.
- Click upper right corner to close a window, available when 'bool* p_open' is passed to ImGui::Begin().
- Click and drag on lower right corner to resize window (double-click to auto fit window to its contents).
- Click and drag on any empty space to move window.
- TAB/SHIFT+TAB to cycle through keyboard editable fields.
- CTRL+Click on a slider or drag box to input value as text.
- Use mouse wheel to scroll.
- Text editor:
- Hold SHIFT or use mouse to select text.
- CTRL+Left/Right to word jump.
- CTRL+Shift+Left/Right to select words.
- CTRL+A our Double-Click to select all.
- CTRL+X,CTRL+C,CTRL+V to use OS clipboard/
- CTRL+Z,CTRL+Y to undo/redo.
- ESCAPE to revert text to its original value.
- You can apply arithmetic operators +,*,/ on numerical values. Use +- to subtract (because - would set a negative value!)
- Controls are automatically adjusted for OSX to match standard OSX text editing operations.
- General Keyboard controls: enable with ImGuiConfigFlags_NavEnableKeyboard.
- General Gamepad controls: enable with ImGuiConfigFlags_NavEnableGamepad. See suggested mappings in imgui.h ImGuiNavInput_ + download PNG/PSD at http://goo.gl/9LgVZW
PROGRAMMER GUIDE
================
READ FIRST:
- Read the FAQ below this section!
- Your code creates the UI, if your code doesn't run the UI is gone! The UI can be highly dynamic, there are no construction
or destruction steps, less superfluous data retention on your side, less state duplication, less state synchronization, less bugs.
- Call and read ImGui::ShowDemoWindow() for demo code demonstrating most features.
- The library is designed to be built from sources. Avoid pre-compiled binaries and packaged versions. See imconfig.h to configure your build.
- Dear ImGui is an implementation of the IMGUI paradigm (immediate-mode graphical user interface, a term coined by Casey Muratori).
You can learn about IMGUI principles at http://www.johno.se/book/imgui.html, http://mollyrocket.com/861 & more links docs/README.md.
- Dear ImGui is a "single pass" rasterizing implementation of the IMGUI paradigm, aimed at ease of use and high-performances.
For every application frame your UI code will be called only once. This is in contrast to e.g. Unity's own implementation of an IMGUI,
where the UI code is called multiple times ("multiple passes") from a single entry point. There are pros and cons to both approaches.
- Our origin are on the top-left. In axis aligned bounding boxes, Min = top-left, Max = bottom-right.
- This codebase is also optimized to yield decent performances with typical "Debug" builds settings.
- Please make sure you have asserts enabled (IM_ASSERT redirects to assert() by default, but can be redirected).
If you get an assert, read the messages and comments around the assert.
- C++: this is a very C-ish codebase: we don't rely on C++11, we don't include any C++ headers, and ImGui:: is a namespace.
- C++: ImVec2/ImVec4 do not expose math operators by default, because it is expected that you use your own math types.
See FAQ "How can I use my own math types instead of ImVec2/ImVec4?" for details about setting up imconfig.h for that.
However, imgui_internal.h can optionally export math operators for ImVec2/ImVec4, which we use in this codebase.
- C++: pay attention that ImVector<> manipulates plain-old-data and does not honor construction/destruction (avoid using it in your code!).
HOW TO UPDATE TO A NEWER VERSION OF DEAR IMGUI:
- Overwrite all the sources files except for imconfig.h (if you have made modification to your copy of imconfig.h)
- Or maintain your own branch where you have imconfig.h modified.
- Read the "API BREAKING CHANGES" section (below). This is where we list occasional API breaking changes.
If a function/type has been renamed / or marked obsolete, try to fix the name in your code before it is permanently removed
from the public API. If you have a problem with a missing function/symbols, search for its name in the code, there will
likely be a comment about it. Please report any issue to the GitHub page!
- Try to keep your copy of dear imgui reasonably up to date.
GETTING STARTED WITH INTEGRATING DEAR IMGUI IN YOUR CODE/ENGINE:
- Run and study the examples and demo in imgui_demo.cpp to get acquainted with the library.
- Add the Dear ImGui source files to your projects or using your preferred build system.
It is recommended you build and statically link the .cpp files as part of your project and not as shared library (DLL).
- You can later customize the imconfig.h file to tweak some compile-time behavior, such as integrating Dear ImGui types with your own maths types.
- When using Dear ImGui, your programming IDE is your friend: follow the declaration of variables, functions and types to find comments about them.
- Dear ImGui never touches or knows about your GPU state. The only function that knows about GPU is the draw function that you provide.
Effectively it means you can create widgets at any time in your code, regardless of considerations of being in "update" vs "render"
phases of your own application. All rendering information are stored into command-lists that you will retrieve after calling ImGui::Render().
- Refer to the bindings and demo applications in the examples/ folder for instruction on how to setup your code.
- If you are running over a standard OS with a common graphics API, you should be able to use unmodified imgui_impl_*** files from the examples/ folder.
HOW A SIMPLE APPLICATION MAY LOOK LIKE:
EXHIBIT 1: USING THE EXAMPLE BINDINGS (imgui_impl_XXX.cpp files from the examples/ folder).
// Application init: create a dear imgui context, setup some options, load fonts
ImGui::CreateContext();
ImGuiIO& io = ImGui::GetIO();
// TODO: Set optional io.ConfigFlags values, e.g. 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard' to enable keyboard controls.
// TODO: Fill optional fields of the io structure later.
// TODO: Load TTF/OTF fonts if you don't want to use the default font.
// Initialize helper Platform and Renderer bindings (here we are using imgui_impl_win32 and imgui_impl_dx11)
ImGui_ImplWin32_Init(hwnd);
ImGui_ImplDX11_Init(g_pd3dDevice, g_pd3dDeviceContext);
// Application main loop
while (true)
{
// Feed inputs to dear imgui, start new frame
ImGui_ImplDX11_NewFrame();
ImGui_ImplWin32_NewFrame();
ImGui::NewFrame();
// Any application code here
ImGui::Text("Hello, world!");
// Render dear imgui into screen
ImGui::Render();
ImGui_ImplDX11_RenderDrawData(ImGui::GetDrawData());
g_pSwapChain->Present(1, 0);
}
// Shutdown
ImGui_ImplDX11_Shutdown();
ImGui_ImplWin32_Shutdown();
ImGui::DestroyContext();
HOW A SIMPLE APPLICATION MAY LOOK LIKE:
EXHIBIT 2: IMPLEMENTING CUSTOM BINDING / CUSTOM ENGINE.
// Application init: create a dear imgui context, setup some options, load fonts
ImGui::CreateContext();
ImGuiIO& io = ImGui::GetIO();
// TODO: Set optional io.ConfigFlags values, e.g. 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard' to enable keyboard controls.
// TODO: Fill optional fields of the io structure later.
// TODO: Load TTF/OTF fonts if you don't want to use the default font.
// Build and load the texture atlas into a texture
// (In the examples/ app this is usually done within the ImGui_ImplXXX_Init() function from one of the demo Renderer)
int width, height;
unsigned char* pixels = NULL;
io.Fonts->GetTexDataAsRGBA32(&pixels, &width, &height);
// At this point you've got the texture data and you need to upload that your your graphic system:
// After we have created the texture, store its pointer/identifier (_in whichever format your engine uses_) in 'io.Fonts->TexID'.
// This will be passed back to your via the renderer. Basically ImTextureID == void*. Read FAQ below for details about ImTextureID.
MyTexture* texture = MyEngine::CreateTextureFromMemoryPixels(pixels, width, height, TEXTURE_TYPE_RGBA32)
io.Fonts->TexID = (void*)texture;
// Application main loop
while (true)
{
// Setup low-level inputs, e.g. on Win32: calling GetKeyboardState(), or write to those fields from your Windows message handlers, etc.
// (In the examples/ app this is usually done within the ImGui_ImplXXX_NewFrame() function from one of the demo Platform bindings)
io.DeltaTime = 1.0f/60.0f; // set the time elapsed since the previous frame (in seconds)
io.DisplaySize.x = 1920.0f; // set the current display width
io.DisplaySize.y = 1280.0f; // set the current display height here
io.MousePos = my_mouse_pos; // set the mouse position
io.MouseDown[0] = my_mouse_buttons[0]; // set the mouse button states
io.MouseDown[1] = my_mouse_buttons[1];
// Call NewFrame(), after this point you can use ImGui::* functions anytime
// (So you want to try calling NewFrame() as early as you can in your mainloop to be able to use Dear ImGui everywhere)
ImGui::NewFrame();
// Most of your application code here
ImGui::Text("Hello, world!");
MyGameUpdate(); // may use any Dear ImGui functions, e.g. ImGui::Begin("My window"); ImGui::Text("Hello, world!"); ImGui::End();
MyGameRender(); // may use any Dear ImGui functions as well!
// Render dear imgui, swap buffers
// (You want to try calling EndFrame/Render as late as you can, to be able to use Dear ImGui in your own game rendering code)
ImGui::EndFrame();
ImGui::Render();
ImDrawData* draw_data = ImGui::GetDrawData();
MyImGuiRenderFunction(draw_data);
SwapBuffers();
}
// Shutdown
ImGui::DestroyContext();
HOW A SIMPLE RENDERING FUNCTION MAY LOOK LIKE:
void void MyImGuiRenderFunction(ImDrawData* draw_data)
{
// TODO: Setup render state: alpha-blending enabled, no face culling, no depth testing, scissor enabled
// TODO: Setup viewport covering draw_data->DisplayPos to draw_data->DisplayPos + draw_data->DisplaySize
// TODO: Setup orthographic projection matrix cover draw_data->DisplayPos to draw_data->DisplayPos + draw_data->DisplaySize
// TODO: Setup shader: vertex { float2 pos, float2 uv, u32 color }, fragment shader sample color from 1 texture, multiply by vertex color.
for (int n = 0; n < draw_data->CmdListsCount; n++)
{
const ImDrawList* cmd_list = draw_data->CmdLists[n];
const ImDrawVert* vtx_buffer = cmd_list->VtxBuffer.Data; // vertex buffer generated by Dear ImGui
const ImDrawIdx* idx_buffer = cmd_list->IdxBuffer.Data; // index buffer generated by Dear ImGui
for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++)
{
const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
if (pcmd->UserCallback)
{
pcmd->UserCallback(cmd_list, pcmd);
}
else
{
// The texture for the draw call is specified by pcmd->TextureId.
// The vast majority of draw calls will use the Dear ImGui texture atlas, which value you have set yourself during initialization.
MyEngineBindTexture((MyTexture*)pcmd->TextureId);
// We are using scissoring to clip some objects. All low-level graphics API should supports it.
// - If your engine doesn't support scissoring yet, you may ignore this at first. You will get some small glitches
// (some elements visible outside their bounds) but you can fix that once everything else works!
// - Clipping coordinates are provided in imgui coordinates space (from draw_data->DisplayPos to draw_data->DisplayPos + draw_data->DisplaySize)
// In a single viewport application, draw_data->DisplayPos will always be (0,0) and draw_data->DisplaySize will always be == io.DisplaySize.
// However, in the interest of supporting multi-viewport applications in the future (see 'viewport' branch on github),
// always subtract draw_data->DisplayPos from clipping bounds to convert them to your viewport space.
// - Note that pcmd->ClipRect contains Min+Max bounds. Some graphics API may use Min+Max, other may use Min+Size (size being Max-Min)
ImVec2 pos = draw_data->DisplayPos;
MyEngineScissor((int)(pcmd->ClipRect.x - pos.x), (int)(pcmd->ClipRect.y - pos.y), (int)(pcmd->ClipRect.z - pos.x), (int)(pcmd->ClipRect.w - pos.y));
// Render 'pcmd->ElemCount/3' indexed triangles.
// By default the indices ImDrawIdx are 16-bits, you can change them to 32-bits in imconfig.h if your engine doesn't support 16-bits indices.
MyEngineDrawIndexedTriangles(pcmd->ElemCount, sizeof(ImDrawIdx) == 2 ? GL_UNSIGNED_SHORT : GL_UNSIGNED_INT, idx_buffer, vtx_buffer);
}
idx_buffer += pcmd->ElemCount;
}
}
}
- The examples/ folders contains many actual implementation of the pseudo-codes above.
- When calling NewFrame(), the 'io.WantCaptureMouse', 'io.WantCaptureKeyboard' and 'io.WantTextInput' flags are updated.
They tell you if Dear ImGui intends to use your inputs. When a flag is set you want to hide the corresponding inputs from the
rest of your application. In every cases you need to pass on the inputs to Dear ImGui. Refer to the FAQ for more information.
- Please read the FAQ below!. Amusingly, it is called a FAQ because people frequently run into the same issues!
USING GAMEPAD/KEYBOARD NAVIGATION CONTROLS
- The gamepad/keyboard navigation is fairly functional and keeps being improved.
- Gamepad support is particularly useful to use dear imgui on a console system (e.g. PS4, Switch, XB1) without a mouse!
- You can ask questions and report issues at https://github.com/ocornut/imgui/issues/787
- The initial focus was to support game controllers, but keyboard is becoming increasingly and decently usable.
- Gamepad:
- Set io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad to enable.
- Backend: Set io.BackendFlags |= ImGuiBackendFlags_HasGamepad + fill the io.NavInputs[] fields before calling NewFrame().
Note that io.NavInputs[] is cleared by EndFrame().
- See 'enum ImGuiNavInput_' in imgui.h for a description of inputs. For each entry of io.NavInputs[], set the following values:
0.0f= not held. 1.0f= fully held. Pass intermediate 0.0f..1.0f values for analog triggers/sticks.
- We uses a simple >0.0f test for activation testing, and won't attempt to test for a dead-zone.
Your code will probably need to transform your raw inputs (such as e.g. remapping your 0.2..0.9 raw input range to 0.0..1.0 imgui range, etc.).
- You can download PNG/PSD files depicting the gamepad controls for common controllers at: http://goo.gl/9LgVZW.
- If you need to share inputs between your game and the imgui parts, the easiest approach is to go all-or-nothing, with a buttons combo
to toggle the target. Please reach out if you think the game vs navigation input sharing could be improved.
- Keyboard:
- Set io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard to enable.
NewFrame() will automatically fill io.NavInputs[] based on your io.KeysDown[] + io.KeyMap[] arrays.
- When keyboard navigation is active (io.NavActive + ImGuiConfigFlags_NavEnableKeyboard), the io.WantCaptureKeyboard flag
will be set. For more advanced uses, you may want to read from:
- io.NavActive: true when a window is focused and it doesn't have the ImGuiWindowFlags_NoNavInputs flag set.
- io.NavVisible: true when the navigation cursor is visible (and usually goes false when mouse is used).
- or query focus information with e.g. IsWindowFocused(ImGuiFocusedFlags_AnyWindow), IsItemFocused() etc. functions.
Please reach out if you think the game vs navigation input sharing could be improved.
- Mouse:
- PS4 users: Consider emulating a mouse cursor with DualShock4 touch pad or a spare analog stick as a mouse-emulation fallback.
- Consoles/Tablet/Phone users: Consider using a Synergy 1.x server (on your PC) + uSynergy.c (on your console/tablet/phone app) to share your PC mouse/keyboard.
- On a TV/console system where readability may be lower or mouse inputs may be awkward, you may want to set the ImGuiConfigFlags_NavEnableSetMousePos flag.
Enabling ImGuiConfigFlags_NavEnableSetMousePos + ImGuiBackendFlags_HasSetMousePos instructs dear imgui to move your mouse cursor along with navigation movements.
When enabled, the NewFrame() function may alter 'io.MousePos' and set 'io.WantSetMousePos' to notify you that it wants the mouse cursor to be moved.
When that happens your back-end NEEDS to move the OS or underlying mouse cursor on the next frame. Some of the binding in examples/ do that.
(If you set the NavEnableSetMousePos flag but don't honor 'io.WantSetMousePos' properly, imgui will misbehave as it will see your mouse as moving back and forth!)
(In a setup when you may not have easy control over the mouse cursor, e.g. uSynergy.c doesn't expose moving remote mouse cursor, you may want
to set a boolean to ignore your other external mouse positions until the external source is moved again.)
API BREAKING CHANGES
====================
Occasionally introducing changes that are breaking the API. We try to make the breakage minor and easy to fix.
Below is a change-log of API breaking changes only. If you are using one of the functions listed, expect to have to fix some code.
When you are not sure about a old symbol or function name, try using the Search/Find function of your IDE to look for comments or references in all imgui files.
You can read releases logs https://github.com/ocornut/imgui/releases for more details.
(Docking/Viewport Branch)
- 2019/XX/XX (1.XX) - when multi-viewports are enabled, all positions will be in your natural OS coordinates space. It means that:
- reference to hard-coded positions such as in SetNextWindowPos(ImVec2(0,0)) are probably not what you want anymore.
you may use GetMainViewport()->Pos to offset hard-coded positions, e.g. SetNextWindowPos(GetMainViewport()->Pos)
- likewise io.MousePos and GetMousePos() will use OS coordinates.
If you query mouse positions to interact with non-imgui coordinates you will need to offset them, e.g. subtract GetWindowViewport()->Pos.
- 2019/XX/XX (1.XX) - Moved IME support functions from io.ImeSetInputScreenPosFn, io.ImeWindowHandle to the PlatformIO api.
- 2019/07/15 (1.72) - removed TreeAdvanceToLabelPos() which is rarely used and only does SetCursorPosX(GetCursorPosX() + GetTreeNodeToLabelSpacing()). Kept redirection function (will obsolete).
- 2019/07/12 (1.72) - renamed ImFontAtlas::CustomRect to ImFontAtlasCustomRect. Kept redirection typedef (will obsolete).
- 2019/06/14 (1.72) - removed redirecting functions/enums names that were marked obsolete in 1.51 (June 2017): ImGuiCol_Column*, ImGuiSetCond_*, IsItemHoveredRect(), IsPosHoveringAnyWindow(), IsMouseHoveringAnyWindow(), IsMouseHoveringWindow(), IMGUI_ONCE_UPON_A_FRAME. Grep this log for details and new names.
- 2019/06/07 (1.71) - rendering of child window outer decorations (bg color, border, scrollbars) is now performed as part of the parent window. If you have
overlapping child windows in a same parent, and relied on their relative z-order to be mapped to their submission order, this will affect your rendering.
This optimization is disabled if the parent window has no visual output, because it appears to be the most common situation leading to the creation of overlapping child windows.
Please reach out if you are affected.
- 2019/05/13 (1.71) - renamed SetNextTreeNodeOpen() to SetNextItemOpen(). Kept inline redirection function (will obsolete).
- 2019/05/11 (1.71) - changed io.AddInputCharacter(unsigned short c) signature to io.AddInputCharacter(unsigned int c).
- 2019/04/29 (1.70) - improved ImDrawList thick strokes (>1.0f) preserving correct thickness up to 90 degrees angles (e.g. rectangles). If you have custom rendering using thick lines, they will appear thicker now.
- 2019/04/29 (1.70) - removed GetContentRegionAvailWidth(), use GetContentRegionAvail().x instead. Kept inline redirection function (will obsolete).
- 2019/03/04 (1.69) - renamed GetOverlayDrawList() to GetForegroundDrawList(). Kept redirection function (will obsolete).
- 2019/02/26 (1.69) - renamed ImGuiColorEditFlags_RGB/ImGuiColorEditFlags_HSV/ImGuiColorEditFlags_HEX to ImGuiColorEditFlags_DisplayRGB/ImGuiColorEditFlags_DisplayHSV/ImGuiColorEditFlags_DisplayHex. Kept redirection enums (will obsolete).
- 2019/02/14 (1.68) - made it illegal/assert when io.DisplayTime == 0.0f (with an exception for the first frame). If for some reason your time step calculation gives you a zero value, replace it with a dummy small value!
- 2019/02/01 (1.68) - removed io.DisplayVisibleMin/DisplayVisibleMax (which were marked obsolete and removed from viewport/docking branch already).
- 2019/01/06 (1.67) - renamed io.InputCharacters[], marked internal as was always intended. Please don't access directly, and use AddInputCharacter() instead!
- 2019/01/06 (1.67) - renamed ImFontAtlas::GlyphRangesBuilder to ImFontGlyphRangesBuilder. Kept redirection typedef (will obsolete).
- 2018/12/20 (1.67) - made it illegal to call Begin("") with an empty string. This somehow half-worked before but had various undesirable side-effects.
- 2018/12/10 (1.67) - renamed io.ConfigResizeWindowsFromEdges to io.ConfigWindowsResizeFromEdges as we are doing a large pass on configuration flags.
- 2018/10/12 (1.66) - renamed misc/stl/imgui_stl.* to misc/cpp/imgui_stdlib.* in prevision for other C++ helper files.
- 2018/09/28 (1.66) - renamed SetScrollHere() to SetScrollHereY(). Kept redirection function (will obsolete).
- 2018/09/06 (1.65) - renamed stb_truetype.h to imstb_truetype.h, stb_textedit.h to imstb_textedit.h, and stb_rect_pack.h to imstb_rectpack.h.
If you were conveniently using the imgui copy of those STB headers in your project you will have to update your include paths.
- 2018/09/05 (1.65) - renamed io.OptCursorBlink/io.ConfigCursorBlink to io.ConfigInputTextCursorBlink. (#1427)
- 2018/08/31 (1.64) - added imgui_widgets.cpp file, extracted and moved widgets code out of imgui.cpp into imgui_widgets.cpp. Re-ordered some of the code remaining in imgui.cpp.
NONE OF THE FUNCTIONS HAVE CHANGED. THE CODE IS SEMANTICALLY 100% IDENTICAL, BUT _EVERY_ FUNCTION HAS BEEN MOVED.
Because of this, any local modifications to imgui.cpp will likely conflict when you update. Read docs/CHANGELOG.txt for suggestions.
- 2018/08/22 (1.63) - renamed IsItemDeactivatedAfterChange() to IsItemDeactivatedAfterEdit() for consistency with new IsItemEdited() API. Kept redirection function (will obsolete soonish as IsItemDeactivatedAfterChange() is very recent).
- 2018/08/21 (1.63) - renamed ImGuiTextEditCallback to ImGuiInputTextCallback, ImGuiTextEditCallbackData to ImGuiInputTextCallbackData for consistency. Kept redirection types (will obsolete).
- 2018/08/21 (1.63) - removed ImGuiInputTextCallbackData::ReadOnly since it is a duplication of (ImGuiInputTextCallbackData::Flags & ImGuiInputTextFlags_ReadOnly).
- 2018/08/01 (1.63) - removed per-window ImGuiWindowFlags_ResizeFromAnySide beta flag in favor of a global io.ConfigResizeWindowsFromEdges [update 1.67 renamed to ConfigWindowsResizeFromEdges] to enable the feature.
- 2018/08/01 (1.63) - renamed io.OptCursorBlink to io.ConfigCursorBlink [-> io.ConfigInputTextCursorBlink in 1.65], io.OptMacOSXBehaviors to ConfigMacOSXBehaviors for consistency.
- 2018/07/22 (1.63) - changed ImGui::GetTime() return value from float to double to avoid accumulating floating point imprecisions over time.
- 2018/07/08 (1.63) - style: renamed ImGuiCol_ModalWindowDarkening to ImGuiCol_ModalWindowDimBg for consistency with other features. Kept redirection enum (will obsolete).
- 2018/06/08 (1.62) - examples: the imgui_impl_xxx files have been split to separate platform (Win32, Glfw, SDL2, etc.) from renderer (DX11, OpenGL, Vulkan, etc.).
old bindings will still work as is, however prefer using the separated bindings as they will be updated to support multi-viewports.
when adopting new bindings follow the main.cpp code of your preferred examples/ folder to know which functions to call.
in particular, note that old bindings called ImGui::NewFrame() at the end of their ImGui_ImplXXXX_NewFrame() function.
- 2018/06/06 (1.62) - renamed GetGlyphRangesChinese() to GetGlyphRangesChineseFull() to distinguish other variants and discourage using the full set.
- 2018/06/06 (1.62) - TreeNodeEx()/TreeNodeBehavior(): the ImGuiTreeNodeFlags_CollapsingHeader helper now include the ImGuiTreeNodeFlags_NoTreePushOnOpen flag. See Changelog for details.
- 2018/05/03 (1.61) - DragInt(): the default compile-time format string has been changed from "%.0f" to "%d", as we are not using integers internally any more.
If you used DragInt() with custom format strings, make sure you change them to use %d or an integer-compatible format.
To honor backward-compatibility, the DragInt() code will currently parse and modify format strings to replace %*f with %d, giving time to users to upgrade their code.
If you have IMGUI_DISABLE_OBSOLETE_FUNCTIONS enabled, the code will instead assert! You may run a reg-exp search on your codebase for e.g. "DragInt.*%f" to help you find them.
- 2018/04/28 (1.61) - obsoleted InputFloat() functions taking an optional "int decimal_precision" in favor of an equivalent and more flexible "const char* format",
consistent with other functions. Kept redirection functions (will obsolete).
- 2018/04/09 (1.61) - IM_DELETE() helper function added in 1.60 doesn't clear the input _pointer_ reference, more consistent with expectation and allows passing r-value.
- 2018/03/20 (1.60) - renamed io.WantMoveMouse to io.WantSetMousePos for consistency and ease of understanding (was added in 1.52, _not_ used by core and only honored by some binding ahead of merging the Nav branch).
- 2018/03/12 (1.60) - removed ImGuiCol_CloseButton, ImGuiCol_CloseButtonActive, ImGuiCol_CloseButtonHovered as the closing cross uses regular button colors now.
- 2018/03/08 (1.60) - changed ImFont::DisplayOffset.y to default to 0 instead of +1. Fixed rounding of Ascent/Descent to match TrueType renderer. If you were adding or subtracting to ImFont::DisplayOffset check if your fonts are correctly aligned vertically.
- 2018/03/03 (1.60) - renamed ImGuiStyleVar_Count_ to ImGuiStyleVar_COUNT and ImGuiMouseCursor_Count_ to ImGuiMouseCursor_COUNT for consistency with other public enums.
- 2018/02/18 (1.60) - BeginDragDropSource(): temporarily removed the optional mouse_button=0 parameter because it is not really usable in many situations at the moment.
- 2018/02/16 (1.60) - obsoleted the io.RenderDrawListsFn callback, you can call your graphics engine render function after ImGui::Render(). Use ImGui::GetDrawData() to retrieve the ImDrawData* to display.
- 2018/02/07 (1.60) - reorganized context handling to be more explicit,
- YOU NOW NEED TO CALL ImGui::CreateContext() AT THE BEGINNING OF YOUR APP, AND CALL ImGui::DestroyContext() AT THE END.
- removed Shutdown() function, as DestroyContext() serve this purpose.
- you may pass a ImFontAtlas* pointer to CreateContext() to share a font atlas between contexts. Otherwise CreateContext() will create its own font atlas instance.
- removed allocator parameters from CreateContext(), they are now setup with SetAllocatorFunctions(), and shared by all contexts.
- removed the default global context and font atlas instance, which were confusing for users of DLL reloading and users of multiple contexts.
- 2018/01/31 (1.60) - moved sample TTF files from extra_fonts/ to misc/fonts/. If you loaded files directly from the imgui repo you may need to update your paths.
- 2018/01/11 (1.60) - obsoleted IsAnyWindowHovered() in favor of IsWindowHovered(ImGuiHoveredFlags_AnyWindow). Kept redirection function (will obsolete).
- 2018/01/11 (1.60) - obsoleted IsAnyWindowFocused() in favor of IsWindowFocused(ImGuiFocusedFlags_AnyWindow). Kept redirection function (will obsolete).
- 2018/01/03 (1.60) - renamed ImGuiSizeConstraintCallback to ImGuiSizeCallback, ImGuiSizeConstraintCallbackData to ImGuiSizeCallbackData.
- 2017/12/29 (1.60) - removed CalcItemRectClosestPoint() which was weird and not really used by anyone except demo code. If you need it it's easy to replicate on your side.
- 2017/12/24 (1.53) - renamed the emblematic ShowTestWindow() function to ShowDemoWindow(). Kept redirection function (will obsolete).
- 2017/12/21 (1.53) - ImDrawList: renamed style.AntiAliasedShapes to style.AntiAliasedFill for consistency and as a way to explicitly break code that manipulate those flag at runtime. You can now manipulate ImDrawList::Flags
- 2017/12/21 (1.53) - ImDrawList: removed 'bool anti_aliased = true' final parameter of ImDrawList::AddPolyline() and ImDrawList::AddConvexPolyFilled(). Prefer manipulating ImDrawList::Flags if you need to toggle them during the frame.
- 2017/12/14 (1.53) - using the ImGuiWindowFlags_NoScrollWithMouse flag on a child window forwards the mouse wheel event to the parent window, unless either ImGuiWindowFlags_NoInputs or ImGuiWindowFlags_NoScrollbar are also set.
- 2017/12/13 (1.53) - renamed GetItemsLineHeightWithSpacing() to GetFrameHeightWithSpacing(). Kept redirection function (will obsolete).
- 2017/12/13 (1.53) - obsoleted IsRootWindowFocused() in favor of using IsWindowFocused(ImGuiFocusedFlags_RootWindow). Kept redirection function (will obsolete).
- obsoleted IsRootWindowOrAnyChildFocused() in favor of using IsWindowFocused(ImGuiFocusedFlags_RootAndChildWindows). Kept redirection function (will obsolete).
- 2017/12/12 (1.53) - renamed ImGuiTreeNodeFlags_AllowOverlapMode to ImGuiTreeNodeFlags_AllowItemOverlap. Kept redirection enum (will obsolete).
- 2017/12/10 (1.53) - removed SetNextWindowContentWidth(), prefer using SetNextWindowContentSize(). Kept redirection function (will obsolete).
- 2017/11/27 (1.53) - renamed ImGuiTextBuffer::append() helper to appendf(), appendv() to appendfv(). If you copied the 'Log' demo in your code, it uses appendv() so that needs to be renamed.
- 2017/11/18 (1.53) - Style, Begin: removed ImGuiWindowFlags_ShowBorders window flag. Borders are now fully set up in the ImGuiStyle structure (see e.g. style.FrameBorderSize, style.WindowBorderSize). Use ImGui::ShowStyleEditor() to look them up.
Please note that the style system will keep evolving (hopefully stabilizing in Q1 2018), and so custom styles will probably subtly break over time. It is recommended you use the StyleColorsClassic(), StyleColorsDark(), StyleColorsLight() functions.
- 2017/11/18 (1.53) - Style: removed ImGuiCol_ComboBg in favor of combo boxes using ImGuiCol_PopupBg for consistency.
- 2017/11/18 (1.53) - Style: renamed ImGuiCol_ChildWindowBg to ImGuiCol_ChildBg.
- 2017/11/18 (1.53) - Style: renamed style.ChildWindowRounding to style.ChildRounding, ImGuiStyleVar_ChildWindowRounding to ImGuiStyleVar_ChildRounding.
- 2017/11/02 (1.53) - obsoleted IsRootWindowOrAnyChildHovered() in favor of using IsWindowHovered(ImGuiHoveredFlags_RootAndChildWindows);
- 2017/10/24 (1.52) - renamed IMGUI_DISABLE_WIN32_DEFAULT_CLIPBOARD_FUNCS/IMGUI_DISABLE_WIN32_DEFAULT_IME_FUNCS to IMGUI_DISABLE_WIN32_DEFAULT_CLIPBOARD_FUNCTIONS/IMGUI_DISABLE_WIN32_DEFAULT_IME_FUNCTIONS for consistency.
- 2017/10/20 (1.52) - changed IsWindowHovered() default parameters behavior to return false if an item is active in another window (e.g. click-dragging item from another window to this window). You can use the newly introduced IsWindowHovered() flags to requests this specific behavior if you need it.
- 2017/10/20 (1.52) - marked IsItemHoveredRect()/IsMouseHoveringWindow() as obsolete, in favor of using the newly introduced flags for IsItemHovered() and IsWindowHovered(). See https://github.com/ocornut/imgui/issues/1382 for details.
removed the IsItemRectHovered()/IsWindowRectHovered() names introduced in 1.51 since they were merely more consistent names for the two functions we are now obsoleting.
IsItemHoveredRect() --> IsItemHovered(ImGuiHoveredFlags_RectOnly)
IsMouseHoveringAnyWindow() --> IsWindowHovered(ImGuiHoveredFlags_AnyWindow)
IsMouseHoveringWindow() --> IsWindowHovered(ImGuiHoveredFlags_AllowWhenBlockedByPopup | ImGuiHoveredFlags_AllowWhenBlockedByActiveItem) [weird, old behavior]
- 2017/10/17 (1.52) - marked the old 5-parameters version of Begin() as obsolete (still available). Use SetNextWindowSize()+Begin() instead!
- 2017/10/11 (1.52) - renamed AlignFirstTextHeightToWidgets() to AlignTextToFramePadding(). Kept inline redirection function (will obsolete).
- 2017/09/26 (1.52) - renamed ImFont::Glyph to ImFontGlyph. Kept redirection typedef (will obsolete).
- 2017/09/25 (1.52) - removed SetNextWindowPosCenter() because SetNextWindowPos() now has the optional pivot information to do the same and more. Kept redirection function (will obsolete).
- 2017/08/25 (1.52) - io.MousePos needs to be set to ImVec2(-FLT_MAX,-FLT_MAX) when mouse is unavailable/missing. Previously ImVec2(-1,-1) was enough but we now accept negative mouse coordinates. In your binding if you need to support unavailable mouse, make sure to replace "io.MousePos = ImVec2(-1,-1)" with "io.MousePos = ImVec2(-FLT_MAX,-FLT_MAX)".
- 2017/08/22 (1.51) - renamed IsItemHoveredRect() to IsItemRectHovered(). Kept inline redirection function (will obsolete). -> (1.52) use IsItemHovered(ImGuiHoveredFlags_RectOnly)!
- renamed IsMouseHoveringAnyWindow() to IsAnyWindowHovered() for consistency. Kept inline redirection function (will obsolete).
- renamed IsMouseHoveringWindow() to IsWindowRectHovered() for consistency. Kept inline redirection function (will obsolete).
- 2017/08/20 (1.51) - renamed GetStyleColName() to GetStyleColorName() for consistency.
- 2017/08/20 (1.51) - added PushStyleColor(ImGuiCol idx, ImU32 col) overload, which _might_ cause an "ambiguous call" compilation error if you are using ImColor() with implicit cast. Cast to ImU32 or ImVec4 explicily to fix.
- 2017/08/15 (1.51) - marked the weird IMGUI_ONCE_UPON_A_FRAME helper macro as obsolete. prefer using the more explicit ImGuiOnceUponAFrame type.
- 2017/08/15 (1.51) - changed parameter order for BeginPopupContextWindow() from (const char*,int buttons,bool also_over_items) to (const char*,int buttons,bool also_over_items). Note that most calls relied on default parameters completely.
- 2017/08/13 (1.51) - renamed ImGuiCol_Column to ImGuiCol_Separator, ImGuiCol_ColumnHovered to ImGuiCol_SeparatorHovered, ImGuiCol_ColumnActive to ImGuiCol_SeparatorActive. Kept redirection enums (will obsolete).
- 2017/08/11 (1.51) - renamed ImGuiSetCond_Always to ImGuiCond_Always, ImGuiSetCond_Once to ImGuiCond_Once, ImGuiSetCond_FirstUseEver to ImGuiCond_FirstUseEver, ImGuiSetCond_Appearing to ImGuiCond_Appearing. Kept redirection enums (will obsolete).
- 2017/08/09 (1.51) - removed ValueColor() helpers, they are equivalent to calling Text(label) + SameLine() + ColorButton().
- 2017/08/08 (1.51) - removed ColorEditMode() and ImGuiColorEditMode in favor of ImGuiColorEditFlags and parameters to the various Color*() functions. The SetColorEditOptions() allows to initialize default but the user can still change them with right-click context menu.
- changed prototype of 'ColorEdit4(const char* label, float col[4], bool show_alpha = true)' to 'ColorEdit4(const char* label, float col[4], ImGuiColorEditFlags flags = 0)', where passing flags = 0x01 is a safe no-op (hello dodgy backward compatibility!). - check and run the demo window, under "Color/Picker Widgets", to understand the various new options.
- changed prototype of rarely used 'ColorButton(ImVec4 col, bool small_height = false, bool outline_border = true)' to 'ColorButton(const char* desc_id, ImVec4 col, ImGuiColorEditFlags flags = 0, ImVec2 size = ImVec2(0,0))'
- 2017/07/20 (1.51) - removed IsPosHoveringAnyWindow(ImVec2), which was partly broken and misleading. ASSERT + redirect user to io.WantCaptureMouse
- 2017/05/26 (1.50) - removed ImFontConfig::MergeGlyphCenterV in favor of a more multipurpose ImFontConfig::GlyphOffset.
- 2017/05/01 (1.50) - renamed ImDrawList::PathFill() (rarely used directly) to ImDrawList::PathFillConvex() for clarity.
- 2016/11/06 (1.50) - BeginChild(const char*) now applies the stack id to the provided label, consistently with other functions as it should always have been. It shouldn't affect you unless (extremely unlikely) you were appending multiple times to a same child from different locations of the stack id. If that's the case, generate an id with GetId() and use it instead of passing string to BeginChild().
- 2016/10/15 (1.50) - avoid 'void* user_data' parameter to io.SetClipboardTextFn/io.GetClipboardTextFn pointers. We pass io.ClipboardUserData to it.
- 2016/09/25 (1.50) - style.WindowTitleAlign is now a ImVec2 (ImGuiAlign enum was removed). set to (0.5f,0.5f) for horizontal+vertical centering, (0.0f,0.0f) for upper-left, etc.
- 2016/07/30 (1.50) - SameLine(x) with x>0.0f is now relative to left of column/group if any, and not always to left of window. This was sort of always the intent and hopefully breakage should be minimal.
- 2016/05/12 (1.49) - title bar (using ImGuiCol_TitleBg/ImGuiCol_TitleBgActive colors) isn't rendered over a window background (ImGuiCol_WindowBg color) anymore.
If your TitleBg/TitleBgActive alpha was 1.0f or you are using the default theme it will not affect you.
If your TitleBg/TitleBgActive alpha was <1.0f you need to tweak your custom theme to readjust for the fact that we don't draw a WindowBg background behind the title bar.
This helper function will convert an old TitleBg/TitleBgActive color into a new one with the same visual output, given the OLD color and the OLD WindowBg color.
ImVec4 ConvertTitleBgCol(const ImVec4& win_bg_col, const ImVec4& title_bg_col)
{
float new_a = 1.0f - ((1.0f - win_bg_col.w) * (1.0f - title_bg_col.w)), k = title_bg_col.w / new_a;
return ImVec4((win_bg_col.x * win_bg_col.w + title_bg_col.x) * k, (win_bg_col.y * win_bg_col.w + title_bg_col.y) * k, (win_bg_col.z * win_bg_col.w + title_bg_col.z) * k, new_a);
}
If this is confusing, pick the RGB value from title bar from an old screenshot and apply this as TitleBg/TitleBgActive. Or you may just create TitleBgActive from a tweaked TitleBg color.
- 2016/05/07 (1.49) - removed confusing set of GetInternalState(), GetInternalStateSize(), SetInternalState() functions. Now using CreateContext(), DestroyContext(), GetCurrentContext(), SetCurrentContext().
- 2016/05/02 (1.49) - renamed SetNextTreeNodeOpened() to SetNextTreeNodeOpen(), no redirection.
- 2016/05/01 (1.49) - obsoleted old signature of CollapsingHeader(const char* label, const char* str_id = NULL, bool display_frame = true, bool default_open = false) as extra parameters were badly designed and rarely used. You can replace the "default_open = true" flag in new API with CollapsingHeader(label, ImGuiTreeNodeFlags_DefaultOpen).
- 2016/04/26 (1.49) - changed ImDrawList::PushClipRect(ImVec4 rect) to ImDrawList::PushClipRect(Imvec2 min,ImVec2 max,bool intersect_with_current_clip_rect=false). Note that higher-level ImGui::PushClipRect() is preferable because it will clip at logic/widget level, whereas ImDrawList::PushClipRect() only affect your renderer.
- 2016/04/03 (1.48) - removed style.WindowFillAlphaDefault setting which was redundant. Bake default BG alpha inside style.Colors[ImGuiCol_WindowBg] and all other Bg color values. (ref github issue #337).
- 2016/04/03 (1.48) - renamed ImGuiCol_TooltipBg to ImGuiCol_PopupBg, used by popups/menus and tooltips. popups/menus were previously using ImGuiCol_WindowBg. (ref github issue #337)
- 2016/03/21 (1.48) - renamed GetWindowFont() to GetFont(), GetWindowFontSize() to GetFontSize(). Kept inline redirection function (will obsolete).
- 2016/03/02 (1.48) - InputText() completion/history/always callbacks: if you modify the text buffer manually (without using DeleteChars()/InsertChars() helper) you need to maintain the BufTextLen field. added an assert.
- 2016/01/23 (1.48) - fixed not honoring exact width passed to PushItemWidth(), previously it would add extra FramePadding.x*2 over that width. if you had manual pixel-perfect alignment in place it might affect you.
- 2015/12/27 (1.48) - fixed ImDrawList::AddRect() which used to render a rectangle 1 px too large on each axis.
- 2015/12/04 (1.47) - renamed Color() helpers to ValueColor() - dangerously named, rarely used and probably to be made obsolete.
- 2015/08/29 (1.45) - with the addition of horizontal scrollbar we made various fixes to inconsistencies with dealing with cursor position.
GetCursorPos()/SetCursorPos() functions now include the scrolled amount. It shouldn't affect the majority of users, but take note that SetCursorPosX(100.0f) puts you at +100 from the starting x position which may include scrolling, not at +100 from the window left side.
GetContentRegionMax()/GetWindowContentRegionMin()/GetWindowContentRegionMax() functions allow include the scrolled amount. Typically those were used in cases where no scrolling would happen so it may not be a problem, but watch out!
- 2015/08/29 (1.45) - renamed style.ScrollbarWidth to style.ScrollbarSize
- 2015/08/05 (1.44) - split imgui.cpp into extra files: imgui_demo.cpp imgui_draw.cpp imgui_internal.h that you need to add to your project.
- 2015/07/18 (1.44) - fixed angles in ImDrawList::PathArcTo(), PathArcToFast() (introduced in 1.43) being off by an extra PI for no justifiable reason
- 2015/07/14 (1.43) - add new ImFontAtlas::AddFont() API. For the old AddFont***, moved the 'font_no' parameter of ImFontAtlas::AddFont** functions to the ImFontConfig structure.
you need to render your textured triangles with bilinear filtering to benefit from sub-pixel positioning of text.
- 2015/07/08 (1.43) - switched rendering data to use indexed rendering. this is saving a fair amount of CPU/GPU and enables us to get anti-aliasing for a marginal cost.
this necessary change will break your rendering function! the fix should be very easy. sorry for that :(
- if you are using a vanilla copy of one of the imgui_impl_XXXX.cpp provided in the example, you just need to update your copy and you can ignore the rest.
- the signature of the io.RenderDrawListsFn handler has changed!
old: ImGui_XXXX_RenderDrawLists(ImDrawList** const cmd_lists, int cmd_lists_count)
new: ImGui_XXXX_RenderDrawLists(ImDrawData* draw_data).
parameters: 'cmd_lists' becomes 'draw_data->CmdLists', 'cmd_lists_count' becomes 'draw_data->CmdListsCount'
ImDrawList: 'commands' becomes 'CmdBuffer', 'vtx_buffer' becomes 'VtxBuffer', 'IdxBuffer' is new.
ImDrawCmd: 'vtx_count' becomes 'ElemCount', 'clip_rect' becomes 'ClipRect', 'user_callback' becomes 'UserCallback', 'texture_id' becomes 'TextureId'.
- each ImDrawList now contains both a vertex buffer and an index buffer. For each command, render ElemCount/3 triangles using indices from the index buffer.
- if you REALLY cannot render indexed primitives, you can call the draw_data->DeIndexAllBuffers() method to de-index the buffers. This is slow and a waste of CPU/GPU. Prefer using indexed rendering!
- refer to code in the examples/ folder or ask on the GitHub if you are unsure of how to upgrade. please upgrade!
- 2015/07/10 (1.43) - changed SameLine() parameters from int to float.
- 2015/07/02 (1.42) - renamed SetScrollPosHere() to SetScrollFromCursorPos(). Kept inline redirection function (will obsolete).
- 2015/07/02 (1.42) - renamed GetScrollPosY() to GetScrollY(). Necessary to reduce confusion along with other scrolling functions, because positions (e.g. cursor position) are not equivalent to scrolling amount.
- 2015/06/14 (1.41) - changed ImageButton() default bg_col parameter from (0,0,0,1) (black) to (0,0,0,0) (transparent) - makes a difference when texture have transparence
- 2015/06/14 (1.41) - changed Selectable() API from (label, selected, size) to (label, selected, flags, size). Size override should have been rarely be used. Sorry!
- 2015/05/31 (1.40) - renamed GetWindowCollapsed() to IsWindowCollapsed() for consistency. Kept inline redirection function (will obsolete).
- 2015/05/31 (1.40) - renamed IsRectClipped() to IsRectVisible() for consistency. Note that return value is opposite! Kept inline redirection function (will obsolete).
- 2015/05/27 (1.40) - removed the third 'repeat_if_held' parameter from Button() - sorry! it was rarely used and inconsistent. Use PushButtonRepeat(true) / PopButtonRepeat() to enable repeat on desired buttons.
- 2015/05/11 (1.40) - changed BeginPopup() API, takes a string identifier instead of a bool. ImGui needs to manage the open/closed state of popups. Call OpenPopup() to actually set the "open" state of a popup. BeginPopup() returns true if the popup is opened.
- 2015/05/03 (1.40) - removed style.AutoFitPadding, using style.WindowPadding makes more sense (the default values were already the same).
- 2015/04/13 (1.38) - renamed IsClipped() to IsRectClipped(). Kept inline redirection function until 1.50.
- 2015/04/09 (1.38) - renamed ImDrawList::AddArc() to ImDrawList::AddArcFast() for compatibility with future API
- 2015/04/03 (1.38) - removed ImGuiCol_CheckHovered, ImGuiCol_CheckActive, replaced with the more general ImGuiCol_FrameBgHovered, ImGuiCol_FrameBgActive.
- 2014/04/03 (1.38) - removed support for passing -FLT_MAX..+FLT_MAX as the range for a SliderFloat(). Use DragFloat() or Inputfloat() instead.
- 2015/03/17 (1.36) - renamed GetItemBoxMin()/GetItemBoxMax()/IsMouseHoveringBox() to GetItemRectMin()/GetItemRectMax()/IsMouseHoveringRect(). Kept inline redirection function until 1.50.
- 2015/03/15 (1.36) - renamed style.TreeNodeSpacing to style.IndentSpacing, ImGuiStyleVar_TreeNodeSpacing to ImGuiStyleVar_IndentSpacing
- 2015/03/13 (1.36) - renamed GetWindowIsFocused() to IsWindowFocused(). Kept inline redirection function until 1.50.
- 2015/03/08 (1.35) - renamed style.ScrollBarWidth to style.ScrollbarWidth (casing)
- 2015/02/27 (1.34) - renamed OpenNextNode(bool) to SetNextTreeNodeOpened(bool, ImGuiSetCond). Kept inline redirection function until 1.50.
- 2015/02/27 (1.34) - renamed ImGuiSetCondition_*** to ImGuiSetCond_***, and _FirstUseThisSession becomes _Once.
- 2015/02/11 (1.32) - changed text input callback ImGuiTextEditCallback return type from void-->int. reserved for future use, return 0 for now.
- 2015/02/10 (1.32) - renamed GetItemWidth() to CalcItemWidth() to clarify its evolving behavior
- 2015/02/08 (1.31) - renamed GetTextLineSpacing() to GetTextLineHeightWithSpacing()
- 2015/02/01 (1.31) - removed IO.MemReallocFn (unused)
- 2015/01/19 (1.30) - renamed ImGuiStorage::GetIntPtr()/GetFloatPtr() to GetIntRef()/GetIntRef() because Ptr was conflicting with actual pointer storage functions.
- 2015/01/11 (1.30) - big font/image API change! now loads TTF file. allow for multiple fonts. no need for a PNG loader.
(1.30) - removed GetDefaultFontData(). uses io.Fonts->GetTextureData*() API to retrieve uncompressed pixels.
font init: { const void* png_data; unsigned int png_size; ImGui::GetDefaultFontData(NULL, NULL, &png_data, &png_size); <..Upload texture to GPU..>; }
became: { unsigned char* pixels; int width, height; io.Fonts->GetTexDataAsRGBA32(&pixels, &width, &height); <..Upload texture to GPU>; io.Fonts->TexId = YourTextureIdentifier; }
you now have more flexibility to load multiple TTF fonts and manage the texture buffer for internal needs.
it is now recommended that you sample the font texture with bilinear interpolation.
(1.30) - added texture identifier in ImDrawCmd passed to your render function (we can now render images). make sure to set io.Fonts->TexID.
(1.30) - removed IO.PixelCenterOffset (unnecessary, can be handled in user projection matrix)
(1.30) - removed ImGui::IsItemFocused() in favor of ImGui::IsItemActive() which handles all widgets
- 2014/12/10 (1.18) - removed SetNewWindowDefaultPos() in favor of new generic API SetNextWindowPos(pos, ImGuiSetCondition_FirstUseEver)
- 2014/11/28 (1.17) - moved IO.Font*** options to inside the IO.Font-> structure (FontYOffset, FontTexUvForWhite, FontBaseScale, FontFallbackGlyph)
- 2014/11/26 (1.17) - reworked syntax of IMGUI_ONCE_UPON_A_FRAME helper macro to increase compiler compatibility
- 2014/11/07 (1.15) - renamed IsHovered() to IsItemHovered()
- 2014/10/02 (1.14) - renamed IMGUI_INCLUDE_IMGUI_USER_CPP to IMGUI_INCLUDE_IMGUI_USER_INL and imgui_user.cpp to imgui_user.inl (more IDE friendly)
- 2014/09/25 (1.13) - removed 'text_end' parameter from IO.SetClipboardTextFn (the string is now always zero-terminated for simplicity)
- 2014/09/24 (1.12) - renamed SetFontScale() to SetWindowFontScale()
- 2014/09/24 (1.12) - moved IM_MALLOC/IM_REALLOC/IM_FREE preprocessor defines to IO.MemAllocFn/IO.MemReallocFn/IO.MemFreeFn
- 2014/08/30 (1.09) - removed IO.FontHeight (now computed automatically)
- 2014/08/30 (1.09) - moved IMGUI_FONT_TEX_UV_FOR_WHITE preprocessor define to IO.FontTexUvForWhite
- 2014/08/28 (1.09) - changed the behavior of IO.PixelCenterOffset following various rendering fixes
FREQUENTLY ASKED QUESTIONS (FAQ), TIPS
======================================
Q: Where is the documentation?
A: This library is poorly documented at the moment and expects of the user to be acquainted with C/C++.
- Run the examples/ and explore them.
- See demo code in imgui_demo.cpp and particularly the ImGui::ShowDemoWindow() function.
- The demo covers most features of Dear ImGui, so you can read the code and see its output.
- See documentation and comments at the top of imgui.cpp + effectively imgui.h.
- Dozens of standalone example applications using e.g. OpenGL/DirectX are provided in the examples/
folder to explain how to integrate Dear ImGui with your own engine/application.
- Your programming IDE is your friend, find the type or function declaration to find comments
associated to it.
Q: Which version should I get?
A: I occasionally tag Releases (https://github.com/ocornut/imgui/releases) but it is generally safe
and recommended to sync to master/latest. The library is fairly stable and regressions tend to be
fixed fast when reported. You may also peak at the 'docking' branch which includes:
- Docking/Merging features (https://github.com/ocornut/imgui/issues/2109)
- Multi-viewport features (https://github.com/ocornut/imgui/issues/1542)
Many projects are using this branch and it is kept in sync with master regularly.
Q: Who uses Dear ImGui?
A: See "Quotes" (https://github.com/ocornut/imgui/wiki/Quotes) and
"Software using Dear ImGui" (https://github.com/ocornut/imgui/wiki/Software-using-dear-imgui) Wiki pages
for a list of games/software which are publicly known to use dear imgui. Please add yours if you can!
Q: Why the odd dual naming, "Dear ImGui" vs "ImGui"?
A: The library started its life as "ImGui" due to the fact that I didn't give it a proper name when
when I released 1.0, and had no particular expectation that it would take off. However, the term IMGUI
(immediate-mode graphical user interface) was coined before and is being used in variety of other
situations (e.g. Unity uses it own implementation of the IMGUI paradigm).
To reduce the ambiguity without affecting existing code bases, I have decided on an alternate,
longer name "Dear ImGui" that people can use to refer to this specific library.
Please try to refer to this library as "Dear ImGui".
Q: How can I tell whether to dispatch mouse/keyboard to Dear ImGui or to my application?
A: You can read the 'io.WantCaptureMouse', 'io.WantCaptureKeyboard' and 'io.WantTextInput' flags from the ImGuiIO structure (e.g. if (ImGui::GetIO().WantCaptureMouse) { ... } )
- When 'io.WantCaptureMouse' is set, imgui wants to use your mouse state, and you may want to discard/hide the inputs from the rest of your application.
- When 'io.WantCaptureKeyboard' is set, imgui wants to use your keyboard state, and you may want to discard/hide the inputs from the rest of your application.
- When 'io.WantTextInput' is set to may want to notify your OS to popup an on-screen keyboard, if available (e.g. on a mobile phone, or console OS).
Note: you should always pass your mouse/keyboard inputs to imgui, even when the io.WantCaptureXXX flag are set false.
This is because imgui needs to detect that you clicked in the void to unfocus its own windows.
Note: The 'io.WantCaptureMouse' is more accurate that any attempt to "check if the mouse is hovering a window" (don't do that!).
It handle mouse dragging correctly (both dragging that started over your application or over an imgui window) and handle e.g. modal windows blocking inputs.
Those flags are updated by ImGui::NewFrame(). Preferably read the flags after calling NewFrame() if you can afford it, but reading them before is also
perfectly fine, as the bool toggle fairly rarely. If you have on a touch device, you might find use for an early call to UpdateHoveredWindowAndCaptureFlags().
Note: Text input widget releases focus on "Return KeyDown", so the subsequent "Return KeyUp" event that your application receive will typically
have 'io.WantCaptureKeyboard=false'. Depending on your application logic it may or not be inconvenient. You might want to track which key-downs
were targeted for Dear ImGui, e.g. with an array of bool, and filter out the corresponding key-ups.)
Q: How can I display an image? What is ImTextureID, how does it works?
A: Short explanation:
- You may use functions such as ImGui::Image(), ImGui::ImageButton() or lower-level ImDrawList::AddImage() to emit draw calls that will use your own textures.
- Actual textures are identified in a way that is up to the user/engine. Those identifiers are stored and passed as ImTextureID (void*) value.
- Loading image files from the disk and turning them into a texture is not within the scope of Dear ImGui (for a good reason).
Please read documentations or tutorials on your graphics API to understand how to display textures on the screen before moving onward.
Long explanation:
- Dear ImGui's job is to create "meshes", defined in a renderer-agnostic format made of draw commands and vertices.
At the end of the frame those meshes (ImDrawList) will be displayed by your rendering function. They are made up of textured polygons and the code
to render them is generally fairly short (a few dozen lines). In the examples/ folder we provide functions for popular graphics API (OpenGL, DirectX, etc.).
- Each rendering function decides on a data type to represent "textures". The concept of what is a "texture" is entirely tied to your underlying engine/graphics API.
We carry the information to identify a "texture" in the ImTextureID type.
ImTextureID is nothing more that a void*, aka 4/8 bytes worth of data: just enough to store 1 pointer or 1 integer of your choice.
Dear ImGui doesn't know or understand what you are storing in ImTextureID, it merely pass ImTextureID values until they reach your rendering function.
- In the examples/ bindings, for each graphics API binding we decided on a type that is likely to be a good representation for specifying
an image from the end-user perspective. This is what the _examples_ rendering functions are using:
OpenGL: ImTextureID = GLuint (see ImGui_ImplOpenGL3_RenderDrawData() function in imgui_impl_opengl3.cpp)
DirectX9: ImTextureID = LPDIRECT3DTEXTURE9 (see ImGui_ImplDX9_RenderDrawData() function in imgui_impl_dx9.cpp)
DirectX11: ImTextureID = ID3D11ShaderResourceView* (see ImGui_ImplDX11_RenderDrawData() function in imgui_impl_dx11.cpp)
DirectX12: ImTextureID = D3D12_GPU_DESCRIPTOR_HANDLE (see ImGui_ImplDX12_RenderDrawData() function in imgui_impl_dx12.cpp)
For example, in the OpenGL example binding we store raw OpenGL texture identifier (GLuint) inside ImTextureID.
Whereas in the DirectX11 example binding we store a pointer to ID3D11ShaderResourceView inside ImTextureID, which is a higher-level structure
tying together both the texture and information about its format and how to read it.
- If you have a custom engine built over e.g. OpenGL, instead of passing GLuint around you may decide to use a high-level data type to carry information about
the texture as well as how to display it (shaders, etc.). The decision of what to use as ImTextureID can always be made better knowing how your codebase
is designed. If your engine has high-level data types for "textures" and "material" then you may want to use them.
If you are starting with OpenGL or DirectX or Vulkan and haven't built much of a rendering engine over them, keeping the default ImTextureID
representation suggested by the example bindings is probably the best choice.
(Advanced users may also decide to keep a low-level type in ImTextureID, and use ImDrawList callback and pass information to their renderer)
User code may do:
// Cast our texture type to ImTextureID / void*
MyTexture* texture = g_CoffeeTableTexture;
ImGui::Image((void*)texture, ImVec2(texture->Width, texture->Height));
The renderer function called after ImGui::Render() will receive that same value that the user code passed:
// Cast ImTextureID / void* stored in the draw command as our texture type
MyTexture* texture = (MyTexture*)pcmd->TextureId;
MyEngineBindTexture2D(texture);
Once you understand this design you will understand that loading image files and turning them into displayable textures is not within the scope of Dear ImGui.
This is by design and is actually a good thing, because it means your code has full control over your data types and how you display them.
If you want to display an image file (e.g. PNG file) into the screen, please refer to documentation and tutorials for the graphics API you are using.
Here's a simplified OpenGL example using stb_image.h:
// Use stb_image.h to load a PNG from disk and turn it into raw RGBA pixel data:
#define STB_IMAGE_IMPLEMENTATION
#include <stb_image.h>
[...]
int my_image_width, my_image_height;
unsigned char* my_image_data = stbi_load("my_image.png", &my_image_width, &my_image_height, NULL, 4);
// Turn the RGBA pixel data into an OpenGL texture:
GLuint my_opengl_texture;
glGenTextures(1, &my_opengl_texture);
glBindTexture(GL_TEXTURE_2D, my_opengl_texture);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, image_width, image_height, 0, GL_RGBA, GL_UNSIGNED_BYTE, image_data);
// Now that we have an OpenGL texture, assuming our imgui rendering function (imgui_impl_xxx.cpp file) takes GLuint as ImTextureID, we can display it:
ImGui::Image((void*)(intptr_t)my_opengl_texture, ImVec2(my_image_width, my_image_height));
C/C++ tip: a void* is pointer-sized storage. You may safely store any pointer or integer into it by casting your value to ImTextureID / void*, and vice-versa.
Because both end-points (user code and rendering function) are under your control, you know exactly what is stored inside the ImTextureID / void*.
Examples:
GLuint my_tex = XXX;
void* my_void_ptr;
my_void_ptr = (void*)(intptr_t)my_tex; // cast a GLuint into a void* (we don't take its address! we literally store the value inside the pointer)
my_tex = (GLuint)(intptr_t)my_void_ptr; // cast a void* into a GLuint
ID3D11ShaderResourceView* my_dx11_srv = XXX;
void* my_void_ptr;
my_void_ptr = (void*)my_dx11_srv; // cast a ID3D11ShaderResourceView* into an opaque void*
my_dx11_srv = (ID3D11ShaderResourceView*)my_void_ptr; // cast a void* into a ID3D11ShaderResourceView*
Finally, you may call ImGui::ShowMetricsWindow() to explore/visualize/understand how the ImDrawList are generated.
Q: Why are multiple widgets reacting when I interact with a single one?
Q: How can I have multiple widgets with the same label or with an empty label?
A: A primer on labels and the ID Stack...
Dear ImGui internally need to uniquely identify UI elements.
Elements that are typically not clickable (such as calls to the Text functions) don't need an ID.
Interactive widgets (such as calls to Button buttons) need a unique ID.
Unique ID are used internally to track active widgets and occasionally associate state to widgets.
Unique ID are implicitly built from the hash of multiple elements that identify the "path" to the UI element.
- Unique ID are often derived from a string label:
Button("OK"); // Label = "OK", ID = hash of (..., "OK")
Button("Cancel"); // Label = "Cancel", ID = hash of (..., "Cancel")
- ID are uniquely scoped within windows, tree nodes, etc. which all pushes to the ID stack. Having
two buttons labeled "OK" in different windows or different tree locations is fine.
We used "..." above to signify whatever was already pushed to the ID stack previously:
Begin("MyWindow");
Button("OK"); // Label = "OK", ID = hash of ("MyWindow", "OK")
End();
Begin("MyOtherWindow");
Button("OK"); // Label = "OK", ID = hash of ("MyOtherWindow", "OK")
End();
- If you have a same ID twice in the same location, you'll have a conflict:
Button("OK");
Button("OK"); // ID collision! Interacting with either button will trigger the first one.
Fear not! this is easy to solve and there are many ways to solve it!
- Solving ID conflict in a simple/local context:
When passing a label you can optionally specify extra ID information within string itself.
Use "##" to pass a complement to the ID that won't be visible to the end-user.
This helps solving the simple collision cases when you know e.g. at compilation time which items
are going to be created:
Begin("MyWindow");
Button("Play"); // Label = "Play", ID = hash of ("MyWindow", "Play")
Button("Play##foo1"); // Label = "Play", ID = hash of ("MyWindow", "Play##foo1") // Different from above
Button("Play##foo2"); // Label = "Play", ID = hash of ("MyWindow", "Play##foo2") // Different from above
End();
- If you want to completely hide the label, but still need an ID:
Checkbox("##On", &b); // Label = "", ID = hash of (..., "##On") // No visible label, just a checkbox!
- Occasionally/rarely you might want change a label while preserving a constant ID. This allows
you to animate labels. For example you may want to include varying information in a window title bar,
but windows are uniquely identified by their ID. Use "###" to pass a label that isn't part of ID:
Button("Hello###ID"); // Label = "Hello", ID = hash of (..., "###ID")
Button("World###ID"); // Label = "World", ID = hash of (..., "###ID") // Same as above, even though the label looks different
sprintf(buf, "My game (%f FPS)###MyGame", fps);
Begin(buf); // Variable title, ID = hash of "MyGame"
- Solving ID conflict in a more general manner:
Use PushID() / PopID() to create scopes and manipulate the ID stack, as to avoid ID conflicts
within the same window. This is the most convenient way of distinguishing ID when iterating and
creating many UI elements programmatically.
You can push a pointer, a string or an integer value into the ID stack.
Remember that ID are formed from the concatenation of _everything_ pushed into the ID stack.
At each level of the stack we store the seed used for items at this level of the ID stack.
Begin("Window");
for (int i = 0; i < 100; i++)
{
PushID(i); // Push i to the id tack
Button("Click"); // Label = "Click", ID = hash of ("Window", i, "Click")
PopID();
}
for (int i = 0; i < 100; i++)
{
MyObject* obj = Objects[i];
PushID(obj);
Button("Click"); // Label = "Click", ID = hash of ("Window", obj pointer, "Click")
PopID();
}
for (int i = 0; i < 100; i++)
{
MyObject* obj = Objects[i];
PushID(obj->Name);
Button("Click"); // Label = "Click", ID = hash of ("Window", obj->Name, "Click")
PopID();
}
End();
- You can stack multiple prefixes into the ID stack:
Button("Click"); // Label = "Click", ID = hash of (..., "Click")
PushID("node");
Button("Click"); // Label = "Click", ID = hash of (..., "node", "Click")
PushID(my_ptr);
Button("Click"); // Label = "Click", ID = hash of (..., "node", my_ptr, "Click")
PopID();
PopID();
- Tree nodes implicitly creates a scope for you by calling PushID().
Button("Click"); // Label = "Click", ID = hash of (..., "Click")
if (TreeNode("node")) // <-- this function call will do a PushID() for you (unless instructed not to, with a special flag)
{
Button("Click"); // Label = "Click", ID = hash of (..., "node", "Click")
TreePop();
}
- When working with trees, ID are used to preserve the open/close state of each tree node.
Depending on your use cases you may want to use strings, indices or pointers as ID.
e.g. when following a single pointer that may change over time, using a static string as ID
will preserve your node open/closed state when the targeted object change.
e.g. when displaying a list of objects, using indices or pointers as ID will preserve the
node open/closed state differently. See what makes more sense in your situation!
Q: How can I use my own math types instead of ImVec2/ImVec4?
A: You can edit imconfig.h and setup the IM_VEC2_CLASS_EXTRA/IM_VEC4_CLASS_EXTRA macros to add implicit type conversions.
This way you'll be able to use your own types everywhere, e.g. passing glm::vec2 to ImGui functions instead of ImVec2.
Q: How can I load a different font than the default?
A: Use the font atlas to load the TTF/OTF file you want:
ImGuiIO& io = ImGui::GetIO();
io.Fonts->AddFontFromFileTTF("myfontfile.ttf", size_in_pixels);
io.Fonts->GetTexDataAsRGBA32() or GetTexDataAsAlpha8()
Default is ProggyClean.ttf, monospace, rendered at size 13, embedded in dear imgui's source code.
(Tip: monospace fonts are convenient because they allow to facilitate horizontal alignment directly at the string level.)
(Read the 'misc/fonts/README.txt' file for more details about font loading.)
New programmers: remember that in C/C++ and most programming languages if you want to use a
backslash \ within a string literal, you need to write it double backslash "\\":
io.Fonts->AddFontFromFileTTF("MyDataFolder\MyFontFile.ttf", size_in_pixels); // WRONG (you are escape the M here!)
io.Fonts->AddFontFromFileTTF("MyDataFolder\\MyFontFile.ttf", size_in_pixels); // CORRECT
io.Fonts->AddFontFromFileTTF("MyDataFolder/MyFontFile.ttf", size_in_pixels); // ALSO CORRECT
Q: How can I easily use icons in my application?
A: The most convenient and practical way is to merge an icon font such as FontAwesome inside you
main font. Then you can refer to icons within your strings.
You may want to see ImFontConfig::GlyphMinAdvanceX to make your icon look monospace to facilitate alignment.
(Read the 'misc/fonts/README.txt' file for more details about icons font loading.)
With some extra effort, you may use colorful icon by registering custom rectangle space inside the font atlas,
and copying your own graphics data into it. See misc/fonts/README.txt about using the AddCustomRectFontGlyph API.
Q: How can I load multiple fonts?
A: Use the font atlas to pack them into a single texture:
(Read the 'misc/fonts/README.txt' file and the code in ImFontAtlas for more details.)
ImGuiIO& io = ImGui::GetIO();
ImFont* font0 = io.Fonts->AddFontDefault();
ImFont* font1 = io.Fonts->AddFontFromFileTTF("myfontfile.ttf", size_in_pixels);
ImFont* font2 = io.Fonts->AddFontFromFileTTF("myfontfile2.ttf", size_in_pixels);
io.Fonts->GetTexDataAsRGBA32() or GetTexDataAsAlpha8()
// the first loaded font gets used by default
// use ImGui::PushFont()/ImGui::PopFont() to change the font at runtime
// Options
ImFontConfig config;
config.OversampleH = 2;
config.OversampleV = 1;
config.GlyphOffset.y -= 1.0f; // Move everything by 1 pixels up
config.GlyphExtraSpacing.x = 1.0f; // Increase spacing between characters
io.Fonts->AddFontFromFileTTF("myfontfile.ttf", size_pixels, &config);
// Combine multiple fonts into one (e.g. for icon fonts)
static ImWchar ranges[] = { 0xf000, 0xf3ff, 0 };
ImFontConfig config;
config.MergeMode = true;
io.Fonts->AddFontDefault();
io.Fonts->AddFontFromFileTTF("fontawesome-webfont.ttf", 16.0f, &config, ranges); // Merge icon font
io.Fonts->AddFontFromFileTTF("myfontfile.ttf", size_pixels, NULL, &config, io.Fonts->GetGlyphRangesJapanese()); // Merge japanese glyphs
Q: How can I display and input non-Latin characters such as Chinese, Japanese, Korean, Cyrillic?
A: When loading a font, pass custom Unicode ranges to specify the glyphs to load.
// Add default Japanese ranges
io.Fonts->AddFontFromFileTTF("myfontfile.ttf", size_in_pixels, NULL, io.Fonts->GetGlyphRangesJapanese());
// Or create your own custom ranges (e.g. for a game you can feed your entire game script and only build the characters the game need)
ImVector<ImWchar> ranges;
ImFontGlyphRangesBuilder builder;
builder.AddText("Hello world"); // Add a string (here "Hello world" contains 7 unique characters)
builder.AddChar(0x7262); // Add a specific character
builder.AddRanges(io.Fonts->GetGlyphRangesJapanese()); // Add one of the default ranges
builder.BuildRanges(&ranges); // Build the final result (ordered ranges with all the unique characters submitted)
io.Fonts->AddFontFromFileTTF("myfontfile.ttf", size_in_pixels, NULL, ranges.Data);
All your strings needs to use UTF-8 encoding. In C++11 you can encode a string literal in UTF-8
by using the u8"hello" syntax. Specifying literal in your source code using a local code page
(such as CP-923 for Japanese or CP-1251 for Cyrillic) will NOT work!
Otherwise you can convert yourself to UTF-8 or load text data from file already saved as UTF-8.
Text input: it is up to your application to pass the right character code by calling io.AddInputCharacter().
The applications in examples/ are doing that.
Windows: you can use the WM_CHAR or WM_UNICHAR or WM_IME_CHAR message (depending if your app is built using Unicode or MultiByte mode).
You may also use MultiByteToWideChar() or ToUnicode() to retrieve Unicode codepoints from MultiByte characters or keyboard state.
Windows: if your language is relying on an Input Method Editor (IME), you copy the HWND of your window to io.ImeWindowHandle in order for
the default implementation of io.ImeSetInputScreenPosFn() to set your Microsoft IME position correctly.
Q: How can I interact with standard C++ types (such as std::string and std::vector)?
A: - Being highly portable (bindings for several languages, frameworks, programming style, obscure or older platforms/compilers),
and aiming for compatibility & performance suitable for every modern real-time game engines, dear imgui does not use
any of std C++ types. We use raw types (e.g. char* instead of std::string) because they adapt to more use cases.
- To use ImGui::InputText() with a std::string or any resizable string class, see misc/cpp/imgui_stdlib.h.
- To use combo boxes and list boxes with std::vector or any other data structure: the BeginCombo()/EndCombo() API
lets you iterate and submit items yourself, so does the ListBoxHeader()/ListBoxFooter() API.
Prefer using them over the old and awkward Combo()/ListBox() api.
- Generally for most high-level types you should be able to access the underlying data type.
You may write your own one-liner wrappers to facilitate user code (tip: add new functions in ImGui:: namespace from your code).
- Dear ImGui applications often need to make intensive use of strings. It is expected that many of the strings you will pass
to the API are raw literals (free in C/C++) or allocated in a manner that won't incur a large cost on your application.
Please bear in mind that using std::string on applications with large amount of UI may incur unsatisfactory performances.
Modern implementations of std::string often include small-string optimization (which is often a local buffer) but those
are not configurable and not the same across implementations.
- If you are finding your UI traversal cost to be too large, make sure your string usage is not leading to excessive amount
of heap allocations. Consider using literals, statically sized buffers and your own helper functions. A common pattern
is that you will need to build lots of strings on the fly, and their maximum length can be easily be scoped ahead.
One possible implementation of a helper to facilitate printf-style building of strings: https://github.com/ocornut/Str
This is a small helper where you can instance strings with configurable local buffers length. Many game engines will
provide similar or better string helpers.
Q: How can I use the drawing facilities without an ImGui window? (using ImDrawList API)
A: - You can create a dummy window. Call Begin() with the NoBackground | NoDecoration | NoSavedSettings | NoInputs flags.
(The ImGuiWindowFlags_NoDecoration flag itself is a shortcut for NoTitleBar | NoResize | NoScrollbar | NoCollapse)
Then you can retrieve the ImDrawList* via GetWindowDrawList() and draw to it in any way you like.
- You can call ImGui::GetBackgroundDrawList() or ImGui::GetForegroundDrawList() and use those draw list to display
contents behind or over every other imgui windows (one bg/fg drawlist per viewport).
- You can create your own ImDrawList instance. You'll need to initialize them ImGui::GetDrawListSharedData(), or create
your own ImDrawListSharedData, and then call your rendered code with your own ImDrawList or ImDrawData data.
Q: How can I use this without a mouse, without a keyboard or without a screen? (gamepad, input share, remote display)
A: - You can control Dear ImGui with a gamepad. Read about navigation in "Using gamepad/keyboard navigation controls".
(short version: map gamepad inputs into the io.NavInputs[] array + set io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad)
- You can share your computer mouse seamlessly with your console/tablet/phone using Synergy (https://symless.com/synergy)
This is the preferred solution for developer productivity.
In particular, the "micro-synergy-client" repository (https://github.com/symless/micro-synergy-client) has simple
and portable source code (uSynergy.c/.h) for a small embeddable client that you can use on any platform to connect
to your host computer, based on the Synergy 1.x protocol. Make sure you download the Synergy 1 server on your computer.
Console SDK also sometimes provide equivalent tooling or wrapper for Synergy-like protocols.
- You may also use a third party solution such as Remote ImGui (https://github.com/JordiRos/remoteimgui) which sends
the vertices to render over the local network, allowing you to use Dear ImGui even on a screen-less machine.
- For touch inputs, you can increase the hit box of widgets (via the style.TouchPadding setting) to accommodate
for the lack of precision of touch inputs, but it is recommended you use a mouse or gamepad to allow optimizing
for screen real-estate and precision.
Q: I integrated Dear ImGui in my engine and the text or lines are blurry..
A: In your Render function, try translating your projection matrix by (0.5f,0.5f) or (0.375f,0.375f).
Also make sure your orthographic projection matrix and io.DisplaySize matches your actual framebuffer dimension.
Q: I integrated Dear ImGui in my engine and some elements are clipping or disappearing when I move windows around..
A: You are probably mishandling the clipping rectangles in your render function.
Rectangles provided by ImGui are defined as (x1=left,y1=top,x2=right,y2=bottom) and NOT as (x1,y1,width,height).
Q: How can I help?
A: - If you are experienced with Dear ImGui and C++, look at the github issues, look at the Wiki, read docs/TODO.txt
and see how you want to help and can help!
- Businesses: convince your company to fund development via support contracts/sponsoring! This is among the most useful thing you can do for dear imgui.
- Individuals: you can also become a Patron (http://www.patreon.com/imgui) or donate on PayPal! See README.
- Disclose your usage of dear imgui via a dev blog post, a tweet, a screenshot, a mention somewhere etc.
You may post screenshot or links in the gallery threads (github.com/ocornut/imgui/issues/1902). Visuals are ideal as they inspire other programmers.
But even without visuals, disclosing your use of dear imgui help the library grow credibility, and help other teams and programmers with taking decisions.
- If you have issues or if you need to hack into the library, even if you don't expect any support it is useful that you share your issues (on github or privately).
- tip: you can call Begin() multiple times with the same name during the same frame, it will keep appending to the same window.
this is also useful to set yourself in the context of another window (to get/set other settings)
- tip: you can create widgets without a Begin()/End() block, they will go in an implicit window called "Debug".
- tip: the ImGuiOnceUponAFrame helper will allow run the block of code only once a frame. You can use it to quickly add custom UI in the middle
of a deep nested inner loop in your code.
- tip: you can call Render() multiple times (e.g for VR renders).
- tip: call and read the ShowDemoWindow() code in imgui_demo.cpp for more example of how to use ImGui!
*/
#if defined(_MSC_VER) && !defined(_CRT_SECURE_NO_WARNINGS)
#define _CRT_SECURE_NO_WARNINGS
#endif
#include "imgui.h"
#ifndef IMGUI_DEFINE_MATH_OPERATORS
#define IMGUI_DEFINE_MATH_OPERATORS
#endif
#include "imgui_internal.h"
#include <ctype.h> // toupper
#include <stdio.h> // vsnprintf, sscanf, printf
#if defined(_MSC_VER) && _MSC_VER <= 1500 // MSVC 2008 or earlier
#include <stddef.h> // intptr_t
#else
#include <stdint.h> // intptr_t
#endif
// Debug options
#define IMGUI_DEBUG_NAV_SCORING 0 // Display navigation scoring preview when hovering items. Display last moving direction matches when holding CTRL
#define IMGUI_DEBUG_NAV_RECTS 0 // Display the reference navigation rectangle for each window
#define IMGUI_DEBUG_INI_SETTINGS 0 // Save additional comments in .ini file (particularly helps for Docking, but makes saving slower)
// Visual Studio warnings
#ifdef _MSC_VER
#pragma warning (disable: 4127) // condition expression is constant
#pragma warning (disable: 4996) // 'This function or variable may be unsafe': strcpy, strdup, sprintf, vsnprintf, sscanf, fopen
#endif
// Clang/GCC warnings with -Weverything
#if defined(__clang__)
#pragma clang diagnostic ignored "-Wunknown-pragmas" // warning : unknown warning group '-Wformat-pedantic *' // not all warnings are known by all clang versions.. so ignoring warnings triggers new warnings on some configuration. great!
#pragma clang diagnostic ignored "-Wold-style-cast" // warning : use of old-style cast // yes, they are more terse.
#pragma clang diagnostic ignored "-Wfloat-equal" // warning : comparing floating point with == or != is unsafe // storing and comparing against same constants (typically 0.0f) is ok.
#pragma clang diagnostic ignored "-Wformat-nonliteral" // warning : format string is not a string literal // passing non-literal to vsnformat(). yes, user passing incorrect format strings can crash the code.
#pragma clang diagnostic ignored "-Wexit-time-destructors" // warning : declaration requires an exit-time destructor // exit-time destruction order is undefined. if MemFree() leads to users code that has been disabled before exit it might cause problems. ImGui coding style welcomes static/globals.
#pragma clang diagnostic ignored "-Wglobal-constructors" // warning : declaration requires a global destructor // similar to above, not sure what the exact difference is.
#pragma clang diagnostic ignored "-Wsign-conversion" // warning : implicit conversion changes signedness //
#pragma clang diagnostic ignored "-Wformat-pedantic" // warning : format specifies type 'void *' but the argument has type 'xxxx *' // unreasonable, would lead to casting every %p arg to void*. probably enabled by -pedantic.
#pragma clang diagnostic ignored "-Wint-to-void-pointer-cast" // warning : cast to 'void *' from smaller integer type 'int'
#if __has_warning("-Wzero-as-null-pointer-constant")
#pragma clang diagnostic ignored "-Wzero-as-null-pointer-constant" // warning : zero as null pointer constant // some standard header variations use #define NULL 0
#endif
#if __has_warning("-Wdouble-promotion")
#pragma clang diagnostic ignored "-Wdouble-promotion" // warning: implicit conversion from 'float' to 'double' when passing argument to function // using printf() is a misery with this as C++ va_arg ellipsis changes float to double.
#endif
#elif defined(__GNUC__)
// We disable -Wpragmas because GCC doesn't provide an has_warning equivalent and some forks/patches may not following the warning/version association.
#pragma GCC diagnostic ignored "-Wpragmas" // warning: unknown option after '#pragma GCC diagnostic' kind
#pragma GCC diagnostic ignored "-Wunused-function" // warning: 'xxxx' defined but not used
#pragma GCC diagnostic ignored "-Wint-to-pointer-cast" // warning: cast to pointer from integer of different size
#pragma GCC diagnostic ignored "-Wformat" // warning: format '%p' expects argument of type 'void*', but argument 6 has type 'ImGuiWindow*'
#pragma GCC diagnostic ignored "-Wdouble-promotion" // warning: implicit conversion from 'float' to 'double' when passing argument to function
#pragma GCC diagnostic ignored "-Wconversion" // warning: conversion to 'xxxx' from 'xxxx' may alter its value
#pragma GCC diagnostic ignored "-Wformat-nonliteral" // warning: format not a string literal, format string not checked
#pragma GCC diagnostic ignored "-Wstrict-overflow" // warning: assuming signed overflow does not occur when assuming that (X - c) > X is always false
#pragma GCC diagnostic ignored "-Wclass-memaccess" // [__GNUC__ >= 8] warning: 'memset/memcpy' clearing/writing an object of type 'xxxx' with no trivial copy-assignment; use assignment or value-initialization instead
#endif
// When using CTRL+TAB (or Gamepad Square+L/R) we delay the visual a little in order to reduce visual noise doing a fast switch.
static const float NAV_WINDOWING_HIGHLIGHT_DELAY = 0.20f; // Time before the highlight and screen dimming starts fading in
static const float NAV_WINDOWING_LIST_APPEAR_DELAY = 0.15f; // Time before the window list starts to appear
// Window resizing from edges (when io.ConfigWindowsResizeFromEdges = true and ImGuiBackendFlags_HasMouseCursors is set in io.BackendFlags by back-end)
static const float WINDOWS_RESIZE_FROM_EDGES_HALF_THICKNESS = 4.0f; // Extend outside and inside windows. Affect FindHoveredWindow().
static const float WINDOWS_RESIZE_FROM_EDGES_FEEDBACK_TIMER = 0.04f; // Reduce visual noise by only highlighting the border after a certain time.
static const float WINDOWS_MOUSE_WHEEL_SCROLL_LOCK_TIMER = 2.00f; // Lock scrolled window (so it doesn't pick child windows that are scrolling through) for a certaint time, unless mouse moved.
// Docking
static const float DOCKING_TRANSPARENT_PAYLOAD_ALPHA = 0.50f; // For use with io.ConfigDockingTransparentPayload. Apply to Viewport _or_ WindowBg in host viewport.
//-------------------------------------------------------------------------
// [SECTION] FORWARD DECLARATIONS
//-------------------------------------------------------------------------
static void SetCurrentWindow(ImGuiWindow* window);
static void SetWindowHitTestHole(ImGuiWindow* window, const ImVec2& pos, const ImVec2& size);
static void FindHoveredWindow();
static ImGuiWindow* CreateNewWindow(const char* name, ImVec2 size, ImGuiWindowFlags flags);
static void CheckStacksSize(ImGuiWindow* window, bool write);
static ImVec2 CalcNextScrollFromScrollTargetAndClamp(ImGuiWindow* window, bool snap_on_edges);
static void AddDrawListToDrawData(ImVector<ImDrawList*>* out_list, ImDrawList* draw_list);
static void AddWindowToSortBuffer(ImVector<ImGuiWindow*>* out_sorted_windows, ImGuiWindow* window);
// Settings
static void* SettingsHandlerWindow_ReadOpen(ImGuiContext*, ImGuiSettingsHandler*, const char* name);
static void SettingsHandlerWindow_ReadLine(ImGuiContext*, ImGuiSettingsHandler*, void* entry, const char* line);
static void SettingsHandlerWindow_WriteAll(ImGuiContext* imgui_ctx, ImGuiSettingsHandler* handler, ImGuiTextBuffer* buf);
// Platform Dependents default implementation for IO functions
static const char* GetClipboardTextFn_DefaultImpl(void* user_data);
static void SetClipboardTextFn_DefaultImpl(void* user_data, const char* text);
namespace ImGui
{
static bool BeginChildEx(const char* name, ImGuiID id, const ImVec2& size_arg, bool border, ImGuiWindowFlags flags);
// Navigation
static void NavUpdate();
static void NavUpdateWindowing();
static void NavUpdateWindowingList();
static void NavUpdateMoveResult();
static float NavUpdatePageUpPageDown(int allowed_dir_flags);
static inline void NavUpdateAnyRequestFlag();
static void NavProcessItem(ImGuiWindow* window, const ImRect& nav_bb, ImGuiID id);
static ImVec2 NavCalcPreferredRefPos();
static void NavSaveLastChildNavWindowIntoParent(ImGuiWindow* nav_window);
static ImGuiWindow* NavRestoreLastChildNavWindow(ImGuiWindow* window);
static int FindWindowFocusIndex(ImGuiWindow* window);
// Misc
static void UpdateMouseInputs();
static void UpdateMouseWheel();
static bool UpdateManualResize(ImGuiWindow* window, const ImVec2& size_auto_fit, int* border_held, int resize_grip_count, ImU32 resize_grip_col[4]);
static void UpdateDebugToolItemPicker();
static void RenderWindowOuterBorders(ImGuiWindow* window);
static void RenderWindowDecorations(ImGuiWindow* window, const ImRect& title_bar_rect, bool title_bar_is_highlight, bool handle_borders_and_resize_grips, int resize_grip_count, const ImU32 resize_grip_col[4], float resize_grip_draw_size);
static void RenderWindowTitleBarContents(ImGuiWindow* window, const ImRect& title_bar_rect, const char* name, bool* p_open);
static void EndFrameDrawDimmedBackgrounds();
// Viewports
const ImGuiID IMGUI_VIEWPORT_DEFAULT_ID = 0x11111111; // Using an arbitrary constant instead of e.g. ImHashStr("ViewportDefault", 0); so it's easier to spot in the debugger. The exact value doesn't matter.
static ImGuiViewportP* AddUpdateViewport(ImGuiWindow* window, ImGuiID id, const ImVec2& platform_pos, const ImVec2& size, ImGuiViewportFlags flags);
static void UpdateViewportsNewFrame();
static void UpdateViewportsEndFrame();
static void UpdateSelectWindowViewport(ImGuiWindow* window);
static bool UpdateTryMergeWindowIntoHostViewport(ImGuiWindow* window, ImGuiViewportP* host_viewport);
static bool UpdateTryMergeWindowIntoHostViewports(ImGuiWindow* window);
static void SetCurrentViewport(ImGuiWindow* window, ImGuiViewportP* viewport);
static bool GetWindowAlwaysWantOwnViewport(ImGuiWindow* window);
static int FindPlatformMonitorForPos(const ImVec2& pos);
static int FindPlatformMonitorForRect(const ImRect& r);
static void UpdateViewportPlatformMonitor(ImGuiViewportP* viewport);
}
//-----------------------------------------------------------------------------
// [SECTION] CONTEXT AND MEMORY ALLOCATORS
//-----------------------------------------------------------------------------
// Current context pointer. Implicitly used by all Dear ImGui functions. Always assumed to be != NULL.
// ImGui::CreateContext() will automatically set this pointer if it is NULL. Change to a different context by calling ImGui::SetCurrentContext().
// 1) Important: globals are not shared across DLL boundaries! If you use DLLs or any form of hot-reloading: you will need to call
// SetCurrentContext() (with the pointer you got from CreateContext) from each unique static/DLL boundary, and after each hot-reloading.
// In your debugger, add GImGui to your watch window and notice how its value changes depending on which location you are currently stepping into.
// 2) Important: Dear ImGui functions are not thread-safe because of this pointer.
// If you want thread-safety to allow N threads to access N different contexts, you can:
// - Change this variable to use thread local storage so each thread can refer to a different context, in imconfig.h:
// struct ImGuiContext;
// extern thread_local ImGuiContext* MyImGuiTLS;
// #define GImGui MyImGuiTLS
// And then define MyImGuiTLS in one of your cpp file. Note that thread_local is a C++11 keyword, earlier C++ uses compiler-specific keyword.
// - Future development aim to make this context pointer explicit to all calls. Also read https://github.com/ocornut/imgui/issues/586
// - If you need a finite number of contexts, you may compile and use multiple instances of the ImGui code from different namespace.
#ifndef GImGui
ImGuiContext* GImGui = NULL;
#endif
// Memory Allocator functions. Use SetAllocatorFunctions() to change them.
// If you use DLL hotreloading you might need to call SetAllocatorFunctions() after reloading code from this file.
// Otherwise, you probably don't want to modify them mid-program, and if you use global/static e.g. ImVector<> instances you may need to keep them accessible during program destruction.
#ifndef IMGUI_DISABLE_DEFAULT_ALLOCATORS
static void* MallocWrapper(size_t size, void* user_data) { IM_UNUSED(user_data); return malloc(size); }
static void FreeWrapper(void* ptr, void* user_data) { IM_UNUSED(user_data); free(ptr); }
#else
static void* MallocWrapper(size_t size, void* user_data) { IM_UNUSED(user_data); IM_UNUSED(size); IM_ASSERT(0); return NULL; }
static void FreeWrapper(void* ptr, void* user_data) { IM_UNUSED(user_data); IM_UNUSED(ptr); IM_ASSERT(0); }
#endif
static void* (*GImAllocatorAllocFunc)(size_t size, void* user_data) = MallocWrapper;
static void (*GImAllocatorFreeFunc)(void* ptr, void* user_data) = FreeWrapper;
static void* GImAllocatorUserData = NULL;
//-----------------------------------------------------------------------------
// [SECTION] MAIN USER FACING STRUCTURES (ImGuiStyle, ImGuiIO)
//-----------------------------------------------------------------------------
ImGuiStyle::ImGuiStyle()
{
Alpha = 1.0f; // Global alpha applies to everything in ImGui
WindowPadding = ImVec2(8,8); // Padding within a window
WindowRounding = 7.0f; // Radius of window corners rounding. Set to 0.0f to have rectangular windows
WindowBorderSize = 1.0f; // Thickness of border around windows. Generally set to 0.0f or 1.0f. Other values not well tested.
WindowMinSize = ImVec2(32,32); // Minimum window size
WindowTitleAlign = ImVec2(0.0f,0.5f);// Alignment for title bar text
WindowMenuButtonPosition= ImGuiDir_Left; // Position of the collapsing/docking button in the title bar (left/right). Defaults to ImGuiDir_Left.
ChildRounding = 0.0f; // Radius of child window corners rounding. Set to 0.0f to have rectangular child windows
ChildBorderSize = 1.0f; // Thickness of border around child windows. Generally set to 0.0f or 1.0f. Other values not well tested.
PopupRounding = 0.0f; // Radius of popup window corners rounding. Set to 0.0f to have rectangular child windows
PopupBorderSize = 1.0f; // Thickness of border around popup or tooltip windows. Generally set to 0.0f or 1.0f. Other values not well tested.
FramePadding = ImVec2(4,3); // Padding within a framed rectangle (used by most widgets)
FrameRounding = 0.0f; // Radius of frame corners rounding. Set to 0.0f to have rectangular frames (used by most widgets).
FrameBorderSize = 0.0f; // Thickness of border around frames. Generally set to 0.0f or 1.0f. Other values not well tested.
ItemSpacing = ImVec2(8,4); // Horizontal and vertical spacing between widgets/lines
ItemInnerSpacing = ImVec2(4,4); // Horizontal and vertical spacing between within elements of a composed widget (e.g. a slider and its label)
TouchExtraPadding = ImVec2(0,0); // Expand reactive bounding box for touch-based system where touch position is not accurate enough. Unfortunately we don't sort widgets so priority on overlap will always be given to the first widget. So don't grow this too much!
IndentSpacing = 21.0f; // Horizontal spacing when e.g. entering a tree node. Generally == (FontSize + FramePadding.x*2).
ColumnsMinSpacing = 6.0f; // Minimum horizontal spacing between two columns. Preferably > (FramePadding.x + 1).
ScrollbarSize = 14.0f; // Width of the vertical scrollbar, Height of the horizontal scrollbar
ScrollbarRounding = 9.0f; // Radius of grab corners rounding for scrollbar
GrabMinSize = 10.0f; // Minimum width/height of a grab box for slider/scrollbar
GrabRounding = 0.0f; // Radius of grabs corners rounding. Set to 0.0f to have rectangular slider grabs.
TabRounding = 4.0f; // Radius of upper corners of a tab. Set to 0.0f to have rectangular tabs.
TabBorderSize = 0.0f; // Thickness of border around tabs.
ColorButtonPosition = ImGuiDir_Right; // Side of the color button in the ColorEdit4 widget (left/right). Defaults to ImGuiDir_Right.
ButtonTextAlign = ImVec2(0.5f,0.5f);// Alignment of button text when button is larger than text.
SelectableTextAlign = ImVec2(0.0f,0.0f);// Alignment of selectable text when button is larger than text.
DisplayWindowPadding = ImVec2(19,19); // Window position are clamped to be visible within the display area or monitors by at least this amount. Only applies to regular windows.
DisplaySafeAreaPadding = ImVec2(3,3); // If you cannot see the edge of your screen (e.g. on a TV) increase the safe area padding. Covers popups/tooltips as well regular windows.
MouseCursorScale = 1.0f; // Scale software rendered mouse cursor (when io.MouseDrawCursor is enabled). May be removed later.
AntiAliasedLines = true; // Enable anti-aliasing on lines/borders. Disable if you are really short on CPU/GPU.
AntiAliasedFill = true; // Enable anti-aliasing on filled shapes (rounded rectangles, circles, etc.)
CurveTessellationTol = 1.25f; // Tessellation tolerance when using PathBezierCurveTo() without a specific number of segments. Decrease for highly tessellated curves (higher quality, more polygons), increase to reduce quality.
// Default theme
ImGui::StyleColorsDark(this);
}
// To scale your entire UI (e.g. if you want your app to use High DPI or generally be DPI aware) you may use this helper function. Scaling the fonts is done separately and is up to you.
// Important: This operation is lossy because we round all sizes to integer. If you need to change your scale multiples, call this over a freshly initialized ImGuiStyle structure rather than scaling multiple times.
void ImGuiStyle::ScaleAllSizes(float scale_factor)
{
WindowPadding = ImFloor(WindowPadding * scale_factor);
WindowRounding = ImFloor(WindowRounding * scale_factor);
WindowMinSize = ImFloor(WindowMinSize * scale_factor);
ChildRounding = ImFloor(ChildRounding * scale_factor);
PopupRounding = ImFloor(PopupRounding * scale_factor);
FramePadding = ImFloor(FramePadding * scale_factor);
FrameRounding = ImFloor(FrameRounding * scale_factor);
ItemSpacing = ImFloor(ItemSpacing * scale_factor);
ItemInnerSpacing = ImFloor(ItemInnerSpacing * scale_factor);
TouchExtraPadding = ImFloor(TouchExtraPadding * scale_factor);
IndentSpacing = ImFloor(IndentSpacing * scale_factor);
ColumnsMinSpacing = ImFloor(ColumnsMinSpacing * scale_factor);
ScrollbarSize = ImFloor(ScrollbarSize * scale_factor);
ScrollbarRounding = ImFloor(ScrollbarRounding * scale_factor);
GrabMinSize = ImFloor(GrabMinSize * scale_factor);
GrabRounding = ImFloor(GrabRounding * scale_factor);
TabRounding = ImFloor(TabRounding * scale_factor);
DisplayWindowPadding = ImFloor(DisplayWindowPadding * scale_factor);
DisplaySafeAreaPadding = ImFloor(DisplaySafeAreaPadding * scale_factor);
MouseCursorScale = ImFloor(MouseCursorScale * scale_factor);
}
ImGuiIO::ImGuiIO()
{
// Most fields are initialized with zero
memset(this, 0, sizeof(*this));
// Settings
ConfigFlags = ImGuiConfigFlags_None;
BackendFlags = ImGuiBackendFlags_None;
DisplaySize = ImVec2(-1.0f, -1.0f);
DeltaTime = 1.0f/60.0f;
IniSavingRate = 5.0f;
IniFilename = "imgui.ini";
LogFilename = "imgui_log.txt";
MouseDoubleClickTime = 0.30f;
MouseDoubleClickMaxDist = 6.0f;
for (int i = 0; i < ImGuiKey_COUNT; i++)
KeyMap[i] = -1;
KeyRepeatDelay = 0.250f;
KeyRepeatRate = 0.050f;
UserData = NULL;
Fonts = NULL;
FontGlobalScale = 1.0f;
FontDefault = NULL;
FontAllowUserScaling = false;
DisplayFramebufferScale = ImVec2(1.0f, 1.0f);
// Docking options (when ImGuiConfigFlags_DockingEnable is set)
ConfigDockingNoSplit = false;
ConfigDockingWithShift = false;
ConfigDockingAlwaysTabBar = false;
ConfigDockingTransparentPayload = false;
// Viewport options (when ImGuiConfigFlags_ViewportsEnable is set)
ConfigViewportsNoAutoMerge = false;
ConfigViewportsNoTaskBarIcon = false;
ConfigViewportsNoDecoration = true;
ConfigViewportsNoDefaultParent = false;
// Miscellaneous options
MouseDrawCursor = false;
#ifdef __APPLE__
ConfigMacOSXBehaviors = true; // Set Mac OS X style defaults based on __APPLE__ compile time flag
#else
ConfigMacOSXBehaviors = false;
#endif
ConfigInputTextCursorBlink = true;
ConfigWindowsResizeFromEdges = true;
ConfigWindowsMoveFromTitleBarOnly = false;
// Platform Functions
BackendPlatformName = BackendRendererName = NULL;
BackendPlatformUserData = BackendRendererUserData = BackendLanguageUserData = NULL;
GetClipboardTextFn = GetClipboardTextFn_DefaultImpl; // Platform dependent default implementations
SetClipboardTextFn = SetClipboardTextFn_DefaultImpl;
ClipboardUserData = NULL;
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
RenderDrawListsFn = NULL;
#endif
// Input (NB: we already have memset zero the entire structure!)
MousePos = ImVec2(-FLT_MAX, -FLT_MAX);
MousePosPrev = ImVec2(-FLT_MAX, -FLT_MAX);
MouseDragThreshold = 6.0f;
for (int i = 0; i < IM_ARRAYSIZE(MouseDownDuration); i++) MouseDownDuration[i] = MouseDownDurationPrev[i] = -1.0f;
for (int i = 0; i < IM_ARRAYSIZE(KeysDownDuration); i++) KeysDownDuration[i] = KeysDownDurationPrev[i] = -1.0f;
for (int i = 0; i < IM_ARRAYSIZE(NavInputsDownDuration); i++) NavInputsDownDuration[i] = -1.0f;
}
// Pass in translated ASCII characters for text input.
// - with glfw you can get those from the callback set in glfwSetCharCallback()
// - on Windows you can get those using ToAscii+keyboard state, or via the WM_CHAR message
void ImGuiIO::AddInputCharacter(unsigned int c)
{
if (c > 0 && c < 0x10000)
InputQueueCharacters.push_back((ImWchar)c);
}
void ImGuiIO::AddInputCharactersUTF8(const char* utf8_chars)
{
while (*utf8_chars != 0)
{
unsigned int c = 0;
utf8_chars += ImTextCharFromUtf8(&c, utf8_chars, NULL);
if (c > 0 && c < 0x10000)
InputQueueCharacters.push_back((ImWchar)c);
}
}
void ImGuiIO::ClearInputCharacters()
{
InputQueueCharacters.resize(0);
}
//-----------------------------------------------------------------------------
// [SECTION] MISC HELPERS/UTILITIES (Maths, String, Format, Hash, File functions)
//-----------------------------------------------------------------------------
ImVec2 ImLineClosestPoint(const ImVec2& a, const ImVec2& b, const ImVec2& p)
{
ImVec2 ap = p - a;
ImVec2 ab_dir = b - a;
float dot = ap.x * ab_dir.x + ap.y * ab_dir.y;
if (dot < 0.0f)
return a;
float ab_len_sqr = ab_dir.x * ab_dir.x + ab_dir.y * ab_dir.y;
if (dot > ab_len_sqr)
return b;
return a + ab_dir * dot / ab_len_sqr;
}
bool ImTriangleContainsPoint(const ImVec2& a, const ImVec2& b, const ImVec2& c, const ImVec2& p)
{
bool b1 = ((p.x - b.x) * (a.y - b.y) - (p.y - b.y) * (a.x - b.x)) < 0.0f;
bool b2 = ((p.x - c.x) * (b.y - c.y) - (p.y - c.y) * (b.x - c.x)) < 0.0f;
bool b3 = ((p.x - a.x) * (c.y - a.y) - (p.y - a.y) * (c.x - a.x)) < 0.0f;
return ((b1 == b2) && (b2 == b3));
}
void ImTriangleBarycentricCoords(const ImVec2& a, const ImVec2& b, const ImVec2& c, const ImVec2& p, float& out_u, float& out_v, float& out_w)
{
ImVec2 v0 = b - a;
ImVec2 v1 = c - a;
ImVec2 v2 = p - a;
const float denom = v0.x * v1.y - v1.x * v0.y;
out_v = (v2.x * v1.y - v1.x * v2.y) / denom;
out_w = (v0.x * v2.y - v2.x * v0.y) / denom;
out_u = 1.0f - out_v - out_w;
}
ImVec2 ImTriangleClosestPoint(const ImVec2& a, const ImVec2& b, const ImVec2& c, const ImVec2& p)
{
ImVec2 proj_ab = ImLineClosestPoint(a, b, p);
ImVec2 proj_bc = ImLineClosestPoint(b, c, p);
ImVec2 proj_ca = ImLineClosestPoint(c, a, p);
float dist2_ab = ImLengthSqr(p - proj_ab);
float dist2_bc = ImLengthSqr(p - proj_bc);
float dist2_ca = ImLengthSqr(p - proj_ca);
float m = ImMin(dist2_ab, ImMin(dist2_bc, dist2_ca));
if (m == dist2_ab)
return proj_ab;
if (m == dist2_bc)
return proj_bc;
return proj_ca;
}
// Consider using _stricmp/_strnicmp under Windows or strcasecmp/strncasecmp. We don't actually use either ImStricmp/ImStrnicmp in the codebase any more.
int ImStricmp(const char* str1, const char* str2)
{
int d;
while ((d = toupper(*str2) - toupper(*str1)) == 0 && *str1) { str1++; str2++; }
return d;
}
int ImStrnicmp(const char* str1, const char* str2, size_t count)
{
int d = 0;
while (count > 0 && (d = toupper(*str2) - toupper(*str1)) == 0 && *str1) { str1++; str2++; count--; }
return d;
}
void ImStrncpy(char* dst, const char* src, size_t count)
{
if (count < 1)
return;
if (count > 1)
strncpy(dst, src, count - 1);
dst[count - 1] = 0;
}
char* ImStrdup(const char* str)
{
size_t len = strlen(str);
void* buf = IM_ALLOC(len + 1);
return (char*)memcpy(buf, (const void*)str, len + 1);
}
char* ImStrdupcpy(char* dst, size_t* p_dst_size, const char* src)
{
size_t dst_buf_size = p_dst_size ? *p_dst_size : strlen(dst) + 1;
size_t src_size = strlen(src) + 1;
if (dst_buf_size < src_size)
{
IM_FREE(dst);
dst = (char*)IM_ALLOC(src_size);
if (p_dst_size)
*p_dst_size = src_size;
}
return (char*)memcpy(dst, (const void*)src, src_size);
}
const char* ImStrchrRange(const char* str, const char* str_end, char c)
{
const char* p = (const char*)memchr(str, (int)c, str_end - str);
return p;
}
int ImStrlenW(const ImWchar* str)
{
//return (int)wcslen((const wchar_t*)str); // FIXME-OPT: Could use this when wchar_t are 16-bits
int n = 0;
while (*str++) n++;
return n;
}
// Find end-of-line. Return pointer will point to either first \n, either str_end.
const char* ImStreolRange(const char* str, const char* str_end)
{
const char* p = (const char*)memchr(str, '\n', str_end - str);
return p ? p : str_end;
}
const ImWchar* ImStrbolW(const ImWchar* buf_mid_line, const ImWchar* buf_begin) // find beginning-of-line
{
while (buf_mid_line > buf_begin && buf_mid_line[-1] != '\n')
buf_mid_line--;
return buf_mid_line;
}
const char* ImStristr(const char* haystack, const char* haystack_end, const char* needle, const char* needle_end)
{
if (!needle_end)
needle_end = needle + strlen(needle);
const char un0 = (char)toupper(*needle);
while ((!haystack_end && *haystack) || (haystack_end && haystack < haystack_end))
{
if (toupper(*haystack) == un0)
{
const char* b = needle + 1;
for (const char* a = haystack + 1; b < needle_end; a++, b++)
if (toupper(*a) != toupper(*b))
break;
if (b == needle_end)
return haystack;
}
haystack++;
}
return NULL;
}
// Trim str by offsetting contents when there's leading data + writing a \0 at the trailing position. We use this in situation where the cost is negligible.
void ImStrTrimBlanks(char* buf)
{
char* p = buf;
while (p[0] == ' ' || p[0] == '\t') // Leading blanks
p++;
char* p_start = p;
while (*p != 0) // Find end of string
p++;
while (p > p_start && (p[-1] == ' ' || p[-1] == '\t')) // Trailing blanks
p--;
if (p_start != buf) // Copy memory if we had leading blanks
memmove(buf, p_start, p - p_start);
buf[p - p_start] = 0; // Zero terminate
}
const char* ImStrSkipBlank(const char* str)
{
while (str[0] == ' ' || str[0] == '\t')
str++;
return str;
}
// A) MSVC version appears to return -1 on overflow, whereas glibc appears to return total count (which may be >= buf_size).
// Ideally we would test for only one of those limits at runtime depending on the behavior the vsnprintf(), but trying to deduct it at compile time sounds like a pandora can of worm.
// B) When buf==NULL vsnprintf() will return the output size.
#ifndef IMGUI_DISABLE_FORMAT_STRING_FUNCTIONS
//#define IMGUI_USE_STB_SPRINTF
#ifdef IMGUI_USE_STB_SPRINTF
#define STB_SPRINTF_IMPLEMENTATION
#include "imstb_sprintf.h"
#endif
#if defined(_MSC_VER) && !defined(vsnprintf)
#define vsnprintf _vsnprintf
#endif
int ImFormatString(char* buf, size_t buf_size, const char* fmt, ...)
{
va_list args;
va_start(args, fmt);
#ifdef IMGUI_USE_STB_SPRINTF
int w = stbsp_vsnprintf(buf, (int)buf_size, fmt, args);
#else
int w = vsnprintf(buf, buf_size, fmt, args);
#endif
va_end(args);
if (buf == NULL)
return w;
if (w == -1 || w >= (int)buf_size)
w = (int)buf_size - 1;
buf[w] = 0;
return w;
}
int ImFormatStringV(char* buf, size_t buf_size, const char* fmt, va_list args)
{
#ifdef IMGUI_USE_STB_SPRINTF
int w = stbsp_vsnprintf(buf, (int)buf_size, fmt, args);
#else
int w = vsnprintf(buf, buf_size, fmt, args);
#endif
if (buf == NULL)
return w;
if (w == -1 || w >= (int)buf_size)
w = (int)buf_size - 1;
buf[w] = 0;
return w;
}
#endif // #ifdef IMGUI_DISABLE_FORMAT_STRING_FUNCTIONS
// CRC32 needs a 1KB lookup table (not cache friendly)
// Although the code to generate the table is simple and shorter than the table itself, using a const table allows us to easily:
// - avoid an unnecessary branch/memory tap, - keep the ImHashXXX functions usable by static constructors, - make it thread-safe.
static const ImU32 GCrc32LookupTable[256] =
{
0x00000000,0x77073096,0xEE0E612C,0x990951BA,0x076DC419,0x706AF48F,0xE963A535,0x9E6495A3,0x0EDB8832,0x79DCB8A4,0xE0D5E91E,0x97D2D988,0x09B64C2B,0x7EB17CBD,0xE7B82D07,0x90BF1D91,
0x1DB71064,0x6AB020F2,0xF3B97148,0x84BE41DE,0x1ADAD47D,0x6DDDE4EB,0xF4D4B551,0x83D385C7,0x136C9856,0x646BA8C0,0xFD62F97A,0x8A65C9EC,0x14015C4F,0x63066CD9,0xFA0F3D63,0x8D080DF5,
0x3B6E20C8,0x4C69105E,0xD56041E4,0xA2677172,0x3C03E4D1,0x4B04D447,0xD20D85FD,0xA50AB56B,0x35B5A8FA,0x42B2986C,0xDBBBC9D6,0xACBCF940,0x32D86CE3,0x45DF5C75,0xDCD60DCF,0xABD13D59,
0x26D930AC,0x51DE003A,0xC8D75180,0xBFD06116,0x21B4F4B5,0x56B3C423,0xCFBA9599,0xB8BDA50F,0x2802B89E,0x5F058808,0xC60CD9B2,0xB10BE924,0x2F6F7C87,0x58684C11,0xC1611DAB,0xB6662D3D,
0x76DC4190,0x01DB7106,0x98D220BC,0xEFD5102A,0x71B18589,0x06B6B51F,0x9FBFE4A5,0xE8B8D433,0x7807C9A2,0x0F00F934,0x9609A88E,0xE10E9818,0x7F6A0DBB,0x086D3D2D,0x91646C97,0xE6635C01,
0x6B6B51F4,0x1C6C6162,0x856530D8,0xF262004E,0x6C0695ED,0x1B01A57B,0x8208F4C1,0xF50FC457,0x65B0D9C6,0x12B7E950,0x8BBEB8EA,0xFCB9887C,0x62DD1DDF,0x15DA2D49,0x8CD37CF3,0xFBD44C65,
0x4DB26158,0x3AB551CE,0xA3BC0074,0xD4BB30E2,0x4ADFA541,0x3DD895D7,0xA4D1C46D,0xD3D6F4FB,0x4369E96A,0x346ED9FC,0xAD678846,0xDA60B8D0,0x44042D73,0x33031DE5,0xAA0A4C5F,0xDD0D7CC9,
0x5005713C,0x270241AA,0xBE0B1010,0xC90C2086,0x5768B525,0x206F85B3,0xB966D409,0xCE61E49F,0x5EDEF90E,0x29D9C998,0xB0D09822,0xC7D7A8B4,0x59B33D17,0x2EB40D81,0xB7BD5C3B,0xC0BA6CAD,
0xEDB88320,0x9ABFB3B6,0x03B6E20C,0x74B1D29A,0xEAD54739,0x9DD277AF,0x04DB2615,0x73DC1683,0xE3630B12,0x94643B84,0x0D6D6A3E,0x7A6A5AA8,0xE40ECF0B,0x9309FF9D,0x0A00AE27,0x7D079EB1,
0xF00F9344,0x8708A3D2,0x1E01F268,0x6906C2FE,0xF762575D,0x806567CB,0x196C3671,0x6E6B06E7,0xFED41B76,0x89D32BE0,0x10DA7A5A,0x67DD4ACC,0xF9B9DF6F,0x8EBEEFF9,0x17B7BE43,0x60B08ED5,
0xD6D6A3E8,0xA1D1937E,0x38D8C2C4,0x4FDFF252,0xD1BB67F1,0xA6BC5767,0x3FB506DD,0x48B2364B,0xD80D2BDA,0xAF0A1B4C,0x36034AF6,0x41047A60,0xDF60EFC3,0xA867DF55,0x316E8EEF,0x4669BE79,
0xCB61B38C,0xBC66831A,0x256FD2A0,0x5268E236,0xCC0C7795,0xBB0B4703,0x220216B9,0x5505262F,0xC5BA3BBE,0xB2BD0B28,0x2BB45A92,0x5CB36A04,0xC2D7FFA7,0xB5D0CF31,0x2CD99E8B,0x5BDEAE1D,
0x9B64C2B0,0xEC63F226,0x756AA39C,0x026D930A,0x9C0906A9,0xEB0E363F,0x72076785,0x05005713,0x95BF4A82,0xE2B87A14,0x7BB12BAE,0x0CB61B38,0x92D28E9B,0xE5D5BE0D,0x7CDCEFB7,0x0BDBDF21,
0x86D3D2D4,0xF1D4E242,0x68DDB3F8,0x1FDA836E,0x81BE16CD,0xF6B9265B,0x6FB077E1,0x18B74777,0x88085AE6,0xFF0F6A70,0x66063BCA,0x11010B5C,0x8F659EFF,0xF862AE69,0x616BFFD3,0x166CCF45,
0xA00AE278,0xD70DD2EE,0x4E048354,0x3903B3C2,0xA7672661,0xD06016F7,0x4969474D,0x3E6E77DB,0xAED16A4A,0xD9D65ADC,0x40DF0B66,0x37D83BF0,0xA9BCAE53,0xDEBB9EC5,0x47B2CF7F,0x30B5FFE9,
0xBDBDF21C,0xCABAC28A,0x53B39330,0x24B4A3A6,0xBAD03605,0xCDD70693,0x54DE5729,0x23D967BF,0xB3667A2E,0xC4614AB8,0x5D681B02,0x2A6F2B94,0xB40BBE37,0xC30C8EA1,0x5A05DF1B,0x2D02EF8D,
};
// Known size hash
// It is ok to call ImHashData on a string with known length but the ### operator won't be supported.
// FIXME-OPT: Replace with e.g. FNV1a hash? CRC32 pretty much randomly access 1KB. Need to do proper measurements.
ImU32 ImHashData(const void* data_p, size_t data_size, ImU32 seed)
{
ImU32 crc = ~seed;
const unsigned char* data = (const unsigned char*)data_p;
const ImU32* crc32_lut = GCrc32LookupTable;
while (data_size-- != 0)
crc = (crc >> 8) ^ crc32_lut[(crc & 0xFF) ^ *data++];
return ~crc;
}
// Zero-terminated string hash, with support for ### to reset back to seed value
// We support a syntax of "label###id" where only "###id" is included in the hash, and only "label" gets displayed.
// Because this syntax is rarely used we are optimizing for the common case.
// - If we reach ### in the string we discard the hash so far and reset to the seed.
// - We don't do 'current += 2; continue;' after handling ### to keep the code smaller/faster (measured ~10% diff in Debug build)
// FIXME-OPT: Replace with e.g. FNV1a hash? CRC32 pretty much randomly access 1KB. Need to do proper measurements.
ImU32 ImHashStr(const char* data_p, size_t data_size, ImU32 seed)
{
seed = ~seed;
ImU32 crc = seed;
const unsigned char* data = (const unsigned char*)data_p;
const ImU32* crc32_lut = GCrc32LookupTable;
if (data_size != 0)
{
while (data_size-- != 0)
{
unsigned char c = *data++;
if (c == '#' && data_size >= 2 && data[0] == '#' && data[1] == '#')
crc = seed;
crc = (crc >> 8) ^ crc32_lut[(crc & 0xFF) ^ c];
}
}
else
{
while (unsigned char c = *data++)
{
if (c == '#' && data[0] == '#' && data[1] == '#')
crc = seed;
crc = (crc >> 8) ^ crc32_lut[(crc & 0xFF) ^ c];
}
}
return ~crc;
}
FILE* ImFileOpen(const char* filename, const char* mode)
{
#if defined(_WIN32) && !defined(__CYGWIN__) && !defined(__GNUC__)
// We need a fopen() wrapper because MSVC/Windows fopen doesn't handle UTF-8 filenames. Converting both strings from UTF-8 to wchar format (using a single allocation, because we can)
const int filename_wsize = ImTextCountCharsFromUtf8(filename, NULL) + 1;
const int mode_wsize = ImTextCountCharsFromUtf8(mode, NULL) + 1;
ImVector<ImWchar> buf;
buf.resize(filename_wsize + mode_wsize);
ImTextStrFromUtf8(&buf[0], filename_wsize, filename, NULL);
ImTextStrFromUtf8(&buf[filename_wsize], mode_wsize, mode, NULL);
return _wfopen((wchar_t*)&buf[0], (wchar_t*)&buf[filename_wsize]);
#else
return fopen(filename, mode);
#endif
}
// Load file content into memory
// Memory allocated with IM_ALLOC(), must be freed by user using IM_FREE() == ImGui::MemFree()
void* ImFileLoadToMemory(const char* filename, const char* file_open_mode, size_t* out_file_size, int padding_bytes)
{
IM_ASSERT(filename && file_open_mode);
if (out_file_size)
*out_file_size = 0;
FILE* f;
if ((f = ImFileOpen(filename, file_open_mode)) == NULL)
return NULL;
long file_size_signed;
if (fseek(f, 0, SEEK_END) || (file_size_signed = ftell(f)) == -1 || fseek(f, 0, SEEK_SET))
{
fclose(f);
return NULL;
}
size_t file_size = (size_t)file_size_signed;
void* file_data = IM_ALLOC(file_size + padding_bytes);
if (file_data == NULL)
{
fclose(f);
return NULL;
}
if (fread(file_data, 1, file_size, f) != file_size)
{
fclose(f);
IM_FREE(file_data);
return NULL;
}
if (padding_bytes > 0)
memset((void*)(((char*)file_data) + file_size), 0, (size_t)padding_bytes);
fclose(f);
if (out_file_size)
*out_file_size = file_size;
return file_data;
}
//-----------------------------------------------------------------------------
// [SECTION] MISC HELPERS/UTILITIES (ImText* functions)
//-----------------------------------------------------------------------------
// Convert UTF-8 to 32-bits character, process single character input.
// Based on stb_from_utf8() from github.com/nothings/stb/
// We handle UTF-8 decoding error by skipping forward.
int ImTextCharFromUtf8(unsigned int* out_char, const char* in_text, const char* in_text_end)
{
unsigned int c = (unsigned int)-1;
const unsigned char* str = (const unsigned char*)in_text;
if (!(*str & 0x80))
{
c = (unsigned int)(*str++);
*out_char = c;
return 1;
}
if ((*str & 0xe0) == 0xc0)
{
*out_char = 0xFFFD; // will be invalid but not end of string
if (in_text_end && in_text_end - (const char*)str < 2) return 1;
if (*str < 0xc2) return 2;
c = (unsigned int)((*str++ & 0x1f) << 6);
if ((*str & 0xc0) != 0x80) return 2;
c += (*str++ & 0x3f);
*out_char = c;
return 2;
}
if ((*str & 0xf0) == 0xe0)
{
*out_char = 0xFFFD; // will be invalid but not end of string
if (in_text_end && in_text_end - (const char*)str < 3) return 1;
if (*str == 0xe0 && (str[1] < 0xa0 || str[1] > 0xbf)) return 3;
if (*str == 0xed && str[1] > 0x9f) return 3; // str[1] < 0x80 is checked below
c = (unsigned int)((*str++ & 0x0f) << 12);
if ((*str & 0xc0) != 0x80) return 3;
c += (unsigned int)((*str++ & 0x3f) << 6);
if ((*str & 0xc0) != 0x80) return 3;
c += (*str++ & 0x3f);
*out_char = c;
return 3;
}
if ((*str & 0xf8) == 0xf0)
{
*out_char = 0xFFFD; // will be invalid but not end of string
if (in_text_end && in_text_end - (const char*)str < 4) return 1;
if (*str > 0xf4) return 4;
if (*str == 0xf0 && (str[1] < 0x90 || str[1] > 0xbf)) return 4;
if (*str == 0xf4 && str[1] > 0x8f) return 4; // str[1] < 0x80 is checked below
c = (unsigned int)((*str++ & 0x07) << 18);
if ((*str & 0xc0) != 0x80) return 4;
c += (unsigned int)((*str++ & 0x3f) << 12);
if ((*str & 0xc0) != 0x80) return 4;
c += (unsigned int)((*str++ & 0x3f) << 6);
if ((*str & 0xc0) != 0x80) return 4;
c += (*str++ & 0x3f);
// utf-8 encodings of values used in surrogate pairs are invalid
if ((c & 0xFFFFF800) == 0xD800) return 4;
*out_char = c;
return 4;
}
*out_char = 0;
return 0;
}
int ImTextStrFromUtf8(ImWchar* buf, int buf_size, const char* in_text, const char* in_text_end, const char** in_text_remaining)
{
ImWchar* buf_out = buf;
ImWchar* buf_end = buf + buf_size;
while (buf_out < buf_end-1 && (!in_text_end || in_text < in_text_end) && *in_text)
{
unsigned int c;
in_text += ImTextCharFromUtf8(&c, in_text, in_text_end);
if (c == 0)
break;
if (c < 0x10000) // FIXME: Losing characters that don't fit in 2 bytes
*buf_out++ = (ImWchar)c;
}
*buf_out = 0;
if (in_text_remaining)
*in_text_remaining = in_text;
return (int)(buf_out - buf);
}
int ImTextCountCharsFromUtf8(const char* in_text, const char* in_text_end)
{
int char_count = 0;
while ((!in_text_end || in_text < in_text_end) && *in_text)
{
unsigned int c;
in_text += ImTextCharFromUtf8(&c, in_text, in_text_end);
if (c == 0)
break;
if (c < 0x10000)
char_count++;
}
return char_count;
}
// Based on stb_to_utf8() from github.com/nothings/stb/
static inline int ImTextCharToUtf8(char* buf, int buf_size, unsigned int c)
{
if (c < 0x80)
{
buf[0] = (char)c;
return 1;
}
if (c < 0x800)
{
if (buf_size < 2) return 0;
buf[0] = (char)(0xc0 + (c >> 6));
buf[1] = (char)(0x80 + (c & 0x3f));
return 2;
}
if (c >= 0xdc00 && c < 0xe000)
{
return 0;
}
if (c >= 0xd800 && c < 0xdc00)
{
if (buf_size < 4) return 0;
buf[0] = (char)(0xf0 + (c >> 18));
buf[1] = (char)(0x80 + ((c >> 12) & 0x3f));
buf[2] = (char)(0x80 + ((c >> 6) & 0x3f));
buf[3] = (char)(0x80 + ((c ) & 0x3f));
return 4;
}
//else if (c < 0x10000)
{
if (buf_size < 3) return 0;
buf[0] = (char)(0xe0 + (c >> 12));
buf[1] = (char)(0x80 + ((c>> 6) & 0x3f));
buf[2] = (char)(0x80 + ((c ) & 0x3f));
return 3;
}
}
// Not optimal but we very rarely use this function.
int ImTextCountUtf8BytesFromChar(const char* in_text, const char* in_text_end)
{
unsigned int dummy = 0;
return ImTextCharFromUtf8(&dummy, in_text, in_text_end);
}
static inline int ImTextCountUtf8BytesFromChar(unsigned int c)
{
if (c < 0x80) return 1;
if (c < 0x800) return 2;
if (c >= 0xdc00 && c < 0xe000) return 0;
if (c >= 0xd800 && c < 0xdc00) return 4;
return 3;
}
int ImTextStrToUtf8(char* buf, int buf_size, const ImWchar* in_text, const ImWchar* in_text_end)
{
char* buf_out = buf;
const char* buf_end = buf + buf_size;
while (buf_out < buf_end-1 && (!in_text_end || in_text < in_text_end) && *in_text)
{
unsigned int c = (unsigned int)(*in_text++);
if (c < 0x80)
*buf_out++ = (char)c;
else
buf_out += ImTextCharToUtf8(buf_out, (int)(buf_end-buf_out-1), c);
}
*buf_out = 0;
return (int)(buf_out - buf);
}
int ImTextCountUtf8BytesFromStr(const ImWchar* in_text, const ImWchar* in_text_end)
{
int bytes_count = 0;
while ((!in_text_end || in_text < in_text_end) && *in_text)
{
unsigned int c = (unsigned int)(*in_text++);
if (c < 0x80)
bytes_count++;
else
bytes_count += ImTextCountUtf8BytesFromChar(c);
}
return bytes_count;
}
//-----------------------------------------------------------------------------
// [SECTION] MISC HELPERS/UTILTIES (Color functions)
// Note: The Convert functions are early design which are not consistent with other API.
//-----------------------------------------------------------------------------
ImVec4 ImGui::ColorConvertU32ToFloat4(ImU32 in)
{
float s = 1.0f/255.0f;
return ImVec4(
((in >> IM_COL32_R_SHIFT) & 0xFF) * s,
((in >> IM_COL32_G_SHIFT) & 0xFF) * s,
((in >> IM_COL32_B_SHIFT) & 0xFF) * s,
((in >> IM_COL32_A_SHIFT) & 0xFF) * s);
}
ImU32 ImGui::ColorConvertFloat4ToU32(const ImVec4& in)
{
ImU32 out;
out = ((ImU32)IM_F32_TO_INT8_SAT(in.x)) << IM_COL32_R_SHIFT;
out |= ((ImU32)IM_F32_TO_INT8_SAT(in.y)) << IM_COL32_G_SHIFT;
out |= ((ImU32)IM_F32_TO_INT8_SAT(in.z)) << IM_COL32_B_SHIFT;
out |= ((ImU32)IM_F32_TO_INT8_SAT(in.w)) << IM_COL32_A_SHIFT;
return out;
}
// Convert rgb floats ([0-1],[0-1],[0-1]) to hsv floats ([0-1],[0-1],[0-1]), from Foley & van Dam p592
// Optimized http://lolengine.net/blog/2013/01/13/fast-rgb-to-hsv
void ImGui::ColorConvertRGBtoHSV(float r, float g, float b, float& out_h, float& out_s, float& out_v)
{
float K = 0.f;
if (g < b)
{
ImSwap(g, b);
K = -1.f;
}
if (r < g)
{
ImSwap(r, g);
K = -2.f / 6.f - K;
}
const float chroma = r - (g < b ? g : b);
out_h = ImFabs(K + (g - b) / (6.f * chroma + 1e-20f));
out_s = chroma / (r + 1e-20f);
out_v = r;
}
// Convert hsv floats ([0-1],[0-1],[0-1]) to rgb floats ([0-1],[0-1],[0-1]), from Foley & van Dam p593
// also http://en.wikipedia.org/wiki/HSL_and_HSV
void ImGui::ColorConvertHSVtoRGB(float h, float s, float v, float& out_r, float& out_g, float& out_b)
{
if (s == 0.0f)
{
// gray
out_r = out_g = out_b = v;
return;
}
h = ImFmod(h, 1.0f) / (60.0f/360.0f);
int i = (int)h;
float f = h - (float)i;
float p = v * (1.0f - s);
float q = v * (1.0f - s * f);
float t = v * (1.0f - s * (1.0f - f));
switch (i)
{
case 0: out_r = v; out_g = t; out_b = p; break;
case 1: out_r = q; out_g = v; out_b = p; break;
case 2: out_r = p; out_g = v; out_b = t; break;
case 3: out_r = p; out_g = q; out_b = v; break;
case 4: out_r = t; out_g = p; out_b = v; break;
case 5: default: out_r = v; out_g = p; out_b = q; break;
}
}
ImU32 ImGui::GetColorU32(ImGuiCol idx, float alpha_mul)
{
ImGuiStyle& style = GImGui->Style;
ImVec4 c = style.Colors[idx];
c.w *= style.Alpha * alpha_mul;
return ColorConvertFloat4ToU32(c);
}
ImU32 ImGui::GetColorU32(const ImVec4& col)
{
ImGuiStyle& style = GImGui->Style;
ImVec4 c = col;
c.w *= style.Alpha;
return ColorConvertFloat4ToU32(c);
}
const ImVec4& ImGui::GetStyleColorVec4(ImGuiCol idx)
{
ImGuiStyle& style = GImGui->Style;
return style.Colors[idx];
}
ImU32 ImGui::GetColorU32(ImU32 col)
{
float style_alpha = GImGui->Style.Alpha;
if (style_alpha >= 1.0f)
return col;
ImU32 a = (col & IM_COL32_A_MASK) >> IM_COL32_A_SHIFT;
a = (ImU32)(a * style_alpha); // We don't need to clamp 0..255 because Style.Alpha is in 0..1 range.
return (col & ~IM_COL32_A_MASK) | (a << IM_COL32_A_SHIFT);
}
//-----------------------------------------------------------------------------
// [SECTION] ImGuiStorage
// Helper: Key->value storage
//-----------------------------------------------------------------------------
// std::lower_bound but without the bullshit
static ImGuiStorage::ImGuiStoragePair* LowerBound(ImVector<ImGuiStorage::ImGuiStoragePair>& data, ImGuiID key)
{
ImGuiStorage::ImGuiStoragePair* first = data.Data;
ImGuiStorage::ImGuiStoragePair* last = data.Data + data.Size;
size_t count = (size_t)(last - first);
while (count > 0)
{
size_t count2 = count >> 1;
ImGuiStorage::ImGuiStoragePair* mid = first + count2;
if (mid->key < key)
{
first = ++mid;
count -= count2 + 1;
}
else
{
count = count2;
}
}
return first;
}
// For quicker full rebuild of a storage (instead of an incremental one), you may add all your contents and then sort once.
void ImGuiStorage::BuildSortByKey()
{
struct StaticFunc
{
static int IMGUI_CDECL PairCompareByID(const void* lhs, const void* rhs)
{
// We can't just do a subtraction because qsort uses signed integers and subtracting our ID doesn't play well with that.
if (((const ImGuiStoragePair*)lhs)->key > ((const ImGuiStoragePair*)rhs)->key) return +1;
if (((const ImGuiStoragePair*)lhs)->key < ((const ImGuiStoragePair*)rhs)->key) return -1;
return 0;
}
};
if (Data.Size > 1)
ImQsort(Data.Data, (size_t)Data.Size, sizeof(ImGuiStoragePair), StaticFunc::PairCompareByID);
}
int ImGuiStorage::GetInt(ImGuiID key, int default_val) const
{
ImGuiStoragePair* it = LowerBound(const_cast<ImVector<ImGuiStoragePair>&>(Data), key);
if (it == Data.end() || it->key != key)
return default_val;
return it->val_i;
}
bool ImGuiStorage::GetBool(ImGuiID key, bool default_val) const
{
return GetInt(key, default_val ? 1 : 0) != 0;
}
float ImGuiStorage::GetFloat(ImGuiID key, float default_val) const
{
ImGuiStoragePair* it = LowerBound(const_cast<ImVector<ImGuiStoragePair>&>(Data), key);
if (it == Data.end() || it->key != key)
return default_val;
return it->val_f;
}
void* ImGuiStorage::GetVoidPtr(ImGuiID key) const
{
ImGuiStoragePair* it = LowerBound(const_cast<ImVector<ImGuiStoragePair>&>(Data), key);
if (it == Data.end() || it->key != key)
return NULL;
return it->val_p;
}
// References are only valid until a new value is added to the storage. Calling a Set***() function or a Get***Ref() function invalidates the pointer.
int* ImGuiStorage::GetIntRef(ImGuiID key, int default_val)
{
ImGuiStoragePair* it = LowerBound(Data, key);
if (it == Data.end() || it->key != key)
it = Data.insert(it, ImGuiStoragePair(key, default_val));
return &it->val_i;
}
bool* ImGuiStorage::GetBoolRef(ImGuiID key, bool default_val)
{
return (bool*)GetIntRef(key, default_val ? 1 : 0);
}
float* ImGuiStorage::GetFloatRef(ImGuiID key, float default_val)
{
ImGuiStoragePair* it = LowerBound(Data, key);
if (it == Data.end() || it->key != key)
it = Data.insert(it, ImGuiStoragePair(key, default_val));
return &it->val_f;
}
void** ImGuiStorage::GetVoidPtrRef(ImGuiID key, void* default_val)
{
ImGuiStoragePair* it = LowerBound(Data, key);
if (it == Data.end() || it->key != key)
it = Data.insert(it, ImGuiStoragePair(key, default_val));
return &it->val_p;
}
// FIXME-OPT: Need a way to reuse the result of lower_bound when doing GetInt()/SetInt() - not too bad because it only happens on explicit interaction (maximum one a frame)
void ImGuiStorage::SetInt(ImGuiID key, int val)
{
ImGuiStoragePair* it = LowerBound(Data, key);
if (it == Data.end() || it->key != key)
{
Data.insert(it, ImGuiStoragePair(key, val));
return;
}
it->val_i = val;
}
void ImGuiStorage::SetBool(ImGuiID key, bool val)
{
SetInt(key, val ? 1 : 0);
}
void ImGuiStorage::SetFloat(ImGuiID key, float val)
{
ImGuiStoragePair* it = LowerBound(Data, key);
if (it == Data.end() || it->key != key)
{
Data.insert(it, ImGuiStoragePair(key, val));
return;
}
it->val_f = val;
}
void ImGuiStorage::SetVoidPtr(ImGuiID key, void* val)
{
ImGuiStoragePair* it = LowerBound(Data, key);
if (it == Data.end() || it->key != key)
{
Data.insert(it, ImGuiStoragePair(key, val));
return;
}
it->val_p = val;
}
void ImGuiStorage::SetAllInt(int v)
{
for (int i = 0; i < Data.Size; i++)
Data[i].val_i = v;
}
//-----------------------------------------------------------------------------
// [SECTION] ImGuiTextFilter
//-----------------------------------------------------------------------------
// Helper: Parse and apply text filters. In format "aaaaa[,bbbb][,ccccc]"
ImGuiTextFilter::ImGuiTextFilter(const char* default_filter)
{
if (default_filter)
{
ImStrncpy(InputBuf, default_filter, IM_ARRAYSIZE(InputBuf));
Build();
}
else
{
InputBuf[0] = 0;
CountGrep = 0;
}
}
bool ImGuiTextFilter::Draw(const char* label, float width)
{
if (width != 0.0f)
ImGui::SetNextItemWidth(width);
bool value_changed = ImGui::InputText(label, InputBuf, IM_ARRAYSIZE(InputBuf));
if (value_changed)
Build();
return value_changed;
}
void ImGuiTextFilter::ImGuiTextRange::split(char separator, ImVector<ImGuiTextRange>* out) const
{
out->resize(0);
const char* wb = b;
const char* we = wb;
while (we < e)
{
if (*we == separator)
{
out->push_back(ImGuiTextRange(wb, we));
wb = we + 1;
}
we++;
}
if (wb != we)
out->push_back(ImGuiTextRange(wb, we));
}
void ImGuiTextFilter::Build()
{
Filters.resize(0);
ImGuiTextRange input_range(InputBuf, InputBuf+strlen(InputBuf));
input_range.split(',', &Filters);
CountGrep = 0;
for (int i = 0; i != Filters.Size; i++)
{
ImGuiTextRange& f = Filters[i];
while (f.b < f.e && ImCharIsBlankA(f.b[0]))
f.b++;
while (f.e > f.b && ImCharIsBlankA(f.e[-1]))
f.e--;
if (f.empty())
continue;
if (Filters[i].b[0] != '-')
CountGrep += 1;
}
}
bool ImGuiTextFilter::PassFilter(const char* text, const char* text_end) const
{
if (Filters.empty())
return true;
if (text == NULL)
text = "";
for (int i = 0; i != Filters.Size; i++)
{
const ImGuiTextRange& f = Filters[i];
if (f.empty())
continue;
if (f.b[0] == '-')
{
// Subtract
if (ImStristr(text, text_end, f.b + 1, f.e) != NULL)
return false;
}
else
{
// Grep
if (ImStristr(text, text_end, f.b, f.e) != NULL)
return true;
}
}
// Implicit * grep
if (CountGrep == 0)
return true;
return false;
}
//-----------------------------------------------------------------------------
// [SECTION] ImGuiTextBuffer
//-----------------------------------------------------------------------------
// On some platform vsnprintf() takes va_list by reference and modifies it.
// va_copy is the 'correct' way to copy a va_list but Visual Studio prior to 2013 doesn't have it.
#ifndef va_copy
#if defined(__GNUC__) || defined(__clang__)
#define va_copy(dest, src) __builtin_va_copy(dest, src)
#else
#define va_copy(dest, src) (dest = src)
#endif
#endif
char ImGuiTextBuffer::EmptyString[1] = { 0 };
void ImGuiTextBuffer::append(const char* str, const char* str_end)
{
int len = str_end ? (int)(str_end - str) : (int)strlen(str);
// Add zero-terminator the first time
const int write_off = (Buf.Size != 0) ? Buf.Size : 1;
const int needed_sz = write_off + len;
if (write_off + len >= Buf.Capacity)
{
int new_capacity = Buf.Capacity * 2;
Buf.reserve(needed_sz > new_capacity ? needed_sz : new_capacity);
}
Buf.resize(needed_sz);
memcpy(&Buf[write_off - 1], str, (size_t)len);
Buf[write_off - 1 + len] = 0;
}
void ImGuiTextBuffer::appendf(const char* fmt, ...)
{
va_list args;
va_start(args, fmt);
appendfv(fmt, args);
va_end(args);
}
// Helper: Text buffer for logging/accumulating text
void ImGuiTextBuffer::appendfv(const char* fmt, va_list args)
{
va_list args_copy;
va_copy(args_copy, args);
int len = ImFormatStringV(NULL, 0, fmt, args); // FIXME-OPT: could do a first pass write attempt, likely successful on first pass.
if (len <= 0)
{
va_end(args_copy);
return;
}
// Add zero-terminator the first time
const int write_off = (Buf.Size != 0) ? Buf.Size : 1;
const int needed_sz = write_off + len;
if (write_off + len >= Buf.Capacity)
{
int new_capacity = Buf.Capacity * 2;
Buf.reserve(needed_sz > new_capacity ? needed_sz : new_capacity);
}
Buf.resize(needed_sz);
ImFormatStringV(&Buf[write_off - 1], (size_t)len + 1, fmt, args_copy);
va_end(args_copy);
}
//-----------------------------------------------------------------------------
// [SECTION] ImGuiListClipper
// This is currently not as flexible/powerful as it should be and really confusing/spaghetti, mostly because we changed
// the API mid-way through development and support two ways to using the clipper, needs some rework (see TODO)
//-----------------------------------------------------------------------------
// Helper to calculate coarse clipping of large list of evenly sized items.
// NB: Prefer using the ImGuiListClipper higher-level helper if you can! Read comments and instructions there on how those use this sort of pattern.
// NB: 'items_count' is only used to clamp the result, if you don't know your count you can use INT_MAX
void ImGui::CalcListClipping(int items_count, float items_height, int* out_items_display_start, int* out_items_display_end)
{
ImGuiContext& g = *GImGui;
ImGuiWindow* window = g.CurrentWindow;
if (g.LogEnabled)
{
// If logging is active, do not perform any clipping
*out_items_display_start = 0;
*out_items_display_end = items_count;
return;
}
if (window->SkipItems)
{
*out_items_display_start = *out_items_display_end = 0;
return;
}
// We create the union of the ClipRect and the NavScoringRect which at worst should be 1 page away from ClipRect
ImRect unclipped_rect = window->ClipRect;
if (g.NavMoveRequest)
unclipped_rect.Add(g.NavScoringRectScreen);
const ImVec2 pos = window->DC.CursorPos;
int start = (int)((unclipped_rect.Min.y - pos.y) / items_height);
int end = (int)((unclipped_rect.Max.y - pos.y) / items_height);
// When performing a navigation request, ensure we have one item extra in the direction we are moving to
if (g.NavMoveRequest && g.NavMoveClipDir == ImGuiDir_Up)
start--;
if (g.NavMoveRequest && g.NavMoveClipDir == ImGuiDir_Down)
end++;
start = ImClamp(start, 0, items_count);
end = ImClamp(end + 1, start, items_count);
*out_items_display_start = start;
*out_items_display_end = end;
}
static void SetCursorPosYAndSetupDummyPrevLine(float pos_y, float line_height)
{
// Set cursor position and a few other things so that SetScrollHereY() and Columns() can work when seeking cursor.
// FIXME: It is problematic that we have to do that here, because custom/equivalent end-user code would stumble on the same issue.
// The clipper should probably have a 4th step to display the last item in a regular manner.
ImGuiContext& g = *GImGui;
ImGuiWindow* window = g.CurrentWindow;
window->DC.CursorPos.y = pos_y;
window->DC.CursorMaxPos.y = ImMax(window->DC.CursorMaxPos.y, pos_y);
window->DC.CursorPosPrevLine.y = window->DC.CursorPos.y - line_height; // Setting those fields so that SetScrollHereY() can properly function after the end of our clipper usage.
window->DC.PrevLineSize.y = (line_height - g.Style.ItemSpacing.y); // If we end up needing more accurate data (to e.g. use SameLine) we may as well make the clipper have a fourth step to let user process and display the last item in their list.
if (ImGuiColumns* columns = window->DC.CurrentColumns)
columns->LineMinY = window->DC.CursorPos.y; // Setting this so that cell Y position are set properly
}
// Use case A: Begin() called from constructor with items_height<0, then called again from Sync() in StepNo 1
// Use case B: Begin() called from constructor with items_height>0
// FIXME-LEGACY: Ideally we should remove the Begin/End functions but they are part of the legacy API we still support. This is why some of the code in Step() calling Begin() and reassign some fields, spaghetti style.
void ImGuiListClipper::Begin(int count, float items_height)
{
ImGuiContext& g = *GImGui;
ImGuiWindow* window = g.CurrentWindow;
StartPosY = window->DC.CursorPos.y;
ItemsHeight = items_height;
ItemsCount = count;
StepNo = 0;
DisplayEnd = DisplayStart = -1;
if (ItemsHeight > 0.0f)
{
ImGui::CalcListClipping(ItemsCount, ItemsHeight, &DisplayStart, &DisplayEnd); // calculate how many to clip/display
if (DisplayStart > 0)
SetCursorPosYAndSetupDummyPrevLine(StartPosY + DisplayStart * ItemsHeight, ItemsHeight); // advance cursor
StepNo = 2;
}
}
void ImGuiListClipper::End()
{
if (ItemsCount < 0)
return;
// In theory here we should assert that ImGui::GetCursorPosY() == StartPosY + DisplayEnd * ItemsHeight, but it feels saner to just seek at the end and not assert/crash the user.
if (ItemsCount < INT_MAX)
SetCursorPosYAndSetupDummyPrevLine(StartPosY + ItemsCount * ItemsHeight, ItemsHeight); // advance cursor
ItemsCount = -1;
StepNo = 3;
}
bool ImGuiListClipper::Step()
{
ImGuiContext& g = *GImGui;
ImGuiWindow* window = g.CurrentWindow;
if (ItemsCount == 0 || window->SkipItems)
{
ItemsCount = -1;
return false;
}
if (StepNo == 0) // Step 0: the clipper let you process the first element, regardless of it being visible or not, so we can measure the element height.
{
DisplayStart = 0;
DisplayEnd = 1;
StartPosY = window->DC.CursorPos.y;
StepNo = 1;
return true;
}
if (StepNo == 1) // Step 1: the clipper infer height from first element, calculate the actual range of elements to display, and position the cursor before the first element.
{
if (ItemsCount == 1) { ItemsCount = -1; return false; }
float items_height = window->DC.CursorPos.y - StartPosY;
IM_ASSERT(items_height > 0.0f); // If this triggers, it means Item 0 hasn't moved the cursor vertically
Begin(ItemsCount - 1, items_height);
DisplayStart++;
DisplayEnd++;
StepNo = 3;
return true;
}
if (StepNo == 2) // Step 2: dummy step only required if an explicit items_height was passed to constructor or Begin() and user still call Step(). Does nothing and switch to Step 3.
{
IM_ASSERT(DisplayStart >= 0 && DisplayEnd >= 0);
StepNo = 3;
return true;
}
if (StepNo == 3) // Step 3: the clipper validate that we have reached the expected Y position (corresponding to element DisplayEnd), advance the cursor to the end of the list and then returns 'false' to end the loop.
End();
return false;
}
//-----------------------------------------------------------------------------
// [SECTION] RENDER HELPERS
// Those (internal) functions are currently quite a legacy mess - their signature and behavior will change.
// Also see imgui_draw.cpp for some more which have been reworked to not rely on ImGui:: state.
//-----------------------------------------------------------------------------
const char* ImGui::FindRenderedTextEnd(const char* text, const char* text_end)
{
const char* text_display_end = text;
if (!text_end)
text_end = (const char*)-1;
while (text_display_end < text_end && *text_display_end != '\0' && (text_display_end[0] != '#' || text_display_end[1] != '#'))
text_display_end++;
return text_display_end;
}
// Internal ImGui functions to render text
// RenderText***() functions calls ImDrawList::AddText() calls ImBitmapFont::RenderText()
void ImGui::RenderText(ImVec2 pos, const char* text, const char* text_end, bool hide_text_after_hash)
{
ImGuiContext& g = *GImGui;
ImGuiWindow* window = g.CurrentWindow;
// Hide anything after a '##' string
const char* text_display_end;
if (hide_text_after_hash)
{
text_display_end = FindRenderedTextEnd(text, text_end);
}
else
{
if (!text_end)
text_end = text + strlen(text); // FIXME-OPT
text_display_end = text_end;
}
if (text != text_display_end)
{
window->DrawList->AddText(g.Font, g.FontSize, pos, GetColorU32(ImGuiCol_Text), text, text_display_end);
if (g.LogEnabled)
LogRenderedText(&pos, text, text_display_end);
}
}
void ImGui::RenderTextWrapped(ImVec2 pos, const char* text, const char* text_end, float wrap_width)
{
ImGuiContext& g = *GImGui;
ImGuiWindow* window = g.CurrentWindow;
if (!text_end)
text_end = text + strlen(text); // FIXME-OPT
if (text != text_end)
{
window->DrawList->AddText(g.Font, g.FontSize, pos, GetColorU32(ImGuiCol_Text), text, text_end, wrap_width);
if (g.LogEnabled)
LogRenderedText(&pos, text, text_end);
}
}
// Default clip_rect uses (pos_min,pos_max)
// Handle clipping on CPU immediately (vs typically let the GPU clip the triangles that are overlapping the clipping rectangle edges)
void ImGui::RenderTextClippedEx(ImDrawList* draw_list, const ImVec2& pos_min, const ImVec2& pos_max, const char* text, const char* text_display_end, const ImVec2* text_size_if_known, const ImVec2& align, const ImRect* clip_rect)
{
// Perform CPU side clipping for single clipped element to avoid using scissor state
ImVec2 pos = pos_min;
const ImVec2 text_size = text_size_if_known ? *text_size_if_known : CalcTextSize(text, text_display_end, false, 0.0f);
const ImVec2* clip_min = clip_rect ? &clip_rect->Min : &pos_min;
const ImVec2* clip_max = clip_rect ? &clip_rect->Max : &pos_max;
bool need_clipping = (pos.x + text_size.x >= clip_max->x) || (pos.y + text_size.y >= clip_max->y);
if (clip_rect) // If we had no explicit clipping rectangle then pos==clip_min
need_clipping |= (pos.x < clip_min->x) || (pos.y < clip_min->y);
// Align whole block. We should defer that to the better rendering function when we'll have support for individual line alignment.
if (align.x > 0.0f) pos.x = ImMax(pos.x, pos.x + (pos_max.x - pos.x - text_size.x) * align.x);
if (align.y > 0.0f) pos.y = ImMax(pos.y, pos.y + (pos_max.y - pos.y - text_size.y) * align.y);
// Render
if (need_clipping)
{
ImVec4 fine_clip_rect(clip_min->x, clip_min->y, clip_max->x, clip_max->y);
draw_list->AddText(NULL, 0.0f, pos, GetColorU32(ImGuiCol_Text), text, text_display_end, 0.0f, &fine_clip_rect);
}
else
{
draw_list->AddText(NULL, 0.0f, pos, GetColorU32(ImGuiCol_Text), text, text_display_end, 0.0f, NULL);
}
}
void ImGui::RenderTextClipped(const ImVec2& pos_min, const ImVec2& pos_max, const char* text, const char* text_end, const ImVec2* text_size_if_known, const ImVec2& align, const ImRect* clip_rect)
{
// Hide anything after a '##' string
const char* text_display_end = FindRenderedTextEnd(text, text_end);
const int text_len = (int)(text_display_end - text);
if (text_len == 0)
return;
ImGuiContext& g = *GImGui;
ImGuiWindow* window = g.CurrentWindow;
RenderTextClippedEx(window->DrawList, pos_min, pos_max, text, text_display_end, text_size_if_known, align, clip_rect);
if (g.LogEnabled)
LogRenderedText(&pos_min, text, text_display_end);
}
// Another overly complex function until we reorganize everything into a nice all-in-one helper.
// This is made more complex because we have dissociated the layout rectangle (pos_min..pos_max) which define _where_ the ellipsis is, from actual clipping of text and limit of the ellipsis display.
// This is because in the context of tabs we selectively hide part of the text when the Close Button appears, but we don't want the ellipsis to move.
void ImGui::RenderTextEllipsis(ImDrawList* draw_list, const ImVec2& pos_min, const ImVec2& pos_max, float clip_max_x, float ellipsis_max_x, const char* text, const char* text_end_full, const ImVec2* text_size_if_known)
{
ImGuiContext& g = *GImGui;
if (text_end_full == NULL)
text_end_full = FindRenderedTextEnd(text);
const ImVec2 text_size = text_size_if_known ? *text_size_if_known : CalcTextSize(text, text_end_full, false, 0.0f);
if (text_size.x > pos_max.x - pos_min.x)
{
// Hello wo...
// | | |
// min max ellipsis_max
// <-> this is generally some padding value
// FIXME-STYLE: RenderPixelEllipsis() style should use actual font data.
const ImFont* font = draw_list->_Data->Font;
const float font_size = draw_list->_Data->FontSize;
const int ellipsis_dot_count = 3;
const float ellipsis_width = (1.0f + 1.0f) * ellipsis_dot_count - 1.0f;
const char* text_end_ellipsis = NULL;
float text_width = ImMax((pos_max.x - ellipsis_width) - pos_min.x, 1.0f);
float text_size_clipped_x = font->CalcTextSizeA(font_size, text_width, 0.0f, text, text_end_full, &text_end_ellipsis).x;
if (text == text_end_ellipsis && text_end_ellipsis < text_end_full)
{
// Always display at least 1 character if there's no room for character + ellipsis
text_end_ellipsis = text + ImTextCountUtf8BytesFromChar(text, text_end_full);
text_size_clipped_x = font->CalcTextSizeA(font_size, FLT_MAX, 0.0f, text, text_end_ellipsis).x;
}
while (text_end_ellipsis > text && ImCharIsBlankA(text_end_ellipsis[-1]))
{
// Trim trailing space before ellipsis
text_end_ellipsis--;
text_size_clipped_x -= font->CalcTextSizeA(font_size, FLT_MAX, 0.0f, text_end_ellipsis, text_end_ellipsis + 1).x; // Ascii blanks are always 1 byte
}
RenderTextClippedEx(draw_list, pos_min, ImVec2(clip_max_x, pos_max.y), text, text_end_ellipsis, &text_size, ImVec2(0.0f, 0.0f));
const float ellipsis_x = pos_min.x + text_size_clipped_x + 1.0f;
if (ellipsis_x + ellipsis_width - 1.0f <= ellipsis_max_x)
RenderPixelEllipsis(draw_list, ImVec2(ellipsis_x, pos_min.y), GetColorU32(ImGuiCol_Text), ellipsis_dot_count);
}
else
{
RenderTextClippedEx(draw_list, pos_min, ImVec2(clip_max_x, pos_max.y), text, text_end_full, &text_size, ImVec2(0.0f, 0.0f));
}
if (g.LogEnabled)
LogRenderedText(&pos_min, text, text_end_full);
}
// Render a rectangle shaped with optional rounding and borders
void ImGui::RenderFrame(ImVec2 p_min, ImVec2 p_max, ImU32 fill_col, bool border, float rounding)
{
ImGuiContext& g = *GImGui;
ImGuiWindow* window = g.CurrentWindow;
window->DrawList->AddRectFilled(p_min, p_max, fill_col, rounding);
const float border_size = g.Style.FrameBorderSize;
if (border && border_size > 0.0f)
{
window->DrawList->AddRect(p_min+ImVec2(1,1), p_max+ImVec2(1,1), GetColorU32(ImGuiCol_BorderShadow), rounding, ImDrawCornerFlags_All, border_size);
window->DrawList->AddRect(p_min, p_max, GetColorU32(ImGuiCol_Border), rounding, ImDrawCornerFlags_All, border_size);
}
}
void ImGui::RenderFrameBorder(ImVec2 p_min, ImVec2 p_max, float rounding)
{
ImGuiContext& g = *GImGui;
ImGuiWindow* window = g.CurrentWindow;
const float border_size = g.Style.FrameBorderSize;
if (border_size > 0.0f)
{
window->DrawList->AddRect(p_min+ImVec2(1,1), p_max+ImVec2(1,1), GetColorU32(ImGuiCol_BorderShadow), rounding, ImDrawCornerFlags_All, border_size);
window->DrawList->AddRect(p_min, p_max, GetColorU32(ImGuiCol_Border), rounding, ImDrawCornerFlags_All, border_size);
}
}
// Render an arrow aimed to be aligned with text (p_min is a position in the same space text would be positioned). To e.g. denote expanded/collapsed state
void ImGui::RenderArrow(ImDrawList* draw_list, ImVec2 pos, ImU32 col, ImGuiDir dir, float scale)
{
const float h = draw_list->_Data->FontSize * 1.00f;
float r = h * 0.40f * scale;
ImVec2 center = pos + ImVec2(h * 0.50f, h * 0.50f * scale);
ImVec2 a, b, c;
switch (dir)
{
case ImGuiDir_Up:
case ImGuiDir_Down:
if (dir == ImGuiDir_Up) r = -r;
a = ImVec2(+0.000f,+0.750f) * r;
b = ImVec2(-0.866f,-0.750f) * r;
c = ImVec2(+0.866f,-0.750f) * r;
break;
case ImGuiDir_Left:
case ImGuiDir_Right:
if (dir == ImGuiDir_Left) r = -r;
a = ImVec2(+0.750f,+0.000f) * r;
b = ImVec2(-0.750f,+0.866f) * r;
c = ImVec2(-0.750f,-0.866f) * r;
break;
case ImGuiDir_None:
case ImGuiDir_COUNT:
IM_ASSERT(0);
break;
}
draw_list->AddTriangleFilled(center + a, center + b, center + c, col);
}
void ImGui::RenderBullet(ImDrawList* draw_list, ImVec2 pos, ImU32 col)
{
draw_list->AddCircleFilled(pos, draw_list->_Data->FontSize * 0.20f, col, 8);
}
void ImGui::RenderCheckMark(ImVec2 pos, ImU32 col, float sz)
{
ImGuiContext& g = *GImGui;
ImGuiWindow* window = g.CurrentWindow;
float thickness = ImMax(sz / 5.0f, 1.0f);
sz -= thickness*0.5f;
pos += ImVec2(thickness*0.25f, thickness*0.25f);
float third = sz / 3.0f;
float bx = pos.x + third;
float by = pos.y + sz - third*0.5f;
window->DrawList->PathLineTo(ImVec2(bx - third, by - third));
window->DrawList->PathLineTo(ImVec2(bx, by));
window->DrawList->PathLineTo(ImVec2(bx + third*2, by - third*2));
window->DrawList->PathStroke(col, false, thickness);
}
void ImGui::RenderNavHighlight(const ImRect& bb, ImGuiID id, ImGuiNavHighlightFlags flags)
{
ImGuiContext& g = *GImGui;
if (id != g.NavId)
return;
if (g.NavDisableHighlight && !(flags & ImGuiNavHighlightFlags_AlwaysDraw))
return;
ImGuiWindow* window = g.CurrentWindow;
if (window->DC.NavHideHighlightOneFrame)
return;
float rounding = (flags & ImGuiNavHighlightFlags_NoRounding) ? 0.0f : g.Style.FrameRounding;
ImRect display_rect = bb;
display_rect.ClipWith(window->ClipRect);
if (flags & ImGuiNavHighlightFlags_TypeDefault)
{
const float THICKNESS = 2.0f;
const float DISTANCE = 3.0f + THICKNESS * 0.5f;
display_rect.Expand(ImVec2(DISTANCE,DISTANCE));
bool fully_visible = window->ClipRect.Contains(display_rect);
if (!fully_visible)
window->DrawList->PushClipRect(display_rect.Min, display_rect.Max);
window->DrawList->AddRect(display_rect.Min + ImVec2(THICKNESS*0.5f,THICKNESS*0.5f), display_rect.Max - ImVec2(THICKNESS*0.5f,THICKNESS*0.5f), GetColorU32(ImGuiCol_NavHighlight), rounding, ImDrawCornerFlags_All, THICKNESS);
if (!fully_visible)
window->DrawList->PopClipRect();
}
if (flags & ImGuiNavHighlightFlags_TypeThin)
{
window->DrawList->AddRect(display_rect.Min, display_rect.Max, GetColorU32(ImGuiCol_NavHighlight), rounding, ~0, 1.0f);
}
}
//-----------------------------------------------------------------------------
// [SECTION] MAIN CODE (most of the code! lots of stuff, needs tidying up!)
//-----------------------------------------------------------------------------
// ImGuiWindow is mostly a dumb struct. It merely has a constructor and a few helper methods
ImGuiWindow::ImGuiWindow(ImGuiContext* context, const char* name)
: DrawListInst(&context->DrawListSharedData)
{
Name = ImStrdup(name);
ID = ImHashStr(name);
IDStack.push_back(ID);
Flags = FlagsPreviousFrame = ImGuiWindowFlags_None;
Viewport = NULL;
ViewportId = 0;
ViewportAllowPlatformMonitorExtend = -1;
ViewportPos = ImVec2(FLT_MAX, FLT_MAX);
Pos = ImVec2(0.0f, 0.0f);
Size = SizeFull = ImVec2(0.0f, 0.0f);
ContentSize = ContentSizeExplicit = ImVec2(0.0f, 0.0f);
WindowPadding = ImVec2(0.0f, 0.0f);
WindowRounding = 0.0f;
WindowBorderSize = 0.0f;
NameBufLen = (int)strlen(name) + 1;
MoveId = GetID("#MOVE");
ChildId = 0;
Scroll = ImVec2(0.0f, 0.0f);
ScrollTarget = ImVec2(FLT_MAX, FLT_MAX);
ScrollTargetCenterRatio = ImVec2(0.5f, 0.5f);
ScrollbarSizes = ImVec2(0.0f, 0.0f);
ScrollbarX = ScrollbarY = false;
ViewportOwned = false;
Active = WasActive = false;
WriteAccessed = false;
Collapsed = false;
WantCollapseToggle = false;
SkipItems = false;
Appearing = false;
Hidden = false;
IsFallbackWindow = false;
HasCloseButton = false;
ResizeBorderHeld = -1;
BeginCount = 0;
BeginOrderWithinParent = -1;
BeginOrderWithinContext = -1;
PopupId = 0;
AutoFitFramesX = AutoFitFramesY = -1;
AutoFitOnlyGrows = false;
AutoFitChildAxises = 0x00;
AutoPosLastDirection = ImGuiDir_None;
HiddenFramesCanSkipItems = HiddenFramesCannotSkipItems = 0;
SetWindowPosAllowFlags = SetWindowSizeAllowFlags = SetWindowCollapsedAllowFlags = SetWindowDockAllowFlags = ImGuiCond_Always | ImGuiCond_Once | ImGuiCond_FirstUseEver | ImGuiCond_Appearing;
SetWindowPosVal = SetWindowPosPivot = ImVec2(FLT_MAX, FLT_MAX);
LastFrameActive = -1;
LastFrameJustFocused = -1;
ItemWidthDefault = 0.0f;
FontWindowScale = FontDpiScale = 1.0f;
SettingsIdx = -1;
DrawList = &DrawListInst;
DrawList->_OwnerName = Name;
ParentWindow = NULL;
RootWindow = NULL;
RootWindowDockStop = NULL;
RootWindowForTitleBarHighlight = NULL;
RootWindowForNav = NULL;
NavLastIds[0] = NavLastIds[1] = 0;
NavRectRel[0] = NavRectRel[1] = ImRect();
NavLastChildNavWindow = NULL;
DockNode = DockNodeAsHost = NULL;
DockId = 0;
DockTabItemStatusFlags = ImGuiItemStatusFlags_None;
DockOrder = -1;
DockIsActive = DockTabIsVisible = DockTabWantClose = false;
}
ImGuiWindow::~ImGuiWindow()
{
IM_ASSERT(DrawList == &DrawListInst);
IM_DELETE(Name);
for (int i = 0; i != ColumnsStorage.Size; i++)
ColumnsStorage[i].~ImGuiColumns();
}
ImGuiID ImGuiWindow::GetID(const char* str, const char* str_end)
{
ImGuiID seed = IDStack.back();
ImGuiID id = ImHashStr(str, str_end ? (str_end - str) : 0, seed);
ImGui::KeepAliveID(id);
return id;
}
ImGuiID ImGuiWindow::GetID(const void* ptr)
{
ImGuiID seed = IDStack.back();
ImGuiID id = ImHashData(&ptr, sizeof(void*), seed);
ImGui::KeepAliveID(id);
return id;
}
ImGuiID ImGuiWindow::GetID(int n)
{
ImGuiID seed = IDStack.back();
ImGuiID id = ImHashData(&n, sizeof(n), seed);
ImGui::KeepAliveID(id);
return id;
}
ImGuiID ImGuiWindow::GetIDNoKeepAlive(const char* str, const char* str_end)
{
ImGuiID seed = IDStack.back();
return ImHashStr(str, str_end ? (str_end - str) : 0, seed);
}
ImGuiID ImGuiWindow::GetIDNoKeepAlive(const void* ptr)
{
ImGuiID seed = IDStack.back();
return ImHashData(&ptr, sizeof(void*), seed);
}
ImGuiID ImGuiWindow::GetIDNoKeepAlive(int n)
{
ImGuiID seed = IDStack.back();
return ImHashData(&n, sizeof(n), seed);
}
// This is only used in rare/specific situations to manufacture an ID out of nowhere.
ImGuiID ImGuiWindow::GetIDFromRectangle(const ImRect& r_abs)
{
ImGuiID seed = IDStack.back();
const int r_rel[4] = { (int)(r_abs.Min.x - Pos.x), (int)(r_abs.Min.y - Pos.y), (int)(r_abs.Max.x - Pos.x), (int)(r_abs.Max.y - Pos.y) };
ImGuiID id = ImHashData(&r_rel, sizeof(r_rel), seed);
ImGui::KeepAliveID(id);
return id;
}
static void SetCurrentWindow(ImGuiWindow* window)
{
ImGuiContext& g = *GImGui;
g.CurrentWindow = window;
if (window)
g.FontSize = g.DrawListSharedData.FontSize = window->CalcFontSize();
}
void ImGui::SetNavID(ImGuiID id, int nav_layer)
{
ImGuiContext& g = *GImGui;
IM_ASSERT(g.NavWindow);
IM_ASSERT(nav_layer == 0 || nav_layer == 1);
g.NavId = id;
g.NavWindow->NavLastIds[nav_layer] = id;
}
void ImGui::SetNavIDWithRectRel(ImGuiID id, int nav_layer, const ImRect& rect_rel)
{
ImGuiContext& g = *GImGui;
SetNavID(id, nav_layer);
g.NavWindow->NavRectRel[nav_layer] = rect_rel;
g.NavMousePosDirty = true;
g.NavDisableHighlight = false;
g.NavDisableMouseHover = true;
}
void ImGui::SetActiveID(ImGuiID id, ImGuiWindow* window)
{
ImGuiContext& g = *GImGui;
g.ActiveIdIsJustActivated = (g.ActiveId != id);
if (g.ActiveIdIsJustActivated)
{
g.ActiveIdTimer = 0.0f;
g.ActiveIdHasBeenPressedBefore = false;
g.ActiveIdHasBeenEditedBefore = false;
if (id != 0)
{
g.LastActiveId = id;
g.LastActiveIdTimer = 0.0f;
}
}
g.ActiveId = id;
g.ActiveIdAllowNavDirFlags = 0;
g.ActiveIdBlockNavInputFlags = 0;
g.ActiveIdAllowOverlap = false;
g.ActiveIdWindow = window;
g.ActiveIdHasBeenEditedThisFrame = false;
if (id)
{
g.ActiveIdIsAlive = id;
g.ActiveIdSource = (g.NavActivateId == id || g.NavInputId == id || g.NavJustTabbedId == id || g.NavJustMovedToId == id) ? ImGuiInputSource_Nav : ImGuiInputSource_Mouse;
}
}
// FIXME-NAV: The existence of SetNavID/SetNavIDWithRectRel/SetFocusID is incredibly messy and confusing and needs some explanation or refactoring.
void ImGui::SetFocusID(ImGuiID id, ImGuiWindow* window)
{
ImGuiContext& g = *GImGui;
IM_ASSERT(id != 0);
// Assume that SetFocusID() is called in the context where its NavLayer is the current layer, which is the case everywhere we call it.
const ImGuiNavLayer nav_layer = window->DC.NavLayerCurrent;
if (g.NavWindow != window)
g.NavInitRequest = false;
g.NavId = id;
g.NavWindow = window;
g.NavLayer = nav_layer;
window->NavLastIds[nav_layer] = id;
if (window->DC.LastItemId == id)
window->NavRectRel[nav_layer] = ImRect(window->DC.LastItemRect.Min - window->Pos, window->DC.LastItemRect.Max - window->Pos);
if (g.ActiveIdSource == ImGuiInputSource_Nav)
g.NavDisableMouseHover = true;
else
g.NavDisableHighlight = true;
}
void ImGui::ClearActiveID()
{
SetActiveID(0, NULL);
}
void ImGui::SetHoveredID(ImGuiID id)
{
ImGuiContext& g = *GImGui;
g.HoveredId = id;
g.HoveredIdAllowOverlap = false;
if (id != 0 && g.HoveredIdPreviousFrame != id)
g.HoveredIdTimer = g.HoveredIdNotActiveTimer = 0.0f;
}
ImGuiID ImGui::GetHoveredID()
{
ImGuiContext& g = *GImGui;
return g.HoveredId ? g.HoveredId : g.HoveredIdPreviousFrame;
}
void ImGui::KeepAliveID(ImGuiID id)
{
ImGuiContext& g = *GImGui;
if (g.ActiveId == id)
g.ActiveIdIsAlive = id;
if (g.ActiveIdPreviousFrame == id)
g.ActiveIdPreviousFrameIsAlive = true;
}
void ImGui::MarkItemEdited(ImGuiID id)
{
// This marking is solely to be able to provide info for IsItemDeactivatedAfterEdit().
// ActiveId might have been released by the time we call this (as in the typical press/release button behavior) but still need need to fill the data.
ImGuiContext& g = *GImGui;
IM_ASSERT(g.ActiveId == id || g.ActiveId == 0 || g.DragDropActive);
IM_UNUSED(id); // Avoid unused variable warnings when asserts are compiled out.
//IM_ASSERT(g.CurrentWindow->DC.LastItemId == id);
g.ActiveIdHasBeenEditedThisFrame = true;
g.ActiveIdHasBeenEditedBefore = true;
g.CurrentWindow->DC.LastItemStatusFlags |= ImGuiItemStatusFlags_Edited;
}
static inline bool IsWindowContentHoverable(ImGuiWindow* window, ImGuiHoveredFlags flags)
{
// An active popup disable hovering on other windows (apart from its own children)
// FIXME-OPT: This could be cached/stored within the window.
ImGuiContext& g = *GImGui;
if (g.NavWindow)
if (ImGuiWindow* focused_root_window = g.NavWindow->RootWindow)
if (focused_root_window->WasActive && focused_root_window != window->RootWindow)
{
// For the purpose of those flags we differentiate "standard popup" from "modal popup"
// NB: The order of those two tests is important because Modal windows are also Popups.
if (focused_root_window->Flags & ImGuiWindowFlags_Modal)
return false;
if ((focused_root_window->Flags & ImGuiWindowFlags_Popup) && !(flags & ImGuiHoveredFlags_AllowWhenBlockedByPopup))
return false;
}
// Filter by viewport
if (window->Viewport != g.MouseViewport)
if (g.MovingWindow == NULL || window->RootWindow != g.MovingWindow->RootWindow)
return false;
return true;
}
// Advance cursor given item size for layout.
void ImGui::ItemSize(const ImVec2& size, float text_offset_y)
{
ImGuiContext& g = *GImGui;
ImGuiWindow* window = g.CurrentWindow;
if (window->SkipItems)
return;
// Always align ourselves on pixel boundaries
const float line_height = ImMax(window->DC.CurrLineSize.y, size.y);
const float text_base_offset = ImMax(window->DC.CurrLineTextBaseOffset, text_offset_y);
//if (g.IO.KeyAlt) window->DrawList->AddRect(window->DC.CursorPos, window->DC.CursorPos + ImVec2(size.x, line_height), IM_COL32(255,0,0,200)); // [DEBUG]
window->DC.CursorPosPrevLine.x = window->DC.CursorPos.x + size.x;
window->DC.CursorPosPrevLine.y = window->DC.CursorPos.y;
window->DC.CursorPos.x = (float)(int)(window->Pos.x + window->DC.Indent.x + window->DC.ColumnsOffset.x);
window->DC.CursorPos.y = (float)(int)(window->DC.CursorPos.y + line_height + g.Style.ItemSpacing.y);
window->DC.CursorMaxPos.x = ImMax(window->DC.CursorMaxPos.x, window->DC.CursorPosPrevLine.x);
window->DC.CursorMaxPos.y = ImMax(window->DC.CursorMaxPos.y, window->DC.CursorPos.y - g.Style.ItemSpacing.y);
//if (g.IO.KeyAlt) window->DrawList->AddCircle(window->DC.CursorMaxPos, 3.0f, IM_COL32(255,0,0,255), 4); // [DEBUG]
window->DC.PrevLineSize.y = line_height;
window->DC.PrevLineTextBaseOffset = text_base_offset;
window->DC.CurrLineSize.y = window->DC.CurrLineTextBaseOffset = 0.0f;
// Horizontal layout mode
if (window->DC.LayoutType == ImGuiLayoutType_Horizontal)
SameLine();
}
void ImGui::ItemSize(const ImRect& bb, float text_offset_y)
{
ItemSize(bb.GetSize(), text_offset_y);
}
// Declare item bounding box for clipping and interaction.
// Note that the size can be different than the one provided to ItemSize(). Typically, widgets that spread over available surface
// declare their minimum size requirement to ItemSize() and then use a larger region for drawing/interaction, which is passed to ItemAdd().
bool ImGui::ItemAdd(const ImRect& bb, ImGuiID id, const ImRect* nav_bb_arg)
{
ImGuiContext& g = *GImGui;
ImGuiWindow* window = g.CurrentWindow;
if (id != 0)
{
// Navigation processing runs prior to clipping early-out
// (a) So that NavInitRequest can be honored, for newly opened windows to select a default widget
// (b) So that we can scroll up/down past clipped items. This adds a small O(N) cost to regular navigation requests
// unfortunately, but it is still limited to one window. It may not scale very well for windows with ten of
// thousands of item, but at least NavMoveRequest is only set on user interaction, aka maximum once a frame.
// We could early out with "if (is_clipped && !g.NavInitRequest) return false;" but when we wouldn't be able
// to reach unclipped widgets. This would work if user had explicit scrolling control (e.g. mapped on a stick).
// We intentionally don't check if g.NavWindow != NULL because g.NavAnyRequest should only be set when it is non null.
// If we crash on a NULL g.NavWindow we need to fix the bug elsewhere.
window->DC.NavLayerActiveMaskNext |= window->DC.NavLayerCurrentMask;
if (g.NavId == id || g.NavAnyRequest)
if (g.NavWindow->RootWindowForNav == window->RootWindowForNav)
if (window == g.NavWindow || ((window->Flags | g.NavWindow->Flags) & ImGuiWindowFlags_NavFlattened))
NavProcessItem(window, nav_bb_arg ? *nav_bb_arg : bb, id);
// [DEBUG] Item Picker tool, when enabling the "extended" version we perform the check in ItemAdd()
#ifdef IMGUI_DEBUG_TOOL_ITEM_PICKER_EX
if (id == g.DebugItemPickerBreakID)
{
IM_DEBUG_BREAK();
g.DebugItemPickerBreakID = 0;
}
#endif
}
window->DC.LastItemId = id;
window->DC.LastItemRect = bb;
window->DC.LastItemStatusFlags = ImGuiItemStatusFlags_None;
g.NextItemData.Flags = ImGuiNextItemDataFlags_None;
#ifdef IMGUI_ENABLE_TEST_ENGINE
if (id != 0)
IMGUI_TEST_ENGINE_ITEM_ADD(nav_bb_arg ? *nav_bb_arg : bb, id);
#endif
// Clipping test
const bool is_clipped = IsClippedEx(bb, id, false);
if (is_clipped)
return false;
//if (g.IO.KeyAlt) window->DrawList->AddRect(bb.Min, bb.Max, IM_COL32(255,255,0,120)); // [DEBUG]
// We need to calculate this now to take account of the current clipping rectangle (as items like Selectable may change them)
if (IsMouseHoveringRect(bb.Min, bb.Max))
window->DC.LastItemStatusFlags |= ImGuiItemStatusFlags_HoveredRect;
return true;
}
// This is roughly matching the behavior of internal-facing ItemHoverable()
// - we allow hovering to be true when ActiveId==window->MoveID, so that clicking on non-interactive items such as a Text() item still returns true with IsItemHovered()
// - this should work even for non-interactive items that have no ID, so we cannot use LastItemId
bool ImGui::IsItemHovered(ImGuiHoveredFlags flags)
{
ImGuiContext& g = *GImGui;
ImGuiWindow* window = g.CurrentWindow;
if (g.NavDisableMouseHover && !g.NavDisableHighlight)
return IsItemFocused();
// Test for bounding box overlap, as updated as ItemAdd()
if (!(window->DC.LastItemStatusFlags & ImGuiItemStatusFlags_HoveredRect))
return false;
IM_ASSERT((flags & (ImGuiHoveredFlags_RootWindow | ImGuiHoveredFlags_ChildWindows)) == 0); // Flags not supported by this function
// Test if we are hovering the right window (our window could be behind another window)
// [2017/10/16] Reverted commit 344d48be3 and testing RootWindow instead. I believe it is correct to NOT test for RootWindow but this leaves us unable to use IsItemHovered() after EndChild() itself.
// Until a solution is found I believe reverting to the test from 2017/09/27 is safe since this was the test that has been running for a long while.
//if (g.HoveredWindow != window)
// return false;
if (g.HoveredRootWindow != window->RootWindow && !(flags & ImGuiHoveredFlags_AllowWhenOverlapped))
return false;
// Test if another item is active (e.g. being dragged)
if (!(flags & ImGuiHoveredFlags_AllowWhenBlockedByActiveItem))
if (g.ActiveId != 0 && g.ActiveId != window->DC.LastItemId && !g.ActiveIdAllowOverlap && g.ActiveId != window->MoveId)
return false;
// Test if interactions on this window are blocked by an active popup or modal.
// The ImGuiHoveredFlags_AllowWhenBlockedByPopup flag will be tested here.
if (!IsWindowContentHoverable(window, flags))
return false;
// Test if the item is disabled
if ((window->DC.ItemFlags & ImGuiItemFlags_Disabled) && !(flags & ImGuiHoveredFlags_AllowWhenDisabled))
return false;
// Special handling for the dummy item after Begin() which represent the title bar or tab.
// When the window is collapsed (SkipItems==true) that last item will never be overwritten so we need to detect the case.
if ((window->DC.LastItemId == window->ID || window->DC.LastItemId == window->MoveId) && window->WriteAccessed)
return false;
return true;
}
// Internal facing ItemHoverable() used when submitting widgets. Differs slightly from IsItemHovered().
bool ImGui::ItemHoverable(const ImRect& bb, ImGuiID id)
{
ImGuiContext& g = *GImGui;
if (g.HoveredId != 0 && g.HoveredId != id && !g.HoveredIdAllowOverlap)
return false;
ImGuiWindow* window = g.CurrentWindow;
if (g.HoveredWindow != window)
return false;
if (g.ActiveId != 0 && g.ActiveId != id && !g.ActiveIdAllowOverlap)
return false;
if (!IsMouseHoveringRect(bb.Min, bb.Max))
return false;
if (g.NavDisableMouseHover || !IsWindowContentHoverable(window, ImGuiHoveredFlags_None))
return false;
if (window->DC.ItemFlags & ImGuiItemFlags_Disabled)
return false;
SetHoveredID(id);
// [DEBUG] Item Picker tool!
// We perform the check here because SetHoveredID() is not frequently called (1~ time a frame), making
// the cost of this tool near-zero. We can get slightly better call-stack and support picking non-hovered
// items if we perform the test in ItemAdd(), but that would incur a small runtime cost.
// #define IMGUI_DEBUG_TOOL_ITEM_PICKER_EX in imconfig.h if you want this check to also be performed in ItemAdd().
if (g.DebugItemPickerActive && g.HoveredIdPreviousFrame == id)
GetForegroundDrawList()->AddRect(bb.Min, bb.Max, IM_COL32(255, 255, 0, 255));
if (g.DebugItemPickerBreakID == id)
IM_DEBUG_BREAK();
return true;
}
bool ImGui::IsClippedEx(const ImRect& bb, ImGuiID id, bool clip_even_when_logged)
{
ImGuiContext& g = *GImGui;
ImGuiWindow* window = g.CurrentWindow;
if (!bb.Overlaps(window->ClipRect))
if (id == 0 || id != g.ActiveId)
if (clip_even_when_logged || !g.LogEnabled)
return true;
return false;
}
// Process TAB/Shift+TAB. Be mindful that this function may _clear_ the ActiveID when tabbing out.
bool ImGui::FocusableItemRegister(ImGuiWindow* window, ImGuiID id)
{
ImGuiContext& g = *GImGui;
// Increment counters
const bool is_tab_stop = (window->DC.ItemFlags & (ImGuiItemFlags_NoTabStop | ImGuiItemFlags_Disabled)) == 0;
window->DC.FocusCounterAll++;
if (is_tab_stop)
window->DC.FocusCounterTab++;
// Process TAB/Shift-TAB to tab *OUT* of the currently focused item.
// (Note that we can always TAB out of a widget that doesn't allow tabbing in)
if (g.ActiveId == id && g.FocusTabPressed && !(g.ActiveIdBlockNavInputFlags & (1 << ImGuiNavInput_KeyTab_)) && g.FocusRequestNextWindow == NULL)
{
g.FocusRequestNextWindow = window;
g.FocusRequestNextCounterTab = window->DC.FocusCounterTab + (g.IO.KeyShift ? (is_tab_stop ? -1 : 0) : +1); // Modulo on index will be applied at the end of frame once we've got the total counter of items.
}
// Handle focus requests
if (g.FocusRequestCurrWindow == window)
{
if (window->DC.FocusCounterAll == g.FocusRequestCurrCounterAll)
return true;
if (is_tab_stop && window->DC.FocusCounterTab == g.FocusRequestCurrCounterTab)
{
g.NavJustTabbedId = id;
return true;
}
// If another item is about to be focused, we clear our own active id
if (g.ActiveId == id)
ClearActiveID();
}
return false;
}
void ImGui::FocusableItemUnregister(ImGuiWindow* window)
{
window->DC.FocusCounterAll--;
window->DC.FocusCounterTab--;
}
float ImGui::CalcWrapWidthForPos(const ImVec2& pos, float wrap_pos_x)
{
if (wrap_pos_x < 0.0f)
return 0.0f;
ImGuiWindow* window = GImGui->CurrentWindow;
if (wrap_pos_x == 0.0f)
wrap_pos_x = window->WorkRect.Max.x;
else if (wrap_pos_x > 0.0f)
wrap_pos_x += window->Pos.x - window->Scroll.x; // wrap_pos_x is provided is window local space
return ImMax(wrap_pos_x - pos.x, 1.0f);
}
// IM_ALLOC() == ImGui::MemAlloc()
void* ImGui::MemAlloc(size_t size)
{
if (ImGuiContext* ctx = GImGui)
ctx->IO.MetricsActiveAllocations++;
return GImAllocatorAllocFunc(size, GImAllocatorUserData);
}
// IM_FREE() == ImGui::MemFree()
void ImGui::MemFree(void* ptr)
{
if (ptr)
if (ImGuiContext* ctx = GImGui)
ctx->IO.MetricsActiveAllocations--;
return GImAllocatorFreeFunc(ptr, GImAllocatorUserData);
}
const char* ImGui::GetClipboardText()
{
ImGuiContext& g = *GImGui;
return g.IO.GetClipboardTextFn ? g.IO.GetClipboardTextFn(g.IO.ClipboardUserData) : "";
}
void ImGui::SetClipboardText(const char* text)
{
ImGuiContext& g = *GImGui;
if (g.IO.SetClipboardTextFn)
g.IO.SetClipboardTextFn(g.IO.ClipboardUserData, text);
}
const char* ImGui::GetVersion()
{
return IMGUI_VERSION;
}
// Internal state access - if you want to share Dear ImGui state between modules (e.g. DLL) or allocate it yourself
// Note that we still point to some static data and members (such as GFontAtlas), so the state instance you end up using will point to the static data within its module
ImGuiContext* ImGui::GetCurrentContext()
{
return GImGui;
}
void ImGui::SetCurrentContext(ImGuiContext* ctx)
{
#ifdef IMGUI_SET_CURRENT_CONTEXT_FUNC
IMGUI_SET_CURRENT_CONTEXT_FUNC(ctx); // For custom thread-based hackery you may want to have control over this.
#else
GImGui = ctx;
#endif
}
// Helper function to verify ABI compatibility between caller code and compiled version of Dear ImGui.
// Verify that the type sizes are matching between the calling file's compilation unit and imgui.cpp's compilation unit
// If the user has inconsistent compilation settings, imgui configuration #define, packing pragma, etc. your user code
// may see different structures than what imgui.cpp sees, which is problematic.
// We usually require settings to be in imconfig.h to make sure that they are accessible to all compilation units involved with Dear ImGui.
bool ImGui::DebugCheckVersionAndDataLayout(const char* version, size_t sz_io, size_t sz_style, size_t sz_vec2, size_t sz_vec4, size_t sz_vert, size_t sz_idx)
{
bool error = false;
if (strcmp(version, IMGUI_VERSION)!=0) { error = true; IM_ASSERT(strcmp(version,IMGUI_VERSION)==0 && "Mismatched version string!"); }
if (sz_io != sizeof(ImGuiIO)) { error = true; IM_ASSERT(sz_io == sizeof(ImGuiIO) && "Mismatched struct layout!"); }
if (sz_style != sizeof(ImGuiStyle)) { error = true; IM_ASSERT(sz_style == sizeof(ImGuiStyle) && "Mismatched struct layout!"); }
if (sz_vec2 != sizeof(ImVec2)) { error = true; IM_ASSERT(sz_vec2 == sizeof(ImVec2) && "Mismatched struct layout!"); }
if (sz_vec4 != sizeof(ImVec4)) { error = true; IM_ASSERT(sz_vec4 == sizeof(ImVec4) && "Mismatched struct layout!"); }
if (sz_vert != sizeof(ImDrawVert)) { error = true; IM_ASSERT(sz_vert == sizeof(ImDrawVert) && "Mismatched struct layout!"); }
if (sz_idx != sizeof(ImDrawIdx)) { error = true; IM_ASSERT(sz_idx == sizeof(ImDrawIdx) && "Mismatched struct layout!"); }
return !error;
}
void ImGui::SetAllocatorFunctions(void* (*alloc_func)(size_t sz, void* user_data), void (*free_func)(void* ptr, void* user_data), void* user_data)
{
GImAllocatorAllocFunc = alloc_func;
GImAllocatorFreeFunc = free_func;
GImAllocatorUserData = user_data;
}
ImGuiContext* ImGui::CreateContext(ImFontAtlas* shared_font_atlas)
{
ImGuiContext* ctx = IM_NEW(ImGuiContext)(shared_font_atlas);
if (GImGui == NULL)
SetCurrentContext(ctx);
Initialize(ctx);
return ctx;
}
void ImGui::DestroyContext(ImGuiContext* ctx)
{
if (ctx == NULL)
ctx = GImGui;
Shutdown(ctx);
if (GImGui == ctx)
SetCurrentContext(NULL);
IM_DELETE(ctx);
}
ImGuiIO& ImGui::GetIO()
{
IM_ASSERT(GImGui != NULL && "No current context. Did you call ImGui::CreateContext() and ImGui::SetCurrentContext() ?");
return GImGui->IO;
}
ImGuiPlatformIO& ImGui::GetPlatformIO()
{
IM_ASSERT(GImGui != NULL && "No current context. Did you call ImGui::CreateContext() or ImGui::SetCurrentContext()?");
return GImGui->PlatformIO;
}
ImGuiStyle& ImGui::GetStyle()
{
IM_ASSERT(GImGui != NULL && "No current context. Did you call ImGui::CreateContext() and ImGui::SetCurrentContext() ?");
return GImGui->Style;
}
// Same value as passed to the old io.RenderDrawListsFn function. Valid after Render() and until the next call to NewFrame()
ImDrawData* ImGui::GetDrawData()
{
ImGuiContext& g = *GImGui;
return g.Viewports[0]->DrawDataP.Valid ? &g.Viewports[0]->DrawDataP : NULL;
}
double ImGui::GetTime()
{
return GImGui->Time;
}
int ImGui::GetFrameCount()
{
return GImGui->FrameCount;
}
static ImDrawList* GetViewportDrawList(ImGuiViewportP* viewport, size_t drawlist_no, const char* drawlist_name)
{
// Create the draw list on demand, because they are not frequently used for all viewports
ImGuiContext& g = *GImGui;
IM_ASSERT(drawlist_no >= 0 && drawlist_no < IM_ARRAYSIZE(viewport->DrawLists));
ImDrawList* draw_list = viewport->DrawLists[drawlist_no];
if (draw_list == NULL)
{
draw_list = IM_NEW(ImDrawList)(&g.DrawListSharedData);
draw_list->_OwnerName = drawlist_name;
viewport->DrawLists[drawlist_no] = draw_list;
}
// Our ImDrawList system requires that there is always a command
if (viewport->LastFrameDrawLists[drawlist_no] != g.FrameCount)
{
draw_list->Clear();
draw_list->PushTextureID(g.IO.Fonts->TexID);
draw_list->PushClipRect(viewport->Pos, viewport->Pos + viewport->Size, false);
viewport->LastFrameDrawLists[drawlist_no] = g.FrameCount;
}
return draw_list;
}
ImDrawList* ImGui::GetBackgroundDrawList(ImGuiViewport* viewport)
{
return GetViewportDrawList((ImGuiViewportP*)viewport, 0, "##Background");
}
ImDrawList* ImGui::GetBackgroundDrawList()
{
ImGuiWindow* window = GImGui->CurrentWindow;
return GetBackgroundDrawList(window->Viewport);
}
ImDrawList* ImGui::GetForegroundDrawList(ImGuiViewport* viewport)
{
return GetViewportDrawList((ImGuiViewportP*)viewport, 1, "##Foreground");
}
ImDrawList* ImGui::GetForegroundDrawList()
{
ImGuiWindow* window = GImGui->CurrentWindow;
return GetForegroundDrawList(window->Viewport);
}
ImDrawListSharedData* ImGui::GetDrawListSharedData()
{
return &GImGui->DrawListSharedData;
}
void ImGui::StartMouseMovingWindow(ImGuiWindow* window)
{
// Set ActiveId even if the _NoMove flag is set. Without it, dragging away from a window with _NoMove would activate hover on other windows.
// We _also_ call this when clicking in a window empty space when io.ConfigWindowsMoveFromTitleBarOnly is set, but clear g.MovingWindow afterward.
// This is because we want ActiveId to be set even when the window is not permitted to move.
ImGuiContext& g = *GImGui;
FocusWindow(window);
SetActiveID(window->MoveId, window);
g.NavDisableHighlight = true;
g.ActiveIdClickOffset = g.IO.MousePos - window->RootWindow->Pos;
bool can_move_window = true;
if ((window->Flags & ImGuiWindowFlags_NoMove) || (window->RootWindow->Flags & ImGuiWindowFlags_NoMove))
can_move_window = false;
if (ImGuiDockNode* node = window->DockNodeAsHost)
if (node->VisibleWindow && (node->VisibleWindow->Flags & ImGuiWindowFlags_NoMove))
can_move_window = false;
if (can_move_window)
g.MovingWindow = window;
}
void ImGui::StartMouseDragFromTitleBar(ImGuiWindow* window, ImGuiDockNode* node, bool from_collapse_button)
{
ImGuiContext& g = *GImGui;
bool can_extract_dock_node = false;
if (node != NULL && node->VisibleWindow && (node->VisibleWindow->Flags & ImGuiWindowFlags_NoMove) == 0)
{
ImGuiDockNode* root_node = DockNodeGetRootNode(node);
if (root_node->OnlyNodeWithWindows != node || (root_node->CentralNode != NULL))
if (from_collapse_button || root_node->IsDockSpace())
can_extract_dock_node = true;
}
const bool clicked = IsMouseClicked(0);
const bool dragging = IsMouseDragging(0, g.IO.MouseDragThreshold * 1.70f);
if (can_extract_dock_node && dragging)
{
DockContextQueueUndockNode(&g, node);
g.ActiveIdClickOffset = g.IO.MouseClickedPos[0] - node->Pos;
}
else if (!can_extract_dock_node && (clicked || dragging) && g.MovingWindow != window)
{
StartMouseMovingWindow(window);
g.ActiveIdClickOffset = g.IO.MouseClickedPos[0] - window->RootWindow->Pos;
}
}
// Handle mouse moving window
// Note: moving window with the navigation keys (Square + d-pad / CTRL+TAB + Arrows) are processed in NavUpdateWindowing()
void ImGui::UpdateMouseMovingWindowNewFrame()
{
ImGuiContext& g = *GImGui;
if (g.MovingWindow != NULL)
{
// We actually want to move the root window. g.MovingWindow == window we clicked on (could be a child window).
// We track it to preserve Focus and so that generally ActiveIdWindow == MovingWindow and ActiveId == MovingWindow->MoveId for consistency.
KeepAliveID(g.ActiveId);
IM_ASSERT(g.MovingWindow && g.MovingWindow->RootWindow);
ImGuiWindow* moving_window = g.MovingWindow->RootWindow;
if (g.IO.MouseDown[0] && IsMousePosValid(&g.IO.MousePos))
{
ImVec2 pos = g.IO.MousePos - g.ActiveIdClickOffset;
if (moving_window->Pos.x != pos.x || moving_window->Pos.y != pos.y)
{
MarkIniSettingsDirty(moving_window);
SetWindowPos(moving_window, pos, ImGuiCond_Always);
if (moving_window->ViewportOwned) // Synchronize viewport immediately because some overlays may relies on clipping rectangle before we Begin() into the window.
moving_window->Viewport->Pos = pos;
}
FocusWindow(g.MovingWindow);
}
else
{
// Try to merge the window back into the main viewport.
// This works because MouseViewport should be != MovingWindow->Viewport on release (as per code in UpdateViewports)
if (g.ConfigFlagsCurrFrame & ImGuiConfigFlags_ViewportsEnable)
UpdateTryMergeWindowIntoHostViewport(moving_window, g.MouseViewport);
// Restore the mouse viewport so that we don't hover the viewport _under_ the moved window during the frame we released the mouse button.
if (!IsDragDropPayloadBeingAccepted())
g.MouseViewport = moving_window->Viewport;
// Clear the NoInput window flag set by the Viewport system
moving_window->Viewport->Flags &= ~ImGuiViewportFlags_NoInputs;
ClearActiveID();
g.MovingWindow = NULL;
}
}
else
{
// When clicking/dragging from a window that has the _NoMove flag, we still set the ActiveId in order to prevent hovering others.
if (g.ActiveIdWindow && g.ActiveIdWindow->MoveId == g.ActiveId)
{
KeepAliveID(g.ActiveId);
if (!g.IO.MouseDown[0])
ClearActiveID();
}
}
}
// Initiate moving window, handle left-click and right-click focus
void ImGui::UpdateMouseMovingWindowEndFrame()
{
// Initiate moving window
ImGuiContext& g = *GImGui;
if (g.ActiveId != 0 || g.HoveredId != 0)
return;
// Unless we just made a window/popup appear
if (g.NavWindow && g.NavWindow->Appearing)
return;
// Click to focus window and start moving (after we're done with all our widgets)
if (g.IO.MouseClicked[0])
{
if (g.HoveredRootWindow != NULL)
{
StartMouseMovingWindow(g.HoveredWindow);
if (g.IO.ConfigWindowsMoveFromTitleBarOnly && (!(g.HoveredRootWindow->Flags & ImGuiWindowFlags_NoTitleBar) || g.HoveredWindow->RootWindowDockStop->DockIsActive))
if (!g.HoveredRootWindow->TitleBarRect().Contains(g.IO.MouseClickedPos[0]))
g.MovingWindow = NULL;
}
else if (g.NavWindow != NULL && GetTopMostPopupModal() == NULL)
{
// Clicking on void disable focus
FocusWindow(NULL);
}
}
// With right mouse button we close popups without changing focus based on where the mouse is aimed
// Instead, focus will be restored to the window under the bottom-most closed popup.
// (The left mouse button path calls FocusWindow on the hovered window, which will lead NewFrame->ClosePopupsOverWindow to trigger)
if (g.IO.MouseClicked[1])
{
// Find the top-most window between HoveredWindow and the top-most Modal Window.
// This is where we can trim the popup stack.
ImGuiWindow* modal = GetTopMostPopupModal();
bool hovered_window_above_modal = false;
if (modal == NULL)
hovered_window_above_modal = true;
for (int i = g.Windows.Size - 1; i >= 0 && hovered_window_above_modal == false; i--)
{
ImGuiWindow* window = g.Windows[i];
if (window == modal)
break;
if (window == g.HoveredWindow)
hovered_window_above_modal = true;
}
ClosePopupsOverWindow(hovered_window_above_modal ? g.HoveredWindow : modal, true);
}
}
static void TranslateWindow(ImGuiWindow* window, const ImVec2& delta)
{
window->Pos += delta;
window->ClipRect.Translate(delta);
window->OuterRectClipped.Translate(delta);
window->InnerRect.Translate(delta);
window->DC.CursorPos += delta;
window->DC.CursorStartPos += delta;
window->DC.CursorMaxPos += delta;
window->DC.LastItemRect.Translate(delta);
window->DC.LastItemDisplayRect.Translate(delta);
}
static void ScaleWindow(ImGuiWindow* window, float scale)
{
ImVec2 origin = window->Viewport->Pos;
window->Pos = ImFloor((window->Pos - origin) * scale + origin);
window->Size = ImFloor(window->Size * scale);
window->SizeFull = ImFloor(window->SizeFull * scale);
window->ContentSize = ImFloor(window->ContentSize * scale);
}
static bool IsWindowActiveAndVisible(ImGuiWindow* window)
{
return (window->Active) && (!window->Hidden);
}
static void ImGui::UpdateMouseInputs()
{
ImGuiContext& g = *GImGui;
// Round mouse position to avoid spreading non-rounded position (e.g. UpdateManualResize doesn't support them well)
if (IsMousePosValid(&g.IO.MousePos))
g.IO.MousePos = g.LastValidMousePos = ImFloor(g.IO.MousePos);
// If mouse just appeared or disappeared (usually denoted by -FLT_MAX components) we cancel out movement in MouseDelta
if (IsMousePosValid(&g.IO.MousePos) && IsMousePosValid(&g.IO.MousePosPrev))
g.IO.MouseDelta = g.IO.MousePos - g.IO.MousePosPrev;
else
g.IO.MouseDelta = ImVec2(0.0f, 0.0f);
if (g.IO.MouseDelta.x != 0.0f || g.IO.MouseDelta.y != 0.0f)
g.NavDisableMouseHover = false;
g.IO.MousePosPrev = g.IO.MousePos;
for (int i = 0; i < IM_ARRAYSIZE(g.IO.MouseDown); i++)
{
g.IO.MouseClicked[i] = g.IO.MouseDown[i] && g.IO.MouseDownDuration[i] < 0.0f;
g.IO.MouseReleased[i] = !g.IO.MouseDown[i] && g.IO.MouseDownDuration[i] >= 0.0f;
g.IO.MouseDownDurationPrev[i] = g.IO.MouseDownDuration[i];
g.IO.MouseDownDuration[i] = g.IO.MouseDown[i] ? (g.IO.MouseDownDuration[i] < 0.0f ? 0.0f : g.IO.MouseDownDuration[i] + g.IO.DeltaTime) : -1.0f;
g.IO.MouseDoubleClicked[i] = false;
if (g.IO.MouseClicked[i])
{
if ((float)(g.Time - g.IO.MouseClickedTime[i]) < g.IO.MouseDoubleClickTime)
{
ImVec2 delta_from_click_pos = IsMousePosValid(&g.IO.MousePos) ? (g.IO.MousePos - g.IO.MouseClickedPos[i]) : ImVec2(0.0f, 0.0f);
if (ImLengthSqr(delta_from_click_pos) < g.IO.MouseDoubleClickMaxDist * g.IO.MouseDoubleClickMaxDist)
g.IO.MouseDoubleClicked[i] = true;
g.IO.MouseClickedTime[i] = -FLT_MAX; // so the third click isn't turned into a double-click
}
else
{
g.IO.MouseClickedTime[i] = g.Time;
}
g.IO.MouseClickedPos[i] = g.IO.MousePos;
g.IO.MouseDownWasDoubleClick[i] = g.IO.MouseDoubleClicked[i];
g.IO.MouseDragMaxDistanceAbs[i] = ImVec2(0.0f, 0.0f);
g.IO.MouseDragMaxDistanceSqr[i] = 0.0f;
}
else if (g.IO.MouseDown[i])
{
// Maintain the maximum distance we reaching from the initial click position, which is used with dragging threshold
ImVec2 delta_from_click_pos = IsMousePosValid(&g.IO.MousePos) ? (g.IO.MousePos - g.IO.MouseClickedPos[i]) : ImVec2(0.0f, 0.0f);
g.IO.MouseDragMaxDistanceSqr[i] = ImMax(g.IO.MouseDragMaxDistanceSqr[i], ImLengthSqr(delta_from_click_pos));
g.IO.MouseDragMaxDistanceAbs[i].x = ImMax(g.IO.MouseDragMaxDistanceAbs[i].x, delta_from_click_pos.x < 0.0f ? -delta_from_click_pos.x : delta_from_click_pos.x);
g.IO.MouseDragMaxDistanceAbs[i].y = ImMax(g.IO.MouseDragMaxDistanceAbs[i].y, delta_from_click_pos.y < 0.0f ? -delta_from_click_pos.y : delta_from_click_pos.y);
}
if (!g.IO.MouseDown[i] && !g.IO.MouseReleased[i])
g.IO.MouseDownWasDoubleClick[i] = false;
if (g.IO.MouseClicked[i]) // Clicking any mouse button reactivate mouse hovering which may have been deactivated by gamepad/keyboard navigation
g.NavDisableMouseHover = false;
}
}
static void StartLockWheelingWindow(ImGuiWindow* window)
{
ImGuiContext& g = *GImGui;
if (g.WheelingWindow == window)
return;
g.WheelingWindow = window;
g.WheelingWindowRefMousePos = g.IO.MousePos;
g.WheelingWindowTimer = WINDOWS_MOUSE_WHEEL_SCROLL_LOCK_TIMER;
}
void ImGui::UpdateMouseWheel()
{
ImGuiContext& g = *GImGui;
// Reset the locked window if we move the mouse or after the timer elapses
if (g.WheelingWindow != NULL)
{
g.WheelingWindowTimer -= g.IO.DeltaTime;
if (IsMousePosValid() && ImLengthSqr(g.IO.MousePos - g.WheelingWindowRefMousePos) > g.IO.MouseDragThreshold * g.IO.MouseDragThreshold)
g.WheelingWindowTimer = 0.0f;
if (g.WheelingWindowTimer <= 0.0f)
{
g.WheelingWindow = NULL;
g.WheelingWindowTimer = 0.0f;
}
}
if (g.IO.MouseWheel == 0.0f && g.IO.MouseWheelH == 0.0f)
return;
ImGuiWindow* window = g.WheelingWindow ? g.WheelingWindow : g.HoveredWindow;
if (!window || window->Collapsed)
return;
// Zoom / Scale window
// FIXME-OBSOLETE: This is an old feature, it still works but pretty much nobody is using it and may be best redesigned.
if (g.IO.MouseWheel != 0.0f && g.IO.KeyCtrl && g.IO.FontAllowUserScaling)
{
StartLockWheelingWindow(window);
const float new_font_scale = ImClamp(window->FontWindowScale + g.IO.MouseWheel * 0.10f, 0.50f, 2.50f);
const float scale = new_font_scale / window->FontWindowScale;
window->FontWindowScale = new_font_scale;
if (!(window->Flags & ImGuiWindowFlags_ChildWindow))
{
const ImVec2 offset = window->Size * (1.0f - scale) * (g.IO.MousePos - window->Pos) / window->Size;
SetWindowPos(window, window->Pos + offset, 0);
window->Size = ImFloor(window->Size * scale);
window->SizeFull = ImFloor(window->SizeFull * scale);
}
return;
}
// Mouse wheel scrolling
// If a child window has the ImGuiWindowFlags_NoScrollWithMouse flag, we give a chance to scroll its parent
// Vertical Mouse Wheel scrolling
const float wheel_y = (g.IO.MouseWheel != 0.0f && !g.IO.KeyShift) ? g.IO.MouseWheel : 0.0f;
if (wheel_y != 0.0f && !g.IO.KeyCtrl)
{
StartLockWheelingWindow(window);
while ((window->Flags & ImGuiWindowFlags_ChildWindow) && ((window->ScrollMax.y == 0.0f) || ((window->Flags & ImGuiWindowFlags_NoScrollWithMouse) && !(window->Flags & ImGuiWindowFlags_NoMouseInputs))))
window = window->ParentWindow;
if (!(window->Flags & ImGuiWindowFlags_NoScrollWithMouse) && !(window->Flags & ImGuiWindowFlags_NoMouseInputs))
{
float max_step = window->InnerRect.GetHeight() * 0.67f;
float scroll_step = ImFloor(ImMin(5 * window->CalcFontSize(), max_step));
SetScrollY(window, window->Scroll.y - wheel_y * scroll_step);
}
}
// Horizontal Mouse Wheel scrolling, or Vertical Mouse Wheel w/ Shift held
const float wheel_x = (g.IO.MouseWheelH != 0.0f && !g.IO.KeyShift) ? g.IO.MouseWheelH : (g.IO.MouseWheel != 0.0f && g.IO.KeyShift) ? g.IO.MouseWheel : 0.0f;
if (wheel_x != 0.0f && !g.IO.KeyCtrl)
{
StartLockWheelingWindow(window);
while ((window->Flags & ImGuiWindowFlags_ChildWindow) && ((window->ScrollMax.x == 0.0f) || ((window->Flags & ImGuiWindowFlags_NoScrollWithMouse) && !(window->Flags & ImGuiWindowFlags_NoMouseInputs))))
window = window->ParentWindow;
if (!(window->Flags & ImGuiWindowFlags_NoScrollWithMouse) && !(window->Flags & ImGuiWindowFlags_NoMouseInputs))
{
float max_step = window->InnerRect.GetWidth() * 0.67f;
float scroll_step = ImFloor(ImMin(2 * window->CalcFontSize(), max_step));
SetScrollX(window, window->Scroll.x - wheel_x * scroll_step);
}
}
}
// The reason this is exposed in imgui_internal.h is: on touch-based system that don't have hovering, we want to dispatch inputs to the right target (imgui vs imgui+app)
void ImGui::UpdateHoveredWindowAndCaptureFlags()
{
ImGuiContext& g = *GImGui;
// Find the window hovered by mouse:
// - Child windows can extend beyond the limit of their parent so we need to derive HoveredRootWindow from HoveredWindow.
// - When moving a window we can skip the search, which also conveniently bypasses the fact that window->WindowRectClipped is lagging as this point of the frame.
// - We also support the moved window toggling the NoInputs flag after moving has started in order to be able to detect windows below it, which is useful for e.g. docking mechanisms.
FindHoveredWindow();
IM_ASSERT(g.HoveredWindow == NULL || g.HoveredWindow == g.MovingWindow || g.HoveredWindow->Viewport == g.MouseViewport);
// Modal windows prevents cursor from hovering behind them.
ImGuiWindow* modal_window = GetTopMostPopupModal();
if (modal_window)
if (g.HoveredRootWindow && !IsWindowChildOf(g.HoveredRootWindow, modal_window))
g.HoveredWindow = g.HoveredRootWindow = g.HoveredWindowUnderMovingWindow = NULL;
// Disabled mouse?
if (g.IO.ConfigFlags & ImGuiConfigFlags_NoMouse)
g.HoveredWindow = g.HoveredRootWindow = g.HoveredWindowUnderMovingWindow = NULL;
// We track click ownership. When clicked outside of a window the click is owned by the application and won't report hovering nor request capture even while dragging over our windows afterward.
int mouse_earliest_button_down = -1;
bool mouse_any_down = false;
for (int i = 0; i < IM_ARRAYSIZE(g.IO.MouseDown); i++)
{
if (g.IO.MouseClicked[i])
g.IO.MouseDownOwned[i] = (g.HoveredWindow != NULL) || (!g.OpenPopupStack.empty());
mouse_any_down |= g.IO.MouseDown[i];
if (g.IO.MouseDown[i])
if (mouse_earliest_button_down == -1 || g.IO.MouseClickedTime[i] < g.IO.MouseClickedTime[mouse_earliest_button_down])
mouse_earliest_button_down = i;
}
const bool mouse_avail_to_imgui = (mouse_earliest_button_down == -1) || g.IO.MouseDownOwned[mouse_earliest_button_down];
// If mouse was first clicked outside of ImGui bounds we also cancel out hovering.
// FIXME: For patterns of drag and drop across OS windows, we may need to rework/remove this test (first committed 311c0ca9 on 2015/02)
const bool mouse_dragging_extern_payload = g.DragDropActive && (g.DragDropSourceFlags & ImGuiDragDropFlags_SourceExtern) != 0;
if (!mouse_avail_to_imgui && !mouse_dragging_extern_payload)
g.HoveredWindow = g.HoveredRootWindow = g.HoveredWindowUnderMovingWindow = NULL;
// Update io.WantCaptureMouse for the user application (true = dispatch mouse info to imgui, false = dispatch mouse info to Dear ImGui + app)
if (g.WantCaptureMouseNextFrame != -1)
g.IO.WantCaptureMouse = (g.WantCaptureMouseNextFrame != 0);
else
g.IO.WantCaptureMouse = (mouse_avail_to_imgui && (g.HoveredWindow != NULL || mouse_any_down)) || (!g.OpenPopupStack.empty());
// Update io.WantCaptureKeyboard for the user application (true = dispatch keyboard info to imgui, false = dispatch keyboard info to Dear ImGui + app)
if (g.WantCaptureKeyboardNextFrame != -1)
g.IO.WantCaptureKeyboard = (g.WantCaptureKeyboardNextFrame != 0);
else
g.IO.WantCaptureKeyboard = (g.ActiveId != 0) || (modal_window != NULL);
if (g.IO.NavActive && (g.IO.ConfigFlags & ImGuiConfigFlags_NavEnableKeyboard) && !(g.IO.ConfigFlags & ImGuiConfigFlags_NavNoCaptureKeyboard))
g.IO.WantCaptureKeyboard = true;
// Update io.WantTextInput flag, this is to allow systems without a keyboard (e.g. mobile, hand-held) to show a software keyboard if possible
g.IO.WantTextInput = (g.WantTextInputNextFrame != -1) ? (g.WantTextInputNextFrame != 0) : false;
}
static void NewFrameSanityChecks()
{
ImGuiContext& g = *GImGui;
// Check user data
// (We pass an error message in the assert expression to make it visible to programmers who are not using a debugger, as most assert handlers display their argument)
IM_ASSERT(g.Initialized);
IM_ASSERT((g.IO.DeltaTime > 0.0f || g.FrameCount == 0) && "Need a positive DeltaTime!");
IM_ASSERT((g.FrameCount == 0 || g.FrameCountEnded == g.FrameCount) && "Forgot to call Render() or EndFrame() at the end of the previous frame?");
IM_ASSERT(g.IO.DisplaySize.x >= 0.0f && g.IO.DisplaySize.y >= 0.0f && "Invalid DisplaySize value!");
IM_ASSERT(g.IO.Fonts->Fonts.Size > 0 && "Font Atlas not built. Did you call io.Fonts->GetTexDataAsRGBA32() / GetTexDataAsAlpha8() ?");
IM_ASSERT(g.IO.Fonts->Fonts[0]->IsLoaded() && "Font Atlas not built. Did you call io.Fonts->GetTexDataAsRGBA32() / GetTexDataAsAlpha8() ?");
IM_ASSERT(g.Style.CurveTessellationTol > 0.0f && "Invalid style setting!");
IM_ASSERT(g.Style.Alpha >= 0.0f && g.Style.Alpha <= 1.0f && "Invalid style setting. Alpha cannot be negative (allows us to avoid a few clamps in color computations)!");
IM_ASSERT(g.Style.WindowMinSize.x >= 1.0f && g.Style.WindowMinSize.y >= 1.0f && "Invalid style setting.");
IM_ASSERT(g.Style.WindowMenuButtonPosition == ImGuiDir_Left || g.Style.WindowMenuButtonPosition == ImGuiDir_Right);
for (int n = 0; n < ImGuiKey_COUNT; n++)
IM_ASSERT(g.IO.KeyMap[n] >= -1 && g.IO.KeyMap[n] < IM_ARRAYSIZE(g.IO.KeysDown) && "io.KeyMap[] contains an out of bound value (need to be 0..512, or -1 for unmapped key)");
// Perform simple check: required key mapping (we intentionally do NOT check all keys to not pressure user into setting up everything, but Space is required and was only recently added in 1.60 WIP)
if (g.IO.ConfigFlags & ImGuiConfigFlags_NavEnableKeyboard)
IM_ASSERT(g.IO.KeyMap[ImGuiKey_Space] != -1 && "ImGuiKey_Space is not mapped, required for keyboard navigation.");
// Perform simple check: the beta io.ConfigWindowsResizeFromEdges option requires back-end to honor mouse cursor changes and set the ImGuiBackendFlags_HasMouseCursors flag accordingly.
if (g.IO.ConfigWindowsResizeFromEdges && !(g.IO.BackendFlags & ImGuiBackendFlags_HasMouseCursors))
g.IO.ConfigWindowsResizeFromEdges = false;
}
void ImGui::NewFrame()
{
IM_ASSERT(GImGui != NULL && "No current context. Did you call ImGui::CreateContext() and ImGui::SetCurrentContext() ?");
ImGuiContext& g = *GImGui;
#ifdef IMGUI_ENABLE_TEST_ENGINE
ImGuiTestEngineHook_PreNewFrame(&g);
#endif
// Check and assert for various common IO and Configuration mistakes
NewFrameSanityChecks();
// Perform simple check: error if Docking or Viewport are enabled _exactly_ on frame 1 (instead of frame 0 or later), which is a common error leading to loss of .ini data.
g.ConfigFlagsLastFrame = g.ConfigFlagsCurrFrame;
if (g.FrameCount == 1 && (g.IO.ConfigFlags & ImGuiConfigFlags_DockingEnable) && (g.ConfigFlagsLastFrame & ImGuiConfigFlags_DockingEnable) == 0)
IM_ASSERT(0 && "Please set DockingEnable before the first call to NewFrame()! Otherwise you will lose your .ini settings!");
if (g.FrameCount == 1 && (g.IO.ConfigFlags & ImGuiConfigFlags_ViewportsEnable) && (g.ConfigFlagsLastFrame & ImGuiConfigFlags_ViewportsEnable) == 0)
IM_ASSERT(0 && "Please set ViewportsEnable before the first call to NewFrame()! Otherwise you will lose your .ini settings!");
// Perform simple checks: multi-viewport and platform windows support
if (g.IO.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
{
if ((g.IO.BackendFlags & ImGuiBackendFlags_PlatformHasViewports) && (g.IO.BackendFlags & ImGuiBackendFlags_RendererHasViewports))
{
IM_ASSERT((g.FrameCount == 0 || g.FrameCount == g.FrameCountPlatformEnded) && "Forgot to call UpdatePlatformWindows() in main loop after EndFrame()? Check examples/ applications for reference.");
IM_ASSERT(g.PlatformIO.Platform_CreateWindow != NULL && "Platform init didn't install handlers?");
IM_ASSERT(g.PlatformIO.Platform_DestroyWindow != NULL && "Platform init didn't install handlers?");
IM_ASSERT(g.PlatformIO.Platform_GetWindowPos != NULL && "Platform init didn't install handlers?");
IM_ASSERT(g.PlatformIO.Platform_SetWindowPos != NULL && "Platform init didn't install handlers?");
IM_ASSERT(g.PlatformIO.Platform_GetWindowSize != NULL && "Platform init didn't install handlers?");
IM_ASSERT(g.PlatformIO.Platform_SetWindowSize != NULL && "Platform init didn't install handlers?");
IM_ASSERT(g.PlatformIO.Monitors.Size > 0 && "Platform init didn't setup Monitors list?");
IM_ASSERT((g.Viewports[0]->PlatformUserData != NULL || g.Viewports[0]->PlatformHandle != NULL) && "Platform init didn't setup main viewport.");
if (g.IO.ConfigDockingTransparentPayload && (g.IO.ConfigFlags & ImGuiConfigFlags_DockingEnable))
IM_ASSERT(g.PlatformIO.Platform_SetWindowAlpha != NULL && "Platform_SetWindowAlpha handler is required to use io.ConfigDockingTransparent!");
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
IM_ASSERT(g.IO.RenderDrawListsFn == NULL); // Call ImGui::Render() then pass ImGui::GetDrawData() yourself to your render function!
#endif
}
else
{
// Disable feature, our back-ends do not support it
g.IO.ConfigFlags &= ~ImGuiConfigFlags_ViewportsEnable;
}
// Perform simple checks on platform monitor data + compute a total bounding box for quick early outs
for (int monitor_n = 0; monitor_n < g.PlatformIO.Monitors.Size; monitor_n++)
{
ImGuiPlatformMonitor& mon = g.PlatformIO.Monitors[monitor_n];
IM_UNUSED(mon);
IM_ASSERT(mon.MainSize.x > 0.0f && mon.MainSize.y > 0.0f && "Monitor bounds not setup properly.");
IM_ASSERT(mon.WorkSize.x > 0.0f && mon.WorkSize.y > 0.0f && "Monitor bounds not setup properly. If you don't have work area information, just copy Min/Max into them.");
IM_ASSERT(mon.DpiScale != 0.0f);
}
}
g.ConfigFlagsCurrFrame = g.IO.ConfigFlags;
// Load settings on first frame (if not explicitly loaded manually before)
if (!g.SettingsLoaded)
{
IM_ASSERT(g.SettingsWindows.empty());
if (g.IO.IniFilename)
LoadIniSettingsFromDisk(g.IO.IniFilename);
g.SettingsLoaded = true;
}
// Save settings (with a delay after the last modification, so we don't spam disk too much)
if (g.SettingsDirtyTimer > 0.0f)
{
g.SettingsDirtyTimer -= g.IO.DeltaTime;
if (g.SettingsDirtyTimer <= 0.0f)
{
if (g.IO.IniFilename != NULL)
SaveIniSettingsToDisk(g.IO.IniFilename);
else
g.IO.WantSaveIniSettings = true; // Let user know they can call SaveIniSettingsToMemory(). user will need to clear io.WantSaveIniSettings themselves.
g.SettingsDirtyTimer = 0.0f;
}
}
g.Time += g.IO.DeltaTime;
g.FrameScopeActive = true;
g.FrameCount += 1;
g.TooltipOverrideCount = 0;
g.WindowsActiveCount = 0;
UpdateViewportsNewFrame();
// Setup current font and draw list shared data
// FIXME-VIEWPORT: the concept of a single ClipRectFullscreen is not ideal!
g.IO.Fonts->Locked = true;
SetCurrentFont(GetDefaultFont());
IM_ASSERT(g.Font->IsLoaded());
ImRect virtual_space(FLT_MAX, FLT_MAX, -FLT_MAX, -FLT_MAX);
for (int n = 0; n < g.Viewports.Size; n++)
virtual_space.Add(g.Viewports[n]->GetRect());
g.DrawListSharedData.ClipRectFullscreen = ImVec4(virtual_space.Min.x, virtual_space.Min.y, virtual_space.Max.x, virtual_space.Max.y);
g.DrawListSharedData.CurveTessellationTol = g.Style.CurveTessellationTol;
g.DrawListSharedData.InitialFlags = ImDrawListFlags_None;
if (g.Style.AntiAliasedLines)
g.DrawListSharedData.InitialFlags |= ImDrawListFlags_AntiAliasedLines;
if (g.Style.AntiAliasedFill)
g.DrawListSharedData.InitialFlags |= ImDrawListFlags_AntiAliasedFill;
if (g.IO.BackendFlags & ImGuiBackendFlags_RendererHasVtxOffset)
g.DrawListSharedData.InitialFlags |= ImDrawListFlags_AllowVtxOffset;
// Mark rendering data as invalid to prevent user who may have a handle on it to use it.
for (int n = 0; n < g.Viewports.Size; n++)
{
ImGuiViewportP* viewport = g.Viewports[n];
viewport->DrawData = NULL;
viewport->DrawDataP.Clear();
}
// Drag and drop keep the source ID alive so even if the source disappear our state is consistent
if (g.DragDropActive && g.DragDropPayload.SourceId == g.ActiveId)
KeepAliveID(g.DragDropPayload.SourceId);
// Clear reference to active widget if the widget isn't alive anymore
if (!g.HoveredIdPreviousFrame)
g.HoveredIdTimer = 0.0f;
if (!g.HoveredIdPreviousFrame || (g.HoveredId && g.ActiveId == g.HoveredId))
g.HoveredIdNotActiveTimer = 0.0f;
if (g.HoveredId)
g.HoveredIdTimer += g.IO.DeltaTime;
if (g.HoveredId && g.ActiveId != g.HoveredId)
g.HoveredIdNotActiveTimer += g.IO.DeltaTime;
g.HoveredIdPreviousFrame = g.HoveredId;
g.HoveredId = 0;
g.HoveredIdAllowOverlap = false;
if (g.ActiveIdIsAlive != g.ActiveId && g.ActiveIdPreviousFrame == g.ActiveId && g.ActiveId != 0)
ClearActiveID();
if (g.ActiveId)
g.ActiveIdTimer += g.IO.DeltaTime;
g.LastActiveIdTimer += g.IO.DeltaTime;
g.ActiveIdPreviousFrame = g.ActiveId;
g.ActiveIdPreviousFrameWindow = g.ActiveIdWindow;
g.ActiveIdPreviousFrameHasBeenEditedBefore = g.ActiveIdHasBeenEditedBefore;
g.ActiveIdIsAlive = 0;
g.ActiveIdHasBeenEditedThisFrame = false;
g.ActiveIdPreviousFrameIsAlive = false;
g.ActiveIdIsJustActivated = false;
if (g.TempInputTextId != 0 && g.ActiveId != g.TempInputTextId)
g.TempInputTextId = 0;
// Drag and drop
g.DragDropAcceptIdPrev = g.DragDropAcceptIdCurr;
g.DragDropAcceptIdCurr = 0;
g.DragDropAcceptIdCurrRectSurface = FLT_MAX;
g.DragDropWithinSourceOrTarget = false;
// Update keyboard input state
memcpy(g.IO.KeysDownDurationPrev, g.IO.KeysDownDuration, sizeof(g.IO.KeysDownDuration));
for (int i = 0; i < IM_ARRAYSIZE(g.IO.KeysDown); i++)
g.IO.KeysDownDuration[i] = g.IO.KeysDown[i] ? (g.IO.KeysDownDuration[i] < 0.0f ? 0.0f : g.IO.KeysDownDuration[i] + g.IO.DeltaTime) : -1.0f;
// Update gamepad/keyboard directional navigation
NavUpdate();
// Update mouse input state
UpdateMouseInputs();
// Calculate frame-rate for the user, as a purely luxurious feature
g.FramerateSecPerFrameAccum += g.IO.DeltaTime - g.FramerateSecPerFrame[g.FramerateSecPerFrameIdx];
g.FramerateSecPerFrame[g.FramerateSecPerFrameIdx] = g.IO.DeltaTime;
g.FramerateSecPerFrameIdx = (g.FramerateSecPerFrameIdx + 1) % IM_ARRAYSIZE(g.FramerateSecPerFrame);
g.IO.Framerate = (g.FramerateSecPerFrameAccum > 0.0f) ? (1.0f / (g.FramerateSecPerFrameAccum / (float)IM_ARRAYSIZE(g.FramerateSecPerFrame))) : FLT_MAX;
// Undocking
// (needs to be before UpdateMouseMovingWindowNewFrame so the window is already offset and following the mouse on the detaching frame)
DockContextUpdateUndocking(&g);
// Find hovered window
// (needs to be before UpdateMouseMovingWindowNewFrame so we fill g.HoveredWindowUnderMovingWindow on the mouse release frame)
UpdateHoveredWindowAndCaptureFlags();
// Handle user moving window with mouse (at the beginning of the frame to avoid input lag or sheering)
UpdateMouseMovingWindowNewFrame();
// Background darkening/whitening
if (GetTopMostPopupModal() != NULL || (g.NavWindowingTarget != NULL && g.NavWindowingHighlightAlpha > 0.0f))
g.DimBgRatio = ImMin(g.DimBgRatio + g.IO.DeltaTime * 6.0f, 1.0f);
else
g.DimBgRatio = ImMax(g.DimBgRatio - g.IO.DeltaTime * 10.0f, 0.0f);
g.MouseCursor = ImGuiMouseCursor_Arrow;
g.WantCaptureMouseNextFrame = g.WantCaptureKeyboardNextFrame = g.WantTextInputNextFrame = -1;
g.PlatformImePos = ImVec2(1.0f, 1.0f); // OS Input Method Editor showing on top-left of our window by default
g.PlatformImePosViewport = NULL;
// Mouse wheel scrolling, scale
UpdateMouseWheel();
// Pressing TAB activate widget focus
g.FocusTabPressed = (g.NavWindow && g.NavWindow->Active && !(g.NavWindow->Flags & ImGuiWindowFlags_NoNavInputs) && !g.IO.KeyCtrl && IsKeyPressedMap(ImGuiKey_Tab));
if (g.ActiveId == 0 && g.FocusTabPressed)
{
// Note that SetKeyboardFocusHere() sets the Next fields mid-frame. To be consistent we also
// manipulate the Next fields even, even though they will be turned into Curr fields by the code below.
g.FocusRequestNextWindow = g.NavWindow;
g.FocusRequestNextCounterAll = INT_MAX;
if (g.NavId != 0 && g.NavIdTabCounter != INT_MAX)
g.FocusRequestNextCounterTab = g.NavIdTabCounter + 1 + (g.IO.KeyShift ? -1 : 1);
else
g.FocusRequestNextCounterTab = g.IO.KeyShift ? -1 : 0;
}
// Turn queued focus request into current one
g.FocusRequestCurrWindow = NULL;
g.FocusRequestCurrCounterAll = g.FocusRequestCurrCounterTab = INT_MAX;
if (g.FocusRequestNextWindow != NULL)
{
ImGuiWindow* window = g.FocusRequestNextWindow;
g.FocusRequestCurrWindow = window;
if (g.FocusRequestNextCounterAll != INT_MAX && window->DC.FocusCounterAll != -1)
g.FocusRequestCurrCounterAll = ImModPositive(g.FocusRequestNextCounterAll, window->DC.FocusCounterAll + 1);
if (g.FocusRequestNextCounterTab != INT_MAX && window->DC.FocusCounterTab != -1)
g.FocusRequestCurrCounterTab = ImModPositive(g.FocusRequestNextCounterTab, window->DC.FocusCounterTab + 1);
g.FocusRequestNextWindow = NULL;
g.FocusRequestNextCounterAll = g.FocusRequestNextCounterTab = INT_MAX;
}
g.NavIdTabCounter = INT_MAX;
// Mark all windows as not visible
IM_ASSERT(g.WindowsFocusOrder.Size == g.Windows.Size);
for (int i = 0; i != g.Windows.Size; i++)
{
ImGuiWindow* window = g.Windows[i];
window->WasActive = window->Active;
window->BeginCount = 0;
window->Active = false;
window->WriteAccessed = false;
}
// Closing the focused window restore focus to the first active root window in descending z-order
if (g.NavWindow && !g.NavWindow->WasActive)
FocusTopMostWindowUnderOne(NULL, NULL);
// No window should be open at the beginning of the frame.
// But in order to allow the user to call NewFrame() multiple times without calling Render(), we are doing an explicit clear.
g.CurrentWindowStack.resize(0);
g.BeginPopupStack.resize(0);
ClosePopupsOverWindow(g.NavWindow, false);
// Docking
DockContextUpdateDocking(&g);
// [DEBUG] Item picker tool - start with DebugStartItemPicker() - useful to visually select an item and break into its call-stack.
UpdateDebugToolItemPicker();
// Create implicit/fallback window - which we will only render it if the user has added something to it.
// We don't use "Debug" to avoid colliding with user trying to create a "Debug" window with custom flags.
// This fallback is particularly important as it avoid ImGui:: calls from crashing.
g.FrameScopePushedFallbackWindow = true;
SetNextWindowSize(ImVec2(400,400), ImGuiCond_FirstUseEver);
Begin("Debug##Default");
IM_ASSERT(g.CurrentWindow->IsFallbackWindow == true);
#ifdef IMGUI_ENABLE_TEST_ENGINE
ImGuiTestEngineHook_PostNewFrame(&g);
#endif
}
// [DEBUG] Item picker tool - start with DebugStartItemPicker() - useful to visually select an item and break into its call-stack.
void ImGui::UpdateDebugToolItemPicker()
{
ImGuiContext& g = *GImGui;
g.DebugItemPickerBreakID = 0;
if (g.DebugItemPickerActive)
{
const ImGuiID hovered_id = g.HoveredIdPreviousFrame;
ImGui::SetMouseCursor(ImGuiMouseCursor_Hand);
if (ImGui::IsKeyPressedMap(ImGuiKey_Escape))
g.DebugItemPickerActive = false;
if (ImGui::IsMouseClicked(0) && hovered_id)
{
g.DebugItemPickerBreakID = hovered_id;
g.DebugItemPickerActive = false;
}
ImGui::SetNextWindowBgAlpha(0.60f);
ImGui::BeginTooltip();
ImGui::Text("HoveredId: 0x%08X", hovered_id);
ImGui::Text("Press ESC to abort picking.");
ImGui::TextColored(GetStyleColorVec4(hovered_id ? ImGuiCol_Text : ImGuiCol_TextDisabled), "Click to break in debugger!");
ImGui::EndTooltip();
}
}
void ImGui::Initialize(ImGuiContext* context)
{
ImGuiContext& g = *context;
IM_ASSERT(!g.Initialized && !g.SettingsLoaded);
// Add .ini handle for ImGuiWindow type
ImGuiSettingsHandler ini_handler;
ini_handler.TypeName = "Window";
ini_handler.TypeHash = ImHashStr("Window");
ini_handler.ReadOpenFn = SettingsHandlerWindow_ReadOpen;
ini_handler.ReadLineFn = SettingsHandlerWindow_ReadLine;
ini_handler.WriteAllFn = SettingsHandlerWindow_WriteAll;
g.SettingsHandlers.push_back(ini_handler);
// Create default viewport
ImGuiViewportP* viewport = IM_NEW(ImGuiViewportP)();
viewport->ID = IMGUI_VIEWPORT_DEFAULT_ID;
viewport->Idx = 0;
viewport->PlatformWindowCreated = true;
g.Viewports.push_back(viewport);
g.PlatformIO.MainViewport = g.Viewports[0]; // Make it accessible in public-facing GetPlatformIO() immediately (before the first call to EndFrame)
g.PlatformIO.Viewports.push_back(g.Viewports[0]);
// Extensions
IM_ASSERT(g.DockContext == NULL);
DockContextInitialize(&g);
g.Initialized = true;
}
// This function is merely here to free heap allocations.
void ImGui::Shutdown(ImGuiContext* context)
{
// The fonts atlas can be used prior to calling NewFrame(), so we clear it even if g.Initialized is FALSE (which would happen if we never called NewFrame)
ImGuiContext& g = *context;
if (g.IO.Fonts && g.FontAtlasOwnedByContext)
{
g.IO.Fonts->Locked = false;
IM_DELETE(g.IO.Fonts);
}
g.IO.Fonts = NULL;
// Cleanup of other data are conditional on actually having initialized Dear ImGui.
if (!g.Initialized)
return;
// Save settings (unless we haven't attempted to load them: CreateContext/DestroyContext without a call to NewFrame shouldn't save an empty file)
if (g.SettingsLoaded && g.IO.IniFilename != NULL)
{
ImGuiContext* backup_context = GImGui;
SetCurrentContext(context);
SaveIniSettingsToDisk(g.IO.IniFilename);
SetCurrentContext(backup_context);
}
// Destroy platform windows
ImGuiContext* backup_context = ImGui::GetCurrentContext();
SetCurrentContext(context);
DestroyPlatformWindows();
SetCurrentContext(backup_context);
// Shutdown extensions
IM_ASSERT(g.DockContext != NULL);
DockContextShutdown(&g);
// Clear everything else
for (int i = 0; i < g.Windows.Size; i++)
IM_DELETE(g.Windows[i]);
g.Windows.clear();
g.WindowsFocusOrder.clear();
g.WindowsSortBuffer.clear();
g.CurrentWindow = NULL;
g.CurrentWindowStack.clear();
g.WindowsById.Clear();
g.NavWindow = NULL;
g.HoveredWindow = g.HoveredRootWindow = g.HoveredWindowUnderMovingWindow = NULL;
g.ActiveIdWindow = g.ActiveIdPreviousFrameWindow = NULL;
g.MovingWindow = NULL;
g.ColorModifiers.clear();
g.StyleModifiers.clear();
g.FontStack.clear();
g.OpenPopupStack.clear();
g.BeginPopupStack.clear();
g.CurrentViewport = g.MouseViewport = g.MouseLastHoveredViewport = NULL;
for (int i = 0; i < g.Viewports.Size; i++)
IM_DELETE(g.Viewports[i]);
g.Viewports.clear();
g.TabBars.Clear();
g.CurrentTabBarStack.clear();
g.ShrinkWidthBuffer.clear();
g.PrivateClipboard.clear();
g.InputTextState.ClearFreeMemory();
for (int i = 0; i < g.SettingsWindows.Size; i++)
IM_DELETE(g.SettingsWindows[i].Name);
g.SettingsWindows.clear();
g.SettingsHandlers.clear();
if (g.LogFile && g.LogFile != stdout)
{
fclose(g.LogFile);
g.LogFile = NULL;
}
g.LogBuffer.clear();
g.Initialized = false;
}
// FIXME: Add a more explicit sort order in the window structure.
static int IMGUI_CDECL ChildWindowComparer(const void* lhs, const void* rhs)
{
const ImGuiWindow* const a = *(const ImGuiWindow* const *)lhs;
const ImGuiWindow* const b = *(const ImGuiWindow* const *)rhs;
if (int d = (a->Flags & ImGuiWindowFlags_Popup) - (b->Flags & ImGuiWindowFlags_Popup))
return d;
if (int d = (a->Flags & ImGuiWindowFlags_Tooltip) - (b->Flags & ImGuiWindowFlags_Tooltip))
return d;
return (a->BeginOrderWithinParent - b->BeginOrderWithinParent);
}
static void AddWindowToSortBuffer(ImVector<ImGuiWindow*>* out_sorted_windows, ImGuiWindow* window)
{
out_sorted_windows->push_back(window);
if (window->Active)
{
int count = window->DC.ChildWindows.Size;
if (count > 1)
ImQsort(window->DC.ChildWindows.Data, (size_t)count, sizeof(ImGuiWindow*), ChildWindowComparer);
for (int i = 0; i < count; i++)
{
ImGuiWindow* child = window->DC.ChildWindows[i];
if (child->Active)
AddWindowToSortBuffer(out_sorted_windows, child);
}
}
}
static void AddDrawListToDrawData(ImVector<ImDrawList*>* out_list, ImDrawList* draw_list)
{
if (draw_list->CmdBuffer.empty())
return;
// Remove trailing command if unused
ImDrawCmd& last_cmd = draw_list->CmdBuffer.back();
if (last_cmd.ElemCount == 0 && last_cmd.UserCallback == NULL)
{
draw_list->CmdBuffer.pop_back();
if (draw_list->CmdBuffer.empty())
return;
}
// Draw list sanity check. Detect mismatch between PrimReserve() calls and incrementing _VtxCurrentIdx, _VtxWritePtr etc.
// May trigger for you if you are using PrimXXX functions incorrectly.
IM_ASSERT(draw_list->VtxBuffer.Size == 0 || draw_list->_VtxWritePtr == draw_list->VtxBuffer.Data + draw_list->VtxBuffer.Size);
IM_ASSERT(draw_list->IdxBuffer.Size == 0 || draw_list->_IdxWritePtr == draw_list->IdxBuffer.Data + draw_list->IdxBuffer.Size);
if (!(draw_list->Flags & ImDrawListFlags_AllowVtxOffset))
IM_ASSERT((int)draw_list->_VtxCurrentIdx == draw_list->VtxBuffer.Size);
// Check that draw_list doesn't use more vertices than indexable (default ImDrawIdx = unsigned short = 2 bytes = 64K vertices per ImDrawList = per window)
// If this assert triggers because you are drawing lots of stuff manually:
// - First, make sure you are coarse clipping yourself and not trying to draw many things outside visible bounds.
// Be mindful that the ImDrawList API doesn't filter vertices. Use the Metrics window to inspect draw list contents.
// - If you want large meshes with more than 64K vertices, you can either:
// (A) Handle the ImDrawCmd::VtxOffset value in your renderer back-end, and set 'io.BackendFlags |= ImGuiBackendFlags_RendererHasVtxOffset'.
// Most example back-ends already support this from 1.71. Pre-1.71 back-ends won't.
// Some graphics API such as GL ES 1/2 don't have a way to offset the starting vertex so it is not supported for them.
// (B) Or handle 32-bits indices in your renderer back-end, and uncomment '#define ImDrawIdx unsigned int' line in imconfig.h.
// Most example back-ends already support this. For example, the OpenGL example code detect index size at compile-time:
// glDrawElements(GL_TRIANGLES, (GLsizei)pcmd->ElemCount, sizeof(ImDrawIdx) == 2 ? GL_UNSIGNED_SHORT : GL_UNSIGNED_INT, idx_buffer_offset);
// Your own engine or render API may use different parameters or function calls to specify index sizes.
// 2 and 4 bytes indices are generally supported by most graphics API.
// - If for some reason neither of those solutions works for you, a workaround is to call BeginChild()/EndChild() before reaching
// the 64K limit to split your draw commands in multiple draw lists.
if (sizeof(ImDrawIdx) == 2)
IM_ASSERT(draw_list->_VtxCurrentIdx < (1 << 16) && "Too many vertices in ImDrawList using 16-bit indices. Read comment above");
out_list->push_back(draw_list);
}
static void AddWindowToDrawData(ImGuiWindow* window, int layer)
{
ImGuiContext& g = *GImGui;
g.IO.MetricsRenderWindows++;
AddDrawListToDrawData(&window->Viewport->DrawDataBuilder.Layers[layer], window->DrawList);
for (int i = 0; i < window->DC.ChildWindows.Size; i++)
{
ImGuiWindow* child = window->DC.ChildWindows[i];
if (IsWindowActiveAndVisible(child)) // Clipped children may have been marked not active
AddWindowToDrawData(child, layer);
}
}
// Layer is locked for the root window, however child windows may use a different viewport (e.g. extruding menu)
static void AddRootWindowToDrawData(ImGuiWindow* window)
{
int layer = (window->Flags & ImGuiWindowFlags_Tooltip) ? 1 : 0;
AddWindowToDrawData(window, layer);
}
void ImDrawDataBuilder::FlattenIntoSingleLayer()
{
int n = Layers[0].Size;
int size = n;
for (int i = 1; i < IM_ARRAYSIZE(Layers); i++)
size += Layers[i].Size;
Layers[0].resize(size);
for (int layer_n = 1; layer_n < IM_ARRAYSIZE(Layers); layer_n++)
{
ImVector<ImDrawList*>& layer = Layers[layer_n];
if (layer.empty())
continue;
memcpy(&Layers[0][n], &layer[0], layer.Size * sizeof(ImDrawList*));
n += layer.Size;
layer.resize(0);
}
}
static void SetupViewportDrawData(ImGuiViewportP* viewport, ImVector<ImDrawList*>* draw_lists)
{
ImDrawData* draw_data = &viewport->DrawDataP;
viewport->DrawData = draw_data; // Make publicly accessible
draw_data->Valid = true;
draw_data->CmdLists = (draw_lists->Size > 0) ? draw_lists->Data : NULL;
draw_data->CmdListsCount = draw_lists->Size;
draw_data->TotalVtxCount = draw_data->TotalIdxCount = 0;
draw_data->DisplayPos = viewport->Pos;
draw_data->DisplaySize = viewport->Size;
draw_data->FramebufferScale = ImGui::GetIO().DisplayFramebufferScale; // FIXME-VIEWPORT: This may vary on a per-monitor/viewport basis?
draw_data->OwnerViewport = viewport;
for (int n = 0; n < draw_lists->Size; n++)
{
draw_data->TotalVtxCount += draw_lists->Data[n]->VtxBuffer.Size;
draw_data->TotalIdxCount += draw_lists->Data[n]->IdxBuffer.Size;
}
}
// When using this function it is sane to ensure that float are perfectly rounded to integer values, to that e.g. (int)(max.x-min.x) in user's render produce correct result.
void ImGui::PushClipRect(const ImVec2& clip_rect_min, const ImVec2& clip_rect_max, bool intersect_with_current_clip_rect)
{
ImGuiWindow* window = GetCurrentWindow();
window->DrawList->PushClipRect(clip_rect_min, clip_rect_max, intersect_with_current_clip_rect);
window->ClipRect = window->DrawList->_ClipRectStack.back();
}
void ImGui::PopClipRect()
{
ImGuiWindow* window = GetCurrentWindow();
window->DrawList->PopClipRect();
window->ClipRect = window->DrawList->_ClipRectStack.back();
}
static ImGuiWindow* FindFrontMostVisibleChildWindow(ImGuiWindow* window)
{
for (int n = window->DC.ChildWindows.Size - 1; n >= 0; n--)
if (IsWindowActiveAndVisible(window->DC.ChildWindows[n]))
return FindFrontMostVisibleChildWindow(window->DC.ChildWindows[n]);
return window;
}
static void ImGui::EndFrameDrawDimmedBackgrounds()
{
ImGuiContext& g = *GImGui;
// Draw modal whitening background on _other_ viewports than the one the modal is one
ImGuiWindow* modal_window = GetTopMostPopupModal();
const bool dim_bg_for_modal = (modal_window != NULL);
const bool dim_bg_for_window_list = (g.NavWindowingTargetAnim != NULL);
if (dim_bg_for_modal || dim_bg_for_window_list)
for (int viewport_n = 0; viewport_n < g.Viewports.Size; viewport_n++)
{
ImGuiViewportP* viewport = g.Viewports[viewport_n];
if (modal_window && viewport == modal_window->Viewport)
continue;
if (g.NavWindowingList && viewport == g.NavWindowingList->Viewport)
continue;
if (g.NavWindowingTargetAnim && viewport == g.NavWindowingTargetAnim->Viewport)
continue;
ImDrawList* draw_list = GetForegroundDrawList(viewport);
const ImU32 dim_bg_col = GetColorU32(dim_bg_for_modal ? ImGuiCol_ModalWindowDimBg : ImGuiCol_NavWindowingDimBg, g.DimBgRatio);
draw_list->AddRectFilled(viewport->Pos, viewport->Pos + viewport->Size, dim_bg_col);
}
// Draw modal whitening background between CTRL-TAB list
if (dim_bg_for_window_list)
{
// Choose a draw list that will be front-most across all our children
ImGuiWindow* window = g.NavWindowingTargetAnim;
ImDrawList* draw_list = FindFrontMostVisibleChildWindow(window->RootWindow)->DrawList;
draw_list->PushClipRectFullScreen();
// Docking: draw modal whitening background on other nodes of a same dock tree
if (window->RootWindowDockStop->DockIsActive)
if (window->RootWindow != window->RootWindowDockStop)
RenderRectFilledWithHole(draw_list, window->RootWindow->Rect(), window->RootWindowDockStop->Rect(), GetColorU32(ImGuiCol_NavWindowingDimBg, g.DimBgRatio), g.Style.WindowRounding);
// Draw navigation selection/windowing rectangle border
float rounding = ImMax(window->WindowRounding, g.Style.WindowRounding);
ImRect bb = window->Rect();
bb.Expand(g.FontSize);
if (bb.Contains(window->Viewport->GetRect())) // If a window fits the entire viewport, adjust its highlight inward
{
bb.Expand(-g.FontSize - 1.0f);
rounding = window->WindowRounding;
}
draw_list->AddRect(bb.Min, bb.Max, GetColorU32(ImGuiCol_NavWindowingHighlight, g.NavWindowingHighlightAlpha), rounding, ~0, 3.0f);
draw_list->PopClipRect();
}
}
// This is normally called by Render(). You may want to call it directly if you want to avoid calling Render() but the gain will be very minimal.
void ImGui::EndFrame()
{
ImGuiContext& g = *GImGui;
IM_ASSERT(g.Initialized);
if (g.FrameCountEnded == g.FrameCount) // Don't process EndFrame() multiple times.
return;
IM_ASSERT(g.FrameScopeActive && "Forgot to call ImGui::NewFrame()?");
// Notify OS when our Input Method Editor cursor has moved (e.g. CJK inputs using Microsoft IME)
if (g.PlatformIO.Platform_SetImeInputPos && (g.PlatformImeLastPos.x == FLT_MAX || ImLengthSqr(g.PlatformImePos - g.PlatformImeLastPos) > 0.0001f))
if (g.PlatformImePosViewport && g.PlatformImePosViewport->PlatformWindowCreated)
{
g.PlatformIO.Platform_SetImeInputPos(g.PlatformImePosViewport, g.PlatformImePos);
g.PlatformImeLastPos = g.PlatformImePos;
g.PlatformImePosViewport = NULL;
}
// Report when there is a mismatch of Begin/BeginChild vs End/EndChild calls. Important: Remember that the Begin/BeginChild API requires you
// to always call End/EndChild even if Begin/BeginChild returns false! (this is unfortunately inconsistent with most other Begin* API).
if (g.CurrentWindowStack.Size != 1)
{
if (g.CurrentWindowStack.Size > 1)
{
IM_ASSERT(g.CurrentWindowStack.Size == 1 && "Mismatched Begin/BeginChild vs End/EndChild calls: did you forget to call End/EndChild?");
while (g.CurrentWindowStack.Size > 1) // FIXME-ERRORHANDLING
End();
}
else
{
IM_ASSERT(g.CurrentWindowStack.Size == 1 && "Mismatched Begin/BeginChild vs End/EndChild calls: did you call End/EndChild too much?");
}
}
// Hide implicit/fallback "Debug" window if it hasn't been used
g.FrameScopePushedFallbackWindow = false;
if (g.CurrentWindow && !g.CurrentWindow->WriteAccessed)
g.CurrentWindow->Active = false;
End();
// Draw modal whitening background on _other_ viewports than the one the modal is one
EndFrameDrawDimmedBackgrounds();
// Show CTRL+TAB list window
if (g.NavWindowingTarget)
NavUpdateWindowingList();
SetCurrentViewport(NULL, NULL);
// Drag and Drop: Elapse payload (if delivered, or if source stops being submitted)
if (g.DragDropActive)
{
bool is_delivered = g.DragDropPayload.Delivery;
bool is_elapsed = (g.DragDropPayload.DataFrameCount + 1 < g.FrameCount) && ((g.DragDropSourceFlags & ImGuiDragDropFlags_SourceAutoExpirePayload) || !IsMouseDown(g.DragDropMouseButton));
if (is_delivered || is_elapsed)
ClearDragDrop();
}
// Drag and Drop: Fallback for source tooltip. This is not ideal but better than nothing.
if (g.DragDropActive && g.DragDropSourceFrameCount < g.FrameCount)
{
g.DragDropWithinSourceOrTarget = true;
SetTooltip("...");
g.DragDropWithinSourceOrTarget = false;
}
// End frame
g.FrameScopeActive = false;
g.FrameCountEnded = g.FrameCount;
// Initiate moving window + handle left-click and right-click focus
UpdateMouseMovingWindowEndFrame();
// Update user-facing viewport list (g.Viewports -> g.PlatformIO.Viewports after filtering out some)
UpdateViewportsEndFrame();
// Sort the window list so that all child windows are after their parent
// We cannot do that on FocusWindow() because childs may not exist yet
g.WindowsSortBuffer.resize(0);
g.WindowsSortBuffer.reserve(g.Windows.Size);
for (int i = 0; i != g.Windows.Size; i++)
{
ImGuiWindow* window = g.Windows[i];
if (window->Active && (window->Flags & ImGuiWindowFlags_ChildWindow)) // if a child is active its parent will add it
continue;
AddWindowToSortBuffer(&g.WindowsSortBuffer, window);
}
// This usually assert if there is a mismatch between the ImGuiWindowFlags_ChildWindow / ParentWindow values and DC.ChildWindows[] in parents, aka we've done something wrong.
IM_ASSERT(g.Windows.Size == g.WindowsSortBuffer.Size);
g.Windows.swap(g.WindowsSortBuffer);
g.IO.MetricsActiveWindows = g.WindowsActiveCount;
// Unlock font atlas
g.IO.Fonts->Locked = false;
// Clear Input data for next frame
g.IO.MouseWheel = g.IO.MouseWheelH = 0.0f;
g.IO.InputQueueCharacters.resize(0);
memset(g.IO.NavInputs, 0, sizeof(g.IO.NavInputs));
}
void ImGui::Render()
{
ImGuiContext& g = *GImGui;
IM_ASSERT(g.Initialized);
if (g.FrameCountEnded != g.FrameCount)
EndFrame();
g.FrameCountRendered = g.FrameCount;
g.IO.MetricsRenderVertices = g.IO.MetricsRenderIndices = g.IO.MetricsRenderWindows = 0;
// Add background ImDrawList (for each active viewport)
for (int n = 0; n != g.Viewports.Size; n++)
{
ImGuiViewportP* viewport = g.Viewports[n];
viewport->DrawDataBuilder.Clear();
if (viewport->DrawLists[0] != NULL)
AddDrawListToDrawData(&viewport->DrawDataBuilder.Layers[0], GetBackgroundDrawList(viewport));
}
// Add ImDrawList to render (for each active window)
ImGuiWindow* windows_to_render_top_most[2];
windows_to_render_top_most[0] = (g.NavWindowingTarget && !(g.NavWindowingTarget->Flags & ImGuiWindowFlags_NoBringToFrontOnFocus)) ? g.NavWindowingTarget->RootWindow : NULL;
windows_to_render_top_most[1] = (g.NavWindowingTarget ? g.NavWindowingList : NULL);
for (int n = 0; n != g.Windows.Size; n++)
{
ImGuiWindow* window = g.Windows[n];
if (IsWindowActiveAndVisible(window) && (window->Flags & ImGuiWindowFlags_ChildWindow) == 0 && window != windows_to_render_top_most[0] && window != windows_to_render_top_most[1])
AddRootWindowToDrawData(window);
}
for (int n = 0; n < IM_ARRAYSIZE(windows_to_render_top_most); n++)
if (windows_to_render_top_most[n] && IsWindowActiveAndVisible(windows_to_render_top_most[n])) // NavWindowingTarget is always temporarily displayed as the tp-most window
AddRootWindowToDrawData(windows_to_render_top_most[n]);
// Draw software mouse cursor if requested
if (g.IO.MouseDrawCursor)
RenderMouseCursor(g.IO.MousePos, g.Style.MouseCursorScale, g.MouseCursor);
// Setup ImDrawData structures for end-user
g.IO.MetricsRenderVertices = g.IO.MetricsRenderIndices = 0;
for (int n = 0; n < g.Viewports.Size; n++)
{
ImGuiViewportP* viewport = g.Viewports[n];
viewport->DrawDataBuilder.FlattenIntoSingleLayer();
// Add foreground ImDrawList (for each active viewport)
if (viewport->DrawLists[1] != NULL)
AddDrawListToDrawData(&viewport->DrawDataBuilder.Layers[0], GetForegroundDrawList(viewport));
SetupViewportDrawData(viewport, &viewport->DrawDataBuilder.Layers[0]);
g.IO.MetricsRenderVertices += viewport->DrawData->TotalVtxCount;
g.IO.MetricsRenderIndices += viewport->DrawData->TotalIdxCount;
}
// (Legacy) Call the Render callback function. The current prefer way is to let the user retrieve GetDrawData() and call the render function themselves.
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
if (g.Viewports[0]->DrawData->CmdListsCount > 0 && g.IO.RenderDrawListsFn != NULL)
g.IO.RenderDrawListsFn(g.Viewports[0]->DrawData);
#endif
}
// Calculate text size. Text can be multi-line. Optionally ignore text after a ## marker.
// CalcTextSize("") should return ImVec2(0.0f, GImGui->FontSize)
ImVec2 ImGui::CalcTextSize(const char* text, const char* text_end, bool hide_text_after_double_hash, float wrap_width)
{
ImGuiContext& g = *GImGui;
const char* text_display_end;
if (hide_text_after_double_hash)
text_display_end = FindRenderedTextEnd(text, text_end); // Hide anything after a '##' string
else
text_display_end = text_end;
ImFont* font = g.Font;
const float font_size = g.FontSize;
if (text == text_display_end)
return ImVec2(0.0f, font_size);
ImVec2 text_size = font->CalcTextSizeA(font_size, FLT_MAX, wrap_width, text, text_display_end, NULL);
// Round
text_size.x = (float)(int)(text_size.x + 0.95f);
return text_size;
}
// Find window given position, search front-to-back
// FIXME: Note that we have an inconsequential lag here: OuterRectClipped is updated in Begin(), so windows moved programatically
// with SetWindowPos() and not SetNextWindowPos() will have that rectangle lagging by a frame at the time FindHoveredWindow() is
// called, aka before the next Begin(). Moving window isn't affected.
static void FindHoveredWindow()
{
ImGuiContext& g = *GImGui;
// Special handling for the window being moved: Ignore the mouse viewport check (because it may reset/lose its viewport during the undocking frame)
ImGuiViewportP* moving_window_viewport = g.MovingWindow ? g.MovingWindow->Viewport : NULL;
if (g.MovingWindow)
g.MovingWindow->Viewport = g.MouseViewport;
ImGuiWindow* hovered_window = NULL;
ImGuiWindow* hovered_window_ignoring_moving_window = NULL;
if (g.MovingWindow && !(g.MovingWindow->Flags & ImGuiWindowFlags_NoMouseInputs))
hovered_window = g.MovingWindow;
ImVec2 padding_regular = g.Style.TouchExtraPadding;
ImVec2 padding_for_resize_from_edges = g.IO.ConfigWindowsResizeFromEdges ? ImMax(g.Style.TouchExtraPadding, ImVec2(WINDOWS_RESIZE_FROM_EDGES_HALF_THICKNESS, WINDOWS_RESIZE_FROM_EDGES_HALF_THICKNESS)) : padding_regular;
for (int i = g.Windows.Size - 1; i >= 0; i--)
{
ImGuiWindow* window = g.Windows[i];
if (!window->Active || window->Hidden)
continue;
if (window->Flags & ImGuiWindowFlags_NoMouseInputs)
continue;
IM_ASSERT(window->Viewport);
if (window->Viewport != g.MouseViewport)
continue;
// Using the clipped AABB, a child window will typically be clipped by its parent (not always)
ImRect bb(window->OuterRectClipped);
if (window->Flags & (ImGuiWindowFlags_ChildWindow | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_AlwaysAutoResize))
bb.Expand(padding_regular);
else
bb.Expand(padding_for_resize_from_edges);
if (!bb.Contains(g.IO.MousePos))
continue;
if (window->HitTestHoleSize.x != 0)
{
// FIXME: Consider generalizing hit-testing override (with more generic data, callback, etc.) (#1512)
ImRect hole_bb((float)(window->HitTestHoleOffset.x), (float)(window->HitTestHoleOffset.y),
(float)(window->HitTestHoleOffset.x + window->HitTestHoleSize.x), (float)(window->HitTestHoleOffset.y + window->HitTestHoleSize.y));
if (hole_bb.Contains(g.IO.MousePos - window->Pos))
continue;
}
if (hovered_window == NULL)
hovered_window = window;
if (hovered_window_ignoring_moving_window == NULL && (!g.MovingWindow || window->RootWindow != g.MovingWindow->RootWindow))
hovered_window_ignoring_moving_window = window;
if (hovered_window && hovered_window_ignoring_moving_window)
break;
}
g.HoveredWindow = hovered_window;
g.HoveredRootWindow = g.HoveredWindow ? g.HoveredWindow->RootWindow : NULL;
g.HoveredWindowUnderMovingWindow = hovered_window_ignoring_moving_window;
if (g.MovingWindow)
g.MovingWindow->Viewport = moving_window_viewport;
}
// Test if mouse cursor is hovering given rectangle
// NB- Rectangle is clipped by our current clip setting
// NB- Expand the rectangle to be generous on imprecise inputs systems (g.Style.TouchExtraPadding)
bool ImGui::IsMouseHoveringRect(const ImVec2& r_min, const ImVec2& r_max, bool clip)
{
ImGuiContext& g = *GImGui;
// Clip
ImRect rect_clipped(r_min, r_max);
if (clip)
rect_clipped.ClipWith(g.CurrentWindow->ClipRect);
// Expand for touch input
const ImRect rect_for_touch(rect_clipped.Min - g.Style.TouchExtraPadding, rect_clipped.Max + g.Style.TouchExtraPadding);
if (!rect_for_touch.Contains(g.IO.MousePos))
return false;
if (!g.MouseViewport->GetRect().Overlaps(rect_clipped))
return false;
return true;
}
int ImGui::GetKeyIndex(ImGuiKey imgui_key)
{
IM_ASSERT(imgui_key >= 0 && imgui_key < ImGuiKey_COUNT);
ImGuiContext& g = *GImGui;
return g.IO.KeyMap[imgui_key];
}
// Note that imgui doesn't know the semantic of each entry of io.KeysDown[]. Use your own indices/enums according to how your back-end/engine stored them into io.KeysDown[]!
bool ImGui::IsKeyDown(int user_key_index)
{
if (user_key_index < 0)
return false;
ImGuiContext& g = *GImGui;
IM_ASSERT(user_key_index >= 0 && user_key_index < IM_ARRAYSIZE(g.IO.KeysDown));
return g.IO.KeysDown[user_key_index];
}
int ImGui::CalcTypematicPressedRepeatAmount(float t, float t_prev, float repeat_delay, float repeat_rate)
{
if (t == 0.0f)
return 1;
if (t <= repeat_delay || repeat_rate <= 0.0f)
return 0;
const int count = (int)((t - repeat_delay) / repeat_rate) - (int)((t_prev - repeat_delay) / repeat_rate);
return (count > 0) ? count : 0;
}
int ImGui::GetKeyPressedAmount(int key_index, float repeat_delay, float repeat_rate)
{
ImGuiContext& g = *GImGui;
if (key_index < 0)
return 0;
IM_ASSERT(key_index >= 0 && key_index < IM_ARRAYSIZE(g.IO.KeysDown));
const float t = g.IO.KeysDownDuration[key_index];
return CalcTypematicPressedRepeatAmount(t, t - g.IO.DeltaTime, repeat_delay, repeat_rate);
}
bool ImGui::IsKeyPressed(int user_key_index, bool repeat)
{
ImGuiContext& g = *GImGui;
if (user_key_index < 0)
return false;
IM_ASSERT(user_key_index >= 0 && user_key_index < IM_ARRAYSIZE(g.IO.KeysDown));
const float t = g.IO.KeysDownDuration[user_key_index];
if (t == 0.0f)
return true;
if (repeat && t > g.IO.KeyRepeatDelay)
return GetKeyPressedAmount(user_key_index, g.IO.KeyRepeatDelay, g.IO.KeyRepeatRate) > 0;
return false;
}
bool ImGui::IsKeyReleased(int user_key_index)
{
ImGuiContext& g = *GImGui;
if (user_key_index < 0) return false;
IM_ASSERT(user_key_index >= 0 && user_key_index < IM_ARRAYSIZE(g.IO.KeysDown));
return g.IO.KeysDownDurationPrev[user_key_index] >= 0.0f && !g.IO.KeysDown[user_key_index];
}
bool ImGui::IsMouseDown(int button)
{
ImGuiContext& g = *GImGui;
IM_ASSERT(button >= 0 && button < IM_ARRAYSIZE(g.IO.MouseDown));
return g.IO.MouseDown[button];
}
bool ImGui::IsAnyMouseDown()
{
ImGuiContext& g = *GImGui;
for (int n = 0; n < IM_ARRAYSIZE(g.IO.MouseDown); n++)
if (g.IO.MouseDown[n])
return true;
return false;
}
bool ImGui::IsMouseClicked(int button, bool repeat)
{
ImGuiContext& g = *GImGui;
IM_ASSERT(button >= 0 && button < IM_ARRAYSIZE(g.IO.MouseDown));
const float t = g.IO.MouseDownDuration[button];
if (t == 0.0f)
return true;
if (repeat && t > g.IO.KeyRepeatDelay)
{
// FIXME: 2019/05/03: Our old repeat code was wrong here and led to doubling the repeat rate, which made it an ok rate for repeat on mouse hold.
int amount = CalcTypematicPressedRepeatAmount(t, t - g.IO.DeltaTime, g.IO.KeyRepeatDelay, g.IO.KeyRepeatRate * 0.5f);
if (amount > 0)
return true;
}
return false;
}
bool ImGui::IsMouseReleased(int button)
{
ImGuiContext& g = *GImGui;
IM_ASSERT(button >= 0 && button < IM_ARRAYSIZE(g.IO.MouseDown));
return g.IO.MouseReleased[button];
}
bool ImGui::IsMouseDoubleClicked(int button)
{
ImGuiContext& g = *GImGui;
IM_ASSERT(button >= 0 && button < IM_ARRAYSIZE(g.IO.MouseDown));
return g.IO.MouseDoubleClicked[button];
}
// [Internal] This doesn't test if the button is pressed
bool ImGui::IsMouseDragPastThreshold(int button, float lock_threshold)
{
ImGuiContext& g = *GImGui;
IM_ASSERT(button >= 0 && button < IM_ARRAYSIZE(g.IO.MouseDown));
if (lock_threshold < 0.0f)
lock_threshold = g.IO.MouseDragThreshold;
return g.IO.MouseDragMaxDistanceSqr[button] >= lock_threshold * lock_threshold;
}
bool ImGui::IsMouseDragging(int button, float lock_threshold)
{
ImGuiContext& g = *GImGui;
IM_ASSERT(button >= 0 && button < IM_ARRAYSIZE(g.IO.MouseDown));
if (!g.IO.MouseDown[button])
return false;
return IsMouseDragPastThreshold(button, lock_threshold);
}
ImVec2 ImGui::GetMousePos()
{
return GImGui->IO.MousePos;
}
// NB: prefer to call right after BeginPopup(). At the time Selectable/MenuItem is activated, the popup is already closed!
ImVec2 ImGui::GetMousePosOnOpeningCurrentPopup()
{
ImGuiContext& g = *GImGui;
if (g.BeginPopupStack.Size > 0)
return g.OpenPopupStack[g.BeginPopupStack.Size-1].OpenMousePos;
return g.IO.MousePos;
}
// We typically use ImVec2(-FLT_MAX,-FLT_MAX) to denote an invalid mouse position.
bool ImGui::IsMousePosValid(const ImVec2* mouse_pos)
{
// The assert is only to silence a false-positive in XCode Static Analysis.
// Because GImGui is not dereferenced in every code path, the static analyzer assume that it may be NULL (which it doesn't for other functions).
IM_ASSERT(GImGui != NULL);
const float MOUSE_INVALID = -256000.0f;
ImVec2 p = mouse_pos ? *mouse_pos : GImGui->IO.MousePos;
return p.x >= MOUSE_INVALID && p.y >= MOUSE_INVALID;
}
// Return the delta from the initial clicking position while the mouse button is clicked or was just released.
// This is locked and return 0.0f until the mouse moves past a distance threshold at least once.
// NB: This is only valid if IsMousePosValid(). Back-ends in theory should always keep mouse position valid when dragging even outside the client window.
ImVec2 ImGui::GetMouseDragDelta(int button, float lock_threshold)
{
ImGuiContext& g = *GImGui;
IM_ASSERT(button >= 0 && button < IM_ARRAYSIZE(g.IO.MouseDown));
if (lock_threshold < 0.0f)
lock_threshold = g.IO.MouseDragThreshold;
if (g.IO.MouseDown[button] || g.IO.MouseReleased[button])
if (g.IO.MouseDragMaxDistanceSqr[button] >= lock_threshold * lock_threshold)
if (IsMousePosValid(&g.IO.MousePos) && IsMousePosValid(&g.IO.MouseClickedPos[button]))
return g.IO.MousePos - g.IO.MouseClickedPos[button];
return ImVec2(0.0f, 0.0f);
}
void ImGui::ResetMouseDragDelta(int button)
{
ImGuiContext& g = *GImGui;
IM_ASSERT(button >= 0 && button < IM_ARRAYSIZE(g.IO.MouseDown));
// NB: We don't need to reset g.IO.MouseDragMaxDistanceSqr
g.IO.MouseClickedPos[button] = g.IO.MousePos;
}
ImGuiMouseCursor ImGui::GetMouseCursor()
{
return GImGui->MouseCursor;
}
void ImGui::SetMouseCursor(ImGuiMouseCursor cursor_type)
{
GImGui->MouseCursor = cursor_type;
}
void ImGui::CaptureKeyboardFromApp(bool capture)
{
GImGui->WantCaptureKeyboardNextFrame = capture ? 1 : 0;
}
void ImGui::CaptureMouseFromApp(bool capture)
{
GImGui->WantCaptureMouseNextFrame = capture ? 1 : 0;
}
bool ImGui::IsItemActive()
{
ImGuiContext& g = *GImGui;
if (g.ActiveId)
{
ImGuiWindow* window = g.CurrentWindow;
return g.ActiveId == window->DC.LastItemId;
}
return false;
}
bool ImGui::IsItemActivated()
{
ImGuiContext& g = *GImGui;
if (g.ActiveId)
{
ImGuiWindow* window = g.CurrentWindow;
if (g.ActiveId == window->DC.LastItemId && g.ActiveIdPreviousFrame != window->DC.LastItemId)
return true;
}
return false;
}
bool ImGui::IsItemDeactivated()
{
ImGuiContext& g = *GImGui;
ImGuiWindow* window = g.CurrentWindow;
if (window->DC.LastItemStatusFlags & ImGuiItemStatusFlags_HasDeactivated)
return (window->DC.LastItemStatusFlags & ImGuiItemStatusFlags_Deactivated) != 0;
return (g.ActiveIdPreviousFrame == window->DC.LastItemId && g.ActiveIdPreviousFrame != 0 && g.ActiveId != window->DC.LastItemId);
}
bool ImGui::IsItemDeactivatedAfterEdit()
{
ImGuiContext& g = *GImGui;
return IsItemDeactivated() && (g.ActiveIdPreviousFrameHasBeenEditedBefore || (g.ActiveId == 0 && g.ActiveIdHasBeenEditedBefore));
}
bool ImGui::IsItemFocused()
{
ImGuiContext& g = *GImGui;
ImGuiWindow* window = g.CurrentWindow;
if (g.NavId == 0 || g.NavDisableHighlight || g.NavId != window->DC.LastItemId)
return false;
// Special handling for the dummy item after Begin() which represent the title bar or tab.
// When the window is collapsed (SkipItems==true) that last item will never be overwritten so we need to detect the case.
if (window->DC.LastItemId == window->ID && window->WriteAccessed)
return false;
return true;
}
bool ImGui::IsItemClicked(int mouse_button)
{
return IsMouseClicked(mouse_button) && IsItemHovered(ImGuiHoveredFlags_None);
}
bool ImGui::IsItemToggledSelection()
{
ImGuiContext& g = *GImGui;
return (g.CurrentWindow->DC.LastItemStatusFlags & ImGuiItemStatusFlags_ToggledSelection) ? true : false;
}
bool ImGui::IsAnyItemHovered()
{
ImGuiContext& g = *GImGui;
return g.HoveredId != 0 || g.HoveredIdPreviousFrame != 0;
}
bool ImGui::IsAnyItemActive()
{
ImGuiContext& g = *GImGui;
return g.ActiveId != 0;
}
bool ImGui::IsAnyItemFocused()
{
ImGuiContext& g = *GImGui;
return g.NavId != 0 && !g.NavDisableHighlight;
}
bool ImGui::IsItemVisible()
{
ImGuiWindow* window = GetCurrentWindowRead();
return window->ClipRect.Overlaps(window->DC.LastItemRect);
}
bool ImGui::IsItemEdited()
{
ImGuiWindow* window = GetCurrentWindowRead();
return (window->DC.LastItemStatusFlags & ImGuiItemStatusFlags_Edited) != 0;
}
// Allow last item to be overlapped by a subsequent item. Both may be activated during the same frame before the later one takes priority.
void ImGui::SetItemAllowOverlap()
{
ImGuiContext& g = *GImGui;
if (g.HoveredId == g.CurrentWindow->DC.LastItemId)
g.HoveredIdAllowOverlap = true;
if (g.ActiveId == g.CurrentWindow->DC.LastItemId)
g.ActiveIdAllowOverlap = true;
}
ImVec2 ImGui::GetItemRectMin()
{
ImGuiWindow* window = GetCurrentWindowRead();
return window->DC.LastItemRect.Min;
}
ImVec2 ImGui::GetItemRectMax()
{
ImGuiWindow* window = GetCurrentWindowRead();
return window->DC.LastItemRect.Max;
}
ImVec2 ImGui::GetItemRectSize()
{
ImGuiWindow* window = GetCurrentWindowRead();
return window->DC.LastItemRect.GetSize();
}
static bool ImGui::BeginChildEx(const char* name, ImGuiID id, const ImVec2& size_arg, bool border, ImGuiWindowFlags flags)
{
ImGuiContext& g = *GImGui;
ImGuiWindow* parent_window = g.CurrentWindow;
flags |= ImGuiWindowFlags_NoTitleBar|ImGuiWindowFlags_NoResize|ImGuiWindowFlags_NoSavedSettings|ImGuiWindowFlags_ChildWindow|ImGuiWindowFlags_NoDocking;
flags |= (parent_window->Flags & ImGuiWindowFlags_NoMove); // Inherit the NoMove flag
// Size
const ImVec2 content_avail = GetContentRegionAvail();
ImVec2 size = ImFloor(size_arg);
const int auto_fit_axises = ((size.x == 0.0f) ? (1 << ImGuiAxis_X) : 0x00) | ((size.y == 0.0f) ? (1 << ImGuiAxis_Y) : 0x00);
if (size.x <= 0.0f)
size.x = ImMax(content_avail.x + size.x, 4.0f); // Arbitrary minimum child size (0.0f causing too much issues)
if (size.y <= 0.0f)
size.y = ImMax(content_avail.y + size.y, 4.0f);
SetNextWindowSize(size);
// Build up name. If you need to append to a same child from multiple location in the ID stack, use BeginChild(ImGuiID id) with a stable value.
char title[256];
if (name)
ImFormatString(title, IM_ARRAYSIZE(title), "%s/%s_%08X", parent_window->Name, name, id);
else
ImFormatString(title, IM_ARRAYSIZE(title), "%s/%08X", parent_window->Name, id);
const float backup_border_size = g.Style.ChildBorderSize;
if (!border)
g.Style.ChildBorderSize = 0.0f;
bool ret = Begin(title, NULL, flags);
g.Style.ChildBorderSize = backup_border_size;
ImGuiWindow* child_window = g.CurrentWindow;
child_window->ChildId = id;
child_window->AutoFitChildAxises = auto_fit_axises;
// Set the cursor to handle case where the user called SetNextWindowPos()+BeginChild() manually.
// While this is not really documented/defined, it seems that the expected thing to do.
if (child_window->BeginCount == 1)
parent_window->DC.CursorPos = child_window->Pos;
// Process navigation-in immediately so NavInit can run on first frame
if (g.NavActivateId == id && !(flags & ImGuiWindowFlags_NavFlattened) && (child_window->DC.NavLayerActiveMask != 0 || child_window->DC.NavHasScroll))
{
FocusWindow(child_window);
NavInitWindow(child_window, false);
SetActiveID(id+1, child_window); // Steal ActiveId with a dummy id so that key-press won't activate child item
g.ActiveIdSource = ImGuiInputSource_Nav;
}
return ret;
}
bool ImGui::BeginChild(const char* str_id, const ImVec2& size_arg, bool border, ImGuiWindowFlags extra_flags)
{
ImGuiWindow* window = GetCurrentWindow();
return BeginChildEx(str_id, window->GetID(str_id), size_arg, border, extra_flags);
}
bool ImGui::BeginChild(ImGuiID id, const ImVec2& size_arg, bool border, ImGuiWindowFlags extra_flags)
{
IM_ASSERT(id != 0);
return BeginChildEx(NULL, id, size_arg, border, extra_flags);
}
void ImGui::EndChild()
{
ImGuiContext& g = *GImGui;
ImGuiWindow* window = g.CurrentWindow;
IM_ASSERT(window->Flags & ImGuiWindowFlags_ChildWindow); // Mismatched BeginChild()/EndChild() callss
if (window->BeginCount > 1)
{
End();
}
else
{
ImVec2 sz = window->Size;
if (window->AutoFitChildAxises & (1 << ImGuiAxis_X)) // Arbitrary minimum zero-ish child size of 4.0f causes less trouble than a 0.0f
sz.x = ImMax(4.0f, sz.x);
if (window->AutoFitChildAxises & (1 << ImGuiAxis_Y))
sz.y = ImMax(4.0f, sz.y);
End();
ImGuiWindow* parent_window = g.CurrentWindow;
ImRect bb(parent_window->DC.CursorPos, parent_window->DC.CursorPos + sz);
ItemSize(sz);
if ((window->DC.NavLayerActiveMask != 0 || window->DC.NavHasScroll) && !(window->Flags & ImGuiWindowFlags_NavFlattened))
{
ItemAdd(bb, window->ChildId);
RenderNavHighlight(bb, window->ChildId);
// When browsing a window that has no activable items (scroll only) we keep a highlight on the child
if (window->DC.NavLayerActiveMask == 0 && window == g.NavWindow)
RenderNavHighlight(ImRect(bb.Min - ImVec2(2,2), bb.Max + ImVec2(2,2)), g.NavId, ImGuiNavHighlightFlags_TypeThin);
}
else
{
// Not navigable into
ItemAdd(bb, 0);
}
}
}
// Helper to create a child window / scrolling region that looks like a normal widget frame.
bool ImGui::BeginChildFrame(ImGuiID id, const ImVec2& size, ImGuiWindowFlags extra_flags)
{
ImGuiContext& g = *GImGui;
const ImGuiStyle& style = g.Style;
PushStyleColor(ImGuiCol_ChildBg, style.Colors[ImGuiCol_FrameBg]);
PushStyleVar(ImGuiStyleVar_ChildRounding, style.FrameRounding);
PushStyleVar(ImGuiStyleVar_ChildBorderSize, style.FrameBorderSize);
PushStyleVar(ImGuiStyleVar_WindowPadding, style.FramePadding);
bool ret = BeginChild(id, size, true, ImGuiWindowFlags_NoMove | ImGuiWindowFlags_AlwaysUseWindowPadding | extra_flags);
PopStyleVar(3);
PopStyleColor();
return ret;
}
void ImGui::EndChildFrame()
{
EndChild();
}
// Save and compare stack sizes on Begin()/End() to detect usage errors
static void CheckStacksSize(ImGuiWindow* window, bool write)
{
// NOT checking: DC.ItemWidth, DC.AllowKeyboardFocus, DC.ButtonRepeat, DC.TextWrapPos (per window) to allow user to conveniently push once and not pop (they are cleared on Begin)
ImGuiContext& g = *GImGui;
short* p_backup = &window->DC.StackSizesBackup[0];
{ int current = window->IDStack.Size; if (write) *p_backup = (short)current; else IM_ASSERT(*p_backup == current && "PushID/PopID or TreeNode/TreePop Mismatch!"); p_backup++; } // Too few or too many PopID()/TreePop()
{ int current = window->DC.GroupStack.Size; if (write) *p_backup = (short)current; else IM_ASSERT(*p_backup == current && "BeginGroup/EndGroup Mismatch!"); p_backup++; } // Too few or too many EndGroup()
{ int current = g.BeginPopupStack.Size; if (write) *p_backup = (short)current; else IM_ASSERT(*p_backup == current && "BeginMenu/EndMenu or BeginPopup/EndPopup Mismatch"); p_backup++;}// Too few or too many EndMenu()/EndPopup()
// For color, style and font stacks there is an incentive to use Push/Begin/Pop/.../End patterns, so we relax our checks a little to allow them.
{ int current = g.ColorModifiers.Size; if (write) *p_backup = (short)current; else IM_ASSERT(*p_backup >= current && "PushStyleColor/PopStyleColor Mismatch!"); p_backup++; } // Too few or too many PopStyleColor()
{ int current = g.StyleModifiers.Size; if (write) *p_backup = (short)current; else IM_ASSERT(*p_backup >= current && "PushStyleVar/PopStyleVar Mismatch!"); p_backup++; } // Too few or too many PopStyleVar()
{ int current = g.FontStack.Size; if (write) *p_backup = (short)current; else IM_ASSERT(*p_backup >= current && "PushFont/PopFont Mismatch!"); p_backup++; } // Too few or too many PopFont()
IM_ASSERT(p_backup == window->DC.StackSizesBackup + IM_ARRAYSIZE(window->DC.StackSizesBackup));
}
static void SetWindowConditionAllowFlags(ImGuiWindow* window, ImGuiCond flags, bool enabled)
{
window->SetWindowPosAllowFlags = enabled ? (window->SetWindowPosAllowFlags | flags) : (window->SetWindowPosAllowFlags & ~flags);
window->SetWindowSizeAllowFlags = enabled ? (window->SetWindowSizeAllowFlags | flags) : (window->SetWindowSizeAllowFlags & ~flags);
window->SetWindowCollapsedAllowFlags = enabled ? (window->SetWindowCollapsedAllowFlags | flags) : (window->SetWindowCollapsedAllowFlags & ~flags);
window->SetWindowDockAllowFlags = enabled ? (window->SetWindowDockAllowFlags | flags) : (window->SetWindowDockAllowFlags & ~flags);
}
ImGuiWindow* ImGui::FindWindowByID(ImGuiID id)
{
ImGuiContext& g = *GImGui;
return (ImGuiWindow*)g.WindowsById.GetVoidPtr(id);
}
ImGuiWindow* ImGui::FindWindowByName(const char* name)
{
ImGuiID id = ImHashStr(name);
return FindWindowByID(id);
}
static ImGuiWindow* CreateNewWindow(const char* name, ImVec2 size, ImGuiWindowFlags flags)
{
ImGuiContext& g = *GImGui;
//IMGUI_DEBUG_LOG("CreateNewWindow '%s', flags = 0x%08X\n", name, flags);
// Create window the first time
ImGuiWindow* window = IM_NEW(ImGuiWindow)(&g, name);
window->Flags = flags;
g.WindowsById.SetVoidPtr(window->ID, window);
// Default/arbitrary window position. Use SetNextWindowPos() with the appropriate condition flag to change the initial position of a window.
ImGuiViewport* main_viewport = ImGui::GetMainViewport();
window->Pos = main_viewport->Pos + ImVec2(60, 60);
// User can disable loading and saving of settings. Tooltip and child windows also don't store settings.
if (!(flags & ImGuiWindowFlags_NoSavedSettings))
if (ImGuiWindowSettings* settings = ImGui::FindWindowSettings(window->ID))
{
// Retrieve settings from .ini file
window->SettingsIdx = g.SettingsWindows.index_from_ptr(settings);
SetWindowConditionAllowFlags(window, ImGuiCond_FirstUseEver, false);
if (settings->ViewportId)
{
window->ViewportId = settings->ViewportId;
window->ViewportPos = ImVec2(settings->ViewportPos.x, settings->ViewportPos.y);
}
else
{
window->ViewportPos = main_viewport->Pos;
}
window->Pos = ImVec2(settings->Pos.x + window->ViewportPos.x, settings->Pos.y + window->ViewportPos.y);
window->Collapsed = settings->Collapsed;
if (settings->Size.x > 0 && settings->Size.y > 0)
size = ImVec2(settings->Size.x, settings->Size.y);
window->DockId = settings->DockId;
window->DockOrder = settings->DockOrder;
}
window->Size = window->SizeFull = ImFloor(size);
window->DC.CursorStartPos = window->DC.CursorMaxPos = window->Pos; // So first call to CalcContentSize() doesn't return crazy values
if ((flags & ImGuiWindowFlags_AlwaysAutoResize) != 0)
{
window->AutoFitFramesX = window->AutoFitFramesY = 2;
window->AutoFitOnlyGrows = false;
}
else
{
if (window->Size.x <= 0.0f)
window->AutoFitFramesX = 2;
if (window->Size.y <= 0.0f)
window->AutoFitFramesY = 2;
window->AutoFitOnlyGrows = (window->AutoFitFramesX > 0) || (window->AutoFitFramesY > 0);
}
g.WindowsFocusOrder.push_back(window);
if (flags & ImGuiWindowFlags_NoBringToFrontOnFocus)
g.Windows.push_front(window); // Quite slow but rare and only once
else
g.Windows.push_back(window);
return window;
}
static ImGuiWindow* GetWindowForTitleDisplay(ImGuiWindow* window)
{
return window->DockNodeAsHost ? window->DockNodeAsHost->VisibleWindow : window;
}
static ImGuiWindow* GetWindowForTitleAndMenuHeight(ImGuiWindow* window)
{
return (window->DockNodeAsHost && window->DockNodeAsHost->VisibleWindow) ? window->DockNodeAsHost->VisibleWindow : window;
}
static ImVec2 CalcWindowSizeAfterConstraint(ImGuiWindow* window, ImVec2 new_size)
{
ImGuiContext& g = *GImGui;
if (g.NextWindowData.Flags & ImGuiNextWindowDataFlags_HasSizeConstraint)
{
// Using -1,-1 on either X/Y axis to preserve the current size.
ImRect cr = g.NextWindowData.SizeConstraintRect;
new_size.x = (cr.Min.x >= 0 && cr.Max.x >= 0) ? ImClamp(new_size.x, cr.Min.x, cr.Max.x) : window->SizeFull.x;
new_size.y = (cr.Min.y >= 0 && cr.Max.y >= 0) ? ImClamp(new_size.y, cr.Min.y, cr.Max.y) : window->SizeFull.y;
if (g.NextWindowData.SizeCallback)
{
ImGuiSizeCallbackData data;
data.UserData = g.NextWindowData.SizeCallbackUserData;
data.Pos = window->Pos;
data.CurrentSize = window->SizeFull;
data.DesiredSize = new_size;
g.NextWindowData.SizeCallback(&data);
new_size = data.DesiredSize;
}
new_size.x = ImFloor(new_size.x);
new_size.y = ImFloor(new_size.y);
}
// Minimum size
if (!(window->Flags & (ImGuiWindowFlags_ChildWindow | ImGuiWindowFlags_AlwaysAutoResize)))
{
ImGuiWindow* window_for_height = GetWindowForTitleAndMenuHeight(window);
new_size = ImMax(new_size, g.Style.WindowMinSize);
new_size.y = ImMax(new_size.y, window_for_height->TitleBarHeight() + window_for_height->MenuBarHeight() + ImMax(0.0f, g.Style.WindowRounding - 1.0f)); // Reduce artifacts with very small windows
}
return new_size;
}
static ImVec2 CalcWindowContentSize(ImGuiWindow* window)
{
if (window->Collapsed)
if (window->AutoFitFramesX <= 0 && window->AutoFitFramesY <= 0)
return window->ContentSize;
if (window->Hidden && window->HiddenFramesCannotSkipItems == 0 && window->HiddenFramesCanSkipItems > 0)
return window->ContentSize;
ImVec2 sz;
sz.x = (float)(int)((window->ContentSizeExplicit.x != 0.0f) ? window->ContentSizeExplicit.x : window->DC.CursorMaxPos.x - window->DC.CursorStartPos.x);
sz.y = (float)(int)((window->ContentSizeExplicit.y != 0.0f) ? window->ContentSizeExplicit.y : window->DC.CursorMaxPos.y - window->DC.CursorStartPos.y);
return sz;
}
static ImVec2 CalcWindowAutoFitSize(ImGuiWindow* window, const ImVec2& size_contents)
{
ImGuiContext& g = *GImGui;
ImGuiStyle& style = g.Style;
ImVec2 size_decorations = ImVec2(0.0f, window->TitleBarHeight() + window->MenuBarHeight());
ImVec2 size_pad = window->WindowPadding * 2.0f;
ImVec2 size_desired = size_contents + size_pad + size_decorations;
if (window->Flags & ImGuiWindowFlags_Tooltip)
{
// Tooltip always resize
return size_desired;
}
else
{
// Maximum window size is determined by the viewport size or monitor size
const bool is_popup = (window->Flags & ImGuiWindowFlags_Popup) != 0;
const bool is_menu = (window->Flags & ImGuiWindowFlags_ChildMenu) != 0;
ImVec2 size_min = style.WindowMinSize;
if (is_popup || is_menu) // Popups and menus bypass style.WindowMinSize by default, but we give then a non-zero minimum size to facilitate understanding problematic cases (e.g. empty popups)
size_min = ImMin(size_min, ImVec2(4.0f, 4.0f));
ImVec2 avail_size = window->Viewport->Size;
if (window->ViewportOwned)
avail_size = ImVec2(FLT_MAX, FLT_MAX);
const int monitor_idx = window->ViewportAllowPlatformMonitorExtend;
if (monitor_idx >= 0 && monitor_idx < g.PlatformIO.Monitors.Size)
avail_size = g.PlatformIO.Monitors[monitor_idx].WorkSize;
ImVec2 size_auto_fit = ImClamp(size_desired, size_min, ImMax(size_min, avail_size - g.Style.DisplaySafeAreaPadding * 2.0f));
// When the window cannot fit all contents (either because of constraints, either because screen is too small),
// we are growing the size on the other axis to compensate for expected scrollbar. FIXME: Might turn bigger than ViewportSize-WindowPadding.
ImVec2 size_auto_fit_after_constraint = CalcWindowSizeAfterConstraint(window, size_auto_fit);
bool will_have_scrollbar_x = (size_auto_fit_after_constraint.x - size_pad.x - size_decorations.x < size_contents.x && !(window->Flags & ImGuiWindowFlags_NoScrollbar) && (window->Flags & ImGuiWindowFlags_HorizontalScrollbar)) || (window->Flags & ImGuiWindowFlags_AlwaysHorizontalScrollbar);
bool will_have_scrollbar_y = (size_auto_fit_after_constraint.y - size_pad.y - size_decorations.y < size_contents.y && !(window->Flags & ImGuiWindowFlags_NoScrollbar)) || (window->Flags & ImGuiWindowFlags_AlwaysVerticalScrollbar);
if (will_have_scrollbar_x)
size_auto_fit.y += style.ScrollbarSize;
if (will_have_scrollbar_y)
size_auto_fit.x += style.ScrollbarSize;
return size_auto_fit;
}
}
ImVec2 ImGui::CalcWindowExpectedSize(ImGuiWindow* window)
{
ImVec2 size_contents = CalcWindowContentSize(window);
ImVec2 size_auto_fit = CalcWindowAutoFitSize(window, size_contents);
ImVec2 size_final = CalcWindowSizeAfterConstraint(window, size_auto_fit);
return size_final;
}
static ImGuiCol GetWindowBgColorIdxFromFlags(ImGuiWindowFlags flags)
{
if (flags & (ImGuiWindowFlags_Tooltip | ImGuiWindowFlags_Popup))
return ImGuiCol_PopupBg;
if (flags & ImGuiWindowFlags_ChildWindow)
return ImGuiCol_ChildBg;
return ImGuiCol_WindowBg;
}
static void CalcResizePosSizeFromAnyCorner(ImGuiWindow* window, const ImVec2& corner_target, const ImVec2& corner_norm, ImVec2* out_pos, ImVec2* out_size)
{
ImVec2 pos_min = ImLerp(corner_target, window->Pos, corner_norm); // Expected window upper-left
ImVec2 pos_max = ImLerp(window->Pos + window->Size, corner_target, corner_norm); // Expected window lower-right
ImVec2 size_expected = pos_max - pos_min;
ImVec2 size_constrained = CalcWindowSizeAfterConstraint(window, size_expected);
*out_pos = pos_min;
if (corner_norm.x == 0.0f)
out_pos->x -= (size_constrained.x - size_expected.x);
if (corner_norm.y == 0.0f)
out_pos->y -= (size_constrained.y - size_expected.y);
*out_size = size_constrained;
}
struct ImGuiResizeGripDef
{
ImVec2 CornerPosN;
ImVec2 InnerDir;
int AngleMin12, AngleMax12;
};
static const ImGuiResizeGripDef resize_grip_def[4] =
{
{ ImVec2(1,1), ImVec2(-1,-1), 0, 3 }, // Lower right
{ ImVec2(0,1), ImVec2(+1,-1), 3, 6 }, // Lower left
{ ImVec2(0,0), ImVec2(+1,+1), 6, 9 }, // Upper left
{ ImVec2(1,0), ImVec2(-1,+1), 9,12 }, // Upper right
};
static ImRect GetResizeBorderRect(ImGuiWindow* window, int border_n, float perp_padding, float thickness)
{
ImRect rect = window->Rect();
if (thickness == 0.0f) rect.Max -= ImVec2(1,1);
if (border_n == 0) return ImRect(rect.Min.x + perp_padding, rect.Min.y - thickness, rect.Max.x - perp_padding, rect.Min.y + thickness); // Top
if (border_n == 1) return ImRect(rect.Max.x - thickness, rect.Min.y + perp_padding, rect.Max.x + thickness, rect.Max.y - perp_padding); // Right
if (border_n == 2) return ImRect(rect.Min.x + perp_padding, rect.Max.y - thickness, rect.Max.x - perp_padding, rect.Max.y + thickness); // Bottom
if (border_n == 3) return ImRect(rect.Min.x - thickness, rect.Min.y + perp_padding, rect.Min.x + thickness, rect.Max.y - perp_padding); // Left
IM_ASSERT(0);
return ImRect();
}
// Handle resize for: Resize Grips, Borders, Gamepad
// Return true when using auto-fit (double click on resize grip)
static bool ImGui::UpdateManualResize(ImGuiWindow* window, const ImVec2& size_auto_fit, int* border_held, int resize_grip_count, ImU32 resize_grip_col[4])
{
ImGuiContext& g = *GImGui;
ImGuiWindowFlags flags = window->Flags;
if ((flags & ImGuiWindowFlags_NoResize) || (flags & ImGuiWindowFlags_AlwaysAutoResize) || window->AutoFitFramesX > 0 || window->AutoFitFramesY > 0)
return false;
if (window->WasActive == false) // Early out to avoid running this code for e.g. an hidden implicit/fallback Debug window.
return false;
bool ret_auto_fit = false;
const int resize_border_count = g.IO.ConfigWindowsResizeFromEdges ? 4 : 0;
const float grip_draw_size = (float)(int)ImMax(g.FontSize * 1.35f, window->WindowRounding + 1.0f + g.FontSize * 0.2f);
const float grip_hover_inner_size = (float)(int)(grip_draw_size * 0.75f);
const float grip_hover_outer_size = g.IO.ConfigWindowsResizeFromEdges ? WINDOWS_RESIZE_FROM_EDGES_HALF_THICKNESS : 0.0f;
ImVec2 pos_target(FLT_MAX, FLT_MAX);
ImVec2 size_target(FLT_MAX, FLT_MAX);
// Clip mouse interaction rectangles within the viewport (in practice the narrowing is going to happen most of the time).
// - Not narrowing would mostly benefit the situation where OS windows _without_ decoration have a threshold for hovering when outside their limits.
// This is however not the case with current back-ends under Win32, but a custom borderless window implementation would benefit from it.
// - When decoration are enabled we typically benefit from that distance, but then our resize elements would be conflicting with OS resize elements, so we also narrow.
// - Note that we are unable to tell if the platform setup allows hovering with a distance threshold (on Win32, decorated window have such threshold).
ImRect clip_viewport_rect(-FLT_MAX, -FLT_MAX, +FLT_MAX, +FLT_MAX);
if (!(g.IO.BackendFlags & ImGuiBackendFlags_HasMouseHoveredViewport) || (g.IO.MouseHoveredViewport != window->ViewportId) || !(window->Viewport->Flags & ImGuiViewportFlags_NoDecoration))
clip_viewport_rect = window->Viewport->GetRect();
// Resize grips and borders are on layer 1
window->DC.NavLayerCurrent = ImGuiNavLayer_Menu;
window->DC.NavLayerCurrentMask = (1 << ImGuiNavLayer_Menu);
// Manual resize grips
PushID("#RESIZE");
for (int resize_grip_n = 0; resize_grip_n < resize_grip_count; resize_grip_n++)
{
const ImGuiResizeGripDef& grip = resize_grip_def[resize_grip_n];
const ImVec2 corner = ImLerp(window->Pos, window->Pos + window->Size, grip.CornerPosN);
// Using the FlattenChilds button flag we make the resize button accessible even if we are hovering over a child window
ImRect resize_rect(corner - grip.InnerDir * grip_hover_outer_size, corner + grip.InnerDir * grip_hover_inner_size);
if (resize_rect.Min.x > resize_rect.Max.x) ImSwap(resize_rect.Min.x, resize_rect.Max.x);
if (resize_rect.Min.y > resize_rect.Max.y) ImSwap(resize_rect.Min.y, resize_rect.Max.y);
resize_rect.ClipWith(clip_viewport_rect);
bool hovered, held;
ButtonBehavior(resize_rect, window->GetID((void*)(intptr_t)resize_grip_n), &hovered, &held, ImGuiButtonFlags_FlattenChildren | ImGuiButtonFlags_NoNavFocus);
//GetForegroundDrawList(window)->AddRect(resize_rect.Min, resize_rect.Max, IM_COL32(255, 255, 0, 255));
if (hovered || held)
g.MouseCursor = (resize_grip_n & 1) ? ImGuiMouseCursor_ResizeNESW : ImGuiMouseCursor_ResizeNWSE;
if (held && g.IO.MouseDoubleClicked[0] && resize_grip_n == 0)
{
// Manual auto-fit when double-clicking
size_target = CalcWindowSizeAfterConstraint(window, size_auto_fit);
ret_auto_fit = true;
ClearActiveID();
}
else if (held)
{
// Resize from any of the four corners
// We don't use an incremental MouseDelta but rather compute an absolute target size based on mouse position
ImVec2 corner_target = g.IO.MousePos - g.ActiveIdClickOffset + ImLerp(grip.InnerDir * grip_hover_outer_size, grip.InnerDir * -grip_hover_inner_size, grip.CornerPosN); // Corner of the window corresponding to our corner grip
CalcResizePosSizeFromAnyCorner(window, corner_target, grip.CornerPosN, &pos_target, &size_target);
}
if (resize_grip_n == 0 || held || hovered)
resize_grip_col[resize_grip_n] = GetColorU32(held ? ImGuiCol_ResizeGripActive : hovered ? ImGuiCol_ResizeGripHovered : ImGuiCol_ResizeGrip);
}
for (int border_n = 0; border_n < resize_border_count; border_n++)
{
bool hovered, held;
ImRect border_rect = GetResizeBorderRect(window, border_n, grip_hover_inner_size, WINDOWS_RESIZE_FROM_EDGES_HALF_THICKNESS);
border_rect.ClipWith(clip_viewport_rect);
ButtonBehavior(border_rect, window->GetID((void*)(intptr_t)(border_n + 4)), &hovered, &held, ImGuiButtonFlags_FlattenChildren);
//GetForegroundDrawList(window)->AddRect(border_rect.Min, border_rect.Max, IM_COL32(255, 255, 0, 255));
if ((hovered && g.HoveredIdTimer > WINDOWS_RESIZE_FROM_EDGES_FEEDBACK_TIMER) || held)
{
g.MouseCursor = (border_n & 1) ? ImGuiMouseCursor_ResizeEW : ImGuiMouseCursor_ResizeNS;
if (held)
*border_held = border_n;
}
if (held)
{
ImVec2 border_target = window->Pos;
ImVec2 border_posn;
if (border_n == 0) { border_posn = ImVec2(0, 0); border_target.y = (g.IO.MousePos.y - g.ActiveIdClickOffset.y + WINDOWS_RESIZE_FROM_EDGES_HALF_THICKNESS); } // Top
if (border_n == 1) { border_posn = ImVec2(1, 0); border_target.x = (g.IO.MousePos.x - g.ActiveIdClickOffset.x + WINDOWS_RESIZE_FROM_EDGES_HALF_THICKNESS); } // Right
if (border_n == 2) { border_posn = ImVec2(0, 1); border_target.y = (g.IO.MousePos.y - g.ActiveIdClickOffset.y + WINDOWS_RESIZE_FROM_EDGES_HALF_THICKNESS); } // Bottom
if (border_n == 3) { border_posn = ImVec2(0, 0); border_target.x = (g.IO.MousePos.x - g.ActiveIdClickOffset.x + WINDOWS_RESIZE_FROM_EDGES_HALF_THICKNESS); } // Left
CalcResizePosSizeFromAnyCorner(window, border_target, border_posn, &pos_target, &size_target);
}
}
PopID();
// Resize nav layer
window->DC.NavLayerCurrent = ImGuiNavLayer_Main;
window->DC.NavLayerCurrentMask = (1 << ImGuiNavLayer_Main);
// Navigation resize (keyboard/gamepad)
if (g.NavWindowingTarget && g.NavWindowingTarget->RootWindow == window)
{
ImVec2 nav_resize_delta;
if (g.NavInputSource == ImGuiInputSource_NavKeyboard && g.IO.KeyShift)
nav_resize_delta = GetNavInputAmount2d(ImGuiNavDirSourceFlags_Keyboard, ImGuiInputReadMode_Down);
if (g.NavInputSource == ImGuiInputSource_NavGamepad)
nav_resize_delta = GetNavInputAmount2d(ImGuiNavDirSourceFlags_PadDPad, ImGuiInputReadMode_Down);
if (nav_resize_delta.x != 0.0f || nav_resize_delta.y != 0.0f)
{
const float NAV_RESIZE_SPEED = 600.0f;
nav_resize_delta *= ImFloor(NAV_RESIZE_SPEED * g.IO.DeltaTime * ImMin(g.IO.DisplayFramebufferScale.x, g.IO.DisplayFramebufferScale.y));
g.NavWindowingToggleLayer = false;
g.NavDisableMouseHover = true;
resize_grip_col[0] = GetColorU32(ImGuiCol_ResizeGripActive);
// FIXME-NAV: Should store and accumulate into a separate size buffer to handle sizing constraints properly, right now a constraint will make us stuck.
size_target = CalcWindowSizeAfterConstraint(window, window->SizeFull + nav_resize_delta);
}
}
// Apply back modified position/size to window
if (size_target.x != FLT_MAX)
{
window->SizeFull = size_target;
MarkIniSettingsDirty(window);
}
if (pos_target.x != FLT_MAX)
{
window->Pos = ImFloor(pos_target);
MarkIniSettingsDirty(window);
}
window->Size = window->SizeFull;
return ret_auto_fit;
}
static inline void ClampWindowRect(ImGuiWindow* window, const ImRect& rect, const ImVec2& padding)
{
ImGuiContext& g = *GImGui;
ImVec2 size_for_clamping = (g.IO.ConfigWindowsMoveFromTitleBarOnly && !(window->Flags & ImGuiWindowFlags_NoTitleBar)) ? ImVec2(window->Size.x, window->TitleBarHeight()) : window->Size;
window->Pos = ImMin(rect.Max - padding, ImMax(window->Pos + size_for_clamping, rect.Min + padding) - size_for_clamping);
}
static void ImGui::RenderWindowOuterBorders(ImGuiWindow* window)
{
ImGuiContext& g = *GImGui;
float rounding = window->WindowRounding;
float border_size = window->WindowBorderSize;
if (border_size > 0.0f && !(window->Flags & ImGuiWindowFlags_NoBackground))
window->DrawList->AddRect(window->Pos, window->Pos + window->Size, GetColorU32(ImGuiCol_Border), rounding, ImDrawCornerFlags_All, border_size);
int border_held = window->ResizeBorderHeld;
if (border_held != -1)
{
struct ImGuiResizeBorderDef
{
ImVec2 InnerDir;
ImVec2 CornerPosN1, CornerPosN2;
float OuterAngle;
};
static const ImGuiResizeBorderDef resize_border_def[4] =
{
{ ImVec2(0,+1), ImVec2(0,0), ImVec2(1,0), IM_PI*1.50f }, // Top
{ ImVec2(-1,0), ImVec2(1,0), ImVec2(1,1), IM_PI*0.00f }, // Right
{ ImVec2(0,-1), ImVec2(1,1), ImVec2(0,1), IM_PI*0.50f }, // Bottom
{ ImVec2(+1,0), ImVec2(0,1), ImVec2(0,0), IM_PI*1.00f } // Left
};
const ImGuiResizeBorderDef& def = resize_border_def[border_held];
ImRect border_r = GetResizeBorderRect(window, border_held, rounding, 0.0f);
window->DrawList->PathArcTo(ImLerp(border_r.Min, border_r.Max, def.CornerPosN1) + ImVec2(0.5f, 0.5f) + def.InnerDir * rounding, rounding, def.OuterAngle - IM_PI*0.25f, def.OuterAngle);
window->DrawList->PathArcTo(ImLerp(border_r.Min, border_r.Max, def.CornerPosN2) + ImVec2(0.5f, 0.5f) + def.InnerDir * rounding, rounding, def.OuterAngle, def.OuterAngle + IM_PI*0.25f);
window->DrawList->PathStroke(GetColorU32(ImGuiCol_SeparatorActive), false, ImMax(2.0f, border_size)); // Thicker than usual
}
if (g.Style.FrameBorderSize > 0 && !(window->Flags & ImGuiWindowFlags_NoTitleBar) && !window->DockIsActive)
{
float y = window->Pos.y + window->TitleBarHeight() - 1;
window->DrawList->AddLine(ImVec2(window->Pos.x + border_size, y), ImVec2(window->Pos.x + window->Size.x - border_size, y), GetColorU32(ImGuiCol_Border), g.Style.FrameBorderSize);
}
}
// Draw background and borders
// Draw and handle scrollbars
void ImGui::RenderWindowDecorations(ImGuiWindow* window, const ImRect& title_bar_rect, bool title_bar_is_highlight, bool handle_borders_and_resize_grips, int resize_grip_count, const ImU32 resize_grip_col[4], float resize_grip_draw_size)
{
ImGuiContext& g = *GImGui;
ImGuiStyle& style = g.Style;
ImGuiWindowFlags flags = window->Flags;
// Draw window + handle manual resize
// As we highlight the title bar when want_focus is set, multiple reappearing windows will have have their title bar highlighted on their reappearing frame.
const float window_rounding = window->WindowRounding;
const float window_border_size = window->WindowBorderSize;
if (window->Collapsed)
{
// Title bar only
float backup_border_size = style.FrameBorderSize;
g.Style.FrameBorderSize = window->WindowBorderSize;
ImU32 title_bar_col = GetColorU32((title_bar_is_highlight && !g.NavDisableHighlight) ? ImGuiCol_TitleBgActive : ImGuiCol_TitleBgCollapsed);
RenderFrame(title_bar_rect.Min, title_bar_rect.Max, title_bar_col, true, window_rounding);
g.Style.FrameBorderSize = backup_border_size;
}
else
{
// Window background
if (!(flags & ImGuiWindowFlags_NoBackground))
{
bool is_docking_transparent_payload = false;
if (g.DragDropActive && (g.FrameCount - g.DragDropAcceptFrameCount) <= 1 && g.IO.ConfigDockingTransparentPayload)
if (g.DragDropPayload.IsDataType(IMGUI_PAYLOAD_TYPE_WINDOW) && *(ImGuiWindow**)g.DragDropPayload.Data == window)
is_docking_transparent_payload = true;
ImU32 bg_col = GetColorU32(GetWindowBgColorIdxFromFlags(flags));
if (window->ViewportOwned)
{
// No alpha
if (!(g.ConfigFlagsCurrFrame & ImGuiConfigFlags_TransparentBackbuffers)) {
bg_col = (bg_col | IM_COL32_A_MASK);
}
if (is_docking_transparent_payload)
window->Viewport->Alpha *= DOCKING_TRANSPARENT_PAYLOAD_ALPHA;
}
else
{
// Adjust alpha. For docking
float alpha = 1.0f;
if (g.NextWindowData.Flags & ImGuiNextWindowDataFlags_HasBgAlpha)
alpha = g.NextWindowData.BgAlphaVal;
if (is_docking_transparent_payload)
alpha *= DOCKING_TRANSPARENT_PAYLOAD_ALPHA;
if (alpha != 1.0f)
bg_col = (bg_col & ~IM_COL32_A_MASK) | (IM_F32_TO_INT8_SAT(alpha) << IM_COL32_A_SHIFT);
}
window->DrawList->AddRectFilled(window->Pos + ImVec2(0, window->TitleBarHeight()), window->Pos + window->Size, bg_col, window_rounding, (flags & ImGuiWindowFlags_NoTitleBar) ? ImDrawCornerFlags_All : ImDrawCornerFlags_Bot);
}
// Title bar
// (when docked, DockNode are drawing their own title bar. Individual windows however do NOT set the _NoTitleBar flag,
// in order for their pos/size to be matching their undocking state.)
if (!(flags & ImGuiWindowFlags_NoTitleBar) && !window->DockIsActive)
{
ImU32 title_bar_col = GetColorU32(title_bar_is_highlight ? ImGuiCol_TitleBgActive : ImGuiCol_TitleBg);
window->DrawList->AddRectFilled(title_bar_rect.Min, title_bar_rect.Max, title_bar_col, window_rounding, ImDrawCornerFlags_Top);
}
// Menu bar
if (flags & ImGuiWindowFlags_MenuBar)
{
ImRect menu_bar_rect = window->MenuBarRect();
menu_bar_rect.ClipWith(window->Rect()); // Soft clipping, in particular child window don't have minimum size covering the menu bar so this is useful for them.
window->DrawList->AddRectFilled(menu_bar_rect.Min + ImVec2(window_border_size, 0), menu_bar_rect.Max - ImVec2(window_border_size, 0), GetColorU32(ImGuiCol_MenuBarBg), (flags & ImGuiWindowFlags_NoTitleBar) ? window_rounding : 0.0f, ImDrawCornerFlags_Top);
if (style.FrameBorderSize > 0.0f && menu_bar_rect.Max.y < window->Pos.y + window->Size.y)
window->DrawList->AddLine(menu_bar_rect.GetBL(), menu_bar_rect.GetBR(), GetColorU32(ImGuiCol_Border), style.FrameBorderSize);
}
// Docking: Unhide tab bar (small triangle in the corner)
if (window->DockNode && window->DockNode->IsHiddenTabBar() && !window->DockNode->IsNoTabBar())
{
float unhide_sz_draw = ImFloor(g.FontSize * 0.70f);
float unhide_sz_hit = ImFloor(g.FontSize * 0.55f);
ImVec2 p = window->DockNode->Pos;
ImRect r(p, p + ImVec2(unhide_sz_hit, unhide_sz_hit));
bool hovered, held;
if (ButtonBehavior(r, window->GetID("#UNHIDE"), &hovered, &held, ImGuiButtonFlags_FlattenChildren))
window->DockNode->WantHiddenTabBarToggle = true;
// FIXME-DOCK: Ideally we'd use ImGuiCol_TitleBgActive/ImGuiCol_TitleBg here, but neither is guaranteed to be visible enough at this sort of size..
ImU32 col = GetColorU32(((held && hovered) || (window->DockNode->IsFocused && !hovered)) ? ImGuiCol_ButtonActive : hovered ? ImGuiCol_ButtonHovered : ImGuiCol_Button);
window->DrawList->AddTriangleFilled(p, p + ImVec2(unhide_sz_draw, 0.0f), p + ImVec2(0.0f, unhide_sz_draw), col);
}
// Scrollbars
if (window->ScrollbarX)
Scrollbar(ImGuiAxis_X);
if (window->ScrollbarY)
Scrollbar(ImGuiAxis_Y);
// Render resize grips (after their input handling so we don't have a frame of latency)
if (handle_borders_and_resize_grips && !(flags & ImGuiWindowFlags_NoResize))
{
for (int resize_grip_n = 0; resize_grip_n < resize_grip_count; resize_grip_n++)
{
const ImGuiResizeGripDef& grip = resize_grip_def[resize_grip_n];
const ImVec2 corner = ImLerp(window->Pos, window->Pos + window->Size, grip.CornerPosN);
window->DrawList->PathLineTo(corner + grip.InnerDir * ((resize_grip_n & 1) ? ImVec2(window_border_size, resize_grip_draw_size) : ImVec2(resize_grip_draw_size, window_border_size)));
window->DrawList->PathLineTo(corner + grip.InnerDir * ((resize_grip_n & 1) ? ImVec2(resize_grip_draw_size, window_border_size) : ImVec2(window_border_size, resize_grip_draw_size)));
window->DrawList->PathArcToFast(ImVec2(corner.x + grip.InnerDir.x * (window_rounding + window_border_size), corner.y + grip.InnerDir.y * (window_rounding + window_border_size)), window_rounding, grip.AngleMin12, grip.AngleMax12);
window->DrawList->PathFillConvex(resize_grip_col[resize_grip_n]);
}
}
// Borders (for dock node host they will be rendered over after the tab bar)
if (handle_borders_and_resize_grips && !window->DockNodeAsHost)
RenderWindowOuterBorders(window);
}
}
// Render title text, collapse button, close button
// When inside a dock node, this is handled in DockNodeUpdateTabBar() instead.
void ImGui::RenderWindowTitleBarContents(ImGuiWindow* window, const ImRect& title_bar_rect, const char* name, bool* p_open)
{
ImGuiContext& g = *GImGui;
ImGuiStyle& style = g.Style;
ImGuiWindowFlags flags = window->Flags;
const bool has_close_button = (p_open != NULL);
const bool has_collapse_button = !(flags & ImGuiWindowFlags_NoCollapse);
// Close & Collapse button are on the Menu NavLayer and don't default focus (unless there's nothing else on that layer)
const ImGuiItemFlags item_flags_backup = window->DC.ItemFlags;
window->DC.ItemFlags |= ImGuiItemFlags_NoNavDefaultFocus;
window->DC.NavLayerCurrent = ImGuiNavLayer_Menu;
window->DC.NavLayerCurrentMask = (1 << ImGuiNavLayer_Menu);
// Layout buttons
// FIXME: Would be nice to generalize the subtleties expressed here into reusable code.
float pad_l = style.FramePadding.x;
float pad_r = style.FramePadding.x;
float button_sz = g.FontSize;
ImVec2 close_button_pos;
ImVec2 collapse_button_pos;
if (has_close_button)
{
pad_r += button_sz;
close_button_pos = ImVec2(title_bar_rect.Max.x - pad_r - style.FramePadding.x, title_bar_rect.Min.y);
}
if (has_collapse_button && style.WindowMenuButtonPosition == ImGuiDir_Right)
{
pad_r += button_sz;
collapse_button_pos = ImVec2(title_bar_rect.Max.x - pad_r - style.FramePadding.x, title_bar_rect.Min.y);
}
if (has_collapse_button && style.WindowMenuButtonPosition == ImGuiDir_Left)
{
collapse_button_pos = ImVec2(title_bar_rect.Min.x + pad_l - style.FramePadding.x, title_bar_rect.Min.y);
pad_l += button_sz;
}
// Collapse button (submitting first so it gets priority when choosing a navigation init fallback)
if (has_collapse_button)
if (CollapseButton(window->GetID("#COLLAPSE"), collapse_button_pos, NULL))
window->WantCollapseToggle = true; // Defer actual collapsing to next frame as we are too far in the Begin() function
// Close button
if (has_close_button)
if (CloseButton(window->GetID("#CLOSE"), close_button_pos))
*p_open = false;
window->DC.NavLayerCurrent = ImGuiNavLayer_Main;
window->DC.NavLayerCurrentMask = (1 << ImGuiNavLayer_Main);
window->DC.ItemFlags = item_flags_backup;
// Title bar text (with: horizontal alignment, avoiding collapse/close button, optional "unsaved document" marker)
// FIXME: Refactor text alignment facilities along with RenderText helpers, this is WAY too much messy code..
const char* UNSAVED_DOCUMENT_MARKER = "*";
const float marker_size_x = (flags & ImGuiWindowFlags_UnsavedDocument) ? CalcTextSize(UNSAVED_DOCUMENT_MARKER, NULL, false).x : 0.0f;
const ImVec2 text_size = CalcTextSize(name, NULL, true) + ImVec2(marker_size_x, 0.0f);
// As a nice touch we try to ensure that centered title text doesn't get affected by visibility of Close/Collapse button,
// while uncentered title text will still reach edges correct.
if (pad_l > style.FramePadding.x)
pad_l += g.Style.ItemInnerSpacing.x;
if (pad_r > style.FramePadding.x)
pad_r += g.Style.ItemInnerSpacing.x;
if (style.WindowTitleAlign.x > 0.0f && style.WindowTitleAlign.x < 1.0f)
{
float centerness = ImSaturate(1.0f - ImFabs(style.WindowTitleAlign.x - 0.5f) * 2.0f); // 0.0f on either edges, 1.0f on center
float pad_extend = ImMin(ImMax(pad_l, pad_r), title_bar_rect.GetWidth() - pad_l - pad_r - text_size.x);
pad_l = ImMax(pad_l, pad_extend * centerness);
pad_r = ImMax(pad_r, pad_extend * centerness);
}
ImRect layout_r(title_bar_rect.Min.x + pad_l, title_bar_rect.Min.y, title_bar_rect.Max.x - pad_r, title_bar_rect.Max.y);
ImRect clip_r(layout_r.Min.x, layout_r.Min.y, layout_r.Max.x + g.Style.ItemInnerSpacing.x, layout_r.Max.y);
//if (g.IO.KeyCtrl) window->DrawList->AddRect(layout_r.Min, layout_r.Max, IM_COL32(255, 128, 0, 255)); // [DEBUG]
RenderTextClipped(layout_r.Min, layout_r.Max, name, NULL, &text_size, style.WindowTitleAlign, &clip_r);
if (flags & ImGuiWindowFlags_UnsavedDocument)
{
ImVec2 marker_pos = ImVec2(ImMax(layout_r.Min.x, layout_r.Min.x + (layout_r.GetWidth() - text_size.x) * style.WindowTitleAlign.x) + text_size.x, layout_r.Min.y) + ImVec2(2 - marker_size_x, 0.0f);
ImVec2 off = ImVec2(0.0f, (float)(int)(-g.FontSize * 0.25f));
RenderTextClipped(marker_pos + off, layout_r.Max + off, UNSAVED_DOCUMENT_MARKER, NULL, NULL, ImVec2(0, style.WindowTitleAlign.y), &clip_r);
}
}
void ImGui::UpdateWindowParentAndRootLinks(ImGuiWindow* window, ImGuiWindowFlags flags, ImGuiWindow* parent_window)
{
window->ParentWindow = parent_window;
window->RootWindow = window->RootWindowDockStop = window->RootWindowForTitleBarHighlight = window->RootWindowForNav = window;
if (parent_window && (flags & ImGuiWindowFlags_ChildWindow) && !(flags & ImGuiWindowFlags_Tooltip))
{
window->RootWindow = parent_window->RootWindow;
if (!window->DockIsActive && !(parent_window->Flags & ImGuiWindowFlags_DockNodeHost))
window->RootWindowDockStop = parent_window->RootWindowDockStop;
}
if (parent_window && !(flags & ImGuiWindowFlags_Modal) && (flags & (ImGuiWindowFlags_ChildWindow | ImGuiWindowFlags_Popup)))
window->RootWindowForTitleBarHighlight = parent_window->RootWindowForTitleBarHighlight;
while (window->RootWindowForNav->Flags & ImGuiWindowFlags_NavFlattened)
{
IM_ASSERT(window->RootWindowForNav->ParentWindow != NULL);
window->RootWindowForNav = window->RootWindowForNav->ParentWindow;
}
}
// Push a new Dear ImGui window to add widgets to.
// - A default window called "Debug" is automatically stacked at the beginning of every frame so you can use widgets without explicitly calling a Begin/End pair.
// - Begin/End can be called multiple times during the frame with the same window name to append content.
// - The window name is used as a unique identifier to preserve window information across frames (and save rudimentary information to the .ini file).
// You can use the "##" or "###" markers to use the same label with different id, or same id with different label. See documentation at the top of this file.
// - Return false when window is collapsed, so you can early out in your code. You always need to call ImGui::End() even if false is returned.
// - Passing 'bool* p_open' displays a Close button on the upper-right corner of the window, the pointed value will be set to false when the button is pressed.
bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
{
ImGuiContext& g = *GImGui;
const ImGuiStyle& style = g.Style;
IM_ASSERT(name != NULL && name[0] != '\0'); // Window name required
IM_ASSERT(g.FrameScopeActive); // Forgot to call ImGui::NewFrame()
IM_ASSERT(g.FrameCountEnded != g.FrameCount); // Called ImGui::Render() or ImGui::EndFrame() and haven't called ImGui::NewFrame() again yet
// Find or create
ImGuiWindow* window = FindWindowByName(name);
const bool window_just_created = (window == NULL);
if (window_just_created)
{
ImVec2 size_on_first_use = (g.NextWindowData.Flags & ImGuiNextWindowDataFlags_HasSize) ? g.NextWindowData.SizeVal : ImVec2(0.0f, 0.0f); // Any condition flag will do since we are creating a new window here.
window = CreateNewWindow(name, size_on_first_use, flags);
}
// Automatically disable manual moving/resizing when NoInputs is set
if ((flags & ImGuiWindowFlags_NoInputs) == ImGuiWindowFlags_NoInputs)
flags |= ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoResize;
if (flags & ImGuiWindowFlags_NavFlattened)
IM_ASSERT(flags & ImGuiWindowFlags_ChildWindow);
const int current_frame = g.FrameCount;
const bool first_begin_of_the_frame = (window->LastFrameActive != current_frame);
window->IsFallbackWindow = (g.CurrentWindowStack.Size == 0 && g.FrameScopePushedFallbackWindow);
// Update the Appearing flag
bool window_just_activated_by_user = (window->LastFrameActive < current_frame - 1); // Not using !WasActive because the implicit "Debug" window would always toggle off->on
const bool window_just_appearing_after_hidden_for_resize = (window->HiddenFramesCannotSkipItems > 0);
if (flags & ImGuiWindowFlags_Popup)
{
ImGuiPopupData& popup_ref = g.OpenPopupStack[g.BeginPopupStack.Size];
window_just_activated_by_user |= (window->PopupId != popup_ref.PopupId); // We recycle popups so treat window as activated if popup id changed
window_just_activated_by_user |= (window != popup_ref.Window);
}
window->Appearing = (window_just_activated_by_user || window_just_appearing_after_hidden_for_resize);
if (window->Appearing)
SetWindowConditionAllowFlags(window, ImGuiCond_Appearing, true);
// Update Flags, LastFrameActive, BeginOrderXXX fields
if (first_begin_of_the_frame)
{
window->FlagsPreviousFrame = window->Flags;
window->Flags = (ImGuiWindowFlags)flags;
window->LastFrameActive = current_frame;
window->BeginOrderWithinParent = 0;
window->BeginOrderWithinContext = (short)(g.WindowsActiveCount++);
}
else
{
flags = window->Flags;
}
// Docking
// (NB: during the frame dock nodes are created, it is possible that (window->DockIsActive == false) even though (window->DockNode->Windows.Size > 1)
IM_ASSERT(window->DockNode == NULL || window->DockNodeAsHost == NULL); // Cannot be both
if (g.NextWindowData.Flags & ImGuiNextWindowDataFlags_HasDock)
SetWindowDock(window, g.NextWindowData.DockId, g.NextWindowData.DockCond);
if (first_begin_of_the_frame)
{
bool has_dock_node = (window->DockId != 0 || window->DockNode != NULL);
bool new_auto_dock_node = !has_dock_node && GetWindowAlwaysWantOwnTabBar(window);
if (has_dock_node || new_auto_dock_node)
{
BeginDocked(window, p_open);
flags = window->Flags;
// Docking currently override constraints
g.NextWindowData.Flags &= ~ImGuiNextWindowDataFlags_HasSizeConstraint;
}
}
// Parent window is latched only on the first call to Begin() of the frame, so further append-calls can be done from a different window stack
ImGuiWindow* parent_window_in_stack = window->DockIsActive ? window->DockNode->HostWindow : g.CurrentWindowStack.empty() ? NULL : g.CurrentWindowStack.back();
ImGuiWindow* parent_window = first_begin_of_the_frame ? ((flags & (ImGuiWindowFlags_ChildWindow | ImGuiWindowFlags_Popup)) ? parent_window_in_stack : NULL) : window->ParentWindow;
IM_ASSERT(parent_window != NULL || !(flags & ImGuiWindowFlags_ChildWindow));
// Add to stack
// We intentionally set g.CurrentWindow to NULL to prevent usage until when the viewport is set, then will call SetCurrentWindow()
g.CurrentWindowStack.push_back(window);
g.CurrentWindow = NULL;
CheckStacksSize(window, true);
if (flags & ImGuiWindowFlags_Popup)
{
ImGuiPopupData& popup_ref = g.OpenPopupStack[g.BeginPopupStack.Size];
popup_ref.Window = window;
g.BeginPopupStack.push_back(popup_ref);
window->PopupId = popup_ref.PopupId;
}
if (window_just_appearing_after_hidden_for_resize && !(flags & ImGuiWindowFlags_ChildWindow))
window->NavLastIds[0] = 0;
// Process SetNextWindow***() calls
bool window_pos_set_by_api = false;
bool window_size_x_set_by_api = false, window_size_y_set_by_api = false;
if (g.NextWindowData.Flags & ImGuiNextWindowDataFlags_HasPos)
{
window_pos_set_by_api = (window->SetWindowPosAllowFlags & g.NextWindowData.PosCond) != 0;
if (window_pos_set_by_api && ImLengthSqr(g.NextWindowData.PosPivotVal) > 0.00001f)
{
// May be processed on the next frame if this is our first frame and we are measuring size
// FIXME: Look into removing the branch so everything can go through this same code path for consistency.
window->SetWindowPosVal = g.NextWindowData.PosVal;
window->SetWindowPosPivot = g.NextWindowData.PosPivotVal;
window->SetWindowPosAllowFlags &= ~(ImGuiCond_Once | ImGuiCond_FirstUseEver | ImGuiCond_Appearing);
}
else
{
SetWindowPos(window, g.NextWindowData.PosVal, g.NextWindowData.PosCond);
}
}
if (g.NextWindowData.Flags & ImGuiNextWindowDataFlags_HasSize)
{
window_size_x_set_by_api = (window->SetWindowSizeAllowFlags & g.NextWindowData.SizeCond) != 0 && (g.NextWindowData.SizeVal.x > 0.0f);
window_size_y_set_by_api = (window->SetWindowSizeAllowFlags & g.NextWindowData.SizeCond) != 0 && (g.NextWindowData.SizeVal.y > 0.0f);
SetWindowSize(window, g.NextWindowData.SizeVal, g.NextWindowData.SizeCond);
}
if (g.NextWindowData.Flags & ImGuiNextWindowDataFlags_HasContentSize)
window->ContentSizeExplicit = g.NextWindowData.ContentSizeVal;
else if (first_begin_of_the_frame)
window->ContentSizeExplicit = ImVec2(0.0f, 0.0f);
if (g.NextWindowData.Flags & ImGuiNextWindowDataFlags_HasWindowClass)
window->WindowClass = g.NextWindowData.WindowClass;
if (g.NextWindowData.Flags & ImGuiNextWindowDataFlags_HasCollapsed)
SetWindowCollapsed(window, g.NextWindowData.CollapsedVal, g.NextWindowData.CollapsedCond);
if (g.NextWindowData.Flags & ImGuiNextWindowDataFlags_HasFocus)
FocusWindow(window);
if (window->Appearing)
SetWindowConditionAllowFlags(window, ImGuiCond_Appearing, false);
// When reusing window again multiple times a frame, just append content (don't need to setup again)
if (first_begin_of_the_frame)
{
// Initialize
const bool window_is_child_tooltip = (flags & ImGuiWindowFlags_ChildWindow) && (flags & ImGuiWindowFlags_Tooltip); // FIXME-WIP: Undocumented behavior of Child+Tooltip for pinned tooltip (#1345)
UpdateWindowParentAndRootLinks(window, flags, parent_window);
window->Active = true;
window->HasCloseButton = (p_open != NULL);
window->ClipRect = ImVec4(-FLT_MAX,-FLT_MAX,+FLT_MAX,+FLT_MAX);
window->IDStack.resize(1);
// Update stored window name when it changes (which can _only_ happen with the "###" operator, so the ID would stay unchanged).
// The title bar always display the 'name' parameter, so we only update the string storage if it needs to be visible to the end-user elsewhere.
bool window_title_visible_elsewhere = false;
if ((window->Viewport && window->Viewport->Window == window) || (window->DockIsActive))
window_title_visible_elsewhere = true;
else if (g.NavWindowingList != NULL && (window->Flags & ImGuiWindowFlags_NoNavFocus) == 0) // Window titles visible when using CTRL+TAB
window_title_visible_elsewhere = true;
if (window_title_visible_elsewhere && !window_just_created && strcmp(name, window->Name) != 0)
{
size_t buf_len = (size_t)window->NameBufLen;
window->Name = ImStrdupcpy(window->Name, &buf_len, name);
window->NameBufLen = (int)buf_len;
}
// UPDATE CONTENTS SIZE, UPDATE HIDDEN STATUS
// Update contents size from last frame for auto-fitting (or use explicit size)
window->ContentSize = CalcWindowContentSize(window);
if (window->HiddenFramesCanSkipItems > 0)
window->HiddenFramesCanSkipItems--;
if (window->HiddenFramesCannotSkipItems > 0)
window->HiddenFramesCannotSkipItems--;
// Hide new windows for one frame until they calculate their size
if (window_just_created && (!window_size_x_set_by_api || !window_size_y_set_by_api))
window->HiddenFramesCannotSkipItems = 1;
// Hide popup/tooltip window when re-opening while we measure size (because we recycle the windows)
// We reset Size/ContentSize for reappearing popups/tooltips early in this function, so further code won't be tempted to use the old size.
if (window_just_activated_by_user && (flags & (ImGuiWindowFlags_Popup | ImGuiWindowFlags_Tooltip)) != 0)
{
window->HiddenFramesCannotSkipItems = 1;
if (flags & ImGuiWindowFlags_AlwaysAutoResize)
{
if (!window_size_x_set_by_api)
window->Size.x = window->SizeFull.x = 0.f;
if (!window_size_y_set_by_api)
window->Size.y = window->SizeFull.y = 0.f;
window->ContentSize = ImVec2(0.f, 0.f);
}
}
// SELECT VIEWPORT
// We need to do this before using any style/font sizes, as viewport with a different DPI may affect font sizes.
UpdateSelectWindowViewport(window);
SetCurrentViewport(window, window->Viewport);
window->FontDpiScale = (g.IO.ConfigFlags & ImGuiConfigFlags_DpiEnableScaleFonts) ? window->Viewport->DpiScale : 1.0f;
SetCurrentWindow(window);
flags = window->Flags;
// LOCK BORDER SIZE AND PADDING FOR THE FRAME (so that altering them doesn't cause inconsistencies)
// We read Style data after the call to UpdateSelectWindowViewport() which might be swapping the style.
if (flags & ImGuiWindowFlags_ChildWindow)
window->WindowBorderSize = style.ChildBorderSize;
else
window->WindowBorderSize = ((flags & (ImGuiWindowFlags_Popup | ImGuiWindowFlags_Tooltip)) && !(flags & ImGuiWindowFlags_Modal)) ? style.PopupBorderSize : style.WindowBorderSize;
if (!window->DockIsActive && (flags & ImGuiWindowFlags_ChildWindow) && !(flags & (ImGuiWindowFlags_AlwaysUseWindowPadding | ImGuiWindowFlags_Popup)) && window->WindowBorderSize == 0.0f)
window->WindowPadding = ImVec2(0.0f, (flags & ImGuiWindowFlags_MenuBar) ? style.WindowPadding.y : 0.0f);
else
window->WindowPadding = style.WindowPadding;
window->DC.MenuBarOffset.x = ImMax(ImMax(window->WindowPadding.x, style.ItemSpacing.x), g.NextWindowData.MenuBarOffsetMinVal.x);
window->DC.MenuBarOffset.y = g.NextWindowData.MenuBarOffsetMinVal.y;
// Collapse window by double-clicking on title bar
// At this point we don't have a clipping rectangle setup yet, so we can use the title bar area for hit detection and drawing
if (!(flags & ImGuiWindowFlags_NoTitleBar) && !(flags & ImGuiWindowFlags_NoCollapse) && !window->DockIsActive)
{
// We don't use a regular button+id to test for double-click on title bar (mostly due to legacy reason, could be fixed), so verify that we don't have items over the title bar.
ImRect title_bar_rect = window->TitleBarRect();
if (g.HoveredWindow == window && g.HoveredId == 0 && g.HoveredIdPreviousFrame == 0 && IsMouseHoveringRect(title_bar_rect.Min, title_bar_rect.Max) && g.IO.MouseDoubleClicked[0])
window->WantCollapseToggle = true;
if (window->WantCollapseToggle)
{
window->Collapsed = !window->Collapsed;
MarkIniSettingsDirty(window);
FocusWindow(window);
}
}
else
{
window->Collapsed = false;
}
window->WantCollapseToggle = false;
// SIZE
// Calculate auto-fit size, handle automatic resize
const ImVec2 size_auto_fit = CalcWindowAutoFitSize(window, window->ContentSize);
bool use_current_size_for_scrollbar_x = window_just_created;
bool use_current_size_for_scrollbar_y = window_just_created;
if ((flags & ImGuiWindowFlags_AlwaysAutoResize) && !window->Collapsed)
{
// Using SetNextWindowSize() overrides ImGuiWindowFlags_AlwaysAutoResize, so it can be used on tooltips/popups, etc.
if (!window_size_x_set_by_api)
{
window->SizeFull.x = size_auto_fit.x;
use_current_size_for_scrollbar_x = true;
}
if (!window_size_y_set_by_api)
{
window->SizeFull.y = size_auto_fit.y;
use_current_size_for_scrollbar_y = true;
}
}
else if (window->AutoFitFramesX > 0 || window->AutoFitFramesY > 0)
{
// Auto-fit may only grow window during the first few frames
// We still process initial auto-fit on collapsed windows to get a window width, but otherwise don't honor ImGuiWindowFlags_AlwaysAutoResize when collapsed.
if (!window_size_x_set_by_api && window->AutoFitFramesX > 0)
{
window->SizeFull.x = window->AutoFitOnlyGrows ? ImMax(window->SizeFull.x, size_auto_fit.x) : size_auto_fit.x;
use_current_size_for_scrollbar_x = true;
}
if (!window_size_y_set_by_api && window->AutoFitFramesY > 0)
{
window->SizeFull.y = window->AutoFitOnlyGrows ? ImMax(window->SizeFull.y, size_auto_fit.y) : size_auto_fit.y;
use_current_size_for_scrollbar_y = true;
}
if (!window->Collapsed)
MarkIniSettingsDirty(window);
}
// Apply minimum/maximum window size constraints and final size
window->SizeFull = CalcWindowSizeAfterConstraint(window, window->SizeFull);
window->Size = window->Collapsed && !(flags & ImGuiWindowFlags_ChildWindow) ? window->TitleBarRect().GetSize() : window->SizeFull;
// Decoration size
const float decoration_up_height = window->TitleBarHeight() + window->MenuBarHeight();
// POSITION
// Popup latch its initial position, will position itself when it appears next frame
if (window_just_activated_by_user)
{
window->AutoPosLastDirection = ImGuiDir_None;
if ((flags & ImGuiWindowFlags_Popup) != 0 && !window_pos_set_by_api)
window->Pos = g.BeginPopupStack.back().OpenPopupPos;
}
// Position child window
if (flags & ImGuiWindowFlags_ChildWindow)
{
IM_ASSERT(parent_window && parent_window->Active);
window->BeginOrderWithinParent = (short)parent_window->DC.ChildWindows.Size;
parent_window->DC.ChildWindows.push_back(window);
if (!(flags & ImGuiWindowFlags_Popup) && !window_pos_set_by_api && !window_is_child_tooltip)
window->Pos = parent_window->DC.CursorPos;
}
const bool window_pos_with_pivot = (window->SetWindowPosVal.x != FLT_MAX && window->HiddenFramesCannotSkipItems == 0);
if (window_pos_with_pivot)
SetWindowPos(window, window->SetWindowPosVal - window->SizeFull * window->SetWindowPosPivot, 0); // Position given a pivot (e.g. for centering)
else if ((flags & ImGuiWindowFlags_ChildMenu) != 0)
window->Pos = FindBestWindowPosForPopup(window);
else if ((flags & ImGuiWindowFlags_Popup) != 0 && !window_pos_set_by_api && window_just_appearing_after_hidden_for_resize)
window->Pos = FindBestWindowPosForPopup(window);
else if ((flags & ImGuiWindowFlags_Tooltip) != 0 && !window_pos_set_by_api && !window_is_child_tooltip)
window->Pos = FindBestWindowPosForPopup(window);
// Late create viewport if we don't fit within our current host viewport.
if (window->ViewportAllowPlatformMonitorExtend >= 0 && !window->ViewportOwned && !(window->Viewport->Flags & ImGuiViewportFlags_Minimized))
if (!window->Viewport->GetRect().Contains(window->Rect()))
{
// This is based on the assumption that the DPI will be known ahead (same as the DPI of the selection done in UpdateSelectWindowViewport)
//ImGuiViewport* old_viewport = window->Viewport;
window->Viewport = AddUpdateViewport(window, window->ID, window->Pos, window->Size, ImGuiViewportFlags_NoFocusOnAppearing);
// FIXME-DPI
//IM_ASSERT(old_viewport->DpiScale == window->Viewport->DpiScale); // FIXME-DPI: Something went wrong
SetCurrentViewport(window, window->Viewport);
window->FontDpiScale = (g.IO.ConfigFlags & ImGuiConfigFlags_DpiEnableScaleFonts) ? window->Viewport->DpiScale : 1.0f;
SetCurrentWindow(window);
}
bool viewport_rect_changed = false;
if (window->ViewportOwned)
{
// Synchronize window --> viewport in most situations
// Synchronize viewport -> window in case the platform window has been moved or resized from the OS/WM
if (window->Viewport->PlatformRequestMove)
{
window->Pos = window->Viewport->Pos;
MarkIniSettingsDirty(window);
}
else if (memcmp(&window->Viewport->Pos, &window->Pos, sizeof(window->Pos)) != 0)
{
viewport_rect_changed = true;
window->Viewport->Pos = window->Pos;
}
if (window->Viewport->PlatformRequestResize)
{
window->Size = window->SizeFull = window->Viewport->Size;
MarkIniSettingsDirty(window);
}
else if (memcmp(&window->Viewport->Size, &window->Size, sizeof(window->Size)) != 0)
{
viewport_rect_changed = true;
window->Viewport->Size = window->Size;
}
// The viewport may have changed monitor since the global update in UpdateViewportsNewFrame()
// Either a SetNextWindowPos() call in the current frame or a SetWindowPos() call in the previous frame may have this effect.
if (viewport_rect_changed)
UpdateViewportPlatformMonitor(window->Viewport);
// Update common viewport flags
ImGuiViewportFlags viewport_flags = (window->Viewport->Flags) & ~(ImGuiViewportFlags_TopMost | ImGuiViewportFlags_NoTaskBarIcon | ImGuiViewportFlags_NoDecoration);
const bool is_short_lived_floating_window = (flags & (ImGuiWindowFlags_ChildMenu | ImGuiWindowFlags_Tooltip | ImGuiWindowFlags_Popup)) != 0;
if (flags & ImGuiWindowFlags_Tooltip)
viewport_flags |= ImGuiViewportFlags_TopMost;
if (g.IO.ConfigViewportsNoTaskBarIcon || is_short_lived_floating_window)
viewport_flags |= ImGuiViewportFlags_NoTaskBarIcon;
if (g.IO.ConfigViewportsNoDecoration || is_short_lived_floating_window)
viewport_flags |= ImGuiViewportFlags_NoDecoration;
// For popups and menus that may be protruding out of their parent viewport, we enable _NoFocusOnClick so that clicking on them
// won't steal the OS focus away from their parent window (which may be reflected in OS the title bar decoration).
// Setting _NoFocusOnClick would technically prevent us from bringing back to front in case they are being covered by an OS window from a different app,
// but it shouldn't be much of a problem considering those are already popups that are closed when clicking elsewhere.
if (is_short_lived_floating_window && (flags & ImGuiWindowFlags_Modal) == 0)
viewport_flags |= ImGuiViewportFlags_NoFocusOnAppearing | ImGuiViewportFlags_NoFocusOnClick;
// We can overwrite viewport flags using ImGuiWindowClass (advanced users)
// We don't default to the main viewport because.
if (window->WindowClass.ParentViewportId)
window->Viewport->ParentViewportId = window->WindowClass.ParentViewportId;
else if ((flags & (ImGuiWindowFlags_Popup | ImGuiWindowFlags_Tooltip)) && parent_window_in_stack)
window->Viewport->ParentViewportId = parent_window_in_stack->Viewport->ID;
else
window->Viewport->ParentViewportId = g.IO.ConfigViewportsNoDefaultParent ? 0 : IMGUI_VIEWPORT_DEFAULT_ID;
if (window->WindowClass.ViewportFlagsOverrideSet)
viewport_flags |= window->WindowClass.ViewportFlagsOverrideSet;
if (window->WindowClass.ViewportFlagsOverrideClear)
viewport_flags &= ~window->WindowClass.ViewportFlagsOverrideClear;
// We also tell the back-end that clearing the platform window won't be necessary, as our window is filling the viewport and we have disabled BgAlpha
if (!(g.ConfigFlagsCurrFrame & ImGuiConfigFlags_TransparentBackbuffers)) {
viewport_flags |= ImGuiViewportFlags_NoRendererClear;
}
window->Viewport->Flags = viewport_flags;
}
// Clamp position/size so window stays visible within its viewport or monitor
// Ignore zero-sized display explicitly to avoid losing positions if a window manager reports zero-sized window when initializing or minimizing.
ImRect viewport_rect = window->Viewport->GetRect();
if (!window_pos_set_by_api && !(flags & ImGuiWindowFlags_ChildWindow) && window->AutoFitFramesX <= 0 && window->AutoFitFramesY <= 0)
{
ImVec2 clamp_padding = ImMax(style.DisplayWindowPadding, style.DisplaySafeAreaPadding);
if (!window->ViewportOwned && viewport_rect.GetWidth() > 0 && viewport_rect.GetHeight() > 0.0f)
ClampWindowRect(window, viewport_rect, clamp_padding);
else if (window->ViewportOwned && g.PlatformIO.Monitors.Size > 0)
{
if (window->Viewport->PlatformMonitor == -1)
{
// Fallback for "lost" window (e.g. a monitor disconnected): we move the window back over the main viewport
SetWindowPos(window, g.Viewports[0]->Pos + style.DisplayWindowPadding, ImGuiCond_Always);
}
else
{
ImGuiPlatformMonitor& monitor = g.PlatformIO.Monitors[window->Viewport->PlatformMonitor];
ClampWindowRect(window, ImRect(monitor.WorkPos, monitor.WorkPos + monitor.WorkSize), clamp_padding);
}
}
}
window->Pos = ImFloor(window->Pos);
// Lock window rounding for the frame (so that altering them doesn't cause inconsistencies)
window->WindowRounding = (flags & ImGuiWindowFlags_ChildWindow) ? style.ChildRounding : ((flags & ImGuiWindowFlags_Popup) && !(flags & ImGuiWindowFlags_Modal)) ? style.PopupRounding : style.WindowRounding;
if (window->ViewportOwned)
window->WindowRounding = 0.0f;
// Apply window focus (new and reactivated windows are moved to front)
bool want_focus = false;
if (window_just_activated_by_user && !(flags & ImGuiWindowFlags_NoFocusOnAppearing))
{
if (flags & ImGuiWindowFlags_Popup)
want_focus = true;
else if ((window->DockIsActive || (flags & ImGuiWindowFlags_ChildWindow) == 0) && !(flags & ImGuiWindowFlags_Tooltip))
want_focus = true;
}
// Decide if we are going to handle borders and resize grips
const bool handle_borders_and_resize_grips = (window->DockNodeAsHost || !window->DockIsActive);
// Handle manual resize: Resize Grips, Borders, Gamepad
int border_held = -1;
ImU32 resize_grip_col[4] = { 0 };
const int resize_grip_count = g.IO.ConfigWindowsResizeFromEdges ? 2 : 1; // 4
const float resize_grip_draw_size = (float)(int)ImMax(g.FontSize * 1.35f, window->WindowRounding + 1.0f + g.FontSize * 0.2f);
if (handle_borders_and_resize_grips && !window->Collapsed)
if (UpdateManualResize(window, size_auto_fit, &border_held, resize_grip_count, &resize_grip_col[0]))
use_current_size_for_scrollbar_x = use_current_size_for_scrollbar_y = true;
window->ResizeBorderHeld = (signed char)border_held;
// Synchronize window --> viewport again and one last time (clamping and manual resize may have affected either)
if (window->ViewportOwned)
{
if (!window->Viewport->PlatformRequestMove)
window->Viewport->Pos = window->Pos;
if (!window->Viewport->PlatformRequestResize)
window->Viewport->Size = window->Size;
viewport_rect = window->Viewport->GetRect();
}
// Save last known viewport position within the window itself (so it can be saved in .ini file and restored)
window->ViewportPos = window->Viewport->Pos;
// SCROLLBAR VISIBILITY
// Update scrollbar visibility (based on the Size that was effective during last frame or the auto-resized Size).
if (!window->Collapsed)
{
// When reading the current size we need to read it after size constraints have been applied.
// When we use InnerRect here we are intentionally reading last frame size, same for ScrollbarSizes values before we set them again.
ImVec2 avail_size_from_current_frame = ImVec2(window->SizeFull.x, window->SizeFull.y - decoration_up_height);
ImVec2 avail_size_from_last_frame = window->InnerRect.GetSize() + window->ScrollbarSizes;
ImVec2 needed_size_from_last_frame = window_just_created ? ImVec2(0, 0) : window->ContentSize + window->WindowPadding * 2.0f;
float size_x_for_scrollbars = use_current_size_for_scrollbar_x ? avail_size_from_current_frame.x : avail_size_from_last_frame.x;
float size_y_for_scrollbars = use_current_size_for_scrollbar_y ? avail_size_from_current_frame.y : avail_size_from_last_frame.y;
//bool scrollbar_y_from_last_frame = window->ScrollbarY; // FIXME: May want to use that in the ScrollbarX expression? How many pros vs cons?
window->ScrollbarY = (flags & ImGuiWindowFlags_AlwaysVerticalScrollbar) || ((needed_size_from_last_frame.y > size_y_for_scrollbars) && !(flags & ImGuiWindowFlags_NoScrollbar));
window->ScrollbarX = (flags & ImGuiWindowFlags_AlwaysHorizontalScrollbar) || ((needed_size_from_last_frame.x > size_x_for_scrollbars - (window->ScrollbarY ? style.ScrollbarSize : 0.0f)) && !(flags & ImGuiWindowFlags_NoScrollbar) && (flags & ImGuiWindowFlags_HorizontalScrollbar));
if (window->ScrollbarX && !window->ScrollbarY)
window->ScrollbarY = (needed_size_from_last_frame.y > size_y_for_scrollbars) && !(flags & ImGuiWindowFlags_NoScrollbar);
window->ScrollbarSizes = ImVec2(window->ScrollbarY ? style.ScrollbarSize : 0.0f, window->ScrollbarX ? style.ScrollbarSize : 0.0f);
}
// UPDATE RECTANGLES (1- THOSE NOT AFFECTED BY SCROLLING)
// Update various regions. Variables they depends on should be set above in this function.
// We set this up after processing the resize grip so that our rectangles doesn't lag by a frame.
// Outer rectangle
// Not affected by window border size. Used by:
// - FindHoveredWindow() (w/ extra padding when border resize is enabled)
// - Begin() initial clipping rect for drawing window background and borders.
// - Begin() clipping whole child
const ImRect host_rect = ((flags & ImGuiWindowFlags_ChildWindow) && !(flags & ImGuiWindowFlags_Popup) && !window_is_child_tooltip) ? parent_window->ClipRect : viewport_rect;
const ImRect outer_rect = window->Rect();
const ImRect title_bar_rect = window->TitleBarRect();
window->OuterRectClipped = outer_rect;
if (window->DockIsActive)
window->OuterRectClipped.Min.y += window->TitleBarHeight();
window->OuterRectClipped.ClipWith(host_rect);
// Inner rectangle
// Not affected by window border size. Used by:
// - InnerClipRect
// - ScrollToBringRectIntoView()
// - NavUpdatePageUpPageDown()
// - Scrollbar()
window->InnerRect.Min.x = window->Pos.x;
window->InnerRect.Min.y = window->Pos.y + decoration_up_height;
window->InnerRect.Max.x = window->Pos.x + window->Size.x - window->ScrollbarSizes.x;
window->InnerRect.Max.y = window->Pos.y + window->Size.y - window->ScrollbarSizes.y;
// Inner clipping rectangle.
// Will extend a little bit outside the normal work region.
// This is to allow e.g. Selectable or CollapsingHeader or some separators to cover that space.
// Force round operator last to ensure that e.g. (int)(max.x-min.x) in user's render code produce correct result.
// Note that if our window is collapsed we will end up with an inverted (~null) clipping rectangle which is the correct behavior.
// Affected by window/frame border size. Used by:
// - Begin() initial clip rect
float top_border_size = (((flags & ImGuiWindowFlags_MenuBar) || !(flags & ImGuiWindowFlags_NoTitleBar)) ? style.FrameBorderSize : window->WindowBorderSize);
window->InnerClipRect.Min.x = ImFloor(0.5f + window->InnerRect.Min.x + ImMax(ImFloor(window->WindowPadding.x * 0.5f), window->WindowBorderSize));
window->InnerClipRect.Min.y = ImFloor(0.5f + window->InnerRect.Min.y + top_border_size);
window->InnerClipRect.Max.x = ImFloor(0.5f + window->InnerRect.Max.x - ImMax(ImFloor(window->WindowPadding.x * 0.5f), window->WindowBorderSize));
window->InnerClipRect.Max.y = ImFloor(0.5f + window->InnerRect.Max.y - window->WindowBorderSize);
window->InnerClipRect.ClipWithFull(host_rect);
// Default item width. Make it proportional to window size if window manually resizes
if (window->Size.x > 0.0f && !(flags & ImGuiWindowFlags_Tooltip) && !(flags & ImGuiWindowFlags_AlwaysAutoResize))
window->ItemWidthDefault = (float)(int)(window->Size.x * 0.65f);
else
window->ItemWidthDefault = (float)(int)(g.FontSize * 16.0f);
// SCROLLING
// Lock down maximum scrolling
// The value of ScrollMax are ahead from ScrollbarX/ScrollbarY which is intentionally using InnerRect from previous rect in order to accommodate
// for right/bottom aligned items without creating a scrollbar.
window->ScrollMax.x = ImMax(0.0f, window->ContentSize.x + window->WindowPadding.x * 2.0f - window->InnerRect.GetWidth());
window->ScrollMax.y = ImMax(0.0f, window->ContentSize.y + window->WindowPadding.y * 2.0f - window->InnerRect.GetHeight());
// Apply scrolling
window->Scroll = CalcNextScrollFromScrollTargetAndClamp(window, true);
window->ScrollTarget = ImVec2(FLT_MAX, FLT_MAX);
// DRAWING
// Setup draw list and outer clipping rectangle
window->DrawList->Clear();
window->DrawList->PushTextureID(g.Font->ContainerAtlas->TexID);
PushClipRect(host_rect.Min, host_rect.Max, false);
// Draw modal or window list full viewport dimming background (for other viewports we'll render them in EndFrame)
const bool dim_bg_for_modal = (flags & ImGuiWindowFlags_Modal) && window == GetTopMostPopupModal() && window->HiddenFramesCannotSkipItems <= 0;
const bool dim_bg_for_window_list = g.NavWindowingTargetAnim && ((window == g.NavWindowingTargetAnim->RootWindow) || (g.NavWindowingList && (window == g.NavWindowingList) && g.NavWindowingList->Viewport != g.NavWindowingTargetAnim->Viewport));
if (dim_bg_for_modal || dim_bg_for_window_list)
{
const ImU32 dim_bg_col = GetColorU32(dim_bg_for_modal ? ImGuiCol_ModalWindowDimBg : ImGuiCol_NavWindowingDimBg, g.DimBgRatio);
window->DrawList->AddRectFilled(viewport_rect.Min, viewport_rect.Max, dim_bg_col);
}
// Draw navigation selection/windowing rectangle background
if (dim_bg_for_window_list && window == g.NavWindowingTargetAnim)
{
ImRect bb = window->Rect();
bb.Expand(g.FontSize);
if (!bb.Contains(viewport_rect)) // Avoid drawing if the window covers all the viewport anyway
window->DrawList->AddRectFilled(bb.Min, bb.Max, GetColorU32(ImGuiCol_NavWindowingHighlight, g.NavWindowingHighlightAlpha * 0.25f), g.Style.WindowRounding);
}
const bool is_undocked_or_docked_visible = !window->DockIsActive || window->DockTabIsVisible;
// Since 1.71, child window can render their decoration (bg color, border, scrollbars, etc.) within their parent to save a draw call.
// When using overlapping child windows, this will break the assumption that child z-order is mapped to submission order.
// We disable this when the parent window has zero vertices, which is a common pattern leading to laying out multiple overlapping child.
// We also disabled this when we have dimming overlay behind this specific one child.
// FIXME: More code may rely on explicit sorting of overlapping child window and would need to disable this somehow. Please get in contact if you are affected.
if (is_undocked_or_docked_visible)
{
bool render_decorations_in_parent = false;
if ((flags & ImGuiWindowFlags_ChildWindow) && !(flags & ImGuiWindowFlags_Popup) && !window_is_child_tooltip)
if (window->DrawList->CmdBuffer.back().ElemCount == 0 && parent_window->DrawList->VtxBuffer.Size > 0)
render_decorations_in_parent = true;
if (render_decorations_in_parent)
window->DrawList = parent_window->DrawList;
// Handle title bar, scrollbar, resize grips and resize borders
const ImGuiWindow* window_to_highlight = g.NavWindowingTarget ? g.NavWindowingTarget : g.NavWindow;
const bool title_bar_is_highlight = want_focus || (window_to_highlight && (window->RootWindowForTitleBarHighlight == window_to_highlight->RootWindowForTitleBarHighlight || (window->DockNode && window->DockNode == window_to_highlight->DockNode)));
RenderWindowDecorations(window, title_bar_rect, title_bar_is_highlight, handle_borders_and_resize_grips, resize_grip_count, resize_grip_col, resize_grip_draw_size);
if (render_decorations_in_parent)
window->DrawList = &window->DrawListInst;
}
// Draw navigation selection/windowing rectangle border
if (g.NavWindowingTargetAnim == window)
{
float rounding = ImMax(window->WindowRounding, g.Style.WindowRounding);
ImRect bb = window->Rect();
bb.Expand(g.FontSize);
if (bb.Contains(viewport_rect)) // If a window fits the entire viewport, adjust its highlight inward
{
bb.Expand(-g.FontSize - 1.0f);
rounding = window->WindowRounding;
}
window->DrawList->AddRect(bb.Min, bb.Max, GetColorU32(ImGuiCol_NavWindowingHighlight, g.NavWindowingHighlightAlpha), rounding, ~0, 3.0f);
}
// UPDATE RECTANGLES (2- THOSE AFFECTED BY SCROLLING)
// Work rectangle.
// Affected by window padding and border size. Used by:
// - Columns() for right-most edge
// - TreeNode(), CollapsingHeader() for right-most edge
// - BeginTabBar() for right-most edge
const bool allow_scrollbar_x = !(flags & ImGuiWindowFlags_NoScrollbar) && (flags & ImGuiWindowFlags_HorizontalScrollbar);
const bool allow_scrollbar_y = !(flags & ImGuiWindowFlags_NoScrollbar);
const float work_rect_size_x = (window->ContentSizeExplicit.x != 0.0f ? window->ContentSizeExplicit.x : ImMax(allow_scrollbar_x ? window->ContentSize.x : 0.0f, window->Size.x - window->WindowPadding.x * 2.0f - window->ScrollbarSizes.x));
const float work_rect_size_y = (window->ContentSizeExplicit.y != 0.0f ? window->ContentSizeExplicit.y : ImMax(allow_scrollbar_y ? window->ContentSize.y : 0.0f, window->Size.y - window->WindowPadding.y * 2.0f - decoration_up_height - window->ScrollbarSizes.y));
window->WorkRect.Min.x = ImFloor(window->InnerRect.Min.x - window->Scroll.x + ImMax(window->WindowPadding.x, window->WindowBorderSize));
window->WorkRect.Min.y = ImFloor(window->InnerRect.Min.y - window->Scroll.y + ImMax(window->WindowPadding.y, window->WindowBorderSize));
window->WorkRect.Max.x = window->WorkRect.Min.x + work_rect_size_x;
window->WorkRect.Max.y = window->WorkRect.Min.y + work_rect_size_y;
// [LEGACY] Contents Region
// FIXME-OBSOLETE: window->ContentsRegionRect.Max is currently very misleading / partly faulty, but some BeginChild() patterns relies on it.
// Used by:
// - Mouse wheel scrolling + many other things
window->ContentsRegionRect.Min.x = window->Pos.x - window->Scroll.x + window->WindowPadding.x;
window->ContentsRegionRect.Min.y = window->Pos.y - window->Scroll.y + window->WindowPadding.y + decoration_up_height;
window->ContentsRegionRect.Max.x = window->ContentsRegionRect.Min.x + (window->ContentSizeExplicit.x != 0.0f ? window->ContentSizeExplicit.x : (window->Size.x - window->WindowPadding.x * 2.0f - window->ScrollbarSizes.x));
window->ContentsRegionRect.Max.y = window->ContentsRegionRect.Min.y + (window->ContentSizeExplicit.y != 0.0f ? window->ContentSizeExplicit.y : (window->Size.y - window->WindowPadding.y * 2.0f - decoration_up_height - window->ScrollbarSizes.y));
// Setup drawing context
// (NB: That term "drawing context / DC" lost its meaning a long time ago. Initially was meant to hold transient data only. Nowadays difference between window-> and window->DC-> is dubious.)
window->DC.Indent.x = 0.0f + window->WindowPadding.x - window->Scroll.x;
window->DC.GroupOffset.x = 0.0f;
window->DC.ColumnsOffset.x = 0.0f;
window->DC.CursorStartPos = window->Pos + ImVec2(window->DC.Indent.x + window->DC.ColumnsOffset.x, decoration_up_height + window->WindowPadding.y - window->Scroll.y);
window->DC.CursorPos = window->DC.CursorStartPos;
window->DC.CursorPosPrevLine = window->DC.CursorPos;
window->DC.CursorMaxPos = window->DC.CursorStartPos;
window->DC.CurrLineSize = window->DC.PrevLineSize = ImVec2(0.0f, 0.0f);
window->DC.CurrLineTextBaseOffset = window->DC.PrevLineTextBaseOffset = 0.0f;
window->DC.NavHideHighlightOneFrame = false;
window->DC.NavHasScroll = (window->ScrollMax.y > 0.0f);
window->DC.NavLayerActiveMask = window->DC.NavLayerActiveMaskNext;
window->DC.NavLayerActiveMaskNext = 0x00;
window->DC.MenuBarAppending = false;
window->DC.ChildWindows.resize(0);
window->DC.LayoutType = ImGuiLayoutType_Vertical;
window->DC.ParentLayoutType = parent_window ? parent_window->DC.LayoutType : ImGuiLayoutType_Vertical;
window->DC.FocusCounterAll = window->DC.FocusCounterTab = -1;
window->DC.ItemFlags = parent_window ? parent_window->DC.ItemFlags : ImGuiItemFlags_Default_;
window->DC.ItemWidth = window->ItemWidthDefault;
window->DC.TextWrapPos = -1.0f; // disabled
window->DC.ItemFlagsStack.resize(0);
window->DC.ItemWidthStack.resize(0);
window->DC.TextWrapPosStack.resize(0);
window->DC.CurrentColumns = NULL;
window->DC.TreeDepth = 0;
window->DC.TreeStoreMayJumpToParentOnPop = 0x00;
window->DC.StateStorage = &window->StateStorage;
window->DC.GroupStack.resize(0);
window->MenuColumns.Update(3, style.ItemSpacing.x, window_just_activated_by_user);
if ((flags & ImGuiWindowFlags_ChildWindow) && (window->DC.ItemFlags != parent_window->DC.ItemFlags))
{
window->DC.ItemFlags = parent_window->DC.ItemFlags;
window->DC.ItemFlagsStack.push_back(window->DC.ItemFlags);
}
if (window->AutoFitFramesX > 0)
window->AutoFitFramesX--;
if (window->AutoFitFramesY > 0)
window->AutoFitFramesY--;
// Apply focus (we need to call FocusWindow() AFTER setting DC.CursorStartPos so our initial navigation reference rectangle can start around there)
if (want_focus)
{
FocusWindow(window);
NavInitWindow(window, false);
}
// Close from platform window
if (p_open != NULL && window->Viewport->PlatformRequestClose && window->Viewport != GetMainViewport())
{
if (!window->DockIsActive || window->DockTabIsVisible)
{
window->Viewport->PlatformRequestClose = false;
g.NavWindowingToggleLayer = false; // Assume user mapped PlatformRequestClose on ALT-F4 so we disable ALT for menu toggle. False positive not an issue.
IMGUI_DEBUG_LOG_VIEWPORT("Window '%s' PlatformRequestClose\n", window->Name);
*p_open = false;
}
}
// Title bar
if (!(flags & ImGuiWindowFlags_NoTitleBar) && !window->DockIsActive)
RenderWindowTitleBarContents(window, title_bar_rect, name, p_open);
// Clear hit test shape every frame
window->HitTestHoleSize.x = window->HitTestHoleSize.y = 0;
// Pressing CTRL+C while holding on a window copy its content to the clipboard
// This works but 1. doesn't handle multiple Begin/End pairs, 2. recursing into another Begin/End pair - so we need to work that out and add better logging scope.
// Maybe we can support CTRL+C on every element?
/*
if (g.ActiveId == move_id)
if (g.IO.KeyCtrl && IsKeyPressedMap(ImGuiKey_C))
LogToClipboard();
*/
if (g.IO.ConfigFlags & ImGuiConfigFlags_DockingEnable)
{
// Docking: Dragging a dockable window (or any of its child) turns it into a drag and drop source.
// We need to do this _before_ we overwrite window->DC.LastItemId below because BeginAsDockableDragDropSource() also overwrites it.
if ((g.ActiveId == window->MoveId) && (g.IO.ConfigDockingWithShift == g.IO.KeyShift))
if ((window->Flags & ImGuiWindowFlags_NoMove) == 0)
if ((window->RootWindow->Flags & (ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoDocking)) == 0)
BeginAsDockableDragDropSource(window);
// Docking: Any dockable window can act as a target. For dock node hosts we call BeginAsDockableDragDropTarget() in DockNodeUpdate() instead.
if (g.DragDropActive && !(flags & ImGuiWindowFlags_NoDocking))
if (g.MovingWindow == NULL || g.MovingWindow->RootWindow != window)
if ((window == window->RootWindow) && !(window->Flags & ImGuiWindowFlags_DockNodeHost))
BeginAsDockableDragDropTarget(window);
}
// We fill last item data based on Title Bar/Tab, in order for IsItemHovered() and IsItemActive() to be usable after Begin().
// This is useful to allow creating context menus on title bar only, etc.
if (window->DockIsActive)
{
window->DC.LastItemId = window->ID;
window->DC.LastItemStatusFlags = window->DockTabItemStatusFlags;
window->DC.LastItemRect = window->DockTabItemRect;
}
else
{
window->DC.LastItemId = window->MoveId;
window->DC.LastItemStatusFlags = IsMouseHoveringRect(title_bar_rect.Min, title_bar_rect.Max, false) ? ImGuiItemStatusFlags_HoveredRect : 0;
window->DC.LastItemRect = title_bar_rect;
}
#ifdef IMGUI_ENABLE_TEST_ENGINE
if (!(window->Flags & ImGuiWindowFlags_NoTitleBar))
IMGUI_TEST_ENGINE_ITEM_ADD(window->DC.LastItemRect, window->DC.LastItemId);
#endif
}
else
{
// Append
SetCurrentViewport(window, window->Viewport);
SetCurrentWindow(window);
}
if (!(flags & ImGuiWindowFlags_DockNodeHost))
PushClipRect(window->InnerClipRect.Min, window->InnerClipRect.Max, true);
// Clear 'accessed' flag last thing (After PushClipRect which will set the flag. We want the flag to stay false when the default "Debug" window is unused)
if (first_begin_of_the_frame)
window->WriteAccessed = false;
window->BeginCount++;
g.NextWindowData.ClearFlags();
// When we are about to select this tab (which will only be visible on the _next frame_), flag it with a non-zero HiddenFramesCannotSkipItems.
// This will have the important effect of actually returning true in Begin() and not setting SkipItems, allowing an earlier submission of the window contents.
// This is analogous to regular windows being hidden from one frame.
// It is especially important as e.g. nested TabBars would otherwise generate flicker in the form of one empty frame, or focus requests won't be processed.
if (window->DockIsActive && !window->DockTabIsVisible)
{
if (window->LastFrameJustFocused == g.FrameCount)
window->HiddenFramesCannotSkipItems = 1;
else
window->HiddenFramesCanSkipItems = 1;
}
if (flags & ImGuiWindowFlags_ChildWindow)
{
// Child window can be out of sight and have "negative" clip windows.
// Mark them as collapsed so commands are skipped earlier (we can't manually collapse them because they have no title bar).
IM_ASSERT((flags & ImGuiWindowFlags_NoTitleBar) != 0 || (window->DockIsActive));
if (!(flags & ImGuiWindowFlags_AlwaysAutoResize) && window->AutoFitFramesX <= 0 && window->AutoFitFramesY <= 0)
if (window->OuterRectClipped.Min.x >= window->OuterRectClipped.Max.x || window->OuterRectClipped.Min.y >= window->OuterRectClipped.Max.y)
window->HiddenFramesCanSkipItems = 1;
// Hide along with parent or if parent is collapsed
if (parent_window && (parent_window->Collapsed || parent_window->HiddenFramesCanSkipItems > 0))
window->HiddenFramesCanSkipItems = 1;
if (parent_window && (parent_window->Collapsed || parent_window->HiddenFramesCannotSkipItems > 0))
window->HiddenFramesCannotSkipItems = 1;
}
// Don't render if style alpha is 0.0 at the time of Begin(). This is arbitrary and inconsistent but has been there for a long while (may remove at some point)
if (style.Alpha <= 0.0f)
window->HiddenFramesCanSkipItems = 1;
// Update the Hidden flag
window->Hidden = (window->HiddenFramesCanSkipItems > 0) || (window->HiddenFramesCannotSkipItems > 0);
// Update the SkipItems flag, used to early out of all items functions (no layout required)
bool skip_items = false;
if (window->Collapsed || !window->Active || window->Hidden)
if (window->AutoFitFramesX <= 0 && window->AutoFitFramesY <= 0 && window->HiddenFramesCannotSkipItems <= 0)
skip_items = true;
window->SkipItems = skip_items;
return !skip_items;
}
// Old Begin() API with 5 parameters, avoid calling this version directly! Use SetNextWindowSize()/SetNextWindowBgAlpha() + Begin() instead.
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
bool ImGui::Begin(const char* name, bool* p_open, const ImVec2& size_first_use, float bg_alpha_override, ImGuiWindowFlags flags)
{
// Old API feature: we could pass the initial window size as a parameter. This was misleading because it only had an effect if the window didn't have data in the .ini file.
if (size_first_use.x != 0.0f || size_first_use.y != 0.0f)
SetNextWindowSize(size_first_use, ImGuiCond_FirstUseEver);
// Old API feature: override the window background alpha with a parameter.
if (bg_alpha_override >= 0.0f)
SetNextWindowBgAlpha(bg_alpha_override);
return Begin(name, p_open, flags);
}
#endif // IMGUI_DISABLE_OBSOLETE_FUNCTIONS
void ImGui::End()
{
ImGuiContext& g = *GImGui;
if (g.CurrentWindowStack.Size <= 1 && g.FrameScopePushedFallbackWindow)
{
IM_ASSERT(g.CurrentWindowStack.Size > 1 && "Calling End() too many times!");
return; // FIXME-ERRORHANDLING
}
IM_ASSERT(g.CurrentWindowStack.Size > 0);
ImGuiWindow* window = g.CurrentWindow;
if (window->DC.CurrentColumns)
EndColumns();
if (!(window->Flags & ImGuiWindowFlags_DockNodeHost)) // Pop inner window clip rectangle
PopClipRect();
// Stop logging
if (!(window->Flags & ImGuiWindowFlags_ChildWindow)) // FIXME: add more options for scope of logging
LogFinish();
// Docking: report contents sizes to parent to allow for auto-resize
if (window->DockNode && window->DockTabIsVisible)
if (ImGuiWindow* host_window = window->DockNode->HostWindow) // FIXME-DOCK
host_window->DC.CursorMaxPos = window->DC.CursorMaxPos + window->WindowPadding - host_window->WindowPadding;
// Pop from window stack
g.CurrentWindowStack.pop_back();
if (window->Flags & ImGuiWindowFlags_Popup)
g.BeginPopupStack.pop_back();
CheckStacksSize(window, false);
SetCurrentWindow(g.CurrentWindowStack.empty() ? NULL : g.CurrentWindowStack.back());
if (g.CurrentWindow)
SetCurrentViewport(g.CurrentWindow, g.CurrentWindow->Viewport);
}
void ImGui::BringWindowToFocusFront(ImGuiWindow* window)
{
ImGuiContext& g = *GImGui;
if (g.WindowsFocusOrder.back() == window)
return;
for (int i = g.WindowsFocusOrder.Size - 2; i >= 0; i--) // We can ignore the top-most window
if (g.WindowsFocusOrder[i] == window)
{
memmove(&g.WindowsFocusOrder[i], &g.WindowsFocusOrder[i + 1], (size_t)(g.WindowsFocusOrder.Size - i - 1) * sizeof(ImGuiWindow*));
g.WindowsFocusOrder[g.WindowsFocusOrder.Size - 1] = window;
break;
}
}
void ImGui::BringWindowToDisplayFront(ImGuiWindow* window)
{
ImGuiContext& g = *GImGui;
ImGuiWindow* current_front_window = g.Windows.back();
if (current_front_window == window || current_front_window->RootWindow == window)
return;
for (int i = g.Windows.Size - 2; i >= 0; i--) // We can ignore the top-most window
if (g.Windows[i] == window)
{
memmove(&g.Windows[i], &g.Windows[i + 1], (size_t)(g.Windows.Size - i - 1) * sizeof(ImGuiWindow*));
g.Windows[g.Windows.Size - 1] = window;
break;
}
}
void ImGui::BringWindowToDisplayBack(ImGuiWindow* window)
{
ImGuiContext& g = *GImGui;
if (g.Windows[0] == window)
return;
for (int i = 0; i < g.Windows.Size; i++)
if (g.Windows[i] == window)
{
memmove(&g.Windows[1], &g.Windows[0], (size_t)i * sizeof(ImGuiWindow*));
g.Windows[0] = window;
break;
}
}
// Moving window to front of display and set focus (which happens to be back of our sorted list)
void ImGui::FocusWindow(ImGuiWindow* window)
{
ImGuiContext& g = *GImGui;
if (g.NavWindow != window)
{
g.NavWindow = window;
if (window && g.NavDisableMouseHover)
g.NavMousePosDirty = true;
g.NavInitRequest = false;
g.NavId = window ? window->NavLastIds[0] : 0; // Restore NavId
g.NavIdIsAlive = false;
g.NavLayer = ImGuiNavLayer_Main;
//IMGUI_DEBUG_LOG("FocusWindow(\"%s\")\n", window ? window->Name : NULL);
}
// Close popups if any
ClosePopupsOverWindow(window, false);
// Passing NULL allow to disable keyboard focus
if (!window)
return;
window->LastFrameJustFocused = g.FrameCount;
// Select in dock node
if (window->DockNode && window->DockNode->TabBar)
window->DockNode->TabBar->SelectedTabId = window->DockNode->TabBar->NextSelectedTabId = window->ID;
// Move the root window to the top of the pile
if (window->RootWindow)
window = window->RootWindow;
// Steal focus on active widgets
if (window->Flags & ImGuiWindowFlags_Popup) // FIXME: This statement should be unnecessary. Need further testing before removing it..
if (g.ActiveId != 0 && g.ActiveIdWindow && g.ActiveIdWindow->RootWindow != window)
ClearActiveID();
// Bring to front
BringWindowToFocusFront(window);
if (!(window->Flags & ImGuiWindowFlags_NoBringToFrontOnFocus))
BringWindowToDisplayFront(window);
}
void ImGui::FocusTopMostWindowUnderOne(ImGuiWindow* under_this_window, ImGuiWindow* ignore_window)
{
ImGuiContext& g = *GImGui;
int start_idx = g.WindowsFocusOrder.Size - 1;
if (under_this_window != NULL)
{
int under_this_window_idx = FindWindowFocusIndex(under_this_window);
if (under_this_window_idx != -1)
start_idx = under_this_window_idx - 1;
}
for (int i = start_idx; i >= 0; i--)
{
// We may later decide to test for different NoXXXInputs based on the active navigation input (mouse vs nav) but that may feel more confusing to the user.
ImGuiWindow* window = g.WindowsFocusOrder[i];
if (window != ignore_window && window->WasActive && !(window->Flags & ImGuiWindowFlags_ChildWindow))
if ((window->Flags & (ImGuiWindowFlags_NoMouseInputs | ImGuiWindowFlags_NoNavInputs)) != (ImGuiWindowFlags_NoMouseInputs | ImGuiWindowFlags_NoNavInputs))
{
// FIXME-DOCKING: This is failing (lagging by one frame) for docked windows.
// If A and B are docked into window and B disappear, at the NewFrame() call site window->NavLastChildNavWindow will still point to B.
// We might leverage the tab order implicitly stored in window->DockNodeAsHost->TabBar (essentially the 'most_recently_selected_tab' code in tab bar will do that but on next update)
// to tell which is the "previous" window. Or we may leverage 'LastFrameFocused/LastFrameJustFocused' and have this function handle child window itself?
ImGuiWindow* focus_window = NavRestoreLastChildNavWindow(window);
FocusWindow(focus_window);
return;
}
}
FocusWindow(NULL);
}
void ImGui::SetNextItemWidth(float item_width)
{
ImGuiContext& g = *GImGui;
g.NextItemData.Flags |= ImGuiNextItemDataFlags_HasWidth;
g.NextItemData.Width = item_width;
}
void ImGui::PushItemWidth(float item_width)
{
ImGuiContext& g = *GImGui;
ImGuiWindow* window = g.CurrentWindow;
window->DC.ItemWidth = (item_width == 0.0f ? window->ItemWidthDefault : item_width);
window->DC.ItemWidthStack.push_back(window->DC.ItemWidth);
g.NextItemData.Flags &= ~ImGuiNextItemDataFlags_HasWidth;
}
void ImGui::PushMultiItemsWidths(int components, float w_full)
{
ImGuiContext& g = *GImGui;
ImGuiWindow* window = g.CurrentWindow;
const ImGuiStyle& style = g.Style;
const float w_item_one = ImMax(1.0f, (float)(int)((w_full - (style.ItemInnerSpacing.x) * (components-1)) / (float)components));
const float w_item_last = ImMax(1.0f, (float)(int)(w_full - (w_item_one + style.ItemInnerSpacing.x) * (components-1)));
window->DC.ItemWidthStack.push_back(w_item_last);
for (int i = 0; i < components-1; i++)
window->DC.ItemWidthStack.push_back(w_item_one);
window->DC.ItemWidth = window->DC.ItemWidthStack.back();
g.NextItemData.Flags &= ~ImGuiNextItemDataFlags_HasWidth;
}
void ImGui::PopItemWidth()
{
ImGuiWindow* window = GetCurrentWindow();
window->DC.ItemWidthStack.pop_back();
window->DC.ItemWidth = window->DC.ItemWidthStack.empty() ? window->ItemWidthDefault : window->DC.ItemWidthStack.back();
}
// Calculate default item width given value passed to PushItemWidth() or SetNextItemWidth().
// The SetNextItemWidth() data is generally cleared/consumed by ItemAdd() or NextItemData.ClearFlags()
float ImGui::CalcItemWidth()
{
ImGuiContext& g = *GImGui;
ImGuiWindow* window = g.CurrentWindow;
float w;
if (g.NextItemData.Flags & ImGuiNextItemDataFlags_HasWidth)
w = g.NextItemData.Width;
else
w = window->DC.ItemWidth;
if (w < 0.0f)
{
float region_max_x = GetContentRegionMaxAbs().x;
w = ImMax(1.0f, region_max_x - window->DC.CursorPos.x + w);
}
w = (float)(int)w;
return w;
}
// [Internal] Calculate full item size given user provided 'size' parameter and default width/height. Default width is often == CalcItemWidth().
// Those two functions CalcItemWidth vs CalcItemSize are awkwardly named because they are not fully symmetrical.
// Note that only CalcItemWidth() is publicly exposed.
// The 4.0f here may be changed to match CalcItemWidth() and/or BeginChild() (right now we have a mismatch which is harmless but undesirable)
ImVec2 ImGui::CalcItemSize(ImVec2 size, float default_w, float default_h)
{
ImGuiWindow* window = GImGui->CurrentWindow;
ImVec2 region_max;
if (size.x < 0.0f || size.y < 0.0f)
region_max = GetContentRegionMaxAbs();
if (size.x == 0.0f)
size.x = default_w;
else if (size.x < 0.0f)
size.x = ImMax(4.0f, region_max.x - window->DC.CursorPos.x + size.x);
if (size.y == 0.0f)
size.y = default_h;
else if (size.y < 0.0f)
size.y = ImMax(4.0f, region_max.y - window->DC.CursorPos.y + size.y);
return size;
}
void ImGui::SetCurrentFont(ImFont* font)
{
ImGuiContext& g = *GImGui;
IM_ASSERT(font && font->IsLoaded()); // Font Atlas not created. Did you call io.Fonts->GetTexDataAsRGBA32 / GetTexDataAsAlpha8 ?
IM_ASSERT(font->Scale > 0.0f);
g.Font = font;
g.FontBaseSize = ImMax(1.0f, g.IO.FontGlobalScale * g.Font->FontSize * g.Font->Scale);
g.FontSize = g.CurrentWindow ? g.CurrentWindow->CalcFontSize() : 0.0f;
ImFontAtlas* atlas = g.Font->ContainerAtlas;
g.DrawListSharedData.TexUvWhitePixel = atlas->TexUvWhitePixel;
g.DrawListSharedData.Font = g.Font;
g.DrawListSharedData.FontSize = g.FontSize;
}
void ImGui::PushFont(ImFont* font)
{
ImGuiContext& g = *GImGui;
if (!font)
font = GetDefaultFont();
SetCurrentFont(font);
g.FontStack.push_back(font);
g.CurrentWindow->DrawList->PushTextureID(font->ContainerAtlas->TexID);
}
void ImGui::PopFont()
{
ImGuiContext& g = *GImGui;
g.CurrentWindow->DrawList->PopTextureID();
g.FontStack.pop_back();
SetCurrentFont(g.FontStack.empty() ? GetDefaultFont() : g.FontStack.back());
}
void ImGui::PushItemFlag(ImGuiItemFlags option, bool enabled)
{
ImGuiWindow* window = GetCurrentWindow();
if (enabled)
window->DC.ItemFlags |= option;
else
window->DC.ItemFlags &= ~option;
window->DC.ItemFlagsStack.push_back(window->DC.ItemFlags);
}
void ImGui::PopItemFlag()
{
ImGuiWindow* window = GetCurrentWindow();
window->DC.ItemFlagsStack.pop_back();
window->DC.ItemFlags = window->DC.ItemFlagsStack.empty() ? ImGuiItemFlags_Default_ : window->DC.ItemFlagsStack.back();
}
// FIXME: Look into renaming this once we have settled the new Focus/Activation/TabStop system.
void ImGui::PushAllowKeyboardFocus(bool allow_keyboard_focus)
{
PushItemFlag(ImGuiItemFlags_NoTabStop, !allow_keyboard_focus);
}
void ImGui::PopAllowKeyboardFocus()
{
PopItemFlag();
}
void ImGui::PushButtonRepeat(bool repeat)
{
PushItemFlag(ImGuiItemFlags_ButtonRepeat, repeat);
}
void ImGui::PopButtonRepeat()
{
PopItemFlag();
}
void ImGui::PushTextWrapPos(float wrap_pos_x)
{
ImGuiWindow* window = GetCurrentWindow();
window->DC.TextWrapPos = wrap_pos_x;
window->DC.TextWrapPosStack.push_back(wrap_pos_x);
}
void ImGui::PopTextWrapPos()
{
ImGuiWindow* window = GetCurrentWindow();
window->DC.TextWrapPosStack.pop_back();
window->DC.TextWrapPos = window->DC.TextWrapPosStack.empty() ? -1.0f : window->DC.TextWrapPosStack.back();
}
// FIXME: This may incur a round-trip (if the end user got their data from a float4) but eventually we aim to store the in-flight colors as ImU32
void ImGui::PushStyleColor(ImGuiCol idx, ImU32 col)
{
ImGuiContext& g = *GImGui;
ImGuiColorMod backup;
backup.Col = idx;
backup.BackupValue = g.Style.Colors[idx];
g.ColorModifiers.push_back(backup);
g.Style.Colors[idx] = ColorConvertU32ToFloat4(col);
}
void ImGui::PushStyleColor(ImGuiCol idx, const ImVec4& col)
{
ImGuiContext& g = *GImGui;
ImGuiColorMod backup;
backup.Col = idx;
backup.BackupValue = g.Style.Colors[idx];
g.ColorModifiers.push_back(backup);
g.Style.Colors[idx] = col;
}
void ImGui::PopStyleColor(int count)
{
ImGuiContext& g = *GImGui;
while (count > 0)
{
ImGuiColorMod& backup = g.ColorModifiers.back();
g.Style.Colors[backup.Col] = backup.BackupValue;
g.ColorModifiers.pop_back();
count--;
}
}
struct ImGuiStyleVarInfo
{
ImGuiDataType Type;
ImU32 Count;
ImU32 Offset;
void* GetVarPtr(ImGuiStyle* style) const { return (void*)((unsigned char*)style + Offset); }
};
static const ImGuiStyleVarInfo GStyleVarInfo[] =
{
{ ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImGuiStyle, Alpha) }, // ImGuiStyleVar_Alpha
{ ImGuiDataType_Float, 2, (ImU32)IM_OFFSETOF(ImGuiStyle, WindowPadding) }, // ImGuiStyleVar_WindowPadding
{ ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImGuiStyle, WindowRounding) }, // ImGuiStyleVar_WindowRounding
{ ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImGuiStyle, WindowBorderSize) }, // ImGuiStyleVar_WindowBorderSize
{ ImGuiDataType_Float, 2, (ImU32)IM_OFFSETOF(ImGuiStyle, WindowMinSize) }, // ImGuiStyleVar_WindowMinSize
{ ImGuiDataType_Float, 2, (ImU32)IM_OFFSETOF(ImGuiStyle, WindowTitleAlign) }, // ImGuiStyleVar_WindowTitleAlign
{ ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImGuiStyle, ChildRounding) }, // ImGuiStyleVar_ChildRounding
{ ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImGuiStyle, ChildBorderSize) }, // ImGuiStyleVar_ChildBorderSize
{ ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImGuiStyle, PopupRounding) }, // ImGuiStyleVar_PopupRounding
{ ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImGuiStyle, PopupBorderSize) }, // ImGuiStyleVar_PopupBorderSize
{ ImGuiDataType_Float, 2, (ImU32)IM_OFFSETOF(ImGuiStyle, FramePadding) }, // ImGuiStyleVar_FramePadding
{ ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImGuiStyle, FrameRounding) }, // ImGuiStyleVar_FrameRounding
{ ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImGuiStyle, FrameBorderSize) }, // ImGuiStyleVar_FrameBorderSize
{ ImGuiDataType_Float, 2, (ImU32)IM_OFFSETOF(ImGuiStyle, ItemSpacing) }, // ImGuiStyleVar_ItemSpacing
{ ImGuiDataType_Float, 2, (ImU32)IM_OFFSETOF(ImGuiStyle, ItemInnerSpacing) }, // ImGuiStyleVar_ItemInnerSpacing
{ ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImGuiStyle, IndentSpacing) }, // ImGuiStyleVar_IndentSpacing
{ ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImGuiStyle, ScrollbarSize) }, // ImGuiStyleVar_ScrollbarSize
{ ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImGuiStyle, ScrollbarRounding) }, // ImGuiStyleVar_ScrollbarRounding
{ ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImGuiStyle, GrabMinSize) }, // ImGuiStyleVar_GrabMinSize
{ ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImGuiStyle, GrabRounding) }, // ImGuiStyleVar_GrabRounding
{ ImGuiDataType_Float, 1, (ImU32)IM_OFFSETOF(ImGuiStyle, TabRounding) }, // ImGuiStyleVar_TabRounding
{ ImGuiDataType_Float, 2, (ImU32)IM_OFFSETOF(ImGuiStyle, ButtonTextAlign) }, // ImGuiStyleVar_ButtonTextAlign
{ ImGuiDataType_Float, 2, (ImU32)IM_OFFSETOF(ImGuiStyle, SelectableTextAlign) }, // ImGuiStyleVar_SelectableTextAlign
};
static const ImGuiStyleVarInfo* GetStyleVarInfo(ImGuiStyleVar idx)
{
IM_ASSERT(idx >= 0 && idx < ImGuiStyleVar_COUNT);
IM_ASSERT(IM_ARRAYSIZE(GStyleVarInfo) == ImGuiStyleVar_COUNT);
return &GStyleVarInfo[idx];
}
void ImGui::PushStyleVar(ImGuiStyleVar idx, float val)
{
const ImGuiStyleVarInfo* var_info = GetStyleVarInfo(idx);
if (var_info->Type == ImGuiDataType_Float && var_info->Count == 1)
{
ImGuiContext& g = *GImGui;
float* pvar = (float*)var_info->GetVarPtr(&g.Style);
g.StyleModifiers.push_back(ImGuiStyleMod(idx, *pvar));
*pvar = val;
return;
}
IM_ASSERT(0 && "Called PushStyleVar() float variant but variable is not a float!");
}
void ImGui::PushStyleVar(ImGuiStyleVar idx, const ImVec2& val)
{
const ImGuiStyleVarInfo* var_info = GetStyleVarInfo(idx);
if (var_info->Type == ImGuiDataType_Float && var_info->Count == 2)
{
ImGuiContext& g = *GImGui;
ImVec2* pvar = (ImVec2*)var_info->GetVarPtr(&g.Style);
g.StyleModifiers.push_back(ImGuiStyleMod(idx, *pvar));
*pvar = val;
return;
}
IM_ASSERT(0 && "Called PushStyleVar() ImVec2 variant but variable is not a ImVec2!");
}
void ImGui::PopStyleVar(int count)
{
ImGuiContext& g = *GImGui;
while (count > 0)
{
// We avoid a generic memcpy(data, &backup.Backup.., GDataTypeSize[info->Type] * info->Count), the overhead in Debug is not worth it.
ImGuiStyleMod& backup = g.StyleModifiers.back();
const ImGuiStyleVarInfo* info = GetStyleVarInfo(backup.VarIdx);
void* data = info->GetVarPtr(&g.Style);
if (info->Type == ImGuiDataType_Float && info->Count == 1) { ((float*)data)[0] = backup.BackupFloat[0]; }
else if (info->Type == ImGuiDataType_Float && info->Count == 2) { ((float*)data)[0] = backup.BackupFloat[0]; ((float*)data)[1] = backup.BackupFloat[1]; }
g.StyleModifiers.pop_back();
count--;
}
}
const char* ImGui::GetStyleColorName(ImGuiCol idx)
{
// Create switch-case from enum with regexp: ImGuiCol_{.*}, --> case ImGuiCol_\1: return "\1";
switch (idx)
{
case ImGuiCol_Text: return "Text";
case ImGuiCol_TextDisabled: return "TextDisabled";
case ImGuiCol_WindowBg: return "WindowBg";
case ImGuiCol_ChildBg: return "ChildBg";
case ImGuiCol_PopupBg: return "PopupBg";
case ImGuiCol_Border: return "Border";
case ImGuiCol_BorderShadow: return "BorderShadow";
case ImGuiCol_FrameBg: return "FrameBg";
case ImGuiCol_FrameBgHovered: return "FrameBgHovered";
case ImGuiCol_FrameBgActive: return "FrameBgActive";
case ImGuiCol_TitleBg: return "TitleBg";
case ImGuiCol_TitleBgActive: return "TitleBgActive";
case ImGuiCol_TitleBgCollapsed: return "TitleBgCollapsed";
case ImGuiCol_MenuBarBg: return "MenuBarBg";
case ImGuiCol_ScrollbarBg: return "ScrollbarBg";
case ImGuiCol_ScrollbarGrab: return "ScrollbarGrab";
case ImGuiCol_ScrollbarGrabHovered: return "ScrollbarGrabHovered";
case ImGuiCol_ScrollbarGrabActive: return "ScrollbarGrabActive";
case ImGuiCol_CheckMark: return "CheckMark";
case ImGuiCol_SliderGrab: return "SliderGrab";
case ImGuiCol_SliderGrabActive: return "SliderGrabActive";
case ImGuiCol_Button: return "Button";
case ImGuiCol_ButtonHovered: return "ButtonHovered";
case ImGuiCol_ButtonActive: return "ButtonActive";
case ImGuiCol_Header: return "Header";
case ImGuiCol_HeaderHovered: return "HeaderHovered";
case ImGuiCol_HeaderActive: return "HeaderActive";
case ImGuiCol_Separator: return "Separator";
case ImGuiCol_SeparatorHovered: return "SeparatorHovered";
case ImGuiCol_SeparatorActive: return "SeparatorActive";
case ImGuiCol_ResizeGrip: return "ResizeGrip";
case ImGuiCol_ResizeGripHovered: return "ResizeGripHovered";
case ImGuiCol_ResizeGripActive: return "ResizeGripActive";
case ImGuiCol_Tab: return "Tab";
case ImGuiCol_TabHovered: return "TabHovered";
case ImGuiCol_TabActive: return "TabActive";
case ImGuiCol_TabUnfocused: return "TabUnfocused";
case ImGuiCol_TabUnfocusedActive: return "TabUnfocusedActive";
case ImGuiCol_DockingPreview: return "DockingPreview";
case ImGuiCol_DockingEmptyBg: return "DockingEmptyBg";
case ImGuiCol_PlotLines: return "PlotLines";
case ImGuiCol_PlotLinesHovered: return "PlotLinesHovered";
case ImGuiCol_PlotHistogram: return "PlotHistogram";
case ImGuiCol_PlotHistogramHovered: return "PlotHistogramHovered";
case ImGuiCol_TextSelectedBg: return "TextSelectedBg";
case ImGuiCol_DragDropTarget: return "DragDropTarget";
case ImGuiCol_NavHighlight: return "NavHighlight";
case ImGuiCol_NavWindowingHighlight: return "NavWindowingHighlight";
case ImGuiCol_NavWindowingDimBg: return "NavWindowingDimBg";
case ImGuiCol_ModalWindowDimBg: return "ModalWindowDimBg";
}
IM_ASSERT(0);
return "Unknown";
}
bool ImGui::IsWindowChildOf(ImGuiWindow* window, ImGuiWindow* potential_parent)
{
if (window->RootWindow == potential_parent)
return true;
while (window != NULL)
{
if (window == potential_parent)
return true;
window = window->ParentWindow;
}
return false;
}
bool ImGui::IsWindowHovered(ImGuiHoveredFlags flags)
{
IM_ASSERT((flags & ImGuiHoveredFlags_AllowWhenOverlapped) == 0); // Flags not supported by this function
ImGuiContext& g = *GImGui;
if (flags & ImGuiHoveredFlags_AnyWindow)
{
if (g.HoveredWindow == NULL)
return false;
}
else
{
switch (flags & (ImGuiHoveredFlags_RootWindow | ImGuiHoveredFlags_ChildWindows))
{
case ImGuiHoveredFlags_RootWindow | ImGuiHoveredFlags_ChildWindows:
if (g.HoveredWindow == NULL || g.HoveredWindow->RootWindowDockStop != g.CurrentWindow->RootWindowDockStop)
return false;
break;
case ImGuiHoveredFlags_RootWindow:
if (g.HoveredWindow != g.CurrentWindow->RootWindowDockStop)
return false;
break;
case ImGuiHoveredFlags_ChildWindows:
if (g.HoveredWindow == NULL || !IsWindowChildOf(g.HoveredWindow, g.CurrentWindow))
return false;
break;
default:
if (g.HoveredWindow != g.CurrentWindow)
return false;
break;
}
}
if (!IsWindowContentHoverable(g.HoveredWindow, flags))
return false;
if (!(flags & ImGuiHoveredFlags_AllowWhenBlockedByActiveItem))
if (g.ActiveId != 0 && !g.ActiveIdAllowOverlap && g.ActiveId != g.HoveredWindow->MoveId)
return false;
return true;
}
bool ImGui::IsWindowFocused(ImGuiFocusedFlags flags)
{
ImGuiContext& g = *GImGui;
if (flags & ImGuiFocusedFlags_AnyWindow)
return g.NavWindow != NULL;
IM_ASSERT(g.CurrentWindow); // Not inside a Begin()/End()
switch (flags & (ImGuiFocusedFlags_RootWindow | ImGuiFocusedFlags_ChildWindows))
{
case ImGuiFocusedFlags_RootWindow | ImGuiFocusedFlags_ChildWindows:
return g.NavWindow && g.NavWindow->RootWindowDockStop == g.CurrentWindow->RootWindowDockStop;
case ImGuiFocusedFlags_RootWindow:
return g.NavWindow == g.CurrentWindow->RootWindowDockStop;
case ImGuiFocusedFlags_ChildWindows:
return g.NavWindow && IsWindowChildOf(g.NavWindow, g.CurrentWindow);
default:
return g.NavWindow == g.CurrentWindow;
}
}
ImGuiID ImGui::GetWindowDockID()
{
ImGuiContext& g = *GImGui;
return g.CurrentWindow->DockId;
}
bool ImGui::IsWindowDocked()
{
ImGuiContext& g = *GImGui;
return g.CurrentWindow->DockIsActive;
}
// Can we focus this window with CTRL+TAB (or PadMenu + PadFocusPrev/PadFocusNext)
// Note that NoNavFocus makes the window not reachable with CTRL+TAB but it can still be focused with mouse or programmaticaly.
// If you want a window to never be focused, you may use the e.g. NoInputs flag.
bool ImGui::IsWindowNavFocusable(ImGuiWindow* window)
{
return window->Active && window == window->RootWindowDockStop && !(window->Flags & ImGuiWindowFlags_NoNavFocus);
}
float ImGui::GetWindowWidth()
{
ImGuiWindow* window = GImGui->CurrentWindow;
return window->Size.x;
}
float ImGui::GetWindowHeight()
{
ImGuiWindow* window = GImGui->CurrentWindow;
return window->Size.y;
}
ImVec2 ImGui::GetWindowPos()
{
ImGuiContext& g = *GImGui;
ImGuiWindow* window = g.CurrentWindow;
return window->Pos;
}
void ImGui::SetWindowPos(ImGuiWindow* window, const ImVec2& pos, ImGuiCond cond)
{
// Test condition (NB: bit 0 is always true) and clear flags for next time
if (cond && (window->SetWindowPosAllowFlags & cond) == 0)
return;
IM_ASSERT(cond == 0 || ImIsPowerOfTwo(cond)); // Make sure the user doesn't attempt to combine multiple condition flags.
window->SetWindowPosAllowFlags &= ~(ImGuiCond_Once | ImGuiCond_FirstUseEver | ImGuiCond_Appearing);
window->SetWindowPosVal = ImVec2(FLT_MAX, FLT_MAX);
// Set
const ImVec2 old_pos = window->Pos;
window->Pos = ImFloor(pos);
ImVec2 offset = window->Pos - old_pos;
window->DC.CursorPos += offset; // As we happen to move the window while it is being appended to (which is a bad idea - will smear) let's at least offset the cursor
window->DC.CursorMaxPos += offset; // And more importantly we need to offset CursorMaxPos/CursorStartPos this so ContentSize calculation doesn't get affected.
window->DC.CursorStartPos += offset;
}
void ImGui::SetWindowPos(const ImVec2& pos, ImGuiCond cond)
{
ImGuiWindow* window = GetCurrentWindowRead();
SetWindowPos(window, pos, cond);
}
void ImGui::SetWindowPos(const char* name, const ImVec2& pos, ImGuiCond cond)
{
if (ImGuiWindow* window = FindWindowByName(name))
SetWindowPos(window, pos, cond);
}
ImVec2 ImGui::GetWindowSize()
{
ImGuiWindow* window = GetCurrentWindowRead();
return window->Size;
}
void ImGui::SetWindowSize(ImGuiWindow* window, const ImVec2& size, ImGuiCond cond)
{
// Test condition (NB: bit 0 is always true) and clear flags for next time
if (cond && (window->SetWindowSizeAllowFlags & cond) == 0)
return;
IM_ASSERT(cond == 0 || ImIsPowerOfTwo(cond)); // Make sure the user doesn't attempt to combine multiple condition flags.
window->SetWindowSizeAllowFlags &= ~(ImGuiCond_Once | ImGuiCond_FirstUseEver | ImGuiCond_Appearing);
// Set
if (size.x > 0.0f)
{
window->AutoFitFramesX = 0;
window->SizeFull.x = ImFloor(size.x);
}
else
{
window->AutoFitFramesX = 2;
window->AutoFitOnlyGrows = false;
}
if (size.y > 0.0f)
{
window->AutoFitFramesY = 0;
window->SizeFull.y = ImFloor(size.y);
}
else
{
window->AutoFitFramesY = 2;
window->AutoFitOnlyGrows = false;
}
}
void ImGui::SetWindowSize(const ImVec2& size, ImGuiCond cond)
{
SetWindowSize(GImGui->CurrentWindow, size, cond);
}
void ImGui::SetWindowSize(const char* name, const ImVec2& size, ImGuiCond cond)
{
if (ImGuiWindow* window = FindWindowByName(name))
SetWindowSize(window, size, cond);
}
void ImGui::SetWindowCollapsed(ImGuiWindow* window, bool collapsed, ImGuiCond cond)
{
// Test condition (NB: bit 0 is always true) and clear flags for next time
if (cond && (window->SetWindowCollapsedAllowFlags & cond) == 0)
return;
window->SetWindowCollapsedAllowFlags &= ~(ImGuiCond_Once | ImGuiCond_FirstUseEver | ImGuiCond_Appearing);
// Set
window->Collapsed = collapsed;
}
static void SetWindowHitTestHole(ImGuiWindow* window, const ImVec2& pos, const ImVec2& size)
{
IM_ASSERT(window->HitTestHoleSize.x == 0); // We don't support multiple holes/hit test filters
window->HitTestHoleSize = ImVec2ih(size);
window->HitTestHoleOffset = ImVec2ih(pos - window->Pos);
}
void ImGui::SetWindowCollapsed(bool collapsed, ImGuiCond cond)
{
SetWindowCollapsed(GImGui->CurrentWindow, collapsed, cond);
}
bool ImGui::IsWindowCollapsed()
{
ImGuiWindow* window = GetCurrentWindowRead();
return window->Collapsed;
}
bool ImGui::IsWindowAppearing()
{
ImGuiWindow* window = GetCurrentWindowRead();
return window->Appearing;
}
void ImGui::SetWindowCollapsed(const char* name, bool collapsed, ImGuiCond cond)
{
if (ImGuiWindow* window = FindWindowByName(name))
SetWindowCollapsed(window, collapsed, cond);
}
void ImGui::SetWindowFocus()
{
FocusWindow(GImGui->CurrentWindow);
}
void ImGui::SetWindowFocus(const char* name)
{
if (name)
{
if (ImGuiWindow* window = FindWindowByName(name))
FocusWindow(window);
}
else
{
FocusWindow(NULL);
}
}
void ImGui::SetNextWindowPos(const ImVec2& pos, ImGuiCond cond, const ImVec2& pivot)
{
ImGuiContext& g = *GImGui;
IM_ASSERT(cond == 0 || ImIsPowerOfTwo(cond)); // Make sure the user doesn't attempt to combine multiple condition flags.
g.NextWindowData.Flags |= ImGuiNextWindowDataFlags_HasPos;
g.NextWindowData.PosVal = pos;
g.NextWindowData.PosPivotVal = pivot;
g.NextWindowData.PosCond = cond ? cond : ImGuiCond_Always;
g.NextWindowData.PosUndock = true;
}
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
void ImGui::SetNextWindowPosCenter(ImGuiCond cond)
{
ImGuiViewport* viewport = ImGui::GetMainViewport();
SetNextWindowPos(viewport->Pos + viewport->Size * 0.5f, cond, ImVec2(0.5f, 0.5f));
SetNextWindowViewport(viewport->ID);
}
#endif
void ImGui::SetNextWindowSize(const ImVec2& size, ImGuiCond cond)
{
ImGuiContext& g = *GImGui;
IM_ASSERT(cond == 0 || ImIsPowerOfTwo(cond)); // Make sure the user doesn't attempt to combine multiple condition flags.
g.NextWindowData.Flags |= ImGuiNextWindowDataFlags_HasSize;
g.NextWindowData.SizeVal = size;
g.NextWindowData.SizeCond = cond ? cond : ImGuiCond_Always;
}
void ImGui::SetNextWindowSizeConstraints(const ImVec2& size_min, const ImVec2& size_max, ImGuiSizeCallback custom_callback, void* custom_callback_user_data)
{
ImGuiContext& g = *GImGui;
g.NextWindowData.Flags |= ImGuiNextWindowDataFlags_HasSizeConstraint;
g.NextWindowData.SizeConstraintRect = ImRect(size_min, size_max);
g.NextWindowData.SizeCallback = custom_callback;
g.NextWindowData.SizeCallbackUserData = custom_callback_user_data;
}
// Content size = inner scrollable rectangle, padded with WindowPadding.
// SetNextWindowContentSize(ImVec2(100,100) + ImGuiWindowFlags_AlwaysAutoResize will always allow submitting a 100x100 item.
void ImGui::SetNextWindowContentSize(const ImVec2& size)
{
ImGuiContext& g = *GImGui;
g.NextWindowData.Flags |= ImGuiNextWindowDataFlags_HasContentSize;
g.NextWindowData.ContentSizeVal = size;
}
void ImGui::SetNextWindowCollapsed(bool collapsed, ImGuiCond cond)
{
ImGuiContext& g = *GImGui;
IM_ASSERT(cond == 0 || ImIsPowerOfTwo(cond)); // Make sure the user doesn't attempt to combine multiple condition flags.
g.NextWindowData.Flags |= ImGuiNextWindowDataFlags_HasCollapsed;
g.NextWindowData.CollapsedVal = collapsed;
g.NextWindowData.CollapsedCond = cond ? cond : ImGuiCond_Always;
}
void ImGui::SetNextWindowFocus()
{
ImGuiContext& g = *GImGui;
g.NextWindowData.Flags |= ImGuiNextWindowDataFlags_HasFocus;
}
void ImGui::SetNextWindowBgAlpha(float alpha)
{
ImGuiContext& g = *GImGui;
g.NextWindowData.Flags |= ImGuiNextWindowDataFlags_HasBgAlpha;
g.NextWindowData.BgAlphaVal = alpha;
}
void ImGui::SetNextWindowViewport(ImGuiID id)
{
ImGuiContext& g = *GImGui;
g.NextWindowData.Flags |= ImGuiNextWindowDataFlags_HasViewport;
g.NextWindowData.ViewportId = id;
}
void ImGui::SetNextWindowDockID(ImGuiID id, ImGuiCond cond)
{
ImGuiContext& g = *GImGui;
g.NextWindowData.Flags |= ImGuiNextWindowDataFlags_HasDock;
g.NextWindowData.DockCond = cond ? cond : ImGuiCond_Always;
g.NextWindowData.DockId = id;
}
void ImGui::SetNextWindowClass(const ImGuiWindowClass* window_class)
{
ImGuiContext& g = *GImGui;
IM_ASSERT((window_class->ViewportFlagsOverrideSet & window_class->ViewportFlagsOverrideClear) == 0); // Cannot set both set and clear for the same bit
g.NextWindowData.Flags |= ImGuiNextWindowDataFlags_HasWindowClass;
g.NextWindowData.WindowClass = *window_class;
}
// FIXME: This is in window space (not screen space!). We should try to obsolete all those functions.
ImVec2 ImGui::GetContentRegionMax()
{
ImGuiContext& g = *GImGui;
ImGuiWindow* window = g.CurrentWindow;
ImVec2 mx = window->ContentsRegionRect.Max - window->Pos;
if (window->DC.CurrentColumns)
mx.x = window->WorkRect.Max.x - window->Pos.x;
return mx;
}
// [Internal] Absolute coordinate. Saner. This is not exposed until we finishing refactoring work rect features.
ImVec2 ImGui::GetContentRegionMaxAbs()
{
ImGuiContext& g = *GImGui;
ImGuiWindow* window = g.CurrentWindow;
ImVec2 mx = window->ContentsRegionRect.Max;
if (window->DC.CurrentColumns)
mx.x = window->WorkRect.Max.x;
return mx;
}
ImVec2 ImGui::GetContentRegionAvail()
{
ImGuiWindow* window = GImGui->CurrentWindow;
return GetContentRegionMaxAbs() - window->DC.CursorPos;
}
// In window space (not screen space!)
ImVec2 ImGui::GetWindowContentRegionMin()
{
ImGuiWindow* window = GImGui->CurrentWindow;
return window->ContentsRegionRect.Min - window->Pos;
}
ImVec2 ImGui::GetWindowContentRegionMax()
{
ImGuiWindow* window = GImGui->CurrentWindow;
return window->ContentsRegionRect.Max - window->Pos;
}
float ImGui::GetWindowContentRegionWidth()
{
ImGuiWindow* window = GImGui->CurrentWindow;
return window->ContentsRegionRect.GetWidth();
}
float ImGui::GetTextLineHeight()
{
ImGuiContext& g = *GImGui;
return g.FontSize;
}
float ImGui::GetTextLineHeightWithSpacing()
{
ImGuiContext& g = *GImGui;
return g.FontSize + g.Style.ItemSpacing.y;
}
float ImGui::GetFrameHeight()
{
ImGuiContext& g = *GImGui;
return g.FontSize + g.Style.FramePadding.y * 2.0f;
}
float ImGui::GetFrameHeightWithSpacing()
{
ImGuiContext& g = *GImGui;
return g.FontSize + g.Style.FramePadding.y * 2.0f + g.Style.ItemSpacing.y;
}
ImDrawList* ImGui::GetWindowDrawList()
{
ImGuiWindow* window = GetCurrentWindow();
return window->DrawList;
}
float ImGui::GetWindowDpiScale()
{
ImGuiContext& g = *GImGui;
IM_ASSERT(g.CurrentViewport != NULL);
return g.CurrentViewport->DpiScale;
}
ImGuiViewport* ImGui::GetWindowViewport()
{
ImGuiContext& g = *GImGui;
IM_ASSERT(g.CurrentViewport != NULL && g.CurrentViewport == g.CurrentWindow->Viewport);
return g.CurrentViewport;
}
ImFont* ImGui::GetFont()
{
return GImGui->Font;
}
float ImGui::GetFontSize()
{
return GImGui->FontSize;
}
ImVec2 ImGui::GetFontTexUvWhitePixel()
{
return GImGui->DrawListSharedData.TexUvWhitePixel;
}
void ImGui::SetWindowFontScale(float scale)
{
ImGuiContext& g = *GImGui;
ImGuiWindow* window = GetCurrentWindow();
window->FontWindowScale = scale;
g.FontSize = g.DrawListSharedData.FontSize = window->CalcFontSize();
}
// User generally sees positions in window coordinates. Internally we store CursorPos in absolute screen coordinates because it is more convenient.
// Conversion happens as we pass the value to user, but it makes our naming convention confusing because GetCursorPos() == (DC.CursorPos - window.Pos). May want to rename 'DC.CursorPos'.
ImVec2 ImGui::GetCursorPos()
{
ImGuiWindow* window = GetCurrentWindowRead();
return window->DC.CursorPos - window->Pos + window->Scroll;
}
float ImGui::GetCursorPosX()
{
ImGuiWindow* window = GetCurrentWindowRead();
return window->DC.CursorPos.x - window->Pos.x + window->Scroll.x;
}
float ImGui::GetCursorPosY()
{
ImGuiWindow* window = GetCurrentWindowRead();
return window->DC.CursorPos.y - window->Pos.y + window->Scroll.y;
}
void ImGui::SetCursorPos(const ImVec2& local_pos)
{
ImGuiWindow* window = GetCurrentWindow();
window->DC.CursorPos = window->Pos - window->Scroll + local_pos;
window->DC.CursorMaxPos = ImMax(window->DC.CursorMaxPos, window->DC.CursorPos);
}
void ImGui::SetCursorPosX(float x)
{
ImGuiWindow* window = GetCurrentWindow();
window->DC.CursorPos.x = window->Pos.x - window->Scroll.x + x;
window->DC.CursorMaxPos.x = ImMax(window->DC.CursorMaxPos.x, window->DC.CursorPos.x);
}
void ImGui::SetCursorPosY(float y)
{
ImGuiWindow* window = GetCurrentWindow();
window->DC.CursorPos.y = window->Pos.y - window->Scroll.y + y;
window->DC.CursorMaxPos.y = ImMax(window->DC.CursorMaxPos.y, window->DC.CursorPos.y);
}
ImVec2 ImGui::GetCursorStartPos()
{
ImGuiWindow* window = GetCurrentWindowRead();
return window->DC.CursorStartPos - window->Pos;
}
ImVec2 ImGui::GetCursorScreenPos()
{
ImGuiWindow* window = GetCurrentWindowRead();
return window->DC.CursorPos;
}
void ImGui::SetCursorScreenPos(const ImVec2& pos)
{
ImGuiWindow* window = GetCurrentWindow();
window->DC.CursorPos = pos;
window->DC.CursorMaxPos = ImMax(window->DC.CursorMaxPos, window->DC.CursorPos);
}
void ImGui::ActivateItem(ImGuiID id)
{
ImGuiContext& g = *GImGui;
g.NavNextActivateId = id;
}
void ImGui::SetKeyboardFocusHere(int offset)
{
IM_ASSERT(offset >= -1); // -1 is allowed but not below
ImGuiContext& g = *GImGui;
ImGuiWindow* window = g.CurrentWindow;
g.FocusRequestNextWindow = window;
g.FocusRequestNextCounterAll = window->DC.FocusCounterAll + 1 + offset;
g.FocusRequestNextCounterTab = INT_MAX;
}
void ImGui::SetItemDefaultFocus()
{
ImGuiContext& g = *GImGui;
ImGuiWindow* window = g.CurrentWindow;
if (!window->Appearing)
return;
if (g.NavWindow == window->RootWindowForNav && (g.NavInitRequest || g.NavInitResultId != 0) && g.NavLayer == g.NavWindow->DC.NavLayerCurrent)
{
g.NavInitRequest = false;
g.NavInitResultId = g.NavWindow->DC.LastItemId;
g.NavInitResultRectRel = ImRect(g.NavWindow->DC.LastItemRect.Min - g.NavWindow->Pos, g.NavWindow->DC.LastItemRect.Max - g.NavWindow->Pos);
NavUpdateAnyRequestFlag();
if (!IsItemVisible())
SetScrollHereY();
}
}
void ImGui::SetStateStorage(ImGuiStorage* tree)
{
ImGuiWindow* window = GImGui->CurrentWindow;
window->DC.StateStorage = tree ? tree : &window->StateStorage;
}
ImGuiStorage* ImGui::GetStateStorage()
{
ImGuiWindow* window = GImGui->CurrentWindow;
return window->DC.StateStorage;
}
void ImGui::PushID(const char* str_id)
{
ImGuiWindow* window = GImGui->CurrentWindow;
window->IDStack.push_back(window->GetIDNoKeepAlive(str_id));
}
void ImGui::PushID(const char* str_id_begin, const char* str_id_end)
{
ImGuiWindow* window = GImGui->CurrentWindow;
window->IDStack.push_back(window->GetIDNoKeepAlive(str_id_begin, str_id_end));
}
void ImGui::PushID(const void* ptr_id)
{
ImGuiWindow* window = GImGui->CurrentWindow;
window->IDStack.push_back(window->GetIDNoKeepAlive(ptr_id));
}
void ImGui::PushID(int int_id)
{
ImGuiWindow* window = GImGui->CurrentWindow;
window->IDStack.push_back(window->GetIDNoKeepAlive(int_id));
}
// Push a given id value ignoring the ID stack as a seed.
void ImGui::PushOverrideID(ImGuiID id)
{
ImGuiWindow* window = GImGui->CurrentWindow;
window->IDStack.push_back(id);
}
void ImGui::PopID()
{
ImGuiWindow* window = GImGui->CurrentWindow;
window->IDStack.pop_back();
}
ImGuiID ImGui::GetID(const char* str_id)
{
ImGuiWindow* window = GImGui->CurrentWindow;
return window->GetID(str_id);
}
ImGuiID ImGui::GetID(const char* str_id_begin, const char* str_id_end)
{
ImGuiWindow* window = GImGui->CurrentWindow;
return window->GetID(str_id_begin, str_id_end);
}
ImGuiID ImGui::GetID(const void* ptr_id)
{
ImGuiWindow* window = GImGui->CurrentWindow;
return window->GetID(ptr_id);
}
bool ImGui::IsRectVisible(const ImVec2& size)
{
ImGuiWindow* window = GImGui->CurrentWindow;
return window->ClipRect.Overlaps(ImRect(window->DC.CursorPos, window->DC.CursorPos + size));
}
bool ImGui::IsRectVisible(const ImVec2& rect_min, const ImVec2& rect_max)
{
ImGuiWindow* window = GImGui->CurrentWindow;
return window->ClipRect.Overlaps(ImRect(rect_min, rect_max));
}
// Lock horizontal starting position + capture group bounding box into one "item" (so you can use IsItemHovered() or layout primitives such as SameLine() on whole group, etc.)
void ImGui::BeginGroup()
{
ImGuiContext& g = *GImGui;
ImGuiWindow* window = GetCurrentWindow();
window->DC.GroupStack.resize(window->DC.GroupStack.Size + 1);
ImGuiGroupData& group_data = window->DC.GroupStack.back();
group_data.BackupCursorPos = window->DC.CursorPos;
group_data.BackupCursorMaxPos = window->DC.CursorMaxPos;
group_data.BackupIndent = window->DC.Indent;
group_data.BackupGroupOffset = window->DC.GroupOffset;
group_data.BackupCurrLineSize = window->DC.CurrLineSize;
group_data.BackupCurrLineTextBaseOffset = window->DC.CurrLineTextBaseOffset;
group_data.BackupActiveIdIsAlive = g.ActiveIdIsAlive;
group_data.BackupActiveIdPreviousFrameIsAlive = g.ActiveIdPreviousFrameIsAlive;
group_data.EmitItem = true;
window->DC.GroupOffset.x = window->DC.CursorPos.x - window->Pos.x - window->DC.ColumnsOffset.x;
window->DC.Indent = window->DC.GroupOffset;
window->DC.CursorMaxPos = window->DC.CursorPos;
window->DC.CurrLineSize = ImVec2(0.0f, 0.0f);
if (g.LogEnabled)
g.LogLinePosY = -FLT_MAX; // To enforce Log carriage return
}
void ImGui::EndGroup()
{
ImGuiContext& g = *GImGui;
ImGuiWindow* window = GetCurrentWindow();
IM_ASSERT(!window->DC.GroupStack.empty()); // Mismatched BeginGroup()/EndGroup() calls
ImGuiGroupData& group_data = window->DC.GroupStack.back();
ImRect group_bb(group_data.BackupCursorPos, ImMax(window->DC.CursorMaxPos, group_data.BackupCursorPos));
window->DC.CursorPos = group_data.BackupCursorPos;
window->DC.CursorMaxPos = ImMax(group_data.BackupCursorMaxPos, window->DC.CursorMaxPos);
window->DC.Indent = group_data.BackupIndent;
window->DC.GroupOffset = group_data.BackupGroupOffset;
window->DC.CurrLineSize = group_data.BackupCurrLineSize;
window->DC.CurrLineTextBaseOffset = group_data.BackupCurrLineTextBaseOffset;
if (g.LogEnabled)
g.LogLinePosY = -FLT_MAX; // To enforce Log carriage return
if (!group_data.EmitItem)
{
window->DC.GroupStack.pop_back();
return;
}
window->DC.CurrLineTextBaseOffset = ImMax(window->DC.PrevLineTextBaseOffset, group_data.BackupCurrLineTextBaseOffset); // FIXME: Incorrect, we should grab the base offset from the *first line* of the group but it is hard to obtain now.
ItemSize(group_bb.GetSize(), 0.0f);
ItemAdd(group_bb, 0);
// If the current ActiveId was declared within the boundary of our group, we copy it to LastItemId so IsItemActive(), IsItemDeactivated() etc. will be functional on the entire group.
// It would be be neater if we replaced window.DC.LastItemId by e.g. 'bool LastItemIsActive', but would put a little more burden on individual widgets.
// Also if you grep for LastItemId you'll notice it is only used in that context.
// (The tests not symmetrical because ActiveIdIsAlive is an ID itself, in order to be able to handle ActiveId being overwritten during the frame.)
const bool group_contains_curr_active_id = (group_data.BackupActiveIdIsAlive != g.ActiveId) && (g.ActiveIdIsAlive == g.ActiveId) && g.ActiveId;
const bool group_contains_prev_active_id = !group_data.BackupActiveIdPreviousFrameIsAlive && g.ActiveIdPreviousFrameIsAlive;
if (group_contains_curr_active_id)
window->DC.LastItemId = g.ActiveId;
else if (group_contains_prev_active_id)
window->DC.LastItemId = g.ActiveIdPreviousFrame;
window->DC.LastItemRect = group_bb;
// Forward Edited flag
if (group_contains_curr_active_id && g.ActiveIdHasBeenEditedThisFrame)
window->DC.LastItemStatusFlags |= ImGuiItemStatusFlags_Edited;
// Forward Deactivated flag
window->DC.LastItemStatusFlags |= ImGuiItemStatusFlags_HasDeactivated;
if (group_contains_prev_active_id && g.ActiveId != g.ActiveIdPreviousFrame)
window->DC.LastItemStatusFlags |= ImGuiItemStatusFlags_Deactivated;
window->DC.GroupStack.pop_back();
//window->DrawList->AddRect(group_bb.Min, group_bb.Max, IM_COL32(255,0,255,255)); // [Debug]
}
// Gets back to previous line and continue with horizontal layout
// offset_from_start_x == 0 : follow right after previous item
// offset_from_start_x != 0 : align to specified x position (relative to window/group left)
// spacing_w < 0 : use default spacing if pos_x == 0, no spacing if pos_x != 0
// spacing_w >= 0 : enforce spacing amount
void ImGui::SameLine(float offset_from_start_x, float spacing_w)
{
ImGuiWindow* window = GetCurrentWindow();
if (window->SkipItems)
return;
ImGuiContext& g = *GImGui;
if (offset_from_start_x != 0.0f)
{
if (spacing_w < 0.0f) spacing_w = 0.0f;
window->DC.CursorPos.x = window->Pos.x - window->Scroll.x + offset_from_start_x + spacing_w + window->DC.GroupOffset.x + window->DC.ColumnsOffset.x;
window->DC.CursorPos.y = window->DC.CursorPosPrevLine.y;
}
else
{
if (spacing_w < 0.0f) spacing_w = g.Style.ItemSpacing.x;
window->DC.CursorPos.x = window->DC.CursorPosPrevLine.x + spacing_w;
window->DC.CursorPos.y = window->DC.CursorPosPrevLine.y;
}
window->DC.CurrLineSize = window->DC.PrevLineSize;
window->DC.CurrLineTextBaseOffset = window->DC.PrevLineTextBaseOffset;
}
void ImGui::Indent(float indent_w)
{
ImGuiContext& g = *GImGui;
ImGuiWindow* window = GetCurrentWindow();
window->DC.Indent.x += (indent_w != 0.0f) ? indent_w : g.Style.IndentSpacing;
window->DC.CursorPos.x = window->Pos.x + window->DC.Indent.x + window->DC.ColumnsOffset.x;
}
void ImGui::Unindent(float indent_w)
{
ImGuiContext& g = *GImGui;
ImGuiWindow* window = GetCurrentWindow();
window->DC.Indent.x -= (indent_w != 0.0f) ? indent_w : g.Style.IndentSpacing;
window->DC.CursorPos.x = window->Pos.x + window->DC.Indent.x + window->DC.ColumnsOffset.x;
}
//-----------------------------------------------------------------------------
// [SECTION] SCROLLING
//-----------------------------------------------------------------------------
static ImVec2 CalcNextScrollFromScrollTargetAndClamp(ImGuiWindow* window, bool snap_on_edges)
{
ImGuiContext& g = *GImGui;
ImVec2 scroll = window->Scroll;
if (window->ScrollTarget.x < FLT_MAX)
{
float cr_x = window->ScrollTargetCenterRatio.x;
float target_x = window->ScrollTarget.x;
if (snap_on_edges && cr_x <= 0.0f && target_x <= window->WindowPadding.x)
target_x = 0.0f;
else if (snap_on_edges && cr_x >= 1.0f && target_x >= window->ContentSize.x + window->WindowPadding.x + g.Style.ItemSpacing.x)
target_x = window->ContentSize.x + window->WindowPadding.x * 2.0f;
scroll.x = target_x - cr_x * (window->SizeFull.x - window->ScrollbarSizes.x);
}
if (window->ScrollTarget.y < FLT_MAX)
{
// 'snap_on_edges' allows for a discontinuity at the edge of scrolling limits to take account of WindowPadding so that scrolling to make the last item visible scroll far enough to see the padding.
float decoration_up_height = window->TitleBarHeight() + window->MenuBarHeight();
float cr_y = window->ScrollTargetCenterRatio.y;
float target_y = window->ScrollTarget.y;
if (snap_on_edges && cr_y <= 0.0f && target_y <= window->WindowPadding.y)
target_y = 0.0f;
if (snap_on_edges && cr_y >= 1.0f && target_y >= window->ContentSize.y + window->WindowPadding.y + g.Style.ItemSpacing.y)
target_y = window->ContentSize.y + window->WindowPadding.y * 2.0f;
scroll.y = target_y - cr_y * (window->SizeFull.y - window->ScrollbarSizes.y - decoration_up_height);
}
scroll = ImMax(scroll, ImVec2(0.0f, 0.0f));
if (!window->Collapsed && !window->SkipItems)
{
scroll.x = ImMin(scroll.x, window->ScrollMax.x);
scroll.y = ImMin(scroll.y, window->ScrollMax.y);
}
return scroll;
}
// Scroll to keep newly navigated item fully into view
ImVec2 ImGui::ScrollToBringRectIntoView(ImGuiWindow* window, const ImRect& item_rect)
{
ImGuiContext& g = *GImGui;
ImRect window_rect(window->InnerRect.Min - ImVec2(1, 1), window->InnerRect.Max + ImVec2(1, 1));
//GetForegroundDrawList(window)->AddRect(window_rect.Min, window_rect.Max, IM_COL32_WHITE); // [DEBUG]
ImVec2 delta_scroll;
if (!window_rect.Contains(item_rect))
{
if (window->ScrollbarX && item_rect.Min.x < window_rect.Min.x)
SetScrollFromPosX(window, item_rect.Min.x - window->Pos.x + g.Style.ItemSpacing.x, 0.0f);
else if (window->ScrollbarX && item_rect.Max.x >= window_rect.Max.x)
SetScrollFromPosX(window, item_rect.Max.x - window->Pos.x + g.Style.ItemSpacing.x, 1.0f);
if (item_rect.Min.y < window_rect.Min.y)
SetScrollFromPosY(window, item_rect.Min.y - window->Pos.y - g.Style.ItemSpacing.y, 0.0f);
else if (item_rect.Max.y >= window_rect.Max.y)
SetScrollFromPosY(window, item_rect.Max.y - window->Pos.y + g.Style.ItemSpacing.y, 1.0f);
ImVec2 next_scroll = CalcNextScrollFromScrollTargetAndClamp(window, false);
delta_scroll = next_scroll - window->Scroll;
}
// Also scroll parent window to keep us into view if necessary
if (window->Flags & ImGuiWindowFlags_ChildWindow)
delta_scroll += ScrollToBringRectIntoView(window->ParentWindow, ImRect(item_rect.Min - delta_scroll, item_rect.Max - delta_scroll));
return delta_scroll;
}
float ImGui::GetScrollX()
{
ImGuiWindow* window = GImGui->CurrentWindow;
return window->Scroll.x;
}
float ImGui::GetScrollY()
{
ImGuiWindow* window = GImGui->CurrentWindow;
return window->Scroll.y;
}
float ImGui::GetScrollMaxX()
{
ImGuiWindow* window = GImGui->CurrentWindow;
return window->ScrollMax.x;
}
float ImGui::GetScrollMaxY()
{
ImGuiWindow* window = GImGui->CurrentWindow;
return window->ScrollMax.y;
}
void ImGui::SetScrollX(float scroll_x)
{
ImGuiWindow* window = GetCurrentWindow();
window->ScrollTarget.x = scroll_x;
window->ScrollTargetCenterRatio.x = 0.0f;
}
void ImGui::SetScrollY(float scroll_y)
{
ImGuiWindow* window = GetCurrentWindow();
window->ScrollTarget.y = scroll_y;
window->ScrollTargetCenterRatio.y = 0.0f;
}
void ImGui::SetScrollX(ImGuiWindow* window, float new_scroll_x)
{
window->ScrollTarget.x = new_scroll_x;
window->ScrollTargetCenterRatio.x = 0.0f;
}
void ImGui::SetScrollY(ImGuiWindow* window, float new_scroll_y)
{
window->ScrollTarget.y = new_scroll_y;
window->ScrollTargetCenterRatio.y = 0.0f;
}
void ImGui::SetScrollFromPosX(ImGuiWindow* window, float local_x, float center_x_ratio)
{
// We store a target position so centering can occur on the next frame when we are guaranteed to have a known window size
IM_ASSERT(center_x_ratio >= 0.0f && center_x_ratio <= 1.0f);
window->ScrollTarget.x = (float)(int)(local_x + window->Scroll.x);
window->ScrollTargetCenterRatio.x = center_x_ratio;
}
void ImGui::SetScrollFromPosY(ImGuiWindow* window, float local_y, float center_y_ratio)
{
// We store a target position so centering can occur on the next frame when we are guaranteed to have a known window size
IM_ASSERT(center_y_ratio >= 0.0f && center_y_ratio <= 1.0f);
const float decoration_up_height = window->TitleBarHeight() + window->MenuBarHeight();
local_y -= decoration_up_height;
window->ScrollTarget.y = (float)(int)(local_y + window->Scroll.y);
window->ScrollTargetCenterRatio.y = center_y_ratio;
}
void ImGui::SetScrollFromPosX(float local_x, float center_x_ratio)
{
ImGuiContext& g = *GImGui;
SetScrollFromPosX(g.CurrentWindow, local_x, center_x_ratio);
}
void ImGui::SetScrollFromPosY(float local_y, float center_y_ratio)
{
ImGuiContext& g = *GImGui;
SetScrollFromPosY(g.CurrentWindow, local_y, center_y_ratio);
}
// center_x_ratio: 0.0f left of last item, 0.5f horizontal center of last item, 1.0f right of last item.
void ImGui::SetScrollHereX(float center_x_ratio)
{
ImGuiContext& g = *GImGui;
ImGuiWindow* window = g.CurrentWindow;
float target_x = window->DC.LastItemRect.Min.x - window->Pos.x; // Left of last item, in window space
float last_item_width = window->DC.LastItemRect.GetWidth();
target_x += (last_item_width * center_x_ratio) + (g.Style.ItemSpacing.x * (center_x_ratio - 0.5f) * 2.0f); // Precisely aim before, in the middle or after the last item.
SetScrollFromPosX(target_x, center_x_ratio);
}
// center_y_ratio: 0.0f top of last item, 0.5f vertical center of last item, 1.0f bottom of last item.
void ImGui::SetScrollHereY(float center_y_ratio)
{
ImGuiContext& g = *GImGui;
ImGuiWindow* window = g.CurrentWindow;
float target_y = window->DC.CursorPosPrevLine.y - window->Pos.y; // Top of last item, in window space
target_y += (window->DC.PrevLineSize.y * center_y_ratio) + (g.Style.ItemSpacing.y * (center_y_ratio - 0.5f) * 2.0f); // Precisely aim above, in the middle or below the last line.
SetScrollFromPosY(target_y, center_y_ratio);
}
//-----------------------------------------------------------------------------
// [SECTION] TOOLTIPS
//-----------------------------------------------------------------------------
void ImGui::BeginTooltip()
{
ImGuiContext& g = *GImGui;
if (g.DragDropWithinSourceOrTarget)
{
// The default tooltip position is a little offset to give space to see the context menu (it's also clamped within the current viewport/monitor)
// In the context of a dragging tooltip we try to reduce that offset and we enforce following the cursor.
// Whatever we do we want to call SetNextWindowPos() to enforce a tooltip position and disable clipping the tooltip without our display area, like regular tooltip do.
//ImVec2 tooltip_pos = g.IO.MousePos - g.ActiveIdClickOffset - g.Style.WindowPadding;
ImVec2 tooltip_pos = g.IO.MousePos + ImVec2(16 * g.Style.MouseCursorScale, 8 * g.Style.MouseCursorScale);
SetNextWindowPos(tooltip_pos);
SetNextWindowBgAlpha(g.Style.Colors[ImGuiCol_PopupBg].w * 0.60f);
//PushStyleVar(ImGuiStyleVar_Alpha, g.Style.Alpha * 0.60f); // This would be nice but e.g ColorButton with checkboard has issue with transparent colors :(
BeginTooltipEx(0, true);
}
else
{
BeginTooltipEx(0, false);
}
}
// Not exposed publicly as BeginTooltip() because bool parameters are evil. Let's see if other needs arise first.
void ImGui::BeginTooltipEx(ImGuiWindowFlags extra_flags, bool override_previous_tooltip)
{
ImGuiContext& g = *GImGui;
char window_name[16];
ImFormatString(window_name, IM_ARRAYSIZE(window_name), "##Tooltip_%02d", g.TooltipOverrideCount);
if (override_previous_tooltip)
if (ImGuiWindow* window = FindWindowByName(window_name))
if (window->Active)
{
// Hide previous tooltip from being displayed. We can't easily "reset" the content of a window so we create a new one.
window->Hidden = true;
window->HiddenFramesCanSkipItems = 1;
ImFormatString(window_name, IM_ARRAYSIZE(window_name), "##Tooltip_%02d", ++g.TooltipOverrideCount);
}
ImGuiWindowFlags flags = ImGuiWindowFlags_Tooltip|ImGuiWindowFlags_NoInputs|ImGuiWindowFlags_NoTitleBar|ImGuiWindowFlags_NoMove|ImGuiWindowFlags_NoResize|ImGuiWindowFlags_NoSavedSettings|ImGuiWindowFlags_AlwaysAutoResize|ImGuiWindowFlags_NoDocking;
Begin(window_name, NULL, flags | extra_flags);
}
void ImGui::EndTooltip()
{
IM_ASSERT(GetCurrentWindowRead()->Flags & ImGuiWindowFlags_Tooltip); // Mismatched BeginTooltip()/EndTooltip() calls
End();
}
void ImGui::SetTooltipV(const char* fmt, va_list args)
{
ImGuiContext& g = *GImGui;
if (g.DragDropWithinSourceOrTarget)
BeginTooltip();
else
BeginTooltipEx(0, true);
TextV(fmt, args);
EndTooltip();
}
void ImGui::SetTooltip(const char* fmt, ...)
{
va_list args;
va_start(args, fmt);
SetTooltipV(fmt, args);
va_end(args);
}
//-----------------------------------------------------------------------------
// [SECTION] POPUPS
//-----------------------------------------------------------------------------
bool ImGui::IsPopupOpen(ImGuiID id)
{
ImGuiContext& g = *GImGui;
return g.OpenPopupStack.Size > g.BeginPopupStack.Size && g.OpenPopupStack[g.BeginPopupStack.Size].PopupId == id;
}
bool ImGui::IsPopupOpen(const char* str_id)
{
ImGuiContext& g = *GImGui;
return g.OpenPopupStack.Size > g.BeginPopupStack.Size && g.OpenPopupStack[g.BeginPopupStack.Size].PopupId == g.CurrentWindow->GetID(str_id);
}
ImGuiWindow* ImGui::GetTopMostPopupModal()
{
ImGuiContext& g = *GImGui;
for (int n = g.OpenPopupStack.Size-1; n >= 0; n--)
if (ImGuiWindow* popup = g.OpenPopupStack.Data[n].Window)
if (popup->Flags & ImGuiWindowFlags_Modal)
return popup;
return NULL;
}
void ImGui::OpenPopup(const char* str_id)
{
ImGuiContext& g = *GImGui;
OpenPopupEx(g.CurrentWindow->GetID(str_id));
}
// Mark popup as open (toggle toward open state).
// Popups are closed when user click outside, or activate a pressable item, or CloseCurrentPopup() is called within a BeginPopup()/EndPopup() block.
// Popup identifiers are relative to the current ID-stack (so OpenPopup and BeginPopup needs to be at the same level).
// One open popup per level of the popup hierarchy (NB: when assigning we reset the Window member of ImGuiPopupRef to NULL)
void ImGui::OpenPopupEx(ImGuiID id)
{
ImGuiContext& g = *GImGui;
ImGuiWindow* parent_window = g.CurrentWindow;
int current_stack_size = g.BeginPopupStack.Size;
ImGuiPopupData popup_ref; // Tagged as new ref as Window will be set back to NULL if we write this into OpenPopupStack.
popup_ref.PopupId = id;
popup_ref.Window = NULL;
popup_ref.SourceWindow = g.NavWindow;
popup_ref.OpenFrameCount = g.FrameCount;
popup_ref.OpenParentId = parent_window->IDStack.back();
popup_ref.OpenPopupPos = NavCalcPreferredRefPos();
popup_ref.OpenMousePos = IsMousePosValid(&g.IO.MousePos) ? g.IO.MousePos : popup_ref.OpenPopupPos;
//IMGUI_DEBUG_LOG("OpenPopupEx(0x%08X)\n", g.FrameCount, id);
if (g.OpenPopupStack.Size < current_stack_size + 1)
{
g.OpenPopupStack.push_back(popup_ref);
}
else
{
// Gently handle the user mistakenly calling OpenPopup() every frame. It is a programming mistake! However, if we were to run the regular code path, the ui
// would become completely unusable because the popup will always be in hidden-while-calculating-size state _while_ claiming focus. Which would be a very confusing
// situation for the programmer. Instead, we silently allow the popup to proceed, it will keep reappearing and the programming error will be more obvious to understand.
if (g.OpenPopupStack[current_stack_size].PopupId == id && g.OpenPopupStack[current_stack_size].OpenFrameCount == g.FrameCount - 1)
{
g.OpenPopupStack[current_stack_size].OpenFrameCount = popup_ref.OpenFrameCount;
}
else
{
// Close child popups if any, then flag popup for open/reopen
g.OpenPopupStack.resize(current_stack_size + 1);
g.OpenPopupStack[current_stack_size] = popup_ref;
}
// When reopening a popup we first refocus its parent, otherwise if its parent is itself a popup it would get closed by ClosePopupsOverWindow().
// This is equivalent to what ClosePopupToLevel() does.
//if (g.OpenPopupStack[current_stack_size].PopupId == id)
// FocusWindow(parent_window);
}
}
bool ImGui::OpenPopupOnItemClick(const char* str_id, int mouse_button)
{
ImGuiWindow* window = GImGui->CurrentWindow;
if (IsMouseReleased(mouse_button) && IsItemHovered(ImGuiHoveredFlags_AllowWhenBlockedByPopup))
{
ImGuiID id = str_id ? window->GetID(str_id) : window->DC.LastItemId; // If user hasn't passed an ID, we can use the LastItemID. Using LastItemID as a Popup ID won't conflict!
IM_ASSERT(id != 0); // You cannot pass a NULL str_id if the last item has no identifier (e.g. a Text() item)
OpenPopupEx(id);
return true;
}
return false;
}
void ImGui::ClosePopupsOverWindow(ImGuiWindow* ref_window, bool restore_focus_to_window_under_popup)
{
ImGuiContext& g = *GImGui;
if (g.OpenPopupStack.empty())
return;
// When popups are stacked, clicking on a lower level popups puts focus back to it and close popups above it.
// Don't close our own child popup windows.
int popup_count_to_keep = 0;
if (ref_window)
{
// Find the highest popup which is a descendant of the reference window (generally reference window = NavWindow)
for (; popup_count_to_keep < g.OpenPopupStack.Size; popup_count_to_keep++)
{
ImGuiPopupData& popup = g.OpenPopupStack[popup_count_to_keep];
if (!popup.Window)
continue;
IM_ASSERT((popup.Window->Flags & ImGuiWindowFlags_Popup) != 0);
if (popup.Window->Flags & ImGuiWindowFlags_ChildWindow)
continue;
// Trim the stack when popups are not direct descendant of the reference window (the reference window is often the NavWindow)
bool popup_or_descendent_is_ref_window = false;
for (int m = popup_count_to_keep; m < g.OpenPopupStack.Size && !popup_or_descendent_is_ref_window; m++)
if (ImGuiWindow* popup_window = g.OpenPopupStack[m].Window)
if (popup_window->RootWindow == ref_window->RootWindow)
popup_or_descendent_is_ref_window = true;
if (!popup_or_descendent_is_ref_window)
break;
}
}
if (popup_count_to_keep < g.OpenPopupStack.Size) // This test is not required but it allows to set a convenient breakpoint on the statement below
{
//IMGUI_DEBUG_LOG("ClosePopupsOverWindow(%s) -> ClosePopupToLevel(%d)\n", ref_window->Name, popup_count_to_keep);
ClosePopupToLevel(popup_count_to_keep, restore_focus_to_window_under_popup);
}
}
void ImGui::ClosePopupToLevel(int remaining, bool restore_focus_to_window_under_popup)
{
ImGuiContext& g = *GImGui;
IM_ASSERT(remaining >= 0 && remaining < g.OpenPopupStack.Size);
ImGuiWindow* focus_window = g.OpenPopupStack[remaining].SourceWindow;
ImGuiWindow* popup_window = g.OpenPopupStack[remaining].Window;
g.OpenPopupStack.resize(remaining);
if (restore_focus_to_window_under_popup)
{
if (focus_window && !focus_window->WasActive && popup_window)
{
// Fallback
FocusTopMostWindowUnderOne(popup_window, NULL);
}
else
{
if (g.NavLayer == 0 && focus_window)
focus_window = NavRestoreLastChildNavWindow(focus_window);
FocusWindow(focus_window);
}
}
}
// Close the popup we have begin-ed into.
void ImGui::CloseCurrentPopup()
{
ImGuiContext& g = *GImGui;
int popup_idx = g.BeginPopupStack.Size - 1;
if (popup_idx < 0 || popup_idx >= g.OpenPopupStack.Size || g.BeginPopupStack[popup_idx].PopupId != g.OpenPopupStack[popup_idx].PopupId)
return;
// Closing a menu closes its top-most parent popup (unless a modal)
while (popup_idx > 0)
{
ImGuiWindow* popup_window = g.OpenPopupStack[popup_idx].Window;
ImGuiWindow* parent_popup_window = g.OpenPopupStack[popup_idx - 1].Window;
bool close_parent = false;
if (popup_window && (popup_window->Flags & ImGuiWindowFlags_ChildMenu))
if (parent_popup_window == NULL || !(parent_popup_window->Flags & ImGuiWindowFlags_Modal))
close_parent = true;
if (!close_parent)
break;
popup_idx--;
}
//IMGUI_DEBUG_LOG("CloseCurrentPopup %d -> %d\n", g.BeginPopupStack.Size - 1, popup_idx);
ClosePopupToLevel(popup_idx, true);
// A common pattern is to close a popup when selecting a menu item/selectable that will open another window.
// To improve this usage pattern, we avoid nav highlight for a single frame in the parent window.
// Similarly, we could avoid mouse hover highlight in this window but it is less visually problematic.
if (ImGuiWindow* window = g.NavWindow)
window->DC.NavHideHighlightOneFrame = true;
}
bool ImGui::BeginPopupEx(ImGuiID id, ImGuiWindowFlags extra_flags)
{
ImGuiContext& g = *GImGui;
if (!IsPopupOpen(id))
{
g.NextWindowData.ClearFlags(); // We behave like Begin() and need to consume those values
return false;
}
char name[20];
if (extra_flags & ImGuiWindowFlags_ChildMenu)
ImFormatString(name, IM_ARRAYSIZE(name), "##Menu_%02d", g.BeginPopupStack.Size); // Recycle windows based on depth
else
ImFormatString(name, IM_ARRAYSIZE(name), "##Popup_%08x", id); // Not recycling, so we can close/open during the same frame
bool is_open = Begin(name, NULL, extra_flags | ImGuiWindowFlags_Popup);
if (!is_open) // NB: Begin can return false when the popup is completely clipped (e.g. zero size display)
EndPopup();
return is_open;
}
bool ImGui::BeginPopup(const char* str_id, ImGuiWindowFlags flags)
{
ImGuiContext& g = *GImGui;
if (g.OpenPopupStack.Size <= g.BeginPopupStack.Size) // Early out for performance
{
g.NextWindowData.ClearFlags(); // We behave like Begin() and need to consume those values
return false;
}
flags |= ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoDocking;
return BeginPopupEx(g.CurrentWindow->GetID(str_id), flags);
}
// If 'p_open' is specified for a modal popup window, the popup will have a regular close button which will close the popup.
// Note that popup visibility status is owned by Dear ImGui (and manipulated with e.g. OpenPopup) so the actual value of *p_open is meaningless here.
bool ImGui::BeginPopupModal(const char* name, bool* p_open, ImGuiWindowFlags flags)
{
ImGuiContext& g = *GImGui;
ImGuiWindow* window = g.CurrentWindow;
const ImGuiID id = window->GetID(name);
if (!IsPopupOpen(id))
{
g.NextWindowData.ClearFlags(); // We behave like Begin() and need to consume those values
return false;
}
// Center modal windows by default
// FIXME: Should test for (PosCond & window->SetWindowPosAllowFlags) with the upcoming window.
if ((g.NextWindowData.Flags & ImGuiNextWindowDataFlags_HasPos) == 0)
{
ImGuiViewportP* viewport = window->WasActive ? window->Viewport : (ImGuiViewportP*)GetMainViewport(); // FIXME-VIEWPORT: What may be our reference viewport?
SetNextWindowPos(viewport->GetCenter(), ImGuiCond_Appearing, ImVec2(0.5f, 0.5f));
}
flags |= ImGuiWindowFlags_Popup | ImGuiWindowFlags_Modal | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoDocking;
const bool is_open = Begin(name, p_open, flags);
if (!is_open || (p_open && !*p_open)) // NB: is_open can be 'false' when the popup is completely clipped (e.g. zero size display)
{
EndPopup();
if (is_open)
ClosePopupToLevel(g.BeginPopupStack.Size, true);
return false;
}
return is_open;
}
void ImGui::EndPopup()
{
ImGuiContext& g = *GImGui;
IM_ASSERT(g.CurrentWindow->Flags & ImGuiWindowFlags_Popup); // Mismatched BeginPopup()/EndPopup() calls
IM_ASSERT(g.BeginPopupStack.Size > 0);
// Make all menus and popups wrap around for now, may need to expose that policy.
NavMoveRequestTryWrapping(g.CurrentWindow, ImGuiNavMoveFlags_LoopY);
End();
}
// This is a helper to handle the simplest case of associating one named popup to one given widget.
// You may want to handle this on user side if you have specific needs (e.g. tweaking IsItemHovered() parameters).
// You can pass a NULL str_id to use the identifier of the last item.
bool ImGui::BeginPopupContextItem(const char* str_id, int mouse_button)
{
ImGuiWindow* window = GImGui->CurrentWindow;
if (window->SkipItems)
return false;
ImGuiID id = str_id ? window->GetID(str_id) : window->DC.LastItemId; // If user hasn't passed an ID, we can use the LastItemID. Using LastItemID as a Popup ID won't conflict!
IM_ASSERT(id != 0); // You cannot pass a NULL str_id if the last item has no identifier (e.g. a Text() item)
if (IsMouseReleased(mouse_button) && IsItemHovered(ImGuiHoveredFlags_AllowWhenBlockedByPopup))
OpenPopupEx(id);
return BeginPopupEx(id, ImGuiWindowFlags_AlwaysAutoResize|ImGuiWindowFlags_NoTitleBar|ImGuiWindowFlags_NoSavedSettings);
}
bool ImGui::BeginPopupContextWindow(const char* str_id, int mouse_button, bool also_over_items)
{
if (!str_id)
str_id = "window_context";
ImGuiID id = GImGui->CurrentWindow->GetID(str_id);
if (IsMouseReleased(mouse_button) && IsWindowHovered(ImGuiHoveredFlags_AllowWhenBlockedByPopup))
if (also_over_items || !IsAnyItemHovered())
OpenPopupEx(id);
return BeginPopupEx(id, ImGuiWindowFlags_AlwaysAutoResize|ImGuiWindowFlags_NoTitleBar|ImGuiWindowFlags_NoSavedSettings);
}
bool ImGui::BeginPopupContextVoid(const char* str_id, int mouse_button)
{
if (!str_id)
str_id = "void_context";
ImGuiID id = GImGui->CurrentWindow->GetID(str_id);
if (IsMouseReleased(mouse_button) && !IsWindowHovered(ImGuiHoveredFlags_AnyWindow))
OpenPopupEx(id);
return BeginPopupEx(id, ImGuiWindowFlags_AlwaysAutoResize|ImGuiWindowFlags_NoTitleBar|ImGuiWindowFlags_NoSavedSettings);
}
// r_avoid = the rectangle to avoid (e.g. for tooltip it is a rectangle around the mouse cursor which we want to avoid. for popups it's a small point around the cursor.)
// r_outer = the visible area rectangle, minus safe area padding. If our popup size won't fit because of safe area padding we ignore it.
// (r_outer is usually equivalent to the viewport rectangle minus padding, but when multi-viewports are enabled and monitor
// information are available, it may represent the entire platform monitor from the frame of reference of the current viewport.
// this allows us to have tooltips/popups displayed out of the parent viewport.)
ImVec2 ImGui::FindBestWindowPosForPopupEx(const ImVec2& ref_pos, const ImVec2& size, ImGuiDir* last_dir, const ImRect& r_outer, const ImRect& r_avoid, ImGuiPopupPositionPolicy policy)
{
ImVec2 base_pos_clamped = ImClamp(ref_pos, r_outer.Min, r_outer.Max - size);
//GetForegroundDrawList()->AddRect(r_avoid.Min, r_avoid.Max, IM_COL32(255,0,0,255));
//GetForegroundDrawList()->AddRect(r_outer.Min, r_outer.Max, IM_COL32(0,255,0,255));
// Combo Box policy (we want a connecting edge)
if (policy == ImGuiPopupPositionPolicy_ComboBox)
{
const ImGuiDir dir_prefered_order[ImGuiDir_COUNT] = { ImGuiDir_Down, ImGuiDir_Right, ImGuiDir_Left, ImGuiDir_Up };
for (int n = (*last_dir != ImGuiDir_None) ? -1 : 0; n < ImGuiDir_COUNT; n++)
{
const ImGuiDir dir = (n == -1) ? *last_dir : dir_prefered_order[n];
if (n != -1 && dir == *last_dir) // Already tried this direction?
continue;
ImVec2 pos;
if (dir == ImGuiDir_Down) pos = ImVec2(r_avoid.Min.x, r_avoid.Max.y); // Below, Toward Right (default)
if (dir == ImGuiDir_Right) pos = ImVec2(r_avoid.Min.x, r_avoid.Min.y - size.y); // Above, Toward Right
if (dir == ImGuiDir_Left) pos = ImVec2(r_avoid.Max.x - size.x, r_avoid.Max.y); // Below, Toward Left
if (dir == ImGuiDir_Up) pos = ImVec2(r_avoid.Max.x - size.x, r_avoid.Min.y - size.y); // Above, Toward Left
if (!r_outer.Contains(ImRect(pos, pos + size)))
continue;
*last_dir = dir;
return pos;
}
}
// Default popup policy
const ImGuiDir dir_prefered_order[ImGuiDir_COUNT] = { ImGuiDir_Right, ImGuiDir_Down, ImGuiDir_Up, ImGuiDir_Left };
for (int n = (*last_dir != ImGuiDir_None) ? -1 : 0; n < ImGuiDir_COUNT; n++)
{
const ImGuiDir dir = (n == -1) ? *last_dir : dir_prefered_order[n];
if (n != -1 && dir == *last_dir) // Already tried this direction?
continue;
float avail_w = (dir == ImGuiDir_Left ? r_avoid.Min.x : r_outer.Max.x) - (dir == ImGuiDir_Right ? r_avoid.Max.x : r_outer.Min.x);
float avail_h = (dir == ImGuiDir_Up ? r_avoid.Min.y : r_outer.Max.y) - (dir == ImGuiDir_Down ? r_avoid.Max.y : r_outer.Min.y);
if (avail_w < size.x || avail_h < size.y)
continue;
ImVec2 pos;
pos.x = (dir == ImGuiDir_Left) ? r_avoid.Min.x - size.x : (dir == ImGuiDir_Right) ? r_avoid.Max.x : base_pos_clamped.x;
pos.y = (dir == ImGuiDir_Up) ? r_avoid.Min.y - size.y : (dir == ImGuiDir_Down) ? r_avoid.Max.y : base_pos_clamped.y;
*last_dir = dir;
return pos;
}
// Fallback, try to keep within display
*last_dir = ImGuiDir_None;
ImVec2 pos = ref_pos;
pos.x = ImMax(ImMin(pos.x + size.x, r_outer.Max.x) - size.x, r_outer.Min.x);
pos.y = ImMax(ImMin(pos.y + size.y, r_outer.Max.y) - size.y, r_outer.Min.y);
return pos;
}
ImRect ImGui::GetWindowAllowedExtentRect(ImGuiWindow* window)
{
ImGuiContext& g = *GImGui;
ImRect r_screen;
if (window->ViewportAllowPlatformMonitorExtend >= 0)
{
// Extent with be in the frame of reference of the given viewport (so Min is likely to be negative here)
const ImGuiPlatformMonitor& monitor = g.PlatformIO.Monitors[window->ViewportAllowPlatformMonitorExtend];
r_screen.Min = monitor.WorkPos;
r_screen.Max = monitor.WorkPos + monitor.WorkSize;
}
else
{
r_screen.Min = window->Viewport->Pos;
r_screen.Max = window->Viewport->Pos + window->Viewport->Size;
}
ImVec2 padding = g.Style.DisplaySafeAreaPadding;
r_screen.Expand(ImVec2((r_screen.GetWidth() > padding.x * 2) ? -padding.x : 0.0f, (r_screen.GetHeight() > padding.y * 2) ? -padding.y : 0.0f));
return r_screen;
}
ImVec2 ImGui::FindBestWindowPosForPopup(ImGuiWindow* window)
{
ImGuiContext& g = *GImGui;
if (window->Flags & ImGuiWindowFlags_ChildMenu)
{
// Child menus typically request _any_ position within the parent menu item, and then we move the new menu outside the parent bounds.
// This is how we end up with child menus appearing (most-commonly) on the right of the parent menu.
ImGuiWindow* parent_window = window->ParentWindow;
float horizontal_overlap = g.Style.ItemInnerSpacing.x; // We want some overlap to convey the relative depth of each menu (currently the amount of overlap is hard-coded to style.ItemSpacing.x).
ImRect r_outer = GetWindowAllowedExtentRect(window);
ImRect r_avoid;
if (parent_window->DC.MenuBarAppending)
r_avoid = ImRect(-FLT_MAX, parent_window->Pos.y + parent_window->TitleBarHeight(), FLT_MAX, parent_window->Pos.y + parent_window->TitleBarHeight() + parent_window->MenuBarHeight());
else
r_avoid = ImRect(parent_window->Pos.x + horizontal_overlap, -FLT_MAX, parent_window->Pos.x + parent_window->Size.x - horizontal_overlap - parent_window->ScrollbarSizes.x, FLT_MAX);
return FindBestWindowPosForPopupEx(window->Pos, window->Size, &window->AutoPosLastDirection, r_outer, r_avoid);
}
if (window->Flags & ImGuiWindowFlags_Popup)
{
ImRect r_outer = GetWindowAllowedExtentRect(window);
ImRect r_avoid = ImRect(window->Pos.x - 1, window->Pos.y - 1, window->Pos.x + 1, window->Pos.y + 1);
return FindBestWindowPosForPopupEx(window->Pos, window->Size, &window->AutoPosLastDirection, r_outer, r_avoid);
}
if (window->Flags & ImGuiWindowFlags_Tooltip)
{
// Position tooltip (always follows mouse)
float sc = g.Style.MouseCursorScale;
ImVec2 ref_pos = NavCalcPreferredRefPos();
ImRect r_outer = GetWindowAllowedExtentRect(window);
ImRect r_avoid;
if (!g.NavDisableHighlight && g.NavDisableMouseHover && !(g.IO.ConfigFlags & ImGuiConfigFlags_NavEnableSetMousePos))
r_avoid = ImRect(ref_pos.x - 16, ref_pos.y - 8, ref_pos.x + 16, ref_pos.y + 8);
else
r_avoid = ImRect(ref_pos.x - 16, ref_pos.y - 8, ref_pos.x + 24 * sc, ref_pos.y + 24 * sc); // FIXME: Hard-coded based on mouse cursor shape expectation. Exact dimension not very important.
ImVec2 pos = FindBestWindowPosForPopupEx(ref_pos, window->Size, &window->AutoPosLastDirection, r_outer, r_avoid);
if (window->AutoPosLastDirection == ImGuiDir_None)
pos = ref_pos + ImVec2(2, 2); // If there's not enough room, for tooltip we prefer avoiding the cursor at all cost even if it means that part of the tooltip won't be visible.
return pos;
}
IM_ASSERT(0);
return window->Pos;
}
//-----------------------------------------------------------------------------
// [SECTION] KEYBOARD/GAMEPAD NAVIGATION
//-----------------------------------------------------------------------------
ImGuiDir ImGetDirQuadrantFromDelta(float dx, float dy)
{
if (ImFabs(dx) > ImFabs(dy))
return (dx > 0.0f) ? ImGuiDir_Right : ImGuiDir_Left;
return (dy > 0.0f) ? ImGuiDir_Down : ImGuiDir_Up;
}
static float inline NavScoreItemDistInterval(float a0, float a1, float b0, float b1)
{
if (a1 < b0)
return a1 - b0;
if (b1 < a0)
return a0 - b1;
return 0.0f;
}
static void inline NavClampRectToVisibleAreaForMoveDir(ImGuiDir move_dir, ImRect& r, const ImRect& clip_rect)
{
if (move_dir == ImGuiDir_Left || move_dir == ImGuiDir_Right)
{
r.Min.y = ImClamp(r.Min.y, clip_rect.Min.y, clip_rect.Max.y);
r.Max.y = ImClamp(r.Max.y, clip_rect.Min.y, clip_rect.Max.y);
}
else
{
r.Min.x = ImClamp(r.Min.x, clip_rect.Min.x, clip_rect.Max.x);
r.Max.x = ImClamp(r.Max.x, clip_rect.Min.x, clip_rect.Max.x);
}
}
// Scoring function for directional navigation. Based on https://gist.github.com/rygorous/6981057
static bool NavScoreItem(ImGuiNavMoveResult* result, ImRect cand)
{
ImGuiContext& g = *GImGui;
ImGuiWindow* window = g.CurrentWindow;
if (g.NavLayer != window->DC.NavLayerCurrent)
return false;
const ImRect& curr = g.NavScoringRectScreen; // Current modified source rect (NB: we've applied Max.x = Min.x in NavUpdate() to inhibit the effect of having varied item width)
g.NavScoringCount++;
// When entering through a NavFlattened border, we consider child window items as fully clipped for scoring
if (window->ParentWindow == g.NavWindow)
{
IM_ASSERT((window->Flags | g.NavWindow->Flags) & ImGuiWindowFlags_NavFlattened);
if (!window->ClipRect.Overlaps(cand))
return false;
cand.ClipWithFull(window->ClipRect); // This allows the scored item to not overlap other candidates in the parent window
}
// We perform scoring on items bounding box clipped by the current clipping rectangle on the other axis (clipping on our movement axis would give us equal scores for all clipped items)
// For example, this ensure that items in one column are not reached when moving vertically from items in another column.
NavClampRectToVisibleAreaForMoveDir(g.NavMoveClipDir, cand, window->ClipRect);
// Compute distance between boxes
// FIXME-NAV: Introducing biases for vertical navigation, needs to be removed.
float dbx = NavScoreItemDistInterval(cand.Min.x, cand.Max.x, curr.Min.x, curr.Max.x);
float dby = NavScoreItemDistInterval(ImLerp(cand.Min.y, cand.Max.y, 0.2f), ImLerp(cand.Min.y, cand.Max.y, 0.8f), ImLerp(curr.Min.y, curr.Max.y, 0.2f), ImLerp(curr.Min.y, curr.Max.y, 0.8f)); // Scale down on Y to keep using box-distance for vertically touching items
if (dby != 0.0f && dbx != 0.0f)
dbx = (dbx/1000.0f) + ((dbx > 0.0f) ? +1.0f : -1.0f);
float dist_box = ImFabs(dbx) + ImFabs(dby);
// Compute distance between centers (this is off by a factor of 2, but we only compare center distances with each other so it doesn't matter)
float dcx = (cand.Min.x + cand.Max.x) - (curr.Min.x + curr.Max.x);
float dcy = (cand.Min.y + cand.Max.y) - (curr.Min.y + curr.Max.y);
float dist_center = ImFabs(dcx) + ImFabs(dcy); // L1 metric (need this for our connectedness guarantee)
// Determine which quadrant of 'curr' our candidate item 'cand' lies in based on distance
ImGuiDir quadrant;
float dax = 0.0f, day = 0.0f, dist_axial = 0.0f;
if (dbx != 0.0f || dby != 0.0f)
{
// For non-overlapping boxes, use distance between boxes
dax = dbx;
day = dby;
dist_axial = dist_box;
quadrant = ImGetDirQuadrantFromDelta(dbx, dby);
}
else if (dcx != 0.0f || dcy != 0.0f)
{
// For overlapping boxes with different centers, use distance between centers
dax = dcx;
day = dcy;
dist_axial = dist_center;
quadrant = ImGetDirQuadrantFromDelta(dcx, dcy);
}
else
{
// Degenerate case: two overlapping buttons with same center, break ties arbitrarily (note that LastItemId here is really the _previous_ item order, but it doesn't matter)
quadrant = (window->DC.LastItemId < g.NavId) ? ImGuiDir_Left : ImGuiDir_Right;
}
#if IMGUI_DEBUG_NAV_SCORING
char buf[128];
if (ImGui::IsMouseHoveringRect(cand.Min, cand.Max))
{
ImFormatString(buf, IM_ARRAYSIZE(buf), "dbox (%.2f,%.2f->%.4f)\ndcen (%.2f,%.2f->%.4f)\nd (%.2f,%.2f->%.4f)\nnav %c, quadrant %c", dbx, dby, dist_box, dcx, dcy, dist_center, dax, day, dist_axial, "WENS"[g.NavMoveDir], "WENS"[quadrant]);
ImDrawList* draw_list = ImGui::GetForegroundDrawList(window);
draw_list->AddRect(curr.Min, curr.Max, IM_COL32(255,200,0,100));
draw_list->AddRect(cand.Min, cand.Max, IM_COL32(255,255,0,200));
draw_list->AddRectFilled(cand.Max-ImVec2(4,4), cand.Max+ImGui::CalcTextSize(buf)+ImVec2(4,4), IM_COL32(40,0,0,150));
draw_list->AddText(g.IO.FontDefault, 13.0f, cand.Max, ~0U, buf);
}
else if (g.IO.KeyCtrl) // Hold to preview score in matching quadrant. Press C to rotate.
{
if (ImGui::IsKeyPressedMap(ImGuiKey_C)) { g.NavMoveDirLast = (ImGuiDir)((g.NavMoveDirLast + 1) & 3); g.IO.KeysDownDuration[g.IO.KeyMap[ImGuiKey_C]] = 0.01f; }
if (quadrant == g.NavMoveDir)
{
ImFormatString(buf, IM_ARRAYSIZE(buf), "%.0f/%.0f", dist_box, dist_center);
ImDrawList* draw_list = ImGui::GetForegroundDrawList(window);
draw_list->AddRectFilled(cand.Min, cand.Max, IM_COL32(255, 0, 0, 200));
draw_list->AddText(g.IO.FontDefault, 13.0f, cand.Min, IM_COL32(255, 255, 255, 255), buf);
}
}
#endif
// Is it in the quadrant we're interesting in moving to?
bool new_best = false;
if (quadrant == g.NavMoveDir)
{
// Does it beat the current best candidate?
if (dist_box < result->DistBox)
{
result->DistBox = dist_box;
result->DistCenter = dist_center;
return true;
}
if (dist_box == result->DistBox)
{
// Try using distance between center points to break ties
if (dist_center < result->DistCenter)
{
result->DistCenter = dist_center;
new_best = true;
}
else if (dist_center == result->DistCenter)
{
// Still tied! we need to be extra-careful to make sure everything gets linked properly. We consistently break ties by symbolically moving "later" items
// (with higher index) to the right/downwards by an infinitesimal amount since we the current "best" button already (so it must have a lower index),
// this is fairly easy. This rule ensures that all buttons with dx==dy==0 will end up being linked in order of appearance along the x axis.
if (((g.NavMoveDir == ImGuiDir_Up || g.NavMoveDir == ImGuiDir_Down) ? dby : dbx) < 0.0f) // moving bj to the right/down decreases distance
new_best = true;
}
}
}
// Axial check: if 'curr' has no link at all in some direction and 'cand' lies roughly in that direction, add a tentative link. This will only be kept if no "real" matches
// are found, so it only augments the graph produced by the above method using extra links. (important, since it doesn't guarantee strong connectedness)
// This is just to avoid buttons having no links in a particular direction when there's a suitable neighbor. you get good graphs without this too.
// 2017/09/29: FIXME: This now currently only enabled inside menu bars, ideally we'd disable it everywhere. Menus in particular need to catch failure. For general navigation it feels awkward.
// Disabling it may lead to disconnected graphs when nodes are very spaced out on different axis. Perhaps consider offering this as an option?
if (result->DistBox == FLT_MAX && dist_axial < result->DistAxial) // Check axial match
if (g.NavLayer == 1 && !(g.NavWindow->Flags & ImGuiWindowFlags_ChildMenu))
if ((g.NavMoveDir == ImGuiDir_Left && dax < 0.0f) || (g.NavMoveDir == ImGuiDir_Right && dax > 0.0f) || (g.NavMoveDir == ImGuiDir_Up && day < 0.0f) || (g.NavMoveDir == ImGuiDir_Down && day > 0.0f))
{
result->DistAxial = dist_axial;
new_best = true;
}
return new_best;
}
// We get there when either NavId == id, or when g.NavAnyRequest is set (which is updated by NavUpdateAnyRequestFlag above)
static void ImGui::NavProcessItem(ImGuiWindow* window, const ImRect& nav_bb, const ImGuiID id)
{
ImGuiContext& g = *GImGui;
//if (!g.IO.NavActive) // [2017/10/06] Removed this possibly redundant test but I am not sure of all the side-effects yet. Some of the feature here will need to work regardless of using a _NoNavInputs flag.
// return;
const ImGuiItemFlags item_flags = window->DC.ItemFlags;
const ImRect nav_bb_rel(nav_bb.Min - window->Pos, nav_bb.Max - window->Pos);
// Process Init Request
if (g.NavInitRequest && g.NavLayer == window->DC.NavLayerCurrent)
{
// Even if 'ImGuiItemFlags_NoNavDefaultFocus' is on (typically collapse/close button) we record the first ResultId so they can be used as a fallback
if (!(item_flags & ImGuiItemFlags_NoNavDefaultFocus) || g.NavInitResultId == 0)
{
g.NavInitResultId = id;
g.NavInitResultRectRel = nav_bb_rel;
}
if (!(item_flags & ImGuiItemFlags_NoNavDefaultFocus))
{
g.NavInitRequest = false; // Found a match, clear request
NavUpdateAnyRequestFlag();
}
}
// Process Move Request (scoring for navigation)
// FIXME-NAV: Consider policy for double scoring (scoring from NavScoringRectScreen + scoring from a rect wrapped according to current wrapping policy)
if ((g.NavId != id || (g.NavMoveRequestFlags & ImGuiNavMoveFlags_AllowCurrentNavId)) && !(item_flags & (ImGuiItemFlags_Disabled|ImGuiItemFlags_NoNav)))
{
ImGuiNavMoveResult* result = (window == g.NavWindow) ? &g.NavMoveResultLocal : &g.NavMoveResultOther;
#if IMGUI_DEBUG_NAV_SCORING
// [DEBUG] Score all items in NavWindow at all times
if (!g.NavMoveRequest)
g.NavMoveDir = g.NavMoveDirLast;
bool new_best = NavScoreItem(result, nav_bb) && g.NavMoveRequest;
#else
bool new_best = g.NavMoveRequest && NavScoreItem(result, nav_bb);
#endif
if (new_best)
{
result->ID = id;
result->SelectScopeId = g.MultiSelectScopeId;
result->Window = window;
result->RectRel = nav_bb_rel;
}
const float VISIBLE_RATIO = 0.70f;
if ((g.NavMoveRequestFlags & ImGuiNavMoveFlags_AlsoScoreVisibleSet) && window->ClipRect.Overlaps(nav_bb))
if (ImClamp(nav_bb.Max.y, window->ClipRect.Min.y, window->ClipRect.Max.y) - ImClamp(nav_bb.Min.y, window->ClipRect.Min.y, window->ClipRect.Max.y) >= (nav_bb.Max.y - nav_bb.Min.y) * VISIBLE_RATIO)
if (NavScoreItem(&g.NavMoveResultLocalVisibleSet, nav_bb))
{
result = &g.NavMoveResultLocalVisibleSet;
result->ID = id;
result->SelectScopeId = g.MultiSelectScopeId;
result->Window = window;
result->RectRel = nav_bb_rel;
}
}
// Update window-relative bounding box of navigated item
if (g.NavId == id)
{
g.NavWindow = window; // Always refresh g.NavWindow, because some operations such as FocusItem() don't have a window.
g.NavLayer = window->DC.NavLayerCurrent;
g.NavIdIsAlive = true;
g.NavIdTabCounter = window->DC.FocusCounterTab;
window->NavRectRel[window->DC.NavLayerCurrent] = nav_bb_rel; // Store item bounding box (relative to window position)
}
}
bool ImGui::NavMoveRequestButNoResultYet()
{
ImGuiContext& g = *GImGui;
return g.NavMoveRequest && g.NavMoveResultLocal.ID == 0 && g.NavMoveResultOther.ID == 0;
}
void ImGui::NavMoveRequestCancel()
{
ImGuiContext& g = *GImGui;
g.NavMoveRequest = false;
NavUpdateAnyRequestFlag();
}
void ImGui::NavMoveRequestForward(ImGuiDir move_dir, ImGuiDir clip_dir, const ImRect& bb_rel, ImGuiNavMoveFlags move_flags)
{
ImGuiContext& g = *GImGui;
IM_ASSERT(g.NavMoveRequestForward == ImGuiNavForward_None);
ImGui::NavMoveRequestCancel();
g.NavMoveDir = move_dir;
g.NavMoveClipDir = clip_dir;
g.NavMoveRequestForward = ImGuiNavForward_ForwardQueued;
g.NavMoveRequestFlags = move_flags;
g.NavWindow->NavRectRel[g.NavLayer] = bb_rel;
}
void ImGui::NavMoveRequestTryWrapping(ImGuiWindow* window, ImGuiNavMoveFlags move_flags)
{
ImGuiContext& g = *GImGui;
if (g.NavWindow != window || !NavMoveRequestButNoResultYet() || g.NavMoveRequestForward != ImGuiNavForward_None || g.NavLayer != 0)
return;
IM_ASSERT(move_flags != 0); // No points calling this with no wrapping
ImRect bb_rel = window->NavRectRel[0];
ImGuiDir clip_dir = g.NavMoveDir;
if (g.NavMoveDir == ImGuiDir_Left && (move_flags & (ImGuiNavMoveFlags_WrapX | ImGuiNavMoveFlags_LoopX)))
{
bb_rel.Min.x = bb_rel.Max.x = ImMax(window->SizeFull.x, window->ContentSize.x + window->WindowPadding.x * 2.0f) - window->Scroll.x;
if (move_flags & ImGuiNavMoveFlags_WrapX) { bb_rel.TranslateY(-bb_rel.GetHeight()); clip_dir = ImGuiDir_Up; }
NavMoveRequestForward(g.NavMoveDir, clip_dir, bb_rel, move_flags);
}
if (g.NavMoveDir == ImGuiDir_Right && (move_flags & (ImGuiNavMoveFlags_WrapX | ImGuiNavMoveFlags_LoopX)))
{
bb_rel.Min.x = bb_rel.Max.x = -window->Scroll.x;
if (move_flags & ImGuiNavMoveFlags_WrapX) { bb_rel.TranslateY(+bb_rel.GetHeight()); clip_dir = ImGuiDir_Down; }
NavMoveRequestForward(g.NavMoveDir, clip_dir, bb_rel, move_flags);
}
if (g.NavMoveDir == ImGuiDir_Up && (move_flags & (ImGuiNavMoveFlags_WrapY | ImGuiNavMoveFlags_LoopY)))
{
bb_rel.Min.y = bb_rel.Max.y = ImMax(window->SizeFull.y, window->ContentSize.y + window->WindowPadding.y * 2.0f) - window->Scroll.y;
if (move_flags & ImGuiNavMoveFlags_WrapY) { bb_rel.TranslateX(-bb_rel.GetWidth()); clip_dir = ImGuiDir_Left; }
NavMoveRequestForward(g.NavMoveDir, clip_dir, bb_rel, move_flags);
}
if (g.NavMoveDir == ImGuiDir_Down && (move_flags & (ImGuiNavMoveFlags_WrapY | ImGuiNavMoveFlags_LoopY)))
{
bb_rel.Min.y = bb_rel.Max.y = -window->Scroll.y;
if (move_flags & ImGuiNavMoveFlags_WrapY) { bb_rel.TranslateX(+bb_rel.GetWidth()); clip_dir = ImGuiDir_Right; }
NavMoveRequestForward(g.NavMoveDir, clip_dir, bb_rel, move_flags);
}
}
// FIXME: This could be replaced by updating a frame number in each window when (window == NavWindow) and (NavLayer == 0).
// This way we could find the last focused window among our children. It would be much less confusing this way?
static void ImGui::NavSaveLastChildNavWindowIntoParent(ImGuiWindow* nav_window)
{
ImGuiWindow* parent_window = nav_window;
while (parent_window && (parent_window->Flags & ImGuiWindowFlags_ChildWindow) != 0 && (parent_window->Flags & (ImGuiWindowFlags_Popup | ImGuiWindowFlags_ChildMenu)) == 0)
parent_window = parent_window->ParentWindow;
if (parent_window && parent_window != nav_window)
parent_window->NavLastChildNavWindow = nav_window;
}
// Restore the last focused child.
// Call when we are expected to land on the Main Layer (0) after FocusWindow()
static ImGuiWindow* ImGui::NavRestoreLastChildNavWindow(ImGuiWindow* window)
{
if (window->NavLastChildNavWindow && window->NavLastChildNavWindow->WasActive)
return window->NavLastChildNavWindow;
if (window->DockNodeAsHost && window->DockNodeAsHost->TabBar)
if (ImGuiTabItem* tab = TabBarFindMostRecentlySelectedTabForActiveWindow(window->DockNodeAsHost->TabBar))
return tab->Window;
return window;
}
static void NavRestoreLayer(ImGuiNavLayer layer)
{
ImGuiContext& g = *GImGui;
g.NavLayer = layer;
if (layer == 0)
g.NavWindow = ImGui::NavRestoreLastChildNavWindow(g.NavWindow);
if (g.NavWindow->NavLastIds[layer] != 0)
ImGui::SetNavIDWithRectRel(g.NavWindow->NavLastIds[layer], layer, g.NavWindow->NavRectRel[layer]);
else
ImGui::NavInitWindow(g.NavWindow, true);
}
static inline void ImGui::NavUpdateAnyRequestFlag()
{
ImGuiContext& g = *GImGui;
g.NavAnyRequest = g.NavMoveRequest || g.NavInitRequest || (IMGUI_DEBUG_NAV_SCORING && g.NavWindow != NULL);
if (g.NavAnyRequest)
IM_ASSERT(g.NavWindow != NULL);
}
// This needs to be called before we submit any widget (aka in or before Begin)
void ImGui::NavInitWindow(ImGuiWindow* window, bool force_reinit)
{
ImGuiContext& g = *GImGui;
IM_ASSERT(window == g.NavWindow);
bool init_for_nav = false;
if (!(window->Flags & ImGuiWindowFlags_NoNavInputs))
if (!(window->Flags & ImGuiWindowFlags_ChildWindow) || (window->Flags & ImGuiWindowFlags_Popup) || (window->NavLastIds[0] == 0) || force_reinit)
init_for_nav = true;
if (init_for_nav)
{
SetNavID(0, g.NavLayer);
g.NavInitRequest = true;
g.NavInitRequestFromMove = false;
g.NavInitResultId = 0;
g.NavInitResultRectRel = ImRect();
NavUpdateAnyRequestFlag();
}
else
{
g.NavId = window->NavLastIds[0];
}
}
static ImVec2 ImGui::NavCalcPreferredRefPos()
{
ImGuiContext& g = *GImGui;
if (g.NavDisableHighlight || !g.NavDisableMouseHover || !g.NavWindow)
{
// Mouse (we need a fallback in case the mouse becomes invalid after being used)
if (IsMousePosValid(&g.IO.MousePos))
return g.IO.MousePos;
return g.LastValidMousePos;
}
else
{
// When navigation is active and mouse is disabled, decide on an arbitrary position around the bottom left of the currently navigated item.
const ImRect& rect_rel = g.NavWindow->NavRectRel[g.NavLayer];
ImVec2 pos = g.NavWindow->Pos + ImVec2(rect_rel.Min.x + ImMin(g.Style.FramePadding.x * 4, rect_rel.GetWidth()), rect_rel.Max.y - ImMin(g.Style.FramePadding.y, rect_rel.GetHeight()));
ImRect visible_rect = g.NavWindow->Viewport->GetRect();
return ImFloor(ImClamp(pos, visible_rect.Min, visible_rect.Max)); // ImFloor() is important because non-integer mouse position application in back-end might be lossy and result in undesirable non-zero delta.
}
}
float ImGui::GetNavInputAmount(ImGuiNavInput n, ImGuiInputReadMode mode)
{
ImGuiContext& g = *GImGui;
if (mode == ImGuiInputReadMode_Down)
return g.IO.NavInputs[n]; // Instant, read analog input (0.0f..1.0f, as provided by user)
const float t = g.IO.NavInputsDownDuration[n];
if (t < 0.0f && mode == ImGuiInputReadMode_Released) // Return 1.0f when just released, no repeat, ignore analog input.
return (g.IO.NavInputsDownDurationPrev[n] >= 0.0f ? 1.0f : 0.0f);
if (t < 0.0f)
return 0.0f;
if (mode == ImGuiInputReadMode_Pressed) // Return 1.0f when just pressed, no repeat, ignore analog input.
return (t == 0.0f) ? 1.0f : 0.0f;
if (mode == ImGuiInputReadMode_Repeat)
return (float)CalcTypematicPressedRepeatAmount(t, t - g.IO.DeltaTime, g.IO.KeyRepeatDelay * 0.80f, g.IO.KeyRepeatRate * 0.80f);
if (mode == ImGuiInputReadMode_RepeatSlow)
return (float)CalcTypematicPressedRepeatAmount(t, t - g.IO.DeltaTime, g.IO.KeyRepeatDelay * 1.00f, g.IO.KeyRepeatRate * 2.00f);
if (mode == ImGuiInputReadMode_RepeatFast)
return (float)CalcTypematicPressedRepeatAmount(t, t - g.IO.DeltaTime, g.IO.KeyRepeatDelay * 0.80f, g.IO.KeyRepeatRate * 0.30f);
return 0.0f;
}
ImVec2 ImGui::GetNavInputAmount2d(ImGuiNavDirSourceFlags dir_sources, ImGuiInputReadMode mode, float slow_factor, float fast_factor)
{
ImVec2 delta(0.0f, 0.0f);
if (dir_sources & ImGuiNavDirSourceFlags_Keyboard)
delta += ImVec2(GetNavInputAmount(ImGuiNavInput_KeyRight_, mode) - GetNavInputAmount(ImGuiNavInput_KeyLeft_, mode), GetNavInputAmount(ImGuiNavInput_KeyDown_, mode) - GetNavInputAmount(ImGuiNavInput_KeyUp_, mode));
if (dir_sources & ImGuiNavDirSourceFlags_PadDPad)
delta += ImVec2(GetNavInputAmount(ImGuiNavInput_DpadRight, mode) - GetNavInputAmount(ImGuiNavInput_DpadLeft, mode), GetNavInputAmount(ImGuiNavInput_DpadDown, mode) - GetNavInputAmount(ImGuiNavInput_DpadUp, mode));
if (dir_sources & ImGuiNavDirSourceFlags_PadLStick)
delta += ImVec2(GetNavInputAmount(ImGuiNavInput_LStickRight, mode) - GetNavInputAmount(ImGuiNavInput_LStickLeft, mode), GetNavInputAmount(ImGuiNavInput_LStickDown, mode) - GetNavInputAmount(ImGuiNavInput_LStickUp, mode));
if (slow_factor != 0.0f && IsNavInputDown(ImGuiNavInput_TweakSlow))
delta *= slow_factor;
if (fast_factor != 0.0f && IsNavInputDown(ImGuiNavInput_TweakFast))
delta *= fast_factor;
return delta;
}
static void ImGui::NavUpdate()
{
ImGuiContext& g = *GImGui;
g.IO.WantSetMousePos = false;
#if 0
if (g.NavScoringCount > 0) IMGUI_DEBUG_LOG("NavScoringCount %d for '%s' layer %d (Init:%d, Move:%d)\n", g.FrameCount, g.NavScoringCount, g.NavWindow ? g.NavWindow->Name : "NULL", g.NavLayer, g.NavInitRequest || g.NavInitResultId != 0, g.NavMoveRequest);
#endif
// Set input source as Gamepad when buttons are pressed before we map Keyboard (some features differs when used with Gamepad vs Keyboard)
bool nav_keyboard_active = (g.IO.ConfigFlags & ImGuiConfigFlags_NavEnableKeyboard) != 0;
bool nav_gamepad_active = (g.IO.ConfigFlags & ImGuiConfigFlags_NavEnableGamepad) != 0 && (g.IO.BackendFlags & ImGuiBackendFlags_HasGamepad) != 0;
if (nav_gamepad_active)
if (g.IO.NavInputs[ImGuiNavInput_Activate] > 0.0f || g.IO.NavInputs[ImGuiNavInput_Input] > 0.0f || g.IO.NavInputs[ImGuiNavInput_Cancel] > 0.0f || g.IO.NavInputs[ImGuiNavInput_Menu] > 0.0f)
g.NavInputSource = ImGuiInputSource_NavGamepad;
// Update Keyboard->Nav inputs mapping
if (nav_keyboard_active)
{
#define NAV_MAP_KEY(_KEY, _NAV_INPUT) do { if (IsKeyDown(g.IO.KeyMap[_KEY])) { g.IO.NavInputs[_NAV_INPUT] = 1.0f; g.NavInputSource = ImGuiInputSource_NavKeyboard; } } while (0)
NAV_MAP_KEY(ImGuiKey_Space, ImGuiNavInput_Activate );
NAV_MAP_KEY(ImGuiKey_Enter, ImGuiNavInput_Input );
NAV_MAP_KEY(ImGuiKey_Escape, ImGuiNavInput_Cancel );
NAV_MAP_KEY(ImGuiKey_LeftArrow, ImGuiNavInput_KeyLeft_ );
NAV_MAP_KEY(ImGuiKey_RightArrow,ImGuiNavInput_KeyRight_);
NAV_MAP_KEY(ImGuiKey_UpArrow, ImGuiNavInput_KeyUp_ );
NAV_MAP_KEY(ImGuiKey_DownArrow, ImGuiNavInput_KeyDown_ );
NAV_MAP_KEY(ImGuiKey_Tab, ImGuiNavInput_KeyTab_ );
if (g.IO.KeyCtrl)
g.IO.NavInputs[ImGuiNavInput_TweakSlow] = 1.0f;
if (g.IO.KeyShift)
g.IO.NavInputs[ImGuiNavInput_TweakFast] = 1.0f;
//if (g.IO.KeyAlt && !g.IO.KeyCtrl) // AltGR is Alt+Ctrl, also even on keyboards without AltGR we don't want Alt+Ctrl to open menu.
// g.IO.NavInputs[ImGuiNavInput_KeyMenu_] = 1.0f;
#undef NAV_MAP_KEY
}
memcpy(g.IO.NavInputsDownDurationPrev, g.IO.NavInputsDownDuration, sizeof(g.IO.NavInputsDownDuration));
for (int i = 0; i < IM_ARRAYSIZE(g.IO.NavInputs); i++)
g.IO.NavInputsDownDuration[i] = (g.IO.NavInputs[i] > 0.0f) ? (g.IO.NavInputsDownDuration[i] < 0.0f ? 0.0f : g.IO.NavInputsDownDuration[i] + g.IO.DeltaTime) : -1.0f;
// Process navigation init request (select first/default focus)
// In very rare cases g.NavWindow may be null (e.g. clearing focus after requesting an init request, which does happen when releasing Alt while clicking on void)
if (g.NavInitResultId != 0 && (!g.NavDisableHighlight || g.NavInitRequestFromMove) && g.NavWindow)
{
// Apply result from previous navigation init request (will typically select the first item, unless SetItemDefaultFocus() has been called)
if (g.NavInitRequestFromMove)
SetNavIDWithRectRel(g.NavInitResultId, g.NavLayer, g.NavInitResultRectRel);
else
SetNavID(g.NavInitResultId, g.NavLayer);
g.NavWindow->NavRectRel[g.NavLayer] = g.NavInitResultRectRel;
}
g.NavInitRequest = false;
g.NavInitRequestFromMove = false;
g.NavInitResultId = 0;
g.NavJustMovedToId = 0;
// Process navigation move request
if (g.NavMoveRequest)
NavUpdateMoveResult();
// When a forwarded move request failed, we restore the highlight that we disabled during the forward frame
if (g.NavMoveRequestForward == ImGuiNavForward_ForwardActive)
{
IM_ASSERT(g.NavMoveRequest);
if (g.NavMoveResultLocal.ID == 0 && g.NavMoveResultOther.ID == 0)
g.NavDisableHighlight = false;
g.NavMoveRequestForward = ImGuiNavForward_None;
}
// Apply application mouse position movement, after we had a chance to process move request result.
if (g.NavMousePosDirty && g.NavIdIsAlive)
{
// Set mouse position given our knowledge of the navigated item position from last frame
if ((g.IO.ConfigFlags & ImGuiConfigFlags_NavEnableSetMousePos) && (g.IO.BackendFlags & ImGuiBackendFlags_HasSetMousePos))
{
if (!g.NavDisableHighlight && g.NavDisableMouseHover && g.NavWindow)
{
g.IO.MousePos = g.IO.MousePosPrev = NavCalcPreferredRefPos();
g.IO.WantSetMousePos = true;
}
}
g.NavMousePosDirty = false;
}
g.NavIdIsAlive = false;
g.NavJustTabbedId = 0;
IM_ASSERT(g.NavLayer == 0 || g.NavLayer == 1);
// Store our return window (for returning from Layer 1 to Layer 0) and clear it as soon as we step back in our own Layer 0
if (g.NavWindow)
NavSaveLastChildNavWindowIntoParent(g.NavWindow);
if (g.NavWindow && g.NavWindow->NavLastChildNavWindow != NULL && g.NavLayer == 0)
g.NavWindow->NavLastChildNavWindow = NULL;
// Update CTRL+TAB and Windowing features (hold Square to move/resize/etc.)
NavUpdateWindowing();
// Set output flags for user application
g.IO.NavActive = (nav_keyboard_active || nav_gamepad_active) && g.NavWindow && !(g.NavWindow->Flags & ImGuiWindowFlags_NoNavInputs);
g.IO.NavVisible = (g.IO.NavActive && g.NavId != 0 && !g.NavDisableHighlight) || (g.NavWindowingTarget != NULL);
// Process NavCancel input (to close a popup, get back to parent, clear focus)
if (IsNavInputPressed(ImGuiNavInput_Cancel, ImGuiInputReadMode_Pressed))
{
if (g.ActiveId != 0)
{
if (!(g.ActiveIdBlockNavInputFlags & (1 << ImGuiNavInput_Cancel)))
ClearActiveID();
}
else if (g.NavWindow && (g.NavWindow->Flags & ImGuiWindowFlags_ChildWindow) && !(g.NavWindow->Flags & ImGuiWindowFlags_Popup) && g.NavWindow->ParentWindow && g.NavWindow != g.NavWindow->RootWindowDockStop)
{
// Exit child window
ImGuiWindow* child_window = g.NavWindow;
ImGuiWindow* parent_window = g.NavWindow->ParentWindow;
IM_ASSERT(child_window->ChildId != 0);
FocusWindow(parent_window);
SetNavID(child_window->ChildId, 0);
g.NavIdIsAlive = false;
if (g.NavDisableMouseHover)
g.NavMousePosDirty = true;
}
else if (g.OpenPopupStack.Size > 0)
{
// Close open popup/menu
if (!(g.OpenPopupStack.back().Window->Flags & ImGuiWindowFlags_Modal))
ClosePopupToLevel(g.OpenPopupStack.Size - 1, true);
}
else if (g.NavLayer != 0)
{
// Leave the "menu" layer
NavRestoreLayer(ImGuiNavLayer_Main);
}
else
{
// Clear NavLastId for popups but keep it for regular child window so we can leave one and come back where we were
if (g.NavWindow && ((g.NavWindow->Flags & ImGuiWindowFlags_Popup) || !(g.NavWindow->Flags & ImGuiWindowFlags_ChildWindow)))
g.NavWindow->NavLastIds[0] = 0;
g.NavId = 0;
}
}
// Process manual activation request
g.NavActivateId = g.NavActivateDownId = g.NavActivatePressedId = g.NavInputId = 0;
if (g.NavId != 0 && !g.NavDisableHighlight && !g.NavWindowingTarget && g.NavWindow && !(g.NavWindow->Flags & ImGuiWindowFlags_NoNavInputs))
{
bool activate_down = IsNavInputDown(ImGuiNavInput_Activate);
bool activate_pressed = activate_down && IsNavInputPressed(ImGuiNavInput_Activate, ImGuiInputReadMode_Pressed);
if (g.ActiveId == 0 && activate_pressed)
g.NavActivateId = g.NavId;
if ((g.ActiveId == 0 || g.ActiveId == g.NavId) && activate_down)
g.NavActivateDownId = g.NavId;
if ((g.ActiveId == 0 || g.ActiveId == g.NavId) && activate_pressed)
g.NavActivatePressedId = g.NavId;
if ((g.ActiveId == 0 || g.ActiveId == g.NavId) && IsNavInputPressed(ImGuiNavInput_Input, ImGuiInputReadMode_Pressed))
g.NavInputId = g.NavId;
}
if (g.NavWindow && (g.NavWindow->Flags & ImGuiWindowFlags_NoNavInputs))
g.NavDisableHighlight = true;
if (g.NavActivateId != 0)
IM_ASSERT(g.NavActivateDownId == g.NavActivateId);
g.NavMoveRequest = false;
// Process programmatic activation request
if (g.NavNextActivateId != 0)
g.NavActivateId = g.NavActivateDownId = g.NavActivatePressedId = g.NavInputId = g.NavNextActivateId;
g.NavNextActivateId = 0;
// Initiate directional inputs request
const int allowed_dir_flags = (g.ActiveId == 0) ? ~0 : g.ActiveIdAllowNavDirFlags;
if (g.NavMoveRequestForward == ImGuiNavForward_None)
{
g.NavMoveDir = ImGuiDir_None;
g.NavMoveRequestFlags = ImGuiNavMoveFlags_None;
if (g.NavWindow && !g.NavWindowingTarget && allowed_dir_flags && !(g.NavWindow->Flags & ImGuiWindowFlags_NoNavInputs))
{
if ((allowed_dir_flags & (1<<ImGuiDir_Left)) && IsNavInputPressedAnyOfTwo(ImGuiNavInput_DpadLeft, ImGuiNavInput_KeyLeft_, ImGuiInputReadMode_Repeat)) g.NavMoveDir = ImGuiDir_Left;
if ((allowed_dir_flags & (1<<ImGuiDir_Right)) && IsNavInputPressedAnyOfTwo(ImGuiNavInput_DpadRight,ImGuiNavInput_KeyRight_,ImGuiInputReadMode_Repeat)) g.NavMoveDir = ImGuiDir_Right;
if ((allowed_dir_flags & (1<<ImGuiDir_Up)) && IsNavInputPressedAnyOfTwo(ImGuiNavInput_DpadUp, ImGuiNavInput_KeyUp_, ImGuiInputReadMode_Repeat)) g.NavMoveDir = ImGuiDir_Up;
if ((allowed_dir_flags & (1<<ImGuiDir_Down)) && IsNavInputPressedAnyOfTwo(ImGuiNavInput_DpadDown, ImGuiNavInput_KeyDown_, ImGuiInputReadMode_Repeat)) g.NavMoveDir = ImGuiDir_Down;
}
g.NavMoveClipDir = g.NavMoveDir;
}
else
{
// Forwarding previous request (which has been modified, e.g. wrap around menus rewrite the requests with a starting rectangle at the other side of the window)
// (Preserve g.NavMoveRequestFlags, g.NavMoveClipDir which were set by the NavMoveRequestForward() function)
IM_ASSERT(g.NavMoveDir != ImGuiDir_None && g.NavMoveClipDir != ImGuiDir_None);
IM_ASSERT(g.NavMoveRequestForward == ImGuiNavForward_ForwardQueued);
g.NavMoveRequestForward = ImGuiNavForward_ForwardActive;
}
// Update PageUp/PageDown scroll
float nav_scoring_rect_offset_y = 0.0f;
if (nav_keyboard_active)
nav_scoring_rect_offset_y = NavUpdatePageUpPageDown(allowed_dir_flags);
// If we initiate a movement request and have no current NavId, we initiate a InitDefautRequest that will be used as a fallback if the direction fails to find a match
if (g.NavMoveDir != ImGuiDir_None)
{
g.NavMoveRequest = true;
g.NavMoveDirLast = g.NavMoveDir;
}
if (g.NavMoveRequest && g.NavId == 0)
{
g.NavInitRequest = g.NavInitRequestFromMove = true;
g.NavInitResultId = 0;
g.NavDisableHighlight = false;
}
NavUpdateAnyRequestFlag();
// Scrolling
if (g.NavWindow && !(g.NavWindow->Flags & ImGuiWindowFlags_NoNavInputs) && !g.NavWindowingTarget)
{
// *Fallback* manual-scroll with Nav directional keys when window has no navigable item
ImGuiWindow* window = g.NavWindow;
const float scroll_speed = ImFloor(window->CalcFontSize() * 100 * g.IO.DeltaTime + 0.5f); // We need round the scrolling speed because sub-pixel scroll isn't reliably supported.
if (window->DC.NavLayerActiveMask == 0x00 && window->DC.NavHasScroll && g.NavMoveRequest)
{
if (g.NavMoveDir == ImGuiDir_Left || g.NavMoveDir == ImGuiDir_Right)
SetScrollX(window, ImFloor(window->Scroll.x + ((g.NavMoveDir == ImGuiDir_Left) ? -1.0f : +1.0f) * scroll_speed));
if (g.NavMoveDir == ImGuiDir_Up || g.NavMoveDir == ImGuiDir_Down)
SetScrollY(window, ImFloor(window->Scroll.y + ((g.NavMoveDir == ImGuiDir_Up) ? -1.0f : +1.0f) * scroll_speed));
}
// *Normal* Manual scroll with NavScrollXXX keys
// Next movement request will clamp the NavId reference rectangle to the visible area, so navigation will resume within those bounds.
ImVec2 scroll_dir = GetNavInputAmount2d(ImGuiNavDirSourceFlags_PadLStick, ImGuiInputReadMode_Down, 1.0f/10.0f, 10.0f);
if (scroll_dir.x != 0.0f && window->ScrollbarX)
{
SetScrollX(window, ImFloor(window->Scroll.x + scroll_dir.x * scroll_speed));
g.NavMoveFromClampedRefRect = true;
}
if (scroll_dir.y != 0.0f)
{
SetScrollY(window, ImFloor(window->Scroll.y + scroll_dir.y * scroll_speed));
g.NavMoveFromClampedRefRect = true;
}
}
// Reset search results
g.NavMoveResultLocal.Clear();
g.NavMoveResultLocalVisibleSet.Clear();
g.NavMoveResultOther.Clear();
// When we have manually scrolled (without using navigation) and NavId becomes out of bounds, we project its bounding box to the visible area to restart navigation within visible items
if (g.NavMoveRequest && g.NavMoveFromClampedRefRect && g.NavLayer == 0)
{
ImGuiWindow* window = g.NavWindow;
ImRect window_rect_rel(window->InnerRect.Min - window->Pos - ImVec2(1,1), window->InnerRect.Max - window->Pos + ImVec2(1,1));
if (!window_rect_rel.Contains(window->NavRectRel[g.NavLayer]))
{
float pad = window->CalcFontSize() * 0.5f;
window_rect_rel.Expand(ImVec2(-ImMin(window_rect_rel.GetWidth(), pad), -ImMin(window_rect_rel.GetHeight(), pad))); // Terrible approximation for the intent of starting navigation from first fully visible item
window->NavRectRel[g.NavLayer].ClipWith(window_rect_rel);
g.NavId = 0;
}
g.NavMoveFromClampedRefRect = false;
}
// For scoring we use a single segment on the left side our current item bounding box (not touching the edge to avoid box overlap with zero-spaced items)
ImRect nav_rect_rel = (g.NavWindow && !g.NavWindow->NavRectRel[g.NavLayer].IsInverted()) ? g.NavWindow->NavRectRel[g.NavLayer] : ImRect(0,0,0,0);
g.NavScoringRectScreen = g.NavWindow ? ImRect(g.NavWindow->Pos + nav_rect_rel.Min, g.NavWindow->Pos + nav_rect_rel.Max) : ImRect(0,0,0,0);
g.NavScoringRectScreen.TranslateY(nav_scoring_rect_offset_y);
g.NavScoringRectScreen.Min.x = ImMin(g.NavScoringRectScreen.Min.x + 1.0f, g.NavScoringRectScreen.Max.x);
g.NavScoringRectScreen.Max.x = g.NavScoringRectScreen.Min.x;
IM_ASSERT(!g.NavScoringRectScreen.IsInverted()); // Ensure if we have a finite, non-inverted bounding box here will allows us to remove extraneous ImFabs() calls in NavScoreItem().
//GetForegroundDrawList()->AddRect(g.NavScoringRectScreen.Min, g.NavScoringRectScreen.Max, IM_COL32(255,200,0,255)); // [DEBUG]
g.NavScoringCount = 0;
#if IMGUI_DEBUG_NAV_RECTS
if (g.NavWindow)
{
ImDrawList* draw_list = GetForegroundDrawList(g.NavWindow);
if (1) { for (int layer = 0; layer < 2; layer++) draw_list->AddRect(g.NavWindow->Pos + g.NavWindow->NavRectRel[layer].Min, g.NavWindow->Pos + g.NavWindow->NavRectRel[layer].Max, IM_COL32(255,200,0,255)); } // [DEBUG]
if (1) { ImU32 col = (!g.NavWindow->Hidden) ? IM_COL32(255,0,255,255) : IM_COL32(255,0,0,255); ImVec2 p = NavCalcPreferredRefPos(); char buf[32]; ImFormatString(buf, 32, "%d", g.NavLayer); draw_list->AddCircleFilled(p, 3.0f, col); draw_list->AddText(NULL, 13.0f, p + ImVec2(8,-4), col, buf); }
}
#endif
}
// Apply result from previous frame navigation directional move request
static void ImGui::NavUpdateMoveResult()
{
ImGuiContext& g = *GImGui;
if (g.NavMoveResultLocal.ID == 0 && g.NavMoveResultOther.ID == 0)
{
// In a situation when there is no results but NavId != 0, re-enable the Navigation highlight (because g.NavId is not considered as a possible result)
if (g.NavId != 0)
{
g.NavDisableHighlight = false;
g.NavDisableMouseHover = true;
}
return;
}
// Select which result to use
ImGuiNavMoveResult* result = (g.NavMoveResultLocal.ID != 0) ? &g.NavMoveResultLocal : &g.NavMoveResultOther;
// PageUp/PageDown behavior first jumps to the bottom/top mostly visible item, _otherwise_ use the result from the previous/next page.
if (g.NavMoveRequestFlags & ImGuiNavMoveFlags_AlsoScoreVisibleSet)
if (g.NavMoveResultLocalVisibleSet.ID != 0 && g.NavMoveResultLocalVisibleSet.ID != g.NavId)
result = &g.NavMoveResultLocalVisibleSet;
// Maybe entering a flattened child from the outside? In this case solve the tie using the regular scoring rules.
if (result != &g.NavMoveResultOther && g.NavMoveResultOther.ID != 0 && g.NavMoveResultOther.Window->ParentWindow == g.NavWindow)
if ((g.NavMoveResultOther.DistBox < result->DistBox) || (g.NavMoveResultOther.DistBox == result->DistBox && g.NavMoveResultOther.DistCenter < result->DistCenter))
result = &g.NavMoveResultOther;
IM_ASSERT(g.NavWindow && result->Window);
// Scroll to keep newly navigated item fully into view.
if (g.NavLayer == 0)
{
ImRect rect_abs = ImRect(result->RectRel.Min + result->Window->Pos, result->RectRel.Max + result->Window->Pos);
ImVec2 delta_scroll = ScrollToBringRectIntoView(result->Window, rect_abs);
// Offset our result position so mouse position can be applied immediately after in NavUpdate()
result->RectRel.TranslateX(-delta_scroll.x);
result->RectRel.TranslateY(-delta_scroll.y);
}
ClearActiveID();
g.NavWindow = result->Window;
if (g.NavId != result->ID)
{
// Don't set NavJustMovedToId if just landed on the same spot (which may happen with ImGuiNavMoveFlags_AllowCurrentNavId)
g.NavJustMovedToId = result->ID;
g.NavJustMovedToMultiSelectScopeId = result->SelectScopeId;
}
SetNavIDWithRectRel(result->ID, g.NavLayer, result->RectRel);
g.NavMoveFromClampedRefRect = false;
}
static float ImGui::NavUpdatePageUpPageDown(int allowed_dir_flags)
{
ImGuiContext& g = *GImGui;
if (g.NavMoveDir != ImGuiDir_None || g.NavWindow == NULL)
return 0.0f;
if ((g.NavWindow->Flags & ImGuiWindowFlags_NoNavInputs) || g.NavWindowingTarget != NULL || g.NavLayer != 0)
return 0.0f;
ImGuiWindow* window = g.NavWindow;
bool page_up_held = IsKeyDown(g.IO.KeyMap[ImGuiKey_PageUp]) && (allowed_dir_flags & (1 << ImGuiDir_Up));
bool page_down_held = IsKeyDown(g.IO.KeyMap[ImGuiKey_PageDown]) && (allowed_dir_flags & (1 << ImGuiDir_Down));
if (page_up_held != page_down_held) // If either (not both) are pressed
{
if (window->DC.NavLayerActiveMask == 0x00 && window->DC.NavHasScroll)
{
// Fallback manual-scroll when window has no navigable item
if (IsKeyPressed(g.IO.KeyMap[ImGuiKey_PageUp], true))
SetScrollY(window, window->Scroll.y - window->InnerRect.GetHeight());
else if (IsKeyPressed(g.IO.KeyMap[ImGuiKey_PageDown], true))
SetScrollY(window, window->Scroll.y + window->InnerRect.GetHeight());
}
else
{
const ImRect& nav_rect_rel = window->NavRectRel[g.NavLayer];
const float page_offset_y = ImMax(0.0f, window->InnerRect.GetHeight() - window->CalcFontSize() * 1.0f + nav_rect_rel.GetHeight());
float nav_scoring_rect_offset_y = 0.0f;
if (IsKeyPressed(g.IO.KeyMap[ImGuiKey_PageUp], true))
{
nav_scoring_rect_offset_y = -page_offset_y;
g.NavMoveDir = ImGuiDir_Down; // Because our scoring rect is offset, we intentionally request the opposite direction (so we can always land on the last item)
g.NavMoveClipDir = ImGuiDir_Up;
g.NavMoveRequestFlags = ImGuiNavMoveFlags_AllowCurrentNavId | ImGuiNavMoveFlags_AlsoScoreVisibleSet;
}
else if (IsKeyPressed(g.IO.KeyMap[ImGuiKey_PageDown], true))
{
nav_scoring_rect_offset_y = +page_offset_y;
g.NavMoveDir = ImGuiDir_Up; // Because our scoring rect is offset, we intentionally request the opposite direction (so we can always land on the last item)
g.NavMoveClipDir = ImGuiDir_Down;
g.NavMoveRequestFlags = ImGuiNavMoveFlags_AllowCurrentNavId | ImGuiNavMoveFlags_AlsoScoreVisibleSet;
}
return nav_scoring_rect_offset_y;
}
}
return 0.0f;
}
static int ImGui::FindWindowFocusIndex(ImGuiWindow* window) // FIXME-OPT O(N)
{
ImGuiContext& g = *GImGui;
for (int i = g.WindowsFocusOrder.Size-1; i >= 0; i--)
if (g.WindowsFocusOrder[i] == window)
return i;
return -1;
}
static ImGuiWindow* FindWindowNavFocusable(int i_start, int i_stop, int dir) // FIXME-OPT O(N)
{
ImGuiContext& g = *GImGui;
for (int i = i_start; i >= 0 && i < g.WindowsFocusOrder.Size && i != i_stop; i += dir)
if (ImGui::IsWindowNavFocusable(g.WindowsFocusOrder[i]))
return g.WindowsFocusOrder[i];
return NULL;
}
static void NavUpdateWindowingHighlightWindow(int focus_change_dir)
{
ImGuiContext& g = *GImGui;
IM_ASSERT(g.NavWindowingTarget);
if (g.NavWindowingTarget->Flags & ImGuiWindowFlags_Modal)
return;
const int i_current = ImGui::FindWindowFocusIndex(g.NavWindowingTarget);
ImGuiWindow* window_target = FindWindowNavFocusable(i_current + focus_change_dir, -INT_MAX, focus_change_dir);
if (!window_target)
window_target = FindWindowNavFocusable((focus_change_dir < 0) ? (g.WindowsFocusOrder.Size - 1) : 0, i_current, focus_change_dir);
if (window_target) // Don't reset windowing target if there's a single window in the list
g.NavWindowingTarget = g.NavWindowingTargetAnim = window_target;
g.NavWindowingToggleLayer = false;
}
// Windowing management mode
// Keyboard: CTRL+Tab (change focus/move/resize), Alt (toggle menu layer)
// Gamepad: Hold Menu/Square (change focus/move/resize), Tap Menu/Square (toggle menu layer)
static void ImGui::NavUpdateWindowing()
{
ImGuiContext& g = *GImGui;
ImGuiWindow* apply_focus_window = NULL;
bool apply_toggle_layer = false;
ImGuiWindow* modal_window = GetTopMostPopupModal();
if (modal_window != NULL)
{
g.NavWindowingTarget = NULL;
return;
}
// Fade out
if (g.NavWindowingTargetAnim && g.NavWindowingTarget == NULL)
{
g.NavWindowingHighlightAlpha = ImMax(g.NavWindowingHighlightAlpha - g.IO.DeltaTime * 10.0f, 0.0f);
if (g.DimBgRatio <= 0.0f && g.NavWindowingHighlightAlpha <= 0.0f)
g.NavWindowingTargetAnim = NULL;
}
// Start CTRL-TAB or Square+L/R window selection
bool start_windowing_with_gamepad = !g.NavWindowingTarget && IsNavInputPressed(ImGuiNavInput_Menu, ImGuiInputReadMode_Pressed);
bool start_windowing_with_keyboard = !g.NavWindowingTarget && g.IO.KeyCtrl && IsKeyPressedMap(ImGuiKey_Tab) && (g.IO.ConfigFlags & ImGuiConfigFlags_NavEnableKeyboard);
if (start_windowing_with_gamepad || start_windowing_with_keyboard)
if (ImGuiWindow* window = g.NavWindow ? g.NavWindow : FindWindowNavFocusable(g.WindowsFocusOrder.Size - 1, -INT_MAX, -1))
{
g.NavWindowingTarget = g.NavWindowingTargetAnim = window;
g.NavWindowingTimer = g.NavWindowingHighlightAlpha = 0.0f;
g.NavWindowingToggleLayer = start_windowing_with_keyboard ? false : true;
g.NavInputSource = start_windowing_with_keyboard ? ImGuiInputSource_NavKeyboard : ImGuiInputSource_NavGamepad;
}
// Gamepad update
g.NavWindowingTimer += g.IO.DeltaTime;
if (g.NavWindowingTarget && g.NavInputSource == ImGuiInputSource_NavGamepad)
{
// Highlight only appears after a brief time holding the button, so that a fast tap on PadMenu (to toggle NavLayer) doesn't add visual noise
g.NavWindowingHighlightAlpha = ImMax(g.NavWindowingHighlightAlpha, ImSaturate((g.NavWindowingTimer - NAV_WINDOWING_HIGHLIGHT_DELAY) / 0.05f));
// Select window to focus
const int focus_change_dir = (int)IsNavInputPressed(ImGuiNavInput_FocusPrev, ImGuiInputReadMode_RepeatSlow) - (int)IsNavInputPressed(ImGuiNavInput_FocusNext, ImGuiInputReadMode_RepeatSlow);
if (focus_change_dir != 0)
{
NavUpdateWindowingHighlightWindow(focus_change_dir);
g.NavWindowingHighlightAlpha = 1.0f;
}
// Single press toggles NavLayer, long press with L/R apply actual focus on release (until then the window was merely rendered top-most)
if (!IsNavInputDown(ImGuiNavInput_Menu))
{
g.NavWindowingToggleLayer &= (g.NavWindowingHighlightAlpha < 1.0f); // Once button was held long enough we don't consider it a tap-to-toggle-layer press anymore.
if (g.NavWindowingToggleLayer && g.NavWindow)
apply_toggle_layer = true;
else if (!g.NavWindowingToggleLayer)
apply_focus_window = g.NavWindowingTarget;
g.NavWindowingTarget = NULL;
}
}
// Keyboard: Focus
if (g.NavWindowingTarget && g.NavInputSource == ImGuiInputSource_NavKeyboard)
{
// Visuals only appears after a brief time after pressing TAB the first time, so that a fast CTRL+TAB doesn't add visual noise
g.NavWindowingHighlightAlpha = ImMax(g.NavWindowingHighlightAlpha, ImSaturate((g.NavWindowingTimer - NAV_WINDOWING_HIGHLIGHT_DELAY) / 0.05f)); // 1.0f
if (IsKeyPressedMap(ImGuiKey_Tab, true))
NavUpdateWindowingHighlightWindow(g.IO.KeyShift ? +1 : -1);
if (!g.IO.KeyCtrl)
apply_focus_window = g.NavWindowingTarget;
}
// Keyboard: Press and Release ALT to toggle menu layer
// FIXME: We lack an explicit IO variable for "is the imgui window focused", so compare mouse validity to detect the common case of back-end clearing releases all keys on ALT-TAB
if (IsNavInputPressed(ImGuiNavInput_KeyMenu_, ImGuiInputReadMode_Pressed))
g.NavWindowingToggleLayer = true;
if ((g.ActiveId == 0 || g.ActiveIdAllowOverlap) && g.NavWindowingToggleLayer && IsNavInputPressed(ImGuiNavInput_KeyMenu_, ImGuiInputReadMode_Released))
if (IsMousePosValid(&g.IO.MousePos) == IsMousePosValid(&g.IO.MousePosPrev))
apply_toggle_layer = true;
// Move window
if (g.NavWindowingTarget && !(g.NavWindowingTarget->Flags & ImGuiWindowFlags_NoMove))
{
ImVec2 move_delta;
if (g.NavInputSource == ImGuiInputSource_NavKeyboard && !g.IO.KeyShift)
move_delta = GetNavInputAmount2d(ImGuiNavDirSourceFlags_Keyboard, ImGuiInputReadMode_Down);
if (g.NavInputSource == ImGuiInputSource_NavGamepad)
move_delta = GetNavInputAmount2d(ImGuiNavDirSourceFlags_PadLStick, ImGuiInputReadMode_Down);
if (move_delta.x != 0.0f || move_delta.y != 0.0f)
{
const float NAV_MOVE_SPEED = 800.0f;
const float move_speed = ImFloor(NAV_MOVE_SPEED * g.IO.DeltaTime * ImMin(g.IO.DisplayFramebufferScale.x, g.IO.DisplayFramebufferScale.y)); // FIXME: Doesn't code variable framerate very well
SetWindowPos(g.NavWindowingTarget->RootWindow, g.NavWindowingTarget->RootWindow->Pos + move_delta * move_speed, ImGuiCond_Always);
g.NavDisableMouseHover = true;
MarkIniSettingsDirty(g.NavWindowingTarget);
}
}
// Apply final focus
if (apply_focus_window && (g.NavWindow == NULL || apply_focus_window != g.NavWindow->RootWindowDockStop))
{
ImGuiViewport* previous_viewport = g.NavWindow ? g.NavWindow->Viewport : NULL;
ClearActiveID();
g.NavDisableHighlight = false;
g.NavDisableMouseHover = true;
apply_focus_window = NavRestoreLastChildNavWindow(apply_focus_window);
ClosePopupsOverWindow(apply_focus_window, false);
FocusWindow(apply_focus_window);
if (apply_focus_window->NavLastIds[0] == 0)
NavInitWindow(apply_focus_window, false);
// If the window only has a menu layer, select it directly
if (apply_focus_window->DC.NavLayerActiveMask == (1 << ImGuiNavLayer_Menu))
g.NavLayer = ImGuiNavLayer_Menu;
// Request OS level focus
if (apply_focus_window->Viewport != previous_viewport && g.PlatformIO.Platform_SetWindowFocus)
g.PlatformIO.Platform_SetWindowFocus(apply_focus_window->Viewport);
}
if (apply_focus_window)
g.NavWindowingTarget = NULL;
// Apply menu/layer toggle
if (apply_toggle_layer && g.NavWindow)
{
// Move to parent menu if necessary
ImGuiWindow* new_nav_window = g.NavWindow;
while (new_nav_window->ParentWindow
&& (new_nav_window->DC.NavLayerActiveMask & (1 << ImGuiNavLayer_Menu)) == 0
&& (new_nav_window->Flags & ImGuiWindowFlags_ChildWindow) != 0
&& (new_nav_window->Flags & (ImGuiWindowFlags_Popup | ImGuiWindowFlags_ChildMenu)) == 0)
new_nav_window = new_nav_window->ParentWindow;
if (new_nav_window != g.NavWindow)
{
ImGuiWindow* old_nav_window = g.NavWindow;
FocusWindow(new_nav_window);
new_nav_window->NavLastChildNavWindow = old_nav_window;
}
g.NavDisableHighlight = false;
g.NavDisableMouseHover = true;
// When entering a regular menu bar with the Alt key, we always reinitialize the navigation ID. It however persist on docking tab tabs.
const ImGuiNavLayer new_nav_layer = (g.NavWindow->DC.NavLayerActiveMask & (1 << ImGuiNavLayer_Menu)) ? (ImGuiNavLayer)((int)g.NavLayer ^ 1) : ImGuiNavLayer_Main;
const bool preserve_layer_1_nav_id = (new_nav_window->DockNodeAsHost != NULL);
if (new_nav_layer == ImGuiNavLayer_Menu && !preserve_layer_1_nav_id)
g.NavWindow->NavLastIds[ImGuiNavLayer_Menu] = 0;
NavRestoreLayer(new_nav_layer);
}
}
// Window has already passed the IsWindowNavFocusable()
static const char* GetFallbackWindowNameForWindowingList(ImGuiWindow* window)
{
if (window->Flags & ImGuiWindowFlags_Popup)
return "(Popup)";
if ((window->Flags & ImGuiWindowFlags_MenuBar) && strcmp(window->Name, "##MainMenuBar") == 0)
return "(Main menu bar)";
if (window->DockNodeAsHost)
return "(Dock node)";
return "(Untitled)";
}
// Overlay displayed when using CTRL+TAB. Called by EndFrame().
void ImGui::NavUpdateWindowingList()
{
ImGuiContext& g = *GImGui;
IM_ASSERT(g.NavWindowingTarget != NULL);
if (g.NavWindowingTimer < NAV_WINDOWING_LIST_APPEAR_DELAY)
return;
if (g.NavWindowingList == NULL)
g.NavWindowingList = FindWindowByName("###NavWindowingList");
ImGuiViewportP* viewport = /*g.NavWindow ? g.NavWindow->Viewport :*/ (ImGuiViewportP*)GetMainViewport();
SetNextWindowSizeConstraints(ImVec2(viewport->Size.x * 0.20f, viewport->Size.y * 0.20f), ImVec2(FLT_MAX, FLT_MAX));
SetNextWindowPos(viewport->Pos + viewport->Size * 0.5f, ImGuiCond_Always, ImVec2(0.5f, 0.5f));
PushStyleVar(ImGuiStyleVar_WindowPadding, g.Style.WindowPadding * 2.0f);
Begin("###NavWindowingList", NULL, ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoFocusOnAppearing | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoInputs | ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoSavedSettings);
for (int n = g.WindowsFocusOrder.Size - 1; n >= 0; n--)
{
ImGuiWindow* window = g.WindowsFocusOrder[n];
if (!IsWindowNavFocusable(window))
continue;
const char* label = window->Name;
if (label == FindRenderedTextEnd(label))
label = GetFallbackWindowNameForWindowingList(window);
Selectable(label, g.NavWindowingTarget == window);
}
End();
PopStyleVar();
}
//-----------------------------------------------------------------------------
// [SECTION] DRAG AND DROP
//-----------------------------------------------------------------------------
void ImGui::ClearDragDrop()
{
ImGuiContext& g = *GImGui;
g.DragDropActive = false;
g.DragDropPayload.Clear();
g.DragDropAcceptFlags = ImGuiDragDropFlags_None;
g.DragDropAcceptIdCurr = g.DragDropAcceptIdPrev = 0;
g.DragDropAcceptIdCurrRectSurface = FLT_MAX;
g.DragDropAcceptFrameCount = -1;
g.DragDropPayloadBufHeap.clear();
memset(&g.DragDropPayloadBufLocal, 0, sizeof(g.DragDropPayloadBufLocal));
}
// Call when current ID is active.
// When this returns true you need to: a) call SetDragDropPayload() exactly once, b) you may render the payload visual/description, c) call EndDragDropSource()
bool ImGui::BeginDragDropSource(ImGuiDragDropFlags flags)
{
ImGuiContext& g = *GImGui;
ImGuiWindow* window = g.CurrentWindow;
bool source_drag_active = false;
ImGuiID source_id = 0;
ImGuiID source_parent_id = 0;
int mouse_button = 0;
if (!(flags & ImGuiDragDropFlags_SourceExtern))
{
source_id = window->DC.LastItemId;
if (source_id != 0 && g.ActiveId != source_id) // Early out for most common case
return false;
if (g.IO.MouseDown[mouse_button] == false)
return false;
if (source_id == 0)
{
// If you want to use BeginDragDropSource() on an item with no unique identifier for interaction, such as Text() or Image(), you need to:
// A) Read the explanation below, B) Use the ImGuiDragDropFlags_SourceAllowNullID flag, C) Swallow your programmer pride.
if (!(flags & ImGuiDragDropFlags_SourceAllowNullID))
{
IM_ASSERT(0);
return false;
}
// Early out
if ((window->DC.LastItemStatusFlags & ImGuiItemStatusFlags_HoveredRect) == 0 && (g.ActiveId == 0 || g.ActiveIdWindow != window))
return false;
// Magic fallback (=somehow reprehensible) to handle items with no assigned ID, e.g. Text(), Image()
// We build a throwaway ID based on current ID stack + relative AABB of items in window.
// THE IDENTIFIER WON'T SURVIVE ANY REPOSITIONING OF THE WIDGET, so if your widget moves your dragging operation will be canceled.
// We don't need to maintain/call ClearActiveID() as releasing the button will early out this function and trigger !ActiveIdIsAlive.
source_id = window->DC.LastItemId = window->GetIDFromRectangle(window->DC.LastItemRect);
bool is_hovered = ItemHoverable(window->DC.LastItemRect, source_id);
if (is_hovered && g.IO.MouseClicked[mouse_button])
{
SetActiveID(source_id, window);
FocusWindow(window);
}
if (g.ActiveId == source_id) // Allow the underlying widget to display/return hovered during the mouse release frame, else we would get a flicker.
g.ActiveIdAllowOverlap = is_hovered;
}
else
{
g.ActiveIdAllowOverlap = false;
}
if (g.ActiveId != source_id)
return false;
source_parent_id = window->IDStack.back();
source_drag_active = IsMouseDragging(mouse_button);
}
else
{
window = NULL;
source_id = ImHashStr("#SourceExtern");
source_drag_active = true;
}
if (source_drag_active)
{
if (!g.DragDropActive)
{
IM_ASSERT(source_id != 0);
ClearDragDrop();
ImGuiPayload& payload = g.DragDropPayload;
payload.SourceId = source_id;
payload.SourceParentId = source_parent_id;
g.DragDropActive = true;
g.DragDropSourceFlags = flags;
g.DragDropMouseButton = mouse_button;
}
g.DragDropSourceFrameCount = g.FrameCount;
g.DragDropWithinSourceOrTarget = true;
if (!(flags & ImGuiDragDropFlags_SourceNoPreviewTooltip))
{
// Target can request the Source to not display its tooltip (we use a dedicated flag to make this request explicit)
// We unfortunately can't just modify the source flags and skip the call to BeginTooltip, as caller may be emitting contents.
BeginTooltip();
if (g.DragDropAcceptIdPrev && (g.DragDropAcceptFlags & ImGuiDragDropFlags_AcceptNoPreviewTooltip))
{
ImGuiWindow* tooltip_window = g.CurrentWindow;
tooltip_window->SkipItems = true;
tooltip_window->HiddenFramesCanSkipItems = 1;
}
}
if (!(flags & ImGuiDragDropFlags_SourceNoDisableHover) && !(flags & ImGuiDragDropFlags_SourceExtern))
window->DC.LastItemStatusFlags &= ~ImGuiItemStatusFlags_HoveredRect;
return true;
}
return false;
}
void ImGui::EndDragDropSource()
{
ImGuiContext& g = *GImGui;
IM_ASSERT(g.DragDropActive);
IM_ASSERT(g.DragDropWithinSourceOrTarget && "Not after a BeginDragDropSource()?");
if (!(g.DragDropSourceFlags & ImGuiDragDropFlags_SourceNoPreviewTooltip))
EndTooltip();
// Discard the drag if have not called SetDragDropPayload()
if (g.DragDropPayload.DataFrameCount == -1)
ClearDragDrop();
g.DragDropWithinSourceOrTarget = false;
}
// Use 'cond' to choose to submit payload on drag start or every frame
bool ImGui::SetDragDropPayload(const char* type, const void* data, size_t data_size, ImGuiCond cond)
{
ImGuiContext& g = *GImGui;
ImGuiPayload& payload = g.DragDropPayload;
if (cond == 0)
cond = ImGuiCond_Always;
IM_ASSERT(type != NULL);
IM_ASSERT(strlen(type) < IM_ARRAYSIZE(payload.DataType) && "Payload type can be at most 32 characters long");
IM_ASSERT((data != NULL && data_size > 0) || (data == NULL && data_size == 0));
IM_ASSERT(cond == ImGuiCond_Always || cond == ImGuiCond_Once);
IM_ASSERT(payload.SourceId != 0); // Not called between BeginDragDropSource() and EndDragDropSource()
if (cond == ImGuiCond_Always || payload.DataFrameCount == -1)
{
// Copy payload
ImStrncpy(payload.DataType, type, IM_ARRAYSIZE(payload.DataType));
g.DragDropPayloadBufHeap.resize(0);
if (data_size > sizeof(g.DragDropPayloadBufLocal))
{
// Store in heap
g.DragDropPayloadBufHeap.resize((int)data_size);
payload.Data = g.DragDropPayloadBufHeap.Data;
memcpy(payload.Data, data, data_size);
}
else if (data_size > 0)
{
// Store locally
memset(&g.DragDropPayloadBufLocal, 0, sizeof(g.DragDropPayloadBufLocal));
payload.Data = g.DragDropPayloadBufLocal;
memcpy(payload.Data, data, data_size);
}
else
{
payload.Data = NULL;
}
payload.DataSize = (int)data_size;
}
payload.DataFrameCount = g.FrameCount;
return (g.DragDropAcceptFrameCount == g.FrameCount) || (g.DragDropAcceptFrameCount == g.FrameCount - 1);
}
bool ImGui::BeginDragDropTargetCustom(const ImRect& bb, ImGuiID id)
{
ImGuiContext& g = *GImGui;
if (!g.DragDropActive)
return false;
ImGuiWindow* window = g.CurrentWindow;
if (g.HoveredWindowUnderMovingWindow == NULL || window->RootWindow != g.HoveredWindowUnderMovingWindow->RootWindow)
return false;
IM_ASSERT(id != 0);
if (!IsMouseHoveringRect(bb.Min, bb.Max) || (id == g.DragDropPayload.SourceId))
return false;
if (window->SkipItems)
return false;
IM_ASSERT(g.DragDropWithinSourceOrTarget == false);
g.DragDropTargetRect = bb;
g.DragDropTargetId = id;
g.DragDropWithinSourceOrTarget = true;
return true;
}
// We don't use BeginDragDropTargetCustom() and duplicate its code because:
// 1) we use LastItemRectHoveredRect which handles items that pushes a temporarily clip rectangle in their code. Calling BeginDragDropTargetCustom(LastItemRect) would not handle them.
// 2) and it's faster. as this code may be very frequently called, we want to early out as fast as we can.
// Also note how the HoveredWindow test is positioned differently in both functions (in both functions we optimize for the cheapest early out case)
bool ImGui::BeginDragDropTarget()
{
ImGuiContext& g = *GImGui;
if (!g.DragDropActive)
return false;
ImGuiWindow* window = g.CurrentWindow;
if (!(window->DC.LastItemStatusFlags & ImGuiItemStatusFlags_HoveredRect))
return false;
if (g.HoveredWindowUnderMovingWindow == NULL || window->RootWindow != g.HoveredWindowUnderMovingWindow->RootWindow)
return false;
const ImRect& display_rect = (window->DC.LastItemStatusFlags & ImGuiItemStatusFlags_HasDisplayRect) ? window->DC.LastItemDisplayRect : window->DC.LastItemRect;
ImGuiID id = window->DC.LastItemId;
if (id == 0)
id = window->GetIDFromRectangle(display_rect);
if (g.DragDropPayload.SourceId == id)
return false;
IM_ASSERT(g.DragDropWithinSourceOrTarget == false);
g.DragDropTargetRect = display_rect;
g.DragDropTargetId = id;
g.DragDropWithinSourceOrTarget = true;
return true;
}
bool ImGui::IsDragDropPayloadBeingAccepted()
{
ImGuiContext& g = *GImGui;
return g.DragDropActive && g.DragDropAcceptIdPrev != 0;
}
const ImGuiPayload* ImGui::AcceptDragDropPayload(const char* type, ImGuiDragDropFlags flags)
{
ImGuiContext& g = *GImGui;
ImGuiWindow* window = g.CurrentWindow;
ImGuiPayload& payload = g.DragDropPayload;
IM_ASSERT(g.DragDropActive); // Not called between BeginDragDropTarget() and EndDragDropTarget() ?
IM_ASSERT(payload.DataFrameCount != -1); // Forgot to call EndDragDropTarget() ?
if (type != NULL && !payload.IsDataType(type))
return NULL;
// Accept smallest drag target bounding box, this allows us to nest drag targets conveniently without ordering constraints.
// NB: We currently accept NULL id as target. However, overlapping targets requires a unique ID to function!
const bool was_accepted_previously = (g.DragDropAcceptIdPrev == g.DragDropTargetId);
ImRect r = g.DragDropTargetRect;
float r_surface = r.GetWidth() * r.GetHeight();
if (r_surface < g.DragDropAcceptIdCurrRectSurface)
{
g.DragDropAcceptFlags = flags;
g.DragDropAcceptIdCurr = g.DragDropTargetId;
g.DragDropAcceptIdCurrRectSurface = r_surface;
}
// Render default drop visuals
payload.Preview = was_accepted_previously;
flags |= (g.DragDropSourceFlags & ImGuiDragDropFlags_AcceptNoDrawDefaultRect); // Source can also inhibit the preview (useful for external sources that lives for 1 frame)
if (!(flags & ImGuiDragDropFlags_AcceptNoDrawDefaultRect) && payload.Preview)
{
// FIXME-DRAG: Settle on a proper default visuals for drop target.
r.Expand(3.5f);
bool push_clip_rect = !window->ClipRect.Contains(r);
if (push_clip_rect) window->DrawList->PushClipRect(r.Min-ImVec2(1,1), r.Max+ImVec2(1,1));
window->DrawList->AddRect(r.Min, r.Max, GetColorU32(ImGuiCol_DragDropTarget), 0.0f, ~0, 2.0f);
if (push_clip_rect) window->DrawList->PopClipRect();
}
g.DragDropAcceptFrameCount = g.FrameCount;
payload.Delivery = was_accepted_previously && !IsMouseDown(g.DragDropMouseButton); // For extern drag sources affecting os window focus, it's easier to just test !IsMouseDown() instead of IsMouseReleased()
if (!payload.Delivery && !(flags & ImGuiDragDropFlags_AcceptBeforeDelivery))
return NULL;
return &payload;
}
const ImGuiPayload* ImGui::GetDragDropPayload()
{
ImGuiContext& g = *GImGui;
return g.DragDropActive ? &g.DragDropPayload : NULL;
}
// We don't really use/need this now, but added it for the sake of consistency and because we might need it later.
void ImGui::EndDragDropTarget()
{
ImGuiContext& g = *GImGui;
IM_ASSERT(g.DragDropActive);
IM_ASSERT(g.DragDropWithinSourceOrTarget);
g.DragDropWithinSourceOrTarget = false;
}
//-----------------------------------------------------------------------------
// [SECTION] LOGGING/CAPTURING
//-----------------------------------------------------------------------------
// All text output from the interface can be captured into tty/file/clipboard.
// By default, tree nodes are automatically opened during logging.
//-----------------------------------------------------------------------------
// Pass text data straight to log (without being displayed)
void ImGui::LogText(const char* fmt, ...)
{
ImGuiContext& g = *GImGui;
if (!g.LogEnabled)
return;
va_list args;
va_start(args, fmt);
if (g.LogFile)
vfprintf(g.LogFile, fmt, args);
else
g.LogBuffer.appendfv(fmt, args);
va_end(args);
}
// Internal version that takes a position to decide on newline placement and pad items according to their depth.
// We split text into individual lines to add current tree level padding
void ImGui::LogRenderedText(const ImVec2* ref_pos, const char* text, const char* text_end)
{
ImGuiContext& g = *GImGui;
ImGuiWindow* window = g.CurrentWindow;
if (!text_end)
text_end = FindRenderedTextEnd(text, text_end);
const bool log_new_line = ref_pos && (ref_pos->y > g.LogLinePosY + 1);
if (ref_pos)
g.LogLinePosY = ref_pos->y;
if (log_new_line)
g.LogLineFirstItem = true;
const char* text_remaining = text;
if (g.LogDepthRef > window->DC.TreeDepth) // Re-adjust padding if we have popped out of our starting depth
g.LogDepthRef = window->DC.TreeDepth;
const int tree_depth = (window->DC.TreeDepth - g.LogDepthRef);
for (;;)
{
// Split the string. Each new line (after a '\n') is followed by spacing corresponding to the current depth of our log entry.
// We don't add a trailing \n to allow a subsequent item on the same line to be captured.
const char* line_start = text_remaining;
const char* line_end = ImStreolRange(line_start, text_end);
const bool is_first_line = (line_start == text);
const bool is_last_line = (line_end == text_end);
if (!is_last_line || (line_start != line_end))
{
const int char_count = (int)(line_end - line_start);
if (log_new_line || !is_first_line)
LogText(IM_NEWLINE "%*s%.*s", tree_depth * 4, "", char_count, line_start);
else if (g.LogLineFirstItem)
LogText("%*s%.*s", tree_depth * 4, "", char_count, line_start);
else
LogText(" %.*s", char_count, line_start);
g.LogLineFirstItem = false;
}
else if (log_new_line)
{
// An empty "" string at a different Y position should output a carriage return.
LogText(IM_NEWLINE);
break;
}
if (is_last_line)
break;
text_remaining = line_end + 1;
}
}
// Start logging/capturing text output
void ImGui::LogBegin(ImGuiLogType type, int auto_open_depth)
{
ImGuiContext& g = *GImGui;
ImGuiWindow* window = g.CurrentWindow;
IM_ASSERT(g.LogEnabled == false);
IM_ASSERT(g.LogFile == NULL);
IM_ASSERT(g.LogBuffer.empty());
g.LogEnabled = true;
g.LogType = type;
g.LogDepthRef = window->DC.TreeDepth;
g.LogDepthToExpand = ((auto_open_depth >= 0) ? auto_open_depth : g.LogDepthToExpandDefault);
g.LogLinePosY = FLT_MAX;
g.LogLineFirstItem = true;
}
void ImGui::LogToTTY(int auto_open_depth)
{
ImGuiContext& g = *GImGui;
if (g.LogEnabled)
return;
LogBegin(ImGuiLogType_TTY, auto_open_depth);
g.LogFile = stdout;
}
// Start logging/capturing text output to given file
void ImGui::LogToFile(int auto_open_depth, const char* filename)
{
ImGuiContext& g = *GImGui;
if (g.LogEnabled)
return;
// FIXME: We could probably open the file in text mode "at", however note that clipboard/buffer logging will still
// be subject to outputting OS-incompatible carriage return if within strings the user doesn't use IM_NEWLINE.
// By opening the file in binary mode "ab" we have consistent output everywhere.
if (!filename)
filename = g.IO.LogFilename;
if (!filename || !filename[0])
return;
FILE* f = ImFileOpen(filename, "ab");
if (f == NULL)
{
IM_ASSERT(0);
return;
}
LogBegin(ImGuiLogType_File, auto_open_depth);
g.LogFile = f;
}
// Start logging/capturing text output to clipboard
void ImGui::LogToClipboard(int auto_open_depth)
{
ImGuiContext& g = *GImGui;
if (g.LogEnabled)
return;
LogBegin(ImGuiLogType_Clipboard, auto_open_depth);
}
void ImGui::LogToBuffer(int auto_open_depth)
{
ImGuiContext& g = *GImGui;
if (g.LogEnabled)
return;
LogBegin(ImGuiLogType_Buffer, auto_open_depth);
}
void ImGui::LogFinish()
{
ImGuiContext& g = *GImGui;
if (!g.LogEnabled)
return;
LogText(IM_NEWLINE);
switch (g.LogType)
{
case ImGuiLogType_TTY:
fflush(g.LogFile);
break;
case ImGuiLogType_File:
fclose(g.LogFile);
break;
case ImGuiLogType_Buffer:
break;
case ImGuiLogType_Clipboard:
if (!g.LogBuffer.empty())
SetClipboardText(g.LogBuffer.begin());
break;
case ImGuiLogType_None:
IM_ASSERT(0);
break;
}
g.LogEnabled = false;
g.LogType = ImGuiLogType_None;
g.LogFile = NULL;
g.LogBuffer.clear();
}
// Helper to display logging buttons
// FIXME-OBSOLETE: We should probably obsolete this and let the user have their own helper (this is one of the oldest function alive!)
void ImGui::LogButtons()
{
ImGuiContext& g = *GImGui;
PushID("LogButtons");
const bool log_to_tty = Button("Log To TTY"); SameLine();
const bool log_to_file = Button("Log To File"); SameLine();
const bool log_to_clipboard = Button("Log To Clipboard"); SameLine();
PushAllowKeyboardFocus(false);
SetNextItemWidth(80.0f);
SliderInt("Default Depth", &g.LogDepthToExpandDefault, 0, 9, NULL);
PopAllowKeyboardFocus();
PopID();
// Start logging at the end of the function so that the buttons don't appear in the log
if (log_to_tty)
LogToTTY();
if (log_to_file)
LogToFile();
if (log_to_clipboard)
LogToClipboard();
}
//-----------------------------------------------------------------------------
// [SECTION] SETTINGS
//-----------------------------------------------------------------------------
void ImGui::MarkIniSettingsDirty()
{
ImGuiContext& g = *GImGui;
if (g.SettingsDirtyTimer <= 0.0f)
g.SettingsDirtyTimer = g.IO.IniSavingRate;
}
void ImGui::MarkIniSettingsDirty(ImGuiWindow* window)
{
ImGuiContext& g = *GImGui;
if (!(window->Flags & ImGuiWindowFlags_NoSavedSettings))
if (g.SettingsDirtyTimer <= 0.0f)
g.SettingsDirtyTimer = g.IO.IniSavingRate;
}
ImGuiWindowSettings* ImGui::CreateNewWindowSettings(const char* name)
{
ImGuiContext& g = *GImGui;
g.SettingsWindows.push_back(ImGuiWindowSettings());
ImGuiWindowSettings* settings = &g.SettingsWindows.back();
#if !IMGUI_DEBUG_INI_SETTINGS
// Skip to the "###" marker if any. We don't skip past to match the behavior of GetID()
// Preserve the full string when IMGUI_DEBUG_INI_SETTINGS is set to make .ini inspection easier.
if (const char* p = strstr(name, "###"))
name = p;
#endif
settings->Name = ImStrdup(name);
settings->ID = ImHashStr(name);
return settings;
}
ImGuiWindowSettings* ImGui::FindWindowSettings(ImGuiID id)
{
ImGuiContext& g = *GImGui;
for (int i = 0; i != g.SettingsWindows.Size; i++)
if (g.SettingsWindows[i].ID == id)
return &g.SettingsWindows[i];
return NULL;
}
ImGuiWindowSettings* ImGui::FindOrCreateWindowSettings(const char* name)
{
if (ImGuiWindowSettings* settings = FindWindowSettings(ImHashStr(name)))
return settings;
return CreateNewWindowSettings(name);
}
void ImGui::LoadIniSettingsFromDisk(const char* ini_filename)
{
size_t file_data_size = 0;
char* file_data = (char*)ImFileLoadToMemory(ini_filename, "rb", &file_data_size);
if (!file_data)
return;
LoadIniSettingsFromMemory(file_data, (size_t)file_data_size);
IM_FREE(file_data);
}
ImGuiSettingsHandler* ImGui::FindSettingsHandler(const char* type_name)
{
ImGuiContext& g = *GImGui;
const ImGuiID type_hash = ImHashStr(type_name);
for (int handler_n = 0; handler_n < g.SettingsHandlers.Size; handler_n++)
if (g.SettingsHandlers[handler_n].TypeHash == type_hash)
return &g.SettingsHandlers[handler_n];
return NULL;
}
// Zero-tolerance, no error reporting, cheap .ini parsing
void ImGui::LoadIniSettingsFromMemory(const char* ini_data, size_t ini_size)
{
ImGuiContext& g = *GImGui;
IM_ASSERT(g.Initialized);
IM_ASSERT(g.SettingsLoaded == false && g.FrameCount == 0);
// For user convenience, we allow passing a non zero-terminated string (hence the ini_size parameter).
// For our convenience and to make the code simpler, we'll also write zero-terminators within the buffer. So let's create a writable copy..
if (ini_size == 0)
ini_size = strlen(ini_data);
char* buf = (char*)IM_ALLOC(ini_size + 1);
char* buf_end = buf + ini_size;
memcpy(buf, ini_data, ini_size);
buf[ini_size] = 0;
void* entry_data = NULL;
ImGuiSettingsHandler* entry_handler = NULL;
char* line_end = NULL;
for (char* line = buf; line < buf_end; line = line_end + 1)
{
// Skip new lines markers, then find end of the line
while (*line == '\n' || *line == '\r')
line++;
line_end = line;
while (line_end < buf_end && *line_end != '\n' && *line_end != '\r')
line_end++;
line_end[0] = 0;
if (line[0] == ';')
continue;
if (line[0] == '[' && line_end > line && line_end[-1] == ']')
{
// Parse "[Type][Name]". Note that 'Name' can itself contains [] characters, which is acceptable with the current format and parsing code.
line_end[-1] = 0;
const char* name_end = line_end - 1;
const char* type_start = line + 1;
char* type_end = (char*)(intptr_t)ImStrchrRange(type_start, name_end, ']');
const char* name_start = type_end ? ImStrchrRange(type_end + 1, name_end, '[') : NULL;
if (!type_end || !name_start)
{
name_start = type_start; // Import legacy entries that have no type
type_start = "Window";
}
else
{
*type_end = 0; // Overwrite first ']'
name_start++; // Skip second '['
}
entry_handler = FindSettingsHandler(type_start);
entry_data = entry_handler ? entry_handler->ReadOpenFn(&g, entry_handler, name_start) : NULL;
}
else if (entry_handler != NULL && entry_data != NULL)
{
// Let type handler parse the line
entry_handler->ReadLineFn(&g, entry_handler, entry_data, line);
}
}
IM_FREE(buf);
g.SettingsLoaded = true;
DockContextOnLoadSettings(&g);
}
void ImGui::SaveIniSettingsToDisk(const char* ini_filename)
{
ImGuiContext& g = *GImGui;
g.SettingsDirtyTimer = 0.0f;
if (!ini_filename)
return;
size_t ini_data_size = 0;
const char* ini_data = SaveIniSettingsToMemory(&ini_data_size);
FILE* f = ImFileOpen(ini_filename, "wt");
if (!f)
return;
fwrite(ini_data, sizeof(char), ini_data_size, f);
fclose(f);
}
// Call registered handlers (e.g. SettingsHandlerWindow_WriteAll() + custom handlers) to write their stuff into a text buffer
const char* ImGui::SaveIniSettingsToMemory(size_t* out_size)
{
ImGuiContext& g = *GImGui;
g.SettingsDirtyTimer = 0.0f;
g.SettingsIniData.Buf.resize(0);
g.SettingsIniData.Buf.push_back(0);
for (int handler_n = 0; handler_n < g.SettingsHandlers.Size; handler_n++)
{
ImGuiSettingsHandler* handler = &g.SettingsHandlers[handler_n];
handler->WriteAllFn(&g, handler, &g.SettingsIniData);
}
if (out_size)
*out_size = (size_t)g.SettingsIniData.size();
return g.SettingsIniData.c_str();
}
static void* SettingsHandlerWindow_ReadOpen(ImGuiContext*, ImGuiSettingsHandler*, const char* name)
{
ImGuiWindowSettings* settings = ImGui::FindWindowSettings(ImHashStr(name));
if (!settings)
settings = ImGui::CreateNewWindowSettings(name);
return (void*)settings;
}
static void SettingsHandlerWindow_ReadLine(ImGuiContext*, ImGuiSettingsHandler*, void* entry, const char* line)
{
ImGuiWindowSettings* settings = (ImGuiWindowSettings*)entry;
int x, y;
int i;
ImU32 u1;
if (sscanf(line, "Pos=%i,%i", &x, &y) == 2) { settings->Pos = ImVec2ih((short)x, (short)y); }
else if (sscanf(line, "Size=%i,%i", &x, &y) == 2) { settings->Size = ImVec2ih((short)x, (short)y); }
else if (sscanf(line, "ViewportId=0x%08X", &u1) == 1) { settings->ViewportId = u1; }
else if (sscanf(line, "ViewportPos=%i,%i", &x, &y) == 2) { settings->ViewportPos = ImVec2ih((short)x, (short)y); }
else if (sscanf(line, "Collapsed=%d", &i) == 1) { settings->Collapsed = (i != 0); }
else if (sscanf(line, "DockId=0x%X,%d", &u1, &i) == 2) { settings->DockId = u1; settings->DockOrder = (short)i; }
else if (sscanf(line, "DockId=0x%X", &u1) == 1) { settings->DockId = u1; settings->DockOrder = -1; }
else if (sscanf(line, "ClassId=0x%X", &u1) == 1) { settings->ClassId = u1; }
}
static void SettingsHandlerWindow_WriteAll(ImGuiContext* ctx, ImGuiSettingsHandler* handler, ImGuiTextBuffer* buf)
{
// Gather data from windows that were active during this session
// (if a window wasn't opened in this session we preserve its settings)
ImGuiContext& g = *ctx;
for (int i = 0; i != g.Windows.Size; i++)
{
ImGuiWindow* window = g.Windows[i];
if (window->Flags & ImGuiWindowFlags_NoSavedSettings)
continue;
ImGuiWindowSettings* settings = (window->SettingsIdx != -1) ? &g.SettingsWindows[window->SettingsIdx] : ImGui::FindWindowSettings(window->ID);
if (!settings)
{
settings = ImGui::CreateNewWindowSettings(window->Name);
window->SettingsIdx = g.SettingsWindows.index_from_ptr(settings);
}
IM_ASSERT(settings->ID == window->ID);
settings->Pos = ImVec2ih(window->Pos - window->ViewportPos);
settings->Size = ImVec2ih(window->SizeFull);
settings->ViewportId = window->ViewportId;
settings->ViewportPos = ImVec2ih(window->ViewportPos);
IM_ASSERT(window->DockNode == NULL || window->DockNode->ID == window->DockId);
settings->DockId = window->DockId;
settings->ClassId = window->WindowClass.ClassId;
settings->DockOrder = window->DockOrder;
settings->Collapsed = window->Collapsed;
}
// Write to text buffer
buf->reserve(buf->size() + g.SettingsWindows.Size * 96); // ballpark reserve
for (int i = 0; i != g.SettingsWindows.Size; i++)
{
const ImGuiWindowSettings* settings = &g.SettingsWindows[i];
buf->appendf("[%s][%s]\n", handler->TypeName, settings->Name);
if (settings->ViewportId != 0 && settings->ViewportId != ImGui::IMGUI_VIEWPORT_DEFAULT_ID)
{
buf->appendf("ViewportPos=%d,%d\n", settings->ViewportPos.x, settings->ViewportPos.y);
buf->appendf("ViewportId=0x%08X\n", settings->ViewportId);
}
if (settings->Pos.x != 0 || settings->Pos.y != 0 || settings->ViewportId == ImGui::IMGUI_VIEWPORT_DEFAULT_ID)
buf->appendf("Pos=%d,%d\n", settings->Pos.x, settings->Pos.y);
if (settings->Size.x != 0 || settings->Size.y != 0)
buf->appendf("Size=%d,%d\n", settings->Size.x, settings->Size.y);
buf->appendf("Collapsed=%d\n", settings->Collapsed);
if (settings->DockId != 0)
{
// Write DockId as 4 digits if possible. Automatic DockId are small numbers, but full explicit DockSpace() are full ImGuiID range.
if (settings->DockOrder == -1)
buf->appendf("DockId=0x%08X\n", settings->DockId);
else
buf->appendf("DockId=0x%08X,%d\n", settings->DockId, settings->DockOrder);
if (settings->ClassId != 0)
buf->appendf("ClassId=0x%08X\n", settings->ClassId);
}
buf->appendf("\n");
}
}
//-----------------------------------------------------------------------------
// [SECTION] VIEWPORTS, PLATFORM WINDOWS
//-----------------------------------------------------------------------------
// - GetMainViewport()
// - FindViewportByID()
// - FindViewportByPlatformHandle()
// - SetCurrentViewport() [Internal]
// - SetWindowViewport() [Internal]
// - GetWindowAlwaysWantOwnViewport() [Internal]
// - UpdateTryMergeWindowIntoHostViewport() [Internal]
// - UpdateTryMergeWindowIntoHostViewports() [Internal]
// - TranslateWindowsInViewport() [Internal]
// - ScaleWindowsInViewport() [Internal]
// - FindHoveredViewportFromPlatformWindowStack() [Internal]
// - UpdateViewportsNewFrame() [Internal]
// - UpdateViewportsEndFrame() [Internal]
// - AddUpdateViewport() [Internal]
// - UpdateSelectWindowViewport() [Internal]
// - UpdatePlatformWindows()
// - RenderPlatformWindowsDefault()
// - FindPlatformMonitorForPos() [Internal]
// - FindPlatformMonitorForRect() [Internal]
// - UpdateViewportPlatformMonitor() [Internal]
// - DestroyPlatformWindow() [Internal]
// - DestroyPlatformWindows()
//-----------------------------------------------------------------------------
ImGuiViewport* ImGui::GetMainViewport()
{
ImGuiContext& g = *GImGui;
return g.Viewports[0];
}
ImGuiViewport* ImGui::FindViewportByID(ImGuiID id)
{
ImGuiContext& g = *GImGui;
for (int n = 0; n < g.Viewports.Size; n++)
if (g.Viewports[n]->ID == id)
return g.Viewports[n];
return NULL;
}
ImGuiViewport* ImGui::FindViewportByPlatformHandle(void* platform_handle)
{
ImGuiContext& g = *GImGui;
for (int i = 0; i != g.Viewports.Size; i++)
if (g.Viewports[i]->PlatformHandle == platform_handle)
return g.Viewports[i];
return NULL;
}
void ImGui::SetCurrentViewport(ImGuiWindow* current_window, ImGuiViewportP* viewport)
{
ImGuiContext& g = *GImGui;
(void)current_window;
if (viewport)
viewport->LastFrameActive = g.FrameCount;
if (g.CurrentViewport == viewport)
return;
g.CurrentViewport = viewport;
//IMGUI_DEBUG_LOG_VIEWPORT("SetCurrentViewport changed '%s' 0x%08X\n", current_window ? current_window->Name : NULL, viewport ? viewport->ID : 0);
// Notify platform layer of viewport changes
// FIXME-DPI: This is only currently used for experimenting with handling of multiple DPI
if (g.CurrentViewport && g.PlatformIO.Platform_OnChangedViewport)
g.PlatformIO.Platform_OnChangedViewport(g.CurrentViewport);
}
static void SetWindowViewport(ImGuiWindow* window, ImGuiViewportP* viewport)
{
window->Viewport = viewport;
window->ViewportId = viewport->ID;
window->ViewportOwned = (viewport->Window == window);
}
static bool ImGui::GetWindowAlwaysWantOwnViewport(ImGuiWindow* window)
{
// Tooltips and menus are not automatically forced into their own viewport when the NoMerge flag is set, however the multiplication of viewports makes them more likely to protrude and create their own.
ImGuiContext& g = *GImGui;
if (g.IO.ConfigViewportsNoAutoMerge || (window->WindowClass.ViewportFlagsOverrideSet & ImGuiViewportFlags_NoAutoMerge))
if (g.ConfigFlagsCurrFrame & ImGuiConfigFlags_ViewportsEnable)
if (!window->DockIsActive)
if ((window->Flags & (ImGuiWindowFlags_ChildWindow | ImGuiWindowFlags_ChildMenu | ImGuiWindowFlags_Tooltip)) == 0)
if ((window->Flags & ImGuiWindowFlags_Popup) == 0 || (window->Flags & ImGuiWindowFlags_Modal) != 0)
return true;
return false;
}
static bool ImGui::UpdateTryMergeWindowIntoHostViewport(ImGuiWindow* window, ImGuiViewportP* viewport)
{
ImGuiContext& g = *GImGui;
if (!(viewport->Flags & (ImGuiViewportFlags_CanHostOtherWindows | ImGuiViewportFlags_Minimized)) || window->Viewport == viewport)
return false;
if (!viewport->GetRect().Contains(window->Rect()))
return false;
if (GetWindowAlwaysWantOwnViewport(window))
return false;
for (int n = 0; n < g.Windows.Size; n++)
{
ImGuiWindow* window_behind = g.Windows[n];
if (window_behind == window)
break;
if (window_behind->WasActive && window_behind->ViewportOwned && !(window_behind->Flags & ImGuiWindowFlags_ChildWindow))
if (window_behind->Viewport->GetRect().Overlaps(window->Rect()))
return false;
}
// Move to the existing viewport, Move child/hosted windows as well (FIXME-OPT: iterate child)
ImGuiViewportP* old_viewport = window->Viewport;
if (window->ViewportOwned)
for (int n = 0; n < g.Windows.Size; n++)
if (g.Windows[n]->Viewport == old_viewport)
SetWindowViewport(g.Windows[n], viewport);
SetWindowViewport(window, viewport);
BringWindowToDisplayFront(window);
return true;
}
static bool ImGui::UpdateTryMergeWindowIntoHostViewports(ImGuiWindow* window)
{
ImGuiContext& g = *GImGui;
return UpdateTryMergeWindowIntoHostViewport(window, g.Viewports[0]);
}
// Translate imgui windows when a Host Viewport has been moved
// (This additionally keeps windows at the same place when ImGuiConfigFlags_ViewportsEnable is toggled!)
void ImGui::TranslateWindowsInViewport(ImGuiViewportP* viewport, const ImVec2& old_pos, const ImVec2& new_pos)
{
ImGuiContext& g = *GImGui;
IM_ASSERT(viewport->Window == NULL && (viewport->Flags & ImGuiViewportFlags_CanHostOtherWindows));
// 1) We test if ImGuiConfigFlags_ViewportsEnable was just toggled, which allows us to conveniently
// translate imgui windows from OS-window-local to absolute coordinates or vice-versa.
// 2) If it's not going to fit into the new size, keep it at same absolute position.
// One problem with this is that most Win32 applications doesn't update their render while dragging,
// and so the window will appear to teleport when releasing the mouse.
const bool translate_all_windows = (g.ConfigFlagsCurrFrame & ImGuiConfigFlags_ViewportsEnable) != (g.ConfigFlagsLastFrame & ImGuiConfigFlags_ViewportsEnable);
ImRect test_still_fit_rect(old_pos, old_pos + viewport->Size);
ImVec2 delta_pos = new_pos - old_pos;
for (int window_n = 0; window_n < g.Windows.Size; window_n++) // FIXME-OPT
if (translate_all_windows || (g.Windows[window_n]->Viewport == viewport && test_still_fit_rect.Contains(g.Windows[window_n]->Rect())))
TranslateWindow(g.Windows[window_n], delta_pos);
}
// Scale all windows (position, size). Use when e.g. changing DPI. (This is a lossy operation!)
void ImGui::ScaleWindowsInViewport(ImGuiViewportP* viewport, float scale)
{
ImGuiContext& g = *GImGui;
if (viewport->Window)
{
ScaleWindow(viewport->Window, scale);
}
else
{
for (int i = 0; i != g.Windows.Size; i++)
if (g.Windows[i]->Viewport == viewport)
ScaleWindow(g.Windows[i], scale);
}
}
// If the back-end doesn't set MouseLastHoveredViewport or doesn't honor ImGuiViewportFlags_NoInputs, we do a search ourselves.
// A) It won't take account of the possibility that non-imgui windows may be in-between our dragged window and our target window.
// B) It requires Platform_GetWindowFocus to be implemented by back-end.
static ImGuiViewportP* FindHoveredViewportFromPlatformWindowStack(const ImVec2 mouse_platform_pos)
{
ImGuiContext& g = *GImGui;
ImGuiViewportP* best_candidate = NULL;
for (int n = 0; n < g.Viewports.Size; n++)
{
ImGuiViewportP* viewport = g.Viewports[n];
if (!(viewport->Flags & (ImGuiViewportFlags_NoInputs | ImGuiViewportFlags_Minimized)) && viewport->GetRect().Contains(mouse_platform_pos))
if (best_candidate == NULL || best_candidate->LastFrontMostStampCount < viewport->LastFrontMostStampCount)
best_candidate = viewport;
}
return best_candidate;
}
// Update viewports and monitor infos
// Note that this is running even if 'ImGuiConfigFlags_ViewportsEnable' is not set, in order to clear unused viewports (if any) and update monitor info.
static void ImGui::UpdateViewportsNewFrame()
{
ImGuiContext& g = *GImGui;
IM_ASSERT(g.PlatformIO.Viewports.Size <= g.Viewports.Size);
// Update Minimized status (we need it first in order to decide if we'll apply Pos/Size of the main viewport)
if ((g.ConfigFlagsCurrFrame & ImGuiConfigFlags_ViewportsEnable))
{
for (int n = 0; n < g.Viewports.Size; n++)
{
ImGuiViewportP* viewport = g.Viewports[n];
const bool platform_funcs_available = viewport->PlatformWindowCreated;
if (g.PlatformIO.Platform_GetWindowMinimized && platform_funcs_available)
{
bool minimized = g.PlatformIO.Platform_GetWindowMinimized(viewport);
if (minimized)
viewport->Flags |= ImGuiViewportFlags_Minimized;
else
viewport->Flags &= ~ImGuiViewportFlags_Minimized;
}
}
}
// Create/update main viewport with current platform position and size
ImGuiViewportP* main_viewport = g.Viewports[0];
IM_ASSERT(main_viewport->ID == IMGUI_VIEWPORT_DEFAULT_ID);
IM_ASSERT(main_viewport->Window == NULL);
ImVec2 main_viewport_platform_pos = ImVec2(0.0f, 0.0f);
ImVec2 main_viewport_platform_size = g.IO.DisplaySize;
if (g.ConfigFlagsCurrFrame & ImGuiConfigFlags_ViewportsEnable)
main_viewport_platform_pos = (main_viewport->Flags & ImGuiViewportFlags_Minimized) ? main_viewport->Pos : g.PlatformIO.Platform_GetWindowPos(main_viewport);
AddUpdateViewport(NULL, IMGUI_VIEWPORT_DEFAULT_ID, main_viewport_platform_pos, main_viewport_platform_size, ImGuiViewportFlags_CanHostOtherWindows);
g.CurrentViewport = NULL;
g.MouseViewport = NULL;
for (int n = 0; n < g.Viewports.Size; n++)
{
ImGuiViewportP* viewport = g.Viewports[n];
viewport->Idx = n;
// Erase unused viewports
if (n > 0 && viewport->LastFrameActive < g.FrameCount - 2)
{
// Clear references to this viewport in windows (window->ViewportId becomes the master data)
for (int window_n = 0; window_n < g.Windows.Size; window_n++)
if (g.Windows[window_n]->Viewport == viewport)
{
g.Windows[window_n]->Viewport = NULL;
g.Windows[window_n]->ViewportOwned = false;
}
if (viewport == g.MouseLastHoveredViewport)
g.MouseLastHoveredViewport = NULL;
g.Viewports.erase(g.Viewports.Data + n);
// Destroy
IMGUI_DEBUG_LOG_VIEWPORT("Delete Viewport %08X (%s)\n", viewport->ID, viewport->Window ? viewport->Window->Name : "n/a");
DestroyPlatformWindow(viewport); // In most circumstances the platform window will already be destroyed here.
IM_ASSERT(g.PlatformIO.Viewports.contains(viewport) == false);
IM_DELETE(viewport);
n--;
continue;
}
const bool platform_funcs_available = viewport->PlatformWindowCreated;
if ((g.ConfigFlagsCurrFrame & ImGuiConfigFlags_ViewportsEnable))
{
// Update Position and Size (from Platform Window to ImGui) if requested.
// We do it early in the frame instead of waiting for UpdatePlatformWindows() to avoid a frame of lag when moving/resizing using OS facilities.
if (!(viewport->Flags & ImGuiViewportFlags_Minimized) && platform_funcs_available)
{
if (viewport->PlatformRequestMove)
viewport->Pos = viewport->LastPlatformPos = g.PlatformIO.Platform_GetWindowPos(viewport);
if (viewport->PlatformRequestResize)
viewport->Size = viewport->LastPlatformSize = g.PlatformIO.Platform_GetWindowSize(viewport);
}
}
// Update/copy monitor info
UpdateViewportPlatformMonitor(viewport);
// Reset alpha every frame. Users of transparency (docking) needs to request a lower alpha back.
viewport->Alpha = 1.0f;
// Translate imgui windows when a Host Viewport has been moved
// (This additionally keeps windows at the same place when ImGuiConfigFlags_ViewportsEnable is toggled!)
const ImVec2 viewport_delta_pos = viewport->Pos - viewport->LastPos;
if ((viewport->Flags & ImGuiViewportFlags_CanHostOtherWindows) && (viewport_delta_pos.x != 0.0f || viewport_delta_pos.y != 0.0f))
TranslateWindowsInViewport(viewport, viewport->LastPos, viewport->Pos);
// Update DPI scale
float new_dpi_scale;
if (g.PlatformIO.Platform_GetWindowDpiScale && platform_funcs_available)
new_dpi_scale = g.PlatformIO.Platform_GetWindowDpiScale(viewport);
else if (viewport->PlatformMonitor != -1)
new_dpi_scale = g.PlatformIO.Monitors[viewport->PlatformMonitor].DpiScale;
else
new_dpi_scale = (viewport->DpiScale != 0.0f) ? viewport->DpiScale : 1.0f;
if (viewport->DpiScale != 0.0f && new_dpi_scale != viewport->DpiScale)
{
float scale_factor = new_dpi_scale / viewport->DpiScale;
if (g.IO.ConfigFlags & ImGuiConfigFlags_DpiEnableScaleViewports)
ScaleWindowsInViewport(viewport, scale_factor);
//if (viewport == GetMainViewport())
// g.PlatformInterface.SetWindowSize(viewport, viewport->Size * scale_factor);
// Scale our window moving pivot so that the window will rescale roughly around the mouse position.
// FIXME-VIEWPORT: This currently creates a resizing feedback loop when a window is straddling a DPI transition border.
// (Minor: since our sizes do not perfectly linearly scale, deferring the click offset scale until we know the actual window scale ratio may get us slightly more precise mouse positioning.)
//if (g.MovingWindow != NULL && g.MovingWindow->Viewport == viewport)
// g.ActiveIdClickOffset = ImFloor(g.ActiveIdClickOffset * scale_factor);
}
viewport->DpiScale = new_dpi_scale;
}
if (!(g.ConfigFlagsCurrFrame & ImGuiConfigFlags_ViewportsEnable))
{
g.MouseViewport = main_viewport;
return;
}
// Mouse handling: decide on the actual mouse viewport for this frame between the active/focused viewport and the hovered viewport.
// Note that 'viewport_hovered' should skip over any viewport that has the ImGuiViewportFlags_NoInputs flags set.
ImGuiViewportP* viewport_hovered = NULL;
if (g.IO.BackendFlags & ImGuiBackendFlags_HasMouseHoveredViewport)
{
viewport_hovered = g.IO.MouseHoveredViewport ? (ImGuiViewportP*)FindViewportByID(g.IO.MouseHoveredViewport) : NULL;
if (viewport_hovered && (viewport_hovered->Flags & ImGuiViewportFlags_NoInputs))
{
// Back-end failed at honoring its contract if it returned a viewport with the _NoInputs flag.
IM_ASSERT(0);
viewport_hovered = FindHoveredViewportFromPlatformWindowStack(g.IO.MousePos);
}
}
else
{
// If the back-end doesn't know how to honor ImGuiViewportFlags_NoInputs, we do a search ourselves. Note that this search:
// A) won't take account of the possibility that non-imgui windows may be in-between our dragged window and our target window.
// B) uses LastFrameAsRefViewport as a flawed replacement for the last time a window was focused (we could/should fix that by introducing Focus functions in PlatformIO)
viewport_hovered = FindHoveredViewportFromPlatformWindowStack(g.IO.MousePos);
}
if (viewport_hovered != NULL)
g.MouseLastHoveredViewport = viewport_hovered;
else if (g.MouseLastHoveredViewport == NULL)
g.MouseLastHoveredViewport = g.Viewports[0];
// Update mouse reference viewport
// (when moving a window we aim at its viewport, but this will be overwritten below if we go in drag and drop mode)
if (g.MovingWindow)
g.MouseViewport = g.MovingWindow->Viewport;
else
g.MouseViewport = g.MouseLastHoveredViewport;
// When dragging something, always refer to the last hovered viewport.
// - when releasing a moving window we will revert to aiming behind (at viewport_hovered)
// - when we are between viewports, our dragged preview will tend to show in the last viewport _even_ if we don't have tooltips in their viewports (when lacking monitor info)
// - consider the case of holding on a menu item to browse child menus: even thou a mouse button is held, there's no active id because menu items only react on mouse release.
const bool is_mouse_dragging_with_an_expected_destination = g.DragDropActive;
if (is_mouse_dragging_with_an_expected_destination && viewport_hovered == NULL)
viewport_hovered = g.MouseLastHoveredViewport;
if (is_mouse_dragging_with_an_expected_destination || g.ActiveId == 0 || !IsAnyMouseDown())
if (viewport_hovered != NULL && viewport_hovered != g.MouseViewport && !(viewport_hovered->Flags & ImGuiViewportFlags_NoInputs))
g.MouseViewport = viewport_hovered;
IM_ASSERT(g.MouseViewport != NULL);
}
// Update user-facing viewport list (g.Viewports -> g.PlatformIO.Viewports after filtering out some)
static void ImGui::UpdateViewportsEndFrame()
{
ImGuiContext& g = *GImGui;
g.PlatformIO.MainViewport = g.Viewports[0];
g.PlatformIO.Viewports.resize(0);
for (int i = 0; i < g.Viewports.Size; i++)
{
ImGuiViewportP* viewport = g.Viewports[i];
viewport->LastPos = viewport->Pos;
if (viewport->LastFrameActive < g.FrameCount || viewport->Size.x <= 0.0f || viewport->Size.y <= 0.0f)
if (i > 0) // Always include main viewport in the list
continue;
if (viewport->Window && !IsWindowActiveAndVisible(viewport->Window))
continue;
if (i > 0)
IM_ASSERT(viewport->Window != NULL);
g.PlatformIO.Viewports.push_back(viewport);
}
g.Viewports[0]->ClearRequestFlags(); // Clear main viewport flags because UpdatePlatformWindows() won't do it and may not even be called
}
// FIXME: We should ideally refactor the system to call this every frame (we currently don't)
ImGuiViewportP* ImGui::AddUpdateViewport(ImGuiWindow* window, ImGuiID id, const ImVec2& pos, const ImVec2& size, ImGuiViewportFlags flags)
{
ImGuiContext& g = *GImGui;
IM_ASSERT(id != 0);
if (window != NULL)
{
if (g.MovingWindow && g.MovingWindow->RootWindow == window)
flags |= ImGuiViewportFlags_NoInputs | ImGuiViewportFlags_NoFocusOnAppearing;
if ((window->Flags & ImGuiWindowFlags_NoMouseInputs) && (window->Flags & ImGuiWindowFlags_NoNavInputs))
flags |= ImGuiViewportFlags_NoInputs;
if (window->Flags & ImGuiWindowFlags_NoFocusOnAppearing)
flags |= ImGuiViewportFlags_NoFocusOnAppearing;
}
ImGuiViewportP* viewport = (ImGuiViewportP*)FindViewportByID(id);
if (viewport)
{
if (!viewport->PlatformRequestMove)
viewport->Pos = pos;
if (!viewport->PlatformRequestResize)
viewport->Size = size;
viewport->Flags = flags | (viewport->Flags & ImGuiViewportFlags_Minimized); // Preserve existing flags
}
else
{
// New viewport
viewport = IM_NEW(ImGuiViewportP)();
viewport->ID = id;
viewport->Idx = g.Viewports.Size;
viewport->Pos = viewport->LastPos = pos;
viewport->Size = size;
viewport->Flags = flags;
UpdateViewportPlatformMonitor(viewport);
g.Viewports.push_back(viewport);
IMGUI_DEBUG_LOG_VIEWPORT("Add Viewport %08X (%s)\n", id, window->Name);
// We normally setup for all viewports in NewFrame() but here need to handle the mid-frame creation of a new viewport.
// We need to extend the fullscreen clip rect so the OverlayDrawList clip is correct for that the first frame
g.DrawListSharedData.ClipRectFullscreen.x = ImMin(g.DrawListSharedData.ClipRectFullscreen.x, viewport->Pos.x);
g.DrawListSharedData.ClipRectFullscreen.y = ImMin(g.DrawListSharedData.ClipRectFullscreen.y, viewport->Pos.y);
g.DrawListSharedData.ClipRectFullscreen.z = ImMax(g.DrawListSharedData.ClipRectFullscreen.z, viewport->Pos.x + viewport->Size.x);
g.DrawListSharedData.ClipRectFullscreen.w = ImMax(g.DrawListSharedData.ClipRectFullscreen.w, viewport->Pos.y + viewport->Size.y);
// Store initial DpiScale before the OS platform window creation, based on expected monitor data.
// This is so we can select an appropriate font size on the first frame of our window lifetime
if (viewport->PlatformMonitor != -1)
viewport->DpiScale = g.PlatformIO.Monitors[viewport->PlatformMonitor].DpiScale;
}
viewport->Window = window;
viewport->LastFrameActive = g.FrameCount;
IM_ASSERT(window == NULL || viewport->ID == window->ID);
if (window != NULL)
window->ViewportOwned = true;
return viewport;
}
// FIXME-VIEWPORT: This is all super messy and ought to be clarified or rewritten.
static void ImGui::UpdateSelectWindowViewport(ImGuiWindow* window)
{
ImGuiContext& g = *GImGui;
ImGuiWindowFlags flags = window->Flags;
window->ViewportAllowPlatformMonitorExtend = -1;
// Restore main viewport if multi-viewport is not supported by the back-end
ImGuiViewportP* main_viewport = g.Viewports[0];
if (!(g.ConfigFlagsCurrFrame & ImGuiConfigFlags_ViewportsEnable))
{
SetWindowViewport(window, main_viewport);
return;
}
window->ViewportOwned = false;
// Appearing popups reset their viewport so they can inherit again
if ((flags & (ImGuiWindowFlags_Popup | ImGuiWindowFlags_Tooltip)) && window->Appearing)
{
window->Viewport = NULL;
window->ViewportId = 0;
}
if ((g.NextWindowData.Flags & ImGuiNextWindowDataFlags_HasViewport) == 0)
{
// By default inherit from parent window
if (window->Viewport == NULL && window->ParentWindow && !window->ParentWindow->IsFallbackWindow)
window->Viewport = window->ParentWindow->Viewport;
// Attempt to restore saved viewport id (= window that hasn't been activated yet), try to restore the viewport based on saved 'window->ViewportPos' restored from .ini file
if (window->Viewport == NULL && window->ViewportId != 0)
{
window->Viewport = (ImGuiViewportP*)FindViewportByID(window->ViewportId);
if (window->Viewport == NULL && window->ViewportPos.x != FLT_MAX && window->ViewportPos.y != FLT_MAX)
window->Viewport = AddUpdateViewport(window, window->ID, window->ViewportPos, window->Size, ImGuiViewportFlags_None);
}
}
bool lock_viewport = false;
if (g.NextWindowData.Flags & ImGuiNextWindowDataFlags_HasViewport)
{
// Code explicitly request a viewport
window->Viewport = (ImGuiViewportP*)FindViewportByID(g.NextWindowData.ViewportId);
window->ViewportId = g.NextWindowData.ViewportId; // Store ID even if Viewport isn't resolved yet.
lock_viewport = true;
}
else if ((flags & ImGuiWindowFlags_ChildWindow) || (flags & ImGuiWindowFlags_ChildMenu))
{
// Always inherit viewport from parent window
window->Viewport = window->ParentWindow->Viewport;
}
else if (flags & ImGuiWindowFlags_Tooltip)
{
window->Viewport = g.MouseViewport;
}
else if (GetWindowAlwaysWantOwnViewport(window))
{
window->Viewport = AddUpdateViewport(window, window->ID, window->Pos, window->Size, ImGuiViewportFlags_None);
}
else if (g.MovingWindow && g.MovingWindow->RootWindow == window && IsMousePosValid())
{
if (window->Viewport != NULL && window->Viewport->Window == window)
window->Viewport = AddUpdateViewport(window, window->ID, window->Pos, window->Size, ImGuiViewportFlags_None);
}
else
{
// Merge into host viewport?
// We cannot test window->ViewportOwned as it set lower in the function.
bool try_to_merge_into_host_viewport = (window->Viewport && window == window->Viewport->Window && g.ActiveId == 0);
if (try_to_merge_into_host_viewport)
UpdateTryMergeWindowIntoHostViewports(window);
}
// Fallback to default viewport
if (window->Viewport == NULL)
window->Viewport = main_viewport;
// Mark window as allowed to protrude outside of its viewport and into the current monitor
if (!lock_viewport)
{
if (flags & (ImGuiWindowFlags_Tooltip | ImGuiWindowFlags_Popup))
{
// We need to take account of the possibility that mouse may become invalid.
// Popups/Tooltip always set ViewportAllowPlatformMonitorExtend so GetWindowAllowedExtentRect() will return full monitor bounds.
ImVec2 mouse_ref = (flags & ImGuiWindowFlags_Tooltip) ? g.IO.MousePos : g.BeginPopupStack.back().OpenMousePos;
bool use_mouse_ref = (g.NavDisableHighlight || !g.NavDisableMouseHover || !g.NavWindow);
bool mouse_valid = IsMousePosValid(&mouse_ref);
if ((window->Appearing || (flags & ImGuiWindowFlags_Tooltip)) && (!use_mouse_ref || mouse_valid))
window->ViewportAllowPlatformMonitorExtend = FindPlatformMonitorForPos((use_mouse_ref && mouse_valid) ? mouse_ref : NavCalcPreferredRefPos());
else
window->ViewportAllowPlatformMonitorExtend = window->Viewport->PlatformMonitor;
}
else if (window->Viewport && window != window->Viewport->Window && window->Viewport->Window && !(flags & ImGuiWindowFlags_ChildWindow))
{
// When called from Begin() we don't have access to a proper version of the Hidden flag yet, so we replicate this code.
const bool will_be_visible = (window->DockIsActive && !window->DockTabIsVisible) ? false : true;
if ((window->Flags & ImGuiWindowFlags_DockNodeHost) && window->Viewport->LastFrameActive < g.FrameCount && will_be_visible)
{
// Steal/transfer ownership
IMGUI_DEBUG_LOG_VIEWPORT("Window '%s' steal Viewport %08X from Window '%s'\n", window->Name, window->Viewport->ID, window->Viewport->Window->Name);
window->Viewport->Window = window;
window->Viewport->ID = window->ID;
window->Viewport->LastNameHash = 0;
}
else if (!UpdateTryMergeWindowIntoHostViewports(window)) // Merge?
{
// New viewport
window->Viewport = AddUpdateViewport(window, window->ID, window->Pos, window->Size, ImGuiViewportFlags_NoFocusOnAppearing);
}
}
else if (window->ViewportAllowPlatformMonitorExtend < 0 && (flags & ImGuiWindowFlags_ChildWindow) == 0)
{
// Regular (non-child, non-popup) windows by default are also allowed to protrude
// Child windows are kept contained within their parent.
window->ViewportAllowPlatformMonitorExtend = window->Viewport->PlatformMonitor;
}
}
// Update flags
window->ViewportOwned = (window == window->Viewport->Window);
window->ViewportId = window->Viewport->ID;
// If the OS window has a title bar, hide our imgui title bar
//if (window->ViewportOwned && !(window->Viewport->Flags & ImGuiViewportFlags_NoDecoration))
// window->Flags |= ImGuiWindowFlags_NoTitleBar;
}
// Called by user at the end of the main loop, after EndFrame()
// This will handle the creation/update of all OS windows via function defined in the ImGuiPlatformIO api.
void ImGui::UpdatePlatformWindows()
{
ImGuiContext& g = *GImGui;
IM_ASSERT(g.FrameCountEnded == g.FrameCount && "Forgot to call Render() or EndFrame() before UpdatePlatformWindows()?");
IM_ASSERT(g.FrameCountPlatformEnded < g.FrameCount);
g.FrameCountPlatformEnded = g.FrameCount;
if (!(g.ConfigFlagsCurrFrame & ImGuiConfigFlags_ViewportsEnable))
return;
// Create/resize/destroy platform windows to match each active viewport.
// Skip the main viewport (index 0), which is always fully handled by the application!
for (int i = 1; i < g.Viewports.Size; i++)
{
ImGuiViewportP* viewport = g.Viewports[i];
// Destroy platform window if the viewport hasn't been submitted or if it is hosting a hidden window
// (the implicit/fallback Debug##Default window will be registering its viewport then be disabled, causing a dummy DestroyPlatformWindow to be made each frame)
bool destroy_platform_window = false;
destroy_platform_window |= (viewport->LastFrameActive < g.FrameCount - 1);
destroy_platform_window |= (viewport->Window && !IsWindowActiveAndVisible(viewport->Window));
if (destroy_platform_window)
{
DestroyPlatformWindow(viewport);
continue;
}
// New windows that appears directly in a new viewport won't always have a size on their first frame
if (viewport->LastFrameActive < g.FrameCount || viewport->Size.x <= 0 || viewport->Size.y <= 0)
continue;
// Create window
bool is_new_platform_window = (viewport->PlatformWindowCreated == false);
if (is_new_platform_window)
{
IMGUI_DEBUG_LOG_VIEWPORT("Create Platform Window %08X (%s)\n", viewport->ID, viewport->Window ? viewport->Window->Name : "n/a");
g.PlatformIO.Platform_CreateWindow(viewport);
if (g.PlatformIO.Renderer_CreateWindow != NULL)
g.PlatformIO.Renderer_CreateWindow(viewport);
viewport->LastNameHash = 0;
viewport->LastPlatformPos = viewport->LastPlatformSize = ImVec2(FLT_MAX, FLT_MAX); // By clearing those we'll enforce a call to Platform_SetWindowPos/Size below, before Platform_ShowWindow (FIXME: Is that necessary?)
viewport->LastRendererSize = viewport->Size; // We don't need to call Renderer_SetWindowSize() as it is expected Renderer_CreateWindow() already did it.
viewport->PlatformWindowCreated = true;
}
// Apply Position and Size (from ImGui to Platform/Renderer back-ends)
if ((viewport->LastPlatformPos.x != viewport->Pos.x || viewport->LastPlatformPos.y != viewport->Pos.y) && !viewport->PlatformRequestMove)
g.PlatformIO.Platform_SetWindowPos(viewport, viewport->Pos);
if ((viewport->LastPlatformSize.x != viewport->Size.x || viewport->LastPlatformSize.y != viewport->Size.y) && !viewport->PlatformRequestResize)
g.PlatformIO.Platform_SetWindowSize(viewport, viewport->Size);
if ((viewport->LastRendererSize.x != viewport->Size.x || viewport->LastRendererSize.y != viewport->Size.y) && g.PlatformIO.Renderer_SetWindowSize)
g.PlatformIO.Renderer_SetWindowSize(viewport, viewport->Size);
viewport->LastPlatformPos = viewport->Pos;
viewport->LastPlatformSize = viewport->LastRendererSize = viewport->Size;
// Update title bar (if it changed)
if (ImGuiWindow* window_for_title = GetWindowForTitleDisplay(viewport->Window))
{
const char* title_begin = window_for_title->Name;
char* title_end = (char*)(intptr_t)FindRenderedTextEnd(title_begin);
const ImGuiID title_hash = ImHashStr(title_begin, title_end - title_begin);
if (viewport->LastNameHash != title_hash)
{
char title_end_backup_c = *title_end;
*title_end = 0; // Cut existing buffer short instead of doing an alloc/free, no small gain.
g.PlatformIO.Platform_SetWindowTitle(viewport, title_begin);
*title_end = title_end_backup_c;
viewport->LastNameHash = title_hash;
}
}
// Update alpha (if it changed)
if (viewport->LastAlpha != viewport->Alpha && g.PlatformIO.Platform_SetWindowAlpha)
g.PlatformIO.Platform_SetWindowAlpha(viewport, viewport->Alpha);
viewport->LastAlpha = viewport->Alpha;
// Optional, general purpose call to allow the back-end to perform general book-keeping even if things haven't changed.
if (g.PlatformIO.Platform_UpdateWindow)
g.PlatformIO.Platform_UpdateWindow(viewport);
if (is_new_platform_window)
{
// On startup ensure new platform window don't steal focus (give it a few frames, as nested contents may lead to viewport being created a few frames late)
if (g.FrameCount < 3)
viewport->Flags |= ImGuiViewportFlags_NoFocusOnAppearing;
// Show window
g.PlatformIO.Platform_ShowWindow(viewport);
// Even without focus, we assume the window becomes front-most.
// This is useful for our platform z-order heuristic when io.MouseHoveredViewport is not available.
if (viewport->LastFrontMostStampCount != g.ViewportFrontMostStampCount)
viewport->LastFrontMostStampCount = ++g.ViewportFrontMostStampCount;
}
// Clear request flags
viewport->ClearRequestFlags();
}
// Update our implicit z-order knowledge of platform windows, which is used when the back-end cannot provide io.MouseHoveredViewport.
// When setting Platform_GetWindowFocus, it is expected that the platform back-end can handle calls without crashing if it doesn't have data stored.
if (g.PlatformIO.Platform_GetWindowFocus != NULL)
{
ImGuiViewportP* focused_viewport = NULL;
for (int n = 0; n < g.Viewports.Size && focused_viewport == NULL; n++)
{
ImGuiViewportP* viewport = g.Viewports[n];
if (viewport->PlatformWindowCreated)
if (g.PlatformIO.Platform_GetWindowFocus(viewport))
focused_viewport = viewport;
}
if (focused_viewport && g.PlatformLastFocusedViewport != focused_viewport->ID)
{
if (focused_viewport->LastFrontMostStampCount != g.ViewportFrontMostStampCount)
focused_viewport->LastFrontMostStampCount = ++g.ViewportFrontMostStampCount;
g.PlatformLastFocusedViewport = focused_viewport->ID;
}
}
}
// This is a default/basic function for performing the rendering/swap of multiple Platform Windows.
// Custom renderers may prefer to not call this function at all, and instead iterate the publicly exposed platform data and handle rendering/sync themselves.
// The Render/Swap functions stored in ImGuiPlatformIO are merely here to allow for this helper to exist, but you can do it yourself:
//
// ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
// for (int i = 1; i < platform_io.Viewports.Size; i++)
// if ((platform_io.Viewports[i]->Flags & ImGuiViewportFlags_Minimized) == 0)
// MyRenderFunction(platform_io.Viewports[i], my_args);
// for (int i = 1; i < platform_io.Viewports.Size; i++)
// if ((platform_io.Viewports[i]->Flags & ImGuiViewportFlags_Minimized) == 0)
// MySwapBufferFunction(platform_io.Viewports[i], my_args);
//
void ImGui::RenderPlatformWindowsDefault(void* platform_render_arg, void* renderer_render_arg)
{
// Skip the main viewport (index 0), which is always fully handled by the application!
ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
for (int i = 1; i < platform_io.Viewports.Size; i++)
{
ImGuiViewport* viewport = platform_io.Viewports[i];
if (viewport->Flags & ImGuiViewportFlags_Minimized)
continue;
if (platform_io.Platform_RenderWindow) platform_io.Platform_RenderWindow(viewport, platform_render_arg);
if (platform_io.Renderer_RenderWindow) platform_io.Renderer_RenderWindow(viewport, renderer_render_arg);
}
for (int i = 1; i < platform_io.Viewports.Size; i++)
{
ImGuiViewport* viewport = platform_io.Viewports[i];
if (viewport->Flags & ImGuiViewportFlags_Minimized)
continue;
if (platform_io.Platform_SwapBuffers) platform_io.Platform_SwapBuffers(viewport, platform_render_arg);
if (platform_io.Renderer_SwapBuffers) platform_io.Renderer_SwapBuffers(viewport, renderer_render_arg);
}
}
static int ImGui::FindPlatformMonitorForPos(const ImVec2& pos)
{
ImGuiContext& g = *GImGui;
for (int monitor_n = 0; monitor_n < g.PlatformIO.Monitors.Size; monitor_n++)
{
const ImGuiPlatformMonitor& monitor = g.PlatformIO.Monitors[monitor_n];
if (ImRect(monitor.MainPos, monitor.MainPos + monitor.MainSize).Contains(pos))
return monitor_n;
}
return -1;
}
// Search for the monitor with the largest intersection area with the given rectangle
// We generally try to avoid searching loops but the monitor count should be very small here
// FIXME-OPT: We could test the last monitor used for that viewport first, and early
static int ImGui::FindPlatformMonitorForRect(const ImRect& rect)
{
ImGuiContext& g = *GImGui;
const int monitor_count = g.PlatformIO.Monitors.Size;
if (monitor_count <= 1)
return monitor_count - 1;
// Use a minimum threshold of 1.0f so a zero-sized rect won't false positive, and will still find the correct monitor given its position.
// This is necessary for tooltips which always resize down to zero at first.
const float surface_threshold = ImMax(rect.GetWidth() * rect.GetHeight() * 0.5f, 1.0f);
int best_monitor_n = -1;
float best_monitor_surface = 0.001f;
for (int monitor_n = 0; monitor_n < g.PlatformIO.Monitors.Size && best_monitor_surface < surface_threshold; monitor_n++)
{
const ImGuiPlatformMonitor& monitor = g.PlatformIO.Monitors[monitor_n];
const ImRect monitor_rect = ImRect(monitor.MainPos, monitor.MainPos + monitor.MainSize);
if (monitor_rect.Contains(rect))
return monitor_n;
ImRect overlapping_rect = rect;
overlapping_rect.ClipWithFull(monitor_rect);
float overlapping_surface = overlapping_rect.GetWidth() * overlapping_rect.GetHeight();
if (overlapping_surface < best_monitor_surface)
continue;
best_monitor_surface = overlapping_surface;
best_monitor_n = monitor_n;
}
return best_monitor_n;
}
// Update monitor from viewport rectangle (we'll use this info to clamp windows and save windows lost in a removed monitor)
static void ImGui::UpdateViewportPlatformMonitor(ImGuiViewportP* viewport)
{
viewport->PlatformMonitor = (short)FindPlatformMonitorForRect(viewport->GetRect());
}
void ImGui::DestroyPlatformWindow(ImGuiViewportP* viewport)
{
ImGuiContext& g = *GImGui;
if (viewport->PlatformWindowCreated)
{
if (g.PlatformIO.Renderer_DestroyWindow)
g.PlatformIO.Renderer_DestroyWindow(viewport);
if (g.PlatformIO.Platform_DestroyWindow)
g.PlatformIO.Platform_DestroyWindow(viewport);
IM_ASSERT(viewport->RendererUserData == NULL && viewport->PlatformUserData == NULL);
viewport->PlatformWindowCreated = false;
}
else
{
IM_ASSERT(viewport->RendererUserData == NULL && viewport->PlatformUserData == NULL && viewport->PlatformHandle == NULL);
}
viewport->RendererUserData = viewport->PlatformUserData = viewport->PlatformHandle = NULL;
viewport->ClearRequestFlags();
}
void ImGui::DestroyPlatformWindows()
{
// We call the destroy window on every viewport (including the main viewport, index 0) to give a chance to the back-end
// to clear any data they may have stored in e.g. PlatformUserData, RendererUserData.
// It is convenient for the platform back-end code to store something in the main viewport, in order for e.g. the mouse handling
// code to operator a consistent manner.
// It is expected that the back-end can handle calls to Renderer_DestroyWindow/Platform_DestroyWindow without
// crashing if it doesn't have data stored.
ImGuiContext& g = *GImGui;
for (int i = 0; i < g.Viewports.Size; i++)
DestroyPlatformWindow(g.Viewports[i]);
}
//-----------------------------------------------------------------------------
// [SECTION] DOCKING
//-----------------------------------------------------------------------------
// Docking: Internal Types
// Docking: Forward Declarations
// Docking: ImGuiDockContext
// Docking: ImGuiDockContext Docking/Undocking functions
// Docking: ImGuiDockNode
// Docking: ImGuiDockNode Tree manipulation functions
// Docking: Public Functions (SetWindowDock, DockSpace, DockSpaceOverViewport)
// Docking: Builder Functions
// Docking: Begin/End Support Functions (called from Begin/End)
// Docking: Settings
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
// Docking: Internal Types
//-----------------------------------------------------------------------------
// - ImGuiDockRequestType
// - ImGuiDockRequest
// - ImGuiDockPreviewData
// - ImGuiDockNodeSettings
// - ImGuiDockContext
//-----------------------------------------------------------------------------
static float IMGUI_DOCK_SPLITTER_SIZE = 2.0f;
enum ImGuiDockRequestType
{
ImGuiDockRequestType_None = 0,
ImGuiDockRequestType_Dock,
ImGuiDockRequestType_Undock,
ImGuiDockRequestType_Split // Split is the same as Dock but without a DockPayload
};
struct ImGuiDockRequest
{
ImGuiDockRequestType Type;
ImGuiWindow* DockTargetWindow; // Destination/Target Window to dock into (may be a loose window or a DockNode, might be NULL in which case DockTargetNode cannot be NULL)
ImGuiDockNode* DockTargetNode; // Destination/Target Node to dock into
ImGuiWindow* DockPayload; // Source/Payload window to dock (may be a loose window or a DockNode), [Optional]
ImGuiDir DockSplitDir;
float DockSplitRatio;
bool DockSplitOuter;
ImGuiWindow* UndockTargetWindow;
ImGuiDockNode* UndockTargetNode;
ImGuiDockRequest()
{
Type = ImGuiDockRequestType_None;
DockTargetWindow = DockPayload = UndockTargetWindow = NULL;
DockTargetNode = UndockTargetNode = NULL;
DockSplitDir = ImGuiDir_None;
DockSplitRatio = 0.5f;
DockSplitOuter = false;
}
};
struct ImGuiDockPreviewData
{
ImGuiDockNode FutureNode;
bool IsDropAllowed;
bool IsCenterAvailable;
bool IsSidesAvailable; // Hold your breath, grammar freaks..
bool IsSplitDirExplicit; // Set when hovered the drop rect (vs. implicit SplitDir==None when hovered the window)
ImGuiDockNode* SplitNode;
ImGuiDir SplitDir;
float SplitRatio;
ImRect DropRectsDraw[ImGuiDir_COUNT + 1]; // May be slightly different from hit-testing drop rects used in DockNodeCalcDropRects()
ImGuiDockPreviewData() : FutureNode(0) { IsDropAllowed = IsCenterAvailable = IsSidesAvailable = IsSplitDirExplicit = false; SplitNode = NULL; SplitDir = ImGuiDir_None; SplitRatio = 0.f; }
};
// Persistent Settings data, stored contiguously in SettingsNodes (sizeof() ~32 bytes)
struct ImGuiDockNodeSettings
{
ImGuiID ID;
ImGuiID ParentNodeID;
ImGuiID ParentWindowID;
ImGuiID SelectedWindowID;
signed char SplitAxis;
char Depth;
ImGuiDockNodeFlags Flags; // NB: We save individual flags one by one in ascii format (ImGuiDockNodeFlags_SavedFlagsMask_)
ImVec2ih Pos;
ImVec2ih Size;
ImVec2ih SizeRef;
ImGuiDockNodeSettings() { ID = ParentNodeID = ParentWindowID = SelectedWindowID = 0; SplitAxis = ImGuiAxis_None; Depth = 0; Flags = ImGuiDockNodeFlags_None; }
};
struct ImGuiDockContext
{
ImGuiStorage Nodes; // Map ID -> ImGuiDockNode*: Active nodes
ImVector<ImGuiDockRequest> Requests;
ImVector<ImGuiDockNodeSettings> SettingsNodes;
bool WantFullRebuild;
ImGuiDockContext() { WantFullRebuild = false; }
};
//-----------------------------------------------------------------------------
// Docking: Forward Declarations
//-----------------------------------------------------------------------------
namespace ImGui
{
// ImGuiDockContext
static ImGuiDockNode* DockContextAddNode(ImGuiContext* ctx, ImGuiID id);
static void DockContextRemoveNode(ImGuiContext* ctx, ImGuiDockNode* node, bool merge_sibling_into_parent_node);
static void DockContextQueueNotifyRemovedNode(ImGuiContext* ctx, ImGuiDockNode* node);
static void DockContextProcessDock(ImGuiContext* ctx, ImGuiDockRequest* req);
static void DockContextProcessUndockWindow(ImGuiContext* ctx, ImGuiWindow* window, bool clear_persistent_docking_ref = true);
static void DockContextProcessUndockNode(ImGuiContext* ctx, ImGuiDockNode* node);
static void DockContextPruneUnusedSettingsNodes(ImGuiContext* ctx);
static ImGuiDockNode* DockContextFindNodeByID(ImGuiContext* ctx, ImGuiID id);
static ImGuiDockNode* DockContextBindNodeToWindow(ImGuiContext* ctx, ImGuiWindow* window);
static void DockContextClearNodes(ImGuiContext* ctx, ImGuiID root_id, bool clear_persistent_docking_refs); // Use root_id==0 to clear all
static void DockContextBuildNodesFromSettings(ImGuiContext* ctx, ImGuiDockNodeSettings* node_settings_array, int node_settings_count);
static void DockContextBuildAddWindowsToNodes(ImGuiContext* ctx, ImGuiID root_id); // Use root_id==0 to add all
// ImGuiDockNode
static void DockNodeAddWindow(ImGuiDockNode* node, ImGuiWindow* window, bool add_to_tab_bar);
static void DockNodeMoveWindows(ImGuiDockNode* dst_node, ImGuiDockNode* src_node);
static void DockNodeMoveChildNodes(ImGuiDockNode* dst_node, ImGuiDockNode* src_node);
static void DockNodeApplyPosSizeToWindows(ImGuiDockNode* node);
static void DockNodeRemoveWindow(ImGuiDockNode* node, ImGuiWindow* window, ImGuiID save_dock_id);
static void DockNodeHideHostWindow(ImGuiDockNode* node);
static void DockNodeUpdate(ImGuiDockNode* node);
static void DockNodeUpdateVisibleFlagAndInactiveChilds(ImGuiDockNode* node);
static void DockNodeUpdateTabBar(ImGuiDockNode* node, ImGuiWindow* host_window);
static void DockNodeAddTabBar(ImGuiDockNode* node);
static void DockNodeRemoveTabBar(ImGuiDockNode* node);
static ImGuiID DockNodeUpdateWindowMenu(ImGuiDockNode* node, ImGuiTabBar* tab_bar);
static void DockNodeUpdateVisibleFlag(ImGuiDockNode* node);
static void DockNodeStartMouseMovingWindow(ImGuiDockNode* node, ImGuiWindow* window);
static bool DockNodeIsDropAllowed(ImGuiWindow* host_window, ImGuiWindow* payload_window);
static void DockNodePreviewDockCalc(ImGuiWindow* host_window, ImGuiDockNode* host_node, ImGuiWindow* payload_window, ImGuiDockPreviewData* preview_data, bool is_explicit_target, bool is_outer_docking);
static void DockNodePreviewDockRender(ImGuiWindow* host_window, ImGuiDockNode* host_node, ImGuiWindow* payload_window, const ImGuiDockPreviewData* preview_data);
static void DockNodeCalcTabBarLayout(const ImGuiDockNode* node, ImRect* out_title_rect, ImRect* out_tab_bar_rect, ImVec2* out_window_menu_button_pos);
static void DockNodeCalcSplitRects(ImVec2& pos_old, ImVec2& size_old, ImVec2& pos_new, ImVec2& size_new, ImGuiDir dir, ImVec2 size_new_desired);
static bool DockNodeCalcDropRectsAndTestMousePos(const ImRect& parent, ImGuiDir dir, ImRect& out_draw, bool outer_docking, ImVec2* test_mouse_pos);
static const char* DockNodeGetHostWindowTitle(ImGuiDockNode* node, char* buf, int buf_size) { ImFormatString(buf, buf_size, "##DockNode_%02X", node->ID); return buf; }
static int DockNodeGetDepth(const ImGuiDockNode* node) { int depth = 0; while (node->ParentNode) { node = node->ParentNode; depth++; } return depth; }
static int DockNodeGetTabOrder(ImGuiWindow* window);
// ImGuiDockNode tree manipulations
static void DockNodeTreeSplit(ImGuiContext* ctx, ImGuiDockNode* parent_node, ImGuiAxis split_axis, int split_first_child, float split_ratio, ImGuiDockNode* new_node);
static void DockNodeTreeMerge(ImGuiContext* ctx, ImGuiDockNode* parent_node, ImGuiDockNode* merge_lead_child);
static void DockNodeTreeUpdatePosSize(ImGuiDockNode* node, ImVec2 pos, ImVec2 size, bool only_write_to_marked_nodes = false);
static void DockNodeTreeUpdateSplitter(ImGuiDockNode* node);
static ImGuiDockNode* DockNodeTreeFindNodeByPos(ImGuiDockNode* node, ImVec2 pos);
static ImGuiDockNode* DockNodeTreeFindFallbackLeafNode(ImGuiDockNode* node);
// Settings
static void DockSettingsRenameNodeReferences(ImGuiID old_node_id, ImGuiID new_node_id);
static void DockSettingsRemoveNodeReferences(ImGuiID* node_ids, int node_ids_count);
static ImGuiDockNodeSettings* DockSettingsFindNodeSettings(ImGuiContext* ctx, ImGuiID node_id);
static void* DockSettingsHandler_ReadOpen(ImGuiContext*, ImGuiSettingsHandler*, const char* name);
static void DockSettingsHandler_ReadLine(ImGuiContext*, ImGuiSettingsHandler*, void* entry, const char* line);
static void DockSettingsHandler_WriteAll(ImGuiContext* imgui_ctx, ImGuiSettingsHandler* handler, ImGuiTextBuffer* buf);
}
//-----------------------------------------------------------------------------
// Docking: ImGuiDockContext
//-----------------------------------------------------------------------------
// The lifetime model is different from the one of regular windows: we always create a ImGuiDockNode for each ImGuiDockNodeSettings,
// or we always hold the entire docking node tree. Nodes are frequently hidden, e.g. if the window(s) or child nodes they host are not active.
// At boot time only, we run a simple GC to remove nodes that have no references.
// Because dock node settings (which are small, contiguous structures) are always mirrored by their corresponding dock nodes (more complete structures),
// we can also very easily recreate the nodes from scratch given the settings data (this is what DockContextRebuild() does).
// This is convenient as docking reconfiguration can be implemented by mostly poking at the simpler settings data.
//-----------------------------------------------------------------------------
// - DockContextInitialize()
// - DockContextShutdown()
// - DockContextOnLoadSettings()
// - DockContextClearNodes()
// - DockContextRebuildNodes()
// - DockContextUpdateUndocking()
// - DockContextUpdateDocking()
// - DockContextFindNodeByID()
// - DockContextBindNodeToWindow()
// - DockContextGenNodeID()
// - DockContextAddNode()
// - DockContextRemoveNode()
// - ImGuiDockContextPruneNodeData
// - DockContextPruneUnusedSettingsNodes()
// - DockContextBuildNodesFromSettings()
// - DockContextBuildAddWindowsToNodes()
//-----------------------------------------------------------------------------
void ImGui::DockContextInitialize(ImGuiContext* ctx)
{
ImGuiContext& g = *ctx;
IM_ASSERT(g.DockContext == NULL);
g.DockContext = IM_NEW(ImGuiDockContext)();
// Add .ini handle for persistent docking data
ImGuiSettingsHandler ini_handler;
ini_handler.TypeName = "Docking";
ini_handler.TypeHash = ImHashStr("Docking");
ini_handler.ReadOpenFn = DockSettingsHandler_ReadOpen;
ini_handler.ReadLineFn = DockSettingsHandler_ReadLine;
ini_handler.WriteAllFn = DockSettingsHandler_WriteAll;
g.SettingsHandlers.push_back(ini_handler);
}
void ImGui::DockContextShutdown(ImGuiContext* ctx)
{
ImGuiContext& g = *ctx;
ImGuiDockContext* dc = ctx->DockContext;
for (int n = 0; n < dc->Nodes.Data.Size; n++)
if (ImGuiDockNode* node = (ImGuiDockNode*)dc->Nodes.Data[n].val_p)
IM_DELETE(node);
IM_DELETE(g.DockContext);
g.DockContext = NULL;
}
void ImGui::DockContextOnLoadSettings(ImGuiContext* ctx)
{
ImGuiDockContext* dc = ctx->DockContext;
DockContextPruneUnusedSettingsNodes(ctx);
DockContextBuildNodesFromSettings(ctx, dc->SettingsNodes.Data, dc->SettingsNodes.Size);
}
void ImGui::DockContextClearNodes(ImGuiContext* ctx, ImGuiID root_id, bool clear_persistent_docking_references)
{
IM_UNUSED(ctx);
IM_ASSERT(ctx == GImGui);
DockBuilderRemoveNodeDockedWindows(root_id, clear_persistent_docking_references);
DockBuilderRemoveNodeChildNodes(root_id);
}
// This function also acts as a defacto test to make sure we can rebuild from scratch without a glitch
void ImGui::DockContextRebuildNodes(ImGuiContext* ctx)
{
IMGUI_DEBUG_LOG_DOCKING("DockContextRebuild()\n");
ImGuiDockContext* dc = ctx->DockContext;
SaveIniSettingsToMemory();
ImGuiID root_id = 0; // Rebuild all
DockContextClearNodes(ctx, root_id, false);
DockContextBuildNodesFromSettings(ctx, dc->SettingsNodes.Data, dc->SettingsNodes.Size);
DockContextBuildAddWindowsToNodes(ctx, root_id);
}
// Docking context update function, called by NewFrame()
void ImGui::DockContextUpdateUndocking(ImGuiContext* ctx)
{
ImGuiContext& g = *ctx;
ImGuiDockContext* dc = ctx->DockContext;
if (!(g.IO.ConfigFlags & ImGuiConfigFlags_DockingEnable))
{
if (dc->Nodes.Data.Size > 0 || dc->Requests.Size > 0)
DockContextClearNodes(ctx, 0, true);
return;
}
// Setting NoSplit at runtime merges all nodes
if (g.IO.ConfigDockingNoSplit)
for (int n = 0; n < dc->Nodes.Data.Size; n++)
if (ImGuiDockNode* node = (ImGuiDockNode*)dc->Nodes.Data[n].val_p)
if (node->IsRootNode() && node->IsSplitNode())
{
DockBuilderRemoveNodeChildNodes(node->ID);
//dc->WantFullRebuild = true;
}
// Process full rebuild
#if 0
if (ImGui::IsKeyPressed(ImGui::GetKeyIndex(ImGuiKey_C)))
dc->WantFullRebuild = true;
#endif
if (dc->WantFullRebuild)
{
DockContextRebuildNodes(ctx);
dc->WantFullRebuild = false;
}
// Process Undocking requests (we need to process them _before_ the UpdateMouseMovingWindowNewFrame call in NewFrame)
for (int n = 0; n < dc->Requests.Size; n++)
{
ImGuiDockRequest* req = &dc->Requests[n];
if (req->Type == ImGuiDockRequestType_Undock && req->UndockTargetWindow)
DockContextProcessUndockWindow(ctx, req->UndockTargetWindow);
else if (req->Type == ImGuiDockRequestType_Undock && req->UndockTargetNode)
DockContextProcessUndockNode(ctx, req->UndockTargetNode);
}
}
// Docking context update function, called by NewFrame()
void ImGui::DockContextUpdateDocking(ImGuiContext* ctx)
{
ImGuiContext& g = *ctx;
ImGuiDockContext* dc = ctx->DockContext;
if (!(g.IO.ConfigFlags & ImGuiConfigFlags_DockingEnable))
return;
// Process Docking requests
for (int n = 0; n < dc->Requests.Size; n++)
if (dc->Requests[n].Type == ImGuiDockRequestType_Dock)
DockContextProcessDock(ctx, &dc->Requests[n]);
dc->Requests.resize(0);
// Create windows for each automatic docking nodes
// We can have NULL pointers when we delete nodes, but because ID are recycled this should amortize nicely (and our node count will never be very high)
for (int n = 0; n < dc->Nodes.Data.Size; n++)
if (ImGuiDockNode* node = (ImGuiDockNode*)dc->Nodes.Data[n].val_p)
if (node->IsFloatingNode())
DockNodeUpdate(node);
}
static ImGuiDockNode* ImGui::DockContextFindNodeByID(ImGuiContext* ctx, ImGuiID id)
{
return (ImGuiDockNode*)ctx->DockContext->Nodes.GetVoidPtr(id);
}
ImGuiID ImGui::DockContextGenNodeID(ImGuiContext* ctx)
{
// Generate an ID for new node (the exact ID value doesn't matter as long as it is not already used)
// FIXME-OPT FIXME-DOCKING: This is suboptimal, even if the node count is small enough not to be a worry. We should poke in ctx->Nodes to find a suitable ID faster.
ImGuiID id = 0x0001;
while (DockContextFindNodeByID(ctx, id) != NULL)
id++;
return id;
}
static ImGuiDockNode* ImGui::DockContextAddNode(ImGuiContext* ctx, ImGuiID id)
{
// Generate an ID for the new node (the exact ID value doesn't matter as long as it is not already used) and add the first window.
if (id == 0)
id = DockContextGenNodeID(ctx);
else
IM_ASSERT(DockContextFindNodeByID(ctx, id) == NULL);
// We don't set node->LastFrameAlive on construction. Nodes are always created at all time to reflect .ini settings!
IMGUI_DEBUG_LOG_DOCKING("DockContextAddNode 0x%08X\n", id);
ImGuiDockNode* node = IM_NEW(ImGuiDockNode)(id);
ctx->DockContext->Nodes.SetVoidPtr(node->ID, node);
return node;
}
static void ImGui::DockContextRemoveNode(ImGuiContext* ctx, ImGuiDockNode* node, bool merge_sibling_into_parent_node)
{
ImGuiContext& g = *ctx;
ImGuiDockContext* dc = ctx->DockContext;
IMGUI_DEBUG_LOG_DOCKING("DockContextRemoveNode 0x%08X\n", node->ID);
IM_ASSERT(DockContextFindNodeByID(ctx, node->ID) == node);
IM_ASSERT(node->ChildNodes[0] == NULL && node->ChildNodes[1] == NULL);
IM_ASSERT(node->Windows.Size == 0);
if (node->HostWindow)
node->HostWindow->DockNodeAsHost = NULL;
ImGuiDockNode* parent_node = node->ParentNode;
const bool merge = (merge_sibling_into_parent_node && parent_node != NULL);
if (merge)
{
IM_ASSERT(parent_node->ChildNodes[0] == node || parent_node->ChildNodes[1] == node);
ImGuiDockNode* sibling_node = (parent_node->ChildNodes[0] == node ? parent_node->ChildNodes[1] : parent_node->ChildNodes[0]);
DockNodeTreeMerge(&g, parent_node, sibling_node);
}
else
{
for (int n = 0; parent_node && n < IM_ARRAYSIZE(parent_node->ChildNodes); n++)
if (parent_node->ChildNodes[n] == node)
node->ParentNode->ChildNodes[n] = NULL;
dc->Nodes.SetVoidPtr(node->ID, NULL);
IM_DELETE(node);
}
}
static int IMGUI_CDECL DockNodeComparerDepthMostFirst(const void* lhs, const void* rhs)
{
const ImGuiDockNode* a = *(const ImGuiDockNode* const*)lhs;
const ImGuiDockNode* b = *(const ImGuiDockNode* const*)rhs;
return ImGui::DockNodeGetDepth(b) - ImGui::DockNodeGetDepth(a);
}
// Pre C++0x doesn't allow us to use a function-local type (without linkage) as template parameter, so we moved this here.
struct ImGuiDockContextPruneNodeData
{
int CountWindows, CountChildWindows, CountChildNodes;
ImGuiID RootID;
ImGuiDockContextPruneNodeData() { CountWindows = CountChildWindows = CountChildNodes = 0; RootID = 0; }
};
// Garbage collect unused nodes (run once at init time)
static void ImGui::DockContextPruneUnusedSettingsNodes(ImGuiContext* ctx)
{
ImGuiContext& g = *ctx;
ImGuiDockContext* dc = ctx->DockContext;
IM_ASSERT(g.Windows.Size == 0);
ImPool<ImGuiDockContextPruneNodeData> pool;
pool.Reserve(dc->SettingsNodes.Size);
// Count child nodes and compute RootID
for (int settings_n = 0; settings_n < dc->SettingsNodes.Size; settings_n++)
{
ImGuiDockNodeSettings* settings = &dc->SettingsNodes[settings_n];
ImGuiDockContextPruneNodeData* parent_data = settings->ParentNodeID ? pool.GetByKey(settings->ParentNodeID) : 0;
pool.GetOrAddByKey(settings->ID)->RootID = parent_data ? parent_data->RootID : settings->ID;
if (settings->ParentNodeID)
pool.GetOrAddByKey(settings->ParentNodeID)->CountChildNodes++;
}
// Count reference to dock ids from dockspaces
// We track the 'auto-DockNode <- manual-Window <- manual-DockSpace' in order to avoid 'auto-DockNode' being ditched by DockContextPruneUnusedSettingsNodes()
for (int settings_n = 0; settings_n < dc->SettingsNodes.Size; settings_n++)
{
ImGuiDockNodeSettings* settings = &dc->SettingsNodes[settings_n];
if (settings->ParentWindowID != 0)
if (ImGuiWindowSettings* window_settings = FindWindowSettings(settings->ParentWindowID))
if (window_settings->DockId)
if (ImGuiDockContextPruneNodeData* data = pool.GetByKey(window_settings->DockId))
data->CountChildNodes++;
}
// Count reference to dock ids from window settings
// We guard against the possibility of an invalid .ini file (RootID may point to a missing node)
for (int settings_n = 0; settings_n < g.SettingsWindows.Size; settings_n++)
if (ImGuiID dock_id = g.SettingsWindows[settings_n].DockId)
if (ImGuiDockContextPruneNodeData* data = pool.GetByKey(dock_id))
{
data->CountWindows++;
if (ImGuiDockContextPruneNodeData* data_root = (data->RootID == dock_id) ? data : pool.GetByKey(data->RootID))
data_root->CountChildWindows++;
}
// Prune
for (int settings_n = 0; settings_n < dc->SettingsNodes.Size; settings_n++)
{
ImGuiDockNodeSettings* settings = &dc->SettingsNodes[settings_n];
ImGuiDockContextPruneNodeData* data = pool.GetByKey(settings->ID);
if (data->CountWindows > 1)
continue;
ImGuiDockContextPruneNodeData* data_root = (data->RootID == settings->ID) ? data : pool.GetByKey(data->RootID);
bool remove = false;
remove |= (data->CountWindows == 1 && settings->ParentNodeID == 0 && data->CountChildNodes == 0 && !(settings->Flags & ImGuiDockNodeFlags_CentralNode)); // Floating root node with only 1 window
remove |= (data->CountWindows == 0 && settings->ParentNodeID == 0 && data->CountChildNodes == 0); // Leaf nodes with 0 window
remove |= (data_root->CountChildWindows == 0);
if (remove)
{
IMGUI_DEBUG_LOG_DOCKING("DockContextPruneUnusedSettingsNodes: Prune 0x%08X\n", settings->ID);
DockSettingsRemoveNodeReferences(&settings->ID, 1);
settings->ID = 0;
}
}
}
static void ImGui::DockContextBuildNodesFromSettings(ImGuiContext* ctx, ImGuiDockNodeSettings* node_settings_array, int node_settings_count)
{
// Build nodes
for (int node_n = 0; node_n < node_settings_count; node_n++)
{
ImGuiDockNodeSettings* settings = &node_settings_array[node_n];
if (settings->ID == 0)
continue;
ImGuiDockNode* node = DockContextAddNode(ctx, settings->ID);
node->ParentNode = settings->ParentNodeID ? DockContextFindNodeByID(ctx, settings->ParentNodeID) : NULL;
node->Pos = ImVec2(settings->Pos.x, settings->Pos.y);
node->Size = ImVec2(settings->Size.x, settings->Size.y);
node->SizeRef = ImVec2(settings->SizeRef.x, settings->SizeRef.y);
node->AuthorityForPos = node->AuthorityForSize = node->AuthorityForViewport = ImGuiDataAuthority_DockNode;
if (node->ParentNode && node->ParentNode->ChildNodes[0] == NULL)
node->ParentNode->ChildNodes[0] = node;
else if (node->ParentNode && node->ParentNode->ChildNodes[1] == NULL)
node->ParentNode->ChildNodes[1] = node;
node->SelectedTabID = settings->SelectedWindowID;
node->SplitAxis = settings->SplitAxis;
node->LocalFlags |= (settings->Flags & ImGuiDockNodeFlags_SavedFlagsMask_);
// Bind host window immediately if it already exist (in case of a rebuild)
// This is useful as the RootWindowForTitleBarHighlight links necessary to highlight the currently focused node requires node->HostWindow to be set.
char host_window_title[20];
ImGuiDockNode* root_node = DockNodeGetRootNode(node);
node->HostWindow = FindWindowByName(DockNodeGetHostWindowTitle(root_node, host_window_title, IM_ARRAYSIZE(host_window_title)));
}
}
void ImGui::DockContextBuildAddWindowsToNodes(ImGuiContext* ctx, ImGuiID root_id)
{
// Rebind all windows to nodes (they can also lazily rebind but we'll have a visible glitch during the first frame)
ImGuiContext& g = *ctx;
for (int n = 0; n < g.Windows.Size; n++)
{
ImGuiWindow* window = g.Windows[n];
if (window->DockId == 0 || window->LastFrameActive < g.FrameCount - 1)
continue;
if (window->DockNode != NULL)
continue;
ImGuiDockNode* node = DockContextFindNodeByID(ctx, window->DockId);
IM_ASSERT(node != NULL); // This should have been called after DockContextBuildNodesFromSettings()
if (root_id == 0 || DockNodeGetRootNode(node)->ID == root_id)
DockNodeAddWindow(node, window, true);
}
}
//-----------------------------------------------------------------------------
// Docking: ImGuiDockContext Docking/Undocking functions
//-----------------------------------------------------------------------------
// - DockContextQueueDock()
// - DockContextQueueUndockWindow()
// - DockContextQueueUndockNode()
// - DockContextQueueNotifyRemovedNode()
// - DockContextProcessDock()
// - DockContextProcessUndockWindow()
// - DockContextProcessUndockNode()
// - DockContextCalcDropPosForDocking()
//-----------------------------------------------------------------------------
void ImGui::DockContextQueueDock(ImGuiContext* ctx, ImGuiWindow* target, ImGuiDockNode* target_node, ImGuiWindow* payload, ImGuiDir split_dir, float split_ratio, bool split_outer)
{
IM_ASSERT(target != payload);
ImGuiDockRequest req;
req.Type = ImGuiDockRequestType_Dock;
req.DockTargetWindow = target;
req.DockTargetNode = target_node;
req.DockPayload = payload;
req.DockSplitDir = split_dir;
req.DockSplitRatio = split_ratio;
req.DockSplitOuter = split_outer;
ctx->DockContext->Requests.push_back(req);
}
void ImGui::DockContextQueueUndockWindow(ImGuiContext* ctx, ImGuiWindow* window)
{
ImGuiDockRequest req;
req.Type = ImGuiDockRequestType_Undock;
req.UndockTargetWindow = window;
ctx->DockContext->Requests.push_back(req);
}
void ImGui::DockContextQueueUndockNode(ImGuiContext* ctx, ImGuiDockNode* node)
{
ImGuiDockRequest req;
req.Type = ImGuiDockRequestType_Undock;
req.UndockTargetNode = node;
ctx->DockContext->Requests.push_back(req);
}
void ImGui::DockContextQueueNotifyRemovedNode(ImGuiContext* ctx, ImGuiDockNode* node)
{
ImGuiDockContext* dc = ctx->DockContext;
for (int n = 0; n < dc->Requests.Size; n++)
if (dc->Requests[n].DockTargetNode == node)
dc->Requests[n].Type = ImGuiDockRequestType_None;
}
void ImGui::DockContextProcessDock(ImGuiContext* ctx, ImGuiDockRequest* req)
{
IM_ASSERT((req->Type == ImGuiDockRequestType_Dock && req->DockPayload != NULL) || (req->Type == ImGuiDockRequestType_Split && req->DockPayload == NULL));
IM_ASSERT(req->DockTargetWindow != NULL || req->DockTargetNode != NULL);
ImGuiContext& g = *ctx;
IM_UNUSED(g);
ImGuiWindow* payload_window = req->DockPayload; // Optional
ImGuiWindow* target_window = req->DockTargetWindow;
ImGuiDockNode* node = req->DockTargetNode;
if (payload_window)
IMGUI_DEBUG_LOG_DOCKING("DockContextProcessDock node 0x%08X target '%s' dock window '%s', split_dir %d\n", node ? node->ID : 0, target_window ? target_window->Name : "NULL", payload_window ? payload_window->Name : "NULL", req->DockSplitDir);
else
IMGUI_DEBUG_LOG_DOCKING("DockContextProcessDock node 0x%08X, split_dir %d\n", node ? node->ID : 0, req->DockSplitDir);
// Decide which Tab will be selected at the end of the operation
ImGuiID next_selected_id = 0;
ImGuiDockNode* payload_node = NULL;
if (payload_window)
{
payload_node = payload_window->DockNodeAsHost;
payload_window->DockNodeAsHost = NULL; // Important to clear this as the node will have its life as a child which might be merged/deleted later.
if (payload_node && payload_node->IsLeafNode())
next_selected_id = payload_node->TabBar->NextSelectedTabId ? payload_node->TabBar->NextSelectedTabId : payload_node->TabBar->SelectedTabId;
if (payload_node == NULL)
next_selected_id = payload_window->ID;
}
// FIXME-DOCK: When we are trying to dock an existing single-window node into a loose window, transfer Node ID as well
// When processing an interactive split, usually LastFrameAlive will be < g.FrameCount. But DockBuilder operations can make it ==.
if (node)
IM_ASSERT(node->LastFrameAlive <= g.FrameCount);
if (node && target_window && node == target_window->DockNodeAsHost)
IM_ASSERT(node->Windows.Size > 0 || node->IsSplitNode() || node->IsCentralNode());
// Create new node and add existing window to it
if (node == NULL)
{
node = DockContextAddNode(ctx, 0);
node->Pos = target_window->Pos;
node->Size = target_window->Size;
if (target_window->DockNodeAsHost == NULL)
{
DockNodeAddWindow(node, target_window, true);
node->TabBar->Tabs[0].Flags &= ~ImGuiTabItemFlags_Unsorted;
target_window->DockIsActive = true;
}
}
ImGuiDir split_dir = req->DockSplitDir;
if (split_dir != ImGuiDir_None)
{
// Split into one, one side will be our payload node unless we are dropping a loose window
const ImGuiAxis split_axis = (split_dir == ImGuiDir_Left || split_dir == ImGuiDir_Right) ? ImGuiAxis_X : ImGuiAxis_Y;
const int split_inheritor_child_idx = (split_dir == ImGuiDir_Left || split_dir == ImGuiDir_Up) ? 1 : 0; // Current contents will be moved to the opposite side
const float split_ratio = req->DockSplitRatio;
DockNodeTreeSplit(ctx, node, split_axis, split_inheritor_child_idx, split_ratio, payload_node); // payload_node may be NULL here!
ImGuiDockNode* new_node = node->ChildNodes[split_inheritor_child_idx ^ 1];
new_node->HostWindow = node->HostWindow;
node = new_node;
}
node->LocalFlags &= ~ImGuiDockNodeFlags_HiddenTabBar;
if (node != payload_node)
{
// Create tab bar before we call DockNodeMoveWindows (which would attempt to move the old tab-bar, which would lead us to payload tabs wrongly appearing before target tabs!)
if (node->Windows.Size > 0 && node->TabBar == NULL)
{
DockNodeAddTabBar(node);
for (int n = 0; n < node->Windows.Size; n++)
TabBarAddTab(node->TabBar, ImGuiTabItemFlags_None, node->Windows[n]);
}
if (payload_node != NULL)
{
// Transfer full payload node (with 1+ child windows or child nodes)
if (payload_node->IsSplitNode())
{
if (node->Windows.Size > 0)
{
// We can dock a split payload into a node that already has windows _only_ if our payload is a node tree with a single visible node.
// In this situation, we move the windows of the target node into the currently visible node of the payload.
// This allows us to preserve some of the underlying dock tree settings nicely.
IM_ASSERT(payload_node->OnlyNodeWithWindows != NULL); // The docking should have been blocked by DockNodePreviewDockCalc() early on and never submitted.
ImGuiDockNode* visible_node = payload_node->OnlyNodeWithWindows;
if (visible_node->TabBar)
IM_ASSERT(visible_node->TabBar->Tabs.Size > 0);
DockNodeMoveWindows(node, visible_node);
DockNodeMoveWindows(visible_node, node);
DockSettingsRenameNodeReferences(node->ID, visible_node->ID);
}
if (node->IsCentralNode())
{
// Central node property needs to be moved to a leaf node, pick the last focused one.
// FIXME-DOCKING: If we had to transfer other flags here, what would the policy be?
ImGuiDockNode* last_focused_node = DockContextFindNodeByID(ctx, payload_node->LastFocusedNodeID);
IM_ASSERT(last_focused_node != NULL);
ImGuiDockNode* last_focused_root_node = DockNodeGetRootNode(last_focused_node);
IM_ASSERT(last_focused_root_node == DockNodeGetRootNode(payload_node));
last_focused_node->LocalFlags |= ImGuiDockNodeFlags_CentralNode;
node->LocalFlags &= ~ImGuiDockNodeFlags_CentralNode;
last_focused_root_node->CentralNode = last_focused_node;
}
IM_ASSERT(node->Windows.Size == 0);
DockNodeMoveChildNodes(node, payload_node);
}
else
{
const ImGuiID payload_dock_id = payload_node->ID;
DockNodeMoveWindows(node, payload_node);
DockSettingsRenameNodeReferences(payload_dock_id, node->ID);
}
DockContextRemoveNode(ctx, payload_node, true);
}
else if (payload_window)
{
// Transfer single window
const ImGuiID payload_dock_id = payload_window->DockId;
node->VisibleWindow = payload_window;
DockNodeAddWindow(node, payload_window, true);
if (payload_dock_id != 0)
DockSettingsRenameNodeReferences(payload_dock_id, node->ID);
}
}
else
{
// When docking a floating single window node we want to reevaluate auto-hiding of the tab bar
node->WantHiddenTabBarUpdate = true;
}
// Update selection immediately
if (ImGuiTabBar* tab_bar = node->TabBar)
tab_bar->NextSelectedTabId = next_selected_id;
MarkIniSettingsDirty();
}
void ImGui::DockContextProcessUndockWindow(ImGuiContext* ctx, ImGuiWindow* window, bool clear_persistent_docking_ref)
{
(void)ctx;
if (window->DockNode)
DockNodeRemoveWindow(window->DockNode, window, clear_persistent_docking_ref ? 0 : window->DockId);
else
window->DockId = 0;
window->Collapsed = false;
window->DockIsActive = false;
window->DockTabIsVisible = false;
MarkIniSettingsDirty();
}
void ImGui::DockContextProcessUndockNode(ImGuiContext* ctx, ImGuiDockNode* node)
{
IM_ASSERT(node->IsLeafNode());
IM_ASSERT(node->Windows.Size >= 1);
if (node->IsRootNode() || node->IsCentralNode())
{
// In the case of a root node or central node, the node will have to stay in place. Create a new node to receive the payload.
ImGuiDockNode* new_node = DockContextAddNode(ctx, 0);
DockNodeMoveWindows(new_node, node);
DockSettingsRenameNodeReferences(node->ID, new_node->ID);
for (int n = 0; n < new_node->Windows.Size; n++)
UpdateWindowParentAndRootLinks(new_node->Windows[n], new_node->Windows[n]->Flags, NULL);
new_node->AuthorityForPos = new_node->AuthorityForSize = ImGuiDataAuthority_Window;
new_node->WantMouseMove = true;
}
else
{
// Otherwise extract our node and merging our sibling back into the parent node.
IM_ASSERT(node->ParentNode->ChildNodes[0] == node || node->ParentNode->ChildNodes[1] == node);
int index_in_parent = (node->ParentNode->ChildNodes[0] == node) ? 0 : 1;
node->ParentNode->ChildNodes[index_in_parent] = NULL;
DockNodeTreeMerge(ctx, node->ParentNode, node->ParentNode->ChildNodes[index_in_parent ^ 1]);
node->ParentNode->AuthorityForViewport = ImGuiDataAuthority_Window; // The node that stays in place keeps the viewport, so our newly dragged out node will create a new viewport
node->ParentNode = NULL;
node->AuthorityForPos = node->AuthorityForSize = ImGuiDataAuthority_Window;
node->WantMouseMove = true;
}
MarkIniSettingsDirty();
}
// This is mostly used for automation.
bool ImGui::DockContextCalcDropPosForDocking(ImGuiWindow* target, ImGuiDockNode* target_node, ImGuiWindow* payload, ImGuiDir split_dir, bool split_outer, ImVec2* out_pos)
{
if (split_outer)
{
IM_ASSERT(0);
}
else
{
ImGuiDockPreviewData split_data;
DockNodePreviewDockCalc(target, target_node, payload, &split_data, false, split_outer);
if (split_data.DropRectsDraw[split_dir+1].IsInverted())
return false;
*out_pos = split_data.DropRectsDraw[split_dir+1].GetCenter();
return true;
}
return false;
}
//-----------------------------------------------------------------------------
// Docking: ImGuiDockNode
//-----------------------------------------------------------------------------
// - DockNodeGetTabOrder()
// - DockNodeAddWindow()
// - DockNodeRemoveWindow()
// - DockNodeMoveChildNodes()
// - DockNodeMoveWindows()
// - DockNodeApplyPosSizeToWindows()
// - DockNodeHideHostWindow()
// - ImGuiDockNodeFindInfoResults
// - DockNodeFindInfo()
// - DockNodeUpdateVisibleFlagAndInactiveChilds()
// - DockNodeUpdateVisibleFlag()
// - DockNodeStartMouseMovingWindow()
// - DockNodeUpdate()
// - DockNodeUpdateWindowMenu()
// - DockNodeUpdateTabBar()
// - DockNodeAddTabBar()
// - DockNodeRemoveTabBar()
// - DockNodeIsDropAllowedOne()
// - DockNodeIsDropAllowed()
// - DockNodeCalcTabBarLayout()
// - DockNodeCalcSplitRects()
// - DockNodeCalcDropRectsAndTestMousePos()
// - DockNodePreviewDockCalc()
// - DockNodePreviewDockRender()
//-----------------------------------------------------------------------------
ImGuiDockNode::ImGuiDockNode(ImGuiID id)
{
ID = id;
SharedFlags = LocalFlags = ImGuiDockNodeFlags_None;
ParentNode = ChildNodes[0] = ChildNodes[1] = NULL;
TabBar = NULL;
SplitAxis = ImGuiAxis_None;
HostWindow = VisibleWindow = NULL;
CentralNode = OnlyNodeWithWindows = NULL;
LastFrameAlive = LastFrameActive = LastFrameFocused = -1;
LastFocusedNodeID = 0;
SelectedTabID = 0;
WantCloseTabID = 0;
AuthorityForPos = AuthorityForSize = ImGuiDataAuthority_DockNode;
AuthorityForViewport = ImGuiDataAuthority_Auto;
IsVisible = true;
IsFocused = HasCloseButton = HasWindowMenuButton = EnableCloseButton = false;
WantCloseAll = WantLockSizeOnce = WantMouseMove = WantHiddenTabBarUpdate = WantHiddenTabBarToggle = false;
MarkedForPosSizeWrite = false;
}
ImGuiDockNode::~ImGuiDockNode()
{
IM_DELETE(TabBar);
TabBar = NULL;
ChildNodes[0] = ChildNodes[1] = NULL;
}
int ImGui::DockNodeGetTabOrder(ImGuiWindow* window)
{
ImGuiTabBar* tab_bar = window->DockNode->TabBar;
if (tab_bar == NULL)
return -1;
ImGuiTabItem* tab = TabBarFindTabByID(tab_bar, window->ID);
return tab ? tab_bar->GetTabOrder(tab) : -1;
}
static void ImGui::DockNodeAddWindow(ImGuiDockNode* node, ImGuiWindow* window, bool add_to_tab_bar)
{
ImGuiContext& g = *GImGui; (void)g;
if (window->DockNode)
{
// Can overwrite an existing window->DockNode (e.g. pointing to a disabled DockSpace node)
IM_ASSERT(window->DockNode->ID != node->ID);
DockNodeRemoveWindow(window->DockNode, window, 0);
}
IM_ASSERT(window->DockNode == NULL || window->DockNodeAsHost == NULL);
IMGUI_DEBUG_LOG_DOCKING("DockNodeAddWindow node 0x%08X window '%s'\n", node->ID, window->Name);
node->Windows.push_back(window);
node->WantHiddenTabBarUpdate = true;
window->DockNode = node;
window->DockId = node->ID;
window->DockIsActive = (node->Windows.Size > 1);
window->DockTabWantClose = false;
// If more than 2 windows appeared on the same frame, we'll create a new hosting DockNode from the point of the second window submission.
// Then we need to hide the first window (after its been output) otherwise it would be visible as a standalone window for one frame.
if (node->HostWindow == NULL && node->Windows.Size == 2 && node->Windows[0]->WasActive == false)
{
node->Windows[0]->Hidden = true;
node->Windows[0]->HiddenFramesCanSkipItems = 1;
}
// When reactivating a node with one or two loose window, the window pos/size/viewport are authoritative over the node storage.
// In particular it is important we init the viewport from the first window so we don't create two viewports and drop one.
if (node->HostWindow == NULL && node->IsFloatingNode())
{
if (node->AuthorityForPos == ImGuiDataAuthority_Auto)
node->AuthorityForPos = ImGuiDataAuthority_Window;
if (node->AuthorityForSize == ImGuiDataAuthority_Auto)
node->AuthorityForSize = ImGuiDataAuthority_Window;
if (node->AuthorityForViewport == ImGuiDataAuthority_Auto)
node->AuthorityForViewport = ImGuiDataAuthority_Window;
}
// Add to tab bar if requested
if (add_to_tab_bar)
{
if (node->TabBar == NULL)
{
DockNodeAddTabBar(node);
node->TabBar->SelectedTabId = node->TabBar->NextSelectedTabId = node->SelectedTabID;
// Add existing windows
for (int n = 0; n < node->Windows.Size - 1; n++)
TabBarAddTab(node->TabBar, ImGuiTabItemFlags_None, node->Windows[n]);
}
TabBarAddTab(node->TabBar, ImGuiTabItemFlags_Unsorted, window);
}
DockNodeUpdateVisibleFlag(node);
// Update this without waiting for the next time we Begin() in the window, so our host window will have the proper title bar color on its first frame.
if (node->HostWindow)
UpdateWindowParentAndRootLinks(window, window->Flags | ImGuiWindowFlags_ChildWindow, node->HostWindow);
}
static void ImGui::DockNodeRemoveWindow(ImGuiDockNode* node, ImGuiWindow* window, ImGuiID save_dock_id)
{
ImGuiContext& g = *GImGui;
IM_ASSERT(window->DockNode == node);
//IM_ASSERT(window->RootWindow == node->HostWindow);
//IM_ASSERT(window->LastFrameActive < g.FrameCount); // We may call this from Begin()
IM_ASSERT(save_dock_id == 0 || save_dock_id == node->ID);
IMGUI_DEBUG_LOG_DOCKING("DockNodeRemoveWindow node 0x%08X window '%s'\n", node->ID, window->Name);
window->DockNode = NULL;
window->DockIsActive = window->DockTabWantClose = false;
window->DockId = save_dock_id;
UpdateWindowParentAndRootLinks(window, window->Flags & ~ImGuiWindowFlags_ChildWindow, NULL); // Update immediately
// Remove window
bool erased = false;
for (int n = 0; n < node->Windows.Size; n++)
if (node->Windows[n] == window)
{
node->Windows.erase(node->Windows.Data + n);
erased = true;
break;
}
IM_ASSERT(erased);
if (node->VisibleWindow == window)
node->VisibleWindow = NULL;
// Remove tab and possibly tab bar
node->WantHiddenTabBarUpdate = true;
if (node->TabBar)
{
TabBarRemoveTab(node->TabBar, window->ID);
const int tab_count_threshold_for_tab_bar = node->IsCentralNode() ? 1 : 2;
if (node->Windows.Size < tab_count_threshold_for_tab_bar)
DockNodeRemoveTabBar(node);
}
if (node->Windows.Size == 0 && !node->IsCentralNode() && !node->IsDockSpace() && window->DockId != node->ID)
{
// Automatic dock node delete themselves if they are not holding at least one tab
DockContextRemoveNode(&g, node, true);
return;
}
if (node->Windows.Size == 1 && !node->IsCentralNode() && node->HostWindow)
{
ImGuiWindow* remaining_window = node->Windows[0];
if (node->HostWindow->ViewportOwned && node->IsRootNode())
{
// Transfer viewport back to the remaining loose window
IM_ASSERT(node->HostWindow->Viewport->Window == node->HostWindow);
node->HostWindow->Viewport->Window = remaining_window;
node->HostWindow->Viewport->ID = remaining_window->ID;
}
remaining_window->Collapsed = node->HostWindow->Collapsed;
}
// Update visibility immediately is required so the DockNodeUpdateRemoveInactiveChilds() processing can reflect changes up the tree
DockNodeUpdateVisibleFlag(node);
}
static void ImGui::DockNodeMoveChildNodes(ImGuiDockNode* dst_node, ImGuiDockNode* src_node)
{
IM_ASSERT(dst_node->Windows.Size == 0);
dst_node->ChildNodes[0] = src_node->ChildNodes[0];
dst_node->ChildNodes[1] = src_node->ChildNodes[1];
if (dst_node->ChildNodes[0])
dst_node->ChildNodes[0]->ParentNode = dst_node;
if (dst_node->ChildNodes[1])
dst_node->ChildNodes[1]->ParentNode = dst_node;
dst_node->SplitAxis = src_node->SplitAxis;
dst_node->SizeRef = src_node->SizeRef;
src_node->ChildNodes[0] = src_node->ChildNodes[1] = NULL;
}
static void ImGui::DockNodeMoveWindows(ImGuiDockNode* dst_node, ImGuiDockNode* src_node)
{
// Insert tabs in the same orders as currently ordered (node->Windows isn't ordered)
IM_ASSERT(src_node && dst_node && dst_node != src_node);
ImGuiTabBar* src_tab_bar = src_node->TabBar;
if (src_tab_bar != NULL)
IM_ASSERT(src_node->Windows.Size == src_node->TabBar->Tabs.Size);
// If the dst_node is empty we can just move the entire tab bar (to preserve selection, scrolling, etc.)
bool move_tab_bar = (src_tab_bar != NULL) && (dst_node->TabBar == NULL);
if (move_tab_bar)
{
dst_node->TabBar = src_node->TabBar;
src_node->TabBar = NULL;
}
for (int n = 0; n < src_node->Windows.Size; n++)
{
ImGuiWindow* window = src_tab_bar ? src_tab_bar->Tabs[n].Window : src_node->Windows[n];
window->DockNode = NULL;
window->DockIsActive = false;
DockNodeAddWindow(dst_node, window, move_tab_bar ? false : true);
}
src_node->Windows.clear();
if (!move_tab_bar && src_node->TabBar)
{
if (dst_node->TabBar)
dst_node->TabBar->SelectedTabId = src_node->TabBar->SelectedTabId;
DockNodeRemoveTabBar(src_node);
}
}
static void ImGui::DockNodeApplyPosSizeToWindows(ImGuiDockNode* node)
{
for (int n = 0; n < node->Windows.Size; n++)
{
SetWindowPos(node->Windows[n], node->Pos, ImGuiCond_Always); // We don't assign directly to Pos because it can break the calculation of SizeContents on next frame
SetWindowSize(node->Windows[n], node->Size, ImGuiCond_Always);
}
}
static void ImGui::DockNodeHideHostWindow(ImGuiDockNode* node)
{
if (node->HostWindow)
{
if (node->HostWindow->DockNodeAsHost == node)
node->HostWindow->DockNodeAsHost = NULL;
node->HostWindow = NULL;
}
if (node->Windows.Size == 1)
{
node->VisibleWindow = node->Windows[0];
node->Windows[0]->DockIsActive = false;
}
if (node->TabBar)
DockNodeRemoveTabBar(node);
}
// Search function called once by root node in DockNodeUpdate()
struct ImGuiDockNodeFindInfoResults
{
ImGuiDockNode* CentralNode;
ImGuiDockNode* FirstNodeWithWindows;
int CountNodesWithWindows;
//ImGuiWindowClass WindowClassForMerges;
ImGuiDockNodeFindInfoResults() { CentralNode = FirstNodeWithWindows = NULL; CountNodesWithWindows = 0; }
};
static void DockNodeFindInfo(ImGuiDockNode* node, ImGuiDockNodeFindInfoResults* results)
{
if (node->Windows.Size > 0)
{
if (results->FirstNodeWithWindows == NULL)
results->FirstNodeWithWindows = node;
results->CountNodesWithWindows++;
}
if (node->IsCentralNode())
{
IM_ASSERT(results->CentralNode == NULL); // Should be only one
IM_ASSERT(node->IsLeafNode() && "If you get this assert: please submit .ini file + repro of actions leading to this.");
results->CentralNode = node;
}
if (results->CountNodesWithWindows > 1 && results->CentralNode != NULL)
return;
if (node->ChildNodes[0])
DockNodeFindInfo(node->ChildNodes[0], results);
if (node->ChildNodes[1])
DockNodeFindInfo(node->ChildNodes[1], results);
}
// - Remove inactive windows/nodes.
// - Update visibility flag.
static void ImGui::DockNodeUpdateVisibleFlagAndInactiveChilds(ImGuiDockNode* node)
{
ImGuiContext& g = *GImGui;
IM_ASSERT(node->ParentNode == NULL || node->ParentNode->ChildNodes[0] == node || node->ParentNode->ChildNodes[1] == node);
// Inherit most flags
if (node->ParentNode)
node->SharedFlags = node->ParentNode->SharedFlags & ImGuiDockNodeFlags_SharedFlagsInheritMask_;
// Recurse into children
// There is the possibility that one of our child becoming empty will delete itself and moving its sibling contents into 'node'.
// If 'node->ChildNode[0]' delete itself, then 'node->ChildNode[1]->Windows' will be moved into 'node'
// If 'node->ChildNode[1]' delete itself, then 'node->ChildNode[0]->Windows' will be moved into 'node' and the "remove inactive windows" loop will have run twice on those windows (harmless)
if (node->ChildNodes[0])
DockNodeUpdateVisibleFlagAndInactiveChilds(node->ChildNodes[0]);
if (node->ChildNodes[1])
DockNodeUpdateVisibleFlagAndInactiveChilds(node->ChildNodes[1]);
// Remove inactive windows
for (int window_n = 0; window_n < node->Windows.Size; window_n++)
{
ImGuiWindow* window = node->Windows[window_n];
IM_ASSERT(window->DockNode == node);
bool node_was_active = (node->LastFrameActive + 1 == g.FrameCount);
bool remove = false;
remove |= node_was_active && (window->LastFrameActive + 1 < g.FrameCount);
remove |= node_was_active && (node->WantCloseAll || node->WantCloseTabID == window->ID) && window->HasCloseButton && !(window->Flags & ImGuiWindowFlags_UnsavedDocument); // Submit all _expected_ closure from last frame
remove |= (window->DockTabWantClose);
if (!remove)
continue;
window->DockTabWantClose = false;
if (node->Windows.Size == 1 && !node->IsCentralNode())
{
DockNodeHideHostWindow(node);
DockNodeRemoveWindow(node, window, node->ID); // Will delete the node so it'll be invalid on return
return;
}
DockNodeRemoveWindow(node, window, node->ID);
window_n--;
}
// Auto-hide tab bar option
ImGuiDockNodeFlags node_flags = node->GetMergedFlags();
if (node->WantHiddenTabBarUpdate && node->Windows.Size == 1 && (node_flags & ImGuiDockNodeFlags_AutoHideTabBar) && !node->IsHiddenTabBar())
node->WantHiddenTabBarToggle = true;
node->WantHiddenTabBarUpdate = false;
// Apply toggles at a single point of the frame (here!)
if (node->Windows.Size > 1)
node->LocalFlags &= ~ImGuiDockNodeFlags_HiddenTabBar;
else if (node->WantHiddenTabBarToggle)
node->LocalFlags ^= ImGuiDockNodeFlags_HiddenTabBar;
node->WantHiddenTabBarToggle = false;
DockNodeUpdateVisibleFlag(node);
}
static void ImGui::DockNodeUpdateVisibleFlag(ImGuiDockNode* node)
{
// Update visibility flag
bool is_visible = (node->ParentNode == NULL) ? node->IsDockSpace() : node->IsCentralNode();
is_visible |= (node->Windows.Size > 0);
is_visible |= (node->ChildNodes[0] && node->ChildNodes[0]->IsVisible);
is_visible |= (node->ChildNodes[1] && node->ChildNodes[1]->IsVisible);
node->IsVisible = is_visible;
}
static void ImGui::DockNodeStartMouseMovingWindow(ImGuiDockNode* node, ImGuiWindow* window)
{
ImGuiContext& g = *GImGui;
IM_ASSERT(node->WantMouseMove == true);
ImVec2 backup_active_click_offset = g.ActiveIdClickOffset;
StartMouseMovingWindow(window);
g.MovingWindow = window; // If we are docked into a non moveable root window, StartMouseMovingWindow() won't set g.MovingWindow. Override that decision.
node->WantMouseMove = false;
g.ActiveIdClickOffset = backup_active_click_offset;
}
static void ImGui::DockNodeUpdate(ImGuiDockNode* node)
{
ImGuiContext& g = *GImGui;
IM_ASSERT(node->LastFrameActive != g.FrameCount);
node->LastFrameAlive = g.FrameCount;
node->MarkedForPosSizeWrite = false;
node->CentralNode = node->OnlyNodeWithWindows = NULL;
if (node->IsRootNode())
{
DockNodeUpdateVisibleFlagAndInactiveChilds(node);
// FIXME-DOCK: Merge this scan into the one above.
// - Setup central node pointers
// - Find if there's only a single visible window in the hierarchy (in which case we need to display a regular title bar -> FIXME-DOCK: that last part is not done yet!)
ImGuiDockNodeFindInfoResults results;
DockNodeFindInfo(node, &results);
node->CentralNode = results.CentralNode;
node->OnlyNodeWithWindows = (results.CountNodesWithWindows == 1) ? results.FirstNodeWithWindows : NULL;
if (node->LastFocusedNodeID == 0 && results.FirstNodeWithWindows != NULL)
node->LastFocusedNodeID = results.FirstNodeWithWindows->ID;
// Copy the window class from of our first window so it can be used for proper dock filtering.
// When node has mixed windows, prioritize the class with the most constraint (DockingAllowUnclassed = false) as the reference to copy.
// FIXME-DOCK: We don't recurse properly, this code could be reworked to work from DockNodeUpdateScanRec.
if (ImGuiDockNode* first_node_with_windows = results.FirstNodeWithWindows)
{
node->WindowClass = first_node_with_windows->Windows[0]->WindowClass;
for (int n = 1; n < first_node_with_windows->Windows.Size; n++)
if (first_node_with_windows->Windows[n]->WindowClass.DockingAllowUnclassed == false)
{
node->WindowClass = first_node_with_windows->Windows[n]->WindowClass;
break;
}
}
}
// Remove tab bar if not needed
if (node->TabBar && node->IsNoTabBar())
DockNodeRemoveTabBar(node);
// Early out for hidden root dock nodes (when all DockId references are in inactive windows, or there is only 1 floating window holding on the DockId)
bool want_to_hide_host_window = false;
if (node->Windows.Size <= 1 && node->IsFloatingNode() && node->IsLeafNode())
if (!g.IO.ConfigDockingAlwaysTabBar && (node->Windows.Size == 0 || !node->Windows[0]->WindowClass.DockingAlwaysTabBar))
want_to_hide_host_window = true;
if (want_to_hide_host_window)
{
if (node->Windows.Size == 1)
{
// Floating window pos/size is authoritative
ImGuiWindow* single_window = node->Windows[0];
node->Pos = single_window->Pos;
node->Size = single_window->SizeFull;
node->AuthorityForPos = node->AuthorityForSize = node->AuthorityForViewport = ImGuiDataAuthority_Window;
// Transfer focus immediately so when we revert to a regular window it is immediately selected
if (node->HostWindow && g.NavWindow == node->HostWindow)
FocusWindow(single_window);
if (node->HostWindow)
{
single_window->Viewport = node->HostWindow->Viewport;
single_window->ViewportId = node->HostWindow->ViewportId;
if (node->HostWindow->ViewportOwned)
{
single_window->Viewport->Window = single_window;
single_window->ViewportOwned = true;
}
}
}
DockNodeHideHostWindow(node);
node->WantCloseAll = false;
node->WantCloseTabID = 0;
node->HasCloseButton = node->HasWindowMenuButton = node->EnableCloseButton = false;
node->LastFrameActive = g.FrameCount;
if (node->WantMouseMove && node->Windows.Size == 1)
DockNodeStartMouseMovingWindow(node, node->Windows[0]);
return;
}
const ImGuiDockNodeFlags node_flags = node->GetMergedFlags();
// Bind or create host window
ImGuiWindow* host_window = NULL;
bool beginned_into_host_window = false;
if (node->IsDockSpace())
{
// [Explicit root dockspace node]
IM_ASSERT(node->HostWindow);
node->EnableCloseButton = false;
node->HasCloseButton = (node_flags & ImGuiDockNodeFlags_NoCloseButton) == 0;
node->HasWindowMenuButton = (node_flags & ImGuiDockNodeFlags_NoWindowMenuButton) == 0;
host_window = node->HostWindow;
}
else
{
// [Automatic root or child nodes]
node->EnableCloseButton = false;
node->HasCloseButton = (node->Windows.Size > 0) && (node_flags & ImGuiDockNodeFlags_NoWindowMenuButton) == 0;
node->HasWindowMenuButton = (node->Windows.Size > 0) && (node_flags & ImGuiDockNodeFlags_NoWindowMenuButton) == 0;
for (int window_n = 0; window_n < node->Windows.Size; window_n++)
{
// FIXME-DOCK: Setting DockIsActive here means that for single active window in a leaf node, DockIsActive will be cleared until the next Begin() call.
ImGuiWindow* window = node->Windows[window_n];
window->DockIsActive = (node->Windows.Size > 1);
node->EnableCloseButton |= window->HasCloseButton;
}
if (node->IsRootNode() && node->IsVisible)
{
ImGuiWindow* ref_window = (node->Windows.Size > 0) ? node->Windows[0] : NULL;
// Sync Pos
if (node->AuthorityForPos == ImGuiDataAuthority_Window && ref_window)
SetNextWindowPos(ref_window->Pos);
else if (node->AuthorityForPos == ImGuiDataAuthority_DockNode)
SetNextWindowPos(node->Pos);
// Sync Size
if (node->AuthorityForSize == ImGuiDataAuthority_Window && ref_window)
SetNextWindowSize(ref_window->SizeFull);
else if (node->AuthorityForSize == ImGuiDataAuthority_DockNode)
SetNextWindowSize(node->Size);
// Sync Collapsed
if (node->AuthorityForSize == ImGuiDataAuthority_Window && ref_window)
SetNextWindowCollapsed(ref_window->Collapsed);
// Sync Viewport
if (node->AuthorityForViewport == ImGuiDataAuthority_Window && ref_window)
SetNextWindowViewport(ref_window->ViewportId);
SetNextWindowClass(&node->WindowClass);
// Begin into the host window
char window_label[20];
DockNodeGetHostWindowTitle(node, window_label, IM_ARRAYSIZE(window_label));
ImGuiWindowFlags window_flags = ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoScrollWithMouse | ImGuiWindowFlags_DockNodeHost;
window_flags |= ImGuiWindowFlags_NoFocusOnAppearing;
window_flags |= ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoNavFocus | ImGuiWindowFlags_NoCollapse;
window_flags |= ImGuiWindowFlags_NoTitleBar;
PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(0, 0));
Begin(window_label, NULL, window_flags);
PopStyleVar();
beginned_into_host_window = true;
node->HostWindow = host_window = g.CurrentWindow;
host_window->DockNodeAsHost = node;
host_window->DC.CursorPos = host_window->Pos;
node->Pos = host_window->Pos;
node->Size = host_window->Size;
// We set ImGuiWindowFlags_NoFocusOnAppearing because we don't want the host window to take full focus (e.g. steal NavWindow)
// But we still it bring it to the front of display. There's no way to choose this precise behavior via window flags.
// One simple case to ponder if: window A has a toggle to create windows B/C/D. Dock B/C/D together, clear the toggle and enable it again.
// When reappearing B/C/D will request focus and be moved to the top of the display pile, but they are not linked to the dock host window
// during the frame they appear. The dock host window would keep its old display order, and the sorting in EndFrame would move B/C/D back
// after the dock host window, losing their top-most status.
if (node->HostWindow->Appearing)
BringWindowToDisplayFront(node->HostWindow);
node->AuthorityForPos = node->AuthorityForSize = node->AuthorityForViewport = ImGuiDataAuthority_Auto;
}
else if (node->ParentNode)
{
node->HostWindow = host_window = node->ParentNode->HostWindow;
node->AuthorityForPos = node->AuthorityForSize = node->AuthorityForViewport = ImGuiDataAuthority_Auto;
}
if (node->WantMouseMove && node->HostWindow)
DockNodeStartMouseMovingWindow(node, node->HostWindow);
}
// Update focused node (the one whose title bar is highlight) within a node tree
if (node->IsSplitNode())
IM_ASSERT(node->TabBar == NULL);
if (node->IsRootNode())
if (g.NavWindow && g.NavWindow->RootWindowDockStop->DockNode && g.NavWindow->RootWindowDockStop->ParentWindow == host_window)
node->LastFocusedNodeID = g.NavWindow->RootWindowDockStop->DockNode->ID;
// We need to draw a background at the root level if requested by ImGuiDockNodeFlags_PassthruCentralNode, but we will only know the correct pos/size after
// processing the resizing splitters. So we are using the DrawList channel splitting facility to submit drawing primitives out of order!
const bool render_dockspace_bg = node->IsRootNode() && host_window && (node_flags & ImGuiDockNodeFlags_PassthruCentralNode) != 0;
if (render_dockspace_bg)
{
host_window->DrawList->ChannelsSplit(2);
host_window->DrawList->ChannelsSetCurrent(1);
}
// Register a hit-test hole in the window unless we are currently dragging a window that is compatible with our dockspace
const ImGuiDockNode* central_node = node->CentralNode;
const bool central_node_hole = node->IsRootNode() && host_window && (node_flags & ImGuiDockNodeFlags_PassthruCentralNode) != 0 && central_node != NULL && central_node->IsEmpty();
bool central_node_hole_register_hit_test_hole = central_node_hole;
if (central_node_hole)
if (const ImGuiPayload* payload = ImGui::GetDragDropPayload())
if (payload->IsDataType(IMGUI_PAYLOAD_TYPE_WINDOW) && DockNodeIsDropAllowed(host_window, *(ImGuiWindow**)payload->Data))
central_node_hole_register_hit_test_hole = false;
if (central_node_hole_register_hit_test_hole)
{
// Add a little padding to match the "resize from edges" behavior and allow grabbing the splitter easily.
IM_ASSERT(node->IsDockSpace()); // We cannot pass this flag without the DockSpace() api. Testing this because we also setup the hole in host_window->ParentNode
ImRect central_hole(central_node->Pos, central_node->Pos + central_node->Size);
central_hole.Expand(ImVec2(-WINDOWS_RESIZE_FROM_EDGES_HALF_THICKNESS, -WINDOWS_RESIZE_FROM_EDGES_HALF_THICKNESS));
if (central_node_hole && !central_hole.IsInverted())
{
SetWindowHitTestHole(host_window, central_hole.Min, central_hole.Max - central_hole.Min);
SetWindowHitTestHole(host_window->ParentWindow, central_hole.Min, central_hole.Max - central_hole.Min);
}
}
// Update position/size, process and draw resizing splitters
if (node->IsRootNode() && host_window)
{
DockNodeTreeUpdatePosSize(node, host_window->Pos, host_window->Size);
DockNodeTreeUpdateSplitter(node);
}
// Draw empty node background (currently can only be the Central Node)
if (host_window && node->IsEmpty() && node->IsVisible && !(node_flags & ImGuiDockNodeFlags_PassthruCentralNode))
host_window->DrawList->AddRectFilled(node->Pos, node->Pos + node->Size, GetColorU32(ImGuiCol_DockingEmptyBg));
// Draw whole dockspace background if ImGuiDockNodeFlags_PassthruCentralNode if set.
if (render_dockspace_bg && node->IsVisible)
{
host_window->DrawList->ChannelsSetCurrent(0);
if (central_node_hole)
RenderRectFilledWithHole(host_window->DrawList, node->Rect(), central_node->Rect(), GetColorU32(ImGuiCol_WindowBg), 0.0f);
else
host_window->DrawList->AddRectFilled(node->Pos, node->Pos + node->Size, GetColorU32(ImGuiCol_WindowBg), 0.0f);
host_window->DrawList->ChannelsMerge();
}
// Draw and populate Tab Bar
if (host_window && node->Windows.Size > 0)
{
DockNodeUpdateTabBar(node, host_window);
}
else
{
node->WantCloseAll = false;
node->WantCloseTabID = 0;
node->IsFocused = false;
}
if (node->TabBar && node->TabBar->SelectedTabId)
node->SelectedTabID = node->TabBar->SelectedTabId;
else if (node->Windows.Size > 0)
node->SelectedTabID = node->Windows[0]->ID;
// Draw payload drop target
if (host_window && node->IsVisible)
if (node->IsRootNode() && (g.MovingWindow == NULL || g.MovingWindow->RootWindow != host_window))
BeginAsDockableDragDropTarget(host_window);
// We update this after DockNodeUpdateTabBar()
node->LastFrameActive = g.FrameCount;
// Recurse into children
// FIXME-DOCK FIXME-OPT: Should not need to recurse into children
if (host_window)
{
if (node->ChildNodes[0])
DockNodeUpdate(node->ChildNodes[0]);
if (node->ChildNodes[1])
DockNodeUpdate(node->ChildNodes[1]);
// Render outer borders last (after the tab bar)
if (node->IsRootNode())
RenderWindowOuterBorders(host_window);
}
// End host window
if (beginned_into_host_window) //-V1020
End();
}
// Compare TabItem nodes given the last known DockOrder (will persist in .ini file as hint), used to sort tabs when multiple tabs are added on the same frame.
static int IMGUI_CDECL TabItemComparerByDockOrder(const void* lhs, const void* rhs)
{
ImGuiWindow* a = ((const ImGuiTabItem*)lhs)->Window;
ImGuiWindow* b = ((const ImGuiTabItem*)rhs)->Window;
if (int d = ((a->DockOrder == -1) ? INT_MAX : a->DockOrder) - ((b->DockOrder == -1) ? INT_MAX : b->DockOrder))
return d;
return (a->BeginOrderWithinContext - b->BeginOrderWithinContext);
}
static ImGuiID ImGui::DockNodeUpdateWindowMenu(ImGuiDockNode* node, ImGuiTabBar* tab_bar)
{
// Try to position the menu so it is more likely to stays within the same viewport
ImGuiContext& g = *GImGui;
ImGuiID ret_tab_id = 0;
if (g.Style.WindowMenuButtonPosition == ImGuiDir_Left)
SetNextWindowPos(ImVec2(node->Pos.x, node->Pos.y + GetFrameHeight()), ImGuiCond_Always, ImVec2(0.0f, 0.0f));
else
SetNextWindowPos(ImVec2(node->Pos.x + node->Size.x, node->Pos.y + GetFrameHeight()), ImGuiCond_Always, ImVec2(1.0f, 0.0f));
if (BeginPopup("#WindowMenu"))
{
node->IsFocused = true;
if (tab_bar->Tabs.Size == 1)
{
if (MenuItem("Hide tab bar", NULL, node->IsHiddenTabBar()))
node->WantHiddenTabBarToggle = true;
}
else
{
for (int tab_n = 0; tab_n < tab_bar->Tabs.Size; tab_n++)
{
ImGuiTabItem* tab = &tab_bar->Tabs[tab_n];
IM_ASSERT(tab->Window != NULL);
if (Selectable(tab->Window->Name, tab->ID == tab_bar->SelectedTabId))
ret_tab_id = tab->ID;
SameLine();
Text(" ");
}
}
EndPopup();
}
return ret_tab_id;
}
static void ImGui::DockNodeUpdateTabBar(ImGuiDockNode* node, ImGuiWindow* host_window)
{
ImGuiContext& g = *GImGui;
ImGuiStyle& style = g.Style;
const bool node_was_active = (node->LastFrameActive + 1 == g.FrameCount);
const bool closed_all = node->WantCloseAll && node_was_active;
const ImGuiID closed_one = node->WantCloseTabID && node_was_active;
node->WantCloseAll = false;
node->WantCloseTabID = 0;
// Decide if we should use a focused title bar color
bool is_focused = false;
ImGuiDockNode* root_node = DockNodeGetRootNode(node);
if (g.NavWindowingTarget)
is_focused = (g.NavWindowingTarget->DockNode == node);
else if (g.NavWindow && g.NavWindow->RootWindowForTitleBarHighlight == host_window->RootWindow && root_node->LastFocusedNodeID == node->ID)
is_focused = true;
// Hidden tab bar will show a triangle on the upper-left (in Begin)
if (node->IsHiddenTabBar() || node->IsNoTabBar())
{
node->VisibleWindow = (node->Windows.Size > 0) ? node->Windows[0] : NULL;
node->IsFocused = is_focused;
if (is_focused)
node->LastFrameFocused = g.FrameCount;
if (node->VisibleWindow)
{
// Notify root of visible window (used to display title in OS task bar)
if (is_focused || root_node->VisibleWindow == NULL)
root_node->VisibleWindow = node->VisibleWindow;
if (node->TabBar)
node->TabBar->VisibleTabId = node->VisibleWindow->ID;
}
return;
}
// Move ourselves to the Menu layer (so we can be accessed by tapping Alt) + undo SkipItems flag in order to draw over the title bar even if the window is collapsed
bool backup_skip_item = host_window->SkipItems;
if (!node->IsDockSpace())
{
host_window->SkipItems = false;
host_window->DC.NavLayerCurrent = ImGuiNavLayer_Menu;
host_window->DC.NavLayerCurrentMask = (1 << ImGuiNavLayer_Menu);
}
// Use PushOverrideID() instead of PushID() to use the node id _without_ the host window ID.
// This is to facilitate computing those ID from the outside, and will affect more or less only the ID of the collapse button, popup and tabs,
// as docked windows themselves will override the stack with their own root ID.
PushOverrideID(node->ID);
ImGuiTabBar* tab_bar = node->TabBar;
bool tab_bar_is_recreated = (tab_bar == NULL); // Tab bar are automatically destroyed when a node gets hidden
if (tab_bar == NULL)
{
DockNodeAddTabBar(node);
tab_bar = node->TabBar;
}
ImGuiID focus_tab_id = 0;
node->IsFocused = is_focused;
const ImGuiDockNodeFlags node_flags = node->GetMergedFlags();
const bool has_window_menu_button = (node_flags & ImGuiDockNodeFlags_NoWindowMenuButton) == 0;
const bool has_close_button = (node_flags & ImGuiDockNodeFlags_NoCloseButton) == 0;
// In a dock node, the Collapse Button turns into the Window Menu button.
// FIXME-DOCK FIXME-OPT: Could we recycle popups id accross multiple dock nodes?
if (has_window_menu_button && IsPopupOpen("#WindowMenu"))
{
if (ImGuiID tab_id = DockNodeUpdateWindowMenu(node, tab_bar))
focus_tab_id = tab_bar->NextSelectedTabId = tab_id;
is_focused |= node->IsFocused;
}
// Layout
ImRect title_bar_rect, tab_bar_rect;
ImVec2 window_menu_button_pos;
DockNodeCalcTabBarLayout(node, &title_bar_rect, &tab_bar_rect, &window_menu_button_pos);
// Title bar
if (is_focused)
node->LastFrameFocused = g.FrameCount;
ImU32 title_bar_col = GetColorU32(host_window->Collapsed ? ImGuiCol_TitleBgCollapsed : is_focused ? ImGuiCol_TitleBgActive : ImGuiCol_TitleBg);
host_window->DrawList->AddRectFilled(title_bar_rect.Min, title_bar_rect.Max, title_bar_col, host_window->WindowRounding, ImDrawCornerFlags_Top);
// Docking/Collapse button
if (has_window_menu_button)
{
if (CollapseButton(host_window->GetID("#COLLAPSE"), window_menu_button_pos, node))
OpenPopup("#WindowMenu");
if (IsItemActive())
focus_tab_id = tab_bar->SelectedTabId;
}
// Submit new tabs and apply NavWindow focus back to the tab bar. They will be added as Unsorted and sorted below based on relative DockOrder value.
const int tabs_count_old = tab_bar->Tabs.Size;
for (int window_n = 0; window_n < node->Windows.Size; window_n++)
{
ImGuiWindow* window = node->Windows[window_n];
if (g.NavWindow && g.NavWindow->RootWindowDockStop == window)
tab_bar->SelectedTabId = window->ID;
if (TabBarFindTabByID(tab_bar, window->ID) == NULL)
TabBarAddTab(tab_bar, ImGuiTabItemFlags_Unsorted, window);
}
// If multiple tabs are appearing on the same frame, sort them based on their persistent DockOrder value
int tabs_unsorted_start = tab_bar->Tabs.Size;
for (int tab_n = tab_bar->Tabs.Size - 1; tab_n >= 0 && (tab_bar->Tabs[tab_n].Flags & ImGuiTabItemFlags_Unsorted); tab_n--)
{
// FIXME-DOCKING: Consider only clearing the flag after the tab has been alive for a few consecutive frames, allowing late comers to not break sorting?
tab_bar->Tabs[tab_n].Flags &= ~ImGuiTabItemFlags_Unsorted;
tabs_unsorted_start = tab_n;
}
if (tab_bar->Tabs.Size > tabs_unsorted_start)
{
IMGUI_DEBUG_LOG_DOCKING("In node 0x%08X: %d new appearing tabs:%s\n", node->ID, tab_bar->Tabs.Size - tabs_unsorted_start, (tab_bar->Tabs.Size > tabs_unsorted_start + 1) ? " (will sort)" : "");
for (int tab_n = tabs_unsorted_start; tab_n < tab_bar->Tabs.Size; tab_n++)
IMGUI_DEBUG_LOG_DOCKING(" - Tab '%s' Order %d\n", tab_bar->Tabs[tab_n].Window->Name, tab_bar->Tabs[tab_n].Window->DockOrder);
if (tab_bar->Tabs.Size > tabs_unsorted_start + 1)
ImQsort(tab_bar->Tabs.Data + tabs_unsorted_start, tab_bar->Tabs.Size - tabs_unsorted_start, sizeof(ImGuiTabItem), TabItemComparerByDockOrder);
}
// Selected newly added tabs, or persistent tab ID if the tab bar was just recreated
if (tab_bar_is_recreated && TabBarFindTabByID(tab_bar, node->SelectedTabID) != NULL)
tab_bar->SelectedTabId = tab_bar->NextSelectedTabId = node->SelectedTabID;
else if (tab_bar->Tabs.Size > tabs_count_old)
tab_bar->SelectedTabId = tab_bar->NextSelectedTabId = tab_bar->Tabs.back().Window->ID;
// Begin tab bar
ImGuiTabBarFlags tab_bar_flags = ImGuiTabBarFlags_Reorderable | ImGuiTabBarFlags_AutoSelectNewTabs; // | ImGuiTabBarFlags_NoTabListScrollingButtons);
tab_bar_flags |= ImGuiTabBarFlags_SaveSettings | ImGuiTabBarFlags_DockNode;
if (!host_window->Collapsed && is_focused)
tab_bar_flags |= ImGuiTabBarFlags_IsFocused;
BeginTabBarEx(tab_bar, tab_bar_rect, tab_bar_flags, node);
//host_window->DrawList->AddRect(tab_bar_rect.Min, tab_bar_rect.Max, IM_COL32(255,0,255,255));
// Submit actual tabs
node->VisibleWindow = NULL;
for (int window_n = 0; window_n < node->Windows.Size; window_n++)
{
ImGuiWindow* window = node->Windows[window_n];
if ((closed_all || closed_one == window->ID) && window->HasCloseButton && !(window->Flags & ImGuiWindowFlags_UnsavedDocument))
continue;
if (window->LastFrameActive + 1 >= g.FrameCount || !node_was_active)
{
ImGuiTabItemFlags tab_item_flags = 0;
if (window->Flags & ImGuiWindowFlags_UnsavedDocument)
tab_item_flags |= ImGuiTabItemFlags_UnsavedDocument;
if (tab_bar->Flags & ImGuiTabBarFlags_NoCloseWithMiddleMouseButton)
tab_item_flags |= ImGuiTabItemFlags_NoCloseWithMiddleMouseButton;
bool tab_open = true;
TabItemEx(tab_bar, window->Name, window->HasCloseButton ? &tab_open : NULL, tab_item_flags, window);
if (!tab_open)
node->WantCloseTabID = window->ID;
if (tab_bar->VisibleTabId == window->ID)
node->VisibleWindow = window;
// Store last item data so it can be queried with IsItemXXX functions after the user Begin() call
window->DockTabItemStatusFlags = host_window->DC.LastItemStatusFlags;
window->DockTabItemRect = host_window->DC.LastItemRect;
// Update navigation ID on menu layer
if (g.NavWindow && g.NavWindow->RootWindowDockStop == window && (window->DC.NavLayerActiveMask & (1 << 1)) == 0)
host_window->NavLastIds[1] = window->ID;
}
}
// Notify root of visible window (used to display title in OS task bar)
if (node->VisibleWindow)
if (is_focused || root_node->VisibleWindow == NULL)
root_node->VisibleWindow = node->VisibleWindow;
// Close button (after VisibleWindow was updated)
// Note that VisibleWindow may have been overrided by CTRL+Tabbing, so VisibleWindow->ID may be != from tab_bar->SelectedTabId
if (has_close_button && node->VisibleWindow)
{
if (!node->VisibleWindow->HasCloseButton)
{
PushItemFlag(ImGuiItemFlags_Disabled, true);
PushStyleColor(ImGuiCol_Text, style.Colors[ImGuiCol_Text] * ImVec4(1.0f,1.0f,1.0f,0.5f));
}
const float button_sz = g.FontSize;
if (CloseButton(host_window->GetID("#CLOSE"), title_bar_rect.GetTR() + ImVec2(-style.FramePadding.x * 2.0f - button_sz, 0.0f)))
if (ImGuiTabItem* tab = TabBarFindTabByID(tab_bar, tab_bar->VisibleTabId))
{
node->WantCloseTabID = tab->ID;
TabBarCloseTab(tab_bar, tab);
}
//if (IsItemActive())
// focus_tab_id = tab_bar->SelectedTabId;
if (!node->VisibleWindow->HasCloseButton)
{
PopStyleColor();
PopItemFlag();
}
}
// When clicking on the title bar outside of tabs, we still focus the selected tab for that node
// FIXME: TabItem use AllowItemOverlap so we manually perform a more specific test for now (hovered || held)
ImGuiID title_bar_id = host_window->GetID("#TITLEBAR");
if (g.HoveredId == 0 || g.HoveredId == title_bar_id || g.ActiveId == title_bar_id)
{
bool held;
ButtonBehavior(title_bar_rect, title_bar_id, NULL, &held);
if (held)
{
if (IsMouseClicked(0))
focus_tab_id = tab_bar->SelectedTabId;
// Forward moving request to selected window
if (ImGuiTabItem* tab = TabBarFindTabByID(tab_bar, tab_bar->SelectedTabId))
StartMouseDragFromTitleBar(tab->Window, node, false);
}
}
// Forward focus from host node to selected window
//if (is_focused && g.NavWindow == host_window && !g.NavWindowingTarget)
// focus_tab_id = tab_bar->SelectedTabId;
// When clicked on a tab we requested focus to the docked child
// This overrides the value set by "forward focus from host node to selected window".
if (tab_bar->NextSelectedTabId)
focus_tab_id = tab_bar->NextSelectedTabId;
// Apply navigation focus
if (focus_tab_id != 0)
if (ImGuiTabItem* tab = TabBarFindTabByID(tab_bar, focus_tab_id))
{
FocusWindow(tab->Window);
NavInitWindow(tab->Window, false);
}
EndTabBar();
PopID();
// Restore SkipItems flag
if (!node->IsDockSpace())
{
host_window->DC.NavLayerCurrent = ImGuiNavLayer_Main;
host_window->DC.NavLayerCurrentMask = (1 << ImGuiNavLayer_Main);
host_window->SkipItems = backup_skip_item;
}
}
static void ImGui::DockNodeAddTabBar(ImGuiDockNode* node)
{
IM_ASSERT(node->TabBar == NULL);
node->TabBar = IM_NEW(ImGuiTabBar);
}
static void ImGui::DockNodeRemoveTabBar(ImGuiDockNode* node)
{
if (node->TabBar == NULL)
return;
IM_DELETE(node->TabBar);
node->TabBar = NULL;
}
static bool DockNodeIsDropAllowedOne(ImGuiWindow* payload, ImGuiWindow* host_window)
{
if (host_window->DockNodeAsHost && host_window->DockNodeAsHost->IsDockSpace() && payload->BeginOrderWithinContext < host_window->BeginOrderWithinContext)
return false;
ImGuiWindowClass* host_class = host_window->DockNodeAsHost ? &host_window->DockNodeAsHost->WindowClass : &host_window->WindowClass;
ImGuiWindowClass* payload_class = &payload->WindowClass;
if (host_class->ClassId != payload_class->ClassId)
{
if (host_class->ClassId != 0 && host_class->DockingAllowUnclassed && payload_class->ClassId == 0)
return true;
if (payload_class->ClassId != 0 && payload_class->DockingAllowUnclassed && host_class->ClassId == 0)
return true;
return false;
}
return true;
}
static bool ImGui::DockNodeIsDropAllowed(ImGuiWindow* host_window, ImGuiWindow* root_payload)
{
if (root_payload->DockNodeAsHost && root_payload->DockNodeAsHost->IsSplitNode())
return true;
const int payload_count = root_payload->DockNodeAsHost ? root_payload->DockNodeAsHost->Windows.Size : 1;
for (int payload_n = 0; payload_n < payload_count; payload_n++)
{
ImGuiWindow* payload = root_payload->DockNodeAsHost ? root_payload->DockNodeAsHost->Windows[payload_n] : root_payload;
if (DockNodeIsDropAllowedOne(payload, host_window))
return true;
}
return false;
}
// window menu button == collapse button when not in a dock node.
// FIXME: This is similar to RenderWindowTitleBarContents, may want to share code.
static void ImGui::DockNodeCalcTabBarLayout(const ImGuiDockNode* node, ImRect* out_title_rect, ImRect* out_tab_bar_rect, ImVec2* out_window_menu_button_pos)
{
ImGuiContext& g = *GImGui;
ImRect r = ImRect(node->Pos.x, node->Pos.y, node->Pos.x + node->Size.x, node->Pos.y + g.FontSize + g.Style.FramePadding.y * 2.0f);
if (out_title_rect) { *out_title_rect = r; }
ImVec2 window_menu_button_pos = r.Min;
r.Min.x += g.Style.FramePadding.x;
r.Max.x -= g.Style.FramePadding.x;
if (node->HasCloseButton)
{
r.Max.x -= g.FontSize;// +1.0f; // In DockNodeUpdateTabBar() we currently display a disabled close button even if there is none.
}
if (node->HasWindowMenuButton && g.Style.WindowMenuButtonPosition == ImGuiDir_Left)
{
r.Min.x += g.FontSize; // + g.Style.ItemInnerSpacing.x; // <-- Adding ItemInnerSpacing makes the title text moves slightly when in a docking tab bar. Instead we adjusted RenderArrowDockMenu()
}
else if (node->HasWindowMenuButton && g.Style.WindowMenuButtonPosition == ImGuiDir_Right)
{
r.Max.x -= g.FontSize + g.Style.FramePadding.x;
window_menu_button_pos = ImVec2(r.Max.x, r.Min.y);
}
if (out_tab_bar_rect) { *out_tab_bar_rect = r; }
if (out_window_menu_button_pos) { *out_window_menu_button_pos = window_menu_button_pos; }
}
void ImGui::DockNodeCalcSplitRects(ImVec2& pos_old, ImVec2& size_old, ImVec2& pos_new, ImVec2& size_new, ImGuiDir dir, ImVec2 size_new_desired)
{
ImGuiContext& g = *GImGui;
const float dock_spacing = g.Style.ItemInnerSpacing.x;
const ImGuiAxis axis = (dir == ImGuiDir_Left || dir == ImGuiDir_Right) ? ImGuiAxis_X : ImGuiAxis_Y;
pos_new[axis ^ 1] = pos_old[axis ^ 1];
size_new[axis ^ 1] = size_old[axis ^ 1];
// Distribute size on given axis (with a desired size or equally)
const float w_avail = size_old[axis] - dock_spacing;
if (size_new_desired[axis] > 0.0f && size_new_desired[axis] <= w_avail * 0.5f)
{
size_new[axis] = size_new_desired[axis];
size_old[axis] = (float)(int)(w_avail - size_new[axis]);
}
else
{
size_new[axis] = (float)(int)(w_avail * 0.5f);
size_old[axis] = (float)(int)(w_avail - size_new[axis]);
}
// Position each node
if (dir == ImGuiDir_Right || dir == ImGuiDir_Down)
{
pos_new[axis] = pos_old[axis] + size_old[axis] + dock_spacing;
}
else if (dir == ImGuiDir_Left || dir == ImGuiDir_Up)
{
pos_new[axis] = pos_old[axis];
pos_old[axis] = pos_new[axis] + size_new[axis] + dock_spacing;
}
}
// Retrieve the drop rectangles for a given direction or for the center + perform hit testing.
bool ImGui::DockNodeCalcDropRectsAndTestMousePos(const ImRect& parent, ImGuiDir dir, ImRect& out_r, bool outer_docking, ImVec2* test_mouse_pos)
{
ImGuiContext& g = *GImGui;
const float parent_smaller_axis = ImMin(parent.GetWidth(), parent.GetHeight());
const float hs_for_central_nodes = ImMin(g.FontSize * 1.5f, ImMax(g.FontSize * 0.5f, parent_smaller_axis / 8.0f));
float hs_w; // Half-size, longer axis
float hs_h; // Half-size, smaller axis
ImVec2 off; // Distance from edge or center
if (outer_docking)
{
//hs_w = ImFloor(ImClamp(parent_smaller_axis - hs_for_central_nodes * 4.0f, g.FontSize * 0.5f, g.FontSize * 8.0f));
//hs_h = ImFloor(hs_w * 0.15f);
//off = ImVec2(ImFloor(parent.GetWidth() * 0.5f - GetFrameHeightWithSpacing() * 1.4f - hs_h), ImFloor(parent.GetHeight() * 0.5f - GetFrameHeightWithSpacing() * 1.4f - hs_h));
hs_w = ImFloor(hs_for_central_nodes * 1.50f);
hs_h = ImFloor(hs_for_central_nodes * 0.80f);
off = ImVec2(ImFloor(parent.GetWidth() * 0.5f - GetFrameHeightWithSpacing() * 0.0f - hs_h), ImFloor(parent.GetHeight() * 0.5f - GetFrameHeightWithSpacing() * 0.0f - hs_h));
}
else
{
hs_w = ImFloor(hs_for_central_nodes);
hs_h = ImFloor(hs_for_central_nodes * 0.90f);
off = ImVec2(ImFloor(hs_w * 2.40f), ImFloor(hs_w * 2.40f));
}
ImVec2 c = ImFloor(parent.GetCenter());
if (dir == ImGuiDir_None) { out_r = ImRect(c.x - hs_w, c.y - hs_w, c.x + hs_w, c.y + hs_w); }
else if (dir == ImGuiDir_Up) { out_r = ImRect(c.x - hs_w, c.y - off.y - hs_h, c.x + hs_w, c.y - off.y + hs_h); }
else if (dir == ImGuiDir_Down) { out_r = ImRect(c.x - hs_w, c.y + off.y - hs_h, c.x + hs_w, c.y + off.y + hs_h); }
else if (dir == ImGuiDir_Left) { out_r = ImRect(c.x - off.x - hs_h, c.y - hs_w, c.x - off.x + hs_h, c.y + hs_w); }
else if (dir == ImGuiDir_Right) { out_r = ImRect(c.x + off.x - hs_h, c.y - hs_w, c.x + off.x + hs_h, c.y + hs_w); }
if (test_mouse_pos == NULL)
return false;
ImRect hit_r = out_r;
if (!outer_docking)
{
// Custom hit testing for the 5-way selection, designed to reduce flickering when moving diagonally between sides
hit_r.Expand(ImFloor(hs_w * 0.30f));
ImVec2 mouse_delta = (*test_mouse_pos - c);
float mouse_delta_len2 = ImLengthSqr(mouse_delta);
float r_threshold_center = hs_w * 1.4f;
float r_threshold_sides = hs_w * (1.4f + 1.2f);
if (mouse_delta_len2 < r_threshold_center * r_threshold_center)
return (dir == ImGuiDir_None);
if (mouse_delta_len2 < r_threshold_sides * r_threshold_sides)
return (dir == ImGetDirQuadrantFromDelta(mouse_delta.x, mouse_delta.y));
}
return hit_r.Contains(*test_mouse_pos);
}
// host_node may be NULL if the window doesn't have a DockNode already.
static void ImGui::DockNodePreviewDockCalc(ImGuiWindow* host_window, ImGuiDockNode* host_node, ImGuiWindow* root_payload, ImGuiDockPreviewData* data, bool is_explicit_target, bool is_outer_docking)
{
ImGuiContext& g = *GImGui;
// There is an edge case when docking into a dockspace which only has inactive nodes.
// In this case DockNodeTreeFindNodeByPos() will have selected a leaf node which is inactive.
// Because the inactive leaf node doesn't have proper pos/size yet, we'll use the root node as reference.
ImGuiDockNode* ref_node_for_rect = (host_node && !host_node->IsVisible) ? DockNodeGetRootNode(host_node) : host_node;
if (ref_node_for_rect)
IM_ASSERT(ref_node_for_rect->IsVisible);
// Build a tentative future node (reuse same structure because it is practical)
data->FutureNode.HasCloseButton = (host_node ? host_node->HasCloseButton : host_window->HasCloseButton) || (root_payload->HasCloseButton);
data->FutureNode.HasWindowMenuButton = host_node ? true : ((host_window->Flags & ImGuiWindowFlags_NoCollapse) == 0);
data->FutureNode.Pos = host_node ? ref_node_for_rect->Pos : host_window->Pos;
data->FutureNode.Size = host_node ? ref_node_for_rect->Size : host_window->Size;
// Figure out here we are allowed to dock
ImGuiDockNodeFlags host_node_flags = host_node ? host_node->GetMergedFlags() : 0;
const bool src_is_visibly_splitted = root_payload->DockNodeAsHost && root_payload->DockNodeAsHost->IsSplitNode() && (root_payload->DockNodeAsHost->OnlyNodeWithWindows == NULL);
data->IsCenterAvailable = !is_outer_docking;
if (src_is_visibly_splitted && (!host_node || !host_node->IsEmpty()))
data->IsCenterAvailable = false;
if (host_node && (host_node_flags & ImGuiDockNodeFlags_NoDockingInCentralNode) && host_node->IsCentralNode())
data->IsCenterAvailable = false;
data->IsSidesAvailable = true;
if ((host_node && (host_node_flags & ImGuiDockNodeFlags_NoSplit)) || g.IO.ConfigDockingNoSplit)
data->IsSidesAvailable = false;
if (!is_outer_docking && host_node && host_node->ParentNode == NULL && host_node->IsCentralNode())
data->IsSidesAvailable = false;
// Calculate drop shapes geometry for allowed splitting directions
IM_ASSERT(ImGuiDir_None == -1);
data->SplitNode = host_node;
data->SplitDir = ImGuiDir_None;
data->IsSplitDirExplicit = false;
if (!host_window->Collapsed)
for (int dir = ImGuiDir_None; dir < ImGuiDir_COUNT; dir++)
{
if (dir == ImGuiDir_None && !data->IsCenterAvailable)
continue;
if (dir != ImGuiDir_None && !data->IsSidesAvailable)
continue;
if (DockNodeCalcDropRectsAndTestMousePos(data->FutureNode.Rect(), (ImGuiDir)dir, data->DropRectsDraw[dir+1], is_outer_docking, &g.IO.MousePos))
{
data->SplitDir = (ImGuiDir)dir;
data->IsSplitDirExplicit = true;
}
}
// When docking without holding Shift, we only allow and preview docking when hovering over a drop rect or over the title bar
data->IsDropAllowed = (data->SplitDir != ImGuiDir_None) || (data->IsCenterAvailable);
if (!is_explicit_target && !data->IsSplitDirExplicit && !g.IO.ConfigDockingWithShift)
data->IsDropAllowed = false;
// Calculate split area
data->SplitRatio = 0.0f;
if (data->SplitDir != ImGuiDir_None)
{
ImGuiDir split_dir = data->SplitDir;
ImGuiAxis split_axis = (split_dir == ImGuiDir_Left || split_dir == ImGuiDir_Right) ? ImGuiAxis_X : ImGuiAxis_Y;
ImVec2 pos_new, pos_old = data->FutureNode.Pos;
ImVec2 size_new, size_old = data->FutureNode.Size;
DockNodeCalcSplitRects(pos_old, size_old, pos_new, size_new, split_dir, root_payload->Size);
// Calculate split ratio so we can pass it down the docking request
float split_ratio = ImSaturate(size_new[split_axis] / data->FutureNode.Size[split_axis]);
data->FutureNode.Pos = pos_new;
data->FutureNode.Size = size_new;
data->SplitRatio = (split_dir == ImGuiDir_Right || split_dir == ImGuiDir_Down) ? (1.0f - split_ratio) : (split_ratio);
}
}
static void ImGui::DockNodePreviewDockRender(ImGuiWindow* host_window, ImGuiDockNode* host_node, ImGuiWindow* root_payload, const ImGuiDockPreviewData* data)
{
ImGuiContext& g = *GImGui;
IM_ASSERT(g.CurrentWindow == host_window); // Because we rely on font size to calculate tab sizes
// With this option, we only display the preview on the target viewport, and the payload viewport is made transparent.
// To compensate for the single layer obstructed by the payload, we'll increase the alpha of the preview nodes.
const bool is_transparent_payload = g.IO.ConfigDockingTransparentPayload;
// In case the two windows involved are on different viewports, we will draw the overlay on each of them.
int overlay_draw_lists_count = 0;
ImDrawList* overlay_draw_lists[2];
overlay_draw_lists[overlay_draw_lists_count++] = GetForegroundDrawList(host_window->Viewport);
if (host_window->Viewport != root_payload->Viewport && !is_transparent_payload)
overlay_draw_lists[overlay_draw_lists_count++] = GetForegroundDrawList(root_payload->Viewport);
// Draw main preview rectangle
const ImU32 overlay_col_tabs = GetColorU32(ImGuiCol_TabActive);
const ImU32 overlay_col_main = GetColorU32(ImGuiCol_DockingPreview, is_transparent_payload ? 0.60f : 0.40f);
const ImU32 overlay_col_drop = GetColorU32(ImGuiCol_DockingPreview, is_transparent_payload ? 0.90f : 0.70f);
const ImU32 overlay_col_drop_hovered = GetColorU32(ImGuiCol_DockingPreview, is_transparent_payload ? 1.20f : 1.00f);
const ImU32 overlay_col_lines = GetColorU32(ImGuiCol_NavWindowingHighlight, is_transparent_payload ? 0.80f : 0.60f);
// Display area preview
const bool can_preview_tabs = (root_payload->DockNodeAsHost == NULL || root_payload->DockNodeAsHost->Windows.Size > 0);
if (data->IsDropAllowed)
{
ImRect overlay_rect = data->FutureNode.Rect();
if (data->SplitDir == ImGuiDir_None && can_preview_tabs)
overlay_rect.Min.y += GetFrameHeight();
if (data->SplitDir != ImGuiDir_None || data->IsCenterAvailable)
for (int overlay_n = 0; overlay_n < overlay_draw_lists_count; overlay_n++)
overlay_draw_lists[overlay_n]->AddRectFilled(overlay_rect.Min, overlay_rect.Max, overlay_col_main, host_window->WindowRounding);
}
// Display tab shape/label preview unless we are splitting node (it generally makes the situation harder to read)
if (data->IsDropAllowed && can_preview_tabs && data->SplitDir == ImGuiDir_None && data->IsCenterAvailable)
{
// Compute target tab bar geometry so we can locate our preview tabs
ImRect tab_bar_rect;
DockNodeCalcTabBarLayout(&data->FutureNode, NULL, &tab_bar_rect, NULL);
ImVec2 tab_pos = tab_bar_rect.Min;
if (host_node && host_node->TabBar)
{
if (!host_node->IsHiddenTabBar() && !host_node->IsNoTabBar())
tab_pos.x += host_node->TabBar->OffsetMax + g.Style.ItemInnerSpacing.x; // We don't use OffsetNewTab because when using non-persistent-order tab bar it is incremented with each Tab submission.
else
tab_pos.x += g.Style.ItemInnerSpacing.x + TabItemCalcSize(host_node->Windows[0]->Name, host_node->Windows[0]->HasCloseButton).x;
}
else if (!(host_window->Flags & ImGuiWindowFlags_DockNodeHost))
{
tab_pos.x += g.Style.ItemInnerSpacing.x + TabItemCalcSize(host_window->Name, host_window->HasCloseButton).x; // Account for slight offset which will be added when changing from title bar to tab bar
}
// Draw tab shape/label preview (payload may be a loose window or a host window carrying multiple tabbed windows)
if (root_payload->DockNodeAsHost)
IM_ASSERT(root_payload->DockNodeAsHost->Windows.Size == root_payload->DockNodeAsHost->TabBar->Tabs.Size);
const int payload_count = root_payload->DockNodeAsHost ? root_payload->DockNodeAsHost->TabBar->Tabs.Size : 1;
for (int payload_n = 0; payload_n < payload_count; payload_n++)
{
// Calculate the tab bounding box for each payload window
ImGuiWindow* payload = root_payload->DockNodeAsHost ? root_payload->DockNodeAsHost->TabBar->Tabs[payload_n].Window : root_payload;
if (!DockNodeIsDropAllowedOne(payload, host_window))
continue;
ImVec2 tab_size = TabItemCalcSize(payload->Name, payload->HasCloseButton);
ImRect tab_bb(tab_pos.x, tab_pos.y, tab_pos.x + tab_size.x, tab_pos.y + tab_size.y);
tab_pos.x += tab_size.x + g.Style.ItemInnerSpacing.x;
for (int overlay_n = 0; overlay_n < overlay_draw_lists_count; overlay_n++)
{
ImGuiTabItemFlags tab_flags = ImGuiTabItemFlags_Preview | ((payload->Flags & ImGuiWindowFlags_UnsavedDocument) ? ImGuiTabItemFlags_UnsavedDocument : 0);
if (!tab_bar_rect.Contains(tab_bb))
overlay_draw_lists[overlay_n]->PushClipRect(tab_bar_rect.Min, tab_bar_rect.Max);
TabItemBackground(overlay_draw_lists[overlay_n], tab_bb, tab_flags, overlay_col_tabs);
TabItemLabelAndCloseButton(overlay_draw_lists[overlay_n], tab_bb, tab_flags, g.Style.FramePadding, payload->Name, 0, 0);
if (!tab_bar_rect.Contains(tab_bb))
overlay_draw_lists[overlay_n]->PopClipRect();
}
}
}
// Display drop boxes
const float overlay_rounding = ImMax(3.0f, g.Style.FrameRounding);
for (int dir = ImGuiDir_None; dir < ImGuiDir_COUNT; dir++)
{
if (!data->DropRectsDraw[dir + 1].IsInverted())
{
ImRect draw_r = data->DropRectsDraw[dir + 1];
ImRect draw_r_in = draw_r;
draw_r_in.Expand(-2.0f);
ImU32 overlay_col = (data->SplitDir == (ImGuiDir)dir && data->IsSplitDirExplicit) ? overlay_col_drop_hovered : overlay_col_drop;
for (int overlay_n = 0; overlay_n < overlay_draw_lists_count; overlay_n++)
{
ImVec2 center = ImFloor(draw_r_in.GetCenter());
overlay_draw_lists[overlay_n]->AddRectFilled(draw_r.Min, draw_r.Max, overlay_col, overlay_rounding);
overlay_draw_lists[overlay_n]->AddRect(draw_r_in.Min, draw_r_in.Max, overlay_col_lines, overlay_rounding);
if (dir == ImGuiDir_Left || dir == ImGuiDir_Right)
overlay_draw_lists[overlay_n]->AddLine(ImVec2(center.x, draw_r_in.Min.y), ImVec2(center.x, draw_r_in.Max.y), overlay_col_lines);
if (dir == ImGuiDir_Up || dir == ImGuiDir_Down)
overlay_draw_lists[overlay_n]->AddLine(ImVec2(draw_r_in.Min.x, center.y), ImVec2(draw_r_in.Max.x, center.y), overlay_col_lines);
}
}
// Stop after ImGuiDir_None
if ((host_node && (host_node->GetMergedFlags() & ImGuiDockNodeFlags_NoSplit)) || g.IO.ConfigDockingNoSplit)
return;
}
}
//-----------------------------------------------------------------------------
// Docking: ImGuiDockNode Tree manipulation functions
//-----------------------------------------------------------------------------
// - DockNodeTreeSplit()
// - DockNodeTreeMerge()
// - DockNodeTreeUpdatePosSize()
// - DockNodeTreeUpdateSplitterFindTouchingNode()
// - DockNodeTreeUpdateSplitter()
// - DockNodeTreeFindFallbackLeafNode()
// - DockNodeTreeFindNodeByPos()
//-----------------------------------------------------------------------------
void ImGui::DockNodeTreeSplit(ImGuiContext* ctx, ImGuiDockNode* parent_node, ImGuiAxis split_axis, int split_inheritor_child_idx, float split_ratio, ImGuiDockNode* new_node)
{
ImGuiContext& g = *GImGui;
IM_ASSERT(split_axis != ImGuiAxis_None);
ImGuiDockNode* child_0 = (new_node && split_inheritor_child_idx != 0) ? new_node : DockContextAddNode(ctx, 0);
child_0->ParentNode = parent_node;
ImGuiDockNode* child_1 = (new_node && split_inheritor_child_idx != 1) ? new_node : DockContextAddNode(ctx, 0);
child_1->ParentNode = parent_node;
ImGuiDockNode* child_inheritor = (split_inheritor_child_idx == 0) ? child_0 : child_1;
DockNodeMoveChildNodes(child_inheritor, parent_node);
parent_node->ChildNodes[0] = child_0;
parent_node->ChildNodes[1] = child_1;
parent_node->ChildNodes[split_inheritor_child_idx]->VisibleWindow = parent_node->VisibleWindow;
parent_node->SplitAxis = split_axis;
parent_node->VisibleWindow = NULL;
parent_node->AuthorityForPos = parent_node->AuthorityForSize = ImGuiDataAuthority_DockNode;
float size_avail = (parent_node->Size[split_axis] - IMGUI_DOCK_SPLITTER_SIZE);
size_avail = ImMax(size_avail, g.Style.WindowMinSize[split_axis] * 2.0f);
IM_ASSERT(size_avail > 0.0f); // If you created a node manually with DockBuilderAddNode(), you need to also call DockBuilderSetNodeSize() before splitting.
child_0->SizeRef = child_1->SizeRef = parent_node->Size;
child_0->SizeRef[split_axis] = ImFloor(size_avail * split_ratio);
child_1->SizeRef[split_axis] = ImFloor(size_avail - child_0->SizeRef[split_axis]);
DockNodeMoveWindows(parent_node->ChildNodes[split_inheritor_child_idx], parent_node);
DockNodeTreeUpdatePosSize(parent_node, parent_node->Pos, parent_node->Size);
// Flags transfer (e.g. this is where we transfer the ImGuiDockNodeFlags_CentralNode property)
child_0->SharedFlags = parent_node->SharedFlags & ImGuiDockNodeFlags_SharedFlagsInheritMask_;
child_1->SharedFlags = parent_node->SharedFlags & ImGuiDockNodeFlags_SharedFlagsInheritMask_;
child_inheritor->LocalFlags = parent_node->LocalFlags & ImGuiDockNodeFlags_LocalFlagsTransferMask_;
parent_node->LocalFlags &= ~ImGuiDockNodeFlags_LocalFlagsTransferMask_;
if (child_inheritor->IsCentralNode())
DockNodeGetRootNode(parent_node)->CentralNode = child_inheritor;
}
void ImGui::DockNodeTreeMerge(ImGuiContext* ctx, ImGuiDockNode* parent_node, ImGuiDockNode* merge_lead_child)
{
// When called from DockContextProcessUndockNode() it is possible that one of the child is NULL.
ImGuiDockNode* child_0 = parent_node->ChildNodes[0];
ImGuiDockNode* child_1 = parent_node->ChildNodes[1];
IM_ASSERT(child_0 || child_1);
IM_ASSERT(merge_lead_child == child_0 || merge_lead_child == child_1);
if ((child_0 && child_0->Windows.Size > 0) || (child_1 && child_1->Windows.Size > 0))
{
IM_ASSERT(parent_node->TabBar == NULL);
IM_ASSERT(parent_node->Windows.Size == 0);
}
IMGUI_DEBUG_LOG_DOCKING("DockNodeTreeMerge 0x%08X & 0x%08X back into parent 0x%08X\n", child_0 ? child_0->ID : 0, child_1 ? child_1->ID : 0, parent_node->ID);
ImVec2 backup_last_explicit_size = parent_node->SizeRef;
DockNodeMoveChildNodes(parent_node, merge_lead_child);
if (child_0)
{
DockNodeMoveWindows(parent_node, child_0); // Generally only 1 of the 2 child node will have windows
DockSettingsRenameNodeReferences(child_0->ID, parent_node->ID);
}
if (child_1)
{
DockNodeMoveWindows(parent_node, child_1);
DockSettingsRenameNodeReferences(child_1->ID, parent_node->ID);
}
DockNodeApplyPosSizeToWindows(parent_node);
parent_node->AuthorityForPos = parent_node->AuthorityForSize = parent_node->AuthorityForViewport = ImGuiDataAuthority_Auto;
parent_node->VisibleWindow = merge_lead_child->VisibleWindow;
parent_node->SizeRef = backup_last_explicit_size;
// Flags transfer
parent_node->LocalFlags &= ~ImGuiDockNodeFlags_LocalFlagsTransferMask_; // Preserve Dockspace flag
parent_node->LocalFlags |= (child_0 ? child_0->LocalFlags : 0) & ImGuiDockNodeFlags_LocalFlagsTransferMask_;
parent_node->LocalFlags |= (child_1 ? child_1->LocalFlags : 0) & ImGuiDockNodeFlags_LocalFlagsTransferMask_;
if (child_0)
{
ctx->DockContext->Nodes.SetVoidPtr(child_0->ID, NULL);
IM_DELETE(child_0);
}
if (child_1)
{
ctx->DockContext->Nodes.SetVoidPtr(child_1->ID, NULL);
IM_DELETE(child_1);
}
}
// Update Pos/Size for a node hierarchy (don't affect child Windows yet)
void ImGui::DockNodeTreeUpdatePosSize(ImGuiDockNode* node, ImVec2 pos, ImVec2 size, bool only_write_to_marked_nodes)
{
// During the regular dock node update we write to all nodes.
// 'only_write_to_marked_nodes' is only set when turning a node visible mid-frame and we need its size right-away.
IM_ASSERT(size.x > 0.0f && size.y > 0.0f);
const bool write_to_node = (only_write_to_marked_nodes == false) || (node->MarkedForPosSizeWrite);
if (write_to_node)
{
node->Pos = pos;
node->Size = size;
}
if (node->IsLeafNode())
return;
ImGuiDockNode* child_0 = node->ChildNodes[0];
ImGuiDockNode* child_1 = node->ChildNodes[1];
ImVec2 child_0_pos = pos, child_1_pos = pos;
ImVec2 child_0_size = size, child_1_size = size;
if (child_0->IsVisible && child_1->IsVisible)
{
const float spacing = IMGUI_DOCK_SPLITTER_SIZE;
const ImGuiAxis axis = (ImGuiAxis)node->SplitAxis;
const float size_avail = ImMax(size[axis] - spacing, 0.0f);
// Size allocation policy
// 1) The first 0..WindowMinSize[axis]*2 are allocated evenly to both windows.
ImGuiContext& g = *GImGui;
const float size_min_each = ImFloor(ImMin(size_avail, g.Style.WindowMinSize[axis] * 2.0f) * 0.5f);
// 2) Process locked absolute size (during a splitter resize we preserve the child of nodes not touching the splitter edge)
IM_ASSERT(!(child_0->WantLockSizeOnce && child_1->WantLockSizeOnce));
if (child_0->WantLockSizeOnce)
{
child_0->WantLockSizeOnce = false;
child_0_size[axis] = child_0->SizeRef[axis] = child_0->Size[axis];
child_1_size[axis] = child_1->SizeRef[axis] = (size_avail - child_0_size[axis]);
IM_ASSERT(child_0->SizeRef[axis] > 0.0f && child_1->SizeRef[axis] > 0.0f);
}
else if (child_1->WantLockSizeOnce)
{
child_1->WantLockSizeOnce = false;
child_1_size[axis] = child_1->SizeRef[axis] = child_1->Size[axis];
child_0_size[axis] = child_0->SizeRef[axis] = (size_avail - child_1_size[axis]);
IM_ASSERT(child_0->SizeRef[axis] > 0.0f && child_1->SizeRef[axis] > 0.0f);
}
// 3) If one window is the central node (~ use remaining space, should be made explicit!), use explicit size from the other, and remainder for the central node
else if (child_1->IsCentralNode() && child_0->SizeRef[axis] != 0.0f)
{
child_0_size[axis] = ImMin(size_avail - size_min_each, child_0->SizeRef[axis]);
child_1_size[axis] = (size_avail - child_0_size[axis]);
}
else if (child_0->IsCentralNode() && child_1->SizeRef[axis] != 0.0f)
{
child_1_size[axis] = ImMin(size_avail - size_min_each, child_1->SizeRef[axis]);
child_0_size[axis] = (size_avail - child_1_size[axis]);
}
else
{
// 4) Otherwise distribute according to the relative ratio of each SizeRef value
float split_ratio = child_0->SizeRef[axis] / (child_0->SizeRef[axis] + child_1->SizeRef[axis]);
child_0_size[axis] = ImMax(size_min_each, ImFloor(size_avail * split_ratio + 0.5F));
child_1_size[axis] = (size_avail - child_0_size[axis]);
}
child_1_pos[axis] += spacing + child_0_size[axis];
}
if (child_0->IsVisible)
DockNodeTreeUpdatePosSize(child_0, child_0_pos, child_0_size);
if (child_1->IsVisible)
DockNodeTreeUpdatePosSize(child_1, child_1_pos, child_1_size);
}
static void DockNodeTreeUpdateSplitterFindTouchingNode(ImGuiDockNode* node, ImGuiAxis axis, int side, ImVector<ImGuiDockNode*>* touching_nodes)
{
if (node->IsLeafNode())
{
touching_nodes->push_back(node);
return;
}
if (node->ChildNodes[0]->IsVisible)
if (node->SplitAxis != axis || side == 0 || !node->ChildNodes[1]->IsVisible)
DockNodeTreeUpdateSplitterFindTouchingNode(node->ChildNodes[0], axis, side, touching_nodes);
if (node->ChildNodes[1]->IsVisible)
if (node->SplitAxis != axis || side == 1 || !node->ChildNodes[0]->IsVisible)
DockNodeTreeUpdateSplitterFindTouchingNode(node->ChildNodes[1], axis, side, touching_nodes);
}
void ImGui::DockNodeTreeUpdateSplitter(ImGuiDockNode* node)
{
if (node->IsLeafNode())
return;
ImGuiContext& g = *GImGui;
ImGuiDockNode* child_0 = node->ChildNodes[0];
ImGuiDockNode* child_1 = node->ChildNodes[1];
if (child_0->IsVisible && child_1->IsVisible)
{
// Bounding box of the splitter cover the space between both nodes (w = Spacing, h = Size[xy^1] for when splitting horizontally)
const ImGuiAxis axis = (ImGuiAxis)node->SplitAxis;
IM_ASSERT(axis != ImGuiAxis_None);
ImRect bb;
bb.Min = child_0->Pos;
bb.Max = child_1->Pos;
bb.Min[axis] += child_0->Size[axis];
bb.Max[axis ^ 1] += child_1->Size[axis ^ 1];
//if (g.IO.KeyCtrl) GetForegroundDrawList(g.CurrentWindow->Viewport)->AddRect(bb.Min, bb.Max, IM_COL32(255,0,255,255));
if ((child_0->GetMergedFlags() | child_1->GetMergedFlags()) & ImGuiDockNodeFlags_NoResize)
{
ImGuiWindow* window = g.CurrentWindow;
window->DrawList->AddRectFilled(bb.Min, bb.Max, GetColorU32(ImGuiCol_Separator), g.Style.FrameRounding);
}
else
{
//bb.Min[axis] += 1; // Display a little inward so highlight doesn't connect with nearby tabs on the neighbor node.
//bb.Max[axis] -= 1;
PushID(node->ID);
// Gather list of nodes that are touching the splitter line. Find resizing limits based on those nodes.
ImVector<ImGuiDockNode*> touching_nodes[2];
float min_size = g.Style.WindowMinSize[axis];
float resize_limits[2];
resize_limits[0] = node->ChildNodes[0]->Pos[axis] + min_size;
resize_limits[1] = node->ChildNodes[1]->Pos[axis] + node->ChildNodes[1]->Size[axis] - min_size;
ImGuiID splitter_id = GetID("##Splitter");
if (g.ActiveId == splitter_id)
{
// Only process when splitter is active
DockNodeTreeUpdateSplitterFindTouchingNode(child_0, axis, 1, &touching_nodes[0]);
DockNodeTreeUpdateSplitterFindTouchingNode(child_1, axis, 0, &touching_nodes[1]);
for (int touching_node_n = 0; touching_node_n < touching_nodes[0].Size; touching_node_n++)
resize_limits[0] = ImMax(resize_limits[0], touching_nodes[0][touching_node_n]->Rect().Min[axis] + min_size);
for (int touching_node_n = 0; touching_node_n < touching_nodes[1].Size; touching_node_n++)
resize_limits[1] = ImMin(resize_limits[1], touching_nodes[1][touching_node_n]->Rect().Max[axis] - min_size);
/*
// [DEBUG] Render limits
ImDrawList* draw_list = node->HostWindow ? GetForegroundDrawList(node->HostWindow) : GetForegroundDrawList((ImGuiViewportP*)GetMainViewport());
for (int n = 0; n < 2; n++)
if (axis == ImGuiAxis_X)
draw_list->AddLine(ImVec2(resize_limits[n], node->ChildNodes[n]->Pos.y), ImVec2(resize_limits[n], node->ChildNodes[n]->Pos.y + node->ChildNodes[n]->Size.y), IM_COL32(255, 0, 255, 255), 3.0f);
else
draw_list->AddLine(ImVec2(node->ChildNodes[n]->Pos.x, resize_limits[n]), ImVec2(node->ChildNodes[n]->Pos.x + node->ChildNodes[n]->Size.x, resize_limits[n]), IM_COL32(255, 0, 255, 255), 3.0f);
*/
}
// Use a short delay before highlighting the splitter (and changing the mouse cursor) in order for regular mouse movement to not highlight many splitters
float cur_size_0 = child_0->Size[axis];
float cur_size_1 = child_1->Size[axis];
float min_size_0 = resize_limits[0] - child_0->Pos[axis];
float min_size_1 = child_1->Pos[axis] + child_1->Size[axis] - resize_limits[1];
if (SplitterBehavior(bb, GetID("##Splitter"), axis, &cur_size_0, &cur_size_1, min_size_0, min_size_1, WINDOWS_RESIZE_FROM_EDGES_HALF_THICKNESS, WINDOWS_RESIZE_FROM_EDGES_FEEDBACK_TIMER))
{
if (touching_nodes[0].Size > 0 && touching_nodes[1].Size > 0)
{
child_0->Size[axis] = child_0->SizeRef[axis] = cur_size_0;
child_1->Pos[axis] -= cur_size_1 - child_1->Size[axis];
child_1->Size[axis] = child_1->SizeRef[axis] = cur_size_1;
// Lock the size of every node that is a sibling of the node we are touching
// This might be less desirable if we can merge sibling of a same axis into the same parental level.
for (int side_n = 0; side_n < 2; side_n++)
for (int touching_node_n = 0; touching_node_n < touching_nodes[side_n].Size; touching_node_n++)
{
ImGuiDockNode* touching_node = touching_nodes[side_n][touching_node_n];
//ImDrawList* draw_list = node->HostWindow ? GetForegroundDrawList(node->HostWindow) : GetForegroundDrawList((ImGuiViewportP*)GetMainViewport());
//draw_list->AddRect(touching_node->Pos, touching_node->Pos + touching_node->Size, IM_COL32(255, 128, 0, 255));
while (touching_node->ParentNode != node)
{
if (touching_node->ParentNode->SplitAxis == axis)
{
// Mark other node so its size will be preserved during the upcoming call to DockNodeTreeUpdatePosSize().
ImGuiDockNode* node_to_preserve = touching_node->ParentNode->ChildNodes[side_n];
node_to_preserve->WantLockSizeOnce = true;
//draw_list->AddRect(touching_node->Pos, touching_node->Rect().Max, IM_COL32(255, 0, 0, 255));
//draw_list->AddRectFilled(node_to_preserve->Pos, node_to_preserve->Rect().Max, IM_COL32(0, 255, 0, 100));
}
touching_node = touching_node->ParentNode;
}
}
DockNodeTreeUpdatePosSize(child_0, child_0->Pos, child_0->Size);
DockNodeTreeUpdatePosSize(child_1, child_1->Pos, child_1->Size);
MarkIniSettingsDirty();
}
}
PopID();
}
}
if (child_0->IsVisible)
DockNodeTreeUpdateSplitter(child_0);
if (child_1->IsVisible)
DockNodeTreeUpdateSplitter(child_1);
}
ImGuiDockNode* ImGui::DockNodeTreeFindFallbackLeafNode(ImGuiDockNode* node)
{
if (node->IsLeafNode())
return node;
if (ImGuiDockNode* leaf_node = DockNodeTreeFindFallbackLeafNode(node->ChildNodes[0]))
return leaf_node;
if (ImGuiDockNode* leaf_node = DockNodeTreeFindFallbackLeafNode(node->ChildNodes[1]))
return leaf_node;
return NULL;
}
ImGuiDockNode* ImGui::DockNodeTreeFindNodeByPos(ImGuiDockNode* node, ImVec2 pos)
{
if (!node->IsVisible)
return NULL;
ImGuiContext& g = *GImGui;
const float dock_spacing = g.Style.ItemInnerSpacing.x;
ImRect r(node->Pos, node->Pos + node->Size);
r.Expand(dock_spacing * 0.5f);
bool inside = r.Contains(pos);
if (!inside)
return NULL;
if (node->IsLeafNode())
return node;
if (ImGuiDockNode* hovered_node = DockNodeTreeFindNodeByPos(node->ChildNodes[0], pos))
return hovered_node;
if (ImGuiDockNode* hovered_node = DockNodeTreeFindNodeByPos(node->ChildNodes[1], pos))
return hovered_node;
// There is an edge case when docking into a dockspace which only has inactive nodes (because none of the windows are active)
// In this case we need to fallback into any leaf mode, possibly the central node.
if (node->IsDockSpace() && node->IsRootNode())
{
if (node->CentralNode && node->IsLeafNode()) // FIXME-20181220: We should not have to test for IsLeafNode() here but we have another bug to fix first.
return node->CentralNode;
return DockNodeTreeFindFallbackLeafNode(node);
}
return NULL;
}
//-----------------------------------------------------------------------------
// Docking: Public Functions (SetWindowDock, DockSpace, DockSpaceOverViewport)
//-----------------------------------------------------------------------------
// - SetWindowDock() [Internal]
// - DockSpace()
// - DockSpaceOverViewport()
//-----------------------------------------------------------------------------
// [Internal] Called via SetNextWindowDockID()
void ImGui::SetWindowDock(ImGuiWindow* window, ImGuiID dock_id, ImGuiCond cond)
{
// Test condition (NB: bit 0 is always true) and clear flags for next time
if (cond && (window->SetWindowDockAllowFlags & cond) == 0)
return;
window->SetWindowDockAllowFlags &= ~(ImGuiCond_Once | ImGuiCond_FirstUseEver | ImGuiCond_Appearing);
if (window->DockId == dock_id)
return;
// If the user attempt to set a dock id that is a split node, we'll dig within to find a suitable docking spot
ImGuiContext* ctx = GImGui;
if (ImGuiDockNode* new_node = DockContextFindNodeByID(ctx, dock_id))
if (new_node->IsSplitNode())
{
// Policy: Find central node or latest focused node. We first move back to our root node.
new_node = DockNodeGetRootNode(new_node);
if (new_node->CentralNode)
{
IM_ASSERT(new_node->CentralNode->IsCentralNode());
dock_id = new_node->CentralNode->ID;
}
else
{
dock_id = new_node->LastFocusedNodeID;
}
}
if (window->DockId == dock_id)
return;
if (window->DockNode)
DockNodeRemoveWindow(window->DockNode, window, 0);
window->DockId = dock_id;
}
// Create an explicit dockspace node within an existing window. Also expose dock node flags and creates a CentralNode by default.
// The Central Node is always displayed even when empty and shrink/extend according to the requested size of its neighbors.
void ImGui::DockSpace(ImGuiID id, const ImVec2& size_arg, ImGuiDockNodeFlags flags, const ImGuiWindowClass* window_class)
{
ImGuiContext* ctx = GImGui;
ImGuiContext& g = *ctx;
ImGuiWindow* window = GetCurrentWindow();
if (!(g.IO.ConfigFlags & ImGuiConfigFlags_DockingEnable))
return;
IM_ASSERT((flags & ImGuiDockNodeFlags_DockSpace) == 0);
ImGuiDockNode* node = DockContextFindNodeByID(ctx, id);
if (!node)
{
IMGUI_DEBUG_LOG_DOCKING("DockSpace: dockspace node 0x%08X created\n", id);
node = DockContextAddNode(ctx, id);
node->LocalFlags |= ImGuiDockNodeFlags_CentralNode;
}
if (window_class && window_class->ClassId != node->WindowClass.ClassId)
IMGUI_DEBUG_LOG_DOCKING("DockSpace: dockspace node 0x%08X: setup WindowClass 0x%08X -> 0x%08X\n", id, node->WindowClass.ClassId, window_class->ClassId);
node->SharedFlags = flags;
node->WindowClass = window_class ? *window_class : ImGuiWindowClass();
// When a DockSpace transitioned form implicit to explicit this may be called a second time
// It is possible that the node has already been claimed by a docked window which appeared before the DockSpace() node, so we overwrite IsDockSpace again.
if (node->LastFrameActive == g.FrameCount && !(flags & ImGuiDockNodeFlags_KeepAliveOnly))
{
IM_ASSERT(node->IsDockSpace() == false && "Cannot call DockSpace() twice a frame with the same ID");
node->LocalFlags |= ImGuiDockNodeFlags_DockSpace;
return;
}
node->LocalFlags |= ImGuiDockNodeFlags_DockSpace;
// Keep alive mode, this is allow windows docked into this node so stay docked even if they are not visible
if (flags & ImGuiDockNodeFlags_KeepAliveOnly)
{
node->LastFrameAlive = g.FrameCount;
return;
}
const ImVec2 content_avail = GetContentRegionAvail();
ImVec2 size = ImFloor(size_arg);
if (size.x <= 0.0f)
size.x = ImMax(content_avail.x + size.x, 4.0f); // Arbitrary minimum child size (0.0f causing too much issues)
if (size.y <= 0.0f)
size.y = ImMax(content_avail.y + size.y, 4.0f);
IM_ASSERT(size.x > 0.0f && size.y > 0.0f);
node->Pos = window->DC.CursorPos;
node->Size = node->SizeRef = size;
SetNextWindowPos(node->Pos);
SetNextWindowSize(node->Size);
g.NextWindowData.PosUndock = false;
// FIXME-DOCKING: Why do we need a child window to host a dockspace, could we host it in the existing window?
ImGuiWindowFlags window_flags = ImGuiWindowFlags_ChildWindow | ImGuiWindowFlags_DockNodeHost;
window_flags |= ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoTitleBar;
window_flags |= ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoScrollWithMouse;
char title[256];
ImFormatString(title, IM_ARRAYSIZE(title), "%s/DockSpace_%08X", window->Name, id);
if (node->Windows.Size > 0 || node->IsSplitNode())
PushStyleColor(ImGuiCol_ChildBg, IM_COL32(0, 0, 0, 0));
PushStyleVar(ImGuiStyleVar_ChildBorderSize, 0.0f);
Begin(title, NULL, window_flags);
PopStyleVar();
if (node->Windows.Size > 0 || node->IsSplitNode())
PopStyleColor();
ImGuiWindow* host_window = g.CurrentWindow;
host_window->DockNodeAsHost = node;
host_window->ChildId = window->GetID(title);
node->HostWindow = host_window;
node->OnlyNodeWithWindows = NULL;
IM_ASSERT(node->IsRootNode());
DockNodeUpdate(node);
End();
}
// Tips: Use with ImGuiDockNodeFlags_PassthruCentralNode!
// The limitation with this call is that your window won't have a menu bar.
// Even though we could pass window flags, it would also require the user to be able to call BeginMenuBar() somehow meaning we can't Begin/End in a single function.
// So if you want a menu bar you need to repeat this code manually ourselves. As with advanced other Docking API, we may change this function signature.
ImGuiID ImGui::DockSpaceOverViewport(ImGuiViewport* viewport, ImGuiDockNodeFlags dockspace_flags, const ImGuiWindowClass* window_class)
{
if (viewport == NULL)
viewport = GetMainViewport();
SetNextWindowPos(viewport->Pos);
SetNextWindowSize(viewport->Size);
SetNextWindowViewport(viewport->ID);
ImGuiWindowFlags host_window_flags = 0;
host_window_flags |= ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoDocking;
host_window_flags |= ImGuiWindowFlags_NoBringToFrontOnFocus | ImGuiWindowFlags_NoNavFocus;
if (dockspace_flags & ImGuiDockNodeFlags_PassthruCentralNode)
host_window_flags |= ImGuiWindowFlags_NoBackground;
char label[32];
ImFormatString(label, IM_ARRAYSIZE(label), "DockSpaceViewport_%08X", viewport->ID);
PushStyleVar(ImGuiStyleVar_WindowRounding, 0.0f);
PushStyleVar(ImGuiStyleVar_WindowBorderSize, 0.0f);
PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(0.0f, 0.0f));
Begin(label, NULL, host_window_flags);
PopStyleVar(3);
ImGuiID dockspace_id = GetID("DockSpace");
DockSpace(dockspace_id, ImVec2(0.0f, 0.0f), dockspace_flags, window_class);
End();
return dockspace_id;
}
//-----------------------------------------------------------------------------
// Docking: Builder Functions
//-----------------------------------------------------------------------------
// Very early end-user API to manipulate dock nodes.
// Only available in imgui_internal.h. Expect this API to change/break!
// It is expected that those functions are all called _before_ the dockspace node submission.
//-----------------------------------------------------------------------------
// - DockBuilderDockWindow()
// - DockBuilderGetNode()
// - DockBuilderSetNodePos()
// - DockBuilderSetNodeSize()
// - DockBuilderAddNode()
// - DockBuilderRemoveNode()
// - DockBuilderRemoveNodeChildNodes()
// - DockBuilderRemoveNodeDockedWindows()
// - DockBuilderSplitNode()
// - DockBuilderCopyNodeRec()
// - DockBuilderCopyNode()
// - DockBuilderCopyWindowSettings()
// - DockBuilderCopyDockSpace()
// - DockBuilderFinish()
//-----------------------------------------------------------------------------
void ImGui::DockBuilderDockWindow(const char* window_name, ImGuiID node_id)
{
// We don't preserve relative order of multiple docked windows (by clearing DockOrder back to -1)
ImGuiID window_id = ImHashStr(window_name);
if (ImGuiWindow* window = FindWindowByID(window_id))
{
// Apply to created window
SetWindowDock(window, node_id, ImGuiCond_Always);
window->DockOrder = -1;
}
else
{
// Apply to settings
ImGuiWindowSettings* settings = FindWindowSettings(window_id);
if (settings == NULL)
settings = CreateNewWindowSettings(window_name);
settings->DockId = node_id;
settings->DockOrder = -1;
}
}
ImGuiDockNode* ImGui::DockBuilderGetNode(ImGuiID node_id)
{
ImGuiContext* ctx = GImGui;
return DockContextFindNodeByID(ctx, node_id);
}
void ImGui::DockBuilderSetNodePos(ImGuiID node_id, ImVec2 pos)
{
ImGuiContext* ctx = GImGui;
ImGuiDockNode* node = DockContextFindNodeByID(ctx, node_id);
if (node == NULL)
return;
node->Pos = pos;
node->AuthorityForPos = ImGuiDataAuthority_DockNode;
}
void ImGui::DockBuilderSetNodeSize(ImGuiID node_id, ImVec2 size)
{
ImGuiContext* ctx = GImGui;
ImGuiDockNode* node = DockContextFindNodeByID(ctx, node_id);
if (node == NULL)
return;
IM_ASSERT(size.x > 0.0f && size.y > 0.0f);
node->Size = node->SizeRef = size;
node->AuthorityForSize = ImGuiDataAuthority_DockNode;
}
// If you create a regular node, both ref_pos/ref_size will position the window.
// If you create a dockspace node: ref_pos won't be used, ref_size is useful on the first frame to...
ImGuiID ImGui::DockBuilderAddNode(ImGuiID id, ImGuiDockNodeFlags flags)
{
ImGuiContext* ctx = GImGui;
ImGuiDockNode* node = NULL;
if (flags & ImGuiDockNodeFlags_DockSpace)
{
DockSpace(id, ImVec2(0, 0), (flags & ~ImGuiDockNodeFlags_DockSpace) | ImGuiDockNodeFlags_KeepAliveOnly);
node = DockContextFindNodeByID(ctx, id);
}
else
{
if (id != 0)
node = DockContextFindNodeByID(ctx, id);
if (!node)
node = DockContextAddNode(ctx, id);
node->LocalFlags = flags;
}
node->LastFrameAlive = ctx->FrameCount; // Set this otherwise BeginDocked will undock during the same frame.
return node->ID;
}
void ImGui::DockBuilderRemoveNode(ImGuiID node_id)
{
ImGuiContext* ctx = GImGui;
ImGuiDockNode* node = DockContextFindNodeByID(ctx, node_id);
if (node == NULL)
return;
DockBuilderRemoveNodeDockedWindows(node_id, true);
DockBuilderRemoveNodeChildNodes(node_id);
if (node->IsCentralNode() && node->ParentNode)
node->ParentNode->LocalFlags |= ImGuiDockNodeFlags_CentralNode;
DockContextRemoveNode(ctx, node, true);
}
void ImGui::DockBuilderRemoveNodeChildNodes(ImGuiID root_id)
{
ImGuiContext* ctx = GImGui;
ImGuiDockContext* dc = ctx->DockContext;
ImGuiDockNode* root_node = root_id ? DockContextFindNodeByID(ctx, root_id) : NULL;
if (root_id && root_node == NULL)
return;
bool has_central_node = false;
ImGuiDataAuthority backup_root_node_authority_for_pos = root_node ? root_node->AuthorityForPos : ImGuiDataAuthority_Auto;
ImGuiDataAuthority backup_root_node_authority_for_size = root_node ? root_node->AuthorityForSize : ImGuiDataAuthority_Auto;
// Process active windows
ImVector<ImGuiDockNode*> nodes_to_remove;
for (int n = 0; n < dc->Nodes.Data.Size; n++)
if (ImGuiDockNode* node = (ImGuiDockNode*)dc->Nodes.Data[n].val_p)
{
bool want_removal = (root_id == 0) || (node->ID != root_id && DockNodeGetRootNode(node)->ID == root_id);
if (want_removal)
{
if (node->IsCentralNode())
has_central_node = true;
if (root_id != 0)
DockContextQueueNotifyRemovedNode(ctx, node);
if (root_node)
DockNodeMoveWindows(root_node, node);
nodes_to_remove.push_back(node);
}
}
// DockNodeMoveWindows->DockNodeAddWindow will normally set those when reaching two windows (which is only adequate during interactive merge)
// Make sure we don't lose our current pos/size. (FIXME-DOCK: Consider tidying up that code in DockNodeAddWindow instead)
if (root_node)
{
root_node->AuthorityForPos = backup_root_node_authority_for_pos;
root_node->AuthorityForSize = backup_root_node_authority_for_size;
}
// Apply to settings
for (int settings_n = 0; settings_n < ctx->SettingsWindows.Size; settings_n++)
if (ImGuiID window_settings_dock_id = ctx->SettingsWindows[settings_n].DockId)
for (int n = 0; n < nodes_to_remove.Size; n++)
if (nodes_to_remove[n]->ID == window_settings_dock_id)
{
ctx->SettingsWindows[settings_n].DockId = root_id;
break;
}
// Not really efficient, but easier to destroy a whole hierarchy considering DockContextRemoveNode is attempting to merge nodes
if (nodes_to_remove.Size > 1)
ImQsort(nodes_to_remove.Data, nodes_to_remove.Size, sizeof(ImGuiDockNode*), DockNodeComparerDepthMostFirst);
for (int n = 0; n < nodes_to_remove.Size; n++)
DockContextRemoveNode(ctx, nodes_to_remove[n], false);
if (root_id == 0)
{
dc->Nodes.Clear();
dc->Requests.clear();
}
else if (has_central_node)
{
root_node->LocalFlags |= ImGuiDockNodeFlags_CentralNode;
root_node->CentralNode = root_node;
}
}
void ImGui::DockBuilderRemoveNodeDockedWindows(ImGuiID root_id, bool clear_persistent_docking_references)
{
// Clear references in settings
ImGuiContext* ctx = GImGui;
ImGuiContext& g = *ctx;
if (clear_persistent_docking_references)
{
for (int n = 0; n < g.SettingsWindows.Size; n++)
{
ImGuiWindowSettings* settings = &g.SettingsWindows[n];
bool want_removal = (root_id == 0) || (settings->DockId == root_id);
if (!want_removal && settings->DockId != 0)
if (ImGuiDockNode* node = DockContextFindNodeByID(ctx, settings->DockId))
if (DockNodeGetRootNode(node)->ID == root_id)
want_removal = true;
if (want_removal)
settings->DockId = 0;
}
}
// Clear references in windows
for (int n = 0; n < g.Windows.Size; n++)
{
ImGuiWindow* window = g.Windows[n];
bool want_removal = (root_id == 0) || (window->DockNode && DockNodeGetRootNode(window->DockNode)->ID == root_id) || (window->DockNodeAsHost && window->DockNodeAsHost->ID == root_id);
if (want_removal)
{
const ImGuiID backup_dock_id = window->DockId;
DockContextProcessUndockWindow(ctx, window, clear_persistent_docking_references);
if (!clear_persistent_docking_references)
IM_ASSERT(window->DockId == backup_dock_id);
}
}
}
// FIXME-DOCK: We are not exposing nor using split_outer.
ImGuiID ImGui::DockBuilderSplitNode(ImGuiID id, ImGuiDir split_dir, float size_ratio_for_node_at_dir, ImGuiID* out_id_at_dir, ImGuiID* out_id_other)
{
ImGuiContext* ctx = GImGui;
IM_ASSERT(split_dir != ImGuiDir_None);
IMGUI_DEBUG_LOG_DOCKING("DockBuilderSplitNode node 0x%08X, split_dir %d\n", id, split_dir);
ImGuiDockNode* node = DockContextFindNodeByID(ctx, id);
if (node == NULL)
{
IM_ASSERT(node != NULL);
return 0;
}
IM_ASSERT(!node->IsSplitNode()); // Assert if already Split
ImGuiDockRequest req;
req.Type = ImGuiDockRequestType_Split;
req.DockTargetWindow = NULL;
req.DockTargetNode = node;
req.DockPayload = NULL;
req.DockSplitDir = split_dir;
req.DockSplitRatio = ImSaturate((split_dir == ImGuiDir_Left || split_dir == ImGuiDir_Up) ? size_ratio_for_node_at_dir : 1.0f - size_ratio_for_node_at_dir);
req.DockSplitOuter = false;
DockContextProcessDock(ctx, &req);
ImGuiID id_at_dir = node->ChildNodes[(split_dir == ImGuiDir_Left || split_dir == ImGuiDir_Up) ? 0 : 1]->ID;
ImGuiID id_other = node->ChildNodes[(split_dir == ImGuiDir_Left || split_dir == ImGuiDir_Up) ? 1 : 0]->ID;
if (out_id_at_dir)
*out_id_at_dir = id_at_dir;
if (out_id_other)
*out_id_other = id_other;
return id_at_dir;
}
static ImGuiDockNode* DockBuilderCopyNodeRec(ImGuiDockNode* src_node, ImGuiID dst_node_id_if_known, ImVector<ImGuiID>* out_node_remap_pairs)
{
ImGuiContext* ctx = GImGui;
ImGuiDockNode* dst_node = ImGui::DockContextAddNode(ctx, dst_node_id_if_known);
dst_node->SharedFlags = src_node->SharedFlags;
dst_node->LocalFlags = src_node->LocalFlags;
dst_node->Pos = src_node->Pos;
dst_node->Size = src_node->Size;
dst_node->SizeRef = src_node->SizeRef;
dst_node->SplitAxis = src_node->SplitAxis;
out_node_remap_pairs->push_back(src_node->ID);
out_node_remap_pairs->push_back(dst_node->ID);
for (int child_n = 0; child_n < IM_ARRAYSIZE(src_node->ChildNodes); child_n++)
if (src_node->ChildNodes[child_n])
{
dst_node->ChildNodes[child_n] = DockBuilderCopyNodeRec(src_node->ChildNodes[child_n], 0, out_node_remap_pairs);
dst_node->ChildNodes[child_n]->ParentNode = dst_node;
}
IMGUI_DEBUG_LOG_DOCKING("Fork node %08X -> %08X (%d childs)\n", src_node->ID, dst_node->ID, dst_node->IsSplitNode() ? 2 : 0);
return dst_node;
}
void ImGui::DockBuilderCopyNode(ImGuiID src_node_id, ImGuiID dst_node_id, ImVector<ImGuiID>* out_node_remap_pairs)
{
ImGuiContext* ctx = GImGui;
IM_ASSERT(src_node_id != 0);
IM_ASSERT(dst_node_id != 0);
IM_ASSERT(out_node_remap_pairs != NULL);
ImGuiDockNode* src_node = DockContextFindNodeByID(ctx, src_node_id);
IM_ASSERT(src_node != NULL);
out_node_remap_pairs->clear();
DockBuilderRemoveNode(dst_node_id);
DockBuilderCopyNodeRec(src_node, dst_node_id, out_node_remap_pairs);
IM_ASSERT((out_node_remap_pairs->Size % 2) == 0);
}
void ImGui::DockBuilderCopyWindowSettings(const char* src_name, const char* dst_name)
{
ImGuiWindow* src_window = FindWindowByName(src_name);
if (src_window == NULL)
return;
if (ImGuiWindow* dst_window = FindWindowByName(dst_name))
{
dst_window->Pos = src_window->Pos;
dst_window->Size = src_window->Size;
dst_window->SizeFull = src_window->SizeFull;
dst_window->Collapsed = src_window->Collapsed;
}
else if (ImGuiWindowSettings* dst_settings = FindOrCreateWindowSettings(dst_name))
{
ImVec2ih window_pos_2ih = ImVec2ih(src_window->Pos);
if (src_window->ViewportId != 0 && src_window->ViewportId != IMGUI_VIEWPORT_DEFAULT_ID)
{
dst_settings->ViewportPos = window_pos_2ih;
dst_settings->ViewportId = src_window->ViewportId;
dst_settings->Pos = ImVec2ih(0, 0);
}
else
{
dst_settings->Pos = window_pos_2ih;
}
dst_settings->Size = ImVec2ih(src_window->SizeFull);
dst_settings->Collapsed = src_window->Collapsed;
}
}
// FIXME: Will probably want to change this signature, in particular how the window remapping pairs are passed.
void ImGui::DockBuilderCopyDockSpace(ImGuiID src_dockspace_id, ImGuiID dst_dockspace_id, ImVector<const char*>* in_window_remap_pairs)
{
IM_ASSERT(src_dockspace_id != 0);
IM_ASSERT(dst_dockspace_id != 0);
IM_ASSERT(in_window_remap_pairs != NULL);
IM_ASSERT((in_window_remap_pairs->Size % 2) == 0);
// Duplicate entire dock
// FIXME: When overwriting dst_dockspace_id, windows that aren't part of our dockspace window class but that are docked in a same node will be split apart,
// whereas we could attempt to at least keep them together in a new, same floating node.
ImVector<ImGuiID> node_remap_pairs;
DockBuilderCopyNode(src_dockspace_id, dst_dockspace_id, &node_remap_pairs);
// Attempt to transition all the upcoming windows associated to dst_dockspace_id into the newly created hierarchy of dock nodes
// (The windows associated to src_dockspace_id are staying in place)
ImVector<ImGuiID> src_windows;
for (int remap_window_n = 0; remap_window_n < in_window_remap_pairs->Size; remap_window_n += 2)
{
const char* src_window_name = (*in_window_remap_pairs)[remap_window_n];
const char* dst_window_name = (*in_window_remap_pairs)[remap_window_n + 1];
ImGuiID src_window_id = ImHashStr(src_window_name);
src_windows.push_back(src_window_id);
// Search in the remapping tables
ImGuiID src_dock_id = 0;
if (ImGuiWindow* src_window = FindWindowByID(src_window_id))
src_dock_id = src_window->DockId;
else if (ImGuiWindowSettings* src_window_settings = FindWindowSettings(src_window_id))
src_dock_id = src_window_settings->DockId;
ImGuiID dst_dock_id = 0;
for (int dock_remap_n = 0; dock_remap_n < node_remap_pairs.Size; dock_remap_n += 2)
if (node_remap_pairs[dock_remap_n] == src_dock_id)
{
dst_dock_id = node_remap_pairs[dock_remap_n + 1];
//node_remap_pairs[dock_remap_n] = node_remap_pairs[dock_remap_n + 1] = 0; // Clear
break;
}
if (dst_dock_id != 0)
{
// Docked windows gets redocked into the new node hierarchy.
IMGUI_DEBUG_LOG_DOCKING("Remap live window '%s' 0x%08X -> '%s' 0x%08X\n", src_window_name, src_dock_id, dst_window_name, dst_dock_id);
DockBuilderDockWindow(dst_window_name, dst_dock_id);
}
else
{
// Floating windows gets their settings transferred (regardless of whether the new window already exist or not)
// When this is leading to a Copy and not a Move, we would get two overlapping floating windows. Could we possibly dock them together?
IMGUI_DEBUG_LOG_DOCKING("Remap window settings '%s' -> '%s'\n", src_window_name, dst_window_name);
DockBuilderCopyWindowSettings(src_window_name, dst_window_name);
}
}
// Anything else in the source nodes of 'node_remap_pairs' are windows that were docked in src_dockspace_id but are not owned by it (unaffiliated windows, e.g. "ImGui Demo")
// Find those windows and move to them to the cloned dock node. This may be optional?
for (int dock_remap_n = 0; dock_remap_n < node_remap_pairs.Size; dock_remap_n += 2)
if (ImGuiID src_dock_id = node_remap_pairs[dock_remap_n])
{
ImGuiID dst_dock_id = node_remap_pairs[dock_remap_n + 1];
ImGuiDockNode* node = DockBuilderGetNode(src_dock_id);
for (int window_n = 0; window_n < node->Windows.Size; window_n++)
{
ImGuiWindow* window = node->Windows[window_n];
if (src_windows.contains(window->ID))
continue;
// Docked windows gets redocked into the new node hierarchy.
IMGUI_DEBUG_LOG_DOCKING("Remap window '%s' %08X -> %08X\n", window->Name, src_dock_id, dst_dock_id);
DockBuilderDockWindow(window->Name, dst_dock_id);
}
}
}
void ImGui::DockBuilderFinish(ImGuiID root_id)
{
ImGuiContext* ctx = GImGui;
//DockContextRebuild(ctx);
DockContextBuildAddWindowsToNodes(ctx, root_id);
}
//-----------------------------------------------------------------------------
// Docking: Begin/End Support Functions (called from Begin/End)
//-----------------------------------------------------------------------------
// - GetWindowAlwaysWantOwnTabBar()
// - BeginDocked()
// - BeginAsDockableDragDropSource()
// - BeginAsDockableDragDropTarget()
//-----------------------------------------------------------------------------
bool ImGui::GetWindowAlwaysWantOwnTabBar(ImGuiWindow* window)
{
ImGuiContext& g = *GImGui;
if (g.IO.ConfigDockingAlwaysTabBar || window->WindowClass.DockingAlwaysTabBar)
if ((window->Flags & (ImGuiWindowFlags_ChildWindow | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoDocking)) == 0)
if (!window->IsFallbackWindow) // We don't support AlwaysTabBar on the fallback/implicit window to avoid unused dock-node overhead/noise
return true;
return false;
}
static ImGuiDockNode* ImGui::DockContextBindNodeToWindow(ImGuiContext* ctx, ImGuiWindow* window)
{
ImGuiContext& g = *ctx;
ImGuiDockNode* node = DockContextFindNodeByID(ctx, window->DockId);
IM_ASSERT(window->DockNode == NULL);
// We should not be docking into a split node (SetWindowDock should avoid this)
if (node && node->IsSplitNode())
{
DockContextProcessUndockWindow(ctx, window);
return NULL;
}
// Create node
if (node == NULL)
{
node = DockContextAddNode(ctx, window->DockId);
node->AuthorityForPos = node->AuthorityForSize = node->AuthorityForViewport = ImGuiDataAuthority_Window;
node->LastFrameAlive = g.FrameCount;
}
// If the node just turned visible and is part of a hierarchy, it doesn't have a Size assigned by DockNodeTreeUpdatePosSize() yet,
// so we're forcing a Pos/Size update from the first ancestor that is already visible (often it will be the root node).
// If we don't do this, the window will be assigned a zero-size on its first frame, which won't ideally warm up the layout.
// This is a little wonky because we don't normally update the Pos/Size of visible node mid-frame.
if (!node->IsVisible)
{
ImGuiDockNode* ancestor_node = node;
while (!ancestor_node->IsVisible)
{
ancestor_node->IsVisible = true;
ancestor_node->MarkedForPosSizeWrite = true;
if (ancestor_node->ParentNode)
ancestor_node = ancestor_node->ParentNode;
}
IM_ASSERT(ancestor_node->Size.x > 0.0f && ancestor_node->Size.y > 0.0f);
DockNodeTreeUpdatePosSize(ancestor_node, ancestor_node->Pos, ancestor_node->Size, true);
}
// Add window to node
DockNodeAddWindow(node, window, true);
IM_ASSERT(node == window->DockNode);
return node;
}
void ImGui::BeginDocked(ImGuiWindow* window, bool* p_open)
{
ImGuiContext* ctx = GImGui;
ImGuiContext& g = *ctx;
const bool auto_dock_node = GetWindowAlwaysWantOwnTabBar(window);
if (auto_dock_node)
{
if (window->DockId == 0)
{
IM_ASSERT(window->DockNode == NULL);
window->DockId = DockContextGenNodeID(ctx);
}
}
else
{
// Calling SetNextWindowPos() undock windows by default (by setting PosUndock)
bool want_undock = false;
want_undock |= (window->Flags & ImGuiWindowFlags_NoDocking) != 0;
want_undock |= (g.NextWindowData.Flags & ImGuiNextWindowDataFlags_HasPos) && (window->SetWindowPosAllowFlags & g.NextWindowData.PosCond) && g.NextWindowData.PosUndock;
if (want_undock)
{
DockContextProcessUndockWindow(ctx, window);
return;
}
}
// Bind to our dock node
ImGuiDockNode* node = window->DockNode;
if (node != NULL)
IM_ASSERT(window->DockId == node->ID);
if (window->DockId != 0 && node == NULL)
{
node = DockContextBindNodeToWindow(ctx, window);
if (node == NULL)
return;
}
#if 0
// Undock if the ImGuiDockNodeFlags_NoDockingInCentralNode got set
if (node->IsCentralNode && (node->Flags & ImGuiDockNodeFlags_NoDockingInCentralNode))
{
DockContextProcessUndockWindow(ctx, window);
return;
}
#endif
// Undock if our dockspace node disappeared
// Note how we are testing for LastFrameAlive and NOT LastFrameActive. A DockSpace node can be maintained alive while being inactive with ImGuiDockNodeFlags_KeepAliveOnly.
if (node->LastFrameAlive < g.FrameCount)
{
// If the window has been orphaned, transition the docknode to an implicit node processed in DockContextUpdateDocking()
ImGuiDockNode* root_node = DockNodeGetRootNode(node);
if (root_node->LastFrameAlive < g.FrameCount)
{
DockContextProcessUndockWindow(ctx, window);
}
else
{
window->DockIsActive = true;
window->DockTabIsVisible = false;
}
return;
}
// Fast path return. It is common for windows to hold on a persistent DockId but be the only visible window,
// and never create neither a host window neither a tab bar.
// FIXME-DOCK: replace ->HostWindow NULL compare with something more explicit (~was initially intended as a first frame test)
if (node->HostWindow == NULL)
{
window->DockTabIsVisible = false;
return;
}
IM_ASSERT(node->HostWindow);
IM_ASSERT(node->IsLeafNode());
IM_ASSERT(node->Size.x > 0.0f && node->Size.y > 0.0f);
// Undock if we are submitted earlier than the host window
if (window->BeginOrderWithinContext < node->HostWindow->BeginOrderWithinContext)
{
DockContextProcessUndockWindow(ctx, window);
return;
}
// Position window
SetNextWindowPos(node->Pos);
SetNextWindowSize(node->Size);
g.NextWindowData.PosUndock = false; // Cancel implicit undocking of SetNextWindowPos()
window->DockIsActive = true;
window->DockTabIsVisible = false;
if (node->SharedFlags & ImGuiDockNodeFlags_KeepAliveOnly)
return;
// When the window is selected we mark it as visible.
if (node->VisibleWindow == window)
window->DockTabIsVisible = true;
// Update window flag
IM_ASSERT((window->Flags & ImGuiWindowFlags_ChildWindow) == 0);
window->Flags |= ImGuiWindowFlags_ChildWindow | ImGuiWindowFlags_AlwaysUseWindowPadding | ImGuiWindowFlags_NoResize;
if (node->IsHiddenTabBar() || node->IsNoTabBar())
window->Flags |= ImGuiWindowFlags_NoTitleBar;
else
window->Flags &= ~ImGuiWindowFlags_NoTitleBar; // Clear the NoTitleBar flag in case the user set it: confusingly enough we need a title bar height so we are correctly offset, but it won't be displayed!
// Save new dock order only if the tab bar has been visible once.
// This allows multiple windows to be created in the same frame and have their respective dock orders preserved.
if (node->TabBar && node->TabBar->CurrFrameVisible != -1)
window->DockOrder = (short)DockNodeGetTabOrder(window);
if ((node->WantCloseAll || node->WantCloseTabID == window->ID) && p_open != NULL)
*p_open = false;
// Update ChildId to allow returning from Child to Parent with Escape
ImGuiWindow* parent_window = window->DockNode->HostWindow;
window->ChildId = parent_window->GetID(window->Name);
}
void ImGui::BeginAsDockableDragDropSource(ImGuiWindow* window)
{
ImGuiContext& g = *GImGui;
IM_ASSERT(g.ActiveId == window->MoveId);
window->DC.LastItemId = window->MoveId;
window = window->RootWindow;
IM_ASSERT((window->Flags & ImGuiWindowFlags_NoDocking) == 0);
bool is_drag_docking = (g.IO.ConfigDockingWithShift) || ImRect(0, 0, window->SizeFull.x, GetFrameHeight()).Contains(g.ActiveIdClickOffset);
if (is_drag_docking && BeginDragDropSource(ImGuiDragDropFlags_SourceNoPreviewTooltip | ImGuiDragDropFlags_SourceNoHoldToOpenOthers | ImGuiDragDropFlags_SourceAutoExpirePayload))
{
SetDragDropPayload(IMGUI_PAYLOAD_TYPE_WINDOW, &window, sizeof(window));
EndDragDropSource();
}
}
void ImGui::BeginAsDockableDragDropTarget(ImGuiWindow* window)
{
ImGuiContext* ctx = GImGui;
ImGuiContext& g = *ctx;
//IM_ASSERT(window->RootWindow == window); // May also be a DockSpace
IM_ASSERT((window->Flags & ImGuiWindowFlags_NoDocking) == 0);
if (!g.DragDropActive)
return;
if (!BeginDragDropTargetCustom(window->Rect(), window->ID))
return;
// Peek into the payload before calling AcceptDragDropPayload() so we can handle overlapping dock nodes with filtering
// (this is a little unusual pattern, normally most code would call AcceptDragDropPayload directly)
const ImGuiPayload* payload = &g.DragDropPayload;
if (!payload->IsDataType(IMGUI_PAYLOAD_TYPE_WINDOW) || !DockNodeIsDropAllowed(window, *(ImGuiWindow**)payload->Data))
{
EndDragDropTarget();
return;
}
ImGuiWindow* payload_window = *(ImGuiWindow**)payload->Data;
if (AcceptDragDropPayload(IMGUI_PAYLOAD_TYPE_WINDOW, ImGuiDragDropFlags_AcceptBeforeDelivery | ImGuiDragDropFlags_AcceptNoDrawDefaultRect))
{
// Select target node
ImGuiDockNode* node = NULL;
bool allow_null_target_node = false;
if (window->DockNodeAsHost)
node = DockNodeTreeFindNodeByPos(window->DockNodeAsHost, g.IO.MousePos);
else if (window->DockNode) // && window->DockIsActive)
node = window->DockNode;
else
allow_null_target_node = true; // Dock into a regular window
const ImRect explicit_target_rect = (node && node->TabBar && !node->IsHiddenTabBar() && !node->IsNoTabBar()) ? node->TabBar->BarRect : ImRect(window->Pos, window->Pos + ImVec2(window->Size.x, GetFrameHeight()));
const bool is_explicit_target = g.IO.ConfigDockingWithShift || IsMouseHoveringRect(explicit_target_rect.Min, explicit_target_rect.Max);
// Preview docking request and find out split direction/ratio
//const bool do_preview = true; // Ignore testing for payload->IsPreview() which removes one frame of delay, but breaks overlapping drop targets within the same window.
const bool do_preview = payload->IsPreview() || payload->IsDelivery();
if (do_preview && (node != NULL || allow_null_target_node))
{
ImGuiDockPreviewData split_inner, split_outer;
ImGuiDockPreviewData* split_data = &split_inner;
if (node && (node->ParentNode || node->IsCentralNode()))
if (ImGuiDockNode* root_node = DockNodeGetRootNode(node))
{
DockNodePreviewDockCalc(window, root_node, payload_window, &split_outer, is_explicit_target, true);
if (split_outer.IsSplitDirExplicit)
split_data = &split_outer;
}
DockNodePreviewDockCalc(window, node, payload_window, &split_inner, is_explicit_target, false);
if (split_data == &split_outer)
split_inner.IsDropAllowed = false;
// Draw inner then outer, so that previewed tab (in inner data) will be behind the outer drop boxes
DockNodePreviewDockRender(window, node, payload_window, &split_inner);
DockNodePreviewDockRender(window, node, payload_window, &split_outer);
// Queue docking request
if (split_data->IsDropAllowed && payload->IsDelivery())
DockContextQueueDock(ctx, window, split_data->SplitNode, payload_window, split_data->SplitDir, split_data->SplitRatio, split_data == &split_outer);
}
}
EndDragDropTarget();
}
//-----------------------------------------------------------------------------
// Docking: Settings
//-----------------------------------------------------------------------------
// - DockSettingsRenameNodeReferences()
// - DockSettingsRemoveNodeReferences()
// - DockSettingsFindNodeSettings()
// - DockSettingsHandler_ReadOpen()
// - DockSettingsHandler_ReadLine()
// - DockSettingsHandler_DockNodeToSettings()
// - DockSettingsHandler_WriteAll()
//-----------------------------------------------------------------------------
static void ImGui::DockSettingsRenameNodeReferences(ImGuiID old_node_id, ImGuiID new_node_id)
{
ImGuiContext& g = *GImGui;
IMGUI_DEBUG_LOG_DOCKING("DockSettingsRenameNodeReferences: from 0x%08X -> to 0x%08X\n", old_node_id, new_node_id);
for (int window_n = 0; window_n < g.Windows.Size; window_n++)
{
ImGuiWindow* window = g.Windows[window_n];
if (window->DockId == old_node_id && window->DockNode == NULL)
window->DockId = new_node_id;
}
for (int settings_n = 0; settings_n < g.SettingsWindows.Size; settings_n++) // FIXME-OPT: We could remove this loop by storing the index in the map
{
ImGuiWindowSettings* window_settings = &g.SettingsWindows[settings_n];
if (window_settings->DockId == old_node_id)
window_settings->DockId = new_node_id;
}
}
// Remove references stored in ImGuiWindowSettings to the given ImGuiDockNodeSettings
static void ImGui::DockSettingsRemoveNodeReferences(ImGuiID* node_ids, int node_ids_count)
{
ImGuiContext& g = *GImGui;
int found = 0;
for (int settings_n = 0; settings_n < g.SettingsWindows.Size; settings_n++) // FIXME-OPT: We could remove this loop by storing the index in the map
{
ImGuiWindowSettings* window_settings = &g.SettingsWindows[settings_n];
for (int node_n = 0; node_n < node_ids_count; node_n++)
if (window_settings->DockId == node_ids[node_n])
{
window_settings->DockId = 0;
window_settings->DockOrder = -1;
if (++found < node_ids_count)
break;
return;
}
}
}
static ImGuiDockNodeSettings* ImGui::DockSettingsFindNodeSettings(ImGuiContext* ctx, ImGuiID id)
{
// FIXME-OPT
ImGuiDockContext* dc = ctx->DockContext;
for (int n = 0; n < dc->SettingsNodes.Size; n++)
if (dc->SettingsNodes[n].ID == id)
return &dc->SettingsNodes[n];
return NULL;
}
static void* ImGui::DockSettingsHandler_ReadOpen(ImGuiContext*, ImGuiSettingsHandler*, const char* name)
{
if (strcmp(name, "Data") != 0)
return NULL;
return (void*)1;
}
static void ImGui::DockSettingsHandler_ReadLine(ImGuiContext* ctx, ImGuiSettingsHandler*, void*, const char* line)
{
char c = 0;
int x = 0, y = 0;
int r = 0;
// Parsing, e.g.
// " DockNode ID=0x00000001 Pos=383,193 Size=201,322 Split=Y,0.506 "
// " DockNode ID=0x00000002 Parent=0x00000001 "
// Important: this code expect currently fields in a fixed order.
ImGuiDockNodeSettings node;
line = ImStrSkipBlank(line);
if (strncmp(line, "DockNode", 8) == 0) { line = ImStrSkipBlank(line + strlen("DockNode")); }
else if (strncmp(line, "DockSpace", 9) == 0) { line = ImStrSkipBlank(line + strlen("DockSpace")); node.Flags |= ImGuiDockNodeFlags_DockSpace; }
else return;
if (sscanf(line, "ID=0x%08X%n", &node.ID, &r) == 1) { line += r; } else return;
if (sscanf(line, " Parent=0x%08X%n", &node.ParentNodeID, &r) == 1) { line += r; if (node.ParentNodeID == 0) return; }
if (sscanf(line, " Window=0x%08X%n", &node.ParentWindowID, &r) ==1) { line += r; if (node.ParentWindowID == 0) return; }
if (node.ParentNodeID == 0)
{
if (sscanf(line, " Pos=%i,%i%n", &x, &y, &r) == 2) { line += r; node.Pos = ImVec2ih((short)x, (short)y); } else return;
if (sscanf(line, " Size=%i,%i%n", &x, &y, &r) == 2) { line += r; node.Size = ImVec2ih((short)x, (short)y); } else return;
}
else
{
if (sscanf(line, " SizeRef=%i,%i%n", &x, &y, &r) == 2) { line += r; node.SizeRef = ImVec2ih((short)x, (short)y); }
}
if (sscanf(line, " Split=%c%n", &c, &r) == 1) { line += r; if (c == 'X') node.SplitAxis = ImGuiAxis_X; else if (c == 'Y') node.SplitAxis = ImGuiAxis_Y; }
if (sscanf(line, " NoResize=%d%n", &x, &r) == 1) { line += r; if (x != 0) node.Flags |= ImGuiDockNodeFlags_NoResize; }
if (sscanf(line, " CentralNode=%d%n", &x, &r) == 1) { line += r; if (x != 0) node.Flags |= ImGuiDockNodeFlags_CentralNode; }
if (sscanf(line, " NoTabBar=%d%n", &x, &r) == 1) { line += r; if (x != 0) node.Flags |= ImGuiDockNodeFlags_NoTabBar; }
if (sscanf(line, " HiddenTabBar=%d%n", &x, &r) == 1) { line += r; if (x != 0) node.Flags |= ImGuiDockNodeFlags_HiddenTabBar; }
if (sscanf(line, " NoWindowMenuButton=%d%n", &x, &r) == 1) { line += r; if (x != 0) node.Flags |= ImGuiDockNodeFlags_NoWindowMenuButton; }
if (sscanf(line, " NoCloseButton=%d%n", &x, &r) == 1) { line += r; if (x != 0) node.Flags |= ImGuiDockNodeFlags_NoCloseButton; }
if (sscanf(line, " Selected=0x%08X%n", &node.SelectedWindowID,&r) == 1) { line += r; }
ImGuiDockContext* dc = ctx->DockContext;
if (node.ParentNodeID != 0)
if (ImGuiDockNodeSettings* parent_settings = DockSettingsFindNodeSettings(ctx, node.ParentNodeID))
node.Depth = parent_settings->Depth + 1;
dc->SettingsNodes.push_back(node);
}
static void DockSettingsHandler_DockNodeToSettings(ImGuiDockContext* dc, ImGuiDockNode* node, int depth)
{
ImGuiDockNodeSettings node_settings;
IM_ASSERT(depth < (1 << (sizeof(node_settings.Depth) << 3)));
node_settings.ID = node->ID;
node_settings.ParentNodeID = node->ParentNode ? node->ParentNode->ID : 0;
node_settings.ParentWindowID = (node->IsDockSpace() && node->HostWindow && node->HostWindow->ParentWindow) ? node->HostWindow->ParentWindow->ID : 0;
node_settings.SelectedWindowID = node->SelectedTabID;
node_settings.SplitAxis = node->IsSplitNode() ? (char)node->SplitAxis : ImGuiAxis_None;
node_settings.Depth = (char)depth;
node_settings.Flags = (node->LocalFlags & ImGuiDockNodeFlags_SavedFlagsMask_);
node_settings.Pos = ImVec2ih(node->Pos);
node_settings.Size = ImVec2ih(node->Size);
node_settings.SizeRef = ImVec2ih(node->SizeRef);
dc->SettingsNodes.push_back(node_settings);
if (node->ChildNodes[0])
DockSettingsHandler_DockNodeToSettings(dc, node->ChildNodes[0], depth + 1);
if (node->ChildNodes[1])
DockSettingsHandler_DockNodeToSettings(dc, node->ChildNodes[1], depth + 1);
}
static void ImGui::DockSettingsHandler_WriteAll(ImGuiContext* ctx, ImGuiSettingsHandler* handler, ImGuiTextBuffer* buf)
{
ImGuiContext& g = *ctx;
ImGuiDockContext* dc = g.DockContext;
if (!(g.IO.ConfigFlags & ImGuiConfigFlags_DockingEnable))
return;
// Gather settings data
// (unlike our windows settings, because nodes are always built we can do a full rewrite of the SettingsNode buffer)
dc->SettingsNodes.resize(0);
dc->SettingsNodes.reserve(dc->Nodes.Data.Size);
for (int n = 0; n < dc->Nodes.Data.Size; n++)
if (ImGuiDockNode* node = (ImGuiDockNode*)dc->Nodes.Data[n].val_p)
if (node->IsRootNode())
DockSettingsHandler_DockNodeToSettings(dc, node, 0);
int max_depth = 0;
for (int node_n = 0; node_n < dc->SettingsNodes.Size; node_n++)
max_depth = ImMax((int)dc->SettingsNodes[node_n].Depth, max_depth);
// Write to text buffer
buf->appendf("[%s][Data]\n", handler->TypeName);
for (int node_n = 0; node_n < dc->SettingsNodes.Size; node_n++)
{
const int line_start_pos = buf->size(); (void)line_start_pos;
const ImGuiDockNodeSettings* node_settings = &dc->SettingsNodes[node_n];
buf->appendf("%*s%s%*s", node_settings->Depth * 2, "", (node_settings->Flags & ImGuiDockNodeFlags_DockSpace) ? "DockSpace" : "DockNode ", (max_depth - node_settings->Depth) * 2, ""); // Text align nodes to facilitate looking at .ini file
buf->appendf(" ID=0x%08X", node_settings->ID);
if (node_settings->ParentNodeID)
{
buf->appendf(" Parent=0x%08X SizeRef=%d,%d", node_settings->ParentNodeID, node_settings->SizeRef.x, node_settings->SizeRef.y);
}
else
{
if (node_settings->ParentWindowID)
buf->appendf(" Window=0x%08X", node_settings->ParentWindowID);
buf->appendf(" Pos=%d,%d Size=%d,%d", node_settings->Pos.x, node_settings->Pos.y, node_settings->Size.x, node_settings->Size.y);
}
if (node_settings->SplitAxis != ImGuiAxis_None)
buf->appendf(" Split=%c", (node_settings->SplitAxis == ImGuiAxis_X) ? 'X' : 'Y');
if (node_settings->Flags & ImGuiDockNodeFlags_NoResize)
buf->appendf(" NoResize=1");
if (node_settings->Flags & ImGuiDockNodeFlags_CentralNode)
buf->appendf(" CentralNode=1");
if (node_settings->Flags & ImGuiDockNodeFlags_NoTabBar)
buf->appendf(" NoTabBar=1");
if (node_settings->Flags & ImGuiDockNodeFlags_HiddenTabBar)
buf->appendf(" HiddenTabBar=1");
if (node_settings->Flags & ImGuiDockNodeFlags_NoWindowMenuButton)
buf->appendf(" NoWindowMenuButton=1");
if (node_settings->Flags & ImGuiDockNodeFlags_NoCloseButton)
buf->appendf(" NoCloseButton=1");
if (node_settings->SelectedWindowID)
buf->appendf(" Selected=0x%08X", node_settings->SelectedWindowID);
#if IMGUI_DEBUG_INI_SETTINGS
// [DEBUG] Include comments in the .ini file to ease debugging
if (ImGuiDockNode* node = DockContextFindNodeByID(ctx, node_settings->ID))
{
buf->appendf("%*s", ImMax(2, (line_start_pos + 92) - buf->size()), ""); // Align everything
if (node->IsDockSpace() && node->HostWindow && node->HostWindow->ParentWindow)
buf->appendf(" ; in '%s'", node->HostWindow->ParentWindow->Name);
int contains_window = 0;
for (int window_n = 0; window_n < ctx->SettingsWindows.Size; window_n++) // Iterate settings so we can give info about windows that didn't exist during the session.
if (ctx->SettingsWindows[window_n].DockId == node_settings->ID)
{
if (contains_window++ == 0)
buf->appendf(" ; contains ");
buf->appendf("'%s' ", ctx->SettingsWindows[window_n].Name);
}
}
#endif
buf->appendf("\n");
}
buf->appendf("\n");
}
//-----------------------------------------------------------------------------
// [SECTION] PLATFORM DEPENDENT HELPERS
//-----------------------------------------------------------------------------
#if defined(_WIN32) && !defined(_WINDOWS_) && !defined(IMGUI_DISABLE_WIN32_FUNCTIONS) && (!defined(IMGUI_DISABLE_WIN32_DEFAULT_CLIPBOARD_FUNCTIONS) || !defined(IMGUI_DISABLE_WIN32_DEFAULT_IME_FUNCTIONS))
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
#endif
#ifndef __MINGW32__
#include <Windows.h>
#else
#include <windows.h>
#endif
#elif defined(__APPLE__)
#include <TargetConditionals.h>
#endif
#if defined(_WIN32) && !defined(IMGUI_DISABLE_WIN32_FUNCTIONS) && !defined(IMGUI_DISABLE_WIN32_DEFAULT_CLIPBOARD_FUNCTIONS)
#ifdef _MSC_VER
#pragma comment(lib, "user32")
#endif
// Win32 clipboard implementation
static const char* GetClipboardTextFn_DefaultImpl(void*)
{
static ImVector<char> buf_local;
buf_local.clear();
if (!::OpenClipboard(NULL))
return NULL;
HANDLE wbuf_handle = ::GetClipboardData(CF_UNICODETEXT);
if (wbuf_handle == NULL)
{
::CloseClipboard();
return NULL;
}
if (ImWchar* wbuf_global = (ImWchar*)::GlobalLock(wbuf_handle))
{
int buf_len = ImTextCountUtf8BytesFromStr(wbuf_global, NULL) + 1;
buf_local.resize(buf_len);
ImTextStrToUtf8(buf_local.Data, buf_len, wbuf_global, NULL);
}
::GlobalUnlock(wbuf_handle);
::CloseClipboard();
return buf_local.Data;
}
static void SetClipboardTextFn_DefaultImpl(void*, const char* text)
{
if (!::OpenClipboard(NULL))
return;
const int wbuf_length = ImTextCountCharsFromUtf8(text, NULL) + 1;
HGLOBAL wbuf_handle = ::GlobalAlloc(GMEM_MOVEABLE, (SIZE_T)wbuf_length * sizeof(ImWchar));
if (wbuf_handle == NULL)
{
::CloseClipboard();
return;
}
ImWchar* wbuf_global = (ImWchar*)::GlobalLock(wbuf_handle);
ImTextStrFromUtf8(wbuf_global, wbuf_length, text, NULL);
::GlobalUnlock(wbuf_handle);
::EmptyClipboard();
if (::SetClipboardData(CF_UNICODETEXT, wbuf_handle) == NULL)
::GlobalFree(wbuf_handle);
::CloseClipboard();
}
#elif defined(__APPLE__) && TARGET_OS_OSX && defined(IMGUI_ENABLE_OSX_DEFAULT_CLIPBOARD_FUNCTIONS)
#include <Carbon/Carbon.h> // Use old API to avoid need for separate .mm file
static PasteboardRef main_clipboard = 0;
// OSX clipboard implementation
// If you enable this you will need to add '-framework ApplicationServices' to your linker command-line!
static void SetClipboardTextFn_DefaultImpl(void*, const char* text)
{
if (!main_clipboard)
PasteboardCreate(kPasteboardClipboard, &main_clipboard);
PasteboardClear(main_clipboard);
CFDataRef cf_data = CFDataCreate(kCFAllocatorDefault, (const UInt8*)text, strlen(text));
if (cf_data)
{
PasteboardPutItemFlavor(main_clipboard, (PasteboardItemID)1, CFSTR("public.utf8-plain-text"), cf_data, 0);
CFRelease(cf_data);
}
}
static const char* GetClipboardTextFn_DefaultImpl(void*)
{
if (!main_clipboard)
PasteboardCreate(kPasteboardClipboard, &main_clipboard);
PasteboardSynchronize(main_clipboard);
ItemCount item_count = 0;
PasteboardGetItemCount(main_clipboard, &item_count);
for (int i = 0; i < item_count; i++)
{
PasteboardItemID item_id = 0;
PasteboardGetItemIdentifier(main_clipboard, i + 1, &item_id);
CFArrayRef flavor_type_array = 0;
PasteboardCopyItemFlavors(main_clipboard, item_id, &flavor_type_array);
for (CFIndex j = 0, nj = CFArrayGetCount(flavor_type_array); j < nj; j++)
{
CFDataRef cf_data;
if (PasteboardCopyItemFlavorData(main_clipboard, item_id, CFSTR("public.utf8-plain-text"), &cf_data) == noErr)
{
static ImVector<char> clipboard_text;
int length = (int)CFDataGetLength(cf_data);
clipboard_text.resize(length + 1);
CFDataGetBytes(cf_data, CFRangeMake(0, length), (UInt8*)clipboard_text.Data);
clipboard_text[length] = 0;
CFRelease(cf_data);
return clipboard_text.Data;
}
}
}
return NULL;
}
#else
// Local Dear ImGui-only clipboard implementation, if user hasn't defined better clipboard handlers.
static const char* GetClipboardTextFn_DefaultImpl(void*)
{
ImGuiContext& g = *GImGui;
return g.PrivateClipboard.empty() ? NULL : g.PrivateClipboard.begin();
}
static void SetClipboardTextFn_DefaultImpl(void*, const char* text)
{
ImGuiContext& g = *GImGui;
g.PrivateClipboard.clear();
const char* text_end = text + strlen(text);
g.PrivateClipboard.resize((int)(text_end - text) + 1);
memcpy(&g.PrivateClipboard[0], text, (size_t)(text_end - text));
g.PrivateClipboard[(int)(text_end - text)] = 0;
}
#endif
//-----------------------------------------------------------------------------
// [SECTION] METRICS/DEBUG WINDOW
//-----------------------------------------------------------------------------
static void RenderViewportThumbnail(ImDrawList* draw_list, ImGuiViewportP* viewport, const ImRect& bb)
{
ImGuiContext& g = *GImGui;
ImGuiWindow* window = g.CurrentWindow;
ImVec2 scale = bb.GetSize() / viewport->Size;
ImVec2 off = bb.Min - viewport->Pos * scale;
float alpha_mul = (viewport->Flags & ImGuiViewportFlags_Minimized) ? 0.30f : 1.00f;
window->DrawList->AddRectFilled(bb.Min, bb.Max, ImGui::GetColorU32(ImGuiCol_Border, alpha_mul * 0.40f));
for (int i = 0; i != g.Windows.Size; i++)
{
ImGuiWindow* thumb_window = g.Windows[i];
if (!thumb_window->WasActive || ((thumb_window->Flags & ImGuiWindowFlags_ChildWindow)))
continue;
if (thumb_window->SkipItems && (thumb_window->Flags & ImGuiWindowFlags_ChildWindow)) // FIXME-DOCK: Skip hidden docked windows. Identify those betters.
continue;
if (thumb_window->Viewport != viewport)
continue;
ImRect thumb_r = thumb_window->Rect();
ImRect title_r = thumb_window->TitleBarRect();
ImRect thumb_r_scaled = ImRect(ImFloor(off + thumb_r.Min * scale), ImFloor(off + thumb_r.Max * scale));
ImRect title_r_scaled = ImRect(ImFloor(off + title_r.Min * scale), ImFloor(off + ImVec2(title_r.Max.x, title_r.Min.y) * scale) + ImVec2(0,5)); // Exaggerate title bar height
thumb_r_scaled.ClipWithFull(bb);
title_r_scaled.ClipWithFull(bb);
const bool window_is_focused = (g.NavWindow && thumb_window->RootWindowForTitleBarHighlight == g.NavWindow->RootWindowForTitleBarHighlight);
window->DrawList->AddRectFilled(thumb_r_scaled.Min, thumb_r_scaled.Max, ImGui::GetColorU32(ImGuiCol_WindowBg, alpha_mul));
window->DrawList->AddRectFilled(title_r_scaled.Min, title_r_scaled.Max, ImGui::GetColorU32(window_is_focused ? ImGuiCol_TitleBgActive : ImGuiCol_TitleBg, alpha_mul));
window->DrawList->AddRect(thumb_r_scaled.Min, thumb_r_scaled.Max, ImGui::GetColorU32(ImGuiCol_Border, alpha_mul));
if (ImGuiWindow* window_for_title = GetWindowForTitleDisplay(thumb_window))
window->DrawList->AddText(g.Font, g.FontSize * 1.0f, title_r_scaled.Min, ImGui::GetColorU32(ImGuiCol_Text, alpha_mul), window_for_title->Name, ImGui::FindRenderedTextEnd(window_for_title->Name));
}
draw_list->AddRect(bb.Min, bb.Max, ImGui::GetColorU32(ImGuiCol_Border, alpha_mul));
}
void ImGui::ShowViewportThumbnails()
{
ImGuiContext& g = *GImGui;
ImGuiWindow* window = g.CurrentWindow;
// We don't display full monitor bounds (we could, but it often looks awkward), instead we display just enough to cover all of our viewports.
float SCALE = 1.0f / 8.0f;
ImRect bb_full;
//for (int n = 0; n < g.PlatformIO.Monitors.Size; n++)
// bb_full.Add(GetPlatformMonitorMainRect(g.PlatformIO.Monitors[n]));
for (int n = 0; n < g.Viewports.Size; n++)
bb_full.Add(g.Viewports[n]->GetRect());
ImVec2 p = window->DC.CursorPos;
ImVec2 off = p - bb_full.Min * SCALE;
//for (int n = 0; n < g.PlatformIO.Monitors.Size; n++)
// window->DrawList->AddRect(off + g.PlatformIO.Monitors[n].MainPos * SCALE, off + (g.PlatformIO.Monitors[n].MainPos + g.PlatformIO.Monitors[n].MainSize) * SCALE, ImGui::GetColorU32(ImGuiCol_Border));
for (int n = 0; n < g.Viewports.Size; n++)
{
ImGuiViewportP* viewport = g.Viewports[n];
ImRect viewport_draw_bb(off + (viewport->Pos) * SCALE, off + (viewport->Pos + viewport->Size) * SCALE);
RenderViewportThumbnail(window->DrawList, viewport, viewport_draw_bb);
}
ImGui::Dummy(bb_full.GetSize() * SCALE);
}
#ifndef IMGUI_DISABLE_METRICS_WINDOW
void ImGui::ShowMetricsWindow(bool* p_open)
{
if (!ImGui::Begin("Dear ImGui Metrics", p_open))
{
ImGui::End();
return;
}
// State
enum { WRT_OuterRect, WRT_OuterRectClipped, WRT_InnerRect, WRT_InnerClipRect, WRT_WorkRect, WRT_Contents, WRT_ContentsRegionRect, WRT_Count }; // Windows Rect Type
const char* wrt_rects_names[WRT_Count] = { "OuterRect", "OuterRectClipped", "InnerRect", "InnerClipRect", "WorkRect", "Contents", "ContentsRegionRect" };
static bool show_windows_rects = false;
static int show_windows_rect_type = WRT_WorkRect;
static bool show_windows_begin_order = false;
static bool show_drawcmd_clip_rects = true;
static bool show_docking_nodes = false;
// Basic info
ImGuiContext& g = *GImGui;
ImGuiIO& io = ImGui::GetIO();
ImGui::Text("Dear ImGui %s", ImGui::GetVersion());
ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / io.Framerate, io.Framerate);
ImGui::Text("%d vertices, %d indices (%d triangles)", io.MetricsRenderVertices, io.MetricsRenderIndices, io.MetricsRenderIndices / 3);
ImGui::Text("%d active windows (%d visible)", io.MetricsActiveWindows, io.MetricsRenderWindows);
ImGui::Text("%d active allocations", io.MetricsActiveAllocations);
ImGui::Separator();
// Helper functions to display common structures:
// - NodeDrawList
// - NodeColumns
// - NodeWindow
// - NodeWindows
// - NodeViewport
// - NodeDockNode
// - NodeTabBar
struct Funcs
{
static ImRect GetWindowRect(ImGuiWindow* window, int rect_type)
{
if (rect_type == WRT_OuterRect) { return window->Rect(); }
else if (rect_type == WRT_OuterRectClipped) { return window->OuterRectClipped; }
else if (rect_type == WRT_InnerRect) { return window->InnerRect; }
else if (rect_type == WRT_InnerClipRect) { return window->InnerClipRect; }
else if (rect_type == WRT_WorkRect) { return window->WorkRect; }
else if (rect_type == WRT_Contents) { ImVec2 min = window->InnerRect.Min - window->Scroll + window->WindowPadding; return ImRect(min, min + window->ContentSize); }
else if (rect_type == WRT_ContentsRegionRect) { return window->ContentsRegionRect; }
IM_ASSERT(0);
return ImRect();
}
static void NodeDrawList(ImGuiWindow* window, ImGuiViewportP* viewport, ImDrawList* draw_list, const char* label)
{
bool node_open = ImGui::TreeNode(draw_list, "%s: '%s' %d vtx, %d indices, %d cmds", label, draw_list->_OwnerName ? draw_list->_OwnerName : "", draw_list->VtxBuffer.Size, draw_list->IdxBuffer.Size, draw_list->CmdBuffer.Size);
if (draw_list == ImGui::GetWindowDrawList())
{
ImGui::SameLine();
ImGui::TextColored(ImVec4(1.0f,0.4f,0.4f,1.0f), "CURRENTLY APPENDING"); // Can't display stats for active draw list! (we don't have the data double-buffered)
if (node_open) ImGui::TreePop();
return;
}
ImDrawList* fg_draw_list = viewport ? GetForegroundDrawList(viewport) : NULL; // Render additional visuals into the top-most draw list
if (window && fg_draw_list && ImGui::IsItemHovered())
fg_draw_list->AddRect(window->Pos, window->Pos + window->Size, IM_COL32(255, 255, 0, 255));
if (!node_open)
return;
if (window && !window->WasActive)
ImGui::Text("(Note: owning Window is inactive: DrawList is not being rendered!)");
int elem_offset = 0;
for (const ImDrawCmd* pcmd = draw_list->CmdBuffer.begin(); pcmd < draw_list->CmdBuffer.end(); elem_offset += pcmd->ElemCount, pcmd++)
{
if (pcmd->UserCallback == NULL && pcmd->ElemCount == 0)
continue;
if (pcmd->UserCallback)
{
ImGui::BulletText("Callback %p, user_data %p", pcmd->UserCallback, pcmd->UserCallbackData);
continue;
}
ImDrawIdx* idx_buffer = (draw_list->IdxBuffer.Size > 0) ? draw_list->IdxBuffer.Data : NULL;
char buf[300];
ImFormatString(buf, IM_ARRAYSIZE(buf), "Draw %4d triangles, tex 0x%p, clip_rect (%4.0f,%4.0f)-(%4.0f,%4.0f)",
pcmd->ElemCount/3, (void*)(intptr_t)pcmd->TextureId, pcmd->ClipRect.x, pcmd->ClipRect.y, pcmd->ClipRect.z, pcmd->ClipRect.w);
bool pcmd_node_open = ImGui::TreeNode((void*)(pcmd - draw_list->CmdBuffer.begin()), "%s", buf);
if (show_drawcmd_clip_rects && fg_draw_list && ImGui::IsItemHovered())
{
ImRect clip_rect = pcmd->ClipRect;
ImRect vtxs_rect;
for (int i = elem_offset; i < elem_offset + (int)pcmd->ElemCount; i++)
vtxs_rect.Add(draw_list->VtxBuffer[idx_buffer ? idx_buffer[i] : i].pos);
clip_rect.Floor(); fg_draw_list->AddRect(clip_rect.Min, clip_rect.Max, IM_COL32(255,0,255,255));
vtxs_rect.Floor(); fg_draw_list->AddRect(vtxs_rect.Min, vtxs_rect.Max, IM_COL32(255,255,0,255));
}
if (!pcmd_node_open)
continue;
// Display individual triangles/vertices. Hover on to get the corresponding triangle highlighted.
ImGui::Text("ElemCount: %d, ElemCount/3: %d, VtxOffset: +%d, IdxOffset: +%d", pcmd->ElemCount, pcmd->ElemCount/3, pcmd->VtxOffset, pcmd->IdxOffset);
ImGuiListClipper clipper(pcmd->ElemCount/3); // Manually coarse clip our print out of individual vertices to save CPU, only items that may be visible.
while (clipper.Step())
for (int prim = clipper.DisplayStart, idx_i = elem_offset + clipper.DisplayStart*3; prim < clipper.DisplayEnd; prim++)
{
char *buf_p = buf, *buf_end = buf + IM_ARRAYSIZE(buf);
ImVec2 triangles_pos[3];
for (int n = 0; n < 3; n++, idx_i++)
{
int vtx_i = idx_buffer ? idx_buffer[idx_i] : idx_i;
ImDrawVert& v = draw_list->VtxBuffer[vtx_i];
triangles_pos[n] = v.pos;
buf_p += ImFormatString(buf_p, buf_end - buf_p, "%s %04d: pos (%8.2f,%8.2f), uv (%.6f,%.6f), col %08X\n",
(n == 0) ? "elem" : " ", idx_i, v.pos.x, v.pos.y, v.uv.x, v.uv.y, v.col);
}
ImGui::Selectable(buf, false);
if (fg_draw_list && ImGui::IsItemHovered())
{
ImDrawListFlags backup_flags = fg_draw_list->Flags;
fg_draw_list->Flags &= ~ImDrawListFlags_AntiAliasedLines; // Disable AA on triangle outlines at is more readable for very large and thin triangles.
fg_draw_list->AddPolyline(triangles_pos, 3, IM_COL32(255,255,0,255), true, 1.0f);
fg_draw_list->Flags = backup_flags;
}
}
ImGui::TreePop();
}
ImGui::TreePop();
}
static void NodeColumns(const ImGuiColumns* columns)
{
if (!ImGui::TreeNode((void*)(uintptr_t)columns->ID, "Columns Id: 0x%08X, Count: %d, Flags: 0x%04X", columns->ID, columns->Count, columns->Flags))
return;
ImGui::BulletText("Width: %.1f (MinX: %.1f, MaxX: %.1f)", columns->OffMaxX - columns->OffMinX, columns->OffMinX, columns->OffMaxX);
for (int column_n = 0; column_n < columns->Columns.Size; column_n++)
ImGui::BulletText("Column %02d: OffsetNorm %.3f (= %.1f px)", column_n, columns->Columns[column_n].OffsetNorm, GetColumnOffsetFromNorm(columns, columns->Columns[column_n].OffsetNorm));
ImGui::TreePop();
}
static void NodeWindow(ImGuiWindow* window, const char* label)
{
if (window == NULL)
{
ImGui::BulletText("%s: NULL", label);
return;
}
if (!ImGui::TreeNode(window, "%s '%s', %d @ 0x%p", label, window->Name, (window->Active || window->WasActive), window))
return;
ImGuiWindowFlags flags = window->Flags;
NodeDrawList(window, window->Viewport, window->DrawList, "DrawList");
ImGui::BulletText("Pos: (%.1f,%.1f), Size: (%.1f,%.1f), ContentSize (%.1f,%.1f)", window->Pos.x, window->Pos.y, window->Size.x, window->Size.y, window->ContentSize.x, window->ContentSize.y);
ImGui::BulletText("Flags: 0x%08X (%s%s%s%s%s%s%s%s%s..)", flags,
(flags & ImGuiWindowFlags_ChildWindow) ? "Child " : "", (flags & ImGuiWindowFlags_Tooltip) ? "Tooltip " : "", (flags & ImGuiWindowFlags_Popup) ? "Popup " : "",
(flags & ImGuiWindowFlags_Modal) ? "Modal " : "", (flags & ImGuiWindowFlags_ChildMenu) ? "ChildMenu " : "", (flags & ImGuiWindowFlags_NoSavedSettings) ? "NoSavedSettings " : "",
(flags & ImGuiWindowFlags_NoMouseInputs)? "NoMouseInputs":"", (flags & ImGuiWindowFlags_NoNavInputs) ? "NoNavInputs" : "", (flags & ImGuiWindowFlags_AlwaysAutoResize) ? "AlwaysAutoResize" : "");
ImGui::BulletText("WindowClassId: 0x%08X", window->WindowClass.ClassId);
ImGui::BulletText("Scroll: (%.2f/%.2f,%.2f/%.2f)", window->Scroll.x, window->ScrollMax.x, window->Scroll.y, window->ScrollMax.y);
ImGui::BulletText("Active: %d/%d, WriteAccessed: %d, BeginOrderWithinContext: %d", window->Active, window->WasActive, window->WriteAccessed, (window->Active || window->WasActive) ? window->BeginOrderWithinContext : -1);
ImGui::BulletText("Appearing: %d, Hidden: %d (CanSkip %d Cannot %d), SkipItems: %d", window->Appearing, window->Hidden, window->HiddenFramesCanSkipItems, window->HiddenFramesCannotSkipItems, window->SkipItems);
ImGui::BulletText("NavLastIds: 0x%08X,0x%08X, NavLayerActiveMask: %X", window->NavLastIds[0], window->NavLastIds[1], window->DC.NavLayerActiveMask);
ImGui::BulletText("NavLastChildNavWindow: %s", window->NavLastChildNavWindow ? window->NavLastChildNavWindow->Name : "NULL");
if (!window->NavRectRel[0].IsInverted())
ImGui::BulletText("NavRectRel[0]: (%.1f,%.1f)(%.1f,%.1f)", window->NavRectRel[0].Min.x, window->NavRectRel[0].Min.y, window->NavRectRel[0].Max.x, window->NavRectRel[0].Max.y);
else
ImGui::BulletText("NavRectRel[0]: <None>");
ImGui::BulletText("Viewport: %d%s, ViewportId: 0x%08X, ViewportPos: (%.1f,%.1f)", window->Viewport ? window->Viewport->Idx : -1, window->ViewportOwned ? " (Owned)" : "", window->ViewportId, window->ViewportPos.x, window->ViewportPos.y);
ImGui::BulletText("ViewportMonitor: %d", window->Viewport ? window->Viewport->PlatformMonitor : -1);
ImGui::BulletText("DockId: 0x%04X, DockOrder: %d, Act: %d, Vis: %d", window->DockId, window->DockOrder, window->DockIsActive, window->DockTabIsVisible);
if (window->DockNode || window->DockNodeAsHost)
NodeDockNode(window->DockNodeAsHost ? window->DockNodeAsHost : window->DockNode, window->DockNodeAsHost ? "DockNodeAsHost" : "DockNode");
if (window->RootWindow != window) NodeWindow(window->RootWindow, "RootWindow");
if (window->RootWindowDockStop != window->RootWindow) NodeWindow(window->RootWindowDockStop, "RootWindowDockStop");
if (window->ParentWindow != NULL) NodeWindow(window->ParentWindow, "ParentWindow");
if (window->DC.ChildWindows.Size > 0) NodeWindows(window->DC.ChildWindows, "ChildWindows");
if (window->ColumnsStorage.Size > 0 && ImGui::TreeNode("Columns", "Columns sets (%d)", window->ColumnsStorage.Size))
{
for (int n = 0; n < window->ColumnsStorage.Size; n++)
NodeColumns(&window->ColumnsStorage[n]);
ImGui::TreePop();
}
ImGui::BulletText("Storage: %d bytes", window->StateStorage.Data.size_in_bytes());
ImGui::TreePop();
}
static void NodeWindows(ImVector<ImGuiWindow*>& windows, const char* label)
{
if (!ImGui::TreeNode(label, "%s (%d)", label, windows.Size))
return;
for (int i = 0; i < windows.Size; i++)
Funcs::NodeWindow(windows[i], "Window");
ImGui::TreePop();
}
static void NodeViewport(ImGuiViewportP* viewport)
{
ImGui::SetNextItemOpen(true, ImGuiCond_Once);
if (ImGui::TreeNode((void*)(intptr_t)viewport->ID, "Viewport #%d, ID: 0x%08X, Parent: 0x%08X, Window: \"%s\"", viewport->Idx, viewport->ID, viewport->ParentViewportId, viewport->Window ? viewport->Window->Name : "N/A"))
{
ImGuiWindowFlags flags = viewport->Flags;
ImGui::BulletText("Pos: (%.0f,%.0f), Size: (%.0f,%.0f), Monitor: %d, DpiScale: %.0f%%", viewport->Pos.x, viewport->Pos.y, viewport->Size.x, viewport->Size.y, viewport->PlatformMonitor, viewport->DpiScale * 100.0f);
if (viewport->Idx > 0) { ImGui::SameLine(); if (ImGui::SmallButton("Reset Pos")) { viewport->Pos = ImVec2(200,200); if (viewport->Window) viewport->Window->Pos = ImVec2(200,200); } }
ImGui::BulletText("Flags: 0x%04X =%s%s%s%s%s%s%s", viewport->Flags,
(flags & ImGuiViewportFlags_CanHostOtherWindows) ? " CanHostOtherWindows" : "", (flags & ImGuiViewportFlags_NoDecoration) ? " NoDecoration" : "",
(flags & ImGuiViewportFlags_NoFocusOnAppearing) ? " NoFocusOnAppearing" : "", (flags & ImGuiViewportFlags_NoInputs) ? " NoInputs" : "",
(flags & ImGuiViewportFlags_NoRendererClear) ? " NoRendererClear" : "", (flags & ImGuiViewportFlags_Minimized) ? " Minimized" : "",
(flags & ImGuiViewportFlags_NoAutoMerge) ? " NoAutoMerge" : "");
for (int layer_i = 0; layer_i < IM_ARRAYSIZE(viewport->DrawDataBuilder.Layers); layer_i++)
for (int draw_list_i = 0; draw_list_i < viewport->DrawDataBuilder.Layers[layer_i].Size; draw_list_i++)
Funcs::NodeDrawList(NULL, viewport, viewport->DrawDataBuilder.Layers[layer_i][draw_list_i], "DrawList");
ImGui::TreePop();
}
}
static void NodeDockNode(ImGuiDockNode* node, const char* label)
{
ImGuiContext& g = *GImGui;
bool open;
if (node->Windows.Size > 0)
open = ImGui::TreeNode((void*)(intptr_t)node->ID, "%s 0x%04X%s: %d windows (vis: '%s')", label, node->ID, node->IsVisible ? "" : " (hidden)", node->Windows.Size, node->VisibleWindow ? node->VisibleWindow->Name : "NULL");
else
open = ImGui::TreeNode((void*)(intptr_t)node->ID, "%s 0x%04X%s: %s split (vis: '%s')", label, node->ID, node->IsVisible ? "" : " (hidden)", (node->SplitAxis == ImGuiAxis_X) ? "horizontal" : (node->SplitAxis == ImGuiAxis_Y) ? "vertical" : "n/a", node->VisibleWindow ? node->VisibleWindow->Name : "NULL");
if (open)
{
IM_ASSERT(node->ChildNodes[0] == NULL || node->ChildNodes[0]->ParentNode == node);
IM_ASSERT(node->ChildNodes[1] == NULL || node->ChildNodes[1]->ParentNode == node);
ImGui::BulletText("Pos (%.0f,%.0f), Size (%.0f, %.0f) Ref (%.0f, %.0f)",
node->Pos.x, node->Pos.y, node->Size.x, node->Size.y, node->SizeRef.x, node->SizeRef.y);
NodeWindow(node->HostWindow, "HostWindow");
NodeWindow(node->VisibleWindow, "VisibleWindow");
ImGui::BulletText("SelectedTabID: 0x%08X, LastFocusedNodeID: 0x%08X", node->SelectedTabID, node->LastFocusedNodeID);
ImGui::BulletText("Misc:%s%s%s%s", node->IsDockSpace() ? " IsDockSpace" : "", node->IsCentralNode() ? " IsCentralNode" : "", (g.FrameCount - node->LastFrameAlive < 2) ? " IsAlive" : "", (g.FrameCount - node->LastFrameActive < 2) ? " IsActive" : "");
if (ImGui::TreeNode("flags", "LocalFlags: 0x%04X SharedFlags: 0x%04X", node->LocalFlags, node->SharedFlags))
{
ImGui::CheckboxFlags("LocalFlags: NoSplit", (ImU32*)&node->LocalFlags, ImGuiDockNodeFlags_NoSplit);
ImGui::CheckboxFlags("LocalFlags: NoResize", (ImU32*)&node->LocalFlags, ImGuiDockNodeFlags_NoResize);
ImGui::CheckboxFlags("LocalFlags: NoTabBar", (ImU32*)&node->LocalFlags, ImGuiDockNodeFlags_NoTabBar);
ImGui::CheckboxFlags("LocalFlags: HiddenTabBar", (ImU32*)&node->LocalFlags, ImGuiDockNodeFlags_HiddenTabBar);
ImGui::CheckboxFlags("LocalFlags: NoWindowMenuButton", (ImU32*)&node->LocalFlags, ImGuiDockNodeFlags_NoWindowMenuButton);
ImGui::CheckboxFlags("LocalFlags: NoCloseButton", (ImU32*)&node->LocalFlags, ImGuiDockNodeFlags_NoCloseButton);
ImGui::TreePop();
}
if (node->ParentNode)
NodeDockNode(node->ParentNode, "ParentNode");
if (node->ChildNodes[0])
NodeDockNode(node->ChildNodes[0], "Child[0]");
if (node->ChildNodes[1])
NodeDockNode(node->ChildNodes[1], "Child[1]");
if (node->TabBar)
NodeTabBar(node->TabBar);
ImGui::TreePop();
}
}
static void NodeTabBar(ImGuiTabBar* tab_bar)
{
// Standalone tab bars (not associated to docking/windows functionality) currently hold no discernible strings.
char buf[256];
char* p = buf;
const char* buf_end = buf + IM_ARRAYSIZE(buf);
p += ImFormatString(p, buf_end - p, "TabBar (%d tabs)%s",
tab_bar->Tabs.Size, (tab_bar->PrevFrameVisible < ImGui::GetFrameCount() - 2) ? " *Inactive*" : "");
if (tab_bar->Flags & ImGuiTabBarFlags_DockNode)
{
p += ImFormatString(p, buf_end - p, " { ");
for (int tab_n = 0; tab_n < ImMin(tab_bar->Tabs.Size, 3); tab_n++)
p += ImFormatString(p, buf_end - p, "%s'%s'", tab_n > 0 ? ", " : "", tab_bar->Tabs[tab_n].Window->Name);
p += ImFormatString(p, buf_end - p, (tab_bar->Tabs.Size > 3) ? " ... }" : " } ");
}
if (ImGui::TreeNode(tab_bar, "%s", buf))
{
for (int tab_n = 0; tab_n < tab_bar->Tabs.Size; tab_n++)
{
const ImGuiTabItem* tab = &tab_bar->Tabs[tab_n];
ImGui::PushID(tab);
if (ImGui::SmallButton("<")) { TabBarQueueChangeTabOrder(tab_bar, tab, -1); } ImGui::SameLine(0, 2);
if (ImGui::SmallButton(">")) { TabBarQueueChangeTabOrder(tab_bar, tab, +1); } ImGui::SameLine();
ImGui::Text("%02d%c Tab 0x%08X '%s'", tab_n, (tab->ID == tab_bar->SelectedTabId) ? '*' : ' ', tab->ID, tab->Window ? tab->Window->Name : "N/A");
ImGui::PopID();
}
ImGui::TreePop();
}
}
};
Funcs::NodeWindows(g.Windows, "Windows");
if (ImGui::TreeNode("Viewport", "Viewports (%d)", g.Viewports.Size))
{
ImGui::Indent(ImGui::GetTreeNodeToLabelSpacing());
ImGui::ShowViewportThumbnails();
ImGui::Unindent(ImGui::GetTreeNodeToLabelSpacing());
if (g.PlatformIO.Monitors.Size > 0 && ImGui::TreeNode("Monitors", "Monitors (%d)", g.PlatformIO.Monitors.Size))
{
ImGui::TextWrapped("(When viewports are enabled, imgui needs uses monitor data to position popup/tooltips so they don't straddle monitors.)");
for (int i = 0; i < g.PlatformIO.Monitors.Size; i++)
{
const ImGuiPlatformMonitor& mon = g.PlatformIO.Monitors[i];
ImGui::BulletText("Monitor #%d: DPI %.0f%%\n MainMin (%.0f,%.0f), MainMax (%.0f,%.0f), MainSize (%.0f,%.0f)\n WorkMin (%.0f,%.0f), WorkMax (%.0f,%.0f), WorkSize (%.0f,%.0f)",
i, mon.DpiScale * 100.0f,
mon.MainPos.x, mon.MainPos.y, mon.MainPos.x + mon.MainSize.x, mon.MainPos.y + mon.MainSize.y, mon.MainSize.x, mon.MainSize.y,
mon.WorkPos.x, mon.WorkPos.y, mon.WorkPos.x + mon.WorkSize.x, mon.WorkPos.y + mon.WorkSize.y, mon.WorkSize.x, mon.WorkSize.y);
}
ImGui::TreePop();
}
for (int i = 0; i < g.Viewports.Size; i++)
Funcs::NodeViewport(g.Viewports[i]);
ImGui::TreePop();
}
if (ImGui::TreeNode("Popups", "Popups (%d)", g.OpenPopupStack.Size))
{
for (int i = 0; i < g.OpenPopupStack.Size; i++)
{
ImGuiWindow* window = g.OpenPopupStack[i].Window;
ImGui::BulletText("PopupID: %08x, Window: '%s'%s%s", g.OpenPopupStack[i].PopupId, window ? window->Name : "NULL", window && (window->Flags & ImGuiWindowFlags_ChildWindow) ? " ChildWindow" : "", window && (window->Flags & ImGuiWindowFlags_ChildMenu) ? " ChildMenu" : "");
}
ImGui::TreePop();
}
if (ImGui::TreeNode("TabBars", "Tab Bars (%d)", g.TabBars.Data.Size))
{
for (int n = 0; n < g.TabBars.Data.Size; n++)
Funcs::NodeTabBar(g.TabBars.GetByIndex(n));
ImGui::TreePop();
}
if (ImGui::TreeNode("Docking"))
{
ImGuiDockContext* dc = g.DockContext;
ImGui::Checkbox("Ctrl shows window dock info", &show_docking_nodes);
if (ImGui::TreeNode("Dock nodes"))
{
if (ImGui::SmallButton("Clear settings")) { DockContextClearNodes(&g, 0, true); }
ImGui::SameLine();
if (ImGui::SmallButton("Rebuild all")) { dc->WantFullRebuild = true; }
for (int n = 0; n < dc->Nodes.Data.Size; n++)
if (ImGuiDockNode* node = (ImGuiDockNode*)dc->Nodes.Data[n].val_p)
if (node->IsRootNode())
Funcs::NodeDockNode(node, "Node");
ImGui::TreePop();
}
if (ImGui::TreeNode("Settings"))
{
if (ImGui::SmallButton("Refresh"))
SaveIniSettingsToMemory();
ImGui::SameLine();
if (ImGui::SmallButton("Save to disk"))
SaveIniSettingsToDisk(g.IO.IniFilename);
ImGui::Separator();
ImGui::Text("Docked Windows:");
for (int n = 0; n < g.SettingsWindows.Size; n++)
if (g.SettingsWindows[n].DockId != 0)
ImGui::BulletText("Window '%s' -> DockId %08X", g.SettingsWindows[n].Name, g.SettingsWindows[n].DockId);
ImGui::Separator();
ImGui::Text("Dock Nodes:");
for (int n = 0; n < dc->SettingsNodes.Size; n++)
{
ImGuiDockNodeSettings* settings = &dc->SettingsNodes[n];
const char* selected_tab_name = NULL;
if (settings->SelectedWindowID)
{
if (ImGuiWindow* window = FindWindowByID(settings->SelectedWindowID))
selected_tab_name = window->Name;
else if (ImGuiWindowSettings* window_settings = FindWindowSettings(settings->SelectedWindowID))
selected_tab_name = window_settings->Name;
}
ImGui::BulletText("Node %08X, Parent %08X, SelectedTab %08X ('%s')", settings->ID, settings->ParentNodeID, settings->SelectedWindowID, selected_tab_name ? selected_tab_name : settings->SelectedWindowID ? "N/A" : "");
}
ImGui::TreePop();
}
ImGui::TreePop();
}
#if 0
if (ImGui::TreeNode("Tables", "Tables (%d)", g.Tables.Data.Size))
{
ImGui::TreePop();
}
#endif
if (ImGui::TreeNode("Internal state"))
{
const char* input_source_names[] = { "None", "Mouse", "Nav", "NavKeyboard", "NavGamepad" }; IM_ASSERT(IM_ARRAYSIZE(input_source_names) == ImGuiInputSource_COUNT);
ImGui::Text("HoveredWindow: '%s'", g.HoveredWindow ? g.HoveredWindow->Name : "NULL");
ImGui::Text("HoveredRootWindow: '%s'", g.HoveredRootWindow ? g.HoveredRootWindow->Name : "NULL");
ImGui::Text("HoveredWindowUnderMovingWindow: '%s'", g.HoveredWindowUnderMovingWindow ? g.HoveredWindowUnderMovingWindow->Name : "NULL");
ImGui::Text("HoveredId: 0x%08X/0x%08X (%.2f sec), AllowOverlap: %d", g.HoveredId, g.HoveredIdPreviousFrame, g.HoveredIdTimer, g.HoveredIdAllowOverlap); // Data is "in-flight" so depending on when the Metrics window is called we may see current frame information or not
ImGui::Text("ActiveId: 0x%08X/0x%08X (%.2f sec), AllowOverlap: %d, Source: %s", g.ActiveId, g.ActiveIdPreviousFrame, g.ActiveIdTimer, g.ActiveIdAllowOverlap, input_source_names[g.ActiveIdSource]);
ImGui::Text("ActiveIdWindow: '%s'", g.ActiveIdWindow ? g.ActiveIdWindow->Name : "NULL");
ImGui::Text("MovingWindow: '%s'", g.MovingWindow ? g.MovingWindow->Name : "NULL");
ImGui::Text("NavWindow: '%s'", g.NavWindow ? g.NavWindow->Name : "NULL");
ImGui::Text("NavId: 0x%08X, NavLayer: %d", g.NavId, g.NavLayer);
ImGui::Text("NavInputSource: %s", input_source_names[g.NavInputSource]);
ImGui::Text("NavActive: %d, NavVisible: %d", g.IO.NavActive, g.IO.NavVisible);
ImGui::Text("NavActivateId: 0x%08X, NavInputId: 0x%08X", g.NavActivateId, g.NavInputId);
ImGui::Text("NavDisableHighlight: %d, NavDisableMouseHover: %d", g.NavDisableHighlight, g.NavDisableMouseHover);
ImGui::Text("NavWindowingTarget: '%s'", g.NavWindowingTarget ? g.NavWindowingTarget->Name : "NULL");
ImGui::Text("DragDrop: %d, SourceId = 0x%08X, Payload \"%s\" (%d bytes)", g.DragDropActive, g.DragDropPayload.SourceId, g.DragDropPayload.DataType, g.DragDropPayload.DataSize);
ImGui::Text("MouseViewport: 0x%08X (UserHovered 0x%08X, LastHovered 0x%08X)", g.MouseViewport->ID, g.IO.MouseHoveredViewport, g.MouseLastHoveredViewport ? g.MouseLastHoveredViewport->ID : 0);
ImGui::TreePop();
}
if (ImGui::TreeNode("Tools"))
{
// The Item Picker tool is super useful to visually select an item and break into the call-stack of where it was submitted.
if (ImGui::Button("Item Picker.."))
ImGui::DebugStartItemPicker();
ImGui::Checkbox("Show windows begin order", &show_windows_begin_order);
ImGui::Checkbox("Show windows rectangles", &show_windows_rects);
ImGui::SameLine();
ImGui::SetNextItemWidth(ImGui::GetFontSize() * 12);
show_windows_rects |= ImGui::Combo("##show_windows_rect_type", &show_windows_rect_type, wrt_rects_names, WRT_Count);
if (show_windows_rects && g.NavWindow)
{
ImGui::BulletText("'%s':", g.NavWindow->Name);
ImGui::Indent();
for (int rect_n = 0; rect_n < WRT_Count; rect_n++)
{
ImRect r = Funcs::GetWindowRect(g.NavWindow, rect_n);
ImGui::Text("(%6.1f,%6.1f) (%6.1f,%6.1f) Size (%6.1f,%6.1f) %s", r.Min.x, r.Min.y, r.Max.x, r.Max.y, r.GetWidth(), r.GetHeight(), wrt_rects_names[rect_n]);
}
ImGui::Unindent();
}
ImGui::Checkbox("Show clipping rectangle when hovering ImDrawCmd node", &show_drawcmd_clip_rects);
ImGui::TreePop();
}
// Tool: Display windows Rectangles and Begin Order
if (show_windows_rects || show_windows_begin_order)
{
for (int n = 0; n < g.Windows.Size; n++)
{
ImGuiWindow* window = g.Windows[n];
if (!window->WasActive)
continue;
ImDrawList* draw_list = GetForegroundDrawList(window);
if (show_windows_rects)
{
ImRect r = Funcs::GetWindowRect(window, show_windows_rect_type);
draw_list->AddRect(r.Min, r.Max, IM_COL32(255, 0, 128, 255));
}
if (show_windows_begin_order && !(window->Flags & ImGuiWindowFlags_ChildWindow))
{
char buf[32];
ImFormatString(buf, IM_ARRAYSIZE(buf), "%d", window->BeginOrderWithinContext);
float font_size = ImGui::GetFontSize();
draw_list->AddRectFilled(window->Pos, window->Pos + ImVec2(font_size, font_size), IM_COL32(200, 100, 100, 255));
draw_list->AddText(window->Pos, IM_COL32(255, 255, 255, 255), buf);
}
}
}
if (show_docking_nodes && g.IO.KeyCtrl)
{
for (int n = 0; n < g.DockContext->Nodes.Data.Size; n++)
if (ImGuiDockNode* node = (ImGuiDockNode*)g.DockContext->Nodes.Data[n].val_p)
{
ImGuiDockNode* root_node = DockNodeGetRootNode(node);
if (ImGuiDockNode* hovered_node = DockNodeTreeFindNodeByPos(root_node, g.IO.MousePos))
if (hovered_node != node)
continue;
char buf[64] = "";
char* p = buf;
ImDrawList* overlay_draw_list = node->HostWindow ? GetForegroundDrawList(node->HostWindow) : GetForegroundDrawList((ImGuiViewportP*)GetMainViewport());
p += ImFormatString(p, buf + IM_ARRAYSIZE(buf) - p, "DockId: %X%s\n", node->ID, node->IsCentralNode() ? " *CentralNode*" : "");
p += ImFormatString(p, buf + IM_ARRAYSIZE(buf) - p, "WindowClass: %08X\n", node->WindowClass.ClassId);
p += ImFormatString(p, buf + IM_ARRAYSIZE(buf) - p, "Size: (%.0f, %.0f)\n", node->Size.x, node->Size.y);
p += ImFormatString(p, buf + IM_ARRAYSIZE(buf) - p, "SizeRef: (%.0f, %.0f)\n", node->SizeRef.x, node->SizeRef.y);
int depth = DockNodeGetDepth(node);
overlay_draw_list->AddRect(node->Pos + ImVec2(3, 3) * (float)depth, node->Pos + node->Size - ImVec2(3, 3) * (float)depth, IM_COL32(200, 100, 100, 255));
ImVec2 pos = node->Pos + ImVec2(3, 3) * (float)depth;
overlay_draw_list->AddRectFilled(pos - ImVec2(1, 1), pos + CalcTextSize(buf) + ImVec2(1, 1), IM_COL32(200, 100, 100, 255));
overlay_draw_list->AddText(NULL, 0.0f, pos, IM_COL32(255, 255, 255, 255), buf);
}
}
ImGui::End();
}
#else
void ImGui::ShowMetricsWindow(bool*) { }
#endif
//-----------------------------------------------------------------------------
// Include imgui_user.inl at the end of imgui.cpp to access private data/functions that aren't exposed.
// Prefer just including imgui_internal.h from your code rather than using this define. If a declaration is missing from imgui_internal.h add it or request it on the github.
#ifdef IMGUI_INCLUDE_IMGUI_USER_INL
#include "imgui_user.inl"
#endif
//-----------------------------------------------------------------------------
| [
"amegilham@gmail.com"
] | amegilham@gmail.com |
3bf35fb47961e3be81cffd0e0948461fe6f98d2f | f717e561649d68a2aeb626ced90587fa2b4de176 | /XPostFacto/Application/XPFFatalErrorWindow.cpp | 1c1e930252ef6e6f3a49400d206731d590fd9e5a | [] | no_license | OpenDarwin-CVS/XPostFacto | 9235e78d3302bc3a22911e6d33b40ff3206ccdc3 | 1803de6542e90ac878fd99aa808b15449a124fb4 | refs/heads/master | 2016-09-10T10:16:24.830437 | 2005-08-10T00:01:25 | 2005-08-10T00:01:25 | 19,126,537 | 8 | 2 | null | null | null | null | UTF-8 | C++ | false | false | 2,430 | cpp | /*
Copyright (c) 2002
Other World Computing
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 as the first lines of
each file.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation and/or
other materials provided with the distribution.
3. Redistributions in binary form must retain unchanged the elements of the application
which credit Other World Computing (such as the splash screen and the "about box").
4. Redistributions in binary form must not require payment (or be bundled with items
requiring payment).
This software is provided by Other World Computing ``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 Ryan Rempel or Other World Computing 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 "XPFFatalErrorWindow.h"
//========================================================================================
// CLASS XPFFatalErrorWindow
//========================================================================================
MA_DEFINE_CLASS(XPFFatalErrorWindow);
void
XPFFatalErrorWindow::Close()
{
TWindow::Close ();
if (!gApplication->GetDone ()) gApplication->DoMenuCommand (cQuit);
}
void
XPFFatalErrorWindow::DoEvent(EventNumber eventNumber,
TEventHandler* source,
TEvent* event)
{
TWindow::DoEvent (eventNumber, source, event);
if (eventNumber == mButtonHit) {
gApplication->DoMenuCommand (cQuit);
}
}
void
XPFFatalErrorWindow::SetText (CStr255_AC text)
{
TStaticText *textView = (TStaticText *) FindSubView ('Erro');
textView->SetText (text, true);
}
| [
"ryan"
] | ryan |
28f6b2178cc63a65e7d065974501ed7170d272e6 | a6705707795d8da95d605fb0f1529f41a76f70eb | /CalculatorApp/CalculatorWrap/source/CalculatorWrap.cpp | 3732bf9dc6a76ab077a1b0e64d4815b9541e2ce9 | [] | no_license | KabirSheemul/CPP-CLI-CalculatorApp | 748b04651abc5d3d72d119fe259ed51a07acba69 | 71d619a9e3bfb24902d2bc709af5b3df66b2aa65 | refs/heads/master | 2021-03-25T13:47:32.516920 | 2020-03-16T09:40:50 | 2020-03-16T09:40:50 | 247,624,095 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 768 | cpp | // CalculatorWrap.cpp : main project file.
#include "stdafx.h"
#include "CalculatorWrap.h"
#include "Calculator.h"
#include "iostream"
using namespace System;
CalculatorWrap::CalculatorWrap() {
cppCalculator = new Calculator();
}
String^ CalculatorWrap::add(double first, double second) {
return cppCalculator->add(first, second).ToString();
}
String^ CalculatorWrap::subtract(double minuend, double subtrahend) {
return cppCalculator->subtract(minuend, subtrahend).ToString();
}
String^ CalculatorWrap::multiply(double multiplicand, double multiplier) {
return cppCalculator->multiply(multiplicand, multiplier).ToString();
}
String^ CalculatorWrap::divide(double dividend, double divisor) {
return cppCalculator->divide(dividend, divisor).ToString();
}
| [
"anamul.kabir@enosisbd.com"
] | anamul.kabir@enosisbd.com |
109bb37d800c816dd02eb09e093fe333ae665d70 | 41d4150e01fd696c35f96bda2529683860474cf3 | /teste.cpp | 9df5cad6e53c96ba5071713e304761b27d1634a6 | [] | no_license | ludersGabriel/boids-in-cplusplus | 077b01786aa1a48283334aa178bd6e7b6f50ab61 | dcafb3d29d22aba66b740da05e93a7ac76f388d9 | refs/heads/master | 2022-10-20T16:17:57.119802 | 2020-07-18T02:27:58 | 2020-07-18T02:27:58 | 268,651,535 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 668 | cpp | #include <iostream>
#include "game_manager.h"
#include "boid.h"
int main(int argc, char* argv[]){
const int FPS = 60;
const int frameDelay = 1000/FPS;
Uint32 frameStart;
int frameTime;
game_manager game = game_manager(1800, 1000, "boid sim", false);
flock boids = flock(&game);
while(game.isRunning){
frameStart = SDL_GetTicks();
//main body here
boids.handle_factors();
boids.draw_flock();
boids.move_flock();
frameTime = SDL_GetTicks() - frameStart;
//ends here
if (frameDelay > frameTime)
SDL_Delay(frameDelay - frameTime);
}
return 0;
} | [
"gabeluders@gmail.com"
] | gabeluders@gmail.com |
f231a1fc76bc38eee05a9abdf08d894e35d946b2 | b2ac2cc956c5b7dc8a38e7a44364d0282241ed8e | /branches/japi-w/Sources/MObjectFileImp_elf.cpp | 7e830d2dff0535335bc12b28f64efc001fea2b23 | [
"BSL-1.0"
] | permissive | BackupTheBerlios/japi-svn | b2a9971644a4740d10aef614e09f3fdd49e8460d | f9a5b284e285442b485ef05824ed8e55499c8d61 | refs/heads/master | 2016-09-15T17:14:35.504291 | 2010-12-03T11:39:25 | 2010-12-03T11:39:25 | 40,801,061 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 8,389 | cpp | // Copyright Maarten L. Hekkelman 2006-2008
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#include "MJapi.h"
#include <cstring>
#include <boost/filesystem/fstream.hpp>
#if not (defined(__APPLE__) and defined(__MACH__))
#include "MUtils.h"
#include "MObjectFileImp_elf.h"
#include "MError.h"
using namespace std;
//template
//<
// class SWAPPER,
// typename Elf_Ehdr,
// typename Elf_Shdr
//>
//void MELFObjectFileImp::Read(
// Elf_Ehdr& eh,
// istream& inData)
//{
//}
template
<
MTargetCPU CPU,
typename traits
>
void MELFObjectFileImp<CPU,traits>::Read(
const fs::path& inFile)
{
fs::ifstream file(inFile, ios::binary);
if (not file.is_open())
THROW(("Failed to open object file"));
swapper swap;
char* stringtable = nil;
uint32 stringtablesize = 0;
try
{
Elf_Ehdr eh;
file.read((char*)&eh, sizeof(eh));
file.seekg(swap(eh.e_shoff), ios::beg);
for (uint32 section = 0; section < swap(eh.e_shnum); ++section)
{
Elf_Shdr sh;
file.read((char*)&sh, sizeof(sh));
if (swap(sh.sh_type) == SHT_STRTAB)
{
stringtablesize = swap(sh.sh_size);
stringtable = new char[stringtablesize];
file.seekg(swap(sh.sh_offset), ios::beg);
file.read(stringtable, stringtablesize);
break;
}
}
if (stringtable != nil)
{
file.seekg(swap(eh.e_shoff), ios::beg);
for (uint32 section = 0; section < swap(eh.e_shnum); ++section)
{
Elf_Shdr sh;
file.read((char*)&sh, sizeof(sh));
if (strcmp(stringtable + swap(sh.sh_name), ".text") == 0)
mTextSize += swap(sh.sh_size);
else if (strcmp(stringtable + swap(sh.sh_name), ".data") == 0)
mDataSize += swap(sh.sh_size);
}
}
}
catch (...) {}
if (stringtable != nil)
delete[] stringtable;
}
uint32 WriteDataAligned(
ofstream& inStream,
const void* inData,
uint32 inSize,
uint32 inAlignment = 1)
{
inStream.write(reinterpret_cast<const char*>(inData), inSize);
if (inAlignment > 1)
{
while ((inStream.tellp() % inAlignment) != 0)
inStream.put('\0');
}
return inStream.tellp();
}
enum {
kNullSection,
kTextSection,
kDataSection,
kBssSection,
kShStrtabSection,
kSymtabSection,
kStrtabSection,
kSectionCount
};
enum {
kNullSymbol,
kTextSectionSymbol,
kDataSectionSymbol,
kBssSectionSymbol,
kGlobalSymbol,
kSymbolCount
};
template
<
MTargetCPU CPU,
typename traits
>
void MELFObjectFileImp<CPU, traits>::Write(
const fs::path& inFile)
{
fs::ofstream f(inFile, ios::binary | ios::trunc);
if (not f.is_open())
THROW(("Failed to open object file for writing"));
Elf_Ehdr eh = {
// e_ident
{ ELFMAG0, ELFMAG1, ELFMAG2, ELFMAG3,
traits::ElfClass, traits::ElfData, EV_CURRENT },
ET_REL, // e_type
traits::ElfMachine, // e_machine
EV_CURRENT, // e_version
0, // e_entry
0, // e_phoff
0, // e_shoff
0, // e_flags
sizeof(Elf_Ehdr), // e_ehsize
0, // e_phentsize
0, // e_phnum
sizeof(Elf_Shdr), // e_shentsize
kSectionCount, // e_shnum
kShStrtabSection // e_shstrndx
};
uint32 data_offset = WriteDataAligned(f, &eh, sizeof(eh), 16);
string strtab;
AddNameToNameTable(strtab, ""); // null name
Elf_Sym sym = {};
vector<Elf_Sym> syms;
// kNullSymbol
syms.push_back(sym);
// text section symbol
sym.st_info = ELF32_ST_INFO(STB_LOCAL, STT_SECTION);
sym.st_shndx = kTextSection;
syms.push_back(sym);
// data section symbol
sym.st_info = ELF32_ST_INFO(STB_LOCAL, STT_SECTION);
sym.st_shndx = kDataSection;
syms.push_back(sym);
// bss section symbol
sym.st_info = ELF32_ST_INFO(STB_LOCAL, STT_SECTION);
sym.st_shndx = kBssSection;
syms.push_back(sym);
uint32 sym_offset = data_offset;
for (MGlobals::iterator g = mGlobals.begin(); g != mGlobals.end(); ++g)
{
sym.st_name = AddNameToNameTable(strtab, g->name);
sym.st_value = sym_offset - data_offset;
sym.st_size = g->data.length();
sym.st_info = ELF32_ST_INFO(STB_GLOBAL, STT_OBJECT);
sym.st_shndx = kDataSection;
syms.push_back(sym);
sym_offset = WriteDataAligned(f, g->data.c_str(), g->data.length(), 8);
}
uint32 data_size = sym_offset;
uint32 symtab_off = sym_offset;
assert((sizeof(Elf_Sym) % 8) == 0);
uint32 symtab_size = syms.size() * sizeof(sym);
uint32 strtab_off = WriteDataAligned(f, &syms[0], symtab_size, 8);
uint32 shstrtab_off = WriteDataAligned(f, strtab.c_str(), strtab.length(), 8);
string shstrtab;
(void)AddNameToNameTable(shstrtab, ""); // null name
(void)AddNameToNameTable(shstrtab, ".text");
(void)AddNameToNameTable(shstrtab, ".rsrc_data");
(void)AddNameToNameTable(shstrtab, ".bss");
(void)AddNameToNameTable(shstrtab, ".shstrtab");
(void)AddNameToNameTable(shstrtab, ".symtab");
(void)AddNameToNameTable(shstrtab, ".strtab");
eh.e_shoff = WriteDataAligned(f, shstrtab.c_str(), shstrtab.length(), 16);
Elf_Shdr sh[kSectionCount] = {
{ // kNullSection
},
{ // kTextSection
// sh_name
AddNameToNameTable(shstrtab, ".text"),
SHT_PROGBITS, // sh_type
// sh_flags
SHF_ALLOC|SHF_EXECINSTR,
0, // sh_addr
data_offset, // sh_offset
0, // sh_size
0, // sh_link
0, // sh_info
4, // sh_addralign
0 // sh_entsize
},
{ // kDataSection
// sh_name
AddNameToNameTable(shstrtab, ".rsrc_data"),
SHT_PROGBITS, // sh_type
// sh_flags
SHF_ALLOC|SHF_WRITE,
0, // sh_addr
data_offset, // sh_offset
data_size, // sh_size
0, // sh_link
0, // sh_info
4, // sh_addralign
0 // sh_entsize
},
{ // kBssSection
// sh_name
AddNameToNameTable(shstrtab, ".bss"),
SHT_NOBITS, // sh_type
// sh_flags
SHF_ALLOC|SHF_WRITE,
0, // sh_addr
eh.e_shoff, // sh_offset
0, // sh_size
0, // sh_link
0, // sh_info
4, // sh_addralign
0 // sh_entsize
},
{ // kShStrtabSection
// sh_name
AddNameToNameTable(shstrtab, ".shstrtab"),
SHT_STRTAB, // sh_type
0, // sh_flags
0, // sh_addr
shstrtab_off, // sh_offset
shstrtab.length(),// sh_size
0, // sh_link
0, // sh_info
1, // sh_addralign
0 // sh_entsize
},
{ // kSymtabSection
// sh_name
AddNameToNameTable(shstrtab, ".symtab"),
SHT_SYMTAB, // sh_type
// sh_flags
0,
0, // sh_addr
symtab_off, // sh_offset
symtab_size, // sh_size
6, // sh_link
kGlobalSymbol, // sh_info
8, // sh_addralign
sizeof(Elf_Sym) // sh_entsize
},
{ // kStrtabSection
// sh_name
AddNameToNameTable(shstrtab, ".strtab"),
SHT_STRTAB, // sh_type
// sh_flags
0,
0, // sh_addr
strtab_off, // sh_offset
strtab.length(),// sh_size
0, // sh_link
0, // sh_info
1, // sh_addralign
0 // sh_entsize
},
};
WriteDataAligned(f, sh, sizeof(sh), 1);
f.flush();
f.seekp(0);
WriteDataAligned(f, &eh, sizeof(eh));
}
MObjectFileImp* CreateELFObjectFileImp(
MTargetCPU inTarget)
{
MObjectFileImp* result = nil;
switch (inTarget)
{
case eCPU_386:
result = new MELFObjectFileImp<eCPU_386>();
break;
case eCPU_x86_64:
result = new MELFObjectFileImp<eCPU_x86_64>();
break;
case eCPU_PowerPC_32:
result = new MELFObjectFileImp<eCPU_PowerPC_32>();
break;
case eCPU_PowerPC_64:
result = new MELFObjectFileImp<eCPU_PowerPC_64>();
break;
default:
THROW(("Unsupported object file"));
}
return result;
}
MObjectFileImp* CreateELFObjectFileImp(
const fs::path& inFile)
{
MTargetCPU target = eCPU_Unknown;
fs::ifstream file(inFile, ios::binary);
if (not file.is_open())
THROW(("Could not open object file"));
char ident[EI_NIDENT];
file.read(ident, EI_NIDENT);
if (strncmp(ident, ELFMAG, SELFMAG) != 0 or
(ident[EI_DATA] != ELFDATA2LSB and ident[EI_DATA] != ELFDATA2MSB) or
(ident[EI_CLASS] != ELFCLASS32 and ident[EI_CLASS] != ELFCLASS64))
{
THROW(("File is not a supported object file"));
}
if (ident[EI_DATA] == ELFDATA2LSB)
{
if (ident[EI_CLASS] == ELFCLASS64)
target = eCPU_x86_64;
else
target = eCPU_386;
}
else
{
if (ident[EI_CLASS] == ELFCLASS32)
target = eCPU_PowerPC_32;
else
target = eCPU_PowerPC_64;
}
return CreateELFObjectFileImp(target);
}
#endif
| [
"hekkel@6969af58-1542-49b8-b3af-dcaebf5f4018"
] | hekkel@6969af58-1542-49b8-b3af-dcaebf5f4018 |
011ca6754f7a28afb56952f15eb6674816e1a11a | 2d03b06f70cf1e57c75ea08a6f1e9a795bae3999 | /random.cpp | e70475ab6cb22d6961b36515222f6ca4fe5ff2b7 | [] | no_license | mayank3810/cpp-learning | a90b49ce6bfdac432ff9425ab5b68b234e971dae | 090078894541b4923bf86e62793f434b869f9c56 | refs/heads/main | 2023-06-26T11:50:34.056162 | 2021-08-01T12:23:20 | 2021-08-01T12:23:20 | 384,875,446 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 167 | cpp | #include<iostream>
#include <stdlib.h>
#include<time.h>
using namespace std;
int main(){
int i;
srand(time(NULL));
cout<<rand()%10 +1;
return 0;
} | [
"mayankgautam2105@gmail.com"
] | mayankgautam2105@gmail.com |
0b9982f43ec7c618bb49fb3bd1d85cff80b5c0c6 | 6071593e53e715004c39a5656b162b8d492afdd3 | /CppDesignPattern/Iterator/Iterator.cpp | 202975ad16028781358a4e210835f0d75608fa99 | [] | no_license | crablet/Toys | 27d13a04375ffbbd854c19505f27a7095398d6c1 | 9fe3560332184173d93fcb7082166b44b82009dc | refs/heads/master | 2021-06-17T13:24:54.015618 | 2019-10-28T17:12:25 | 2019-10-28T17:12:25 | 105,600,197 | 1 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 913 | cpp | #include <iostream>
#include <string>
#include <vector>
struct Fruit
{
Fruit(const std::string &Str)
: Name(Str)
{
}
auto GetName() const
{
return Name;
}
bool operator==(const Fruit &rhs) const noexcept
{
return Name == rhs.GetName();
}
private:
std::string Name;
};
class FruitDish
{
public:
FruitDish() = default;
void AddFruit(const Fruit &F)
{
Dish.push_back(F);
}
void RemoveFruit(const Fruit &F)
{
if (auto Iter = std::find(Dish.begin(), Dish.end(), F); Iter != Dish.end())
{
Dish.erase(Iter);
}
}
auto begin()
{
return Dish.begin();
}
auto end()
{
return Dish.end();
}
private:
std::vector<Fruit> Dish;
};
int main()
{
FruitDish FruitDish_;
FruitDish_.AddFruit(Fruit("Apple"));
FruitDish_.AddFruit(Fruit("Banana"));
FruitDish_.AddFruit(Fruit("Cat"));
for (const auto &r : FruitDish_)
{
std::cout << r.GetName() << std::endl;
}
return 0;
} | [
"love4uandgzfc@gmail.com"
] | love4uandgzfc@gmail.com |
3948e83c03ae68d7c55b419b5f1412a3e99c6bcf | 600df3590cce1fe49b9a96e9ca5b5242884a2a70 | /chrome/browser/extensions/api/dial/dial_api.cc | 6f43b17aaf0ade8c3e4e533e98cdbe6a0cfa6358 | [
"BSD-3-Clause"
] | permissive | metux/chromium-suckless | efd087ba4f4070a6caac5bfbfb0f7a4e2f3c438a | 72a05af97787001756bae2511b7985e61498c965 | refs/heads/orig | 2022-12-04T23:53:58.681218 | 2017-04-30T10:59:06 | 2017-04-30T23:35:58 | 89,884,931 | 5 | 3 | BSD-3-Clause | 2022-11-23T20:52:53 | 2017-05-01T00:09:08 | null | UTF-8 | C++ | false | false | 5,588 | cc | // Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/extensions/api/dial/dial_api.h"
#include <stddef.h>
#include <utility>
#include <vector>
#include "base/memory/ptr_util.h"
#include "base/time/time.h"
#include "chrome/browser/extensions/api/dial/dial_api_factory.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/common/extensions/api/dial.h"
#include "content/public/browser/browser_thread.h"
#include "extensions/browser/event_router.h"
#include "extensions/browser/extension_system.h"
using base::TimeDelta;
using content::BrowserThread;
namespace {
// How often to poll for devices.
const int kDialRefreshIntervalSecs = 120;
// We prune a device if it does not respond after this time.
const int kDialExpirationSecs = 240;
// The maximum number of devices retained at once in the registry.
const size_t kDialMaxDevices = 256;
} // namespace
namespace extensions {
namespace dial = api::dial;
DialAPI::DialAPI(Profile* profile)
: RefcountedKeyedService(
BrowserThread::GetTaskRunnerForThread(BrowserThread::IO)),
profile_(profile) {
EventRouter::Get(profile)
->RegisterObserver(this, dial::OnDeviceList::kEventName);
}
DialAPI::~DialAPI() {}
DialRegistry* DialAPI::dial_registry() {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
if (!dial_registry_.get()) {
dial_registry_.reset(new DialRegistry(this,
TimeDelta::FromSeconds(kDialRefreshIntervalSecs),
TimeDelta::FromSeconds(kDialExpirationSecs),
kDialMaxDevices));
}
return dial_registry_.get();
}
void DialAPI::OnListenerAdded(const EventListenerInfo& details) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE,
base::Bind(&DialAPI::NotifyListenerAddedOnIOThread, this));
}
void DialAPI::OnListenerRemoved(const EventListenerInfo& details) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE,
base::Bind(&DialAPI::NotifyListenerRemovedOnIOThread, this));
}
void DialAPI::NotifyListenerAddedOnIOThread() {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
VLOG(2) << "DIAL device event listener added.";
dial_registry()->OnListenerAdded();
}
void DialAPI::NotifyListenerRemovedOnIOThread() {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
VLOG(2) << "DIAL device event listener removed";
dial_registry()->OnListenerRemoved();
}
void DialAPI::OnDialDeviceEvent(const DialRegistry::DeviceList& devices) {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
base::Bind(&DialAPI::SendEventOnUIThread, this, devices));
}
void DialAPI::OnDialError(const DialRegistry::DialErrorCode code) {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
base::Bind(&DialAPI::SendErrorOnUIThread, this, code));
}
void DialAPI::SendEventOnUIThread(const DialRegistry::DeviceList& devices) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
std::vector<api::dial::DialDevice> args;
for (const DialDeviceData& device : devices) {
api::dial::DialDevice api_device;
device.FillDialDevice(&api_device);
args.push_back(std::move(api_device));
}
std::unique_ptr<base::ListValue> results =
api::dial::OnDeviceList::Create(args);
std::unique_ptr<Event> event(new Event(events::DIAL_ON_DEVICE_LIST,
dial::OnDeviceList::kEventName,
std::move(results)));
EventRouter::Get(profile_)->BroadcastEvent(std::move(event));
}
void DialAPI::SendErrorOnUIThread(const DialRegistry::DialErrorCode code) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
api::dial::DialError dial_error;
switch (code) {
case DialRegistry::DIAL_NO_LISTENERS:
dial_error.code = api::dial::DIAL_ERROR_CODE_NO_LISTENERS;
break;
case DialRegistry::DIAL_NO_INTERFACES:
dial_error.code = api::dial::DIAL_ERROR_CODE_NO_VALID_NETWORK_INTERFACES;
break;
case DialRegistry::DIAL_CELLULAR_NETWORK:
dial_error.code = api::dial::DIAL_ERROR_CODE_CELLULAR_NETWORK;
break;
case DialRegistry::DIAL_NETWORK_DISCONNECTED:
dial_error.code = api::dial::DIAL_ERROR_CODE_NETWORK_DISCONNECTED;
break;
case DialRegistry::DIAL_SOCKET_ERROR:
dial_error.code = api::dial::DIAL_ERROR_CODE_SOCKET_ERROR;
break;
default:
dial_error.code = api::dial::DIAL_ERROR_CODE_UNKNOWN;
break;
}
std::unique_ptr<base::ListValue> results =
api::dial::OnError::Create(dial_error);
std::unique_ptr<Event> event(new Event(
events::DIAL_ON_ERROR, dial::OnError::kEventName, std::move(results)));
EventRouter::Get(profile_)->BroadcastEvent(std::move(event));
}
void DialAPI::ShutdownOnUIThread() {}
namespace api {
DialDiscoverNowFunction::DialDiscoverNowFunction()
: dial_(NULL), result_(false) {
}
bool DialDiscoverNowFunction::Prepare() {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
DCHECK(browser_context());
dial_ = DialAPIFactory::GetForBrowserContext(browser_context()).get();
return true;
}
void DialDiscoverNowFunction::Work() {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
result_ = dial_->dial_registry()->DiscoverNow();
}
bool DialDiscoverNowFunction::Respond() {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
SetResult(base::MakeUnique<base::FundamentalValue>(result_));
return true;
}
} // namespace api
} // namespace extensions
| [
"enrico.weigelt@gr13.net"
] | enrico.weigelt@gr13.net |
823388174b2d32304b749eebf3dd2e61a0e298e2 | 2aa72bd467ed3ddcff81cfee563b162671fe53a9 | /Lab07/RotateRandomAxis/main.cpp | 04753cdb0f78dcaa3f6a6d59682d292d978d4dbc | [] | no_license | jonghyunChae/2016OgrePractice | de8f19977ed72ff6a35642f86263a62307008c87 | 7356e5ae20066b7317b1b9a774b738e73dcf1e6f | refs/heads/master | 2021-01-01T05:28:13.278460 | 2016-05-25T02:57:52 | 2016-05-25T02:57:52 | 56,664,581 | 0 | 0 | null | null | null | null | UHC | C++ | false | false | 6,924 | cpp | #if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
#define WIN32_LEAN_AND_MEAN
#include "windows.h"
#endif
#include <Ogre.h>
#include <OIS/OIS.h>
using namespace Ogre;
#define RADIAN(x) (x * (3.141592 / 180.0f))
class ESCListener : public FrameListener {
OIS::Keyboard *mKeyboard;
public:
ESCListener(OIS::Keyboard *keyboard) : mKeyboard(keyboard) {}
bool frameStarted(const FrameEvent &evt)
{
mKeyboard->capture();
return !mKeyboard->isKeyDown(OIS::KC_ESCAPE);
}
};
class MainListener : public FrameListener {
OIS::Keyboard *mKeyboard;
Root* mRoot;
SceneNode *mProfessorNode, *mFishNode;
public:
MainListener(Root* root, OIS::Keyboard *keyboard) : mKeyboard(keyboard), mRoot(root)
{
mProfessorNode = mRoot->getSceneManager("main")->getSceneNode("Professor");
mFishNode = mRoot->getSceneManager("main")->getSceneNode("Fish");
mProfessorNode->setInheritOrientation(false);
mFishNode->setInheritOrientation(false);
}
bool frameStarted(const FrameEvent &evt)
{
// Fill Here ----------------------------------------------
static bool bTurn = false;
static float fRotAngle = 0.0f;
static float fDir = 1.0f;
Vector3 vecPos = mProfessorNode->getPosition();
if (bTurn)
{
mProfessorNode->yaw(Degree(1));
if (++fRotAngle >= 180.f)
{
bTurn = false;
mProfessorNode->translate(Vector3(0, 0, 1) * fDir);
}
}
else if (false == bTurn)
{
if (abs(vecPos.z) >= 250)
{
bTurn = true;
fDir *= -1;
fRotAngle = 0.0f;
}
else
mProfessorNode->translate(Vector3(0, 0, 1) * fDir);
}
vecPos = mProfessorNode->getPosition();
static float fFishAngle = 0.0f;
mFishNode->yaw(Degree(1)/*Ogre::Node::TS_WORLD*/);
fFishAngle++;
vecPos = mProfessorNode->getPosition();
mFishNode->setPosition(
cosf(RADIAN(fFishAngle)) * 100.f + vecPos.x,
0.0f,
sinf(RADIAN(fFishAngle)) * 100.f + vecPos.z);
//-----------------------------------------------------------
return true;
}
};
class LectureApp {
Root* mRoot;
RenderWindow* mWindow;
SceneManager* mSceneMgr;
Camera* mCamera;
Viewport* mViewport;
OIS::Keyboard* mKeyboard;
OIS::InputManager *mInputManager;
MainListener* mMainListener;
ESCListener* mESCListener;
public:
LectureApp() {}
~LectureApp() {}
void go(void)
{
// OGRE의 메인 루트 오브젝트 생성
#if !defined(_DEBUG)
mRoot = new Root("plugins.cfg", "ogre.cfg", "ogre.log");
#else
mRoot = new Root("plugins_d.cfg", "ogre.cfg", "ogre.log");
#endif
// 초기 시작의 컨피규레이션 설정 - ogre.cfg 이용
if (!mRoot->restoreConfig()) {
if (!mRoot->showConfigDialog()) return;
}
mWindow = mRoot->initialise(true, "Rotate on Random Axis : Copyleft by Dae-Hyun Lee");
// ESC key를 눌렀을 경우, 오우거 메인 렌더링 루프의 탈출을 처리
size_t windowHnd = 0;
std::ostringstream windowHndStr;
OIS::ParamList pl;
mWindow->getCustomAttribute("WINDOW", &windowHnd);
windowHndStr << windowHnd;
pl.insert(std::make_pair(std::string("WINDOW"), windowHndStr.str()));
mInputManager = OIS::InputManager::createInputSystem(pl);
mKeyboard = static_cast<OIS::Keyboard*>(mInputManager->createInputObject(OIS::OISKeyboard, false));
mSceneMgr = mRoot->createSceneManager(ST_GENERIC, "main");
mCamera = mSceneMgr->createCamera("main");
mCamera->setPosition(0.0f, 100.0f, 700.0f);
mCamera->lookAt(0.0f, 100.0f, 0.0f);
mCamera->setNearClipDistance(5.0f);
mViewport = mWindow->addViewport(mCamera);
mViewport->setBackgroundColour(ColourValue(0.0f,0.0f,0.5f));
mCamera->setAspectRatio(Real(mViewport->getActualWidth()) / Real(mViewport->getActualHeight()));
ResourceGroupManager::getSingleton().addResourceLocation("resource.zip", "Zip");
ResourceGroupManager::getSingleton().addResourceLocation("fish.zip", "Zip");
ResourceGroupManager::getSingleton().initialiseAllResourceGroups();
mSceneMgr->setAmbientLight(ColourValue(1.0f, 1.0f, 1.0f));
// 좌표축 표시
Ogre::Entity* mAxesEntity = mSceneMgr->createEntity("Axes", "axes.mesh");
mSceneMgr->getRootSceneNode()->createChildSceneNode("AxesNode",Ogre::Vector3(0,0,0))->attachObject(mAxesEntity);
mSceneMgr->getSceneNode("AxesNode")->setScale(5, 5, 5);
_drawGridPlane();
Entity* entity1 = mSceneMgr->createEntity("Professor", "DustinBody.mesh");
SceneNode* node1 = mSceneMgr->getRootSceneNode()->createChildSceneNode("Professor", Vector3(0.0f, 0.0f, 0.0f));
node1->attachObject(entity1);
Entity* entity2 = mSceneMgr->createEntity("Fish", "fish.mesh");
SceneNode* node2 = mSceneMgr->getRootSceneNode()->createChildSceneNode("Fish", Vector3(0.0f, 0.0f, 0.0f));
node2->attachObject(entity2);
node2->scale(10, 10, 10);
mESCListener =new ESCListener(mKeyboard);
mRoot->addFrameListener(mESCListener);
mMainListener = new MainListener(mRoot, mKeyboard);
mRoot->addFrameListener(mMainListener);
mRoot->startRendering();
mInputManager->destroyInputObject(mKeyboard);
OIS::InputManager::destroyInputSystem(mInputManager);
delete mRoot;
}
private:
void _drawGridPlane(void)
{
Ogre::ManualObject* gridPlane = mSceneMgr->createManualObject("GridPlane");
Ogre::SceneNode* gridPlaneNode = mSceneMgr->getRootSceneNode()->createChildSceneNode("GridPlaneNode");
Ogre::MaterialPtr gridPlaneMaterial = Ogre::MaterialManager::getSingleton().create("GridPlanMaterial","General");
gridPlaneMaterial->setReceiveShadows(false);
gridPlaneMaterial->getTechnique(0)->setLightingEnabled(true);
gridPlaneMaterial->getTechnique(0)->getPass(0)->setDiffuse(1,1,1,0);
gridPlaneMaterial->getTechnique(0)->getPass(0)->setAmbient(1,1,1);
gridPlaneMaterial->getTechnique(0)->getPass(0)->setSelfIllumination(1,1,1);
gridPlane->begin("GridPlaneMaterial", Ogre::RenderOperation::OT_LINE_LIST);
for(int i=0; i<21; i++)
{
gridPlane->position(-500.0f, 0.0f, 500.0f-i*50);
gridPlane->position(500.0f, 0.0f, 500.0f-i*50);
gridPlane->position(-500.f+i*50, 0.f, 500.0f);
gridPlane->position(-500.f+i*50, 0.f, -500.f);
}
gridPlane->end();
gridPlaneNode->attachObject(gridPlane);
}
};
#ifdef __cplusplus
extern "C" {
#endif
#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
INT WINAPI WinMain( HINSTANCE hInst, HINSTANCE, LPSTR strCmdLine, INT )
#else
int main(int argc, char *argv[])
#endif
{
LectureApp app;
try {
app.go();
} catch( Ogre::Exception& e ) {
#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
MessageBox( NULL, e.getFullDescription().c_str(), "An exception has occured!", MB_OK | MB_ICONERROR | MB_TASKMODAL);
#else
std::cerr << "An exception has occured: " <<
e.getFullDescription().c_str() << std::endl;
#endif
}
return 0;
}
#ifdef __cplusplus
}
#endif
| [
"jongsys21@naver.com"
] | jongsys21@naver.com |
985c92ed2bf0e22379b8fd4ab2ecd5a90edcfaaa | bbcda48854d6890ad029d5973e011d4784d248d2 | /trunk/win/BumpTop Settings/include/wxWidgets/wx/mac/classic/notebook.h | 4f8bb26bb18e0f0de25d0e9b48145ac00eff159b | [
"LGPL-2.0-or-later",
"WxWindows-exception-3.1",
"Apache-2.0",
"LicenseRef-scancode-public-domain"
] | permissive | dyzmapl/BumpTop | 9c396f876e6a9ace1099b3b32e45612a388943ff | 1329ea41411c7368516b942d19add694af3d602f | refs/heads/master | 2020-12-20T22:42:55.100473 | 2020-01-25T21:00:08 | 2020-01-25T21:00:08 | 236,229,087 | 0 | 0 | Apache-2.0 | 2020-01-25T20:58:59 | 2020-01-25T20:58:58 | null | UTF-8 | C++ | false | false | 4,388 | h | /////////////////////////////////////////////////////////////////////////////
// Name: notebook.h
// Purpose: MSW/GTK compatible notebook (a.k.a. property sheet)
// Author: Stefan Csomor
// Modified by:
// RCS-ID: $Id: notebook.h 41020 2006-09-05 20:47:48Z VZ $
// Copyright: (c) Stefan Csomor
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_NOTEBOOK_H_
#define _WX_NOTEBOOK_H_
// ----------------------------------------------------------------------------
// headers
// ----------------------------------------------------------------------------
#include "wx/event.h"
// ----------------------------------------------------------------------------
// types
// ----------------------------------------------------------------------------
// fwd declarations
class WXDLLEXPORT wxImageList;
class WXDLLEXPORT wxWindow;
// ----------------------------------------------------------------------------
// wxNotebook
// ----------------------------------------------------------------------------
class wxNotebook : public wxNotebookBase
{
public:
// ctors
// -----
// default for dynamic class
wxNotebook();
// the same arguments as for wxControl (@@@ any special styles?)
wxNotebook(wxWindow *parent,
wxWindowID id,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = 0,
const wxString& name = wxNotebookNameStr);
// Create() function
bool Create(wxWindow *parent,
wxWindowID id,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = 0,
const wxString& name = wxNotebookNameStr);
// dtor
virtual ~wxNotebook();
// accessors
// ---------
// set the currently selected page, return the index of the previously
// selected one (or -1 on error)
// NB: this function will _not_ generate wxEVT_NOTEBOOK_PAGE_xxx events
int SetSelection(size_t nPage);
// get the currently selected page
int GetSelection() const { return m_nSelection; }
// set/get the title of a page
bool SetPageText(size_t nPage, const wxString& strText);
wxString GetPageText(size_t nPage) const;
// sets/returns item's image index in the current image list
int GetPageImage(size_t nPage) const;
bool SetPageImage(size_t nPage, int nImage);
// control the appearance of the notebook pages
// set the size (the same for all pages)
virtual void SetPageSize(const wxSize& size);
// set the padding between tabs (in pixels)
virtual void SetPadding(const wxSize& padding);
// sets the size of the tabs (assumes all tabs are the same size)
virtual void SetTabSize(const wxSize& sz);
// calculate size for wxNotebookSizer
wxSize CalcSizeFromPage(const wxSize& sizePage) const;
wxRect GetPageRect() const ;
// operations
// ----------
// remove all pages
bool DeleteAllPages();
// the same as AddPage(), but adds it at the specified position
bool InsertPage(size_t nPage,
wxNotebookPage *pPage,
const wxString& strText,
bool bSelect = false,
int imageId = -1);
// callbacks
// ---------
void OnSize(wxSizeEvent& event);
void OnSelChange(wxNotebookEvent& event);
void OnSetFocus(wxFocusEvent& event);
void OnNavigationKey(wxNavigationKeyEvent& event);
void OnMouse(wxMouseEvent &event);
// implementation
// --------------
#if wxUSE_CONSTRAINTS
virtual void SetConstraintSizes(bool recurse = true);
virtual bool DoPhase(int nPhase);
#endif
// base class virtuals
// -------------------
virtual void Command(wxCommandEvent& event);
protected:
virtual wxSize DoGetBestSize() const ;
virtual wxNotebookPage *DoRemovePage(size_t page) ;
virtual void MacHandleControlClick( WXWidget control , wxInt16 controlpart , bool mouseStillDown ) ;
// common part of all ctors
void Init();
// helper functions
void ChangePage(int nOldSel, int nSel); // change pages
void MacSetupTabs();
// the icon indices
wxArrayInt m_images;
int m_nSelection; // the current selection (-1 if none)
DECLARE_DYNAMIC_CLASS(wxNotebook)
DECLARE_EVENT_TABLE()
};
#endif // _WX_NOTEBOOK_H_
| [
"anandx@google.com"
] | anandx@google.com |
6b4498e82929b9af8d734ac665672e9cda99818a | 11aa0e68e3fba98cee8a23a2fe0e562d87955b6a | /ST2/1_this_call10.cpp | 35c7b6723ec97bacce5437975b72d89776bb8e91 | [] | no_license | hjh4638/C-11 | b97a579a302f0c919bbe4b332b828afcf6d916ad | f7242f903561811b8b69a86637a8a183a66d848f | refs/heads/master | 2021-01-13T01:22:52.586790 | 2015-09-03T06:22:12 | 2015-09-03T06:22:12 | 41,107,420 | 0 | 0 | null | null | null | null | UHC | C++ | false | false | 722 | cpp | #include <iostream>
using namespace std;
//모든 함수의 주소를 담을 수 있는 도구
// C, C++ : 문법적으로는 없다.
//C++11:function<> 모든 함수의 주소를 담을 수 있다.
class Dialog
{
public:
void Close()
{
cout << "Dialog Closed" << endl;
}
};
void foo(){ cout << "foo" << endl; }
void goo(int a) { cout << "goo : " << a << endl; }
void hoo(int a, int b){ cout << "hoo : " << a << b << endl; }
#include <functional>
int main(){
function<void()> f = &foo;
f();
f = bind(&goo, 5);
f();//goo(5)
Dialog dlg;
f = bind(&Dialog::Close, &dlg);
f();
f = bind(&hoo, 1, 2);
f();
/*f = &goo;
f();
f = &hoo;
f();
f = &Dialog::Close;
f();*/
} | [
"Juni@hamjunhyeogui-MacBook-Air.local"
] | Juni@hamjunhyeogui-MacBook-Air.local |
1f391dcfa0911f3499a2595e83a5b24696ae7912 | 9e72d7da45a1b06c03c38ca163c508ffa2c6e28c | /Sensorama/Pods/Realm/include/core/realm/util/buffer_stream.hpp | 9fbe462cffd3dea57c78b19360985b105d11168c | [
"BSD-2-Clause",
"LicenseRef-scancode-free-unknown",
"Apache-2.0",
"LicenseRef-scancode-commercial-license",
"LicenseRef-scancode-proprietary-license",
"LicenseRef-scancode-generic-export-compliance"
] | permissive | wkoszek/sensorama-ios | d61416f44e36ac823358d24753d05f8aac238863 | 99fb407e5602cccbb56c50556e60cb52ae88e84e | refs/heads/master | 2022-10-31T16:11:51.083175 | 2022-10-06T07:13:15 | 2022-10-06T07:13:15 | 49,854,036 | 10 | 1 | BSD-2-Clause | 2022-10-06T07:13:16 | 2016-01-18T05:24:31 | Objective-C | UTF-8 | C++ | false | false | 4,064 | hpp | /*************************************************************************
*
* REALM CONFIDENTIAL
* __________________
*
* [2011] - [2016] Realm Inc
* All Rights Reserved.
*
* NOTICE: All information contained herein is, and remains
* the property of Realm Incorporated and its suppliers,
* if any. The intellectual and technical concepts contained
* herein are proprietary to Realm Incorporated
* and its suppliers and may be covered by U.S. and Foreign Patents,
* patents in process, and are protected by trade secret or copyright law.
* Dissemination of this information or reproduction of this material
* is strictly forbidden unless prior written permission is obtained
* from Realm Incorporated.
*
**************************************************************************/
#ifndef REALM_UTIL_BUFFER_STREAM_HPP
#define REALM_UTIL_BUFFER_STREAM_HPP
#include <sstream>
namespace realm {
namespace util {
template<class C, class T = std::char_traits<C>, class A = std::allocator<C> >
class BasicResettableExpandableOutputStreambuf: public std::basic_stringbuf<C,T,A> {
public:
using char_type = typename std::basic_stringbuf<C,T,A>::char_type;
/// Reset current writing position (std::basic_streambuf::pptr()) to the
/// beginning of the output buffer without reallocating buffer memory.
void reset();
/// Get a pointer to the beginning of the output buffer
/// (std::basic_streambuf::pbase()). Note that this will change as the
/// buffer is reallocated.
char_type* data() noexcept;
/// Get the number of bytes written to the output buffer since the creation
/// of the stream buffer, or since the last invocation of reset()
/// (std::basic_streambuf::pptr() - std::basic_streambuf::pbase()).
std::streamsize size() const noexcept;
};
template<class C, class T = std::char_traits<C>, class A = std::allocator<C> >
class BasicResettableExpandableBufferOutputStream: public std::basic_ostream<C,T> {
public:
using char_type = typename std::basic_ostream<C,T>::char_type;
BasicResettableExpandableBufferOutputStream();
/// Calls BasicResettableExpandableOutputStreambuf::reset().
void reset() noexcept;
/// Calls BasicResettableExpandableOutputStreambuf::data().
char_type* data() noexcept;
/// Calls BasicResettableExpandableOutputStreambuf::size().
std::streamsize size() const noexcept;
private:
BasicResettableExpandableOutputStreambuf<C,T,A> m_streambuf;
};
using ResettableExpandableBufferOutputStream = BasicResettableExpandableBufferOutputStream<char>;
// Implementation
template<class C, class T, class A>
inline void BasicResettableExpandableOutputStreambuf<C,T,A>::reset()
{
char_type* pbeg = this->pbase();
char_type* pend = this->epptr();
this->setp(pbeg, pend);
}
template<class C, class T, class A>
inline typename BasicResettableExpandableOutputStreambuf<C,T,A>::char_type*
BasicResettableExpandableOutputStreambuf<C,T,A>::data() noexcept
{
return this->pbase();
}
template<class C, class T, class A>
inline std::streamsize BasicResettableExpandableOutputStreambuf<C,T,A>::size() const noexcept
{
std::streamsize s = std::streamsize(this->pptr() - this->pbase());
return s;
}
template<class C, class T, class A>
inline BasicResettableExpandableBufferOutputStream<C,T,A>::
BasicResettableExpandableBufferOutputStream():
std::basic_ostream<C,T>(&m_streambuf) // Throws
{
}
template<class C, class T, class A>
inline void BasicResettableExpandableBufferOutputStream<C,T,A>::reset() noexcept
{
m_streambuf.reset();
}
template<class C, class T, class A>
inline typename BasicResettableExpandableBufferOutputStream<C,T,A>::char_type*
BasicResettableExpandableBufferOutputStream<C,T,A>::data() noexcept
{
return m_streambuf.data();
}
template<class C, class T, class A>
inline std::streamsize BasicResettableExpandableBufferOutputStream<C,T,A>::size() const noexcept
{
return m_streambuf.size();
}
} // namespace util
} // namespace realm
#endif // REALM_UTIL_BUFFER_STREAM_HPP
| [
"wojciech@koszek.com"
] | wojciech@koszek.com |
b35d52c8f9ef03d4f650d871195171bd681e90dc | bf325d30bfc855b6a23ae9874c5bb801f2f57d6d | /随机数.cpp | 613fd388b9389e5f3900574ccd097e96aaea5b6d | [] | no_license | sudekidesu/my-programes | 6d606d2af19da3e6ab60c4e192571698256c0109 | 622cbef10dd46ec82f7d9b3f27e1ab6893f08bf5 | refs/heads/master | 2020-04-09T07:20:32.732517 | 2019-04-24T10:17:30 | 2019-04-24T10:17:30 | 160,151,449 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 658 | cpp | //#include<bits/stdc++.h>
#include<iostream>
#include<cmath>
#include<string>
#include<sstream>
#include<ctime>
#include<cstring>
#include<set>
using namespace std;
#define random(a,b) ((a)+rand()%((b)-(a)+1))
int main()
{
int seed=time(NULL);
srand(seed);
//以上为随机数初始化,请勿修改
//random(a,b)生成[a,b]的随机整数、
//以下写你自己的数据生成代码
int n;
scanf("%d", &n);
set<int> s;
while(n--)
{
int a=random(9,32);
if(s.find(a)!=s.end())
{
n++;
continue;
}
s.insert(a);
printf("B170412%02d\n",a);
}
}
| [
"33283268+sudekidesu@users.noreply.github.com"
] | 33283268+sudekidesu@users.noreply.github.com |
0d58ea4ee53a7c8fb114814d42b63b9482b0a5a6 | 2a915381ab646344f25ccf8860fc0266fc059b3b | /DIP/Exercise7.cpp | 82d0cbe3fb6d3b8d8286724b9caec89c2b36da24 | [] | no_license | petrdolejsi/VSB-DZO | c2bc4d55b68da09a88332104cfde2f1131430304 | 0ba3b6dee34072464ad577d560cd16d72f8e07d9 | refs/heads/master | 2020-04-23T11:03:44.782279 | 2019-02-17T13:14:11 | 2019-02-17T13:14:11 | 171,123,278 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,586 | cpp | #include "stdafx.h"
int exercise7noise(const char* sourceText, int radiusLow, int radiusHigh)
{
cv::Mat source = cv::imread(sourceText, CV_LOAD_IMAGE_GRAYSCALE);
if (source.empty())
{
printf("Unable to read input file (%s, %d).", __FILE__, __LINE__);
}
cv::Mat filter_lowPass, filter_highPass;
filter_lowPass = cv::Mat::zeros(64, 64, CV_8UC1);
filter_highPass = cv::Mat::ones(64, 64, CV_8UC1) * 255;
int M = source.rows;
int N = source.cols;
cv::circle(filter_lowPass, cv::Point(M / 2, N / 2), radiusLow, 255, -1);
cv::circle(filter_highPass, cv::Point(M / 2, N / 2), radiusHigh, 0, -1);
viewImage(filter_lowPass, "Circle");
cv::Mat matrixLow = cv::Mat(M, N, CV_64FC2);
cv::Mat matrixHigh = cv::Mat(M, N, CV_64FC2);
FurierFunction(source, matrixLow);
for (int k = 0; k < M; k++)
{
for (int l = 0; l < N; l++)
{
uchar pixelLow = filter_lowPass.at<uchar>(k,l);
if (pixelLow == 0) {
matrixLow.at<cv::Vec2d>(k, l) = cv::Vec2d(0, 0);
}
}
}
cv::Mat lena_noise_cleared_low = cv::Mat(M, N, CV_64FC1), lena_noise_cleared_high = cv::Mat(M, N, CV_64FC1);
FurierInvertedFunction(matrixLow, lena_noise_cleared_low);
cvWaitKey();
FurierFunction(source, matrixHigh);
for (int k = 0; k < M; k++)
{
for (int l = 0; l < N; l++)
{
uchar pixelHigh = filter_highPass.at<uchar>(k, l);
if (pixelHigh == 0) {
matrixHigh.at<cv::Vec2d>(k, l) = cv::Vec2d(0, 0);
}
}
}
viewImage(filter_highPass, "Circle");
FurierInvertedFunction(matrixHigh, lena_noise_cleared_high);
cvWaitKey();
return 0;
}
int exercise7bars(const char* sourceText, int radiusLow, int radiusHigh)
{
cv::Mat source = cv::imread(sourceText, CV_LOAD_IMAGE_GRAYSCALE);
if (source.empty())
{
printf("Unable to read input file (%s, %d).", __FILE__, __LINE__);
}
cv::Mat filter_bars;
filter_bars = cv::Mat::ones(64, 64, CV_8UC1) * 255;
int M = source.rows;
int N = source.cols;
for (int i = 0; i < 64; i++)
{
if (i > 30 && i < 34) continue;
filter_bars.at<uchar>(32, i) = 0;
}
viewImage(filter_bars, "Bars");
cv::Mat matrix = cv::Mat(M, N, CV_64FC2);
FurierFunction(source, matrix);
for (int k = 0; k < M; k++)
{
for (int l = 0; l < N; l++)
{
uchar pixelLow = filter_bars.at<uchar>(k, l);
if (pixelLow == 0)
{
matrix.at<cv::Vec2d>(k, l) = cv::Vec2d(0, 0);
}
}
}
cv::Mat cleared = cv::Mat(M, N, CV_64FC1);
FurierInvertedFunction(matrix, cleared);
cvWaitKey();
return 0;
} | [
"dolejsi.petr@gmail.com"
] | dolejsi.petr@gmail.com |
427a96d20ad39e7818b44baed5569c7d81b8d3d6 | e490b776d21d1ea3dbc906bec781244374bc4ba6 | /Source/ObjectDescription.h | b708406ccf86dbc06e366f1309fe5897df586e36 | [] | no_license | PinMeister/Area51 | 150d7b08dc1cb620be138a0c9671cf132aa5241b | 8a4f35ce31b4f5fd54e367c790be1b36c6bf6d79 | refs/heads/master | 2020-07-14T23:23:14.203740 | 2019-08-16T03:39:58 | 2019-08-16T03:39:58 | null | 0 | 0 | null | null | null | null | WINDOWS-1252 | C++ | false | false | 684 | h | //
// ObjectDescription.h
// Area51
//
// Created by David-Etienne Pigeon on 2019-08-09.
// Copyright © 2019 Concordia. All rights reserved.
//
#include <GL/glew.h>
#include <GLFW/glfw3.h>
#include <iostream>
#include <vector>
#include "Model.h"
using namespace std;
using namespace glm;
class ObjectDescription
{
public:
ObjectDescription();
static string RandomPlanetName();
static bool RayPickObject(mat4 projectionMatrix, mat4 viewMatrix, vec3 cameraPosition, vec3 planetPosition, float radius);
static float intersectRayPlanetPoint(vec3 worldRay, vec3 cameraPosition, vec3 planetPosition, float radius);
~ObjectDescription();
private:
vector<Model*> mObjects;
}; | [
"D_Pig@encs.concordia.ca"
] | D_Pig@encs.concordia.ca |
e568b44bbb3388014a2bc4bc9877987a05f63c7e | ad3bc509c4f61424492b2949e03c60628f631a31 | /test/posix_captures/other/23_stadfa.re | f62e1a8b7911898875429c6a8a3d72fe162898f5 | [
"LicenseRef-scancode-warranty-disclaimer",
"LicenseRef-scancode-public-domain"
] | permissive | sergeyklay/re2c | 0b1cdbfe40b4514be33320b2e1d263cf5d6426d6 | 88ff1e5a2ad57d424fe999e17960c564886d36f4 | refs/heads/master | 2021-12-23T22:24:30.716697 | 2021-06-26T22:56:00 | 2021-06-27T15:23:28 | 299,206,360 | 0 | 0 | NOASSERTION | 2021-06-19T10:49:05 | 2020-09-28T06:10:35 | C | UTF-8 | C++ | false | false | 132 | re | // re2c $INPUT -o $OUTPUT -i --flex-syntax --stadfa
/*!re2c
re2c:flags:posix-captures = 1;
(y?){1,2}y?
{}
"" {}
*/
| [
"skvadrik@gmail.com"
] | skvadrik@gmail.com |
233d5f326f7b70899be89ca8bc7e2e72cc30a4d8 | 243507ac9ccab0489d83f30c7aafd371e2efcffe | /codes/chap05/07multiBasepegasus/Horse.h | d8fc26aab85508b5fd7f9d21b2690fdbf7bc5f69 | [] | no_license | bhsphd/cpplects-beamer | 578b940b91edf26528ec4598160c2bcbfcd677e1 | b271d75f582943cb2934f3d3b3cd9b8f4529e7bf | refs/heads/master | 2021-03-21T14:51:52.696850 | 2020-03-15T13:26:14 | 2020-03-15T13:26:14 | 247,304,995 | 0 | 0 | null | 2020-03-14T15:45:20 | 2020-03-14T15:45:20 | null | UTF-8 | C++ | false | false | 299 | h | #ifndef CHORSE_H
#define CHORSE_H
#include "Animal.h"
class CHorse : public CAnimal
{
public:
CHorse(int pow=0, const char *strName="", int a=0, int w=0);
~CHorse();
void Show();
void Run();
void Talk();
private:
int power;
};
#endif // CHORSE_H
| [
"nangeng@nwafu.edu.cn"
] | nangeng@nwafu.edu.cn |
0fbd0db63dff62743593a05260038fc5123c259b | 797e610dc5f86f6b68ae63ba657c090a204e5fc2 | /lib/common/Collision/CollisionPolygon.h | 17b90054486becd8c3d9c0136b4ab868553ae7dd | [] | no_license | williamsonlogan/ParryPoke | 9c11fa635d05e7733305b45973e6005650d8c62e | 4981fa3bae5509fa3b04ffa11355603e1209e229 | refs/heads/master | 2021-05-09T17:48:52.723517 | 2018-01-29T21:17:23 | 2018-01-29T21:17:23 | 119,146,171 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 1,093 | h | #ifndef _H_AGKCOLPOLYGON
#define _H_AGKCOLPOLYGON
//#include "dllmain.h"
#include "3DMath.h"
#include "Box.h"
#include "Face.h"
#include "CollisionObject.h"
#include "CollisionSphere.h"
namespace AGK
{
class CollisionPolygon : private CollisionObject
{
public:
CollisionPolygon() { faces = 0; }
~CollisionPolygon();
void makeCollisionObject(Face* pFaces);
bool intersects(AGKVector* p, AGKVector* v, AGKVector* vn, AGKVector* vi, CollisionResults* cRes);
bool sphereIntersects(AGKVector* p, AGKVector* v, AGKVector* vn, AGKVector* vi, float rRadius, AGKVector* scale, CollisionResults* cRes);
bool collidesPoly(Face* obj2Faces, AGKMatrix4* transform);
//bool collidesSphere(CollisionSphere* colSphere, float scale, AGKMatrix4* transform);
//bool collidesBox(Box* b, AGKVector* scale, AGKMatrix4* transform);
void drawBounds(int freeObj) {}
//bool SaveObject( FILE *pFile );
//bool LoadObject( FILE *pFile );
Face* faces;
Box bounds;
protected:
};
}
#endif
| [
"williamson.logan@gmail.com"
] | williamson.logan@gmail.com |
0aac0fec38a5282b5fc48e63eed453cbac55b026 | 3db65cd720a88450e2f389b9def413d79dd3ec04 | /src/sat/table.h | 186640049324e1b8745e09c43156a9f075d7f672 | [
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | WendellDuncan/or-tools | 3318215a67e6ca3277004a4bbf1045eae189c304 | 0f2eff30583fc3b5e30ff68b64e67c75b414cf46 | refs/heads/master | 2020-12-25T16:03:05.863120 | 2016-10-03T17:04:15 | 2016-10-03T17:04:15 | 68,244,405 | 2 | 0 | null | 2016-09-14T21:21:46 | 2016-09-14T21:21:45 | null | UTF-8 | C++ | false | false | 1,973 | h | // Copyright 2010-2014 Google
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef OR_TOOLS_SAT_TABLE_H_
#define OR_TOOLS_SAT_TABLE_H_
#include "sat/integer.h"
#include "sat/model.h"
namespace operations_research {
namespace sat {
// Enforces that the given tuple of variables is equal to one of the given
// tuples. All the tuples must have the same size as var.size(), this is
// Checked.
std::function<void(Model*)> TableConstraint(
const std::vector<IntegerVariable>& vars, const std::vector<std::vector<int64>>& tuples);
// Given an automata defined by a set of 3-tuples:
// (state, transition_with_value_as_label, next_state)
// this accepts the sequences of vars.size() variables that are recognized by
// this automata. That is:
// - We start from the initial state.
// - For each variable, we move along the transition labeled by this variable
// value. Moreover, the variable must take a value that correspond to a
// feasible transition.
// - We only accept sequences that ends in one of the final states.
//
// We CHECK that there is only one possible transition for a state/value pair.
// See the test for some examples.
std::function<void(Model*)> TransitionConstraint(
const std::vector<IntegerVariable>& vars, const std::vector<std::vector<int64>>& automata,
int64 initial_state, const std::vector<int64>& final_states);
} // namespace sat
} // namespace operations_research
#endif // OR_TOOLS_SAT_TABLE_H_
| [
"lperron@google.com"
] | lperron@google.com |
946e4e66f5ba59815d4f3017473f2d09c06d42e1 | c09b47a2966f5e49b5e04c815038fdb0339d621c | /Classes/AppDelegate.cpp | daddb656cb8f8ed14ca93d7eed84d6607a9b0488 | [] | no_license | aismann/XFMJ | 7148395df7b3ddd6e954582360a910e8bbf91a15 | d38303c4ddecd9363f3a3e9ad3ce455efe0bb562 | refs/heads/master | 2022-01-15T05:42:37.979533 | 2018-06-08T08:18:50 | 2018-06-08T08:18:50 | null | 0 | 0 | null | null | null | null | GB18030 | C++ | false | false | 4,302 | cpp | #include "AppDelegate.h"
#include "HelloWorldScene.h"
#include "tool\WStrToUTF8.h"
#include "Scene\MainGameScene.h"
USING_NS_CC;
static cocos2d::Size designResolutionSize = cocos2d::Size(600, 380);
static cocos2d::Size smallResolutionSize = cocos2d::Size(600, 380);
static cocos2d::Size mediumResolutionSize = cocos2d::Size(1024, 768);
static cocos2d::Size largeResolutionSize = cocos2d::Size(2048, 1536);
/*
*游戏名:新伏魔记
*开发时间:2017.4.11-?
*类型:RPG
*作者:彭密
截止2017.7.14完成:游戏基本结构。数据载入,游戏界面,人物相关,剧情控制,NPC。
未完成:战斗系统,技能系统,商店系统,敌人,与敌人相关的剧情控制。
截止2017.8.10完成:战斗界面、商店系统、敌人(BOSS战斗未完成)
未完成:技能、敌人剧情、BOSS战、战斗逻辑(伤害)
2017.1.23 改名《新伏魔记》,确认剧情
*/
AppDelegate::AppDelegate() {
}
AppDelegate::~AppDelegate()
{
}
//if you want a different context,just modify the value of glContextAttrs
//it will takes effect on all platforms
void AppDelegate::initGLContextAttrs()
{
//set OpenGL context attributions,now can only set six attributions:
//red,green,blue,alpha,depth,stencil
GLContextAttrs glContextAttrs = {8, 8, 8, 8, 24, 8};
GLView::setGLContextAttrs(glContextAttrs);
}
// If you want to use packages manager to install more packages,
// don't modify or remove this function
static int register_all_packages()
{
return 0; //flag for packages manager
}
bool AppDelegate::applicationDidFinishLaunching() {
// initialize director
auto director = Director::getInstance();
auto glview = director->getOpenGLView();
if(!glview) {
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) || (CC_TARGET_PLATFORM == CC_PLATFORM_MAC) || (CC_TARGET_PLATFORM == CC_PLATFORM_LINUX)
glview = GLViewImpl::createWithRect(wstrtoutf8::CreateUTF8("新伏魔记"), Rect(0, 0, designResolutionSize.width, designResolutionSize.height));
glview->setFrameZoomFactor(1.5f);
#else
glview = GLViewImpl::create(wstrtoutf8::CreateUTF8("新伏魔记"));
#endif
director->setOpenGLView(glview);
}
// turn on display FPS
//director->setDisplayStats(true);
// set FPS. the default value is 1.0/60 if you don't call this
director->setAnimationInterval(1.0 / 60);
// Set the design resolution
glview->setDesignResolutionSize(designResolutionSize.width, designResolutionSize.height, ResolutionPolicy::NO_BORDER);
Size frameSize = glview->getFrameSize();
// if the frame's height is larger than the height of medium size.
if (frameSize.height > mediumResolutionSize.height)
{
director->setContentScaleFactor(MIN(largeResolutionSize.height/designResolutionSize.height, largeResolutionSize.width/designResolutionSize.width));
}
// if the frame's height is larger than the height of small size.
else if (frameSize.height > smallResolutionSize.height)
{
director->setContentScaleFactor(MIN(mediumResolutionSize.height/designResolutionSize.height, mediumResolutionSize.width/designResolutionSize.width));
}
// if the frame's height is smaller than the height of medium size.
else
{
director->setContentScaleFactor(MIN(smallResolutionSize.height/designResolutionSize.height, smallResolutionSize.width/designResolutionSize.width));
}
register_all_packages();
// create a scene. it's an autorelease object
auto scene = HelloWorld::createScene();
//auto scene = MainGameScene::createScene("baicaodi", "baicaodi");
// run
director->runWithScene(scene);
return true;
}
// This function will be called when the app is inactive. When comes a phone call,it's be invoked too
void AppDelegate::applicationDidEnterBackground() {
Director::getInstance()->stopAnimation();
// if you use SimpleAudioEngine, it must be pause
// SimpleAudioEngine::getInstance()->pauseBackgroundMusic();
}
// this function will be called when the app is active again
void AppDelegate::applicationWillEnterForeground() {
Director::getInstance()->startAnimation();
// if you use SimpleAudioEngine, it must resume here
// SimpleAudioEngine::getInstance()->resumeBackgroundMusic();
}
| [
"pengmi1993@163.com"
] | pengmi1993@163.com |
1abbc2fb7274fa49a9ec6da993b095618fbe0617 | 5963efb46c9bbef73ccb6744ab4a52b6ebd6b305 | /Reference_Implementation/crypto_kem/ntru-hps2048509/ntru09/enc/syn/systemc/randombytes_block.h | 7ba30605274f020162330c0536eed820749b6089 | [] | no_license | Deepsavani/Post-Quantum-Crypto---NTRU | a5c0324c0281a9890fc977eae55cc4432c5dd8bd | 5494bd4af96998d4056a17ef425489cf45efbae7 | refs/heads/master | 2023-03-18T03:15:59.184060 | 2021-03-16T16:14:22 | 2021-03-16T16:14:22 | 348,408,223 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 3,295 | h | // ==============================================================
// File generated on Mon Aug 24 19:53:00 EDT 2020
// Vivado(TM) HLS - High-Level Synthesis from C, C++ and SystemC v2018.3 (64-bit)
// SW Build 2405991 on Thu Dec 6 23:36:41 MST 2018
// IP Build 2404404 on Fri Dec 7 01:43:56 MST 2018
// Copyright 1986-2018 Xilinx, Inc. All Rights Reserved.
// ==============================================================
#ifndef __randombytes_block_H__
#define __randombytes_block_H__
#include <systemc>
using namespace sc_core;
using namespace sc_dt;
#include <iostream>
#include <fstream>
struct randombytes_block_ram : public sc_core::sc_module {
static const unsigned DataWidth = 8;
static const unsigned AddressRange = 16;
static const unsigned AddressWidth = 4;
//latency = 1
//input_reg = 1
//output_reg = 0
sc_core::sc_in <sc_lv<AddressWidth> > address0;
sc_core::sc_in <sc_logic> ce0;
sc_core::sc_out <sc_lv<DataWidth> > q0;
sc_core::sc_in<sc_logic> we0;
sc_core::sc_in<sc_lv<DataWidth> > d0;
sc_core::sc_in <sc_lv<AddressWidth> > address1;
sc_core::sc_in <sc_logic> ce1;
sc_core::sc_in<sc_logic> we1;
sc_core::sc_in<sc_lv<DataWidth> > d1;
sc_core::sc_in<sc_logic> reset;
sc_core::sc_in<bool> clk;
sc_lv<DataWidth> ram[AddressRange];
SC_CTOR(randombytes_block_ram) {
SC_METHOD(prc_write_0);
sensitive<<clk.pos();
SC_METHOD(prc_write_1);
sensitive<<clk.pos();
}
void prc_write_0()
{
if (ce0.read() == sc_dt::Log_1)
{
if (we0.read() == sc_dt::Log_1)
{
if(address0.read().is_01() && address0.read().to_uint()<AddressRange)
{
ram[address0.read().to_uint()] = d0.read();
q0 = d0.read();
}
else
q0 = sc_lv<DataWidth>();
}
else {
if(address0.read().is_01() && address0.read().to_uint()<AddressRange)
q0 = ram[address0.read().to_uint()];
else
q0 = sc_lv<DataWidth>();
}
}
}
void prc_write_1()
{
if (ce1.read() == sc_dt::Log_1)
{
if (we1.read() == sc_dt::Log_1)
{
if(address1.read().is_01() && address1.read().to_uint()<AddressRange)
{
ram[address1.read().to_uint()] = d1.read();
}
}
}
}
}; //endmodule
SC_MODULE(randombytes_block) {
static const unsigned DataWidth = 8;
static const unsigned AddressRange = 16;
static const unsigned AddressWidth = 4;
sc_core::sc_in <sc_lv<AddressWidth> > address0;
sc_core::sc_in<sc_logic> ce0;
sc_core::sc_out <sc_lv<DataWidth> > q0;
sc_core::sc_in<sc_logic> we0;
sc_core::sc_in<sc_lv<DataWidth> > d0;
sc_core::sc_in <sc_lv<AddressWidth> > address1;
sc_core::sc_in<sc_logic> ce1;
sc_core::sc_in<sc_logic> we1;
sc_core::sc_in<sc_lv<DataWidth> > d1;
sc_core::sc_in<sc_logic> reset;
sc_core::sc_in<bool> clk;
randombytes_block_ram* meminst;
SC_CTOR(randombytes_block) {
meminst = new randombytes_block_ram("randombytes_block_ram");
meminst->address0(address0);
meminst->ce0(ce0);
meminst->q0(q0);
meminst->we0(we0);
meminst->d0(d0);
meminst->address1(address1);
meminst->ce1(ce1);
meminst->we1(we1);
meminst->d1(d1);
meminst->reset(reset);
meminst->clk(clk);
}
~randombytes_block() {
delete meminst;
}
};//endmodule
#endif
| [
"deepsavani@deeps-mbp.myfiosgateway.com"
] | deepsavani@deeps-mbp.myfiosgateway.com |
c79a862b454c3b428a15569a585434af5d313d79 | 0f255b6f67152bfb7e499918d3c649e079576c3e | /src/masternodeman.h | cfa5e07a786246e10fac91d90e181b684a04fcf4 | [
"MIT"
] | permissive | PierreShark/BitBlocks | f216ce70cea5c46351a01380effb1910fa16c82c | 4be04f939a51c8dad2695cc2828ef88f93946798 | refs/heads/master | 2020-04-07T22:26:11.419331 | 2018-11-22T02:53:19 | 2018-11-22T02:53:19 | 158,770,043 | 1 | 0 | MIT | 2018-11-23T02:18:23 | 2018-11-23T02:18:23 | null | UTF-8 | C++ | false | false | 4,883 | h | // Copyright (c) 2014-2015 The Dash developers
// Copyright (c) 2015-2017 The PIVX developers
// Copyright (c) 2018 LightPayCoin developers
// Copyright (c) 2018 The BitBlocks developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#ifndef MASTERNODEMAN_H
#define MASTERNODEMAN_H
#include "base58.h"
#include "key.h"
#include "main.h"
#include "masternode.h"
#include "net.h"
#include "sync.h"
#include "util.h"
#define MASTERNODES_DUMP_SECONDS (15 * 60)
#define MASTERNODES_DSEG_SECONDS (3 * 60 * 60)
using namespace std;
class CMasternodeMan;
extern CMasternodeMan mnodeman;
void DumpMasternodes();
/** Access to the MN database (mncache.dat)
*/
class CMasternodeDB
{
private:
boost::filesystem::path pathMN;
std::string strMagicMessage;
public:
enum ReadResult {
Ok,
FileError,
HashReadError,
IncorrectHash,
IncorrectMagicMessage,
IncorrectMagicNumber,
IncorrectFormat
};
CMasternodeDB();
bool Write(const CMasternodeMan& mnodemanToSave);
ReadResult Read(CMasternodeMan& mnodemanToLoad, bool fDryRun = false);
};
class CMasternodeMan
{
private:
// critical section to protect the inner data structures
mutable CCriticalSection cs;
// critical section to protect the inner data structures specifically on messaging
mutable CCriticalSection cs_process_message;
// map to hold all MNs
std::vector<CMasternode> vMasternodes;
// who's asked for the Masternode list and the last time
std::map<CNetAddr, int64_t> mAskedUsForMasternodeList;
// who we asked for the Masternode list and the last time
std::map<CNetAddr, int64_t> mWeAskedForMasternodeList;
// which Masternodes we've asked for
std::map<COutPoint, int64_t> mWeAskedForMasternodeListEntry;
public:
// Keep track of all broadcasts I've seen
map<uint256, CMasternodeBroadcast> mapSeenMasternodeBroadcast;
// Keep track of all pings I've seen
map<uint256, CMasternodePing> mapSeenMasternodePing;
// keep track of dsq count to prevent masternodes from gaming obfuscation queue
int64_t nDsqCount;
ADD_SERIALIZE_METHODS;
template <typename Stream, typename Operation>
inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion)
{
LOCK(cs);
READWRITE(vMasternodes);
READWRITE(mAskedUsForMasternodeList);
READWRITE(mWeAskedForMasternodeList);
READWRITE(mWeAskedForMasternodeListEntry);
READWRITE(nDsqCount);
READWRITE(mapSeenMasternodeBroadcast);
READWRITE(mapSeenMasternodePing);
}
CMasternodeMan();
CMasternodeMan(CMasternodeMan& other);
/// Add an entry
bool Add(CMasternode& mn);
/// Ask (source) node for mnb
void AskForMN(CNode* pnode, CTxIn& vin);
/// Check all Masternodes
void Check();
/// Check all Masternodes and remove inactive
void CheckAndRemove(bool forceExpiredRemoval = false);
/// Clear Masternode vector
void Clear();
int CountEnabled(int protocolVersion = -1);
void CountNetworks(int protocolVersion, int& ipv4, int& ipv6, int& onion);
void DsegUpdate(CNode* pnode);
/// Find an entry
CMasternode* Find(const CScript& payee);
CMasternode* Find(const CTxIn& vin);
CMasternode* Find(const CPubKey& pubKeyMasternode);
/// Find an entry in the masternode list that is next to be paid
CMasternode* GetNextMasternodeInQueueForPayment(int nBlockHeight, bool fFilterSigTime, int& nCount);
/// Find a random entry
CMasternode* FindRandomNotInVec(std::vector<CTxIn>& vecToExclude, int protocolVersion = -1);
/// Get the current winner for this block
CMasternode* GetCurrentMasterNode(int mod = 1, int64_t nBlockHeight = 0, int minProtocol = 0);
std::vector<CMasternode> GetFullMasternodeVector()
{
Check();
return vMasternodes;
}
std::vector<pair<int, CMasternode> > GetMasternodeRanks(int64_t nBlockHeight, int minProtocol = 0);
int GetMasternodeRank(const CTxIn& vin, int64_t nBlockHeight, int minProtocol = 0, bool fOnlyActive = true);
CMasternode* GetMasternodeByRank(int nRank, int64_t nBlockHeight, int minProtocol = 0, bool fOnlyActive = true);
void ProcessMasternodeConnections();
void ProcessMessage(CNode* pfrom, std::string& strCommand, CDataStream& vRecv);
/// Return the number of (unique) Masternodes
int size() { return vMasternodes.size(); }
/// Return the number of Masternodes older than (default) 8000 seconds
int stable_size ();
std::string ToString() const;
void Remove(CTxIn vin);
/// Update masternode list and maps using provided CMasternodeBroadcast
void UpdateMasternodeList(CMasternodeBroadcast mnb);
};
#endif
| [
"Bitblocksproject@gmail.com"
] | Bitblocksproject@gmail.com |
926c916102b173184de6fb85a87381f5acfe8692 | f1459b2c2864ddfcd38d04267ae77986adc6b3a6 | /cpp_examples/nasnet_a.h | 89cfd29453b5c0026aa5661f59db0cc8e42f7adc | [
"Apache-2.0"
] | permissive | hafizas101/TASO | 365a99fc3478080b583d21d121ae7e8649ee466c | bfc32fa8cdef249e01eb54200540492e600e2e25 | refs/heads/master | 2023-06-30T04:18:59.026030 | 2021-08-03T07:37:58 | 2021-08-03T07:37:58 | 387,054,062 | 0 | 0 | Apache-2.0 | 2021-07-17T23:27:19 | 2021-07-17T23:27:18 | null | UTF-8 | C++ | false | false | 4,969 | h | /* Copyright 2020 Stanford, Tsinghua
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef _CPP_EXAMPLES_NASNET_A_H_
#define _CPP_EXAMPLES_NASNET_A_H_
#include <vector>
TensorHandle squeeze(Graph* graph, const TensorHandle input, int outChannels) {
auto weight = new_random_weight(graph, { outChannels, input->dim[1], 1, 1 });
return graph->conv2d(input, weight, 1, 1, PD_MODE_SAME, AC_MODE_RELU);
}
TensorHandle fit(Graph* graph, const TensorHandle current, const TensorHandle input) {
if (input->dim[2] == current->dim[2]) {
return squeeze(graph, input, current->dim[1]);
}
auto weight = new_random_weight(graph, { current->dim[1], input->dim[1], 3, 3 });
return graph->conv2d(input, weight, 2, 2, PD_MODE_SAME, AC_MODE_RELU);
}
TensorHandle separable_conv(Graph* graph, const TensorHandle input, int outChannels,
int kernelH, int kernelW, int strideH, int strideW,
PaddingMode padding, ActiMode activation = AC_MODE_NONE) {
assert(input->dim[1] % outChannels == 0);
auto w1 = new_random_weight(graph, { outChannels, input->dim[1] / outChannels, kernelH, kernelW });
auto t = graph->conv2d(input, w1, strideH, strideW, padding);
auto w2 = new_random_weight(graph, { outChannels, t->dim[1], 1, 1 });
return graph->conv2d(t, w2, 1, 1, PD_MODE_SAME, activation);
}
TensorHandle normal_cell(Graph* graph, TensorHandle prev, TensorHandle cur, int outChannels) {
cur = squeeze(graph, cur, outChannels);
prev = fit(graph, cur, prev);
std::vector<TensorHandle> ts;
ts.push_back(separable_conv(graph, cur, outChannels, 3, 3, 1, 1, PD_MODE_SAME));
ts.push_back(cur);
ts.push_back(separable_conv(graph, prev, outChannels, 3, 3, 1, 1, PD_MODE_SAME));
ts.push_back(separable_conv(graph, cur, outChannels, 3, 3, 1, 1, PD_MODE_SAME));
ts.push_back(graph->pool2d_avg(cur, 3, 3, 1, 1, PD_MODE_SAME));
ts.push_back(prev);
ts.push_back(graph->pool2d_avg(prev, 3, 3, 1, 1, PD_MODE_SAME));
ts.push_back(graph->pool2d_avg(prev, 3, 3, 1, 1, PD_MODE_SAME));
ts.push_back(separable_conv(graph, prev, outChannels, 3, 3, 1, 1, PD_MODE_SAME));
ts.push_back(separable_conv(graph, prev, outChannels, 3, 3, 1, 1, PD_MODE_SAME));
assert(ts.size() == 10);
std::vector<TensorHandle> outputs;
for (int i = 0; i < 5; i++) {
outputs.push_back(graph->element(OP_EW_ADD, ts[2 * i], ts[2 * i + 1]));
}
return graph->concat(1, outputs.size(), outputs.data());
}
TensorHandle reduction_cell(Graph* graph, TensorHandle prev, TensorHandle cur, int outChannels) {
cur = squeeze(graph, cur, outChannels);
prev = fit(graph, cur, prev);
std::vector<TensorHandle> ts;
std::vector<TensorHandle> outputs;
ts.push_back(separable_conv(graph, prev, outChannels, 7, 7, 2, 2, PD_MODE_SAME));
ts.push_back(separable_conv(graph, cur, outChannels, 5, 5, 2, 2, PD_MODE_SAME));
outputs.push_back(graph->element(OP_EW_ADD, ts[0], ts[1]));
ts.push_back(graph->pool2d_max(cur, 3, 3, 2, 2, PD_MODE_SAME));
ts.push_back(separable_conv(graph, prev, outChannels, 7, 7, 2, 2, PD_MODE_SAME));
outputs.push_back(graph->element(OP_EW_ADD, ts[2], ts[3]));
ts.push_back(graph->pool2d_avg(cur, 3, 3, 2, 2, PD_MODE_SAME));
ts.push_back(separable_conv(graph, prev, outChannels, 5, 5, 2, 2, PD_MODE_SAME));
outputs.push_back(graph->element(OP_EW_ADD, ts[4], ts[5]));
ts.push_back(graph->pool2d_max(cur, 3, 3, 2, 2, PD_MODE_SAME));
ts.push_back(separable_conv(graph, outputs[0], outChannels, 3, 3, 1, 1, PD_MODE_SAME));
outputs.push_back(graph->element(OP_EW_ADD, ts[6], ts[7]));
ts.push_back(graph->pool2d_avg(outputs[0], 3, 3, 1, 1, PD_MODE_SAME));
ts.push_back(outputs[1]);
outputs.push_back(graph->element(OP_EW_ADD, ts[8], ts[9]));
return graph->concat(1, outputs.size(), outputs.data());
}
Graph* nasnet_a(float alpha, int budget, bool printSubst = false) {
Graph *graph = new Graph();
auto inp = new_input(graph, { 1, 3, 224, 224 });
auto weight = new_random_weight(graph, { 64, 3, 7, 7 });
inp = graph->conv2d(inp, weight, 2, 2, PD_MODE_SAME, AC_MODE_RELU);
inp = graph->pool2d_max(inp, 3, 3, 2, 2, PD_MODE_SAME);
int outChannels = 128;
for (int i = 0; i < 3; i++) {
auto prev = inp;
auto cur = inp;
for (int j = 0; j < 5; j++) {
auto t = normal_cell(graph, prev, cur, outChannels);
prev = cur;
cur = t;
}
outChannels *= 2;
inp = reduction_cell(graph, prev, cur, outChannels);
}
return graph->optimize(alpha, budget, printSubst);
}
#endif
| [
"gaomy@tsinghua.edu.cn"
] | gaomy@tsinghua.edu.cn |
c9aa6a0274ed12afb51eaeadb1522c941508a433 | b8cc7f50628eb2f6b4fdbd66eae5a1aa502cc309 | /scintilla/src/Editor.cxx | 5e6550ad3908dbfb8a9b666c562ccf996380bc2d | [
"BSD-3-Clause",
"LicenseRef-scancode-scintilla",
"MIT",
"BSD-2-Clause",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | zufuliu/notepad2 | ad82f2baaf60cd9efcbf3af57d2e2f381f961f0b | 6296f4a8567d2c22690be0cafcdf91a0fea60cc7 | refs/heads/main | 2023-08-29T03:45:42.292846 | 2023-08-28T10:33:46 | 2023-08-28T10:33:46 | 79,987,996 | 2,154 | 227 | NOASSERTION | 2023-08-11T23:59:02 | 2017-01-25T06:07:49 | C++ | UTF-8 | C++ | false | false | 274,982 | cxx | // Scintilla source code edit control
/** @file Editor.cxx
** Main code for the edit control.
**/
// Copyright 1998-2011 by Neil Hodgson <neilh@scintilla.org>
// The License.txt file describes the conditions under which this software may be distributed.
#include <cstddef>
#include <cstdlib>
#include <cstdint>
#include <cassert>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <stdexcept>
#include <string>
#include <string_view>
#include <vector>
#include <map>
#include <forward_list>
#include <optional>
#include <algorithm>
#include <iterator>
#include <memory>
#include "ParallelSupport.h"
#include "ScintillaTypes.h"
#include "ScintillaMessages.h"
#include "ScintillaStructures.h"
#include "ILoader.h"
#include "ILexer.h"
#include "Debugging.h"
#include "Geometry.h"
#include "Platform.h"
#include "CharacterSet.h"
//#include "CharacterCategory.h"
#include "Position.h"
#include "UniqueString.h"
#include "SplitVector.h"
#include "Partitioning.h"
#include "RunStyles.h"
#include "ContractionState.h"
#include "CellBuffer.h"
#include "PerLine.h"
#include "KeyMap.h"
#include "Indicator.h"
#include "LineMarker.h"
#include "Style.h"
#include "ViewStyle.h"
#include "CharClassify.h"
#include "Decoration.h"
#include "CaseFolder.h"
#include "Document.h"
#include "UniConversion.h"
#include "Selection.h"
#include "PositionCache.h"
#include "EditModel.h"
#include "MarginView.h"
#include "EditView.h"
#include "Editor.h"
#include "ElapsedPeriod.h"
using namespace Scintilla;
using namespace Scintilla::Internal;
using namespace Lexilla;
namespace {
/*
return whether this modification represents an operation that
may reasonably be deferred (not done now OR [possibly] at all)
*/
constexpr bool CanDeferToLastStep(const DocModification &mh) noexcept {
if (FlagSet(mh.modificationType, (ModificationFlags::BeforeInsert | ModificationFlags::BeforeDelete)))
return true; // CAN skip
if (!FlagSet(mh.modificationType, (ModificationFlags::Undo | ModificationFlags::Redo)))
return false; // MUST do
if (FlagSet(mh.modificationType, ModificationFlags::MultiStepUndoRedo))
return true; // CAN skip
return false; // PRESUMABLY must do
}
constexpr bool CanEliminate(const DocModification &mh) noexcept {
return FlagSet(mh.modificationType, (ModificationFlags::BeforeInsert | ModificationFlags::BeforeDelete));
}
/*
return whether this modification represents the FINAL step
in a [possibly lengthy] multi-step Undo/Redo sequence
*/
constexpr bool IsLastStep(const DocModification &mh) noexcept {
return
FlagSet(mh.modificationType, (ModificationFlags::Undo | ModificationFlags::Redo))
&& FlagSet(mh.modificationType, ModificationFlags::MultiStepUndoRedo)
&& FlagSet(mh.modificationType, ModificationFlags::LastStepInUndoRedo)
&& FlagSet(mh.modificationType, ModificationFlags::MultilineUndoRedo);
}
}
Timer::Timer() noexcept :
ticking(false), ticksToWait(0), tickerID{} {}
Idler::Idler() noexcept :
state(false), idlerID(nullptr) {}
static constexpr bool IsAllSpacesOrTabs(std::string_view sv) noexcept {
for (const char ch : sv) {
// This is safe because IsSpaceOrTab() will return false for null terminators
if (!IsSpaceOrTab(ch))
return false;
}
return true;
}
Editor::Editor() {
ctrlID = 0;
stylesValid = false;
technology = Technology::Default;
scaleRGBAImage = 100.0f;
cursorMode = CursorShape::Normal;
errorStatus = Status::Ok;
mouseDownCaptures = true;
mouseWheelCaptures = true;
doubleClickCloseThreshold = Point(3, 3);
lastClickTime = 0;
dwellDelay = TimeForever;
ticksToDwell = TimeForever;
dwelling = false;
dropWentOutside = false;
inDragDrop = DragDrop::none;
ptMouseLast.x = 0;
ptMouseLast.y = 0;
posDrop = SelectionPosition(Sci::invalidPosition);
hotSpotClickPos = Sci::invalidPosition;
selectionUnit = TextUnit::character;
lastXChosen = 0;
autoInsertMask = 0;
lineAnchorPos = 0;
originalAnchorPos = 0;
wordSelectAnchorStartPos = 0;
wordSelectAnchorEndPos = 0;
wordSelectInitialCaretPos = -1;
caretPolicies.x = { CaretPolicy::Slop | CaretPolicy::Even, 50 };
caretPolicies.y = { CaretPolicy::Even, 0 };
visiblePolicy = { 0, 0 };
searchAnchor = 0;
horizontalScrollBarVisible = true;
verticalScrollBarVisible = true;
xCaretMargin = 50;
scrollWidth = 2000;
endAtLastLine = 1;
caretSticky = CaretSticky::Off;
marginOptions = MarginOption::None;
mouseSelectionRectangularSwitch = false;
multipleSelection = false;
additionalSelectionTyping = false;
multiPasteMode = MultiPaste::Once;
virtualSpaceOptions = VirtualSpace::None;
targetRange = SelectionSegment();
searchFlags = FindOption::None;
topLine = 0;
posTopLine = 0;
lengthForEncode = -1;
needUpdateUI = Update::None;
ContainerNeedsUpdate(Update::Content);
paintState = PaintState::notPainting;
paintAbandonedByStyling = false;
paintingAllText = false;
willRedrawAll = false;
idleStyling = IdleStyling::None;
needIdleStyling = false;
recordingMacro = false;
convertPastes = true;
commandEvents = true;
modEventMask = ModificationFlags::EventMaskAll;
foldAutomatic = AutomaticFold::None;
pdoc->AddWatcher(this, nullptr);
SetRepresentations();
}
Editor::~Editor() {
pdoc->RemoveWatcher(this, nullptr);
}
void Editor::Finalise() noexcept {
SetIdle(false);
CancelModes();
}
void Editor::SetRepresentations() {
reprs.SetDefaultRepresentations(pdoc->dbcsCodePage);
}
void Editor::DropGraphics() noexcept {
marginView.DropGraphics();
view.DropGraphics();
}
void Editor::InvalidateStyleData() noexcept {
stylesValid = false;
vs.technology = technology;
DropGraphics();
view.llc.Invalidate(LineLayout::ValidLevel::invalid);
view.posCache.Clear();
}
void Editor::InvalidateStyleRedraw() {
NeedWrapping();
InvalidateStyleData();
Redraw();
}
void Editor::RefreshStyleData() {
if (!stylesValid) {
stylesValid = true;
const AutoSurface surface(this);
if (surface) {
vs.Refresh(*surface, pdoc->tabInChars);
}
SetScrollBars();
SetRectangularRange();
}
}
bool Editor::HasMarginWindow() const noexcept {
return wMargin.Created();
}
Point Editor::GetVisibleOriginInMain() const noexcept {
return Point(0, 0);
}
PointDocument Editor::DocumentPointFromView(Point ptView) const noexcept {
PointDocument ptDocument(ptView);
if (HasMarginWindow()) {
const Point ptOrigin = GetVisibleOriginInMain();
ptDocument.x += ptOrigin.x;
ptDocument.y += ptOrigin.y;
} else {
ptDocument.x += xOffset;
ptDocument.y += topLine * vs.lineHeight;
}
return ptDocument;
}
Sci::Line Editor::TopLineOfMain() const noexcept {
if (HasMarginWindow())
return 0;
else
return topLine;
}
//Point Editor::ClientSize() const noexcept {
// const PRectangle rcClient = GetClientRectangle();
// return Point(rcClient.Width(), rcClient.Height());
//}
PRectangle Editor::GetClientRectangle() const noexcept {
return wMain.GetClientPosition();
}
PRectangle Editor::GetClientDrawingRectangle() const noexcept {
return GetClientRectangle();
}
PRectangle Editor::GetTextRectangle() const noexcept {
PRectangle rc = GetClientRectangle();
rc.left += vs.textStart;
rc.right -= vs.rightMarginWidth;
return rc;
}
Sci::Line Editor::LinesOnScreen() const noexcept {
//const Point sizeClient = ClientSize();
//const int htClient = static_cast<int>(sizeClient.y);
const PRectangle rcClient = GetClientRectangle();
const int htClient = static_cast<int>(rcClient.Height());
//Platform::DebugPrintf("lines on screen = %d\n", htClient / vs.lineHeight + 1);
return htClient / vs.lineHeight;
}
Sci::Line Editor::LinesToScroll() const noexcept {
const Sci::Line retVal = LinesOnScreen() - 1;
if (retVal < 1)
return 1;
else
return retVal;
}
Sci::Line Editor::MaxScrollPos() const noexcept {
Sci::Line retVal = pcs->LinesDisplayed();
const Sci::Line linesOnScreen = LinesOnScreen();
//Platform::DebugPrintf("Lines %d screen = %d maxScroll = %d\n",
//pdoc->LinesTotal(), linesOnScreen, pdoc->LinesTotal() - linesOnScreen + 1);
switch (endAtLastLine) {
default:
retVal--;
break;
case 1:
retVal -= linesOnScreen;
break;
case 2:
retVal -= linesOnScreen/2;
break;
case 3:
retVal -= 2*linesOnScreen/3;
break;
case 4:
retVal -= 3*linesOnScreen/4;
break;
}
return std::max<Sci::Line>(retVal, 0);
}
SelectionPosition Editor::ClampPositionIntoDocument(SelectionPosition sp) const noexcept {
if (sp.Position() < 0) {
return SelectionPosition(0);
} else if (sp.Position() > pdoc->LengthNoExcept()) {
return SelectionPosition(pdoc->LengthNoExcept());
} else {
// If not at end of line then set offset to 0
if (!pdoc->IsLineEndPosition(sp.Position()))
sp.SetVirtualSpace(0);
return sp;
}
}
Point Editor::LocationFromPosition(SelectionPosition pos, PointEnd pe) {
const PRectangle rcClient = GetTextRectangle();
RefreshStyleData();
const AutoSurface surface(this);
return view.LocationFromPosition(surface, *this, pos, topLine, vs, pe, rcClient);
}
Point Editor::LocationFromPosition(Sci::Position pos, PointEnd pe) {
return LocationFromPosition(SelectionPosition(pos), pe);
}
int Editor::XFromPosition(SelectionPosition sp) {
const Point pt = LocationFromPosition(sp);
return static_cast<int>(pt.x) - vs.textStart + xOffset;
}
SelectionPosition Editor::SPositionFromLocation(Point pt, bool canReturnInvalid, bool charPosition, bool virtualSpace) {
RefreshStyleData();
const AutoSurface surface(this);
PRectangle rcClient = GetTextRectangle();
// May be in scroll view coordinates so translate back to main view
const Point ptOrigin = GetVisibleOriginInMain();
rcClient.Move(-ptOrigin.x, -ptOrigin.y);
if (canReturnInvalid) {
if (!rcClient.Contains(pt))
return SelectionPosition(Sci::invalidPosition);
if (pt.x < vs.textStart)
return SelectionPosition(Sci::invalidPosition);
if (pt.y < 0)
return SelectionPosition(Sci::invalidPosition);
}
const PointDocument ptdoc = DocumentPointFromView(pt);
return view.SPositionFromLocation(surface, *this, ptdoc, canReturnInvalid,
charPosition, virtualSpace, vs, rcClient);
}
Sci::Position Editor::PositionFromLocation(Point pt, bool canReturnInvalid, bool charPosition) {
return SPositionFromLocation(pt, canReturnInvalid, charPosition, false).Position();
}
/**
* Find the document position corresponding to an x coordinate on a particular document line.
* Ensure is between whole characters when document is in multi-byte or UTF-8 mode.
* This method is used for rectangular selections and does not work on wrapped lines.
*/
SelectionPosition Editor::SPositionFromLineX(Sci::Line lineDoc, int x) {
RefreshStyleData();
if (lineDoc >= pdoc->LinesTotal())
return SelectionPosition(pdoc->LengthNoExcept());
//Platform::DebugPrintf("Position of (%d) line = %d top=%d\n", x, lineDoc, topLine);
const AutoSurface surface(this);
return view.SPositionFromLineX(surface, *this, lineDoc, x, vs);
}
Sci::Position Editor::PositionFromLineX(Sci::Line lineDoc, int x) {
return SPositionFromLineX(lineDoc, x).Position();
}
Sci::Line Editor::LineFromLocation(Point pt) const noexcept {
return pcs->DocFromDisplay(static_cast<int>(pt.y) / vs.lineHeight + topLine);
}
void Editor::SetTopLine(Sci::Line topLineNew) noexcept {
if ((topLine != topLineNew) && (topLineNew >= 0)) {
topLine = topLineNew;
ContainerNeedsUpdate(Update::VScroll);
}
posTopLine = pdoc->LineStart(pcs->DocFromDisplay(topLine));
}
/**
* If painting then abandon the painting because a wider redraw is needed.
* @return true if calling code should stop drawing.
*/
bool Editor::AbandonPaint() noexcept {
if ((paintState == PaintState::painting) && !paintingAllText) {
paintState = PaintState::abandoned;
}
return paintState == PaintState::abandoned;
}
void Editor::RedrawRect(PRectangle rc) noexcept {
//Platform::DebugPrintf("Redraw %.0f,%.0f - %.0f,%.0f\n", rc.left, rc.top, rc.right, rc.bottom);
// Clip the redraw rectangle into the client area
const PRectangle rcClient = GetClientRectangle();
if (rc.top < rcClient.top)
rc.top = rcClient.top;
if (rc.bottom > rcClient.bottom)
rc.bottom = rcClient.bottom;
if (rc.left < rcClient.left)
rc.left = rcClient.left;
if (rc.right > rcClient.right)
rc.right = rcClient.right;
if ((rc.bottom > rc.top) && (rc.right > rc.left)) {
wMain.InvalidateRectangle(rc);
}
}
void Editor::DiscardOverdraw() noexcept {
// Overridden on platforms that may draw outside visible area.
}
void Editor::Redraw() noexcept {
if (redrawPendingText) {
return;
}
//Platform::DebugPrintf("Redraw all\n");
const PRectangle rcClient = GetClientRectangle();
wMain.InvalidateRectangle(rcClient);
if (HasMarginWindow()) {
wMargin.InvalidateAll();
} else if (paintState == PaintState::notPainting) {
redrawPendingText = true;
}
}
void Editor::RedrawSelMargin(Sci::Line line, bool allAfter) noexcept {
const bool markersInText = vs.maskInLine || vs.maskDrawInText;
if (!HasMarginWindow() || markersInText) { // May affect text area so may need to abandon and retry
if (AbandonPaint()) {
return;
}
}
if (HasMarginWindow() && markersInText) {
Redraw();
return;
}
if (redrawPendingMargin) {
return;
}
PRectangle rcMarkers = GetClientRectangle();
if (!markersInText) {
// Normal case: just draw the margin
rcMarkers.right = rcMarkers.left + vs.fixedColumnWidth;
}
const PRectangle rcMarkersFull = rcMarkers;
if (line >= 0) {
PRectangle rcLine = RectangleFromRange(Range(pdoc->LineStart(line)), 0);
// Inflate line rectangle if there are image markers with height larger than line height
if (vs.largestMarkerHeight > vs.lineHeight) {
const int delta = (vs.largestMarkerHeight - vs.lineHeight + 1) / 2;
rcLine.top = std::max(rcLine.top - delta, rcMarkers.top);
rcLine.bottom = std::min(rcLine.bottom + delta, rcMarkers.bottom);
}
rcMarkers.top = rcLine.top;
if (!allAfter)
rcMarkers.bottom = rcLine.bottom;
if (rcMarkers.Empty())
return;
}
if (HasMarginWindow()) {
const Point ptOrigin = GetVisibleOriginInMain();
rcMarkers.Move(-ptOrigin.x, -ptOrigin.y);
wMargin.InvalidateRectangle(rcMarkers);
} else {
wMain.InvalidateRectangle(rcMarkers);
if (rcMarkers == rcMarkersFull) {
redrawPendingMargin = true;
}
}
}
PRectangle Editor::RectangleFromRange(Range r, int overlap) const noexcept {
const Sci::Line minLine = pcs->DisplayFromDoc(
pdoc->SciLineFromPosition(r.First()));
const Sci::Line maxLine = pcs->DisplayLastFromDoc(
pdoc->SciLineFromPosition(r.Last()));
const PRectangle rcClientDrawing = GetClientDrawingRectangle();
PRectangle rc;
const int leftTextOverlap = ((xOffset == 0) && (vs.leftMarginWidth > 0)) ? 1 : 0;
rc.left = static_cast<XYPOSITION>(vs.textStart - leftTextOverlap);
rc.top = static_cast<XYPOSITION>((minLine - TopLineOfMain()) * vs.lineHeight - overlap);
rc.top = std::max(rc.top, rcClientDrawing.top);
// Extend to right of prepared area if any to prevent artifacts from caret line highlight
rc.right = rcClientDrawing.right;
rc.bottom = static_cast<XYPOSITION>((maxLine - TopLineOfMain() + 1) * vs.lineHeight + overlap);
return rc;
}
void Editor::InvalidateRange(Sci::Position start, Sci::Position end) noexcept {
if (redrawPendingText) {
return;
}
RedrawRect(RectangleFromRange(Range(start, end), view.LinesOverlap() ? vs.lineOverlap : 0));
}
Sci::Position Editor::CurrentPosition() const noexcept {
return sel.MainCaret();
}
bool Editor::SelectionEmpty() const noexcept {
return sel.Empty();
}
SelectionPosition Editor::SelectionStart() noexcept {
return sel.RangeMain().Start();
}
SelectionPosition Editor::SelectionEnd() noexcept {
return sel.RangeMain().End();
}
void Editor::SetRectangularRange() {
if (sel.IsRectangular()) {
const int xAnchor = XFromPosition(sel.Rectangular().anchor);
int xCaret = XFromPosition(sel.Rectangular().caret);
if (sel.selType == Selection::SelTypes::thin) {
xCaret = xAnchor;
}
const Sci::Line lineAnchorRect =
pdoc->SciLineFromPosition(sel.Rectangular().anchor.Position());
const Sci::Line lineCaret =
pdoc->SciLineFromPosition(sel.Rectangular().caret.Position());
const int increment = (lineCaret > lineAnchorRect) ? 1 : -1;
const AutoSurface surface(this);
for (Sci::Line line = lineAnchorRect; line != lineCaret + increment; line += increment) {
SelectionRange range(
view.SPositionFromLineX(surface, *this, line, xCaret, vs),
view.SPositionFromLineX(surface, *this, line, xAnchor, vs));
if (!FlagSet(virtualSpaceOptions, VirtualSpace::RectangularSelection))
range.ClearVirtualSpace();
if (line == lineAnchorRect)
sel.SetSelection(range);
else
sel.AddSelectionWithoutTrim(range);
}
}
}
void Editor::ThinRectangularRange() {
if (sel.IsRectangular()) {
sel.selType = Selection::SelTypes::thin;
if (sel.Rectangular().caret < sel.Rectangular().anchor) {
sel.Rectangular() = SelectionRange(sel.Range(sel.Count() - 1).caret, sel.Range(0).anchor);
} else {
sel.Rectangular() = SelectionRange(sel.Range(sel.Count() - 1).anchor, sel.Range(0).caret);
}
SetRectangularRange();
}
}
void Editor::InvalidateSelection(SelectionRange newMain, bool invalidateWholeSelection) noexcept {
if (sel.Count() > 1 || !(sel.RangeMain().anchor == newMain.anchor) || sel.IsRectangular()) {
invalidateWholeSelection = true;
}
Sci::Position firstAffected = std::min(sel.RangeMain().Start().Position(), newMain.Start().Position());
// +1 for lastAffected ensures caret repainted
Sci::Position lastAffected = std::max(newMain.caret.Position() + 1, newMain.anchor.Position());
lastAffected = std::max(lastAffected, sel.RangeMain().End().Position());
if (invalidateWholeSelection) {
for (size_t r = 0; r < sel.Count(); r++) {
firstAffected = std::min(firstAffected, sel.Range(r).caret.Position());
firstAffected = std::min(firstAffected, sel.Range(r).anchor.Position());
lastAffected = std::max(lastAffected, sel.Range(r).caret.Position() + 1);
lastAffected = std::max(lastAffected, sel.Range(r).anchor.Position());
}
}
ContainerNeedsUpdate(Update::Selection);
InvalidateRange(firstAffected, lastAffected);
}
void Editor::InvalidateWholeSelection() noexcept {
InvalidateSelection(sel.RangeMain(), true);
}
/* For Line selection - the anchor and caret are always
at the beginning and end of the region lines. */
SelectionRange Editor::LineSelectionRange(SelectionPosition currentPos_, SelectionPosition anchor_, bool withEOL) const noexcept {
if (currentPos_ >= anchor_) {
anchor_ = SelectionPosition(
pdoc->LineStart(pdoc->SciLineFromPosition(anchor_.Position())));
const Sci::Line endLine = pdoc->SciLineFromPosition(currentPos_.Position());
currentPos_ = SelectionPosition(
withEOL ? pdoc->LineStart(endLine + 1) : pdoc->LineEnd(endLine));
} else {
currentPos_ = SelectionPosition(
pdoc->LineStart(pdoc->SciLineFromPosition(currentPos_.Position())));
const Sci::Line endLine = pdoc->SciLineFromPosition(anchor_.Position());
anchor_ = SelectionPosition(
withEOL ? pdoc->LineStart(endLine + 1) : pdoc->LineEnd(endLine));
}
return SelectionRange(currentPos_, anchor_);
}
void Editor::SetSelection(SelectionPosition currentPos_, SelectionPosition anchor_) {
currentPos_ = ClampPositionIntoDocument(currentPos_);
anchor_ = ClampPositionIntoDocument(anchor_);
const Sci::Line currentLine = pdoc->SciLineFromPosition(currentPos_.Position());
SelectionRange rangeNew(currentPos_, anchor_);
if (sel.selType == Selection::SelTypes::lines) {
rangeNew = LineSelectionRange(currentPos_, anchor_);
}
if (sel.Count() > 1 || !(sel.RangeMain() == rangeNew)) {
InvalidateSelection(rangeNew);
}
sel.RangeMain() = rangeNew;
SetRectangularRange();
ClaimSelection();
SetHoverIndicatorPosition(sel.MainCaret());
if (marginView.highlightDelimiter.NeedsDrawing(currentLine)) {
RedrawSelMargin();
}
QueueIdleWork(WorkItems::updateUI);
}
void Editor::SetSelection(Sci::Position currentPos_, Sci::Position anchor_) {
SetSelection(SelectionPosition(currentPos_), SelectionPosition(anchor_));
}
// Just move the caret on the main selection
void Editor::SetSelection(SelectionPosition currentPos_) {
currentPos_ = ClampPositionIntoDocument(currentPos_);
const Sci::Line currentLine = pdoc->SciLineFromPosition(currentPos_.Position());
if (sel.Count() > 1 || !(sel.RangeMain().caret == currentPos_)) {
InvalidateSelection(SelectionRange(currentPos_));
}
if (sel.IsRectangular()) {
sel.Rectangular() =
SelectionRange(SelectionPosition(currentPos_), sel.Rectangular().anchor);
SetRectangularRange();
} else if (sel.selType == Selection::SelTypes::lines) {
sel.RangeMain() = LineSelectionRange(currentPos_, sel.RangeMain().anchor);
} else {
sel.RangeMain() =
SelectionRange(SelectionPosition(currentPos_), sel.RangeMain().anchor);
}
ClaimSelection();
SetHoverIndicatorPosition(sel.MainCaret());
if (marginView.highlightDelimiter.NeedsDrawing(currentLine)) {
RedrawSelMargin();
}
QueueIdleWork(WorkItems::updateUI);
}
void Editor::SetEmptySelection(SelectionPosition currentPos_) {
const Sci::Line currentLine = pdoc->SciLineFromPosition(currentPos_.Position());
const SelectionRange rangeNew(ClampPositionIntoDocument(currentPos_));
if (sel.Count() > 1 || !(sel.RangeMain() == rangeNew)) {
InvalidateSelection(rangeNew);
}
sel.Clear();
sel.RangeMain() = rangeNew;
SetRectangularRange();
ClaimSelection();
SetHoverIndicatorPosition(sel.MainCaret());
if (marginView.highlightDelimiter.NeedsDrawing(currentLine)) {
RedrawSelMargin();
}
QueueIdleWork(WorkItems::updateUI);
}
void Editor::SetEmptySelection(Sci::Position currentPos_) {
SetEmptySelection(SelectionPosition(currentPos_));
}
void Editor::MultipleSelectAdd(AddNumber addNumber) {
if (SelectionEmpty() || !multipleSelection) {
// Select word at caret
const Sci::Position startWord = pdoc->ExtendWordSelect(sel.MainCaret(), -1, true);
const Sci::Position endWord = pdoc->ExtendWordSelect(startWord, 1, true);
TrimAndSetSelection(endWord, startWord);
} else {
if (!pdoc->HasCaseFolder())
pdoc->SetCaseFolder(CaseFolderForEncoding());
const Range rangeMainSelection(sel.RangeMain().Start().Position(), sel.RangeMain().End().Position());
const std::string selectedText = RangeText(rangeMainSelection.start, rangeMainSelection.end);
const Range rangeTarget(targetRange.start.Position(), targetRange.end.Position());
std::vector<Range> searchRanges;
// Search should be over the target range excluding the current selection so
// may need to search 2 ranges, after the selection then before the selection.
if (rangeTarget.Overlaps(rangeMainSelection)) {
// Common case is that the selection is completely within the target but
// may also have overlap at start or end.
if (rangeMainSelection.end < rangeTarget.end)
searchRanges.emplace_back(rangeMainSelection.end, rangeTarget.end);
if (rangeTarget.start < rangeMainSelection.start)
searchRanges.emplace_back(rangeTarget.start, rangeMainSelection.start);
} else {
// No overlap
searchRanges.push_back(rangeTarget);
}
for (const auto & range : searchRanges) {
Sci::Position searchStart = range.start;
const Sci::Position searchEnd = range.end;
for (;;) {
Sci::Position lengthFound = selectedText.length();
const Sci::Position pos = pdoc->FindText(searchStart, searchEnd,
selectedText.c_str(), searchFlags, &lengthFound);
if (pos >= 0) {
sel.AddSelection(SelectionRange(pos + lengthFound, pos));
ContainerNeedsUpdate(Update::Selection);
ScrollRange(sel.RangeMain());
Redraw();
if (addNumber == AddNumber::one)
return;
searchStart = pos + lengthFound;
} else {
break;
}
}
}
}
}
bool Editor::RangeContainsProtected(Sci::Position start, Sci::Position end) const noexcept {
if (vs.ProtectionActive()) {
if (start > end) {
std::swap(start, end);
}
for (Sci::Position pos = start; pos < end; pos++) {
if (vs.styles[pdoc->StyleIndexAt(pos)].IsProtected())
return true;
}
}
return false;
}
bool Editor::SelectionContainsProtected() const noexcept {
for (size_t r = 0; r < sel.Count(); r++) {
if (RangeContainsProtected(sel.Range(r).Start().Position(),
sel.Range(r).End().Position())) {
return true;
}
}
return false;
}
/**
* Asks document to find a good position and then moves out of any invisible positions.
*/
Sci::Position Editor::MovePositionOutsideChar(Sci::Position pos, Sci::Position moveDir, bool checkLineEnd) const noexcept {
return MovePositionOutsideChar(SelectionPosition(pos), moveDir, checkLineEnd).Position();
}
SelectionPosition Editor::MovePositionOutsideChar(SelectionPosition pos, Sci::Position moveDir, bool checkLineEnd) const noexcept {
const Sci::Position posMoved = pdoc->MovePositionOutsideChar(pos.Position(), moveDir, checkLineEnd);
if (posMoved != pos.Position())
pos.SetPosition(posMoved);
if (vs.ProtectionActive()) {
if (moveDir > 0) {
if ((pos.Position() > 0) && vs.styles[pdoc->StyleIndexAt(pos.Position() - 1)].IsProtected()) {
while ((pos.Position() < pdoc->LengthNoExcept()) &&
(vs.styles[pdoc->StyleIndexAt(pos.Position())].IsProtected()))
pos.Add(1);
}
} else if (moveDir < 0) {
if (vs.styles[pdoc->StyleIndexAt(pos.Position())].IsProtected()) {
while ((pos.Position() > 0) &&
(vs.styles[pdoc->StyleIndexAt(pos.Position() - 1)].IsProtected()))
pos.Add(-1);
}
}
}
return pos;
}
void Editor::MovedCaret(SelectionPosition newPos, SelectionPosition previousPos,
bool ensureVisible, CaretPolicies policies) {
const Sci::Line currentLine = pdoc->SciLineFromPosition(newPos.Position());
if (ensureVisible) {
// In case in need of wrapping to ensure DisplayFromDoc works.
if (currentLine >= wrapPending.start) {
if (WrapLines(WrapScope::wsAll)) {
Redraw();
}
}
const XYScrollPosition newXY = XYScrollToMakeVisible(
SelectionRange(posDrag.IsValid() ? posDrag : newPos), XYScrollOptions::all, policies);
if (previousPos.IsValid() && (newXY.xOffset == xOffset)) {
// simple vertical scroll then invalidate
ScrollTo(newXY.topLine);
InvalidateSelection(SelectionRange(previousPos), true);
} else {
SetXYScroll(newXY);
}
}
ShowCaretAtCurrentPosition();
NotifyCaretMove();
ClaimSelection();
SetHoverIndicatorPosition(sel.MainCaret());
QueueIdleWork(WorkItems::updateUI);
if (marginView.highlightDelimiter.NeedsDrawing(currentLine)) {
RedrawSelMargin();
}
}
void Editor::MovePositionTo(SelectionPosition newPos, Selection::SelTypes selt, bool ensureVisible) {
const SelectionPosition spCaret = ((sel.Count() == 1) && sel.Empty()) ?
sel.Last() : SelectionPosition(Sci::invalidPosition);
const Sci::Position delta = newPos.Position() - sel.MainCaret();
newPos = ClampPositionIntoDocument(newPos);
newPos = MovePositionOutsideChar(newPos, delta);
if (!multipleSelection && sel.IsRectangular() && (selt == Selection::SelTypes::stream)) {
// Can't turn into multiple selection so clear additional selections
InvalidateSelection(SelectionRange(newPos), true);
sel.DropAdditionalRanges();
}
if (!sel.IsRectangular() && (selt == Selection::SelTypes::rectangle)) {
// Switching to rectangular
InvalidateSelection(sel.RangeMain(), false);
const SelectionRange rangeMain = sel.RangeMain();
sel.Clear();
sel.Rectangular() = rangeMain;
}
if (selt != Selection::SelTypes::none) {
sel.selType = selt;
}
if (selt != Selection::SelTypes::none || sel.MoveExtends()) {
SetSelection(newPos);
} else {
SetEmptySelection(newPos);
}
MovedCaret(newPos, spCaret, ensureVisible, caretPolicies);
}
void Editor::MovePositionTo(Sci::Position newPos, Selection::SelTypes selt, bool ensureVisible) {
MovePositionTo(SelectionPosition(newPos), selt, ensureVisible);
}
SelectionPosition Editor::MovePositionSoVisible(SelectionPosition pos, int moveDir) const noexcept {
pos = ClampPositionIntoDocument(pos);
pos = MovePositionOutsideChar(pos, moveDir);
const Sci::Line lineDoc = pdoc->SciLineFromPosition(pos.Position());
if (pcs->GetVisible(lineDoc)) {
return pos;
} else {
Sci::Line lineDisplay = pcs->DisplayFromDoc(lineDoc);
if (moveDir > 0) {
// lineDisplay is already line before fold as lines in fold use display line of line after fold
lineDisplay = std::clamp<Sci::Line>(lineDisplay, 0, pcs->LinesDisplayed());
return SelectionPosition(
pdoc->LineStart(pcs->DocFromDisplay(lineDisplay)));
} else {
lineDisplay = std::clamp<Sci::Line>(lineDisplay - 1, 0, pcs->LinesDisplayed());
return SelectionPosition(
pdoc->LineEnd(pcs->DocFromDisplay(lineDisplay)));
}
}
}
SelectionPosition Editor::MovePositionSoVisible(Sci::Position pos, int moveDir) const noexcept {
return MovePositionSoVisible(SelectionPosition(pos), moveDir);
}
Point Editor::PointMainCaret() {
return LocationFromPosition(sel.RangeMain().caret);
}
/**
* Choose the x position that the caret will try to stick to
* as it moves up and down.
*/
void Editor::SetLastXChosen() {
const Point pt = PointMainCaret();
lastXChosen = static_cast<int>(pt.x) + xOffset;
}
void Editor::ScrollTo(Sci::Line line, bool moveThumb) {
const Sci::Line topLineNew = std::clamp<Sci::Line>(line, 0, MaxScrollPos());
if (topLineNew != topLine) {
// Try to optimise small scrolls
#ifndef UNDER_CE
const Sci::Line linesToMove = topLine - topLineNew;
const bool performBlit = (std::abs(linesToMove) <= 10) && (paintState == PaintState::notPainting);
willRedrawAll = !performBlit;
#endif
SetTopLine(topLineNew);
// Optimize by styling the view as this will invalidate any needed area
// which could abort the initial paint if discovered later.
StyleAreaBounded(GetClientRectangle(), true);
#ifndef UNDER_CE
// Perform redraw rather than scroll if many lines would be redrawn anyway.
if (performBlit) {
ScrollText(linesToMove);
} else {
Redraw();
}
willRedrawAll = false;
#else
Redraw();
#endif
if (moveThumb) {
SetVerticalScrollPos();
}
}
}
void Editor::ScrollText(Sci::Line /* linesToMove */) {
//Platform::DebugPrintf("Editor::ScrollText %d\n", linesToMove);
Redraw();
}
void Editor::HorizontalScrollTo(int xPos) {
//Platform::DebugPrintf("HorizontalScroll %d\n", xPos);
if (xPos < 0)
xPos = 0;
if (!Wrapping() && (xOffset != xPos)) {
xOffset = xPos;
ContainerNeedsUpdate(Update::HScroll);
SetHorizontalScrollPos();
RedrawRect(GetClientRectangle());
}
}
void Editor::VerticalCentreCaret() {
const Sci::Line lineDoc =
pdoc->SciLineFromPosition(sel.IsRectangular() ? sel.Rectangular().caret.Position() : sel.MainCaret());
const Sci::Line lineDisplay = pcs->DisplayFromDoc(lineDoc);
const Sci::Line newTop = lineDisplay - (LinesOnScreen() / 2);
if (topLine != newTop) {
SetTopLine(newTop > 0 ? newTop : 0);
SetVerticalScrollPos();
RedrawRect(GetClientRectangle());
}
}
void Editor::MoveSelectedLines(int lineDelta) {
if (sel.IsRectangular()) {
return;
}
// if selection doesn't start at the beginning of the line, set the new start
Sci::Position selectionStart = SelectionStart().Position();
const Sci::Line startLine = pdoc->SciLineFromPosition(selectionStart);
const Sci::Position beginningOfStartLine = pdoc->LineStart(startLine);
selectionStart = beginningOfStartLine;
// if selection doesn't end at the beginning of a line greater than that of the start,
// then set it at the beginning of the next one
Sci::Position selectionEnd = SelectionEnd().Position();
const Sci::Line endLine = pdoc->SciLineFromPosition(selectionEnd);
const Sci::Position beginningOfEndLine = pdoc->LineStart(endLine);
bool appendEol = false;
if (selectionEnd > beginningOfEndLine
|| selectionStart == selectionEnd) {
selectionEnd = pdoc->LineStart(endLine + 1);
appendEol = (selectionEnd == pdoc->LengthNoExcept() && pdoc->SciLineFromPosition(selectionEnd) == endLine);
}
// if there's nowhere for the selection to move
// (i.e. at the beginning going up or at the end going down),
// stop it right there!
if ((selectionStart == 0 && lineDelta < 0)
|| (selectionEnd == pdoc->LengthNoExcept() && lineDelta > 0)
|| selectionStart == selectionEnd) {
return;
}
const UndoGroup ug(pdoc);
if (lineDelta > 0 && selectionEnd == pdoc->LineStart(pdoc->LinesTotal() - 1)) {
SetSelection(pdoc->MovePositionOutsideChar(selectionEnd - 1, -1), selectionEnd);
ClearSelection();
selectionEnd = CurrentPosition();
}
SetSelection(selectionStart, selectionEnd);
const std::string selectedText = RangeText(selectionStart, selectionEnd);
const Point currentLocation = LocationFromPosition(CurrentPosition());
const Sci::Line currentLine = LineFromLocation(currentLocation);
if (appendEol)
SetSelection(pdoc->MovePositionOutsideChar(selectionStart - 1, -1), selectionEnd);
ClearSelection();
const std::string_view eol = pdoc->EOLString();
if (currentLine + lineDelta >= pdoc->LinesTotal())
pdoc->InsertString(pdoc->LengthNoExcept(), eol);
GoToLine(currentLine + lineDelta);
Sci::Position selectionLength = pdoc->InsertString(CurrentPosition(), selectedText);
if (appendEol) {
const Sci::Position lengthInserted = pdoc->InsertString(CurrentPosition() + selectionLength, eol);
selectionLength += lengthInserted;
}
SetSelection(CurrentPosition(), CurrentPosition() + selectionLength);
}
void Editor::MoveSelectedLinesUp() {
MoveSelectedLines(-1);
}
void Editor::MoveSelectedLinesDown() {
MoveSelectedLines(1);
}
void Editor::MoveCaretInsideView(bool ensureVisible) {
const PRectangle rcClient = GetTextRectangle();
const Point pt = PointMainCaret();
if (pt.y < rcClient.top) {
MovePositionTo(SPositionFromLocation(
Point::FromInts(lastXChosen - xOffset, static_cast<int>(rcClient.top)),
false, false, UserVirtualSpace()),
Selection::SelTypes::none, ensureVisible);
} else if ((pt.y + vs.lineHeight - 1) > rcClient.bottom) {
const ptrdiff_t yOfLastLineFullyDisplayed = static_cast<ptrdiff_t>(rcClient.top) + (LinesOnScreen() - 1) * vs.lineHeight;
MovePositionTo(SPositionFromLocation(
Point::FromInts(lastXChosen - xOffset, static_cast<int>(rcClient.top + yOfLastLineFullyDisplayed)),
false, false, UserVirtualSpace()),
Selection::SelTypes::none, ensureVisible);
}
}
Sci::Line Editor::DisplayFromPosition(Sci::Position pos) {
const AutoSurface surface(this);
return view.DisplayFromPosition(surface, *this, pos, vs);
}
/**
* Ensure the caret is reasonably visible in context.
*
Caret policy in Scintilla
If slop is set, we can define a slop value.
This value defines an unwanted zone (UZ) where the caret is... unwanted.
This zone is defined as a number of pixels near the vertical margins,
and as a number of lines near the horizontal margins.
By keeping the caret away from the edges, it is seen within its context,
so it is likely that the identifier that the caret is on can be completely seen,
and that the current line is seen with some of the lines following it which are
often dependent on that line.
If strict is set, the policy is enforced... strictly.
The caret is centred on the display if slop is not set,
and cannot go in the UZ if slop is set.
If jumps is set, the display is moved more energetically
so the caret can move in the same direction longer before the policy is applied again.
'3UZ' notation is used to indicate three time the size of the UZ as a distance to the margin.
If even is not set, instead of having symmetrical UZs,
the left and bottom UZs are extended up to right and top UZs respectively.
This way, we favour the displaying of useful information: the beginning of lines,
where most code reside, and the lines after the caret, eg. the body of a function.
| | | | |
slop | strict | jumps | even | Caret can go to the margin | When reaching limit (caret going out of
| | | | | visibility or going into the UZ) display is...
-----+--------+-------+------+--------------------------------------------+--------------------------------------------------------------
0 | 0 | 0 | 0 | Yes | moved to put caret on top/on right
0 | 0 | 0 | 1 | Yes | moved by one position
0 | 0 | 1 | 0 | Yes | moved to put caret on top/on right
0 | 0 | 1 | 1 | Yes | centred on the caret
0 | 1 | - | 0 | Caret is always on top/on right of display | -
0 | 1 | - | 1 | No, caret is always centred | -
1 | 0 | 0 | 0 | Yes | moved to put caret out of the asymmetrical UZ
1 | 0 | 0 | 1 | Yes | moved to put caret out of the UZ
1 | 0 | 1 | 0 | Yes | moved to put caret at 3UZ of the top or right margin
1 | 0 | 1 | 1 | Yes | moved to put caret at 3UZ of the margin
1 | 1 | - | 0 | Caret is always at UZ of top/right margin | -
1 | 1 | 0 | 1 | No, kept out of UZ | moved by one position
1 | 1 | 1 | 1 | No, kept out of UZ | moved to put caret at 3UZ of the margin
*/
Editor::XYScrollPosition Editor::XYScrollToMakeVisible(SelectionRange range, const XYScrollOptions options, CaretPolicies policies) {
const PRectangle rcClient = GetTextRectangle();
const Point ptOrigin = GetVisibleOriginInMain();
const Point pt = LocationFromPosition(range.caret) + ptOrigin;
const Point ptAnchor = LocationFromPosition(range.anchor) + ptOrigin;
const Point ptBottomCaret(pt.x, pt.y + vs.lineHeight - 1);
XYScrollPosition newXY(xOffset, topLine);
if (rcClient.Empty()) {
return newXY;
}
// Vertical positioning
if (FlagSet(options, XYScrollOptions::vertical)
&& (pt.y < rcClient.top || ptBottomCaret.y >= rcClient.bottom || FlagSet(policies.y.policy, CaretPolicy::Strict))) {
const Sci::Line lineCaret = DisplayFromPosition(range.caret.Position());
const Sci::Line linesOnScreen = LinesOnScreen();
const Sci::Line halfScreen = std::max<Sci::Line>(linesOnScreen - 1, 2) / 2;
const bool bSlop = FlagSet(policies.y.policy, CaretPolicy::Slop);
const bool bStrict = FlagSet(policies.y.policy, CaretPolicy::Strict);
const bool bJump = FlagSet(policies.y.policy, CaretPolicy::Jumps);
const bool bEven = FlagSet(policies.y.policy, CaretPolicy::Even);
// It should be possible to scroll the window to show the caret,
// but this fails to remove the caret on GTK
if (bSlop) { // A margin is defined
Sci::Line yMoveT;
Sci::Line yMoveB;
if (bStrict) {
Sci::Line yMarginT;
Sci::Line yMarginB;
if (!FlagSet(options, XYScrollOptions::useMargin)) {
// In drag mode, avoid moves
// otherwise, a double click will select several lines.
yMarginT = yMarginB = 0;
} else {
// yMarginT must equal to caretYSlop, with a minimum of 1 and
// a maximum of slightly less than half the height of the text area.
yMarginT = std::clamp<Sci::Line>(policies.y.slop, 1, halfScreen);
if (bEven) {
yMarginB = yMarginT;
} else {
yMarginB = linesOnScreen - yMarginT - 1;
}
}
yMoveT = yMarginT;
if (bEven) {
if (bJump) {
yMoveT = std::clamp<Sci::Line>(policies.y.slop * 3, 1, halfScreen);
}
yMoveB = yMoveT;
} else {
yMoveB = linesOnScreen - yMoveT - 1;
}
if (lineCaret < topLine + yMarginT) {
// Caret goes too high
newXY.topLine = lineCaret - yMoveT;
} else if (lineCaret > topLine + linesOnScreen - 1 - yMarginB) {
// Caret goes too low
newXY.topLine = lineCaret - linesOnScreen + 1 + yMoveB;
}
} else { // Not strict
yMoveT = bJump ? policies.y.slop * 3 : policies.y.slop;
yMoveT = std::clamp<Sci::Line>(yMoveT, 1, halfScreen);
if (bEven) {
yMoveB = yMoveT;
} else {
yMoveB = linesOnScreen - yMoveT - 1;
}
if (lineCaret < topLine) {
// Caret goes too high
newXY.topLine = lineCaret - yMoveT;
} else if (lineCaret > topLine + linesOnScreen - 1) {
// Caret goes too low
newXY.topLine = lineCaret - linesOnScreen + 1 + yMoveB;
}
}
} else { // No slop
if (!bStrict && !bJump) {
// Minimal move
if (lineCaret < topLine) {
// Caret goes too high
newXY.topLine = lineCaret;
} else if (lineCaret > topLine + linesOnScreen - 1) {
// Caret goes too low
if (bEven) {
newXY.topLine = lineCaret - linesOnScreen + 1;
} else {
newXY.topLine = lineCaret;
}
}
} else { // Strict or going out of display
if (bEven) {
// Always centre caret
newXY.topLine = lineCaret - halfScreen;
} else {
// Always put caret on top of display
newXY.topLine = lineCaret;
}
}
}
if (!(range.caret == range.anchor)) {
const Sci::Line lineAnchor = DisplayFromPosition(range.anchor.Position());
if (lineAnchor < lineCaret) {
// Shift up to show anchor or as much of range as possible
newXY.topLine = std::min(newXY.topLine, lineAnchor);
newXY.topLine = std::max(newXY.topLine, lineCaret - LinesOnScreen());
} else {
// Shift down to show anchor or as much of range as possible
newXY.topLine = std::max(newXY.topLine, lineAnchor - LinesOnScreen());
newXY.topLine = std::min(newXY.topLine, lineCaret);
}
}
newXY.topLine = std::clamp<Sci::Line>(newXY.topLine, 0, MaxScrollPos());
}
// Horizontal positioning
if (FlagSet(options, XYScrollOptions::horizontal) && !Wrapping()) {
const int halfScreen = std::max(static_cast<int>(rcClient.Width()) - 4, 4) / 2;
const bool bSlop = FlagSet(policies.x.policy, CaretPolicy::Slop);
const bool bStrict = FlagSet(policies.x.policy, CaretPolicy::Strict);
const bool bJump = FlagSet(policies.x.policy, CaretPolicy::Jumps);
const bool bEven = FlagSet(policies.x.policy, CaretPolicy::Even);
if (bSlop) { // A margin is defined
int xMoveL;
int xMoveR;
if (bStrict) {
int xMarginL;
int xMarginR;
if (!FlagSet(options, XYScrollOptions::useMargin)) {
// In drag mode, avoid moves unless very near of the margin
// otherwise, a simple click will select text.
xMarginL = xMarginR = 2;
} else {
// xMargin must equal to caretXSlop, with a minimum of 2 and
// a maximum of slightly less than half the width of the text area.
xMarginR = std::clamp(policies.x.slop, 2, halfScreen);
if (bEven) {
xMarginL = xMarginR;
} else {
xMarginL = static_cast<int>(rcClient.Width()) - xMarginR - 4;
}
}
if (bJump && bEven) {
// Jump is used only in even mode
xMoveL = xMoveR = std::clamp(policies.x.slop * 3, 1, halfScreen);
} else {
xMoveL = xMoveR = 0; // Not used, avoid a warning
}
if (pt.x < rcClient.left + xMarginL) {
// Caret is on the left of the display
if (bJump && bEven) {
newXY.xOffset -= xMoveL;
} else {
// Move just enough to allow to display the caret
newXY.xOffset -= static_cast<int>((rcClient.left + xMarginL) - pt.x);
}
} else if (pt.x >= rcClient.right - xMarginR) {
// Caret is on the right of the display
if (bJump && bEven) {
newXY.xOffset += xMoveR;
} else {
// Move just enough to allow to display the caret
newXY.xOffset += static_cast<int>(pt.x - (rcClient.right - xMarginR) + 1);
}
}
} else { // Not strict
xMoveR = bJump ? policies.x.slop * 3 : policies.x.slop;
xMoveR = std::clamp(xMoveR, 1, halfScreen);
if (bEven) {
xMoveL = xMoveR;
} else {
xMoveL = static_cast<int>(rcClient.Width()) - xMoveR - 4;
}
if (pt.x < rcClient.left) {
// Caret is on the left of the display
newXY.xOffset -= xMoveL;
} else if (pt.x >= rcClient.right) {
// Caret is on the right of the display
newXY.xOffset += xMoveR;
}
}
} else { // No slop
if (bStrict ||
(bJump && (pt.x < rcClient.left || pt.x >= rcClient.right))) {
// Strict or going out of display
if (bEven) {
// centre caret
newXY.xOffset += static_cast<int>(pt.x - rcClient.left - halfScreen);
} else {
// Put caret on right
newXY.xOffset += static_cast<int>(pt.x - rcClient.right + 1);
}
} else {
// Move just enough to allow to display the caret
if (pt.x < rcClient.left) {
// Caret is on the left of the display
if (bEven) {
newXY.xOffset -= static_cast<int>(rcClient.left - pt.x);
} else {
newXY.xOffset += static_cast<int>(pt.x - rcClient.right) + 1;
}
} else if (pt.x >= rcClient.right) {
// Caret is on the right of the display
newXY.xOffset += static_cast<int>(pt.x - rcClient.right) + 1;
}
}
}
// In case of a jump (find result) largely out of display, adjust the offset to display the caret
if (pt.x + xOffset < rcClient.left + newXY.xOffset) {
newXY.xOffset = static_cast<int>(pt.x + xOffset - rcClient.left) - 2;
} else if (pt.x + xOffset >= rcClient.right + newXY.xOffset) {
newXY.xOffset = static_cast<int>(pt.x + xOffset - rcClient.right) + 2;
if (vs.IsBlockCaretStyle() || view.imeCaretBlockOverride) {
// Ensure we can see a good portion of the block caret
newXY.xOffset += static_cast<int>(vs.aveCharWidth);
}
}
if (!(range.caret == range.anchor)) {
if (ptAnchor.x < pt.x) {
// Shift to left to show anchor or as much of range as possible
const int maxOffset = static_cast<int>(ptAnchor.x + xOffset - rcClient.left) - 1;
const int minOffset = static_cast<int>(pt.x + xOffset - rcClient.right) + 1;
newXY.xOffset = std::min(newXY.xOffset, maxOffset);
newXY.xOffset = std::max(newXY.xOffset, minOffset);
} else {
// Shift to right to show anchor or as much of range as possible
const int minOffset = static_cast<int>(ptAnchor.x + xOffset - rcClient.right) + 1;
const int maxOffset = static_cast<int>(pt.x + xOffset - rcClient.left) - 1;
newXY.xOffset = std::max(newXY.xOffset, minOffset);
newXY.xOffset = std::min(newXY.xOffset, maxOffset);
}
}
if (newXY.xOffset < 0) {
newXY.xOffset = 0;
}
}
return newXY;
}
void Editor::SetXYScroll(XYScrollPosition newXY) {
if ((newXY.topLine != topLine) || (newXY.xOffset != xOffset)) {
if (newXY.topLine != topLine) {
SetTopLine(newXY.topLine);
SetVerticalScrollPos();
}
if (newXY.xOffset != xOffset) {
xOffset = newXY.xOffset;
ContainerNeedsUpdate(Update::HScroll);
if (newXY.xOffset > 0) {
const PRectangle rcText = GetTextRectangle();
if (horizontalScrollBarVisible &&
rcText.Width() + xOffset > scrollWidth) {
scrollWidth = xOffset + static_cast<int>(rcText.Width());
SetScrollBars();
}
}
SetHorizontalScrollPos();
}
Redraw();
UpdateSystemCaret();
}
}
void Editor::ScrollRange(SelectionRange range) {
SetXYScroll(XYScrollToMakeVisible(range, XYScrollOptions::all, caretPolicies));
}
void Editor::EnsureCaretVisible(bool useMargin, bool vert, bool horiz) {
SetXYScroll(XYScrollToMakeVisible(SelectionRange(posDrag.IsValid() ? posDrag : sel.RangeMain().caret),
(useMargin ? XYScrollOptions::useMargin : XYScrollOptions::none) |
(vert ? XYScrollOptions::vertical : XYScrollOptions::none) |
(horiz ? XYScrollOptions::horizontal : XYScrollOptions::none),
caretPolicies));
}
void Editor::ShowCaretAtCurrentPosition() {
if (hasFocus) {
caret.active = true;
caret.on = true;
FineTickerCancel(TickReason::caret);
if (caret.period > 0)
FineTickerStart(TickReason::caret, caret.period, caret.period / 10);
} else {
caret.active = false;
caret.on = false;
FineTickerCancel(TickReason::caret);
}
InvalidateCaret();
}
void Editor::DropCaret() {
caret.active = false;
FineTickerCancel(TickReason::caret);
InvalidateCaret();
}
void Editor::CaretSetPeriod(int period) {
if (caret.period != period) {
caret.period = period;
caret.on = true;
FineTickerCancel(TickReason::caret);
if ((caret.active) && (caret.period > 0))
FineTickerStart(TickReason::caret, caret.period, caret.period / 10);
InvalidateCaret();
}
}
void Editor::InvalidateCaret() {
if (posDrag.IsValid()) {
InvalidateRange(posDrag.Position(), posDrag.Position() + 1);
} else {
for (size_t r = 0; r < sel.Count(); r++) {
InvalidateRange(sel.Range(r).caret.Position(), sel.Range(r).caret.Position() + 1);
}
}
UpdateSystemCaret();
}
void Editor::NotifyCaretMove() noexcept {
}
void Editor::UpdateSystemCaret() {
}
bool Editor::Wrapping() const noexcept {
return vs.wrap.state != Wrap::None;
}
void Editor::NeedWrapping(Sci::Line docLineStart, Sci::Line docLineEnd, bool invalidate) noexcept {
//Platform::DebugPrintf("\nNeedWrapping: %0d..%0d\n", docLineStart, docLineEnd);
if (wrapPending.AddRange(docLineStart, docLineEnd) && invalidate) {
view.llc.Invalidate(LineLayout::ValidLevel::positions);
}
// Wrap lines during idle.
if (Wrapping() && wrapPending.NeedsWrap()) {
SetIdle(true);
}
}
bool Editor::WrapOneLine(Surface *surface, Sci::Position positionInsert) {
const Sci::Line lineToWrap = pdoc->SciLineFromPosition(positionInsert);
const int posInLine = static_cast<int>(positionInsert - pdoc->LineStart(lineToWrap));
LineLayout * const ll = view.RetrieveLineLayout(lineToWrap, *this);
view.LayoutLine(*this, surface, vs, ll, wrapWidth, LayoutLineOption::ManualUpdate, posInLine);
int linesWrapped = ll->lines;
if (vs.annotationVisible != AnnotationVisible::Hidden) {
linesWrapped += pdoc->AnnotationLines(lineToWrap);
}
return pcs->SetHeight(lineToWrap, linesWrapped);
}
void Editor::OnLineWrapped(Sci::Line lineDoc, int linesWrapped) {
if (Wrapping()) {
//printf("%s(%zd, %d)\n", __func__, lineDoc, linesWrapped);
if (vs.annotationVisible != AnnotationVisible::Hidden) {
linesWrapped += pdoc->AnnotationLines(lineDoc);
}
if (pcs->SetHeight(lineDoc, linesWrapped)) {
NeedWrapping(lineDoc, lineDoc + 1, false);
SetScrollBars();
SetVerticalScrollPos();
}
}
}
bool Editor::WrapBlock(Surface *surface, Sci::Line lineToWrap, Sci::Line lineToWrapEnd, Sci::Line &partialLine) {
const size_t linesBeingWrapped = static_cast<size_t>(lineToWrapEnd - lineToWrap);
const std::unique_ptr<int[]> linesAfterWrap = std::make_unique<int[]>(linesBeingWrapped);
// Lines that are less likely to be re-examined should not be read from or written to the cache.
const Sci::Position caretPosition = sel.MainCaret();
const SignificantLines significantLines {
pdoc->SciLineFromPosition(caretPosition),
pcs->DocFromDisplay(topLine),
LinesOnScreen() + 1,
pdoc->LinesTotal(),
pdoc->GetStyleClock(),
view.llc.GetLevel(),
};
const ElapsedPeriod epWrapping;
SetIdleTaskTime(IdleLineWrapTime);
// Wrap all the long lines in the main thread.
// LayoutLine may then multi-thread over segments in each line.
uint32_t wrappedBytesAllThread = 0;
uint32_t wrappedBytesOneThread = 0;
for (size_t index = 0; index < linesBeingWrapped; index++) {
const Sci::Line lineNumber = lineToWrap + index;
const Sci::Position lineStart = pdoc->LineStart(lineNumber);
const Sci::Position lineEnd = pdoc->LineStart(lineNumber + 1);
const int lengthLine = static_cast<int>(lineEnd - lineStart);
LineLayout * const ll = view.llc.Retrieve(lineNumber, significantLines, lengthLine);
if (lineNumber == significantLines.lineCaret) {
ll->caretPosition = static_cast<int>(caretPosition - lineStart);
} else {
ll->caretPosition = 0;
}
const uint64_t wrappedBytes = view.LayoutLine(*this, surface, vs, ll, wrapWidth, LayoutLineOption::ManualUpdate);
wrappedBytesAllThread += wrappedBytes & UINT32_MAX;
wrappedBytesOneThread += wrappedBytes >> 32;
linesAfterWrap[index] = ll->lines;
if (ll->PartialPosition()) {
partialLine = lineNumber;
break;
}
}
const double duration = epWrapping.Duration();
durationWrapOneUnit.AddSample(wrappedBytesAllThread, duration);
durationWrapOneThread.AddSample(wrappedBytesOneThread, duration);
UpdateParallelLayoutThreshold();
bool wrapOccurred = false;
for (size_t index = 0; index < linesBeingWrapped; index++) {
const Sci::Line lineNumber = lineToWrap + index;
int linesWrapped = linesAfterWrap[index];
if (vs.annotationVisible != AnnotationVisible::Hidden) {
linesWrapped += pdoc->AnnotationLines(lineNumber);
}
if (pcs->SetHeight(lineNumber, linesWrapped)) {
wrapOccurred = true;
}
if (lineNumber == partialLine) {
break;
}
wrapPending.Wrapped(lineNumber);
}
return wrapOccurred;
}
// Perform wrapping for a subset of the lines needing wrapping.
// wsAll: wrap all lines which need wrapping in this single call
// wsVisible: wrap currently visible lines
// wsIdle: wrap one page + 100 lines
// Return true if wrapping occurred.
bool Editor::WrapLines(WrapScope ws) {
Sci::Line goodTopLine = topLine;
bool wrapOccurred = false;
const Sci::Line maxEditorLine = pdoc->LinesTotal();
if (!Wrapping()) {
if (wrapWidth != LineLayout::wrapWidthInfinite) {
wrapWidth = LineLayout::wrapWidthInfinite;
for (Sci::Line lineDoc = 0; lineDoc < maxEditorLine; lineDoc++) {
int linesWrapped = 1;
if (vs.annotationVisible != AnnotationVisible::Hidden) {
linesWrapped += pdoc->AnnotationLines(lineDoc);
}
pcs->SetHeight(lineDoc, linesWrapped);
}
wrapOccurred = true;
}
wrapPending.Reset();
} else if (wrapPending.NeedsWrap()) {
wrapPending.start = std::min(wrapPending.start, maxEditorLine);
if (!SetIdle(true)) {
// Idle processing not supported so full wrap required.
ws = WrapScope::wsAll;
}
// Decide where to start wrapping
Sci::Line lineToWrap = wrapPending.start;
Sci::Line lineToWrapEnd = std::min(wrapPending.end, maxEditorLine);
const Sci::Line lineDocTop = pcs->DocFromDisplay(topLine);
const Sci::Line subLineTop = topLine - pcs->DisplayFromDoc(lineDocTop);
if (ws == WrapScope::wsVisible) {
lineToWrap = std::clamp(lineDocTop - 5, wrapPending.start, maxEditorLine);
// Priority wrap to just after visible area.
// Since wrapping could reduce display lines, treat each
// as taking only one display line.
lineToWrapEnd = lineDocTop;
Sci::Line lines = LinesOnScreen() + 1;
const Sci::Line lineLast = pdoc->LineFromPositionAfter(lineToWrap, ActionDuration::InitialBytes);
const Sci::Line maxLine = std::min(lineLast, pcs->LinesInDoc());
while ((lineToWrapEnd < maxLine) && (lines > 0)) {
if (pcs->GetVisible(lineToWrapEnd))
lines--;
lineToWrapEnd++;
}
// .. and if the paint window is outside pending wraps
if ((lineToWrap > wrapPending.end) || (lineToWrapEnd < wrapPending.start)) {
// Currently visible text does not need wrapping
return false;
}
} else if (ws == WrapScope::wsIdle) {
// Try to keep time taken by wrapping reasonable so interaction remains smooth.
constexpr double secondsAllowed = 0.01;
const int actionsInAllowedTime = durationWrapOneUnit.ActionsInAllowedTime(secondsAllowed);
lineToWrapEnd = pdoc->LineFromPositionAfter(lineToWrap, actionsInAllowedTime);
}
const Sci::Line lineEndNeedWrap = std::min(wrapPending.end, maxEditorLine);
lineToWrapEnd = std::min(lineToWrapEnd, lineEndNeedWrap);
Sci::Line partialLine = Sci::invalidPosition;
// Ensure all lines being wrapped are styled.
pdoc->EnsureStyledTo(pdoc->LineStart(lineToWrapEnd));
if (lineToWrap < lineToWrapEnd) {
PRectangle rcTextArea = GetClientRectangle();
rcTextArea.left = static_cast<XYPOSITION>(vs.textStart);
rcTextArea.right -= vs.rightMarginWidth;
wrapWidth = static_cast<int>(rcTextArea.Width());
RefreshStyleData();
const AutoSurface surface(this);
if (surface) {
//Platform::DebugPrintf("Wraplines: scope=%0d need=%0d..%0d perform=%0d..%0d\n", ws, wrapPending.start, wrapPending.end, lineToWrap, lineToWrapEnd);
wrapOccurred = WrapBlock(surface, lineToWrap, lineToWrapEnd, partialLine);
goodTopLine = pcs->DisplayFromDoc(lineDocTop) + std::min(
subLineTop, static_cast<Sci::Line>(pcs->GetHeight(lineDocTop) - 1));
}
}
// If wrapping is done, bring it to resting position
if (partialLine < 0 && wrapPending.start >= lineEndNeedWrap) {
wrapPending.Reset();
}
#if 0
constexpr double scale = 1e3; // 1 KiB in millisecond
printf("%s idle style duration: %f, wrap duration: %f, %f, parallel=%u, %u\n", __func__,
pdoc->durationStyleOneUnit.Duration()*scale,
durationWrapOneUnit.Duration()*scale, durationWrapOneThread.Duration()*scale,
minParallelLayoutLength/1024, maxParallelLayoutLength/1024);
#endif
}
if (wrapOccurred) {
SetScrollBars();
SetTopLine(std::clamp<Sci::Line>(goodTopLine, 0, MaxScrollPos()));
SetVerticalScrollPos();
}
return wrapOccurred;
}
void Editor::LinesJoin() {
if (!RangeContainsProtected(targetRange.start.Position(), targetRange.end.Position())) {
const UndoGroup ug(pdoc);
const Sci::Line line = pdoc->SciLineFromPosition(targetRange.start.Position());
for (Sci::Position pos = pdoc->LineEnd(line); pos < targetRange.end.Position(); pos = pdoc->LineEnd(line)) {
const char chPrev = pdoc->CharAt(pos - 1);
const Sci::Position widthChar = pdoc->LenChar(pos);
targetRange.end.Add(-widthChar);
pdoc->DeleteChars(pos, widthChar);
if (chPrev != ' ') {
// Ensure at least one space separating previous lines
const Sci::Position lengthInserted = pdoc->InsertString(pos, " ", 1);
targetRange.end.Add(lengthInserted);
}
}
}
}
void Editor::LinesSplit(int pixelWidth) {
if (!RangeContainsProtected(targetRange.start.Position(), targetRange.end.Position())) {
if (pixelWidth == 0) {
const PRectangle rcText = GetTextRectangle();
pixelWidth = static_cast<int>(rcText.Width());
}
const Sci::Line lineStart = pdoc->SciLineFromPosition(targetRange.start.Position());
Sci::Line lineEnd = pdoc->SciLineFromPosition(targetRange.end.Position());
const std::string_view eol = pdoc->EOLString();
const UndoGroup ug(pdoc);
for (Sci::Line line = lineStart; line <= lineEnd; line++) {
const AutoSurface surface(this);
if (surface) {
const Sci::Position posLineStart = pdoc->LineStart(line);
LineLayout * const ll = view.RetrieveLineLayout(line, *this);
view.LayoutLine(*this, surface, vs, ll, pixelWidth, LayoutLineOption::AutoUpdate, ll->maxLineLength);
Sci::Position lengthInsertedTotal = 0;
for (int subLine = 1; subLine < ll->lines; subLine++) {
const Sci::Position lengthInserted = pdoc->InsertString(
posLineStart + lengthInsertedTotal + ll->LineStart(subLine), eol);
targetRange.end.Add(lengthInserted);
lengthInsertedTotal += lengthInserted;
}
}
lineEnd = pdoc->SciLineFromPosition(targetRange.end.Position());
}
}
}
void Editor::PaintSelMargin(Surface *surfaceWindow, PRectangle rc) {
if (vs.fixedColumnWidth == 0)
return;
RefreshStyleData();
RefreshPixMaps(surfaceWindow);
// On GTK with Ubuntu overlay scroll bars, the surface may have been finished
// at this point. The Initialised call checks for this case and sets the status
// to be bad which avoids crashes in following calls.
if (!surfaceWindow->Initialised()) {
return;
}
PRectangle rcMargin = GetClientRectangle();
const Point ptOrigin = GetVisibleOriginInMain();
rcMargin.Move(0, -ptOrigin.y);
rcMargin.left = 0;
rcMargin.right = static_cast<XYPOSITION>(vs.fixedColumnWidth);
if (!rc.Intersects(rcMargin))
return;
Surface *surface;
if (view.bufferedDraw) {
surface = marginView.pixmapSelMargin.get();
surface->SetMode(CurrentSurfaceMode());
} else {
surface = surfaceWindow;
}
// Clip vertically to paint area to avoid drawing line numbers
rcMargin.bottom = std::min(rcMargin.bottom, rc.bottom);
rcMargin.top = std::max(rcMargin.top, rc.top);
marginView.PaintMargin(surface, topLine, rc, rcMargin, *this, vs);
if (view.bufferedDraw) {
marginView.pixmapSelMargin->FlushDrawing();
surfaceWindow->Copy(rcMargin, Point(rcMargin.left, rcMargin.top), *marginView.pixmapSelMargin);
}
}
void Editor::RefreshPixMaps(Surface *surfaceWindow) {
view.RefreshPixMaps(surfaceWindow, vs);
marginView.RefreshPixMaps(surfaceWindow, vs);
if (view.bufferedDraw) {
const PRectangle rcClient = GetClientRectangle();
if (!view.pixmapLine) {
view.pixmapLine = surfaceWindow->AllocatePixMap(static_cast<int>(rcClient.Width()), vs.lineHeight);
}
if (!marginView.pixmapSelMargin) {
marginView.pixmapSelMargin = surfaceWindow->AllocatePixMap(vs.fixedColumnWidth,
static_cast<int>(rcClient.Height()));
}
}
}
void Editor::Paint(Surface *surfaceWindow, PRectangle rcArea) {
redrawPendingText = false;
redrawPendingMargin = false;
//Platform::DebugPrintf("Paint:%1d (%.0f,%.0f) ... (%.0f,%.0f)\n",
// paintingAllText, rcArea.left, rcArea.top, rcArea.right, rcArea.bottom);
RefreshStyleData();
if (paintState == PaintState::abandoned)
return; // Scroll bars may have changed so need redraw
RefreshPixMaps(surfaceWindow);
paintAbandonedByStyling = false;
StyleAreaBounded(rcArea, false);
const PRectangle rcClient = GetClientRectangle();
//Platform::DebugPrintf("Client: (%.0f,%.0f) ... (%.0f,%.0f)\n",
// rcClient.left, rcClient.top, rcClient.right, rcClient.bottom);
if (NotifyUpdateUI()) {
RefreshStyleData();
RefreshPixMaps(surfaceWindow);
}
// Wrap the visible lines if needed.
if (WrapLines(WrapScope::wsVisible)) {
// The wrapping process has changed the height of some lines so
// abandon this paint for a complete repaint.
if (AbandonPaint()) {
return;
}
RefreshPixMaps(surfaceWindow); // In case pixmaps invalidated by scrollbar change
}
if (!marginView.pixmapSelPattern->Initialised()) {
// When Direct2D is used, pixmap creation may fail with D2DERR_RECREATE_TARGET so
// abandon this paint to avoid further failures.
// Main drawing surface and pixmaps should be recreated by next paint.
return;
}
if (!view.bufferedDraw)
surfaceWindow->SetClip(rcArea);
if (paintState != PaintState::abandoned) {
if (vs.marginInside) {
PaintSelMargin(surfaceWindow, rcArea);
PRectangle rcRightMargin = rcClient;
rcRightMargin.left = rcRightMargin.right - vs.rightMarginWidth;
if (rcArea.Intersects(rcRightMargin)) {
surfaceWindow->FillRectangle(rcRightMargin, vs.styles[StyleDefault].back);
}
} else { // Else separate view so separate paint event but leftMargin included to allow overlap
PRectangle rcLeftMargin = rcArea;
rcLeftMargin.left = 0;
rcLeftMargin.right = rcLeftMargin.left + vs.leftMarginWidth;
if (rcArea.Intersects(rcLeftMargin)) {
surfaceWindow->FillRectangle(rcLeftMargin, vs.styles[StyleDefault].back);
}
}
}
if (paintState == PaintState::abandoned) {
// Either styling or NotifyUpdateUI noticed that painting is needed
// outside the current painting rectangle
//Platform::DebugPrintf("Abandoning paint\n");
if (Wrapping()) {
if (paintAbandonedByStyling) {
// Styling has spilled over a line end, such as occurs by starting a multiline
// comment. The width of subsequent text may have changed, so rewrap.
NeedWrapping(pcs->DocFromDisplay(topLine));
}
}
if (!view.bufferedDraw)
surfaceWindow->PopClip();
return;
}
view.PaintText(surfaceWindow, *this, vs, rcArea, rcClient);
if (horizontalScrollBarVisible && trackLineWidth && (view.lineWidthMaxSeen > scrollWidth)) {
scrollWidth = view.lineWidthMaxSeen;
if (!FineTickerRunning(TickReason::widen)) {
FineTickerStart(TickReason::widen, 50, 5);
}
}
if (!view.bufferedDraw)
surfaceWindow->PopClip();
NotifyPainted();
}
// This is mostly copied from the Paint method but with some things omitted
// such as the margin markers, line numbers, selection and caret
// Should be merged back into a combined Draw method.
Sci::Position Editor::FormatRange([[maybe_unused]] Scintilla::Message iMessage, Scintilla::uptr_t wParam, Scintilla::sptr_t lParam) {
if (!lParam || !wMain.GetID()) {
return 0;
}
const bool draw = wParam != 0;
const RangeToFormatFull *pfr = static_cast<const RangeToFormatFull *>(PtrFromSPtr(lParam));
const AutoSurface surface(pfr->hdc, this, true);
const AutoSurface surfaceMeasure(pfr->hdcTarget, this, true);
return view.FormatRange(draw, pfr->chrg, pfr->rc, surface, surfaceMeasure, *this, vs);
}
long Editor::TextWidth(uptr_t style, const char *text) {
RefreshStyleData();
const AutoSurface surface(this);
if (surface) {
return std::lround(surface->WidthText(vs.styles[style].font.get(), text));
} else {
return 1;
}
}
// Empty method is overridden on GTK to show / hide scrollbars
void Editor::ReconfigureScrollBars() noexcept {}
void Editor::SetScrollBars() {
RefreshStyleData();
const Sci::Line nMax = MaxScrollPos();
const Sci::Line nPage = LinesOnScreen();
const bool modified = ModifyScrollBars(nMax + nPage - 1, nPage);
if (modified) {
DwellEnd(true);
}
// TODO: ensure always showing as many lines as possible
// May not be, if, for example, window made larger
if (topLine > MaxScrollPos()) {
SetTopLine(std::clamp<Sci::Line>(topLine, 0, MaxScrollPos()));
SetVerticalScrollPos();
Redraw();
}
if (modified) {
if (!AbandonPaint())
Redraw();
}
//Platform::DebugPrintf("end max = %d page = %d\n", nMax, nPage);
}
void Editor::ChangeSize() {
DropGraphics();
SetScrollBars();
if (Wrapping()) {
PRectangle rcTextArea = GetClientRectangle();
rcTextArea.left = static_cast<XYPOSITION>(vs.textStart);
rcTextArea.right -= vs.rightMarginWidth;
if (wrapWidth != rcTextArea.Width()) {
NeedWrapping();
Redraw();
}
}
}
Sci::Position Editor::RealizeVirtualSpace(Sci::Position position, Sci::Position virtualSpace) {
if (virtualSpace > 0) {
const Sci::Line line = pdoc->SciLineFromPosition(position);
const Sci::Position indent = pdoc->GetLineIndentPosition(line);
if (indent == position) {
return pdoc->SetLineIndentation(line, pdoc->GetLineIndentation(line) + virtualSpace);
} else {
const std::string spaceText(virtualSpace, ' ');
const Sci::Position lengthInserted = pdoc->InsertString(position, spaceText);
position += lengthInserted;
}
}
return position;
}
SelectionPosition Editor::RealizeVirtualSpace(SelectionPosition position) {
// Return the new position with no virtual space
return SelectionPosition(RealizeVirtualSpace(position.Position(), position.VirtualSpace()));
}
void Editor::AddChar(char ch) {
const char s[2] = { ch, '\0' };
InsertCharacter(std::string_view(s, 1), CharacterSource::DirectInput);
}
void Editor::FilterSelections() {
if (!additionalSelectionTyping && (sel.Count() > 1)) {
InvalidateWholeSelection();
sel.DropAdditionalRanges();
}
}
// InsertCharacter inserts a character encoded in document code page.
void Editor::InsertCharacter(std::string_view sv, CharacterSource charSource) {
if (sv.empty()) {
return;
}
FilterSelections();
bool handled = false;
bool wrapOccurred = false;
{
const UndoGroup ug(pdoc, (sel.Count() > 1) || !sel.Empty() || inOverstrike);
// enclose selection on typing punctuation, empty selection will be handled in Notification::CharAdded.
char encloseCh = '\0';
if (charSource == CharacterSource::DirectInput && sv.length() == 1 && !sel.Empty() && !sel.IsRectangular()) {
const uint8_t ch = sv[0];
uint32_t index = ch - '\"';
if (index == '{' - '\"' || (index < 63 && (UINT64_C(0x4200000000000061) & (UINT64_C(1) << index)))) {
index = (index + (index >> 5)) & 7;
index = (0x60501204U >> (4*index)) & 15;
if (autoInsertMask & (1U << index)) {
encloseCh = ch + ((41U >> (index*2)) & 3); // 0b101001
}
}
}
// Vector elements point into selection in order to change selection.
std::vector<SelectionRange *> selPtrs;
for (size_t r = 0; r < sel.Count(); r++) {
selPtrs.push_back(&sel.Range(r));
}
// Order selections by position in document.
std::sort(selPtrs.begin(), selPtrs.end(),
[](const SelectionRange *a, const SelectionRange *b) noexcept { return *a < *b; });
// Loop in reverse to avoid disturbing positions of selections yet to be processed.
for (auto rit = selPtrs.rbegin(); rit != selPtrs.rend(); ++rit) {
SelectionRange *currentSel = *rit;
if (!RangeContainsProtected(currentSel->Start().Position(),
currentSel->End().Position())) {
Sci::Position positionInsert = currentSel->Start().Position();
std::string text;
bool forward = false;
if (!currentSel->Empty()) {
const Sci::Position selectionLength = currentSel->Length();
if (selectionLength) {
if (encloseCh) {
forward = currentSel->anchor < currentSel->caret;
text.resize(selectionLength + 2);
text[0] = sv[0];
pdoc->GetCharRange(text.data() + 1, positionInsert, selectionLength);
text[selectionLength + 1] = encloseCh;
}
pdoc->DeleteChars(positionInsert, selectionLength);
currentSel->ClearVirtualSpace();
} else {
// Range is all virtual so collapse to start of virtual space
currentSel->MinimizeVirtualSpace();
}
} else if (inOverstrike) {
if (positionInsert < pdoc->LengthNoExcept()) {
if (!pdoc->IsPositionInLineEnd(positionInsert)) {
pdoc->DelChar(positionInsert);
currentSel->ClearVirtualSpace();
}
}
}
positionInsert = RealizeVirtualSpace(positionInsert, currentSel->caret.VirtualSpace());
if (text.empty()) {
const Sci::Position lengthInserted = pdoc->InsertString(positionInsert, sv);
if (lengthInserted > 0) {
currentSel->caret.SetPosition(positionInsert + lengthInserted);
currentSel->anchor.SetPosition(positionInsert + lengthInserted);
}
} else {
const Sci::Position lengthInserted = pdoc->InsertString(positionInsert, text);
if (lengthInserted > 0) {
handled = true;
if (forward) {
currentSel->caret.SetPosition(positionInsert + lengthInserted - 1);
currentSel->anchor.SetPosition(positionInsert + 1);
} else {
currentSel->caret.SetPosition(positionInsert + 1);
currentSel->anchor.SetPosition(positionInsert + lengthInserted - 1);
}
}
}
currentSel->ClearVirtualSpace();
// If in wrap mode rewrap current line so EnsureCaretVisible has accurate information
if (Wrapping()) {
const AutoSurface surface(this);
if (surface) {
if (WrapOneLine(surface, positionInsert)) {
wrapOccurred = true;
}
}
}
}
}
}
if (wrapOccurred) {
SetScrollBars();
SetVerticalScrollPos();
Redraw();
}
ThinRectangularRange();
// If in wrap mode rewrap current line so EnsureCaretVisible has accurate information
EnsureCaretVisible();
// Avoid blinking during rapid typing:
ShowCaretAtCurrentPosition();
if ((caretSticky == CaretSticky::Off) ||
((caretSticky == CaretSticky::WhiteSpace) && !IsAllSpacesOrTabs(sv))) {
SetLastXChosen();
}
// We don't handle inline IME tentative input characters
if (!handled && charSource != CharacterSource::TentativeInput && sel.Count() == 1) {
int ch = static_cast<unsigned char>(sv[0]);
if (pdoc->dbcsCodePage != CpUtf8) {
if (sv.length() > 1) {
// DBCS code page or DBCS font character set.
ch = (ch << 8) | static_cast<unsigned char>(sv[1]);
}
} else {
if ((ch < 0xC2) || (1 == sv.length())) {
// Handles UTF-8 characters between 0x01 and 0x7F and single byte
// characters when not in UTF-8 mode.
// Also treats \0 and naked trail bytes 0x80 to 0xBF as valid
// characters representing themselves.
} else {
unsigned int utf32[1] = { 0 };
UTF32FromUTF8(sv, utf32, std::size(utf32));
ch = utf32[0];
}
}
NotifyChar(ch, charSource);
}
if (recordingMacro && charSource != CharacterSource::TentativeInput) {
std::string copy(sv); // ensure NUL-terminated
NotifyMacroRecord(Message::ReplaceSel, 0, reinterpret_cast<sptr_t>(copy.data()));
}
}
void Editor::ClearBeforeTentativeStart() {
// Make positions for the first composition string.
FilterSelections();
const UndoGroup ug(pdoc, (sel.Count() > 1) || !sel.Empty() || inOverstrike);
for (size_t r = 0; r < sel.Count(); r++) {
if (!RangeContainsProtected(sel.Range(r).Start().Position(),
sel.Range(r).End().Position())) {
const Sci::Position positionInsert = sel.Range(r).Start().Position();
if (!sel.Range(r).Empty()) {
if (sel.Range(r).Length()) {
pdoc->DeleteChars(positionInsert, sel.Range(r).Length());
sel.Range(r).ClearVirtualSpace();
} else {
// Range is all virtual so collapse to start of virtual space
sel.Range(r).MinimizeVirtualSpace();
}
}
RealizeVirtualSpace(positionInsert, sel.Range(r).caret.VirtualSpace());
sel.Range(r).ClearVirtualSpace();
}
}
}
void Editor::InsertPaste(const char *text, Sci::Position len) {
if (multiPasteMode == MultiPaste::Once) {
SelectionPosition selStart = sel.Start();
selStart = RealizeVirtualSpace(selStart);
const Sci::Position lengthInserted = pdoc->InsertString(selStart.Position(), text, len);
if (lengthInserted > 0) {
SetEmptySelection(selStart.Position() + lengthInserted);
}
} else {
// MultiPaste::Each
for (size_t r = 0; r < sel.Count(); r++) {
if (!RangeContainsProtected(sel.Range(r).Start().Position(),
sel.Range(r).End().Position())) {
Sci::Position positionInsert = sel.Range(r).Start().Position();
if (!sel.Range(r).Empty()) {
if (sel.Range(r).Length()) {
pdoc->DeleteChars(positionInsert, sel.Range(r).Length());
sel.Range(r).ClearVirtualSpace();
} else {
// Range is all virtual so collapse to start of virtual space
sel.Range(r).MinimizeVirtualSpace();
}
}
positionInsert = RealizeVirtualSpace(positionInsert, sel.Range(r).caret.VirtualSpace());
const Sci::Position lengthInserted = pdoc->InsertString(positionInsert, text, len);
if (lengthInserted > 0) {
sel.Range(r).caret.SetPosition(positionInsert + lengthInserted);
sel.Range(r).anchor.SetPosition(positionInsert + lengthInserted);
}
sel.Range(r).ClearVirtualSpace();
}
}
}
}
void Editor::InsertPasteShape(const char *text, Sci::Position len, PasteShape shape) {
std::string convertedText;
if (convertPastes) {
// Convert line endings of the paste into our local line-endings mode
convertedText = Document::TransformLineEnds(text, len, pdoc->eolMode);
len = convertedText.length();
text = convertedText.c_str();
}
if (shape == PasteShape::rectangular) {
PasteRectangular(sel.Start(), text, len);
} else {
if (shape == PasteShape::line) {
const Sci::Position insertPos =
pdoc->LineStart(pdoc->SciLineFromPosition(sel.MainCaret()));
Sci::Position lengthInserted = pdoc->InsertString(insertPos, text, len);
// add the newline if necessary
if ((len > 0) && !IsEOLCharacter(text[len - 1])) {
const std::string_view endline = pdoc->EOLString();
lengthInserted += pdoc->InsertString(insertPos + lengthInserted, endline);
}
if (sel.MainCaret() == insertPos) {
SetEmptySelection(sel.MainCaret() + lengthInserted);
}
} else {
InsertPaste(text, len);
}
}
}
void Editor::ClearSelection(bool retainMultipleSelections) {
if (!sel.IsRectangular() && !retainMultipleSelections)
FilterSelections();
const UndoGroup ug(pdoc);
for (size_t r = 0; r < sel.Count(); r++) {
if (!sel.Range(r).Empty()) {
SelectionRange rangeNew = sel.Range(r);
if (sel.selType == Selection::SelTypes::lines && sel.Count() == 1) {
// remove EOLs
rangeNew = LineSelectionRange(rangeNew.caret, rangeNew.anchor, true);
}
if (!RangeContainsProtected(rangeNew.Start().Position(),
rangeNew.End().Position())) {
pdoc->DeleteChars(rangeNew.Start().Position(),
rangeNew.Length());
sel.Range(r) = SelectionRange(rangeNew.Start());
}
}
}
ThinRectangularRange();
sel.RemoveDuplicates();
ClaimSelection();
SetHoverIndicatorPosition(sel.MainCaret());
}
void Editor::ClearAll() {
{
const UndoGroup ug(pdoc);
if (0 != pdoc->LengthNoExcept()) {
pdoc->DeleteChars(0, pdoc->LengthNoExcept());
}
if (!pdoc->IsReadOnly()) {
pcs->Clear();
pdoc->AnnotationClearAll();
pdoc->EOLAnnotationClearAll();
pdoc->MarginClearAll();
}
}
view.ClearAllTabstops();
sel.Clear();
SetTopLine(0);
SetVerticalScrollPos();
InvalidateStyleRedraw();
}
void Editor::ClearDocumentStyle() {
pdoc->decorations->DeleteLexerDecorations();
const Sci::Position endStyled = pdoc->GetEndStyled();
pdoc->StartStyling(0);
pdoc->SetStyleFor(endStyled, 0);
pcs->ShowAll();
SetAnnotationHeights(0, pdoc->LinesTotal());
pdoc->ClearLevels();
}
void Editor::CopyAllowLine() const {
SelectionText selectedText;
CopySelectionRange(selectedText, true);
CopyToClipboard(selectedText);
}
void Editor::Cut(bool asBinary, bool lineCopy) {
pdoc->CheckReadOnly();
if (!pdoc->IsReadOnly() && !SelectionContainsProtected()) {
if (lineCopy) {
CopyRangeToClipboard(sel.RangeMain().Start().Position(), sel.RangeMain().End().Position(), true);
} else {
Copy(asBinary);
}
ClearSelection();
}
}
void Editor::PasteRectangular(SelectionPosition pos, const char *ptr, Sci::Position len) {
if (pdoc->IsReadOnly() || SelectionContainsProtected()) {
return;
}
sel.Clear();
sel.RangeMain() = SelectionRange(pos);
Sci::Line line = pdoc->SciLineFromPosition(sel.MainCaret());
const UndoGroup ug(pdoc);
sel.RangeMain().caret = RealizeVirtualSpace(sel.RangeMain().caret);
const int xInsert = XFromPosition(sel.RangeMain().caret);
bool prevCr = false;
while ((len > 0) && IsEOLCharacter(ptr[len - 1])) {
len--;
}
for (Sci::Position i = 0; i < len; i++) {
if (IsEOLCharacter(ptr[i])) {
if ((ptr[i] == '\r') || (!prevCr))
line++;
if (line >= pdoc->LinesTotal()) {
const std::string_view eol = pdoc->EOLString();
pdoc->InsertString(pdoc->LengthNoExcept(), eol);
}
// Pad the end of lines with spaces if required
sel.RangeMain().caret.SetPosition(PositionFromLineX(line, xInsert));
if ((XFromPosition(sel.RangeMain().caret) < xInsert) && (i + 1 < len)) {
while (XFromPosition(sel.RangeMain().caret) < xInsert) {
assert(pdoc);
const Sci::Position lengthInserted = pdoc->InsertString(sel.MainCaret(), " ", 1);
sel.RangeMain().caret.Add(lengthInserted);
}
}
prevCr = ptr[i] == '\r';
} else {
const Sci::Position lengthInserted = pdoc->InsertString(sel.MainCaret(), ptr + i, 1);
sel.RangeMain().caret.Add(lengthInserted);
prevCr = false;
}
}
SetEmptySelection(pos);
}
bool Editor::CanPaste() noexcept {
return !pdoc->IsReadOnly() && !SelectionContainsProtected();
}
void Editor::Clear() {
// If multiple selections, don't delete EOLS
if (sel.Empty()) {
bool singleVirtual = false;
if ((sel.Count() == 1) &&
!RangeContainsProtected(sel.MainCaret(), sel.MainCaret() + 1) &&
sel.RangeMain().Start().VirtualSpace()) {
singleVirtual = true;
}
const UndoGroup ug(pdoc, (sel.Count() > 1) || singleVirtual);
for (size_t r = 0; r < sel.Count(); r++) {
const Sci::Position caretPosition = sel.Range(r).caret.Position();
if (!RangeContainsProtected(caretPosition, caretPosition + 1)) {
if (sel.Range(r).Start().VirtualSpace()) {
if (sel.Range(r).anchor < sel.Range(r).caret)
sel.Range(r) = SelectionRange(RealizeVirtualSpace(caretPosition, sel.Range(r).anchor.VirtualSpace()));
else
sel.Range(r) = SelectionRange(RealizeVirtualSpace(caretPosition, sel.Range(r).caret.VirtualSpace()));
}
if ((sel.Count() == 1) || !pdoc->IsPositionInLineEnd(caretPosition)) {
pdoc->DelChar(caretPosition);
sel.Range(r).ClearVirtualSpace();
} // else multiple selection so don't eat line ends
} else {
sel.Range(r).ClearVirtualSpace();
}
}
} else {
ClearSelection();
}
sel.RemoveDuplicates();
ShowCaretAtCurrentPosition(); // Avoid blinking
}
void Editor::SelectAll() {
sel.Clear();
SetSelection(0, pdoc->LengthNoExcept());
Redraw();
}
void Editor::Undo() {
if (pdoc->CanUndo()) {
InvalidateCaret();
const Sci::Position newPos = pdoc->Undo();
if (newPos >= 0)
SetEmptySelection(newPos);
EnsureCaretVisible();
}
}
void Editor::Redo() {
if (pdoc->CanRedo()) {
const Sci::Position newPos = pdoc->Redo();
if (newPos >= 0)
SetEmptySelection(newPos);
EnsureCaretVisible();
}
}
bool Editor::BackspaceUnindent(Sci::Position lineCurrentPos, Sci::Position caretPosition, Sci::Position *posSelect) {
const char chPrev = pdoc->CharAt(caretPosition - 1);
if (!IsSpaceOrTab(chPrev)) {
return false;
}
const Sci::Position column = pdoc->GetColumn(caretPosition);
const int indentation = pdoc->GetLineIndentation(lineCurrentPos);
if (column > 0 && (column <= indentation || chPrev == ' ')) {
const int indentationStep = pdoc->IndentSize();
Sci::Position indentationChange = column % indentationStep;
if (indentationChange == 0) {
indentationChange = indentationStep;
}
if (column <= indentation && (pdoc->backspaceUnindents & 1)) {
//const UndoGroup ugInner(pdoc, !ug.Needed());
*posSelect = pdoc->SetLineIndentation(lineCurrentPos, indentation - indentationChange);
return true;
}
if (indentationChange > 1 && (pdoc->backspaceUnindents & 2)) {
const Sci_Position minPos = std::max(lineCurrentPos, caretPosition - indentationChange);
Sci::Position pos = caretPosition - 1;
while (pos >= minPos && pdoc->CharAt(pos) == ' ') {
--pos;
}
++pos;
if (pos == minPos) {
pdoc->DeleteChars(pos, indentationChange);
*posSelect = pos;
return true;
}
}
}
return false;
}
void Editor::DelCharBack(bool allowLineStartDeletion) {
RefreshStyleData();
if (!sel.IsRectangular())
FilterSelections();
if (sel.IsRectangular())
allowLineStartDeletion = false;
const UndoGroup ug(pdoc, (sel.Count() > 1) || !sel.Empty());
if (sel.Empty()) {
for (size_t r = 0; r < sel.Count(); r++) {
const Sci::Position caretPosition = sel.Range(r).caret.Position();
if (!RangeContainsProtected(caretPosition - 1, caretPosition)) {
if (sel.Range(r).caret.VirtualSpace()) {
sel.Range(r).caret.SetVirtualSpace(sel.Range(r).caret.VirtualSpace() - 1);
sel.Range(r).anchor.SetVirtualSpace(sel.Range(r).caret.VirtualSpace());
} else {
const Sci::Line lineCurrentPos = pdoc->SciLineFromPosition(caretPosition);
if (allowLineStartDeletion || (pdoc->LineStart(lineCurrentPos) != caretPosition)) {
Sci::Position posSelect;
if (BackspaceUnindent(lineCurrentPos, caretPosition, &posSelect)) {
// SetEmptySelection
sel.Range(r) = SelectionRange(posSelect);
} else {
pdoc->DelCharBack(caretPosition);
}
}
}
} else {
sel.Range(r).ClearVirtualSpace();
}
}
ThinRectangularRange();
} else {
ClearSelection();
}
sel.RemoveDuplicates();
ContainerNeedsUpdate(Update::Selection);
// Avoid blinking during rapid typing:
ShowCaretAtCurrentPosition();
}
void Editor::NotifyFocus(bool focus) {
NotificationData scn = {};
scn.nmhdr.code = focus ? Notification::FocusIn : Notification::FocusOut;
NotifyParent(scn);
}
void Editor::SetCtrlID(int identifier) noexcept {
ctrlID = identifier;
}
void Editor::NotifyStyleToNeeded(Sci::Position endStyleNeeded) {
NotificationData scn = {};
scn.nmhdr.code = Notification::StyleNeeded;
scn.position = endStyleNeeded;
NotifyParent(scn);
}
void Editor::NotifyStyleNeeded(Document *, void *, Sci::Position endStyleNeeded) {
NotifyStyleToNeeded(endStyleNeeded);
}
void Editor::NotifyErrorOccurred(Document *, void *, Status status) noexcept {
errorStatus = status;
}
void Editor::NotifyChar(int ch, CharacterSource charSource) noexcept {
NotificationData scn = {};
scn.nmhdr.code = Notification::CharAdded;
scn.ch = ch;
scn.characterSource = charSource;
NotifyParent(scn);
}
void Editor::NotifySavePoint(bool isSavePoint) noexcept {
NotificationData scn = {};
if (isSavePoint) {
scn.nmhdr.code = Notification::SavePointReached;
if (changeHistoryOption != ChangeHistoryOption::Disabled) {
Redraw();
}
} else {
scn.nmhdr.code = Notification::SavePointLeft;
}
NotifyParent(scn);
}
void Editor::NotifyModifyAttempt() noexcept {
NotificationData scn = {};
scn.nmhdr.code = Notification::ModifyAttemptRO;
NotifyParent(scn);
}
void Editor::NotifyDoubleClick(Point pt, KeyMod modifiers) {
NotificationData scn = {};
scn.nmhdr.code = Notification::DoubleClick;
scn.line = LineFromLocation(pt);
scn.position = PositionFromLocation(pt, true);
scn.modifiers = modifiers;
NotifyParent(scn);
}
void Editor::NotifyHotSpotDoubleClicked(Sci::Position position, KeyMod modifiers) noexcept {
NotificationData scn = {};
scn.nmhdr.code = Notification::HotSpotDoubleClick;
scn.position = position;
scn.modifiers = modifiers;
NotifyParent(scn);
}
void Editor::NotifyHotSpotClicked(Sci::Position position, KeyMod modifiers) noexcept {
NotificationData scn = {};
scn.nmhdr.code = Notification::HotSpotClick;
scn.position = position;
scn.modifiers = modifiers;
NotifyParent(scn);
}
void Editor::NotifyHotSpotReleaseClick(Sci::Position position, KeyMod modifiers) noexcept {
NotificationData scn = {};
scn.nmhdr.code = Notification::HotSpotReleaseClick;
scn.position = position;
scn.modifiers = modifiers;
NotifyParent(scn);
}
bool Editor::NotifyUpdateUI() noexcept {
if (needUpdateUI != Update::None) {
NotificationData scn = {};
scn.nmhdr.code = Notification::UpdateUI;
scn.updated = needUpdateUI;
scn.listType = inOverstrike;
NotifyParent(scn);
needUpdateUI = Update::None;
return true;
}
return false;
}
void Editor::NotifyPainted() noexcept {
#if 0 // avoid very frequent notification
NotificationData scn = {};
scn.nmhdr.code = Notification::Painted;
NotifyParent(scn);
#endif
}
void Editor::NotifyIndicatorClick(bool click, Sci::Position position, KeyMod modifiers) noexcept {
const int mask = pdoc->decorations->AllOnFor(position);
if ((click && mask) || pdoc->decorations->ClickNotified()) {
NotificationData scn = {};
pdoc->decorations->SetClickNotified(click);
scn.nmhdr.code = click ? Notification::IndicatorClick : Notification::IndicatorRelease;
scn.modifiers = modifiers;
scn.position = position;
NotifyParent(scn);
}
}
bool Editor::NotifyMarginClick(Point pt, KeyMod modifiers) {
const int marginClicked = vs.MarginFromLocation(pt);
if ((marginClicked >= 0) && vs.ms[marginClicked].sensitive) {
const Sci::Position position = pdoc->LineStart(LineFromLocation(pt));
if ((vs.ms[marginClicked].mask & MaskFolders) && (FlagSet(foldAutomatic, AutomaticFold::Click))) {
const bool ctrl = FlagSet(modifiers, KeyMod::Ctrl);
const bool shift = FlagSet(modifiers, KeyMod::Shift);
const Sci::Line lineClick = pdoc->SciLineFromPosition(position);
if (shift && ctrl) {
FoldAll(FoldAction::Toggle);
} else {
const FoldLevel levelClick = pdoc->GetFoldLevel(lineClick);
if (LevelIsHeader(levelClick)) {
if (shift) {
// Ensure all children visible
FoldExpand(lineClick, FoldAction::Expand, levelClick);
} else if (ctrl) {
FoldExpand(lineClick, FoldAction::Toggle, levelClick);
} else {
// Toggle this line
FoldLine(lineClick, FoldAction::Toggle);
}
}
}
return true;
}
NotificationData scn = {};
scn.nmhdr.code = Notification::MarginClick;
scn.modifiers = modifiers;
scn.position = position;
scn.margin = marginClicked;
NotifyParent(scn);
return true;
} else {
return false;
}
}
bool Editor::NotifyMarginRightClick(Point pt, KeyMod modifiers) noexcept {
const int marginRightClicked = vs.MarginFromLocation(pt);
if ((marginRightClicked >= 0) && vs.ms[marginRightClicked].sensitive) {
const Sci::Position position = pdoc->LineStart(LineFromLocation(pt));
NotificationData scn = {};
scn.nmhdr.code = Notification::MarginRightClick;
scn.modifiers = modifiers;
scn.position = position;
scn.margin = marginRightClicked;
NotifyParent(scn);
return true;
} else {
return false;
}
}
void Editor::NotifyNeedShown(Sci::Position pos, Sci::Position len) noexcept {
NotificationData scn = {};
scn.nmhdr.code = Notification::NeedShown;
scn.position = pos;
scn.length = len;
NotifyParent(scn);
}
void Editor::NotifyCodePageChanged(int oldCodePage) noexcept {
NotificationData scn = {};
scn.nmhdr.code = Notification::CodePageChanged;
scn.oldCodePage = oldCodePage;
NotifyParent(scn);
}
void Editor::NotifyDwelling(Point pt, bool state) {
NotificationData scn = {};
scn.nmhdr.code = state ? Notification::DwellStart : Notification::DwellEnd;
scn.position = PositionFromLocation(pt, true);
scn.x = static_cast<int>(pt.x + vs.ExternalMarginWidth());
scn.y = static_cast<int>(pt.y);
NotifyParent(scn);
}
void Editor::NotifyZoom() noexcept {
NotificationData scn = {};
scn.nmhdr.code = Notification::Zoom;
NotifyParent(scn);
}
// Notifications from document
void Editor::NotifyModifyAttempt(Document *, void *) noexcept {
//Platform::DebugPrintf("** Modify Attempt\n");
NotifyModifyAttempt();
}
void Editor::NotifySavePoint(Document *, void *, bool atSavePoint) noexcept {
//Platform::DebugPrintf("** Save Point %s\n", atSavePoint ? "On" : "Off");
NotifySavePoint(atSavePoint);
}
void Editor::CheckModificationForWrap(DocModification mh) {
if (FlagSet(mh.modificationType, ModificationFlags::InsertText | ModificationFlags::DeleteText)) {
view.llc.Invalidate(LineLayout::ValidLevel::checkTextAndStyle);
const Sci::Line lineDoc = pdoc->SciLineFromPosition(mh.position);
const Sci::Line lines = std::max<Sci::Line>(0, mh.linesAdded);
if (Wrapping()) {
NeedWrapping(lineDoc, lineDoc + lines + 1);
}
RefreshStyleData();
// Fix up annotation heights
SetAnnotationHeights(lineDoc, lineDoc + lines + 2);
}
}
namespace {
// Move a position so it is still after the same character as before the insertion.
constexpr Sci::Position MovePositionForInsertion(Sci::Position position, Sci::Position startInsertion, Sci::Position length) noexcept {
if (position > startInsertion) {
return position + length;
}
return position;
}
// Move a position so it is still after the same character as before the deletion if that
// character is still present else after the previous surviving character.
constexpr Sci::Position MovePositionForDeletion(Sci::Position position, Sci::Position startDeletion, Sci::Position length) noexcept {
if (position > startDeletion) {
const Sci::Position endDeletion = startDeletion + length;
if (position > endDeletion) {
return position - length;
} else {
return startDeletion;
}
} else {
return position;
}
}
}
void Editor::NotifyModified(Document *, DocModification mh, void *) {
if (FlagSet(mh.modificationType, ModificationFlags::InsertText | ModificationFlags::DeleteText)) {
ContainerNeedsUpdate(Update::Content);
}
if (paintState == PaintState::painting) {
CheckForChangeOutsidePaint(Range(mh.position, mh.position + mh.length));
}
if (FlagSet(mh.modificationType, ModificationFlags::ChangeLineState)) {
if (paintState == PaintState::painting) {
CheckForChangeOutsidePaint(
Range(mh.position, pdoc->LineStart(mh.line + 1)));
} else {
// Could check that change is before last visible line.
Redraw();
}
}
if (FlagSet(mh.modificationType, ModificationFlags::ChangeTabStops)) {
Redraw();
}
if (FlagSet(mh.modificationType, ModificationFlags::LexerState)) {
if (paintState == PaintState::painting) {
CheckForChangeOutsidePaint(
Range(mh.position, mh.position + mh.length));
} else {
Redraw();
}
}
if (FlagSet(mh.modificationType, ModificationFlags::ChangeStyle | ModificationFlags::ChangeIndicator)) {
if (FlagSet(mh.modificationType, ModificationFlags::ChangeStyle)) {
pdoc->IncrementStyleClock();
}
if (paintState == PaintState::notPainting) {
const Sci::Line lineDocTop = pcs->DocFromDisplay(topLine);
if (mh.position < pdoc->LineStart(lineDocTop)) {
// Styling performed before this view
Redraw();
} else {
InvalidateRange(mh.position, mh.position + mh.length);
}
}
if (FlagSet(mh.modificationType, ModificationFlags::ChangeStyle)) {
view.llc.Invalidate(LineLayout::ValidLevel::checkTextAndStyle);
}
} else {
// Move selection and brace highlights
if (FlagSet(mh.modificationType, ModificationFlags::InsertText)) {
sel.MovePositions(true, mh.position, mh.length);
braces[0] = MovePositionForInsertion(braces[0], mh.position, mh.length);
braces[1] = MovePositionForInsertion(braces[1], mh.position, mh.length);
} else if (FlagSet(mh.modificationType, ModificationFlags::DeleteText)) {
sel.MovePositions(false, mh.position, mh.length);
braces[0] = MovePositionForDeletion(braces[0], mh.position, mh.length);
braces[1] = MovePositionForDeletion(braces[1], mh.position, mh.length);
}
if (FlagSet(mh.modificationType, (ModificationFlags::BeforeInsert | ModificationFlags::BeforeDelete)) && pcs->HiddenLines()) {
// Some lines are hidden so may need shown.
const Sci::Line lineOfPos = pdoc->SciLineFromPosition(mh.position);
Sci::Position endNeedShown = mh.position;
if (FlagSet(mh.modificationType, ModificationFlags::BeforeInsert)) {
if (pdoc->ContainsLineEnd(mh.text, mh.length) && (mh.position != pdoc->LineStart(lineOfPos)))
endNeedShown = pdoc->LineStart(lineOfPos + 1);
} else if (FlagSet(mh.modificationType, ModificationFlags::BeforeDelete)) {
// If the deletion includes any EOL then we extend the need shown area.
endNeedShown = mh.position + mh.length;
Sci::Line lineLast = pdoc->SciLineFromPosition(mh.position + mh.length);
for (Sci::Line line = lineOfPos + 1; line <= lineLast; line++) {
const Sci::Line lineMaxSubord = pdoc->GetLastChild(line);
if (lineLast < lineMaxSubord) {
lineLast = lineMaxSubord;
endNeedShown = pdoc->LineEnd(lineLast);
}
}
}
NeedShown(mh.position, endNeedShown - mh.position);
}
if (mh.linesAdded != 0) {
// Update contraction state for inserted and removed lines
// lineOfPos should be calculated in context of state before modification, shouldn't it
Sci::Line lineOfPos = pdoc->SciLineFromPosition(mh.position);
if (mh.position > pdoc->LineStart(lineOfPos))
lineOfPos++; // Affecting subsequent lines
if (mh.linesAdded > 0) {
pcs->InsertLines(lineOfPos, mh.linesAdded);
} else {
pcs->DeleteLines(lineOfPos, -mh.linesAdded);
}
view.LinesAddedOrRemoved(lineOfPos, mh.linesAdded);
}
if (FlagSet(mh.modificationType, ModificationFlags::ChangeAnnotation)) {
const Sci::Line lineDoc = pdoc->SciLineFromPosition(mh.position);
if (vs.annotationVisible != AnnotationVisible::Hidden) {
if (pcs->SetHeight(lineDoc, pcs->GetHeight(lineDoc) + static_cast<int>(mh.annotationLinesAdded))) {
SetScrollBars();
}
Redraw();
}
}
if (FlagSet(mh.modificationType, ModificationFlags::ChangeEOLAnnotation)) {
if (vs.eolAnnotationVisible != EOLAnnotationVisible::Hidden) {
Redraw();
}
}
CheckModificationForWrap(mh);
if (mh.linesAdded != 0) {
// Avoid scrolling of display if change before current display
if (mh.position < posTopLine && !CanDeferToLastStep(mh)) {
const Sci::Line newTop = std::clamp<Sci::Line>(topLine + mh.linesAdded, 0, MaxScrollPos());
if (newTop != topLine) {
SetTopLine(newTop);
SetVerticalScrollPos();
}
}
if (paintState == PaintState::notPainting && !CanDeferToLastStep(mh)) {
if (SynchronousStylingToVisible()) {
QueueIdleWork(WorkItems::style, pdoc->LengthNoExcept());
}
Redraw();
}
} else {
if (paintState == PaintState::notPainting && mh.length && !CanEliminate(mh)) {
if (SynchronousStylingToVisible()) {
QueueIdleWork(WorkItems::style, mh.position + mh.length);
}
InvalidateRange(mh.position, mh.position + mh.length);
if (FlagSet(changeHistoryOption, ChangeHistoryOption::Markers)) {
RedrawSelMargin(pdoc->SciLineFromPosition(mh.position));
}
}
}
}
if (mh.linesAdded != 0 && !CanDeferToLastStep(mh)) {
SetScrollBars();
}
if ((FlagSet(mh.modificationType, ModificationFlags::ChangeMarker)) || (FlagSet(mh.modificationType, ModificationFlags::ChangeMargin))) {
if ((!willRedrawAll) && ((paintState == PaintState::notPainting) || !PaintContainsMargin())) {
if (FlagSet(mh.modificationType, ModificationFlags::ChangeFold)) {
// Fold changes can affect the drawing of following lines so redraw whole margin
RedrawSelMargin(marginView.highlightDelimiter.isEnabled ? -1 : mh.line - 1, true);
} else {
RedrawSelMargin(mh.line);
}
}
}
if ((FlagSet(mh.modificationType, ModificationFlags::ChangeFold)) && (FlagSet(foldAutomatic, AutomaticFold::Change))) {
FoldChanged(mh.line, mh.foldLevelNow, mh.foldLevelPrev);
}
// NOW pay the piper WRT "deferred" visual updates
if (IsLastStep(mh)) {
SetScrollBars();
Redraw();
}
// If client wants to see this modification
if (FlagSet(mh.modificationType, modEventMask)) {
if (commandEvents) {
if ((mh.modificationType & (ModificationFlags::ChangeStyle | ModificationFlags::ChangeIndicator)) == ModificationFlags::None) {
// Real modification made to text of document.
NotifyChange(); // Send EN_CHANGE
}
}
NotificationData scn = {};
scn.nmhdr.code = Notification::Modified;
scn.position = mh.position;
scn.modificationType = mh.modificationType;
scn.text = mh.text;
scn.length = mh.length;
scn.linesAdded = mh.linesAdded;
scn.line = mh.line;
scn.foldLevelNow = mh.foldLevelNow;
scn.foldLevelPrev = mh.foldLevelPrev;
scn.token = static_cast<int>(mh.token);
scn.annotationLinesAdded = mh.annotationLinesAdded;
NotifyParent(scn);
}
}
void Editor::NotifyDeleted(Document *, void *) noexcept {
/* Do nothing */
}
void Editor::NotifyMacroRecord(Message iMessage, uptr_t wParam, sptr_t lParam) noexcept {
// Enumerates all macroable messages
switch (iMessage) {
case Message::Cut:
case Message::Copy:
case Message::Paste:
case Message::Clear:
case Message::ReplaceSel:
case Message::AddText:
case Message::InsertText:
case Message::AppendText:
case Message::ClearAll:
case Message::SelectAll:
case Message::GotoLine:
case Message::GotoPos:
case Message::SearchAnchor:
case Message::SearchNext:
case Message::SearchPrev:
case Message::LineDown:
case Message::LineDownExtend:
case Message::ParaDown:
case Message::ParaDownExtend:
case Message::LineUp:
case Message::LineUpExtend:
case Message::ParaUp:
case Message::ParaUpExtend:
case Message::CharLeft:
case Message::CharLeftExtend:
case Message::CharRight:
case Message::CharRightExtend:
case Message::WordLeft:
case Message::WordLeftExtend:
case Message::WordRight:
case Message::WordRightExtend:
case Message::WordPartLeft:
case Message::WordPartLeftExtend:
case Message::WordPartRight:
case Message::WordPartRightExtend:
case Message::WordLeftEnd:
case Message::WordLeftEndExtend:
case Message::WordRightEnd:
case Message::WordRightEndExtend:
case Message::Home:
case Message::HomeExtend:
case Message::LineEnd:
case Message::LineEndExtend:
case Message::HomeWrap:
case Message::HomeWrapExtend:
case Message::LineEndWrap:
case Message::LineEndWrapExtend:
case Message::DocumentStart:
case Message::DocumentStartExtend:
case Message::DocumentEnd:
case Message::DocumentEndExtend:
case Message::StutteredPageUp:
case Message::StutteredPageUpExtend:
case Message::StutteredPageDown:
case Message::StutteredPageDownExtend:
case Message::PageUp:
case Message::PageUpExtend:
case Message::PageDown:
case Message::PageDownExtend:
case Message::EditToggleOvertype:
case Message::Cancel:
case Message::DeleteBack:
case Message::Tab:
case Message::BackTab:
case Message::FormFeed:
case Message::VCHome:
case Message::VCHomeExtend:
case Message::VCHomeWrap:
case Message::VCHomeWrapExtend:
case Message::VCHomeDisplay:
case Message::VCHomeDisplayExtend:
case Message::DelWordLeft:
case Message::DelWordRight:
case Message::DelWordRightEnd:
case Message::DelLineLeft:
case Message::DelLineRight:
case Message::LineCopy:
case Message::LineCut:
case Message::LineDelete:
case Message::LineTranspose:
case Message::LineReverse:
case Message::LineDuplicate:
case Message::LowerCase:
case Message::UpperCase:
case Message::LineScrollDown:
case Message::LineScrollUp:
case Message::DeleteBackNotLine:
case Message::HomeDisplay:
case Message::HomeDisplayExtend:
case Message::LineEndDisplay:
case Message::LineEndDisplayExtend:
case Message::SetSelectionMode:
case Message::LineDownRectExtend:
case Message::LineUpRectExtend:
case Message::CharLeftRectExtend:
case Message::CharRightRectExtend:
case Message::HomeRectExtend:
case Message::VCHomeRectExtend:
case Message::LineEndRectExtend:
case Message::PageUpRectExtend:
case Message::PageDownRectExtend:
case Message::SelectionDuplicate:
case Message::CopyAllowLine:
case Message::VerticalCentreCaret:
case Message::MoveSelectedLinesUp:
case Message::MoveSelectedLinesDown:
case Message::ScrollToStart:
case Message::ScrollToEnd:
break;
// Filter out all others like display changes. Also, newlines are redundant
// with char insert messages.
case Message::NewLine:
default:
//Platform::DebugPrintf("Filtered out %u of macro recording\n", iMessage);
return;
}
// Send notification
NotificationData scn = {};
scn.nmhdr.code = Notification::MacroRecord;
scn.message = iMessage;
scn.wParam = wParam;
scn.lParam = lParam;
NotifyParent(scn);
}
// Something has changed that the container should know about
void Editor::ContainerNeedsUpdate(Update flags) noexcept {
needUpdateUI = needUpdateUI | flags;
// layout as much as possible inside LayoutLine() to avoid unexpected scrolling
SetIdleTaskTime(ActiveLineWrapTime);
}
/**
* Force scroll and keep position relative to top of window.
*
* If stuttered = true and not already at first/last row, move to first/last row of window.
* If stuttered = true and already at first/last row, scroll as normal.
*/
void Editor::PageMove(int direction, Selection::SelTypes selt, bool stuttered) {
Sci::Line topLineNew;
SelectionPosition newPos;
const Sci::Line currentLine = pdoc->SciLineFromPosition(sel.MainCaret());
const Sci::Line topStutterLine = topLine + caretPolicies.y.slop;
const Sci::Line bottomStutterLine =
pdoc->SciLineFromPosition(PositionFromLocation(
Point::FromInts(lastXChosen - xOffset, direction * vs.lineHeight * static_cast<int>(LinesToScroll()))))
- caretPolicies.y.slop - 1;
if (stuttered && (direction < 0 && currentLine > topStutterLine)) {
topLineNew = topLine;
newPos = SPositionFromLocation(Point::FromInts(lastXChosen - xOffset, vs.lineHeight * caretPolicies.y.slop),
false, false, UserVirtualSpace());
} else if (stuttered && (direction > 0 && currentLine < bottomStutterLine)) {
topLineNew = topLine;
newPos = SPositionFromLocation(Point::FromInts(lastXChosen - xOffset, vs.lineHeight * static_cast<int>(LinesToScroll() - caretPolicies.y.slop)),
false, false, UserVirtualSpace());
} else {
const Point pt = LocationFromPosition(sel.MainCaret());
topLineNew = std::clamp<Sci::Line>(
topLine + direction * LinesToScroll(), 0, MaxScrollPos());
newPos = SPositionFromLocation(
Point::FromInts(lastXChosen - xOffset, static_cast<int>(pt.y) +
direction * (vs.lineHeight * static_cast<int>(LinesToScroll()))),
false, false, UserVirtualSpace());
}
if (topLineNew != topLine) {
SetTopLine(topLineNew);
MovePositionTo(newPos, selt);
SetVerticalScrollPos();
Redraw();
} else {
MovePositionTo(newPos, selt);
}
}
void Editor::ChangeCaseOfSelection(CaseMapping caseMapping) {
const UndoGroup ug(pdoc);
for (size_t r = 0; r < sel.Count(); r++) {
SelectionRange current = sel.Range(r);
SelectionRange currentNoVS = current;
currentNoVS.ClearVirtualSpace();
const size_t rangeBytes = currentNoVS.Length();
if (rangeBytes > 0) {
const std::string sText = RangeText(currentNoVS.Start().Position(), currentNoVS.End().Position());
const std::string sMapped = CaseMapString(sText, caseMapping);
if (sMapped != sText) {
size_t firstDifference = 0;
while (sMapped[firstDifference] == sText[firstDifference]) {
firstDifference++;
}
size_t lastDifferenceText = sText.size() - 1;
size_t lastDifferenceMapped = sMapped.size() - 1;
while (sMapped[lastDifferenceMapped] == sText[lastDifferenceText]) {
lastDifferenceText--;
lastDifferenceMapped--;
}
const size_t endDifferenceText = sText.size() - 1 - lastDifferenceText;
pdoc->DeleteChars(
currentNoVS.Start().Position() + firstDifference,
rangeBytes - firstDifference - endDifferenceText);
const Sci::Position lengthChange = lastDifferenceMapped - firstDifference + 1;
const Sci::Position lengthInserted = pdoc->InsertString(
currentNoVS.Start().Position() + firstDifference,
sMapped.c_str() + firstDifference,
lengthChange);
// Automatic movement changes selection so reset to exactly the same as it was.
const Sci::Position diffSizes = sMapped.size() - sText.size() + lengthInserted - lengthChange;
if (diffSizes != 0) {
if (current.anchor > current.caret)
current.anchor.Add(diffSizes);
else
current.caret.Add(diffSizes);
}
sel.Range(r) = current;
}
}
}
}
void Editor::LineTranspose() {
const Sci::Line line = pdoc->SciLineFromPosition(sel.MainCaret());
if (line > 0) {
const UndoGroup ug(pdoc);
const Sci::Position startPrevious = pdoc->LineStart(line - 1);
const std::string linePrevious = RangeText(startPrevious, pdoc->LineEnd(line - 1));
Sci::Position startCurrent = pdoc->LineStart(line);
const std::string lineCurrent = RangeText(startCurrent, pdoc->LineEnd(line));
pdoc->DeleteChars(startCurrent, lineCurrent.length());
pdoc->DeleteChars(startPrevious, linePrevious.length());
startCurrent -= linePrevious.length();
startCurrent += pdoc->InsertString(startPrevious, lineCurrent);
pdoc->InsertString(startCurrent, linePrevious);
// Move caret to start of current line
MovePositionTo(SelectionPosition(startCurrent));
}
}
void Editor::LineReverse() {
const Sci::Line lineStart =
pdoc->SciLineFromPosition(sel.RangeMain().Start().Position());
const Sci::Line lineEnd =
pdoc->SciLineFromPosition(sel.RangeMain().End().Position() - 1);
const Sci::Line lineDiff = lineEnd - lineStart;
if (lineDiff <= 0)
return;
const UndoGroup ug(pdoc);
for (Sci::Line i = (lineDiff + 1) / 2 - 1; i >= 0; --i) {
const Sci::Line lineNum2 = lineEnd - i;
const Sci::Line lineNum1 = lineStart + i;
Sci::Position lineStart2 = pdoc->LineStart(lineNum2);
const Sci::Position lineStart1 = pdoc->LineStart(lineNum1);
const std::string line2 = RangeText(lineStart2, pdoc->LineEnd(lineNum2));
const std::string line1 = RangeText(lineStart1, pdoc->LineEnd(lineNum1));
const Sci::Position lineLen2 = line2.length();
const Sci::Position lineLen1 = line1.length();
pdoc->DeleteChars(lineStart2, lineLen2);
pdoc->DeleteChars(lineStart1, lineLen1);
lineStart2 -= lineLen1;
pdoc->InsertString(lineStart2, line1);
pdoc->InsertString(lineStart1, line2);
}
// Wholly select all affected lines
sel.RangeMain() = SelectionRange(pdoc->LineStart(lineStart),
pdoc->LineStart(lineEnd + 1));
}
void Editor::Duplicate(bool forLine) {
if (sel.Empty()) {
forLine = true;
}
const UndoGroup ug(pdoc);
std::string_view eol;
if (forLine) {
eol = pdoc->EOLString();
}
for (size_t r = 0; r < sel.Count(); r++) {
SelectionPosition start = sel.Range(r).Start();
SelectionPosition end = sel.Range(r).End();
if (forLine) {
const Sci::Line line = pdoc->SciLineFromPosition(sel.Range(r).caret.Position());
start = SelectionPosition(pdoc->LineStart(line));
end = SelectionPosition(pdoc->LineEnd(line));
}
const std::string text = RangeText(start.Position(), end.Position());
Sci::Position lengthInserted = 0;
if (forLine)
lengthInserted = pdoc->InsertString(end.Position(), eol);
pdoc->InsertString(end.Position() + lengthInserted, text);
}
if (sel.Count() && sel.IsRectangular()) {
SelectionPosition last = sel.Last();
if (forLine) {
const Sci::Line line = pdoc->SciLineFromPosition(last.Position());
last = SelectionPosition(last.Position() +
pdoc->LineStart(line + 1) - pdoc->LineStart(line));
}
if (sel.Rectangular().anchor > sel.Rectangular().caret)
sel.Rectangular().anchor = last;
else
sel.Rectangular().caret = last;
SetRectangularRange();
}
}
void Editor::CancelModes() noexcept {
sel.SetMoveExtends(false);
}
void Editor::NewLine() {
InvalidateWholeSelection();
if (sel.IsRectangular() || !additionalSelectionTyping) {
// Remove non-main ranges
sel.DropAdditionalRanges();
}
const UndoGroup ug(pdoc, !sel.Empty() || (sel.Count() > 1));
// Clear each range
if (!sel.Empty()) {
ClearSelection();
}
// Insert each line end
size_t countInsertions = 0;
const std::string_view eol = pdoc->EOLString();
for (size_t r = 0; r < sel.Count(); r++) {
sel.Range(r).ClearVirtualSpace();
const Sci::Position positionInsert = sel.Range(r).caret.Position();
const Sci::Line lineDoc = pdoc->SciLineFromPosition(positionInsert);
const bool expanded = pcs->GetExpanded(lineDoc);
const Sci::Position insertLength = pdoc->InsertString(positionInsert, eol);
if (insertLength > 0) {
sel.Range(r) = SelectionRange(positionInsert + insertLength);
countInsertions++;
if (!expanded) {
pcs->SetExpanded(lineDoc, true);
pcs->SetExpanded(lineDoc + 1, false);
}
}
}
// Perform notifications after all the changes as the application may change the
// selections in response to the characters.
for (size_t i = 0; i < countInsertions; i++) {
for (const char ch : eol) {
NotifyChar(ch, CharacterSource::DirectInput);
if (recordingMacro) {
const char txt[2] = { ch, '\0' };
NotifyMacroRecord(Message::ReplaceSel, 0, reinterpret_cast<sptr_t>(txt));
}
}
}
SetLastXChosen();
SetScrollBars();
EnsureCaretVisible();
// Avoid blinking during rapid typing:
ShowCaretAtCurrentPosition();
}
SelectionPosition Editor::PositionUpOrDown(SelectionPosition spStart, int direction, int lastX) {
const Point pt = LocationFromPosition(spStart);
int skipLines = 0;
if (vs.annotationVisible != AnnotationVisible::Hidden) {
const Sci::Line lineDoc = pdoc->SciLineFromPosition(spStart.Position());
const Point ptStartLine = LocationFromPosition(pdoc->LineStart(lineDoc));
const int subLine = static_cast<int>(pt.y - ptStartLine.y) / vs.lineHeight;
if (direction < 0 && subLine == 0) {
const Sci::Line lineDisplay = pcs->DisplayFromDoc(lineDoc);
if (lineDisplay > 0) {
skipLines = pdoc->AnnotationLines(pcs->DocFromDisplay(lineDisplay - 1));
}
} else if (direction > 0 && subLine >= (pcs->GetHeight(lineDoc) - 1 - pdoc->AnnotationLines(lineDoc))) {
skipLines = pdoc->AnnotationLines(lineDoc);
}
}
const Sci::Line newY = static_cast<Sci::Line>(pt.y) + (1 + skipLines) * direction * vs.lineHeight;
if (lastX < 0) {
lastX = static_cast<int>(pt.x) + xOffset;
}
SelectionPosition posNew = SPositionFromLocation(
Point::FromInts(lastX - xOffset, static_cast<int>(newY)), false, false, UserVirtualSpace());
if (direction < 0) {
// Line wrapping may lead to a location on the same line, so
// seek back if that is the case.
Point ptNew = LocationFromPosition(posNew.Position());
while ((posNew.Position() > 0) && (pt.y == ptNew.y)) {
posNew.Add(-1);
posNew.SetVirtualSpace(0);
ptNew = LocationFromPosition(posNew.Position());
}
} else if (direction > 0 && posNew.Position() != pdoc->LengthNoExcept()) {
// There is an equivalent case when moving down which skips
// over a line.
Point ptNew = LocationFromPosition(posNew.Position());
while ((posNew.Position() > spStart.Position()) && (ptNew.y > newY)) {
posNew.Add(-1);
posNew.SetVirtualSpace(0);
ptNew = LocationFromPosition(posNew.Position());
}
}
return posNew;
}
void Editor::CursorUpOrDown(int direction, Selection::SelTypes selt) {
if ((selt == Selection::SelTypes::none) && sel.MoveExtends()) {
selt = !sel.IsRectangular() ? Selection::SelTypes::stream : Selection::SelTypes::rectangle;
}
SelectionPosition caretToUse = sel.RangeMain().caret;
if (sel.IsRectangular()) {
if (selt == Selection::SelTypes::none) {
caretToUse = (direction > 0) ? sel.Limits().end : sel.Limits().start;
} else {
caretToUse = sel.Rectangular().caret;
}
}
if (selt == Selection::SelTypes::rectangle) {
const SelectionRange rangeBase = sel.IsRectangular() ? sel.Rectangular() : sel.RangeMain();
if (!sel.IsRectangular()) {
InvalidateWholeSelection();
sel.DropAdditionalRanges();
}
const SelectionPosition posNew = MovePositionSoVisible(
PositionUpOrDown(caretToUse, direction, lastXChosen), direction);
sel.selType = Selection::SelTypes::rectangle;
sel.Rectangular() = SelectionRange(posNew, rangeBase.anchor);
SetRectangularRange();
MovedCaret(posNew, caretToUse, true, caretPolicies);
} else if (sel.selType == Selection::SelTypes::lines && sel.MoveExtends()) {
// Calculate new caret position and call SetSelection(), which will ensure whole lines are selected.
const SelectionPosition posNew = MovePositionSoVisible(
PositionUpOrDown(caretToUse, direction, -1), direction);
SetSelection(posNew, sel.RangeMain().anchor);
} else {
InvalidateWholeSelection();
if (!additionalSelectionTyping || (sel.IsRectangular())) {
sel.DropAdditionalRanges();
}
sel.selType = Selection::SelTypes::stream;
for (size_t r = 0; r < sel.Count(); r++) {
const int lastX = (r == sel.Main()) ? lastXChosen : -1;
const SelectionPosition spCaretNow = sel.Range(r).caret;
const SelectionPosition posNew = MovePositionSoVisible(
PositionUpOrDown(spCaretNow, direction, lastX), direction);
sel.Range(r) = selt == Selection::SelTypes::stream ?
SelectionRange(posNew, sel.Range(r).anchor) : SelectionRange(posNew);
}
sel.RemoveDuplicates();
MovedCaret(sel.RangeMain().caret, caretToUse, true, caretPolicies);
}
}
void Editor::ParaUpOrDown(int direction, Selection::SelTypes selt) {
Sci::Line lineDoc;
const Sci::Position savedPos = sel.MainCaret();
do {
MovePositionTo(SelectionPosition(direction > 0 ? pdoc->ParaDown(sel.MainCaret()) : pdoc->ParaUp(sel.MainCaret())), selt);
lineDoc = pdoc->SciLineFromPosition(sel.MainCaret());
if (direction > 0) {
if (sel.MainCaret() >= pdoc->LengthNoExcept() && !pcs->GetVisible(lineDoc)) {
if (selt == Selection::SelTypes::none) {
MovePositionTo(SelectionPosition(pdoc->LineEndPosition(savedPos)));
}
break;
}
}
} while (!pcs->GetVisible(lineDoc));
}
Range Editor::RangeDisplayLine(Sci::Line lineVisible) {
RefreshStyleData();
const AutoSurface surface(this);
return view.RangeDisplayLine(surface, *this, lineVisible, vs);
}
Sci::Position Editor::StartEndDisplayLine(Sci::Position pos, bool start) {
RefreshStyleData();
const AutoSurface surface(this);
const Sci::Position posRet = view.StartEndDisplayLine(surface, *this, pos, start, vs);
if (posRet == Sci::invalidPosition) {
return pos;
} else {
return posRet;
}
}
namespace {
constexpr short HighShortFromWParam(uptr_t x) noexcept {
return static_cast<short>(x >> 16);
}
constexpr short LowShortFromWParam(uptr_t x) noexcept {
return static_cast<short>(x & 0xffff);
}
constexpr Message WithExtends(Message iMessage) noexcept {
switch (iMessage) {
case Message::CharLeft: return Message::CharLeftExtend;
case Message::CharRight: return Message::CharRightExtend;
case Message::WordLeft: return Message::WordLeftExtend;
case Message::WordRight: return Message::WordRightExtend;
case Message::WordLeftEnd: return Message::WordLeftEndExtend;
case Message::WordRightEnd: return Message::WordRightEndExtend;
case Message::WordPartLeft: return Message::WordPartLeftExtend;
case Message::WordPartRight: return Message::WordPartRightExtend;
case Message::Home: return Message::HomeExtend;
case Message::HomeDisplay: return Message::HomeDisplayExtend;
case Message::HomeWrap: return Message::HomeWrapExtend;
case Message::VCHome: return Message::VCHomeExtend;
case Message::VCHomeDisplay: return Message::VCHomeDisplayExtend;
case Message::VCHomeWrap: return Message::VCHomeWrapExtend;
case Message::LineEnd: return Message::LineEndExtend;
case Message::LineEndDisplay: return Message::LineEndDisplayExtend;
case Message::LineEndWrap: return Message::LineEndWrapExtend;
default: return iMessage;
}
}
constexpr int NaturalDirection(Message iMessage) noexcept {
switch (iMessage) {
case Message::CharLeft:
case Message::CharLeftExtend:
case Message::CharLeftRectExtend:
case Message::WordLeft:
case Message::WordLeftExtend:
case Message::WordLeftEnd:
case Message::WordLeftEndExtend:
case Message::WordPartLeft:
case Message::WordPartLeftExtend:
case Message::Home:
case Message::HomeExtend:
case Message::HomeDisplay:
case Message::HomeDisplayExtend:
case Message::HomeWrap:
case Message::HomeWrapExtend:
// VC_HOME* mostly goes back
case Message::VCHome:
case Message::VCHomeExtend:
case Message::VCHomeDisplay:
case Message::VCHomeDisplayExtend:
case Message::VCHomeWrap:
case Message::VCHomeWrapExtend:
return -1;
default:
return 1;
}
}
constexpr bool IsRectExtend(Message iMessage, bool isRectMoveExtends) noexcept {
switch (iMessage) {
case Message::CharLeftRectExtend:
case Message::CharRightRectExtend:
case Message::HomeRectExtend:
case Message::VCHomeRectExtend:
case Message::LineEndRectExtend:
return true;
default:
if (isRectMoveExtends) {
// Handle Message::SetSelectionMode(SelectionMode::Rectangle) and subsequent movements.
switch (iMessage) {
case Message::CharLeftExtend:
case Message::CharRightExtend:
case Message::HomeExtend:
case Message::VCHomeExtend:
case Message::LineEndExtend:
return true;
default:
return false;
}
}
return false;
}
}
}
Sci::Position Editor::VCHomeDisplayPosition(Sci::Position position) {
const Sci::Position homePos = pdoc->VCHomePosition(position);
const Sci::Position viewLineStart = StartEndDisplayLine(position, true);
if (viewLineStart > homePos)
return viewLineStart;
else
return homePos;
}
Sci::Position Editor::VCHomeWrapPosition(Sci::Position position) {
const Sci::Position homePos = pdoc->VCHomePosition(position);
const Sci::Position viewLineStart = StartEndDisplayLine(position, true);
if ((viewLineStart < position) && (viewLineStart > homePos))
return viewLineStart;
else
return homePos;
}
Sci::Position Editor::LineEndWrapPosition(Sci::Position position) {
const Sci::Position endPos = StartEndDisplayLine(position, false);
const Sci::Position realEndPos = pdoc->LineEndPosition(position);
if (endPos > realEndPos // if moved past visible EOLs
|| position >= endPos) // if at end of display line already
return realEndPos;
else
return endPos;
}
int Editor::HorizontalMove(Message iMessage) {
if (sel.selType == Selection::SelTypes::lines) {
return 0; // horizontal moves with line selection have no effect
}
if (sel.MoveExtends()) {
iMessage = WithExtends(iMessage);
}
if (!multipleSelection && !sel.IsRectangular()) {
// Simplify selection down to 1
sel.SetSelection(sel.RangeMain());
}
// Invalidate each of the current selections
InvalidateWholeSelection();
if (IsRectExtend(iMessage, sel.IsRectangular() && sel.MoveExtends())) {
const SelectionRange rangeBase = sel.IsRectangular() ? sel.Rectangular() : sel.RangeMain();
if (!sel.IsRectangular()) {
sel.DropAdditionalRanges();
}
// Will change to rectangular if not currently rectangular
SelectionPosition spCaret = rangeBase.caret;
switch (iMessage) {
case Message::CharLeftRectExtend:
case Message::CharLeftExtend: // only when sel.IsRectangular() && sel.MoveExtends()
if (pdoc->IsLineEndPosition(spCaret.Position()) && spCaret.VirtualSpace()) {
spCaret.SetVirtualSpace(spCaret.VirtualSpace() - 1);
} else if (!FlagSet(virtualSpaceOptions, VirtualSpace::NoWrapLineStart) || pdoc->GetColumn(spCaret.Position()) > 0) {
spCaret = SelectionPosition(spCaret.Position() - 1);
}
break;
case Message::CharRightRectExtend:
case Message::CharRightExtend: // only when sel.IsRectangular() && sel.MoveExtends()
if (FlagSet(virtualSpaceOptions, VirtualSpace::RectangularSelection) && pdoc->IsLineEndPosition(sel.MainCaret())) {
spCaret.SetVirtualSpace(spCaret.VirtualSpace() + 1);
} else {
spCaret = SelectionPosition(spCaret.Position() + 1);
}
break;
case Message::HomeRectExtend:
case Message::HomeExtend: // only when sel.IsRectangular() && sel.MoveExtends()
spCaret = SelectionPosition(
pdoc->LineStart(pdoc->SciLineFromPosition(spCaret.Position())));
break;
case Message::VCHomeRectExtend:
case Message::VCHomeExtend: // only when sel.IsRectangular() && sel.MoveExtends()
spCaret = SelectionPosition(pdoc->VCHomePosition(spCaret.Position()));
break;
case Message::LineEndRectExtend:
case Message::LineEndExtend: // only when sel.IsRectangular() && sel.MoveExtends()
spCaret = SelectionPosition(pdoc->LineEndPosition(spCaret.Position()));
break;
default:
break;
}
const int directionMove = (spCaret < rangeBase.caret) ? -1 : 1;
spCaret = MovePositionSoVisible(spCaret, directionMove);
sel.selType = Selection::SelTypes::rectangle;
sel.Rectangular() = SelectionRange(spCaret, rangeBase.anchor);
SetRectangularRange();
} else if (sel.IsRectangular()) {
// Not a rectangular extension so switch to stream.
SelectionPosition selAtLimit = (NaturalDirection(iMessage) > 0) ? sel.Limits().end : sel.Limits().start;
switch (iMessage) {
case Message::Home:
selAtLimit = SelectionPosition(
pdoc->LineStart(pdoc->SciLineFromPosition(selAtLimit.Position())));
break;
case Message::VCHome:
selAtLimit = SelectionPosition(pdoc->VCHomePosition(selAtLimit.Position()));
break;
case Message::LineEnd:
selAtLimit = SelectionPosition(pdoc->LineEndPosition(selAtLimit.Position()));
break;
default:
break;
}
sel.selType = Selection::SelTypes::stream;
sel.SetSelection(SelectionRange(selAtLimit));
} else {
if (!additionalSelectionTyping) {
InvalidateWholeSelection();
sel.DropAdditionalRanges();
}
for (size_t r = 0; r < sel.Count(); r++) {
const SelectionPosition spCaretNow = sel.Range(r).caret;
SelectionPosition spCaret = spCaretNow;
switch (iMessage) {
case Message::CharLeft:
case Message::CharLeftExtend:
if (spCaret.VirtualSpace()) {
spCaret.SetVirtualSpace(spCaret.VirtualSpace() - 1);
} else if (!FlagSet(virtualSpaceOptions, VirtualSpace::NoWrapLineStart) || pdoc->GetColumn(spCaret.Position()) > 0) {
spCaret = SelectionPosition(spCaret.Position() - 1);
}
break;
case Message::CharRight:
case Message::CharRightExtend:
if (FlagSet(virtualSpaceOptions, VirtualSpace::UserAccessible) && pdoc->IsLineEndPosition(spCaret.Position())) {
spCaret.SetVirtualSpace(spCaret.VirtualSpace() + 1);
} else {
spCaret = SelectionPosition(spCaret.Position() + 1);
}
break;
case Message::WordLeft:
case Message::WordLeftExtend:
spCaret = SelectionPosition(pdoc->NextWordStart(spCaret.Position(), -1));
break;
case Message::WordRight:
case Message::WordRightExtend:
spCaret = SelectionPosition(pdoc->NextWordStart(spCaret.Position(), 1));
break;
case Message::WordLeftEnd:
case Message::WordLeftEndExtend:
spCaret = SelectionPosition(pdoc->NextWordEnd(spCaret.Position(), -1));
break;
case Message::WordRightEnd:
case Message::WordRightEndExtend:
spCaret = SelectionPosition(pdoc->NextWordEnd(spCaret.Position(), 1));
break;
case Message::WordPartLeft:
case Message::WordPartLeftExtend:
spCaret = SelectionPosition(pdoc->WordPartLeft(spCaret.Position()));
break;
case Message::WordPartRight:
case Message::WordPartRightExtend:
spCaret = SelectionPosition(pdoc->WordPartRight(spCaret.Position()));
break;
case Message::Home:
case Message::HomeExtend:
spCaret = SelectionPosition(
pdoc->LineStart(pdoc->SciLineFromPosition(spCaret.Position())));
break;
case Message::HomeDisplay:
case Message::HomeDisplayExtend:
spCaret = SelectionPosition(StartEndDisplayLine(spCaret.Position(), true));
break;
case Message::HomeWrap:
case Message::HomeWrapExtend:
spCaret = MovePositionSoVisible(StartEndDisplayLine(spCaret.Position(), true), -1);
if (spCaretNow <= spCaret)
spCaret = SelectionPosition(
pdoc->LineStart(pdoc->SciLineFromPosition(spCaret.Position())));
break;
case Message::VCHome:
case Message::VCHomeExtend:
// VCHome alternates between beginning of line and beginning of text so may move back or forwards
spCaret = SelectionPosition(pdoc->VCHomePosition(spCaret.Position()));
break;
case Message::VCHomeDisplay:
case Message::VCHomeDisplayExtend:
spCaret = SelectionPosition(VCHomeDisplayPosition(spCaret.Position()));
break;
case Message::VCHomeWrap:
case Message::VCHomeWrapExtend:
spCaret = SelectionPosition(VCHomeWrapPosition(spCaret.Position()));
break;
case Message::LineEnd:
case Message::LineEndExtend:
spCaret = SelectionPosition(pdoc->LineEndPosition(spCaret.Position()));
break;
case Message::LineEndDisplay:
case Message::LineEndDisplayExtend:
spCaret = SelectionPosition(StartEndDisplayLine(spCaret.Position(), false));
break;
case Message::LineEndWrap:
case Message::LineEndWrapExtend:
spCaret = SelectionPosition(LineEndWrapPosition(spCaret.Position()));
break;
default:
PLATFORM_ASSERT(false);
}
const int directionMove = (spCaret < spCaretNow) ? -1 : 1;
spCaret = MovePositionSoVisible(spCaret, directionMove);
// Handle move versus extend, and special behaviour for non-empty left/right
switch (iMessage) {
case Message::CharLeft:
case Message::CharRight:
if (sel.Range(r).Empty()) {
sel.Range(r) = SelectionRange(spCaret);
} else {
sel.Range(r) = SelectionRange(
(iMessage == Message::CharLeft) ? sel.Range(r).Start() : sel.Range(r).End());
}
break;
case Message::WordLeft:
case Message::WordRight:
case Message::WordLeftEnd:
case Message::WordRightEnd:
case Message::WordPartLeft:
case Message::WordPartRight:
case Message::Home:
case Message::HomeDisplay:
case Message::HomeWrap:
case Message::VCHome:
case Message::VCHomeDisplay:
case Message::VCHomeWrap:
case Message::LineEnd:
case Message::LineEndDisplay:
case Message::LineEndWrap:
sel.Range(r) = SelectionRange(spCaret);
break;
case Message::CharLeftExtend:
case Message::CharRightExtend:
case Message::WordLeftExtend:
case Message::WordRightExtend:
case Message::WordLeftEndExtend:
case Message::WordRightEndExtend:
case Message::WordPartLeftExtend:
case Message::WordPartRightExtend:
case Message::HomeExtend:
case Message::HomeDisplayExtend:
case Message::HomeWrapExtend:
case Message::VCHomeExtend:
case Message::VCHomeDisplayExtend:
case Message::VCHomeWrapExtend:
case Message::LineEndExtend:
case Message::LineEndDisplayExtend:
case Message::LineEndWrapExtend: {
const SelectionRange rangeNew = SelectionRange(spCaret, sel.Range(r).anchor);
sel.TrimOtherSelections(r, SelectionRange(rangeNew));
sel.Range(r) = rangeNew;
}
break;
default:
PLATFORM_ASSERT(false);
}
}
}
sel.RemoveDuplicates();
MovedCaret(sel.RangeMain().caret, SelectionPosition(Sci::invalidPosition), true, caretPolicies);
// Invalidate the new state of the selection
InvalidateWholeSelection();
SetLastXChosen();
// Need the line moving and so forth from MovePositionTo
return 0;
}
int Editor::DelWordOrLine(Message iMessage) {
// Virtual space may be realised for Message::DelWordRight or Message::DelWordRightEnd
// which means 2 actions so wrap in an undo group.
// Rightwards and leftwards deletions differ in treatment of virtual space.
// Clear virtual space for leftwards, realise for rightwards.
const bool leftwards = (iMessage == Message::DelWordLeft) || (iMessage == Message::DelLineLeft);
if (!additionalSelectionTyping) {
InvalidateWholeSelection();
sel.DropAdditionalRanges();
}
const UndoGroup ug0(pdoc, (sel.Count() > 1) || !leftwards);
for (size_t r = 0; r < sel.Count(); r++) {
if (leftwards) {
// Delete to the left so first clear the virtual space.
sel.Range(r).ClearVirtualSpace();
} else {
// Delete to the right so first realise the virtual space.
sel.Range(r) = SelectionRange(
RealizeVirtualSpace(sel.Range(r).caret));
}
Range rangeDelete;
const Sci::Position caretPosition = sel.Range(r).caret.Position();
switch (iMessage) {
case Message::DelWordLeft:
rangeDelete = Range(pdoc->NextWordStart(caretPosition, -1), caretPosition);
break;
case Message::DelWordRight:
rangeDelete = Range(caretPosition, pdoc->NextWordStart(caretPosition, 1));
break;
case Message::DelWordRightEnd:
rangeDelete = Range(caretPosition, pdoc->NextWordEnd(caretPosition, 1));
break;
case Message::DelLineLeft:
rangeDelete = Range(pdoc->LineStart(pdoc->SciLineFromPosition(caretPosition)), caretPosition);
break;
case Message::DelLineRight:
rangeDelete = Range(caretPosition, pdoc->LineEnd(pdoc->SciLineFromPosition(caretPosition)));
break;
default:
break;
}
if (!RangeContainsProtected(rangeDelete.start, rangeDelete.end)) {
pdoc->DeleteChars(rangeDelete.start, rangeDelete.end - rangeDelete.start);
}
}
// May need something stronger here: can selections overlap at this point?
sel.RemoveDuplicates();
MovedCaret(sel.RangeMain().caret, SelectionPosition(Sci::invalidPosition), true, caretPolicies);
// Invalidate the new state of the selection
InvalidateWholeSelection();
SetLastXChosen();
return 0;
}
int Editor::KeyCommand(Message iMessage) {
switch (iMessage) {
case Message::LineDown:
CursorUpOrDown(1, Selection::SelTypes::none);
break;
case Message::LineDownExtend:
CursorUpOrDown(1, Selection::SelTypes::stream);
break;
case Message::LineDownRectExtend:
CursorUpOrDown(1, Selection::SelTypes::rectangle);
break;
case Message::ParaDown:
ParaUpOrDown(1, Selection::SelTypes::none);
break;
case Message::ParaDownExtend:
ParaUpOrDown(1, Selection::SelTypes::stream);
break;
case Message::LineScrollDown:
ScrollTo(topLine + 1);
MoveCaretInsideView(false);
break;
case Message::LineUp:
CursorUpOrDown(-1, Selection::SelTypes::none);
break;
case Message::LineUpExtend:
CursorUpOrDown(-1, Selection::SelTypes::stream);
break;
case Message::LineUpRectExtend:
CursorUpOrDown(-1, Selection::SelTypes::rectangle);
break;
case Message::ParaUp:
ParaUpOrDown(-1, Selection::SelTypes::none);
break;
case Message::ParaUpExtend:
ParaUpOrDown(-1, Selection::SelTypes::stream);
break;
case Message::LineScrollUp:
ScrollTo(topLine - 1);
MoveCaretInsideView(false);
break;
case Message::CharLeft:
case Message::CharLeftExtend:
case Message::CharLeftRectExtend:
case Message::CharRight:
case Message::CharRightExtend:
case Message::CharRightRectExtend:
case Message::WordLeft:
case Message::WordLeftExtend:
case Message::WordRight:
case Message::WordRightExtend:
case Message::WordLeftEnd:
case Message::WordLeftEndExtend:
case Message::WordRightEnd:
case Message::WordRightEndExtend:
case Message::WordPartLeft:
case Message::WordPartLeftExtend:
case Message::WordPartRight:
case Message::WordPartRightExtend:
case Message::Home:
case Message::HomeExtend:
case Message::HomeRectExtend:
case Message::HomeDisplay:
case Message::HomeDisplayExtend:
case Message::HomeWrap:
case Message::HomeWrapExtend:
case Message::VCHome:
case Message::VCHomeExtend:
case Message::VCHomeRectExtend:
case Message::VCHomeDisplay:
case Message::VCHomeDisplayExtend:
case Message::VCHomeWrap:
case Message::VCHomeWrapExtend:
case Message::LineEnd:
case Message::LineEndExtend:
case Message::LineEndRectExtend:
case Message::LineEndDisplay:
case Message::LineEndDisplayExtend:
case Message::LineEndWrap:
case Message::LineEndWrapExtend:
return HorizontalMove(iMessage);
case Message::DocumentStart:
MovePositionTo(0);
SetLastXChosen();
break;
case Message::DocumentStartExtend:
MovePositionTo(0, Selection::SelTypes::stream);
SetLastXChosen();
break;
case Message::DocumentEnd:
MovePositionTo(pdoc->LengthNoExcept());
SetLastXChosen();
break;
case Message::DocumentEndExtend:
MovePositionTo(pdoc->LengthNoExcept(), Selection::SelTypes::stream);
SetLastXChosen();
break;
case Message::StutteredPageUp:
PageMove(-1, Selection::SelTypes::none, true);
break;
case Message::StutteredPageUpExtend:
PageMove(-1, Selection::SelTypes::stream, true);
break;
case Message::StutteredPageDown:
PageMove(1, Selection::SelTypes::none, true);
break;
case Message::StutteredPageDownExtend:
PageMove(1, Selection::SelTypes::stream, true);
break;
case Message::PageUp:
PageMove(-1);
break;
case Message::PageUpExtend:
PageMove(-1, Selection::SelTypes::stream);
break;
case Message::PageUpRectExtend:
PageMove(-1, Selection::SelTypes::rectangle);
break;
case Message::PageDown:
PageMove(1);
break;
case Message::PageDownExtend:
PageMove(1, Selection::SelTypes::stream);
break;
case Message::PageDownRectExtend:
PageMove(1, Selection::SelTypes::rectangle);
break;
case Message::EditToggleOvertype:
inOverstrike = !inOverstrike;
ContainerNeedsUpdate(Update::Selection);
ShowCaretAtCurrentPosition();
SetIdle(true);
break;
case Message::Cancel: // Cancel any modes - handled in subclass
// Also unselect text
CancelModes();
if ((sel.Count() > 1) && !sel.IsRectangular()) {
// Drop additional selections
InvalidateWholeSelection();
sel.DropAdditionalRanges();
}
break;
case Message::DeleteBack:
DelCharBack(true);
if ((caretSticky == CaretSticky::Off) || (caretSticky == CaretSticky::WhiteSpace)) {
SetLastXChosen();
}
EnsureCaretVisible();
break;
case Message::DeleteBackNotLine:
DelCharBack(false);
if ((caretSticky == CaretSticky::Off) || (caretSticky == CaretSticky::WhiteSpace)) {
SetLastXChosen();
}
EnsureCaretVisible();
break;
case Message::Tab:
Indent(true);
if (caretSticky == CaretSticky::Off) {
SetLastXChosen();
}
EnsureCaretVisible();
ShowCaretAtCurrentPosition(); // Avoid blinking
break;
case Message::BackTab:
Indent(false);
if ((caretSticky == CaretSticky::Off) || (caretSticky == CaretSticky::WhiteSpace)) {
SetLastXChosen();
}
EnsureCaretVisible();
ShowCaretAtCurrentPosition(); // Avoid blinking
break;
case Message::NewLine:
NewLine();
break;
case Message::FormFeed:
AddChar('\f');
break;
case Message::ZoomIn:
if (vs.ZoomIn()) {
InvalidateStyleRedraw();
NotifyZoom();
}
break;
case Message::ZoomOut:
if (vs.ZoomOut()) {
InvalidateStyleRedraw();
NotifyZoom();
}
break;
case Message::DelWordLeft:
case Message::DelWordRight:
case Message::DelWordRightEnd:
case Message::DelLineLeft:
case Message::DelLineRight:
return DelWordOrLine(iMessage);
case Message::LineDelete: {
const Sci::Line line = pdoc->SciLineFromPosition(sel.MainCaret());
const Sci::Position start = pdoc->LineStart(line);
const Sci::Position end = pdoc->LineStart(line + 1);
pdoc->DeleteChars(start, end - start);
}
break;
case Message::LineTranspose:
LineTranspose();
break;
case Message::LineReverse:
LineReverse();
break;
case Message::LineDuplicate:
Duplicate(true);
break;
case Message::SelectionDuplicate:
Duplicate(false);
break;
case Message::LowerCase:
ChangeCaseOfSelection(CaseMapping::lower);
break;
case Message::UpperCase:
ChangeCaseOfSelection(CaseMapping::upper);
break;
case Message::ScrollToStart:
ScrollTo(0);
break;
case Message::ScrollToEnd:
ScrollTo(MaxScrollPos());
break;
default:
break;
}
return 0;
}
int Editor::KeyDefault(Keys, KeyMod) noexcept {
return 0;
}
int Editor::KeyDownWithModifiers(Keys key, KeyMod modifiers, bool *consumed) {
DwellEnd(false);
const Message msg = kmap.Find(key, modifiers);
if (msg != static_cast<Message>(0)) {
if (consumed)
*consumed = true;
return static_cast<int>(WndProc(msg, 0, 0));
} else {
if (consumed)
*consumed = false;
return KeyDefault(key, modifiers);
}
}
void Editor::Indent(bool forwards) {
const UndoGroup ug(pdoc);
for (size_t r = 0; r < sel.Count(); r++) {
const Sci::Line lineOfAnchor =
pdoc->SciLineFromPosition(sel.Range(r).anchor.Position());
Sci::Position caretPosition = sel.Range(r).caret.Position();
const Sci::Line lineCurrentPos = pdoc->SciLineFromPosition(caretPosition);
if (lineOfAnchor == lineCurrentPos) {
if (forwards) {
pdoc->DeleteChars(sel.Range(r).Start().Position(), sel.Range(r).Length());
caretPosition = sel.Range(r).caret.Position();
if (pdoc->tabIndents && pdoc->GetColumn(caretPosition) <= pdoc->GetColumn(pdoc->GetLineIndentPosition(lineCurrentPos))) {
const int indentation = pdoc->GetLineIndentation(lineCurrentPos);
const int indentationStep = pdoc->IndentSize();
const Sci::Position posSelect = pdoc->SetLineIndentation(
lineCurrentPos, indentation + indentationStep - indentation % indentationStep);
sel.Range(r) = SelectionRange(posSelect);
} else {
if (pdoc->useTabs) {
const Sci::Position lengthInserted = pdoc->InsertString(caretPosition, "\t", 1);
sel.Range(r) = SelectionRange(caretPosition + lengthInserted);
} else {
int numSpaces = (pdoc->tabInChars) -
(pdoc->GetColumn(caretPosition) % (pdoc->tabInChars));
if (numSpaces < 1)
numSpaces = pdoc->tabInChars;
const std::string spaceText(numSpaces, ' ');
const Sci::Position lengthInserted = pdoc->InsertString(caretPosition, spaceText);
sel.Range(r) = SelectionRange(caretPosition + lengthInserted);
}
}
} else {
const Sci::Position column = pdoc->GetColumn(caretPosition);
const int indentation = pdoc->tabIndents ? pdoc->GetLineIndentation(lineCurrentPos) : -1;
if (column <= indentation) {
const int indentationStep = pdoc->IndentSize();
const Sci::Position posSelect = pdoc->SetLineIndentation(lineCurrentPos, indentation - indentationStep);
sel.Range(r) = SelectionRange(posSelect);
} else {
Sci::Position newColumn = ((column - 1) / pdoc->tabInChars) *
pdoc->tabInChars;
newColumn = std::max<Sci::Position>(newColumn, 0);
Sci::Position newPos = caretPosition;
while (pdoc->GetColumn(newPos) > newColumn)
newPos--;
sel.Range(r) = SelectionRange(newPos);
}
}
} else { // Multiline
const Sci::Position anchorPosOnLine = sel.Range(r).anchor.Position() -
pdoc->LineStart(lineOfAnchor);
const Sci::Position currentPosPosOnLine = caretPosition -
pdoc->LineStart(lineCurrentPos);
// Multiple lines selected so indent / dedent
const Sci::Line lineTopSel = std::min(lineOfAnchor, lineCurrentPos);
Sci::Line lineBottomSel = std::max(lineOfAnchor, lineCurrentPos);
if (pdoc->LineStart(lineBottomSel) == sel.Range(r).anchor.Position() || pdoc->LineStart(lineBottomSel) == caretPosition)
lineBottomSel--; // If not selecting any characters on a line, do not indent
pdoc->Indent(forwards, lineBottomSel, lineTopSel);
if (lineOfAnchor < lineCurrentPos) {
if (currentPosPosOnLine == 0)
sel.Range(r) = SelectionRange(pdoc->LineStart(lineCurrentPos),
pdoc->LineStart(lineOfAnchor));
else
sel.Range(r) = SelectionRange(pdoc->LineStart(lineCurrentPos + 1),
pdoc->LineStart(lineOfAnchor));
} else {
if (anchorPosOnLine == 0)
sel.Range(r) = SelectionRange(pdoc->LineStart(lineCurrentPos),
pdoc->LineStart(lineOfAnchor));
else
sel.Range(r) = SelectionRange(pdoc->LineStart(lineCurrentPos),
pdoc->LineStart(lineOfAnchor + 1));
}
}
}
ContainerNeedsUpdate(Update::Selection);
}
std::unique_ptr<CaseFolder> Editor::CaseFolderForEncoding() {
// Simple default that only maps ASCII upper case to lower case.
return std::make_unique<CaseFolderTable>();
}
/**
* Search of a text in the document, in the given range.
* @return The position of the found text, -1 if not found.
*/
Sci::Position Editor::FindTextFull(
uptr_t wParam, ///< Search modes : @c FindOption::MatchCase, @c FindOption::WholeWord,
///< @c FindOption::WordStart, @c FindOption::RegExp or @c FindOption::Posix.
sptr_t lParam) { ///< @c TextToFindFull structure: The text to search for in the given range.
TextToFindFull *ft = static_cast<TextToFindFull *>(PtrFromSPtr(lParam));
Sci::Position lengthFound = strlen(ft->lpstrText);
if (!pdoc->HasCaseFolder())
pdoc->SetCaseFolder(CaseFolderForEncoding());
try {
const Sci::Position pos = pdoc->FindText(
ft->chrg.cpMin,
ft->chrg.cpMax,
ft->lpstrText,
static_cast<FindOption>(wParam),
&lengthFound);
if (pos >= 0) {
ft->chrgText.cpMin = pos;
ft->chrgText.cpMax = pos + lengthFound;
}
return pos;
} catch (const RegexError &) {
errorStatus = Status::RegEx;
return -1;
}
}
/**
* Relocatable search support : Searches relative to current selection
* point and sets the selection to the found text range with
* each search.
*/
/**
* Anchor following searches at current selection start: This allows
* multiple incremental interactive searches to be macro recorded
* while still setting the selection to found text so the find/select
* operation is self-contained.
*/
void Editor::SearchAnchor() noexcept {
searchAnchor = SelectionStart().Position();
}
/**
* Find text from current search anchor: Must call @c SearchAnchor first.
* Used for next text and previous text requests.
* @return The position of the found text, -1 if not found.
*/
Sci::Position Editor::SearchText(
Message iMessage, ///< Accepts both @c Message::SearchNext and @c Message::SearchPrev.
uptr_t wParam, ///< Search modes : @c FindOption::MatchCase, @c FindOption::WholeWord,
///< @c FindOption::WordStart, @c FindOption::RegExp or @c FindOption::Posix.
sptr_t lParam) { ///< The text to search for.
const char *txt = ConstCharPtrFromSPtr(lParam);
Sci::Position pos = Sci::invalidPosition;
Sci::Position lengthFound = strlen(txt);
if (!pdoc->HasCaseFolder())
pdoc->SetCaseFolder(CaseFolderForEncoding());
try {
if (iMessage == Message::SearchNext) {
pos = pdoc->FindText(searchAnchor, pdoc->LengthNoExcept(), txt,
static_cast<FindOption>(wParam),
&lengthFound);
} else {
pos = pdoc->FindText(searchAnchor, 0, txt,
static_cast<FindOption>(wParam),
&lengthFound);
}
} catch (const RegexError &) {
errorStatus = Status::RegEx;
return Sci::invalidPosition;
}
if (pos != Sci::invalidPosition) {
SetSelection(pos, pos + lengthFound);
}
return pos;
}
std::string Editor::CaseMapString(const std::string &s, CaseMapping caseMapping) const {
std::string ret(s);
for (char &ch : ret) {
switch (caseMapping) {
case CaseMapping::upper:
ch = MakeUpperCase(ch);
break;
case CaseMapping::lower:
ch = MakeLowerCase(ch);
break;
default: // no action
break;
}
}
return ret;
}
/**
* Search for text in the target range of the document.
* @return The position of the found text, -1 if not found.
*/
Sci::Position Editor::SearchInTarget(const char *text, Sci::Position length) {
Sci::Position lengthFound = length;
if (!pdoc->HasCaseFolder())
pdoc->SetCaseFolder(CaseFolderForEncoding());
try {
const Sci::Position pos = pdoc->FindText(targetRange.start.Position(), targetRange.end.Position(), text,
searchFlags,
&lengthFound);
if (pos >= 0) {
targetRange.start.SetPosition(pos);
targetRange.end.SetPosition(pos + lengthFound);
}
return pos;
} catch (const RegexError &) {
errorStatus = Status::RegEx;
return -1;
}
}
void Editor::GoToLine(Sci::Line lineNo) {
lineNo = std::clamp<Sci::Line>(lineNo, 0, pdoc->LinesTotal());
SetEmptySelection(pdoc->LineStart(lineNo));
ShowCaretAtCurrentPosition();
EnsureCaretVisible();
}
static bool Close(Point pt1, Point pt2, Point threshold) noexcept {
const Point ptDifference = pt2 - pt1;
if (std::abs(ptDifference.x) > threshold.x)
return false;
if (std::abs(ptDifference.y) > threshold.y)
return false;
return true;
}
std::string Editor::RangeText(Sci::Position start, Sci::Position end) const {
if (start < end) {
const Sci::Position len = end - start;
std::string ret(len, '\0');
pdoc->GetCharRange(ret.data(), start, len);
return ret;
}
return {};
}
void Editor::CopySelectionRange(SelectionText &ss, bool allowLineCopy) const {
if (sel.Empty()) {
if (allowLineCopy) {
const Sci::Line currentLine = pdoc->SciLineFromPosition(sel.MainCaret());
const Sci::Position start = pdoc->LineStart(currentLine);
const Sci::Position end = pdoc->LineStart(currentLine + 1);
const std::string text = RangeText(start, end);
ss.Copy(text, pdoc->dbcsCodePage, false, true);
}
} else {
std::string text;
std::vector<SelectionRange> rangesInOrder = sel.RangesCopy();
if (sel.selType == Selection::SelTypes::rectangle)
std::sort(rangesInOrder.begin(), rangesInOrder.end());
for (const SelectionRange ¤t : rangesInOrder) {
text.append(RangeText(current.Start().Position(), current.End().Position()));
if (sel.selType == Selection::SelTypes::rectangle) {
if (pdoc->eolMode != EndOfLine::Lf)
text.push_back('\r');
if (pdoc->eolMode != EndOfLine::Cr)
text.push_back('\n');
}
}
ss.Copy(text, pdoc->dbcsCodePage, sel.IsRectangular(), sel.selType == Selection::SelTypes::lines);
}
}
void Editor::CopyRangeToClipboard(Sci::Position start, Sci::Position end, bool lineCopy) const {
start = pdoc->ClampPositionIntoDocument(start);
end = pdoc->ClampPositionIntoDocument(end);
SelectionText selectedText;
const std::string text = RangeText(start, end);
selectedText.Copy(text, pdoc->dbcsCodePage, false, lineCopy);
CopyToClipboard(selectedText);
}
void Editor::CopyText(size_t length, const char *text) const {
SelectionText selectedText;
selectedText.Copy(std::string(text, length), pdoc->dbcsCodePage, false, false);
CopyToClipboard(selectedText);
}
void Editor::SetDragPosition(SelectionPosition newPos) {
if (newPos.Position() >= 0) {
newPos = MovePositionOutsideChar(newPos, 1);
posDrop = newPos;
}
if (!(posDrag == newPos)) {
const CaretPolicies dragCaretPolicies = {
{ CaretPolicy::Slop | CaretPolicy::Strict | CaretPolicy::Even, 50 },
{ CaretPolicy::Slop | CaretPolicy::Strict | CaretPolicy::Even, 2 }
};
MovedCaret(newPos, posDrag, true, dragCaretPolicies);
caret.on = true;
FineTickerCancel(TickReason::caret);
if ((caret.active) && (caret.period > 0) && (newPos.Position() < 0))
FineTickerStart(TickReason::caret, caret.period, caret.period / 10);
InvalidateCaret();
posDrag = newPos;
InvalidateCaret();
}
}
void Editor::DisplayCursor(Window::Cursor c) noexcept {
if (cursorMode == CursorShape::Normal)
wMain.SetCursor(c);
else
wMain.SetCursor(static_cast<Window::Cursor>(cursorMode));
}
bool Editor::DragThreshold(Point ptStart, Point ptNow) noexcept {
const Point ptDiff = ptStart - ptNow;
const XYPOSITION distanceSquared = ptDiff.x * ptDiff.x + ptDiff.y * ptDiff.y;
return distanceSquared > 16.0f;
}
void Editor::StartDrag() {
// Always handled by subclasses
//SetMouseCapture(true);
//DisplayCursor(Window::Cursor::::arrow);
}
void Editor::DropAt(SelectionPosition position, const char *value, size_t lengthValue, bool moving, bool rectangular) {
//Platform::DebugPrintf("DropAt %d %d\n", inDragDrop, position);
if (inDragDrop == DragDrop::dragging)
dropWentOutside = false;
const bool positionWasInSelection = PositionInSelection(position.Position());
const bool positionOnEdgeOfSelection =
(position == SelectionStart()) || (position == SelectionEnd());
if ((inDragDrop != DragDrop::dragging) || !(positionWasInSelection) ||
(positionOnEdgeOfSelection && !moving)) {
const SelectionPosition selStart = SelectionStart();
const SelectionPosition selEnd = SelectionEnd();
const UndoGroup ug(pdoc);
SelectionPosition positionAfterDeletion = position;
if ((inDragDrop == DragDrop::dragging) && moving) {
// Remove dragged out text
if (rectangular || sel.selType == Selection::SelTypes::lines) {
for (size_t r = 0; r < sel.Count(); r++) {
if (position >= sel.Range(r).Start()) {
if (position > sel.Range(r).End()) {
positionAfterDeletion.Add(-sel.Range(r).Length());
} else {
positionAfterDeletion.Add(-SelectionRange(position, sel.Range(r).Start()).Length());
}
}
}
} else {
if (position > selStart) {
positionAfterDeletion.Add(-SelectionRange(selEnd, selStart).Length());
}
}
ClearSelection();
}
position = positionAfterDeletion;
const std::string convertedText = Document::TransformLineEnds(value, lengthValue, pdoc->eolMode);
if (rectangular) {
PasteRectangular(position, convertedText.c_str(), convertedText.length());
// Should try to select new rectangle but it may not be a rectangle now so just select the drop position
SetEmptySelection(position);
} else {
position = MovePositionOutsideChar(position, sel.MainCaret() - position.Position());
position = RealizeVirtualSpace(position);
const Sci::Position lengthInserted = pdoc->InsertString(
position.Position(), convertedText);
if (lengthInserted > 0) {
SelectionPosition posAfterInsertion = position;
posAfterInsertion.Add(lengthInserted);
SetSelection(posAfterInsertion, position);
}
}
} else if (inDragDrop == DragDrop::dragging) {
SetEmptySelection(position);
}
}
void Editor::DropAt(SelectionPosition position, const char *value, bool moving, bool rectangular) {
DropAt(position, value, strlen(value), moving, rectangular);
}
/**
* @return true if given position is inside the selection,
*/
bool Editor::PositionInSelection(Sci::Position pos) const noexcept {
pos = MovePositionOutsideChar(pos, sel.MainCaret() - pos);
for (size_t r = 0; r < sel.Count(); r++) {
if (sel.Range(r).Contains(pos))
return true;
}
return false;
}
bool Editor::PointInSelection(Point pt) {
const SelectionPosition pos = SPositionFromLocation(pt, false, true);
const Point ptPos = LocationFromPosition(pos);
for (size_t r = 0; r < sel.Count(); r++) {
const SelectionRange &range = sel.Range(r);
if (range.Contains(pos)) {
bool hit = true;
if (pos == range.Start()) {
// see if just before selection
if (pt.x < ptPos.x) {
hit = false;
}
}
if (pos == range.End()) {
// see if just after selection
if (pt.x > ptPos.x) {
hit = false;
}
}
if (hit)
return true;
}
}
return false;
}
bool Editor::PointInSelMargin(Point pt) const noexcept {
// Really means: "Point in a margin"
if (vs.fixedColumnWidth > 0) { // There is a margin
PRectangle rcSelMargin = GetClientRectangle();
rcSelMargin.right = static_cast<XYPOSITION>(vs.textStart - vs.leftMarginWidth);
rcSelMargin.left = static_cast<XYPOSITION>(vs.textStart - vs.fixedColumnWidth);
const Point ptOrigin = GetVisibleOriginInMain();
rcSelMargin.Move(0, -ptOrigin.y);
return rcSelMargin.ContainsWholePixel(pt);
} else {
return false;
}
}
Window::Cursor Editor::GetMarginCursor(Point pt) const noexcept {
int x = 0;
for (const auto &m : vs.ms) {
if ((pt.x >= x) && (pt.x < x + m.width))
return static_cast<Window::Cursor>(m.cursor);
x += m.width;
}
return Window::Cursor::reverseArrow;
}
void Editor::TrimAndSetSelection(Sci::Position currentPos_, Sci::Position anchor_) {
sel.TrimSelection(SelectionRange(currentPos_, anchor_));
SetSelection(currentPos_, anchor_);
}
void Editor::LineSelection(Sci::Position lineCurrentPos_, Sci::Position lineAnchorPos_, bool wholeLine) {
Sci::Position selCurrentPos;
Sci::Position selAnchorPos;
if (wholeLine) {
const Sci::Line lineCurrent_ = pdoc->SciLineFromPosition(lineCurrentPos_);
const Sci::Line lineAnchor_ = pdoc->SciLineFromPosition(lineAnchorPos_);
if (lineAnchorPos_ < lineCurrentPos_) {
selCurrentPos = pdoc->LineStart(lineCurrent_ + 1);
selAnchorPos = pdoc->LineStart(lineAnchor_);
} else if (lineAnchorPos_ > lineCurrentPos_) {
selCurrentPos = pdoc->LineStart(lineCurrent_);
selAnchorPos = pdoc->LineStart(lineAnchor_ + 1);
} else { // Same line, select it
selCurrentPos = pdoc->LineStart(lineAnchor_ + 1);
selAnchorPos = pdoc->LineStart(lineAnchor_);
}
} else {
if (lineAnchorPos_ < lineCurrentPos_) {
selCurrentPos = StartEndDisplayLine(lineCurrentPos_, false) + 1;
selCurrentPos = pdoc->MovePositionOutsideChar(selCurrentPos, 1);
selAnchorPos = StartEndDisplayLine(lineAnchorPos_, true);
} else if (lineAnchorPos_ > lineCurrentPos_) {
selCurrentPos = StartEndDisplayLine(lineCurrentPos_, true);
selAnchorPos = StartEndDisplayLine(lineAnchorPos_, false) + 1;
selAnchorPos = pdoc->MovePositionOutsideChar(selAnchorPos, 1);
} else { // Same line, select it
selCurrentPos = StartEndDisplayLine(lineAnchorPos_, false) + 1;
selCurrentPos = pdoc->MovePositionOutsideChar(selCurrentPos, 1);
selAnchorPos = StartEndDisplayLine(lineAnchorPos_, true);
}
}
TrimAndSetSelection(selCurrentPos, selAnchorPos);
}
void Editor::WordSelection(Sci::Position pos) {
if (pos < wordSelectAnchorStartPos) {
// Extend backward to the word containing pos.
// Skip ExtendWordSelect if the line is empty or if pos is after the last character.
// This ensures that a series of empty lines isn't counted as a single "word".
if (!pdoc->IsLineEndPosition(pos))
pos = pdoc->ExtendWordSelect(pdoc->MovePositionOutsideChar(pos + 1, 1), -1);
TrimAndSetSelection(pos, wordSelectAnchorEndPos);
} else if (pos > wordSelectAnchorEndPos) {
// Extend forward to the word containing the character to the left of pos.
// Skip ExtendWordSelect if the line is empty or if pos is the first position on the line.
// This ensures that a series of empty lines isn't counted as a single "word".
if (pos > pdoc->LineStart(pdoc->SciLineFromPosition(pos)))
pos = pdoc->ExtendWordSelect(pdoc->MovePositionOutsideChar(pos - 1, -1), 1);
TrimAndSetSelection(pos, wordSelectAnchorStartPos);
} else {
// Select only the anchored word
if (pos >= originalAnchorPos)
TrimAndSetSelection(wordSelectAnchorEndPos, wordSelectAnchorStartPos);
else
TrimAndSetSelection(wordSelectAnchorStartPos, wordSelectAnchorEndPos);
}
}
void Editor::DwellEnd(bool mouseMoved) {
if (mouseMoved)
ticksToDwell = dwellDelay;
else
ticksToDwell = TimeForever;
if (dwelling && (dwellDelay < TimeForever)) {
dwelling = false;
NotifyDwelling(ptMouseLast, dwelling);
}
FineTickerCancel(TickReason::dwell);
}
void Editor::MouseLeave() {
SetHotSpotRange(nullptr);
SetHoverIndicatorPosition(Sci::invalidPosition);
if (!HaveMouseCapture()) {
ptMouseLast = Point(-1, -1);
DwellEnd(true);
}
}
static constexpr bool AllowVirtualSpace(VirtualSpace virtualSpaceOptions, bool rectangular) noexcept {
return (!rectangular && (FlagSet(virtualSpaceOptions, VirtualSpace::UserAccessible)))
|| (rectangular && (FlagSet(virtualSpaceOptions, VirtualSpace::RectangularSelection)));
}
void Editor::ButtonDownWithModifiers(Point pt, unsigned int curTime, KeyMod modifiers) {
SetHoverIndicatorPoint(pt);
//Platform::DebugPrintf("ButtonDown %d %d = %d modifiers=%d %d\n", curTime, lastClickTime, curTime - lastClickTime, modifiers, inDragDrop);
ptMouseLast = pt;
const bool ctrl = FlagSet(modifiers, KeyMod::Ctrl);
const bool shift = FlagSet(modifiers, KeyMod::Shift);
const bool alt = FlagSet(modifiers, KeyMod::Alt);
SelectionPosition newPos = SPositionFromLocation(pt, false, false, AllowVirtualSpace(virtualSpaceOptions, alt));
newPos = MovePositionOutsideChar(newPos, sel.MainCaret() - newPos.Position());
SelectionPosition newCharPos = SPositionFromLocation(pt, false, true, false);
newCharPos = MovePositionOutsideChar(newCharPos, -1);
inDragDrop = DragDrop::none;
sel.SetMoveExtends(false);
if (NotifyMarginClick(pt, modifiers))
return;
NotifyIndicatorClick(true, newPos.Position(), modifiers);
const bool inSelMargin = PointInSelMargin(pt);
// In margin ctrl+(double)click should always select everything
if (ctrl && inSelMargin) {
SelectAll();
lastClickTime = curTime;
lastClick = pt;
return;
}
if (shift && !inSelMargin) {
SetSelection(newPos);
}
if ((curTime < (lastClickTime + Platform::DoubleClickTime())) && Close(pt, lastClick, doubleClickCloseThreshold)) {
//Platform::DebugPrintf("Double click %d %d = %d\n", curTime, lastClickTime, curTime - lastClickTime);
SetMouseCapture(true);
FineTickerStart(TickReason::scroll, 100, 10);
if (!ctrl || !multipleSelection || (selectionUnit != TextUnit::character && selectionUnit != TextUnit::word))
SetEmptySelection(newPos.Position());
bool doubleClick = false;
if (inSelMargin) {
// Inside margin selection type should be either subLine or wholeLine.
if (selectionUnit == TextUnit::subLine) {
// If it is subLine, we're inside a *double* click and word wrap is enabled,
// so we switch to wholeLine in order to select whole line.
selectionUnit = TextUnit::wholeLine;
} else if (selectionUnit != TextUnit::subLine && selectionUnit != TextUnit::wholeLine) {
// If it is neither, reset selection type to line selection.
selectionUnit = (Wrapping() && (FlagSet(marginOptions, MarginOption::SubLineSelect))) ? TextUnit::subLine : TextUnit::wholeLine;
}
} else {
if (selectionUnit == TextUnit::character) {
selectionUnit = TextUnit::word;
doubleClick = true;
} else if (selectionUnit == TextUnit::word) {
// Since we ended up here, we're inside a *triple* click, which should always select
// whole line regardless of word wrap being enabled or not.
selectionUnit = TextUnit::wholeLine;
} else {
selectionUnit = TextUnit::character;
originalAnchorPos = sel.MainCaret();
}
}
if (selectionUnit == TextUnit::word) {
Sci::Position charPos = originalAnchorPos;
if (sel.MainCaret() == originalAnchorPos) {
charPos = PositionFromLocation(pt, false, true);
charPos = MovePositionOutsideChar(charPos, -1);
}
Sci::Position startWord;
Sci::Position endWord;
if ((sel.MainCaret() >= originalAnchorPos) && !pdoc->IsLineEndPosition(charPos)) {
startWord = pdoc->ExtendWordSelect(pdoc->MovePositionOutsideChar(charPos + 1, 1), -1);
endWord = pdoc->ExtendWordSelect(charPos, 1);
} else {
// Selecting backwards, or anchor beyond last character on line. In these cases,
// we select the word containing the character to the *left* of the anchor.
if (charPos > pdoc->LineStart(pdoc->SciLineFromPosition(charPos))) {
startWord = pdoc->ExtendWordSelect(charPos, -1);
endWord = pdoc->ExtendWordSelect(startWord, 1);
} else {
// Anchor at start of line; select nothing to begin with.
startWord = charPos;
endWord = charPos;
}
}
wordSelectAnchorStartPos = startWord;
wordSelectAnchorEndPos = endWord;
wordSelectInitialCaretPos = sel.MainCaret();
WordSelection(wordSelectInitialCaretPos);
} else if (selectionUnit == TextUnit::subLine || selectionUnit == TextUnit::wholeLine) {
lineAnchorPos = newPos.Position();
LineSelection(lineAnchorPos, lineAnchorPos, selectionUnit == TextUnit::wholeLine);
//Platform::DebugPrintf("Triple click: %d - %d\n", anchor, currentPos);
} else {
SetEmptySelection(sel.MainCaret());
}
//Platform::DebugPrintf("Double click: %d - %d\n", anchor, currentPos);
if (doubleClick) {
NotifyDoubleClick(pt, modifiers);
if (PositionIsHotspot(newCharPos.Position()))
NotifyHotSpotDoubleClicked(newCharPos.Position(), modifiers);
}
} else { // Single click
if (inSelMargin) {
if (sel.IsRectangular() || (sel.Count() > 1)) {
InvalidateWholeSelection();
sel.Clear();
}
sel.selType = Selection::SelTypes::stream;
if (!shift) {
// Single click in margin: select wholeLine or only subLine if word wrap is enabled
lineAnchorPos = newPos.Position();
selectionUnit = (Wrapping() && (FlagSet(marginOptions, MarginOption::SubLineSelect))) ? TextUnit::subLine : TextUnit::wholeLine;
LineSelection(lineAnchorPos, lineAnchorPos, selectionUnit == TextUnit::wholeLine);
} else {
// Single shift+click in margin: select from line anchor to clicked line
if (sel.MainAnchor() > sel.MainCaret())
lineAnchorPos = sel.MainAnchor() - 1;
else
lineAnchorPos = sel.MainAnchor();
// Reset selection type if there is an empty selection.
// This ensures that we don't end up stuck in previous selection mode, which is no longer valid.
// Otherwise, if there's a non empty selection, reset selection type only if it differs from selSubLine and selWholeLine.
// This ensures that we continue selecting in the same selection mode.
if (sel.Empty() || (selectionUnit != TextUnit::subLine && selectionUnit != TextUnit::wholeLine))
selectionUnit = (Wrapping() && (FlagSet(marginOptions, MarginOption::SubLineSelect))) ? TextUnit::subLine : TextUnit::wholeLine;
LineSelection(newPos.Position(), lineAnchorPos, selectionUnit == TextUnit::wholeLine);
}
SetDragPosition(SelectionPosition(Sci::invalidPosition));
SetMouseCapture(true);
FineTickerStart(TickReason::scroll, 100, 10);
} else {
if (PointIsHotspot(pt)) {
NotifyHotSpotClicked(newCharPos.Position(), modifiers);
hotSpotClickPos = newCharPos.Position();
}
if (!shift) {
if (PointInSelection(pt) && !SelectionEmpty())
inDragDrop = DragDrop::initial;
else
inDragDrop = DragDrop::none;
}
SetMouseCapture(true);
FineTickerStart(TickReason::scroll, 100, 10);
if (inDragDrop != DragDrop::initial) {
SetDragPosition(SelectionPosition(Sci::invalidPosition));
if (!shift) {
if (ctrl && multipleSelection) {
const SelectionRange range(newPos);
sel.TentativeSelection(range);
InvalidateSelection(range, true);
} else {
InvalidateSelection(SelectionRange(newPos), true);
if (sel.Count() > 1)
Redraw();
if ((sel.Count() > 1) || (sel.selType != Selection::SelTypes::stream))
sel.Clear();
sel.selType = alt ? Selection::SelTypes::rectangle : Selection::SelTypes::stream;
SetSelection(newPos, newPos);
}
}
SelectionPosition anchorCurrent = newPos;
if (shift)
anchorCurrent = sel.IsRectangular() ?
sel.Rectangular().anchor : sel.RangeMain().anchor;
sel.selType = alt ? Selection::SelTypes::rectangle : Selection::SelTypes::stream;
selectionUnit = TextUnit::character;
originalAnchorPos = sel.MainCaret();
sel.Rectangular() = SelectionRange(newPos, anchorCurrent);
SetRectangularRange();
}
}
}
lastClickTime = curTime;
lastClick = pt;
lastXChosen = static_cast<int>(pt.x) + xOffset;
ShowCaretAtCurrentPosition();
}
void Editor::RightButtonDownWithModifiers(Point pt, unsigned int, KeyMod modifiers) {
if (NotifyMarginRightClick(pt, modifiers))
return;
}
bool Editor::PositionIsHotspot(Sci::Position position) const noexcept {
return vs.styles[pdoc->StyleIndexAt(position)].hotspot;
}
bool Editor::PointIsHotspot(Point pt) {
const Sci::Position pos = PositionFromLocation(pt, true, true);
if (pos == Sci::invalidPosition)
return false;
return PositionIsHotspot(pos);
}
void Editor::SetHoverIndicatorPosition(Sci::Position position) noexcept {
const Sci::Position hoverIndicatorPosPrev = hoverIndicatorPos;
hoverIndicatorPos = Sci::invalidPosition;
if (!vs.indicatorsDynamic)
return;
if (position != Sci::invalidPosition) {
for (const auto *deco : pdoc->decorations->View()) {
if (vs.indicators[deco->Indicator()].IsDynamic()) {
if (pdoc->decorations->ValueAt(deco->Indicator(), position)) {
hoverIndicatorPos = position;
}
}
}
}
if (hoverIndicatorPosPrev != hoverIndicatorPos) {
Redraw();
}
}
void Editor::SetHoverIndicatorPoint(Point pt) {
if (!vs.indicatorsDynamic) {
SetHoverIndicatorPosition(Sci::invalidPosition);
} else {
SetHoverIndicatorPosition(PositionFromLocation(pt, true, true));
}
}
void Editor::SetHotSpotRange(const Point *pt) {
if (pt) {
const Sci::Position pos = PositionFromLocation(*pt, false, true);
// If we don't limit this to word characters then the
// range can encompass more than the run range and then
// the underline will not be drawn properly.
Range hsNew;
hsNew.start = pdoc->ExtendStyleRange(pos, -1, hotspotSingleLine);
hsNew.end = pdoc->ExtendStyleRange(pos, 1, hotspotSingleLine);
// Only invalidate the range if the hotspot range has changed...
if (!(hsNew == hotspot)) {
if (hotspot.Valid()) {
InvalidateRange(hotspot.start, hotspot.end);
}
hotspot = hsNew;
InvalidateRange(hotspot.start, hotspot.end);
}
} else {
if (hotspot.Valid()) {
InvalidateRange(hotspot.start, hotspot.end);
}
hotspot = Range(Sci::invalidPosition);
}
}
void Editor::ButtonMoveWithModifiers(Point pt, unsigned int, KeyMod modifiers) {
if (ptMouseLast != pt) {
DwellEnd(true);
}
SelectionPosition movePos = SPositionFromLocation(pt, false, false,
AllowVirtualSpace(virtualSpaceOptions, sel.IsRectangular()));
movePos = MovePositionOutsideChar(movePos, sel.MainCaret() - movePos.Position());
if (inDragDrop == DragDrop::initial) {
if (DragThreshold(ptMouseLast, pt)) {
SetMouseCapture(false);
FineTickerCancel(TickReason::scroll);
SetDragPosition(movePos);
CopySelectionRange(drag);
StartDrag();
}
return;
}
ptMouseLast = pt;
PRectangle rcClient = GetClientRectangle();
const Point ptOrigin = GetVisibleOriginInMain();
rcClient.Move(0, -ptOrigin.y);
if ((dwellDelay < TimeForever) && rcClient.Contains(pt)) {
FineTickerStart(TickReason::dwell, dwellDelay, dwellDelay / 10);
}
//Platform::DebugPrintf("Move %.0f %.0f\n", pt.x, pt.y);
if (HaveMouseCapture()) {
// Slow down autoscrolling/selection
autoScrollTimer.ticksToWait -= Timer::tickSize;
if (autoScrollTimer.ticksToWait > 0)
return;
autoScrollTimer.ticksToWait = autoScrollDelay;
// Adjust selection
if (posDrag.IsValid()) {
SetDragPosition(movePos);
} else {
if (selectionUnit == TextUnit::character) {
if (sel.selType == Selection::SelTypes::stream && FlagSet(modifiers, KeyMod::Alt) && mouseSelectionRectangularSwitch) {
sel.selType = Selection::SelTypes::rectangle;
}
if (sel.IsRectangular()) {
sel.Rectangular() = SelectionRange(movePos, sel.Rectangular().anchor);
SetSelection(movePos, sel.RangeMain().anchor);
} else if (sel.Count() > 1) {
InvalidateSelection(sel.RangeMain(), false);
const SelectionRange range(movePos, sel.RangeMain().anchor);
sel.TentativeSelection(range);
InvalidateSelection(range, true);
} else {
SetSelection(movePos, sel.RangeMain().anchor);
}
} else if (selectionUnit == TextUnit::word) {
// Continue selecting by word
if (movePos.Position() == wordSelectInitialCaretPos) { // Didn't move
// No need to do anything. Previously this case was lumped
// in with "Moved forward", but that can be harmful in this
// case: a handler for the NotifyDoubleClick re-adjusts
// the selection for a fancier definition of "word" (for
// example, in Perl it is useful to include the leading
// '$', '%' or '@' on variables for word selection). In this
// the ButtonMove() called via TickFor() for auto-scrolling
// could result in the fancier word selection adjustment
// being unmade.
} else {
wordSelectInitialCaretPos = -1;
WordSelection(movePos.Position());
}
} else {
// Continue selecting by line
LineSelection(movePos.Position(), lineAnchorPos, selectionUnit == TextUnit::wholeLine);
}
}
// Autoscroll
const Sci::Line lineMove = DisplayFromPosition(movePos.Position());
if (pt.y >= rcClient.bottom) {
ScrollTo(lineMove - LinesOnScreen() + 1);
Redraw();
} else if (pt.y < rcClient.top) {
ScrollTo(lineMove);
Redraw();
}
EnsureCaretVisible(false, false, true);
if (hotspot.Valid() && !PointIsHotspot(pt))
SetHotSpotRange(nullptr);
if (hotSpotClickPos != Sci::invalidPosition && PositionFromLocation(pt, true, true) != hotSpotClickPos) {
if (inDragDrop == DragDrop::none) {
DisplayCursor(Window::Cursor::text);
}
hotSpotClickPos = Sci::invalidPosition;
}
} else {
if (vs.fixedColumnWidth > 0) { // There is a margin
if (PointInSelMargin(pt)) {
DisplayCursor(GetMarginCursor(pt));
SetHotSpotRange(nullptr);
SetHoverIndicatorPosition(Sci::invalidPosition);
return; // No need to test for selection
}
}
// Display regular (drag) cursor over selection
if (PointInSelection(pt) && !SelectionEmpty()) {
DisplayCursor(Window::Cursor::arrow);
SetHoverIndicatorPosition(Sci::invalidPosition);
} else {
SetHoverIndicatorPoint(pt);
if (PointIsHotspot(pt)) {
DisplayCursor(Window::Cursor::hand);
SetHotSpotRange(&pt);
} else {
if (hoverIndicatorPos != Sci::invalidPosition)
DisplayCursor(Window::Cursor::hand);
else
DisplayCursor(Window::Cursor::text);
SetHotSpotRange(nullptr);
}
}
}
}
void Editor::ButtonUpWithModifiers(Point pt, unsigned int curTime, KeyMod modifiers) {
//Platform::DebugPrintf("ButtonUp %d %d\n", HaveMouseCapture(), inDragDrop);
SelectionPosition newPos = SPositionFromLocation(pt, false, false,
AllowVirtualSpace(virtualSpaceOptions, sel.IsRectangular()));
if (hoverIndicatorPos != Sci::invalidPosition)
InvalidateRange(newPos.Position(), newPos.Position() + 1);
newPos = MovePositionOutsideChar(newPos, sel.MainCaret() - newPos.Position());
if (inDragDrop == DragDrop::initial) {
inDragDrop = DragDrop::none;
SetEmptySelection(newPos);
selectionUnit = TextUnit::character;
originalAnchorPos = sel.MainCaret();
}
if (hotSpotClickPos != Sci::invalidPosition && PointIsHotspot(pt)) {
hotSpotClickPos = Sci::invalidPosition;
SelectionPosition newCharPos = SPositionFromLocation(pt, false, true, false);
newCharPos = MovePositionOutsideChar(newCharPos, -1);
NotifyHotSpotReleaseClick(newCharPos.Position(), modifiers & KeyMod::Ctrl);
}
if (HaveMouseCapture()) {
if (PointInSelMargin(pt)) {
DisplayCursor(GetMarginCursor(pt));
} else {
DisplayCursor(Window::Cursor::text);
SetHotSpotRange(nullptr);
}
ptMouseLast = pt;
SetMouseCapture(false);
FineTickerCancel(TickReason::scroll);
NotifyIndicatorClick(false, newPos.Position(), modifiers);
if (inDragDrop == DragDrop::dragging) {
const SelectionPosition selStart = SelectionStart();
const SelectionPosition selEnd = SelectionEnd();
if (selStart < selEnd) {
if (drag.Length()) {
const Sci::Position length = drag.Length();
if (FlagSet(modifiers, KeyMod::Ctrl)) {
const Sci::Position lengthInserted = pdoc->InsertString(
newPos.Position(), drag.Data(), length);
if (lengthInserted > 0) {
SetSelection(newPos.Position(), newPos.Position() + lengthInserted);
}
} else if (newPos < selStart) {
pdoc->DeleteChars(selStart.Position(), drag.Length());
const Sci::Position lengthInserted = pdoc->InsertString(
newPos.Position(), drag.Data(), length);
if (lengthInserted > 0) {
SetSelection(newPos.Position(), newPos.Position() + lengthInserted);
}
} else if (newPos > selEnd) {
pdoc->DeleteChars(selStart.Position(), drag.Length());
newPos.Add(-static_cast<Sci::Position>(drag.Length()));
const Sci::Position lengthInserted = pdoc->InsertString(
newPos.Position(), drag.Data(), length);
if (lengthInserted > 0) {
SetSelection(newPos.Position(), newPos.Position() + lengthInserted);
}
} else {
SetEmptySelection(newPos.Position());
}
drag.Clear();
}
selectionUnit = TextUnit::character;
}
} else {
if (selectionUnit == TextUnit::character) {
if (sel.Count() > 1) {
sel.RangeMain() =
SelectionRange(newPos, sel.Range(sel.Count() - 1).anchor);
InvalidateWholeSelection();
} else {
SetSelection(newPos, sel.RangeMain().anchor);
}
}
sel.CommitTentative();
}
SetRectangularRange();
lastClickTime = curTime;
lastClick = pt;
lastXChosen = static_cast<int>(pt.x) + xOffset;
if (sel.selType == Selection::SelTypes::stream) {
SetLastXChosen();
}
inDragDrop = DragDrop::none;
EnsureCaretVisible(false);
}
}
bool Editor::Idle() {
NotifyUpdateUI();
bool needWrap = Wrapping() && wrapPending.NeedsWrap();
if (needWrap) {
// Wrap lines during idle.
WrapLines(WrapScope::wsIdle);
// No more wrapping
needWrap = wrapPending.NeedsWrap();
} else if (needIdleStyling) {
IdleStyle();
}
// Add more idle things to do here, but make sure idleDone is
// set correctly before the function returns. returning
// false will stop calling this idle function until SetIdle() is
// called again.
const bool idleDone = !needWrap && !needIdleStyling; // && thatDone && theOtherThingDone...
return !idleDone;
}
void Editor::TickFor(TickReason reason) {
switch (reason) {
case TickReason::caret:
caret.on = !caret.on;
if (caret.active) {
InvalidateCaret();
}
break;
case TickReason::scroll:
// Auto scroll
ButtonMoveWithModifiers(ptMouseLast, 0, KeyMod::Norm);
break;
case TickReason::widen:
SetScrollBars();
FineTickerCancel(TickReason::widen);
break;
case TickReason::dwell:
if ((!HaveMouseCapture()) &&
(ptMouseLast.y >= 0)) {
dwelling = true;
NotifyDwelling(ptMouseLast, dwelling);
}
FineTickerCancel(TickReason::dwell);
break;
default:
// tickPlatform handled by subclass
break;
}
}
// FineTickerStart is be overridden by subclasses that support fine ticking so
// this method should never be called.
bool Editor::FineTickerRunning(TickReason) const noexcept {
assert(false);
return false;
}
// FineTickerStart is be overridden by subclasses that support fine ticking so
// this method should never be called.
void Editor::FineTickerStart(TickReason, int, int) noexcept {
assert(false);
}
// FineTickerCancel is be overridden by subclasses that support fine ticking so
// this method should never be called.
void Editor::FineTickerCancel(TickReason) noexcept {
assert(false);
}
void Editor::SetFocusState(bool focusState) {
const bool changing = hasFocus != focusState;
hasFocus = focusState;
if (changing) {
Redraw();
}
NotifyFocus(hasFocus);
if (!hasFocus) {
CancelModes();
}
ShowCaretAtCurrentPosition();
}
Sci::Position Editor::PositionAfterArea(PRectangle rcArea) const noexcept {
// The start of the document line after the display line after the area
// This often means that the line after a modification is restyled which helps
// detect multiline comment additions and heals single line comments
const Sci::Line lineAfter = TopLineOfMain() + static_cast<Sci::Line>(rcArea.bottom - 1) / vs.lineHeight + 1;
if (lineAfter < pcs->LinesDisplayed())
return pdoc->LineStart(pcs->DocFromDisplay(lineAfter) + 1);
else
return pdoc->LengthNoExcept();
}
// Style to a position within the view. If this causes a change at end of last line then
// affects later lines so style all the viewed text.
void Editor::StyleToPositionInView(Sci::Position pos) {
Sci::Position endWindow = PositionAfterArea(GetClientDrawingRectangle());
pos = std::min(pos, endWindow);
const int styleAtEnd = pdoc->StyleIndexAt(pos - 1);
pdoc->EnsureStyledTo(pos);
if ((endWindow > pos) && (styleAtEnd != pdoc->StyleIndexAt(pos - 1))) {
// Style at end of line changed so is multi-line change like starting a comment
// so require rest of window to be styled.
DiscardOverdraw(); // Prepared bitmaps may be invalid
// DiscardOverdraw may have truncated client drawing area so recalculate endWindow
endWindow = PositionAfterArea(GetClientDrawingRectangle());
pdoc->EnsureStyledTo(endWindow);
}
}
Sci::Position Editor::PositionAfterMaxStyling(Sci::Position posMax, bool scrolling) const noexcept {
if (SynchronousStylingToVisible()) {
// Both states do not limit styling
return posMax;
}
// Try to keep time taken by styling reasonable so interaction remains smooth.
// When scrolling, allow less time to ensure responsive
const double secondsAllowed = scrolling ? 0.005 : 0.02;
Sci::Line lineLast = pdoc->SciLineFromPosition(pdoc->GetEndStyled());
const int actionsInAllowedTime = pdoc->durationStyleOneUnit.ActionsInAllowedTime(secondsAllowed);
lineLast = pdoc->LineFromPositionAfter(lineLast, actionsInAllowedTime);
const Sci::Line stylingMaxLine = std::min(lineLast, pdoc->LinesTotal());
return std::min(pdoc->LineStart(stylingMaxLine), posMax);
}
void Editor::StartIdleStyling(bool truncatedLastStyling) noexcept {
if ((idleStyling == IdleStyling::All) || (idleStyling == IdleStyling::AfterVisible)) {
if (pdoc->GetEndStyled() < pdoc->LengthNoExcept()) {
// Style remainder of document in idle time
needIdleStyling = true;
}
} else if (truncatedLastStyling) {
needIdleStyling = true;
}
if (needIdleStyling) {
SetIdle(true);
}
}
// Style for an area but bound the amount of styling to remain responsive
void Editor::StyleAreaBounded(PRectangle rcArea, bool scrolling) {
const Sci::Position posAfterArea = PositionAfterArea(rcArea);
const Sci::Position posAfterMax = PositionAfterMaxStyling(posAfterArea, scrolling);
if (posAfterMax < posAfterArea) {
// Idle styling may be performed before current visible area
// Style a bit now then style further in idle time
pdoc->StyleToAdjustingLineDuration(posAfterMax);
} else {
// Can style all wanted now.
StyleToPositionInView(posAfterArea);
}
StartIdleStyling(posAfterMax < posAfterArea);
}
void Editor::IdleStyle() {
const Sci::Position posAfterArea = PositionAfterArea(GetClientRectangle());
const Sci::Position endGoal = (idleStyling >= IdleStyling::AfterVisible) ?
pdoc->LengthNoExcept() : posAfterArea;
const Sci::Position posAfterMax = PositionAfterMaxStyling(endGoal, false);
pdoc->StyleToAdjustingLineDuration(posAfterMax);
if (pdoc->GetEndStyled() >= endGoal) {
needIdleStyling = false;
}
}
void Editor::IdleWork() {
// Style the line after the modification as this allows modifications that change just the
// line of the modification to heal instead of propagating to the rest of the window.
if (FlagSet(workNeeded.items, WorkItems::style)) {
StyleToPositionInView(pdoc->LineStart(pdoc->SciLineFromPosition(workNeeded.upTo) + 2));
}
NotifyUpdateUI();
workNeeded.Reset();
}
void Editor::QueueIdleWork(WorkItems items, Sci::Position upTo) noexcept {
workNeeded.Need(items, upTo);
}
bool Editor::SupportsFeature(Supports feature) const {
const AutoSurface surface(this);
return surface->SupportsFeature(feature);
}
bool Editor::PaintContains(PRectangle rc) const noexcept {
if (rc.Empty()) {
return true;
} else {
return rcPaint.Contains(rc);
}
}
bool Editor::PaintContainsMargin() const noexcept {
if (HasMarginWindow()) {
// With separate margin view, paint of text view
// never contains margin.
return false;
}
PRectangle rcSelMargin = GetClientRectangle();
rcSelMargin.right = static_cast<XYPOSITION>(vs.textStart);
return PaintContains(rcSelMargin);
}
void Editor::CheckForChangeOutsidePaint(Range r) noexcept {
if (paintState == PaintState::painting && !paintingAllText) {
//Platform::DebugPrintf("Checking range in paint %d-%d\n", r.start, r.end);
if (!r.Valid())
return;
PRectangle rcRange = RectangleFromRange(r, 0);
const PRectangle rcText = GetTextRectangle();
rcRange.top = std::max(rcRange.top, rcText.top);
rcRange.bottom = std::min(rcRange.bottom, rcText.bottom);
if (!PaintContains(rcRange)) {
AbandonPaint();
paintAbandonedByStyling = true;
}
}
}
void Editor::SetBraceHighlight(Sci::Position pos0, Sci::Position pos1, int matchStyle) noexcept {
if ((pos0 != braces[0]) || (pos1 != braces[1]) || (matchStyle != bracesMatchStyle)) {
if ((braces[0] != pos0) || (matchStyle != bracesMatchStyle)) {
CheckForChangeOutsidePaint(Range(braces[0]));
CheckForChangeOutsidePaint(Range(pos0));
braces[0] = pos0;
}
if ((braces[1] != pos1) || (matchStyle != bracesMatchStyle)) {
CheckForChangeOutsidePaint(Range(braces[1]));
CheckForChangeOutsidePaint(Range(pos1));
braces[1] = pos1;
}
bracesMatchStyle = matchStyle;
if (paintState == PaintState::notPainting) {
Redraw();
}
}
}
void Editor::SetAnnotationHeights(Sci::Line start, Sci::Line end) {
if (vs.annotationVisible != AnnotationVisible::Hidden) {
RefreshStyleData();
bool changedHeight = false;
end = std::min(end, pdoc->LinesTotal());
for (Sci::Line line = start; line < end; line++) {
int linesWrapped = 1;
if (Wrapping()) {
const AutoSurface surface(this);
if (surface) {
LineLayout * const ll = view.RetrieveLineLayout(line, *this);
view.LayoutLine(*this, surface, vs, ll, wrapWidth, LayoutLineOption::ManualUpdate);
linesWrapped = ll->lines;
}
}
if (pcs->SetHeight(line, pdoc->AnnotationLines(line) + linesWrapped))
changedHeight = true;
}
if (changedHeight) {
SetScrollBars();
SetVerticalScrollPos();
Redraw();
}
}
}
void Editor::SetDocPointer(Document *document) {
//Platform::DebugPrintf("** %p setdoc to %p\n", pdoc, document);
pdoc->RemoveWatcher(this, nullptr);
pdoc->Release();
if (document == nullptr) {
pdoc = new Document(DocumentOption::StylesNone);
} else {
pdoc = document;
}
pdoc->AddRef();
pcs = ContractionStateCreate(pdoc->IsLarge());
// Ensure all positions within document
sel.Clear();
targetRange = SelectionSegment();
braces[0] = Sci::invalidPosition;
braces[1] = Sci::invalidPosition;
vs.ReleaseAllExtendedStyles();
SetRepresentations();
// Reset the contraction state to fully shown.
pcs->Clear();
pcs->InsertLines(0, pdoc->LinesTotal() - 1);
SetAnnotationHeights(0, pdoc->LinesTotal());
view.llc.Deallocate();
NeedWrapping();
hotspot = Range(Sci::invalidPosition);
hoverIndicatorPos = Sci::invalidPosition;
view.ClearAllTabstops();
pdoc->AddWatcher(this, nullptr);
SetScrollBars();
Redraw();
}
void Editor::SetAnnotationVisible(AnnotationVisible visible) {
if (vs.annotationVisible != visible) {
const bool changedFromOrToHidden = ((vs.annotationVisible != AnnotationVisible::Hidden) != (visible != AnnotationVisible::Hidden));
vs.annotationVisible = visible;
if (changedFromOrToHidden) {
const int dir = (vs.annotationVisible!= AnnotationVisible::Hidden) ? 1 : -1;
const Sci::Line maxLine = pdoc->LinesTotal();
for (Sci::Line line = 0; line < maxLine; line++) {
const int annotationLines = pdoc->AnnotationLines(line);
if (annotationLines > 0) {
pcs->SetHeight(line, pcs->GetHeight(line) + annotationLines * dir);
}
}
SetScrollBars();
}
Redraw();
}
}
void Editor::SetEOLAnnotationVisible(EOLAnnotationVisible visible) noexcept {
if (vs.eolAnnotationVisible != visible) {
vs.eolAnnotationVisible = visible;
Redraw();
}
}
/**
* Recursively expand a fold, making lines visible except where they have an unexpanded parent.
*/
Sci::Line Editor::ExpandLine(Sci::Line line, FoldLevel level, Sci::Line *parentLine) {
const Sci::Line lineMaxSubord = pdoc->GetLastChild(line, level);
line++;
Sci::Line lineStart = parentLine ? *parentLine : line;
while (line <= lineMaxSubord) {
level = pdoc->GetFoldLevel(line);
if (LevelIsHeader(level)) {
if (pcs->GetExpanded(line)) {
line = ExpandLine(line, level, &lineStart);
} else {
pcs->SetVisible(lineStart, line, true);
line = pdoc->GetLastChild(line, level);
lineStart = line + 1;
}
}
line++;
}
if (parentLine) {
*parentLine = lineStart;
} else if (lineStart <= lineMaxSubord) {
pcs->SetVisible(lineStart, lineMaxSubord, true);
}
return lineMaxSubord;
}
void Editor::SetFoldExpanded(Sci::Line lineDoc, bool expanded) {
if (pcs->SetExpanded(lineDoc, expanded)) {
RedrawSelMargin();
}
}
void Editor::FoldLine(Sci::Line line, FoldAction action) {
if (line >= 0) {
FoldLevel level = pdoc->GetFoldLevel(line);
if (action == FoldAction::Toggle) {
if (!LevelIsHeader(level)) {
line = pdoc->GetFoldParent(line);
if (line < 0) {
return;
}
level = pdoc->GetFoldLevel(line);
}
action = pcs->GetExpanded(line) ? FoldAction::Contract : FoldAction::Expand;
}
const bool visible = pcs->GetVisible(line);
if (action == FoldAction::Contract) {
const Sci::Line lineMaxSubord = pdoc->GetLastChild(line, level);
if (lineMaxSubord > line) {
pcs->SetExpanded(line, false);
if (visible) {
pcs->SetVisible(line + 1, lineMaxSubord, false);
}
const Sci::Line lineCurrent = pdoc->SciLineFromPosition(sel.MainCaret());
if (lineCurrent > line && lineCurrent <= lineMaxSubord) {
// This does not re-expand the fold
EnsureCaretVisible();
}
}
} else {
if (!visible) {
EnsureLineVisible(line, false);
GoToLine(line);
}
pcs->SetExpanded(line, true);
ExpandLine(line, level);
}
SetScrollBars();
Redraw();
}
}
void Editor::FoldExpand(Sci::Line line, FoldAction action, FoldLevel level) {
bool expanding = action == FoldAction::Expand;
if (action == FoldAction::Toggle) {
expanding = !pcs->GetExpanded(line);
}
// Ensure child lines lexed and fold information extracted before
// flipping the state.
pdoc->GetLastChild(line, level);
SetFoldExpanded(line, expanding);
if (expanding && (pcs->HiddenLines() == 0)) {
// Nothing to do
return;
}
const Sci::Line lineMaxSubord = pdoc->GetLastChild(line, level);
line++;
pcs->SetVisible(line, lineMaxSubord, expanding);
while (line <= lineMaxSubord) {
const FoldLevel levelLine = pdoc->GetFoldLevel(line);
if (LevelIsHeader(levelLine)) {
SetFoldExpanded(line, expanding);
}
line++;
}
SetScrollBars();
Redraw();
}
Sci::Line Editor::ContractedFoldNext(Sci::Line lineStart) const noexcept {
const Sci::Line maxLine = pdoc->LinesTotal();
for (Sci::Line line = lineStart; line < maxLine;) {
if (!pcs->GetExpanded(line) && LevelIsHeader(pdoc->GetFoldLevel(line)))
return line;
line = pcs->ContractedNext(line + 1);
if (line < 0)
return -1;
}
return -1;
}
/**
* Recurse up from this line to find any folds that prevent this line from being visible
* and unfold them all.
*/
void Editor::EnsureLineVisible(Sci::Line lineDoc, bool enforcePolicy) {
// In case in need of wrapping to ensure DisplayFromDoc works.
if (lineDoc >= wrapPending.start) {
if (WrapLines(WrapScope::wsAll)) {
Redraw();
}
}
if (!pcs->GetVisible(lineDoc)) {
// Back up to find a non-blank line
Sci::Line lookLine = lineDoc;
FoldLevel lookLineLevel = pdoc->GetFoldLevel(lookLine);
while ((lookLine > 0) && LevelIsWhitespace(lookLineLevel)) {
lookLineLevel = pdoc->GetFoldLevel(--lookLine);
}
Sci::Line lineParent = pdoc->GetFoldParent(lookLine);
if (lineParent < 0) {
// Backed up to a top level line, so try to find parent of initial line
lineParent = pdoc->GetFoldParent(lineDoc);
}
if (lineParent >= 0) {
if (lineDoc != lineParent)
EnsureLineVisible(lineParent, enforcePolicy);
if (pcs->SetExpanded(lineParent, true)) {
ExpandLine(lineParent);
}
}
SetScrollBars();
Redraw();
}
if (enforcePolicy) {
const Sci::Line lineDisplay = pcs->DisplayFromDoc(lineDoc);
if (FlagSet(visiblePolicy.policy, VisiblePolicy::Slop)) {
if ((topLine > lineDisplay) || ((FlagSet(visiblePolicy.policy, VisiblePolicy::Strict)) && (topLine + visiblePolicy.slop > lineDisplay))) {
SetTopLine(std::clamp<Sci::Line>(lineDisplay - visiblePolicy.slop, 0, MaxScrollPos()));
SetVerticalScrollPos();
Redraw();
} else if ((lineDisplay > topLine + LinesOnScreen() - 1) ||
((FlagSet(visiblePolicy.policy, VisiblePolicy::Strict)) && (lineDisplay > topLine + LinesOnScreen() - 1 - visiblePolicy.slop))) {
SetTopLine(std::clamp<Sci::Line>(lineDisplay - LinesOnScreen() + 1 + visiblePolicy.slop, 0, MaxScrollPos()));
SetVerticalScrollPos();
Redraw();
}
} else {
if ((topLine > lineDisplay) || (lineDisplay > topLine + LinesOnScreen() - 1) || (FlagSet(visiblePolicy.policy, VisiblePolicy::Strict))) {
SetTopLine(std::clamp<Sci::Line>(lineDisplay - LinesOnScreen() / 2 + 1, 0, MaxScrollPos()));
SetVerticalScrollPos();
Redraw();
}
}
}
}
void Editor::FoldAll(FoldAction action) {
const Sci::Line maxLine = pdoc->LinesTotal();
const bool contractAll = FlagSet(action, FoldAction::ContractEveryLevel);
action = static_cast<FoldAction>(static_cast<int>(action) & ~static_cast<int>(FoldAction::ContractEveryLevel));
bool expanding = action == FoldAction::Expand;
if (!expanding) {
pdoc->EnsureStyledTo(pdoc->LengthNoExcept());
}
Sci::Line line = 0;
if (action == FoldAction::Toggle) {
// Discover current state
for (; line < maxLine; line++) {
const FoldLevel level = pdoc->GetFoldLevel(line);
if (LevelIsHeader(level)) {
const FoldLevel levelNext = pdoc->GetFoldLevel(line + 1);
if (LevelNumber(level) < LevelNumber(levelNext)) {
expanding = !pcs->GetExpanded(line);
break;
}
}
}
}
if (expanding) {
pcs->SetVisible(0, maxLine - 1, true);
pcs->ExpandAll();
} else {
FoldLevel topLevel = FoldLevel::NumberMask;
for (; line < maxLine; line++) {
const FoldLevel level = pdoc->GetFoldLevel(line);
if (LevelIsHeader(level)) {
const FoldLevel levelNum = LevelNumberPart(level);
if (levelNum <= topLevel) {
topLevel = levelNum;
const Sci::Line lineMaxSubord = pdoc->GetLastChild(line, level);
if (lineMaxSubord > line) {
pcs->SetExpanded(line, false);
pcs->SetVisible(line + 1, lineMaxSubord, false);
if (!contractAll) {
line = lineMaxSubord;
}
}
} else if (contractAll) {
const FoldLevel levelNext = pdoc->GetFoldLevel(line + 1);
if (levelNum < LevelNumberPart(levelNext)) {
pcs->SetExpanded(line, false);
}
}
}
}
}
SetScrollBars();
Redraw();
}
void Editor::FoldChanged(Sci::Line line, FoldLevel levelNow, FoldLevel levelPrev) {
if (LevelIsHeader(levelNow)) {
if (!LevelIsHeader(levelPrev)) {
// Adding a fold point.
SetFoldExpanded(line, true);
FoldExpand(line, FoldAction::Expand, levelPrev);
}
} else if (LevelIsHeader(levelPrev)) {
const Sci::Line prevLine = line - 1;
const FoldLevel prevLineLevel = pdoc->GetFoldLevel(prevLine);
// Combining two blocks where the first block is collapsed (e.g. by deleting the line(s) which separate(s) the two blocks)
if ((LevelNumber(prevLineLevel) == LevelNumber(levelNow)) && !pcs->GetVisible(prevLine))
FoldLine(pdoc->GetFoldParent(prevLine), FoldAction::Expand);
if (!pcs->GetExpanded(line)) {
// Removing the fold from one that has been contracted so should expand
// otherwise lines are left invisible with no way to make them visible
SetFoldExpanded(line, true);
// Combining two blocks where the second one is collapsed (e.g. by adding characters in the line which separates the two blocks)
FoldExpand(line, FoldAction::Expand, levelPrev);
}
}
if (!LevelIsWhitespace(levelNow) &&
(LevelNumber(levelPrev) > LevelNumber(levelNow))) {
if (pcs->HiddenLines()) {
// See if should still be hidden
const Sci::Line parentLine = pdoc->GetFoldParent(line);
if ((parentLine < 0) || (pcs->GetExpanded(parentLine) && pcs->GetVisible(parentLine))) {
pcs->SetVisible(line, line, true);
SetScrollBars();
Redraw();
}
}
}
// Combining two blocks where the first one is collapsed (e.g. by adding characters in the line which separates the two blocks)
if (!LevelIsWhitespace(levelNow) && (LevelNumber(levelPrev) < LevelNumber(levelNow))) {
if (pcs->HiddenLines()) {
const Sci::Line parentLine = pdoc->GetFoldParent(line);
if (!pcs->GetExpanded(parentLine) && pcs->GetVisible(line))
FoldLine(parentLine, FoldAction::Expand);
}
}
}
void Editor::NeedShown(Sci::Position pos, Sci::Position len) {
if (FlagSet(foldAutomatic, AutomaticFold::Show)) {
const Sci::Line lineStart = pdoc->SciLineFromPosition(pos);
const Sci::Line lineEnd = pdoc->SciLineFromPosition(pos + len);
for (Sci::Line line = lineStart; line <= lineEnd; line++) {
EnsureLineVisible(line, false);
}
} else {
NotifyNeedShown(pos, len);
}
}
Sci::Position Editor::GetTag(char *tagValue, int tagNumber) {
const char *text = nullptr;
Sci::Position length = 0;
if ((tagNumber >= 1) && (tagNumber <= 9)) {
char name[3] = "\\?";
name[1] = static_cast<char>(tagNumber + '0');
length = 2;
text = pdoc->SubstituteByPosition(name, &length);
}
if (tagValue) {
if (text)
memcpy(tagValue, text, length + 1);
else
*tagValue = '\0';
}
return length;
}
Sci::Position Editor::ReplaceTarget(ReplaceType replaceType, std::string_view text) {
const UndoGroup ug(pdoc);
if (replaceType == ReplaceType::patterns) {
Sci::Position length = text.length();
const char *p = pdoc->SubstituteByPosition(text.data(), &length);
if (!p) {
return 0;
}
text = std::string_view(p, length);
}
if (replaceType == ReplaceType::minimal) {
// Check for prefix and suffix and reduce text and target to match.
// This is performed with Range which doesn't support virtual space.
Range range(targetRange.start.Position(), targetRange.end.Position());
pdoc->TrimReplacement(text, range);
// Re-apply virtual space to start if start position didn't change.
// Don't bother with end as its virtual space is not used
const SelectionPosition start(range.start == targetRange.start.Position() ?
targetRange.start : SelectionPosition(range.start));
targetRange = SelectionSegment(start, SelectionPosition(range.end));
}
// Remove the text inside the range
if (targetRange.Length() > 0) {
pdoc->DeleteChars(targetRange.start.Position(), targetRange.Length());
}
targetRange.end = targetRange.start;
// Realize virtual space of target start
const Sci::Position startAfterSpaceInsertion = RealizeVirtualSpace(targetRange.start.Position(), targetRange.start.VirtualSpace());
targetRange.start.SetPosition(startAfterSpaceInsertion);
targetRange.end = targetRange.start;
// Insert the new text
const Sci::Position lengthInserted = pdoc->InsertString(targetRange.start.Position(), text);
targetRange.end.SetPosition(targetRange.start.Position() + lengthInserted);
return text.length();
}
bool Editor::IsUnicodeMode() const noexcept {
return pdoc && (CpUtf8 == pdoc->dbcsCodePage);
}
int Editor::CodePage() const noexcept {
if (pdoc)
return pdoc->dbcsCodePage;
else
return 0;
}
std::unique_ptr<Surface> Editor::CreateMeasurementSurface() const {
if (!wMain.GetID()) {
return {};
}
std::unique_ptr<Surface> surf = Surface::Allocate(technology);
surf->Init(wMain.GetID());
surf->SetMode(CurrentSurfaceMode());
return surf;
}
std::unique_ptr<Surface> Editor::CreateDrawingSurface(SurfaceID sid, bool printing) const {
if (!wMain.GetID()) {
return {};
}
std::unique_ptr<Surface> surf = Surface::Allocate(printing ? Technology::Default : technology);
surf->Init(sid, wMain.GetID(), printing);
surf->SetMode(CurrentSurfaceMode());
return surf;
}
Sci::Line Editor::WrapCount(Sci::Line line) {
const AutoSurface surface(this);
if (surface) {
LineLayout * const ll = view.RetrieveLineLayout(line, *this);
view.LayoutLine(*this, surface, vs, ll, wrapWidth, LayoutLineOption::AutoUpdate);
return ll->lines;
} else {
return 1;
}
}
void Editor::AddStyledText(const char *buffer, Sci::Position appendLength) {
// The buffer consists of alternating character bytes and style bytes
const Sci::Position textLength = appendLength / 2;
std::string text(textLength, '\0');
for (Sci::Position i = 0; i < textLength; i++) {
text[i] = buffer[i * 2];
}
const Sci::Position lengthInserted = pdoc->InsertString(CurrentPosition(), text);
for (Sci::Position i = 0; i < textLength; i++) {
text[i] = buffer[i * 2 + 1];
}
pdoc->StartStyling(CurrentPosition());
pdoc->SetStyles(textLength, reinterpret_cast<const unsigned char*>(text.c_str()));
SetEmptySelection(sel.MainCaret() + lengthInserted);
}
Sci::Position Editor::GetStyledText(char *buffer, Sci::Position cpMin, Sci::Position cpMax) const noexcept {
Sci::Position iPlace = 0;
for (Sci::Position iChar = cpMin; iChar < cpMax; iChar++) {
buffer[iPlace++] = pdoc->CharAt(iChar);
buffer[iPlace++] = pdoc->StyleAt(iChar);
}
buffer[iPlace] = '\0';
buffer[iPlace + 1] = '\0';
return iPlace;
}
Sci::Position Editor::GetTextRange(char *buffer, Sci::Position cpMin, Sci::Position cpMax) const noexcept {
const Sci::Position cpEnd = (cpMax == -1) ? pdoc->Length() : cpMax;
PLATFORM_ASSERT(cpEnd <= pdoc->Length());
const Sci::Position len = cpEnd - cpMin; // No -1 as cpMin and cpMax are referring to inter character positions
pdoc->GetCharRange(buffer, cpMin, len);
// Spec says copied text is terminated with a NUL
buffer[len] = '\0';
return len; // Not including NUL
}
bool Editor::ValidMargin(uptr_t wParam) const noexcept {
return wParam < vs.ms.size();
}
void Editor::StyleSetMessage(Message iMessage, uptr_t wParam, sptr_t lParam) {
vs.EnsureStyle(wParam);
switch (iMessage) {
case Message::StyleSetFore:
vs.styles[wParam].fore = ColourRGBA::FromIpRGB(lParam);
break;
case Message::StyleSetBack:
vs.styles[wParam].back = ColourRGBA::FromIpRGB(lParam);
break;
case Message::StyleSetBold:
vs.fontsValid = false;
vs.styles[wParam].weight = lParam != 0 ? FontWeight::Bold : FontWeight::Normal;
break;
case Message::StyleSetWeight:
vs.fontsValid = false;
vs.styles[wParam].weight = static_cast<FontWeight>(lParam);
break;
case Message::StyleSetItalic:
vs.fontsValid = false;
vs.styles[wParam].italic = lParam != 0;
break;
case Message::StyleSetEOLFilled:
vs.styles[wParam].eolFilled = lParam != 0;
break;
case Message::StyleSetSize:
vs.fontsValid = false;
vs.styles[wParam].size = static_cast<int>(lParam * FontSizeMultiplier);
break;
case Message::StyleSetSizeFractional:
vs.fontsValid = false;
vs.styles[wParam].size = static_cast<int>(lParam);
break;
case Message::StyleSetFont:
if (lParam != 0) {
vs.SetStyleFontName(static_cast<int>(wParam), ConstCharPtrFromSPtr(lParam));
}
break;
case Message::StyleSetUnderline:
vs.styles[wParam].underline = lParam != 0;
break;
case Message::StyleSetStrike: // 2011-12-20
vs.styles[wParam].strike = lParam != 0;
break;
case Message::StyleSetOverline: // 2022-02-06
vs.styles[wParam].overline = lParam != 0;
break;
case Message::StyleSetCase:
vs.styles[wParam].caseForce = static_cast<Style::CaseForce>(lParam);
break;
case Message::StyleSetCharacterSet:
vs.fontsValid = false;
vs.styles[wParam].characterSet = static_cast<CharacterSet>(lParam);
break;
case Message::StyleSetVisible:
vs.styles[wParam].visible = lParam != 0;
break;
case Message::StyleSetChangeable:
vs.styles[wParam].changeable = lParam != 0;
break;
case Message::StyleSetInvisibleRepresentation: {
const char *utf8 = ConstCharPtrFromSPtr(lParam);
const size_t len = strlen(utf8);
memcpy(vs.styles[wParam].invisibleRepresentation, utf8, len + 1);
vs.styles[wParam].invisibleRepresentationLength = static_cast<uint8_t>(len);
break;
}
case Message::StyleSetHotSpot:
vs.styles[wParam].hotspot = lParam != 0;
break;
case Message::StyleSetCheckMonospaced:
vs.styles[wParam].checkMonospaced = lParam != 0;
break;
default:
break;
}
InvalidateStyleRedraw();
}
sptr_t Editor::StyleGetMessage(Message iMessage, uptr_t wParam, sptr_t lParam) {
vs.EnsureStyle(wParam);
switch (iMessage) {
case Message::StyleGetFore:
return vs.styles[wParam].fore.OpaqueRGB();
case Message::StyleGetBack:
return vs.styles[wParam].back.OpaqueRGB();
case Message::StyleGetBold:
return vs.styles[wParam].weight > FontWeight::Normal;
case Message::StyleGetWeight:
return static_cast<sptr_t>(vs.styles[wParam].weight);
case Message::StyleGetItalic:
return vs.styles[wParam].italic ? 1 : 0;
case Message::StyleGetEOLFilled:
return vs.styles[wParam].eolFilled ? 1 : 0;
case Message::StyleGetSize:
return vs.styles[wParam].size / FontSizeMultiplier;
case Message::StyleGetSizeFractional:
return vs.styles[wParam].size;
case Message::StyleGetFont:
return StringResult(lParam, vs.styles[wParam].fontName);
case Message::StyleGetUnderline:
return vs.styles[wParam].underline ? 1 : 0;
case Message::StyleGetStrike:
return vs.styles[wParam].strike ? 1 : 0;
case Message::StyleGetCase:
return static_cast<sptr_t>(vs.styles[wParam].caseForce);
case Message::StyleGetCharacterSet:
return static_cast<sptr_t>(vs.styles[wParam].characterSet);
case Message::StyleGetVisible:
return vs.styles[wParam].visible ? 1 : 0;
case Message::StyleGetChangeable:
return vs.styles[wParam].changeable ? 1 : 0;
case Message::StyleGetInvisibleRepresentation:
return StringResult(lParam, vs.styles[wParam].invisibleRepresentation);
case Message::StyleGetHotSpot:
return vs.styles[wParam].hotspot ? 1 : 0;
case Message::StyleGetCheckMonospaced:
return vs.styles[wParam].checkMonospaced ? 1 : 0;
default:
break;
}
return 0;
}
void Editor::SetSelectionNMessage(Message iMessage, uptr_t wParam, sptr_t lParam) noexcept {
if (wParam >= sel.Count()) {
return;
}
InvalidateRange(sel.Range(wParam).Start().Position(), sel.Range(wParam).End().Position());
switch (iMessage) {
case Message::SetSelectionNCaret:
sel.Range(wParam).caret.SetPosition(lParam);
break;
case Message::SetSelectionNAnchor:
sel.Range(wParam).anchor.SetPosition(lParam);
break;
case Message::SetSelectionNCaretVirtualSpace:
sel.Range(wParam).caret.SetVirtualSpace(lParam);
break;
case Message::SetSelectionNAnchorVirtualSpace:
sel.Range(wParam).anchor.SetVirtualSpace(lParam);
break;
case Message::SetSelectionNStart:
sel.Range(wParam).anchor.SetPosition(lParam);
break;
case Message::SetSelectionNEnd:
sel.Range(wParam).caret.SetPosition(lParam);
break;
default:
break;
}
InvalidateRange(sel.Range(wParam).Start().Position(), sel.Range(wParam).End().Position());
ContainerNeedsUpdate(Update::Selection);
}
sptr_t Editor::StringResult(sptr_t lParam, const char *val) noexcept {
const size_t len = val ? strlen(val) : 0;
if (lParam) {
char *ptr = CharPtrFromSPtr(lParam);
if (val)
memcpy(ptr, val, len + 1);
else
*ptr = 0;
}
return len; // Not including NUL
}
sptr_t Editor::BytesResult(sptr_t lParam, const unsigned char *val, size_t len) noexcept {
// No NUL termination: len is number of valid/displayed bytes
if ((lParam) && (len > 0)) {
char *ptr = CharPtrFromSPtr(lParam);
if (val)
memcpy(ptr, val, len);
else
*ptr = 0;
}
return val ? len : 0;
}
sptr_t Editor::WndProc(Message iMessage, uptr_t wParam, sptr_t lParam) {
//Platform::DebugPrintf("S start wnd proc %u %d %d\n", iMessage, wParam, lParam);
// Optional macro recording hook
if (recordingMacro)
NotifyMacroRecord(iMessage, wParam, lParam);
switch (iMessage) {
case Message::GetText: {
if (lParam == 0)
return pdoc->LengthNoExcept();
if (wParam == 0)
return 0;
char *ptr = CharPtrFromSPtr(lParam);
const Sci_Position len = std::min<Sci_Position>(wParam, pdoc->LengthNoExcept());
pdoc->GetCharRange(ptr, 0, len);
ptr[len] = '\0';
return len;
}
case Message::SetText: {
if (lParam == 0)
return 0;
const UndoGroup ug(pdoc);
pdoc->DeleteChars(0, pdoc->LengthNoExcept());
SetEmptySelection(0);
const char *text = ConstCharPtrFromSPtr(lParam);
pdoc->InsertString(0, text, strlen(text));
return 1;
}
case Message::GetTextLength:
return pdoc->LengthNoExcept();
case Message::Cut:
Cut(wParam != 0);
SetLastXChosen();
break;
case Message::Copy:
Copy(wParam != 0);
break;
case Message::CopyAllowLine:
CopyAllowLine();
break;
case Message::VerticalCentreCaret:
VerticalCentreCaret();
break;
case Message::MoveSelectedLinesUp:
MoveSelectedLinesUp();
break;
case Message::MoveSelectedLinesDown:
MoveSelectedLinesDown();
break;
case Message::CopyRange:
CopyRangeToClipboard(PositionFromUPtr(wParam), lParam);
break;
case Message::CopyText:
CopyText(wParam, ConstCharPtrFromSPtr(lParam));
break;
case Message::Paste:
Paste(wParam != 0);
if ((caretSticky == CaretSticky::Off) || (caretSticky == CaretSticky::WhiteSpace)) {
SetLastXChosen();
}
EnsureCaretVisible();
break;
case Message::ReplaceRectangular: {
const UndoGroup ug(pdoc);
if (!sel.Empty()) {
ClearSelection(); // want to replace rectangular selection contents
}
InsertPasteShape(ConstCharPtrFromSPtr(lParam), PositionFromUPtr(wParam), PasteShape::rectangular);
break;
}
case Message::Clear:
Clear();
SetLastXChosen();
EnsureCaretVisible();
break;
case Message::Undo:
Undo();
SetLastXChosen();
break;
case Message::CanUndo:
return (pdoc->CanUndo() && !pdoc->IsReadOnly()) ? 1 : 0;
case Message::EmptyUndoBuffer:
pdoc->DeleteUndoHistory();
return 0;
case Message::GetFirstVisibleLine:
return topLine;
case Message::SetFirstVisibleLine:
ScrollTo(LineFromUPtr(wParam));
break;
case Message::GetLine: { // Risk of overwriting the end of the buffer
const Sci::Position lineStart =
pdoc->LineStart(LineFromUPtr(wParam));
const Sci::Position lineEnd =
pdoc->LineStart(LineFromUPtr(wParam) + 1);
// not NULL terminated
const Sci::Position len = lineEnd - lineStart;
if (lParam == 0) {
return len;
}
char *ptr = CharPtrFromSPtr(lParam);
pdoc->GetCharRange(ptr, lineStart, len);
ptr[len] = '\0'; //! overwriting
return len;
}
case Message::GetLineCount: {
const Sci::Line lines = pdoc->LinesTotal();
return lines ? lines : 1;
}
case Message::AllocateLines:
pdoc->AllocateLines(wParam);
break;
case Message::GetModify:
return !pdoc->IsSavePoint();
case Message::SetSel: {
Sci::Position nStart = PositionFromUPtr(wParam);
Sci::Position nEnd = lParam;
if (nEnd < 0)
nEnd = pdoc->LengthNoExcept();
if (nStart < 0)
nStart = nEnd; // Remove selection
InvalidateSelection(SelectionRange(nStart, nEnd));
sel.Clear();
sel.selType = Selection::SelTypes::stream;
SetSelection(nEnd, nStart);
EnsureCaretVisible();
}
break;
case Message::GetSelText: {
SelectionText selectedText;
selectedText.asBinary = wParam != 0;
CopySelectionRange(selectedText);
const size_t iChar = selectedText.Length();
if (lParam) {
char *ptr = CharPtrFromSPtr(lParam);
memcpy(ptr, selectedText.Data(), iChar);
ptr[iChar] = '\0';
}
return iChar;
}
case Message::LineFromPosition:
if (PositionFromUPtr(wParam) < 0)
return 0;
return pdoc->SciLineFromPosition(PositionFromUPtr(wParam));
case Message::PositionFromLine:
if (PositionFromUPtr(wParam) < 0)
wParam = pdoc->SciLineFromPosition(SelectionStart().Position());
if (wParam == 0)
return 0; // Even if there is no text, there is a first line that starts at 0
if (LineFromUPtr(wParam) > pdoc->LinesTotal())
return -1;
//if (wParam > pdoc->SciLineFromPosition(pdoc->LengthNoExcept())) // Useful test, anyway...
// return -1;
return pdoc->LineStart(LineFromUPtr(wParam));
// Replacement of the old Scintilla interpretation of EM_LINELENGTH
case Message::LineLength:
if (LineFromUPtr(wParam) < 0 ||
LineFromUPtr(wParam) > pdoc->SciLineFromPosition(pdoc->LengthNoExcept()))
return 0;
return pdoc->LineStart(LineFromUPtr(wParam) + 1) - pdoc->LineStart(LineFromUPtr(wParam));
case Message::ReplaceSel: {
if (lParam == 0)
return 0;
const UndoGroup ug(pdoc);
ClearSelection();
const char *replacement = ConstCharPtrFromSPtr(lParam);
const Sci::Position lengthInserted = pdoc->InsertString(
sel.MainCaret(), replacement, strlen(replacement));
SetEmptySelection(sel.MainCaret() + lengthInserted);
SetLastXChosen();
EnsureCaretVisible();
}
break;
case Message::SetTargetStart:
targetRange.start.SetPosition(PositionFromUPtr(wParam));
break;
case Message::GetTargetStart:
return targetRange.start.Position();
case Message::SetTargetStartVirtualSpace:
targetRange.start.SetVirtualSpace(PositionFromUPtr(wParam));
break;
case Message::GetTargetStartVirtualSpace:
return targetRange.start.VirtualSpace();
case Message::SetTargetEnd:
targetRange.end.SetPosition(PositionFromUPtr(wParam));
break;
case Message::GetTargetEnd:
return targetRange.end.Position();
case Message::SetTargetEndVirtualSpace:
targetRange.end.SetVirtualSpace(PositionFromUPtr(wParam));
break;
case Message::GetTargetEndVirtualSpace:
return targetRange.end.VirtualSpace();
case Message::SetTargetRange:
targetRange.start.SetPosition(PositionFromUPtr(wParam));
targetRange.end.SetPosition(lParam);
break;
case Message::TargetWholeDocument:
targetRange.start.SetPosition(0);
targetRange.end.SetPosition(pdoc->LengthNoExcept());
break;
case Message::TargetFromSelection:
targetRange.start = sel.RangeMain().Start();
targetRange.end = sel.RangeMain().End();
break;
case Message::GetTargetText: {
const std::string text = RangeText(targetRange.start.Position(), targetRange.end.Position());
return BytesResult(lParam, reinterpret_cast<const unsigned char *>(text.c_str()), text.length());
}
case Message::ReplaceTarget:
PLATFORM_ASSERT(lParam);
return ReplaceTarget(ReplaceType::basic, ViewFromParams(lParam, wParam));
case Message::ReplaceTargetRE:
PLATFORM_ASSERT(lParam);
return ReplaceTarget(ReplaceType::patterns, ViewFromParams(lParam, wParam));
case Message::ReplaceTargetMinimal:
PLATFORM_ASSERT(lParam);
return ReplaceTarget(ReplaceType::minimal, ViewFromParams(lParam, wParam));
case Message::SearchInTarget:
PLATFORM_ASSERT(lParam);
return SearchInTarget(ConstCharPtrFromSPtr(lParam), PositionFromUPtr(wParam));
case Message::SetSearchFlags:
searchFlags = static_cast<FindOption>(wParam);
break;
case Message::GetSearchFlags:
return static_cast<sptr_t>(searchFlags);
case Message::GetTag:
return GetTag(CharPtrFromSPtr(lParam), static_cast<int>(wParam));
case Message::PositionBefore:
return pdoc->MovePositionOutsideChar(PositionFromUPtr(wParam) - 1, -1, true);
case Message::PositionAfter:
return pdoc->MovePositionOutsideChar(PositionFromUPtr(wParam) + 1, 1, true);
case Message::PositionRelative:
return std::clamp<Sci::Position>(pdoc->GetRelativePosition(
PositionFromUPtr(wParam), lParam),
0, pdoc->LengthNoExcept());
case Message::PositionRelativeCodeUnits:
return std::clamp<Sci::Position>(pdoc->GetRelativePositionUTF16(
PositionFromUPtr(wParam), lParam),
0, pdoc->LengthNoExcept());
case Message::LineScroll:
ScrollTo(topLine + lParam);
HorizontalScrollTo(xOffset + static_cast<int>(static_cast<int>(wParam) * vs.spaceWidth));
return 1;
case Message::SetXOffset:
xOffset = static_cast<int>(wParam);
ContainerNeedsUpdate(Update::HScroll);
SetHorizontalScrollPos();
Redraw();
break;
case Message::GetXOffset:
return xOffset;
case Message::ChooseCaretX:
SetLastXChosen();
break;
case Message::ScrollCaret:
EnsureCaretVisible();
break;
case Message::SetReadOnly:
pdoc->SetReadOnly(wParam != 0);
return 1;
case Message::GetReadOnly:
return pdoc->IsReadOnly();
case Message::CanPaste:
return CanPaste();
case Message::PointXFromPosition:
if (lParam < 0) {
return 0;
} else {
const Point pt = LocationFromPosition(lParam);
// Convert to view-relative
return static_cast<int>(pt.x) - vs.textStart + vs.fixedColumnWidth;
}
case Message::PointYFromPosition:
if (lParam < 0) {
return 0;
} else {
const Point pt = LocationFromPosition(lParam);
return static_cast<int>(pt.y);
}
case Message::FindTextFull:
return FindTextFull(wParam, lParam);
case Message::GetTextRangeFull:
if (const TextRangeFull *tr = static_cast<const TextRangeFull *>(PtrFromSPtr(lParam))) {
return GetTextRange(tr->lpstrText, tr->chrg.cpMin, tr->chrg.cpMax);
}
return 0;
case Message::HideSelection:
vs.selection.visible = wParam != 0;
Redraw();
break;
case Message::GetSelectionHidden:
return !vs.selection.visible;
break;
case Message::FormatRangeFull:
return FormatRange(iMessage, wParam, lParam);
case Message::GetMarginLeft:
return vs.leftMarginWidth;
case Message::GetMarginRight:
return vs.rightMarginWidth;
case Message::SetMarginLeft:
lastXChosen += static_cast<int>(lParam) - vs.leftMarginWidth;
vs.leftMarginWidth = static_cast<int>(lParam);
InvalidateStyleRedraw();
break;
case Message::SetMarginRight:
vs.rightMarginWidth = static_cast<int>(lParam);
InvalidateStyleRedraw();
break;
// Control specific messages
case Message::AddText: {
if (lParam == 0)
return 0;
const Sci::Position lengthInserted = pdoc->InsertString(
CurrentPosition(), ConstCharPtrFromSPtr(lParam), PositionFromUPtr(wParam));
SetEmptySelection(sel.MainCaret() + lengthInserted);
return 0;
}
case Message::AddStyledText:
if (lParam)
AddStyledText(ConstCharPtrFromSPtr(lParam), PositionFromUPtr(wParam));
return 0;
case Message::InsertText: {
if (lParam == 0)
return 0;
Sci::Position insertPos = PositionFromUPtr(wParam);
if (insertPos < 0)
insertPos = CurrentPosition();
Sci::Position newCurrent = CurrentPosition();
const char *sz = ConstCharPtrFromSPtr(lParam);
const Sci::Position lengthInserted = pdoc->InsertString(insertPos, sz, strlen(sz));
if (newCurrent > insertPos)
newCurrent += lengthInserted;
SetEmptySelection(newCurrent);
return 0;
}
case Message::ChangeInsertion:
PLATFORM_ASSERT(lParam);
pdoc->ChangeInsertion(ConstCharPtrFromSPtr(lParam), PositionFromUPtr(wParam));
return 0;
case Message::AppendText:
pdoc->InsertString(pdoc->LengthNoExcept(),
ConstCharPtrFromSPtr(lParam), PositionFromUPtr(wParam));
return 0;
case Message::ClearAll:
ClearAll();
return 0;
case Message::DeleteRange:
pdoc->DeleteChars(PositionFromUPtr(wParam), lParam);
return 0;
case Message::ClearDocumentStyle:
ClearDocumentStyle();
return 0;
case Message::SetUndoCollection:
pdoc->SetUndoCollection(wParam != 0);
return 0;
case Message::GetUndoCollection:
return pdoc->IsCollectingUndo();
case Message::BeginUndoAction:
pdoc->BeginUndoAction();
return 0;
case Message::EndUndoAction:
pdoc->EndUndoAction();
return 0;
case Message::GetCaretPeriod:
return caret.period;
case Message::SetCaretPeriod:
CaretSetPeriod(static_cast<int>(wParam));
break;
case Message::GetWordChars:
return pdoc->GetCharsOfClass(CharacterClass::word, UCharPtrFromSPtr(lParam));
case Message::SetWordChars: {
pdoc->SetDefaultCharClasses(false);
if (lParam == 0)
return 0;
pdoc->SetCharClasses(ConstUCharPtrFromSPtr(lParam), CharacterClass::word);
}
break;
case Message::SetCharClassesEx:
pdoc->SetCharClassesEx(ConstUCharPtrFromSPtr(lParam), wParam);
break;
case Message::GetWhitespaceChars:
return pdoc->GetCharsOfClass(CharacterClass::space, UCharPtrFromSPtr(lParam));
case Message::SetWhitespaceChars: {
if (lParam == 0)
return 0;
pdoc->SetCharClasses(ConstUCharPtrFromSPtr(lParam), CharacterClass::space);
}
break;
case Message::GetPunctuationChars:
return pdoc->GetCharsOfClass(CharacterClass::punctuation, UCharPtrFromSPtr(lParam));
case Message::SetPunctuationChars: {
if (lParam == 0)
return 0;
pdoc->SetCharClasses(ConstUCharPtrFromSPtr(lParam), CharacterClass::punctuation);
}
break;
case Message::SetCharsDefault:
pdoc->SetDefaultCharClasses(true);
break;
#if 0
case Message::SetCharacterCategoryOptimization:
pdoc->SetCharacterCategoryOptimization(static_cast<int>(wParam));
break;
case Message::GetCharacterCategoryOptimization:
return pdoc->CharacterCategoryOptimization();
#endif
case Message::GetLength:
return pdoc->LengthNoExcept();
case Message::Allocate:
pdoc->Allocate(PositionFromUPtr(wParam));
break;
case Message::GetCharAt:
return pdoc->UCharAt(PositionFromUPtr(wParam));
case Message::GetCharacterAndWidth:
return pdoc->GetCharacterAndWidth(wParam, reinterpret_cast<Sci_Position *>(lParam));
case Message::GetCharacterClass:
return static_cast<int>(pdoc->GetCharacterClass(static_cast<unsigned int>(wParam)));
case Message::SetCurrentPos:
if (sel.IsRectangular()) {
sel.Rectangular().caret.SetPosition(PositionFromUPtr(wParam));
SetRectangularRange();
Redraw();
} else {
SetSelection(PositionFromUPtr(wParam), sel.MainAnchor());
}
break;
case Message::GetCurrentPos:
return sel.IsRectangular() ? sel.Rectangular().caret.Position() : sel.MainCaret();
case Message::SetAnchor:
if (sel.IsRectangular()) {
sel.Rectangular().anchor.SetPosition(PositionFromUPtr(wParam));
SetRectangularRange();
Redraw();
} else {
SetSelection(sel.MainCaret(), PositionFromUPtr(wParam));
}
break;
case Message::GetAnchor:
return sel.IsRectangular() ? sel.Rectangular().anchor.Position() : sel.MainAnchor();
case Message::SetSelectionStart:
SetSelection(std::max(sel.MainCaret(), PositionFromUPtr(wParam)), PositionFromUPtr(wParam));
break;
case Message::GetSelectionStart:
return sel.LimitsForRectangularElseMain().start.Position();
case Message::SetSelectionEnd:
SetSelection(PositionFromUPtr(wParam), std::min(sel.MainAnchor(), PositionFromUPtr(wParam)));
break;
case Message::GetSelectionEnd:
return sel.LimitsForRectangularElseMain().end.Position();
case Message::SetEmptySelection:
SetEmptySelection(PositionFromUPtr(wParam));
break;
case Message::SetPrintMagnification:
view.printParameters.magnification = std::clamp(static_cast<int>(wParam), MinZoomLevel, MaxZoomLevel);
break;
case Message::GetPrintMagnification:
return view.printParameters.magnification;
case Message::SetPrintColourMode:
view.printParameters.colourMode = static_cast<PrintOption>(wParam);
break;
case Message::GetPrintColourMode:
return static_cast<sptr_t>(view.printParameters.colourMode);
case Message::SetPrintWrapMode:
view.printParameters.wrapState = (static_cast<Wrap>(wParam) == Wrap::Word) ? Wrap::Word : Wrap::None;
break;
case Message::GetPrintWrapMode:
return static_cast<sptr_t>(view.printParameters.wrapState);
case Message::GetStyleIndexAt:
return pdoc->StyleIndexAt(PositionFromUPtr(wParam));
case Message::Redo:
Redo();
break;
case Message::SelectAll:
SelectAll();
break;
case Message::SetSavePoint:
pdoc->SetSavePoint();
break;
case Message::GetStyledTextFull:
if (const TextRangeFull *tr = static_cast<TextRangeFull *>(PtrFromSPtr(lParam))) {
return GetStyledText(tr->lpstrText, tr->chrg.cpMin, tr->chrg.cpMax);
}
return 0;
case Message::CanRedo:
return (pdoc->CanRedo() && !pdoc->IsReadOnly()) ? 1 : 0;
case Message::MarkerLineFromHandle:
return pdoc->LineFromHandle(static_cast<int>(wParam));
case Message::MarkerDeleteHandle:
pdoc->DeleteMarkFromHandle(static_cast<int>(wParam));
break;
case Message::MarkerHandleFromLine:
return pdoc->MarkerHandleFromLine(LineFromUPtr(wParam), static_cast<int>(lParam));
case Message::MarkerNumberFromLine:
return pdoc->MarkerNumberFromLine(LineFromUPtr(wParam), static_cast<int>(lParam));
case Message::GetViewWS:
return static_cast<sptr_t>(vs.viewWhitespace);
case Message::SetViewWS:
vs.viewWhitespace = static_cast<WhiteSpace>(wParam);
Redraw();
break;
case Message::GetTabDrawMode:
return static_cast<sptr_t>(vs.tabDrawMode);
case Message::SetTabDrawMode:
vs.tabDrawMode = static_cast<TabDrawMode>(wParam);
Redraw();
break;
case Message::GetWhitespaceSize:
return vs.whitespaceSize;
case Message::SetWhitespaceSize:
vs.whitespaceSize = static_cast<int>(wParam);
Redraw();
break;
case Message::PositionFromPoint:
return PositionFromLocation(PointFromParameters(wParam, lParam), false, false);
case Message::PositionFromPointClose:
return PositionFromLocation(PointFromParameters(wParam, lParam), true, false);
case Message::CharPositionFromPoint:
return PositionFromLocation(PointFromParameters(wParam, lParam), false, true);
case Message::CharPositionFromPointClose:
return PositionFromLocation(PointFromParameters(wParam, lParam), true, true);
case Message::GotoLine:
GoToLine(LineFromUPtr(wParam));
break;
case Message::GotoPos:
SetEmptySelection(PositionFromUPtr(wParam));
EnsureCaretVisible();
break;
case Message::GetCurLine: {
const Sci::Line lineCurrentPos = pdoc->SciLineFromPosition(sel.MainCaret());
const Sci::Position lineStart = pdoc->LineStart(lineCurrentPos);
const Sci::Position lineEnd = pdoc->LineStart(lineCurrentPos + 1);
if (lParam == 0) {
return lineEnd - lineStart;
}
char *ptr = CharPtrFromSPtr(lParam);
const Sci::Position len = std::min<Sci::Position>(lineEnd - lineStart, wParam);
pdoc->GetCharRange(ptr, lineStart, len);
ptr[len] = '\0';
return sel.MainCaret() - lineStart;
}
case Message::GetEndStyled:
return pdoc->GetEndStyled();
case Message::GetEOLMode:
return static_cast<sptr_t>(pdoc->eolMode);
case Message::SetEOLMode:
pdoc->eolMode = static_cast<EndOfLine>(wParam);
break;
case Message::SetLineEndTypesAllowed:
if (pdoc->SetLineEndTypesAllowed(static_cast<LineEndType>(wParam))) {
pcs->Clear();
pcs->InsertLines(0, pdoc->LinesTotal() - 1);
SetAnnotationHeights(0, pdoc->LinesTotal());
InvalidateStyleRedraw();
}
break;
case Message::GetLineEndTypesAllowed:
return static_cast<sptr_t>(pdoc->GetLineEndTypesAllowed());
case Message::GetLineEndTypesActive:
return static_cast<sptr_t>(pdoc->GetLineEndTypesActive());
case Message::StartStyling:
pdoc->StartStyling(PositionFromUPtr(wParam));
break;
case Message::SetStyling:
if (PositionFromUPtr(wParam) < 0)
errorStatus = Status::Failure;
else
pdoc->SetStyleFor(PositionFromUPtr(wParam), static_cast<unsigned char>(lParam));
break;
case Message::SetStylingEx: // Specify a complete styling buffer
if (lParam == 0)
return 0;
pdoc->SetStyles(PositionFromUPtr(wParam), ConstUCharPtrFromSPtr(lParam));
break;
case Message::SetBufferedDraw:
view.bufferedDraw = wParam != 0;
break;
case Message::GetBufferedDraw:
return view.bufferedDraw;
case Message::GetPhasesDraw:
return static_cast<sptr_t>(view.phasesDraw);
case Message::SetPhasesDraw:
if (view.SetPhasesDraw(static_cast<int>(wParam)))
InvalidateStyleRedraw();
break;
case Message::SetFontQuality:
vs.extraFontFlag = static_cast<FontQuality>(
(static_cast<int>(vs.extraFontFlag) & ~static_cast<int>(FontQuality::QualityMask)) |
(wParam & static_cast<int>(FontQuality::QualityMask)));
vs.fontsValid = false;
InvalidateStyleRedraw();
break;
case Message::GetFontQuality:
return static_cast<int>(vs.extraFontFlag) & static_cast<int>(FontQuality::QualityMask);
case Message::SetTabWidth:
if (wParam > 0) {
pdoc->tabInChars = static_cast<int>(wParam);
if (pdoc->indentInChars == 0)
pdoc->actualIndentInChars = pdoc->tabInChars;
}
InvalidateStyleRedraw();
break;
case Message::GetTabWidth:
return pdoc->tabInChars;
case Message::SetTabMinimumWidth:
SetAppearance(view.tabWidthMinimumPixels, static_cast<int>(wParam));
break;
case Message::GetTabMinimumWidth:
return view.tabWidthMinimumPixels;
case Message::ClearTabStops:
if (view.ClearTabstops(LineFromUPtr(wParam))) {
const DocModification mh(ModificationFlags::ChangeTabStops, 0, 0, 0, nullptr, LineFromUPtr(wParam));
NotifyModified(pdoc, mh, nullptr);
}
break;
case Message::AddTabStop:
if (view.AddTabstop(LineFromUPtr(wParam), static_cast<int>(lParam))) {
const DocModification mh(ModificationFlags::ChangeTabStops, 0, 0, 0, nullptr, LineFromUPtr(wParam));
NotifyModified(pdoc, mh, nullptr);
}
break;
case Message::GetNextTabStop:
return view.GetNextTabstop(LineFromUPtr(wParam), static_cast<int>(lParam));
case Message::SetIndent:
pdoc->indentInChars = static_cast<int>(wParam);
if (pdoc->indentInChars != 0)
pdoc->actualIndentInChars = pdoc->indentInChars;
else
pdoc->actualIndentInChars = pdoc->tabInChars;
InvalidateStyleRedraw();
break;
case Message::GetIndent:
return pdoc->indentInChars;
case Message::SetUseTabs:
pdoc->useTabs = wParam != 0;
InvalidateStyleRedraw();
break;
case Message::GetUseTabs:
return pdoc->useTabs;
case Message::SetLineIndentation:
pdoc->SetLineIndentation(LineFromUPtr(wParam), lParam);
break;
case Message::GetLineIndentation:
return pdoc->GetLineIndentation(LineFromUPtr(wParam));
case Message::GetLineIndentPosition:
return pdoc->GetLineIndentPosition(LineFromUPtr(wParam));
case Message::SetTabIndents:
pdoc->tabIndents = wParam != 0;
break;
case Message::GetTabIndents:
return pdoc->tabIndents;
case Message::SetBackSpaceUnIndents:
pdoc->backspaceUnindents = static_cast<uint8_t>(wParam);
break;
case Message::GetBackSpaceUnIndents:
return pdoc->backspaceUnindents;
case Message::SetMouseDwellTime:
dwellDelay = static_cast<int>(wParam);
ticksToDwell = dwellDelay;
break;
case Message::GetMouseDwellTime:
return dwellDelay;
case Message::WordStartPosition:
return pdoc->ExtendWordSelect(PositionFromUPtr(wParam), -1, lParam != 0);
case Message::WordEndPosition:
return pdoc->ExtendWordSelect(PositionFromUPtr(wParam), 1, lParam != 0);
case Message::IsRangeWord:
return pdoc->IsWordAt(PositionFromUPtr(wParam), lParam);
case Message::SetIdleStyling:
idleStyling = static_cast<IdleStyling>(wParam);
break;
case Message::GetIdleStyling:
return static_cast<sptr_t>(idleStyling);
case Message::SetWrapMode:
if (vs.SetWrapState(static_cast<Wrap>(wParam))) {
xOffset = 0;
ContainerNeedsUpdate(Update::HScroll);
InvalidateStyleRedraw();
ReconfigureScrollBars();
}
break;
case Message::GetWrapMode:
return static_cast<sptr_t>(vs.wrap.state);
case Message::SetWrapVisualFlags:
if (vs.SetWrapVisualFlags(static_cast<WrapVisualFlag>(wParam))) {
InvalidateStyleRedraw();
ReconfigureScrollBars();
}
break;
case Message::GetWrapVisualFlags:
return static_cast<sptr_t>(vs.wrap.visualFlags);
case Message::SetWrapVisualFlagsLocation:
if (vs.SetWrapVisualFlagsLocation(static_cast<WrapVisualLocation>(wParam))) {
InvalidateStyleRedraw();
}
break;
case Message::GetWrapVisualFlagsLocation:
return static_cast<sptr_t>(vs.wrap.visualFlagsLocation);
case Message::SetWrapStartIndent:
if (vs.SetWrapVisualStartIndent(static_cast<int>(wParam))) {
InvalidateStyleRedraw();
ReconfigureScrollBars();
}
break;
case Message::GetWrapStartIndent:
return vs.wrap.visualStartIndent;
case Message::SetWrapIndentMode:
if (vs.SetWrapIndentMode(static_cast<WrapIndentMode>(wParam))) {
InvalidateStyleRedraw();
ReconfigureScrollBars();
}
break;
case Message::GetWrapIndentMode:
return static_cast<sptr_t>(vs.wrap.indentMode);
case Message::SetLayoutCache:
if (static_cast<LineCache>(wParam) <= LineCache::Document) {
view.llc.SetLevel(static_cast<LineCache>(wParam));
}
break;
case Message::GetLayoutCache:
return static_cast<sptr_t>(view.llc.GetLevel());
case Message::SetPositionCache:
view.posCache.SetSize(wParam);
break;
case Message::GetPositionCache:
return view.posCache.GetSize();
case Message::SetScrollWidth:
PLATFORM_ASSERT(wParam > 0);
if ((wParam > 0) && (wParam != static_cast<unsigned int>(scrollWidth))) {
view.lineWidthMaxSeen = 0;
scrollWidth = static_cast<int>(wParam);
SetScrollBars();
}
break;
case Message::GetScrollWidth:
return scrollWidth;
case Message::SetScrollWidthTracking:
trackLineWidth = wParam != 0;
break;
case Message::GetScrollWidthTracking:
return trackLineWidth;
case Message::LinesJoin:
LinesJoin();
break;
case Message::LinesSplit:
LinesSplit(static_cast<int>(wParam));
break;
case Message::TextWidth:
PLATFORM_ASSERT(wParam < vs.styles.size());
PLATFORM_ASSERT(lParam);
return TextWidth(wParam, ConstCharPtrFromSPtr(lParam));
case Message::TextHeight:
RefreshStyleData();
return vs.lineHeight;
case Message::SetEndAtLastLine: {
const int line = std::clamp(static_cast<int>(wParam), 0, 4);
if (endAtLastLine != line) {
endAtLastLine = line;
SetScrollBars();
}
}
break;
case Message::GetEndAtLastLine:
return endAtLastLine;
case Message::SetCaretSticky:
PLATFORM_ASSERT(static_cast<CaretSticky>(wParam) <= CaretSticky::WhiteSpace);
if (static_cast<CaretSticky>(wParam) <= CaretSticky::WhiteSpace) {
caretSticky = static_cast<CaretSticky>(wParam);
}
break;
case Message::GetCaretSticky:
return static_cast<sptr_t>(caretSticky);
case Message::ToggleCaretSticky:
caretSticky = (caretSticky == CaretSticky::Off) ? CaretSticky::On : CaretSticky::Off;
break;
case Message::GetColumn:
return pdoc->GetColumn(PositionFromUPtr(wParam));
case Message::FindColumn:
return pdoc->FindColumn(LineFromUPtr(wParam), lParam);
case Message::SetHScrollBar:
if (horizontalScrollBarVisible != (wParam != 0)) {
horizontalScrollBarVisible = wParam != 0;
SetScrollBars();
ReconfigureScrollBars();
}
break;
case Message::GetHScrollBar:
return horizontalScrollBarVisible;
case Message::SetVScrollBar:
if (verticalScrollBarVisible != (wParam != 0)) {
verticalScrollBarVisible = wParam != 0;
SetScrollBars();
ReconfigureScrollBars();
if (verticalScrollBarVisible)
SetVerticalScrollPos();
}
break;
case Message::GetVScrollBar:
return verticalScrollBarVisible;
case Message::SetIndentationGuides:
vs.viewIndentationGuides = static_cast<IndentView>(wParam);
Redraw();
break;
case Message::GetIndentationGuides:
return static_cast<sptr_t>(vs.viewIndentationGuides);
case Message::SetHighlightGuide:
if ((highlightGuideColumn != static_cast<int>(wParam)) || (wParam > 0)) {
highlightGuideColumn = static_cast<int>(wParam);
Redraw();
}
break;
case Message::GetHighlightGuide:
return highlightGuideColumn;
case Message::GetLineEndPosition:
return pdoc->LineEnd(LineFromUPtr(wParam));
case Message::SetCodePage:
if (ValidCodePage(static_cast<int>(wParam))) {
const int oldCodePage = pdoc->dbcsCodePage;
if (pdoc->SetDBCSCodePage(static_cast<int>(wParam))) {
pcs->Clear();
pcs->InsertLines(0, pdoc->LinesTotal() - 1);
SetAnnotationHeights(0, pdoc->LinesTotal());
InvalidateStyleRedraw();
SetRepresentations();
NotifyCodePageChanged(oldCodePage);
}
}
break;
case Message::GetCodePage:
return pdoc->dbcsCodePage;
case Message::SetIMEInteraction:
imeInteraction = static_cast<IMEInteraction>(wParam);
break;
case Message::GetIMEInteraction:
return static_cast<sptr_t>(imeInteraction);
case Message::SetBidirectional:
// Message::SetBidirectional is implemented on platform subclasses if they support bidirectional text.
break;
case Message::GetBidirectional:
return static_cast<sptr_t>(bidirectional);
case Message::GetLineCharacterIndex:
return static_cast<sptr_t>(pdoc->LineCharacterIndex());
case Message::AllocateLineCharacterIndex:
pdoc->AllocateLineCharacterIndex(static_cast<LineCharacterIndexType>(wParam));
break;
case Message::ReleaseLineCharacterIndex:
pdoc->ReleaseLineCharacterIndex(static_cast<LineCharacterIndexType>(wParam));
break;
case Message::LineFromIndexPosition:
return pdoc->LineFromPositionIndex(LineFromUPtr(wParam), static_cast<LineCharacterIndexType>(lParam));
case Message::IndexPositionFromLine:
return pdoc->IndexLineStart(LineFromUPtr(wParam), static_cast<LineCharacterIndexType>(lParam));
// Marker definition and setting
case Message::MarkerDefine:
if (wParam <= MarkerMax) {
vs.markers[wParam].markType = static_cast<MarkerSymbol>(lParam);
vs.CalcLargestMarkerHeight();
}
InvalidateStyleData();
RedrawSelMargin();
break;
case Message::MarkerSymbolDefined:
if (wParam <= MarkerMax)
return static_cast<sptr_t>(vs.markers[wParam].markType);
else
return 0;
case Message::MarkerSetForeTranslucent:
if (wParam <= MarkerMax)
vs.markers[wParam].fore = ColourRGBA(static_cast<unsigned int>(lParam));
InvalidateStyleData();
RedrawSelMargin();
break;
case Message::MarkerSetBackTranslucent:
if (wParam <= MarkerMax)
vs.markers[wParam].back = ColourRGBA(static_cast<unsigned int>(lParam));
InvalidateStyleData();
RedrawSelMargin();
break;
case Message::MarkerSetBackSelectedTranslucent:
if (wParam <= MarkerMax)
vs.markers[wParam].backSelected = ColourRGBA(static_cast<unsigned int>(lParam));
InvalidateStyleData();
RedrawSelMargin();
break;
case Message::MarkerSetStrokeWidth:
if (wParam <= MarkerMax)
vs.markers[wParam].strokeWidth = lParam / 100.0f;
InvalidateStyleData();
RedrawSelMargin();
break;
case Message::MarkerEnableHighlight:
marginView.highlightDelimiter.isEnabled = wParam == 1;
RedrawSelMargin();
break;
case Message::MarkerSetLayer:
if (wParam <= MarkerMax) {
SetAppearance(vs.markers[wParam].layer, static_cast<Layer>(lParam));
}
break;
case Message::MarkerGetLayer:
if (wParam <= MarkerMax) {
return static_cast<sptr_t>(vs.markers[wParam].layer);
}
return 0;
case Message::MarkerAdd: {
const int markerID = pdoc->AddMark(LineFromUPtr(wParam), static_cast<int>(lParam));
return markerID;
}
case Message::MarkerAddSet:
if (lParam != 0)
pdoc->AddMarkSet(LineFromUPtr(wParam), static_cast<MarkerMask>(lParam));
break;
case Message::MarkerDelete:
pdoc->DeleteMark(LineFromUPtr(wParam), static_cast<int>(lParam));
break;
case Message::MarkerDeleteAll:
pdoc->DeleteAllMarks(static_cast<int>(wParam));
break;
case Message::MarkerGet:
return GetMark(LineFromUPtr(wParam));
case Message::MarkerNext:
return pdoc->MarkerNext(LineFromUPtr(wParam), static_cast<MarkerMask>(lParam));
case Message::MarkerPrevious: {
for (Sci::Line iLine = LineFromUPtr(wParam); iLine >= 0; iLine--) {
if ((GetMark(iLine) & lParam) != 0)
return iLine;
}
}
return -1;
case Message::MarkerDefinePixmap:
if (wParam <= MarkerMax) {
vs.markers[wParam].SetXPM(ConstCharPtrFromSPtr(lParam));
vs.CalcLargestMarkerHeight();
}
InvalidateStyleData();
RedrawSelMargin();
break;
case Message::RGBAImageSetWidth:
sizeRGBAImage.x = static_cast<XYPOSITION>(wParam);
break;
case Message::RGBAImageSetHeight:
sizeRGBAImage.y = static_cast<XYPOSITION>(wParam);
break;
case Message::RGBAImageSetScale:
scaleRGBAImage = static_cast<float>(wParam);
break;
case Message::MarkerDefineRGBAImage:
if (wParam <= MarkerMax) {
vs.markers[wParam].SetRGBAImage(sizeRGBAImage, scaleRGBAImage / 100.0f, ConstUCharPtrFromSPtr(lParam));
vs.CalcLargestMarkerHeight();
}
InvalidateStyleData();
RedrawSelMargin();
break;
case Message::SetMarginTypeN:
if (ValidMargin(wParam)) {
vs.ms[wParam].style = static_cast<MarginType>(lParam);
InvalidateStyleRedraw();
}
break;
case Message::GetMarginTypeN:
if (ValidMargin(wParam))
return static_cast<sptr_t>(vs.ms[wParam].style);
else
return 0;
case Message::SetMarginWidthN:
if (ValidMargin(wParam)) {
// Short-circuit if the width is unchanged, to avoid unnecessary redraw.
if (vs.ms[wParam].width != lParam) {
lastXChosen += static_cast<int>(lParam) - vs.ms[wParam].width;
vs.ms[wParam].width = static_cast<int>(lParam);
InvalidateStyleRedraw();
}
}
break;
case Message::GetMarginWidthN:
if (ValidMargin(wParam))
return vs.ms[wParam].width;
else
return 0;
case Message::SetMarginMaskN:
if (ValidMargin(wParam)) {
vs.ms[wParam].mask = static_cast<MarkerMask>(lParam);
InvalidateStyleRedraw();
}
break;
case Message::GetMarginMaskN:
if (ValidMargin(wParam))
return vs.ms[wParam].mask;
else
return 0;
case Message::SetMarginSensitiveN:
if (ValidMargin(wParam)) {
vs.ms[wParam].sensitive = lParam != 0;
InvalidateStyleRedraw();
}
break;
case Message::GetMarginSensitiveN:
if (ValidMargin(wParam))
return vs.ms[wParam].sensitive ? 1 : 0;
else
return 0;
case Message::SetMarginCursorN:
if (ValidMargin(wParam))
vs.ms[wParam].cursor = static_cast<CursorShape>(lParam);
break;
case Message::GetMarginCursorN:
if (ValidMargin(wParam))
return static_cast<sptr_t>(vs.ms[wParam].cursor);
else
return 0;
case Message::SetMarginBackN:
if (ValidMargin(wParam)) {
vs.ms[wParam].back = ColourRGBA::FromIpRGB(lParam);
InvalidateStyleRedraw();
}
break;
case Message::GetMarginBackN:
if (ValidMargin(wParam))
return vs.ms[wParam].back.OpaqueRGB();
else
return 0;
case Message::SetMargins:
if (wParam < 1000)
vs.ms.resize(wParam);
break;
case Message::GetMargins:
return vs.ms.size();
case Message::StyleClearAll:
vs.ClearStyles();
InvalidateStyleRedraw();
break;
case Message::CopyStyles:
vs.CopyStyles(wParam, lParam);
InvalidateStyleRedraw();
break;
case Message::StyleSetFore:
case Message::StyleSetBack:
case Message::StyleSetBold:
case Message::StyleSetWeight:
case Message::StyleSetItalic:
case Message::StyleSetEOLFilled:
case Message::StyleSetSize:
case Message::StyleSetSizeFractional:
case Message::StyleSetFont:
case Message::StyleSetUnderline:
case Message::StyleSetStrike:
case Message::StyleSetOverline:
case Message::StyleSetCase:
case Message::StyleSetCharacterSet:
case Message::StyleSetVisible:
case Message::StyleSetChangeable:
case Message::StyleSetHotSpot:
case Message::StyleSetCheckMonospaced:
case Message::StyleSetInvisibleRepresentation:
StyleSetMessage(iMessage, wParam, lParam);
break;
case Message::StyleGetFore:
case Message::StyleGetBack:
case Message::StyleGetBold:
case Message::StyleGetWeight:
case Message::StyleGetItalic:
case Message::StyleGetEOLFilled:
case Message::StyleGetSize:
case Message::StyleGetSizeFractional:
case Message::StyleGetFont:
case Message::StyleGetUnderline:
case Message::StyleGetStrike:
case Message::StyleGetCase:
case Message::StyleGetCharacterSet:
case Message::StyleGetVisible:
case Message::StyleGetChangeable:
case Message::StyleGetHotSpot:
case Message::StyleGetCheckMonospaced:
case Message::StyleGetInvisibleRepresentation:
return StyleGetMessage(iMessage, wParam, lParam);
case Message::StyleResetDefault:
vs.ResetDefaultStyle();
InvalidateStyleRedraw();
break;
case Message::SetElementColour:
if (vs.SetElementColour(static_cast<Element>(wParam), ColourRGBA(static_cast<unsigned int>(lParam)))) {
InvalidateStyleRedraw();
}
break;
case Message::GetElementColour:
return vs.ElementColour(static_cast<Element>(wParam)).value_or(ColourRGBA()).AsInteger();
case Message::ResetElementColour:
if (vs.ResetElement(static_cast<Element>(wParam))) {
InvalidateStyleRedraw();
}
break;
case Message::GetElementIsSet:
return vs.ElementColour(static_cast<Element>(wParam)).has_value();
case Message::GetElementAllowsTranslucent:
return ViewStyle::ElementAllowsTranslucent(static_cast<Element>(wParam));
case Message::GetElementBaseColour:
return vs.elementBaseColours[static_cast<Element>(wParam)].value_or(ColourRGBA()).AsInteger();
case Message::SetFontLocale:
if (lParam != 0) {
vs.SetFontLocaleName(ConstCharPtrFromSPtr(lParam));
}
break;
case Message::GetFontLocale:
return StringResult(lParam, vs.localeName.c_str());
case Message::SetLineState:
return pdoc->SetLineState(LineFromUPtr(wParam), static_cast<int>(lParam));
case Message::GetLineState:
return pdoc->GetLineState(LineFromUPtr(wParam));
case Message::GetCaretLineVisibleAlways:
return vs.caretLine.alwaysShow;
case Message::SetCaretLineVisibleAlways:
vs.caretLine.alwaysShow = wParam != 0;
InvalidateStyleRedraw();
break;
case Message::GetCaretLineHighlightSubLine:
return vs.caretLine.subLine;
case Message::SetCaretLineHighlightSubLine:
vs.caretLine.subLine = wParam != 0;
InvalidateStyleRedraw();
break;
case Message::GetCaretLineFrame:
return vs.caretLine.frame;
case Message::SetCaretLineFrame:
vs.caretLine.frame = static_cast<int>(wParam);
InvalidateStyleRedraw();
break;
case Message::GetCaretLineLayer:
return static_cast<sptr_t>(vs.caretLine.layer);
case Message::SetCaretLineLayer:
if (vs.caretLine.layer != static_cast<Layer>(wParam)) {
vs.caretLine.layer = static_cast<Layer>(wParam);
UpdateBaseElements();
InvalidateStyleRedraw();
}
break;
// Folding messages
case Message::VisibleFromDocLine:
return pcs->DisplayFromDoc(LineFromUPtr(wParam));
case Message::DocLineFromVisible:
return pcs->DocFromDisplay(LineFromUPtr(wParam));
case Message::WrapCount:
return WrapCount(LineFromUPtr(wParam));
case Message::SetFoldLevel: {
const int prev = pdoc->SetLevel(LineFromUPtr(wParam), static_cast<int>(lParam));
if (prev != static_cast<int>(lParam))
RedrawSelMargin();
return prev;
}
case Message::GetFoldLevel:
return pdoc->GetLevel(LineFromUPtr(wParam));
case Message::GetLastChild:
return pdoc->GetLastChild(LineFromUPtr(wParam), (lParam < 0 ? FoldLevel::None : static_cast<FoldLevel>(lParam)));
case Message::GetFoldParent:
return pdoc->GetFoldParent(LineFromUPtr(wParam));
case Message::ShowLines:
pcs->SetVisible(LineFromUPtr(wParam), lParam, true);
SetScrollBars();
Redraw();
break;
case Message::HideLines:
pcs->SetVisible(LineFromUPtr(wParam), lParam, false);
SetScrollBars();
Redraw();
break;
case Message::GetLineVisible:
return pcs->GetVisible(LineFromUPtr(wParam));
case Message::GetAllLinesVisible:
return pcs->HiddenLines() ? 0 : 1;
case Message::SetFoldExpanded:
SetFoldExpanded(LineFromUPtr(wParam), lParam != 0);
break;
case Message::GetFoldExpanded:
return pcs->GetExpanded(LineFromUPtr(wParam));
case Message::SetAutomaticFold:
foldAutomatic = static_cast<AutomaticFold>(wParam);
break;
case Message::GetAutomaticFold:
return static_cast<sptr_t>(foldAutomatic);
case Message::SetFoldFlags:
foldFlags = static_cast<FoldFlag>(wParam);
Redraw();
break;
case Message::ToggleFoldShowText:
#if EnablePerLineFoldDisplayText
pcs->SetFoldDisplayText(LineFromUPtr(wParam), ConstCharPtrFromSPtr(lParam));
#endif
FoldLine(LineFromUPtr(wParam), FoldAction::Toggle);
break;
case Message::FoldDisplayTextSetStyle:
foldDisplayTextStyle = static_cast<FoldDisplayTextStyle>(wParam);
Redraw();
break;
case Message::FoldDisplayTextGetStyle:
return static_cast<sptr_t>(foldDisplayTextStyle);
case Message::SetDefaultFoldDisplayText:
SetDefaultFoldDisplayText(ConstCharPtrFromSPtr(lParam));
Redraw();
break;
case Message::GetDefaultFoldDisplayText:
return StringResult(lParam, GetDefaultFoldDisplayText());
case Message::ToggleFold:
FoldLine(LineFromUPtr(wParam), FoldAction::Toggle);
break;
case Message::FoldLine:
FoldLine(LineFromUPtr(wParam), static_cast<FoldAction>(lParam));
break;
case Message::FoldChildren:
FoldExpand(LineFromUPtr(wParam), static_cast<FoldAction>(lParam), pdoc->GetFoldLevel(wParam));
break;
case Message::FoldAll:
FoldAll(static_cast<FoldAction>(wParam));
break;
case Message::ExpandChildren:
FoldExpand(LineFromUPtr(wParam), FoldAction::Expand, static_cast<FoldLevel>(lParam));
break;
case Message::ContractedFoldNext:
return ContractedFoldNext(LineFromUPtr(wParam));
case Message::EnsureVisible:
EnsureLineVisible(LineFromUPtr(wParam), false);
break;
case Message::EnsureVisibleEnforcePolicy:
EnsureLineVisible(LineFromUPtr(wParam), true);
break;
case Message::ScrollRange:
ScrollRange(SelectionRange(PositionFromUPtr(wParam), lParam));
break;
case Message::SearchAnchor:
SearchAnchor();
break;
case Message::SearchNext:
case Message::SearchPrev:
return SearchText(iMessage, wParam, lParam);
case Message::SetXCaretPolicy:
caretPolicies.x = CaretPolicySlop(wParam, lParam);
break;
case Message::SetYCaretPolicy:
caretPolicies.y = CaretPolicySlop(wParam, lParam);
break;
case Message::SetVisiblePolicy:
visiblePolicy = VisiblePolicySlop(wParam, lParam);
break;
case Message::LinesOnScreen:
return LinesOnScreen();
case Message::GetSelEOLFilled:
return vs.selection.eolFilled;
case Message::SetSelEOLFilled:
vs.selection.eolFilled = wParam != 0;
InvalidateStyleRedraw();
break;
case Message::SetEOLSelectedWidth:
vs.selection.eolSelectedWidth = std::clamp(static_cast<int>(wParam), 0, 100);
InvalidateStyleRedraw();
break;
case Message::SetSelectionLayer:
if (vs.selection.layer != static_cast<Layer>(wParam)) {
vs.selection.layer = static_cast<Layer>(wParam);
UpdateBaseElements();
InvalidateStyleRedraw();
}
break;
case Message::GetSelectionLayer:
return static_cast<sptr_t>(vs.selection.layer);
case Message::SetCaretStyle:
if (static_cast<CaretStyle>(wParam) <= (CaretStyle::Block | CaretStyle::OverstrikeBlock | CaretStyle::Curses | CaretStyle::BlockAfter))
vs.caret.style = static_cast<CaretStyle>(wParam);
else
/* Default to the line caret */
vs.caret.style = CaretStyle::Line;
InvalidateStyleRedraw();
break;
case Message::GetCaretStyle:
return static_cast<sptr_t>(vs.caret.style);
case Message::SetCaretWidth:
// Windows accessibility allows 20 pixels caret width.
vs.caret.width = std::clamp(static_cast<int>(wParam), 0, 20);
InvalidateStyleRedraw();
break;
case Message::GetCaretWidth:
return vs.caret.width;
case Message::AssignCmdKey:
kmap.AssignCmdKey(static_cast<Keys>(LowShortFromWParam(wParam)),
static_cast<KeyMod>(HighShortFromWParam(wParam)), static_cast<Message>(lParam));
break;
case Message::ClearCmdKey:
kmap.AssignCmdKey(static_cast<Keys>(LowShortFromWParam(wParam)),
static_cast<KeyMod>(HighShortFromWParam(wParam)), Message::Null);
break;
case Message::ClearAllCmdKeys:
kmap.Clear();
break;
case Message::IndicSetStyle:
if (wParam <= IndicatorMax) {
vs.indicators[wParam].sacNormal.style = static_cast<IndicatorStyle>(lParam);
vs.indicators[wParam].sacHover.style = static_cast<IndicatorStyle>(lParam);
InvalidateStyleRedraw();
}
break;
case Message::IndicGetStyle:
return (wParam <= IndicatorMax) ? static_cast<sptr_t>(vs.indicators[wParam].sacNormal.style) : 0;
case Message::IndicSetFore:
if (wParam <= IndicatorMax) {
vs.indicators[wParam].sacNormal.fore = ColourRGBA::FromIpRGB(lParam);
vs.indicators[wParam].sacHover.fore = ColourRGBA::FromIpRGB(lParam);
InvalidateStyleRedraw();
}
break;
case Message::IndicGetFore:
return (wParam <= IndicatorMax) ? vs.indicators[wParam].sacNormal.fore.OpaqueRGB() : 0;
case Message::IndicSetHoverStyle:
if (wParam <= IndicatorMax) {
vs.indicators[wParam].sacHover.style = static_cast<IndicatorStyle>(lParam);
InvalidateStyleRedraw();
}
break;
case Message::IndicGetHoverStyle:
return (wParam <= IndicatorMax) ? static_cast<sptr_t>(vs.indicators[wParam].sacHover.style) : 0;
case Message::IndicSetHoverFore:
if (wParam <= IndicatorMax) {
vs.indicators[wParam].sacHover.fore = ColourRGBA::FromIpRGB(lParam);
InvalidateStyleRedraw();
}
break;
case Message::IndicGetHoverFore:
return (wParam <= IndicatorMax) ? vs.indicators[wParam].sacHover.fore.OpaqueRGB() : 0;
case Message::IndicSetFlags:
if (wParam <= IndicatorMax) {
vs.indicators[wParam].SetFlags(static_cast<IndicFlag>(lParam));
InvalidateStyleRedraw();
}
break;
case Message::IndicGetFlags:
return (wParam <= IndicatorMax) ? static_cast<sptr_t>(vs.indicators[wParam].Flags()) : 0;
case Message::IndicSetUnder:
if (wParam <= IndicatorMax) {
vs.indicators[wParam].under = lParam != 0;
InvalidateStyleRedraw();
}
break;
case Message::IndicGetUnder:
return (wParam <= IndicatorMax) ? vs.indicators[wParam].under : 0;
case Message::IndicSetAlpha:
if (wParam <= IndicatorMax && lParam >=0 && lParam <= 255) {
vs.indicators[wParam].fillAlpha = static_cast<int>(lParam);
InvalidateStyleRedraw();
}
break;
case Message::IndicGetAlpha:
return (wParam <= IndicatorMax) ? vs.indicators[wParam].fillAlpha : 0;
case Message::IndicSetOutlineAlpha:
if (wParam <= IndicatorMax && lParam >=0 && lParam <= 255) {
vs.indicators[wParam].outlineAlpha = static_cast<int>(lParam);
InvalidateStyleRedraw();
}
break;
case Message::IndicGetOutlineAlpha:
return (wParam <= IndicatorMax) ? vs.indicators[wParam].outlineAlpha : 0;
case Message::IndicSetStrokeWidth:
if (wParam <= IndicatorMax && lParam >= 0 && lParam <= 1000) {
vs.indicators[wParam].strokeWidth = lParam / 100.0f;
InvalidateStyleRedraw();
}
break;
case Message::IndicGetStrokeWidth:
if (wParam <= IndicatorMax) {
return std::lround(vs.indicators[wParam].strokeWidth * 100);
}
break;
case Message::SetIndicatorCurrent:
pdoc->DecorationSetCurrentIndicator(static_cast<int>(wParam));
break;
case Message::GetIndicatorCurrent:
return pdoc->decorations->GetCurrentIndicator();
case Message::SetIndicatorValue:
pdoc->decorations->SetCurrentValue(static_cast<int>(wParam));
break;
case Message::GetIndicatorValue:
return pdoc->decorations->GetCurrentValue();
case Message::IndicatorFillRange:
pdoc->DecorationFillRange(PositionFromUPtr(wParam),
pdoc->decorations->GetCurrentValue(), lParam);
break;
case Message::IndicatorClearRange:
pdoc->DecorationFillRange(PositionFromUPtr(wParam), 0, lParam);
break;
case Message::IndicatorAllOnFor:
return pdoc->decorations->AllOnFor(PositionFromUPtr(wParam));
case Message::IndicatorValueAt:
return pdoc->decorations->ValueAt(static_cast<int>(wParam), lParam);
case Message::IndicatorStart:
return pdoc->decorations->Start(static_cast<int>(wParam), lParam);
case Message::IndicatorEnd:
return pdoc->decorations->End(static_cast<int>(wParam), lParam);
case Message::LineCopy: {
const Sci::Line lineStart = pdoc->SciLineFromPosition(SelectionStart().Position());
const Sci::Line lineEnd = pdoc->SciLineFromPosition(SelectionEnd().Position());
CopyRangeToClipboard(pdoc->LineStart(lineStart), pdoc->LineStart(lineEnd + 1), wParam != 0);
}
break;
case Message::LineCut: {
const Sci::Line lineStart = pdoc->SciLineFromPosition(SelectionStart().Position());
const Sci::Line lineEnd = pdoc->SciLineFromPosition(SelectionEnd().Position());
const Sci::Position start = pdoc->LineStart(lineStart);
const Sci::Position end = pdoc->LineStart(lineEnd + 1);
SetSelection(start, end);
Cut(false, wParam != 0);
SetLastXChosen();
}
break;
case Message::LineDown:
case Message::LineDownExtend:
case Message::ParaDown:
case Message::ParaDownExtend:
case Message::LineUp:
case Message::LineUpExtend:
case Message::ParaUp:
case Message::ParaUpExtend:
case Message::CharLeft:
case Message::CharLeftExtend:
case Message::CharRight:
case Message::CharRightExtend:
case Message::WordLeft:
case Message::WordLeftExtend:
case Message::WordRight:
case Message::WordRightExtend:
case Message::WordLeftEnd:
case Message::WordLeftEndExtend:
case Message::WordRightEnd:
case Message::WordRightEndExtend:
case Message::Home:
case Message::HomeExtend:
case Message::LineEnd:
case Message::LineEndExtend:
case Message::HomeWrap:
case Message::HomeWrapExtend:
case Message::LineEndWrap:
case Message::LineEndWrapExtend:
case Message::DocumentStart:
case Message::DocumentStartExtend:
case Message::DocumentEnd:
case Message::DocumentEndExtend:
case Message::ScrollToStart:
case Message::ScrollToEnd:
case Message::StutteredPageUp:
case Message::StutteredPageUpExtend:
case Message::StutteredPageDown:
case Message::StutteredPageDownExtend:
case Message::PageUp:
case Message::PageUpExtend:
case Message::PageDown:
case Message::PageDownExtend:
case Message::EditToggleOvertype:
case Message::Cancel:
case Message::DeleteBack:
case Message::Tab:
case Message::BackTab:
case Message::NewLine:
case Message::FormFeed:
case Message::VCHome:
case Message::VCHomeExtend:
case Message::VCHomeWrap:
case Message::VCHomeWrapExtend:
case Message::VCHomeDisplay:
case Message::VCHomeDisplayExtend:
case Message::ZoomIn:
case Message::ZoomOut:
case Message::DelWordLeft:
case Message::DelWordRight:
case Message::DelWordRightEnd:
case Message::DelLineLeft:
case Message::DelLineRight:
case Message::LineDelete:
case Message::LineTranspose:
case Message::LineReverse:
case Message::LineDuplicate:
case Message::LowerCase:
case Message::UpperCase:
case Message::LineScrollDown:
case Message::LineScrollUp:
case Message::WordPartLeft:
case Message::WordPartLeftExtend:
case Message::WordPartRight:
case Message::WordPartRightExtend:
case Message::DeleteBackNotLine:
case Message::HomeDisplay:
case Message::HomeDisplayExtend:
case Message::LineEndDisplay:
case Message::LineEndDisplayExtend:
case Message::LineDownRectExtend:
case Message::LineUpRectExtend:
case Message::CharLeftRectExtend:
case Message::CharRightRectExtend:
case Message::HomeRectExtend:
case Message::VCHomeRectExtend:
case Message::LineEndRectExtend:
case Message::PageUpRectExtend:
case Message::PageDownRectExtend:
case Message::SelectionDuplicate:
return KeyCommand(iMessage);
case Message::BraceHighlight:
SetBraceHighlight(PositionFromUPtr(wParam), lParam, StyleBraceLight);
break;
case Message::BraceHighlightIndicator:
if (lParam >= 0 && lParam <= IndicatorMax) {
vs.braceHighlightIndicatorSet = wParam != 0;
vs.braceHighlightIndicator = static_cast<int>(lParam);
}
break;
case Message::BraceBadLight:
SetBraceHighlight(PositionFromUPtr(wParam), -1, StyleBraceBad);
break;
case Message::BraceBadLightIndicator:
if (lParam >= 0 && lParam <= IndicatorMax) {
vs.braceBadLightIndicatorSet = wParam != 0;
vs.braceBadLightIndicator = static_cast<int>(lParam);
}
break;
case Message::BraceMatch:
// wParam is position of char to find brace for,
// lParam is maximum amount of text to restyle to find it
return pdoc->BraceMatch(PositionFromUPtr(wParam), lParam, 0, false);
case Message::BraceMatchNext:
return pdoc->BraceMatch(PositionFromUPtr(wParam), 0, lParam, true);
case Message::GetViewEOL:
return vs.viewEOL;
case Message::SetViewEOL:
vs.viewEOL = wParam != 0;
InvalidateStyleRedraw();
break;
case Message::SetZoom: {
const int zoomLevel = std::clamp(static_cast<int>(wParam), MinZoomLevel, MaxZoomLevel);
if (zoomLevel != vs.zoomLevel) {
vs.zoomLevel = zoomLevel;
vs.fontsValid = false;
InvalidateStyleRedraw();
NotifyZoom();
}
break;
}
case Message::GetZoom:
return vs.zoomLevel;
case Message::GetEdgeColumn:
return vs.theEdge.column;
case Message::SetEdgeColumn:
vs.theEdge.column = static_cast<int>(wParam);
InvalidateStyleRedraw();
break;
case Message::GetEdgeMode:
return static_cast<sptr_t>(vs.edgeState);
case Message::SetEdgeMode:
vs.edgeState = static_cast<EdgeVisualStyle>(wParam);
InvalidateStyleRedraw();
break;
case Message::GetEdgeColour:
return vs.theEdge.colour.OpaqueRGB();
case Message::SetEdgeColour:
vs.theEdge.colour = ColourRGBA::FromIpRGB(SPtrFromUPtr(wParam));
InvalidateStyleRedraw();
break;
case Message::MultiEdgeAddLine:
vs.AddMultiEdge(static_cast<int>(wParam), ColourRGBA::FromIpRGB(lParam));
InvalidateStyleRedraw();
break;
case Message::MultiEdgeClearAll:
std::vector<EdgeProperties>().swap(vs.theMultiEdge); // Free vector and memory, C++03 compatible
InvalidateStyleRedraw();
break;
case Message::GetMultiEdgeColumn: {
const size_t which = wParam;
// size_t is unsigned so this also handles negative inputs.
if (which >= vs.theMultiEdge.size()) {
return -1;
}
return vs.theMultiEdge[which].column;
}
case Message::GetAccessibility:
return static_cast<sptr_t>(Accessibility::Disabled);
case Message::SetAccessibility:
// May be implemented by platform code.
break;
case Message::GetDocPointer:
return reinterpret_cast<sptr_t>(pdoc);
case Message::SetDocPointer:
CancelModes();
SetDocPointer(static_cast<Document *>(PtrFromSPtr(lParam)));
return 0;
case Message::CreateDocument: {
Document *doc = new Document(static_cast<DocumentOption>(lParam));
doc->AddRef();
doc->Allocate(PositionFromUPtr(wParam));
pcs = ContractionStateCreate(pdoc->IsLarge());
return reinterpret_cast<sptr_t>(doc);
}
case Message::AddRefDocument:
(static_cast<Document *>(PtrFromSPtr(lParam)))->AddRef();
break;
case Message::ReleaseDocument:
(static_cast<Document *>(PtrFromSPtr(lParam)))->Release();
break;
case Message::GetDocumentOptions:
return static_cast<sptr_t>(pdoc->Options());
case Message::CreateLoader: {
Document *doc = new Document(static_cast<DocumentOption>(lParam));
doc->AddRef();
doc->Allocate(PositionFromUPtr(wParam));
doc->SetUndoCollection(false);
pcs = ContractionStateCreate(pdoc->IsLarge());
return reinterpret_cast<sptr_t>(doc);
}
case Message::SetModEventMask:
modEventMask = static_cast<ModificationFlags>(wParam);
return 0;
case Message::GetModEventMask:
return static_cast<sptr_t>(modEventMask);
case Message::SetCommandEvents:
commandEvents = wParam != 0;
return 0;
case Message::GetCommandEvents:
return commandEvents;
case Message::ConvertEOLs:
pdoc->ConvertLineEnds(static_cast<EndOfLine>(wParam));
SetSelection(sel.MainCaret(), sel.MainAnchor()); // Ensure selection inside document
return 0;
case Message::SetLengthForEncode:
lengthForEncode = PositionFromUPtr(wParam);
return 0;
case Message::SelectionIsRectangle:
return sel.selType == Selection::SelTypes::rectangle ? 1 : 0;
case Message::SetSelectionMode: {
switch (static_cast<SelectionMode>(wParam)) {
case SelectionMode::Stream:
sel.SetMoveExtends(!sel.MoveExtends() || (sel.selType != Selection::SelTypes::stream));
sel.selType = Selection::SelTypes::stream;
break;
case SelectionMode::Rectangle:
sel.SetMoveExtends(!sel.MoveExtends() || (sel.selType != Selection::SelTypes::rectangle));
sel.selType = Selection::SelTypes::rectangle;
sel.Rectangular() = sel.RangeMain(); // adjust current selection
break;
case SelectionMode::Lines:
sel.SetMoveExtends(!sel.MoveExtends() || (sel.selType != Selection::SelTypes::lines));
sel.selType = Selection::SelTypes::lines;
SetSelection(sel.RangeMain().caret, sel.RangeMain().anchor); // adjust current selection
break;
case SelectionMode::Thin:
sel.SetMoveExtends(!sel.MoveExtends() || (sel.selType != Selection::SelTypes::thin));
sel.selType = Selection::SelTypes::thin;
break;
default:
sel.SetMoveExtends(!sel.MoveExtends() || (sel.selType != Selection::SelTypes::stream));
sel.selType = Selection::SelTypes::stream;
}
InvalidateWholeSelection();
break;
}
case Message::GetSelectionMode:
switch (sel.selType) {
case Selection::SelTypes::stream:
return static_cast<sptr_t>(SelectionMode::Stream);
case Selection::SelTypes::rectangle:
return static_cast<sptr_t>(SelectionMode::Rectangle);
case Selection::SelTypes::lines:
return static_cast<sptr_t>(SelectionMode::Lines);
case Selection::SelTypes::thin:
return static_cast<sptr_t>(SelectionMode::Thin);
default: // ?!
return static_cast<sptr_t>(SelectionMode::Stream);
}
case Message::GetMoveExtendsSelection:
return sel.MoveExtends();
case Message::GetLineSelStartPosition:
case Message::GetLineSelEndPosition: {
const SelectionSegment segmentLine(
SelectionPosition(pdoc->LineStart(LineFromUPtr(wParam))),
SelectionPosition(pdoc->LineEnd(LineFromUPtr(wParam))));
for (size_t r=0; r<sel.Count(); r++) {
const SelectionSegment portion = sel.Range(r).Intersect(segmentLine);
if (portion.start.IsValid()) {
return (iMessage == Message::GetLineSelStartPosition) ? portion.start.Position() : portion.end.Position();
}
}
return Sci::invalidPosition;
}
case Message::SetOvertype:
if (inOverstrike != (wParam != 0)) {
inOverstrike = wParam != 0;
ContainerNeedsUpdate(Update::Selection);
ShowCaretAtCurrentPosition();
SetIdle(true);
}
break;
case Message::GetOvertype:
return inOverstrike ? 1 : 0;
case Message::SetFocus:
SetFocusState(wParam != 0);
break;
case Message::GetFocus:
return hasFocus;
case Message::SetStatus:
errorStatus = static_cast<Status>(wParam);
break;
case Message::GetStatus:
return static_cast<sptr_t>(errorStatus);
case Message::SetMouseDownCaptures:
mouseDownCaptures = wParam != 0;
break;
case Message::GetMouseDownCaptures:
return mouseDownCaptures;
case Message::SetMouseWheelCaptures:
mouseWheelCaptures = wParam != 0;
break;
case Message::GetMouseWheelCaptures:
return mouseWheelCaptures;
case Message::SetCursor:
cursorMode = static_cast<CursorShape>(wParam);
DisplayCursor(Window::Cursor::text);
break;
case Message::GetCursor:
return static_cast<sptr_t>(cursorMode);
case Message::SetControlCharSymbol:
vs.controlCharSymbol = static_cast<int>(wParam);
InvalidateStyleRedraw();
break;
case Message::GetControlCharSymbol:
return vs.controlCharSymbol;
case Message::SetRepresentation:
reprs.SetRepresentation(ConstCharPtrFromUPtr(wParam), ConstCharPtrFromSPtr(lParam));
break;
case Message::GetRepresentation: {
const Representation *repr = reprs.RepresentationFromCharacter(
ConstCharPtrFromUPtr(wParam));
if (repr) {
return StringResult(lParam, repr->stringRep);
}
return 0;
}
case Message::ClearRepresentation:
reprs.ClearRepresentation(ConstCharPtrFromUPtr(wParam));
break;
case Message::ClearAllRepresentations:
SetRepresentations();
break;
case Message::SetRepresentationAppearance:
reprs.SetRepresentationAppearance(ConstCharPtrFromUPtr(wParam), static_cast<RepresentationAppearance>(lParam));
break;
case Message::GetRepresentationAppearance: {
const Representation *repr = reprs.RepresentationFromCharacter(ConstCharPtrFromUPtr(wParam));
if (repr) {
return static_cast<sptr_t>(repr->appearance);
}
return 0;
}
case Message::SetRepresentationColour:
reprs.SetRepresentationColour(ConstCharPtrFromUPtr(wParam), ColourRGBA(static_cast<unsigned int>(lParam)));
break;
case Message::GetRepresentationColour: {
const Representation *repr = reprs.RepresentationFromCharacter(ConstCharPtrFromUPtr(wParam));
if (repr) {
return repr->colour.AsInteger();
}
return 0;
}
case Message::StartRecord:
recordingMacro = true;
return 0;
case Message::StopRecord:
recordingMacro = false;
return 0;
case Message::MoveCaretInsideView:
MoveCaretInsideView();
break;
case Message::SetFoldMarginColour:
vs.foldmarginColour = OptionalColour(wParam, lParam);
InvalidateStyleRedraw();
break;
case Message::SetFoldMarginHiColour:
vs.foldmarginHighlightColour = OptionalColour(wParam, lParam);
InvalidateStyleRedraw();
break;
case Message::SetHotspotActiveUnderline:
vs.hotspotUnderline = wParam != 0;
InvalidateStyleRedraw();
break;
case Message::GetHotspotActiveUnderline:
return vs.hotspotUnderline ? 1 : 0;
case Message::SetHotspotSingleLine:
hotspotSingleLine = wParam != 0;
InvalidateStyleRedraw();
break;
case Message::GetHotspotSingleLine:
return hotspotSingleLine ? 1 : 0;
case Message::SetPasteConvertEndings:
convertPastes = wParam != 0;
break;
case Message::GetPasteConvertEndings:
return convertPastes ? 1 : 0;
case Message::GetCharacterPointer:
return reinterpret_cast<sptr_t>(pdoc->BufferPointer());
case Message::GetRangePointer:
return reinterpret_cast<sptr_t>(pdoc->RangePointer(PositionFromUPtr(wParam), lParam));
case Message::GetGapPosition:
return pdoc->GapPosition();
case Message::SetChangeHistory:
changeHistoryOption = static_cast<ChangeHistoryOption>(wParam);
pdoc->ChangeHistorySet(wParam & static_cast<int>(ChangeHistoryOption::Enabled));
break;
case Message::GetChangeHistory:
return static_cast<sptr_t>(changeHistoryOption);
case Message::SetExtraAscent:
vs.extraAscent = static_cast<int>(wParam);
InvalidateStyleRedraw();
break;
case Message::GetExtraAscent:
return vs.extraAscent;
case Message::SetExtraDescent:
vs.extraDescent = static_cast<int>(wParam);
InvalidateStyleRedraw();
break;
case Message::GetExtraDescent:
return vs.extraDescent;
case Message::MarginSetStyleOffset:
vs.marginStyleOffset = static_cast<int>(wParam);
InvalidateStyleRedraw();
break;
case Message::MarginGetStyleOffset:
return vs.marginStyleOffset;
case Message::SetMarginOptions:
marginOptions = static_cast<MarginOption>(wParam);
break;
case Message::GetMarginOptions:
return static_cast<sptr_t>(marginOptions);
case Message::MarginSetText:
pdoc->MarginSetText(LineFromUPtr(wParam), ConstCharPtrFromSPtr(lParam));
break;
case Message::MarginGetText: {
const StyledText st = pdoc->MarginStyledText(LineFromUPtr(wParam));
return BytesResult(lParam, reinterpret_cast<const unsigned char *>(st.text), st.length);
}
case Message::MarginSetStyle:
pdoc->MarginSetStyle(LineFromUPtr(wParam), static_cast<int>(lParam));
break;
case Message::MarginGetStyle: {
const StyledText st = pdoc->MarginStyledText(LineFromUPtr(wParam));
return st.style;
}
case Message::MarginSetStyles:
pdoc->MarginSetStyles(LineFromUPtr(wParam), ConstUCharPtrFromSPtr(lParam));
break;
case Message::MarginGetStyles: {
const StyledText st = pdoc->MarginStyledText(LineFromUPtr(wParam));
return BytesResult(lParam, st.styles, st.length);
}
case Message::MarginTextClearAll:
pdoc->MarginClearAll();
break;
case Message::AnnotationSetText:
pdoc->AnnotationSetText(LineFromUPtr(wParam), ConstCharPtrFromSPtr(lParam));
break;
case Message::AnnotationGetText: {
const StyledText st = pdoc->AnnotationStyledText(LineFromUPtr(wParam));
return BytesResult(lParam, reinterpret_cast<const unsigned char *>(st.text), st.length);
}
case Message::AnnotationGetStyle: {
const StyledText st = pdoc->AnnotationStyledText(LineFromUPtr(wParam));
return st.style;
}
case Message::AnnotationSetStyle:
pdoc->AnnotationSetStyle(LineFromUPtr(wParam), static_cast<int>(lParam));
break;
case Message::AnnotationSetStyles:
pdoc->AnnotationSetStyles(LineFromUPtr(wParam), ConstUCharPtrFromSPtr(lParam));
break;
case Message::AnnotationGetStyles: {
const StyledText st = pdoc->AnnotationStyledText(LineFromUPtr(wParam));
return BytesResult(lParam, st.styles, st.length);
}
case Message::AnnotationGetLines:
return pdoc->AnnotationLines(LineFromUPtr(wParam));
case Message::AnnotationClearAll:
pdoc->AnnotationClearAll();
break;
case Message::AnnotationSetVisible:
SetAnnotationVisible(static_cast<AnnotationVisible>(wParam));
break;
case Message::AnnotationGetVisible:
return static_cast<sptr_t>(vs.annotationVisible);
case Message::AnnotationSetStyleOffset:
vs.annotationStyleOffset = static_cast<int>(wParam);
InvalidateStyleRedraw();
break;
case Message::AnnotationGetStyleOffset:
return vs.annotationStyleOffset;
case Message::EOLAnnotationSetText:
pdoc->EOLAnnotationSetText(LineFromUPtr(wParam), ConstCharPtrFromSPtr(lParam));
break;
case Message::EOLAnnotationGetText: {
const StyledText st = pdoc->EOLAnnotationStyledText(LineFromUPtr(wParam));
return BytesResult(lParam, reinterpret_cast<const unsigned char *>(st.text), st.length);
}
case Message::EOLAnnotationGetStyle: {
const StyledText st = pdoc->EOLAnnotationStyledText(LineFromUPtr(wParam));
return st.style;
}
case Message::EOLAnnotationSetStyle:
pdoc->EOLAnnotationSetStyle(LineFromUPtr(wParam), static_cast<int>(lParam));
break;
case Message::EOLAnnotationClearAll:
pdoc->EOLAnnotationClearAll();
break;
case Message::EOLAnnotationSetVisible:
SetEOLAnnotationVisible(static_cast<EOLAnnotationVisible>(wParam));
break;
case Message::EOLAnnotationGetVisible:
return static_cast<sptr_t>(vs.eolAnnotationVisible);
case Message::EOLAnnotationSetStyleOffset:
vs.eolAnnotationStyleOffset = static_cast<int>(wParam);
InvalidateStyleRedraw();
break;
case Message::EOLAnnotationGetStyleOffset:
return vs.eolAnnotationStyleOffset;
case Message::ReleaseAllExtendedStyles:
vs.ReleaseAllExtendedStyles();
break;
case Message::AllocateExtendedStyles:
return vs.AllocateExtendedStyles(static_cast<int>(wParam));
case Message::SupportsFeature:
return SupportsFeature(static_cast<Supports>(wParam));
case Message::AddUndoAction:
pdoc->AddUndoAction(PositionFromUPtr(wParam), FlagSet(static_cast<UndoFlags>(lParam), UndoFlags::MayCoalesce));
break;
case Message::SetMouseSelectionRectangularSwitch:
mouseSelectionRectangularSwitch = wParam != 0;
break;
case Message::GetMouseSelectionRectangularSwitch:
return mouseSelectionRectangularSwitch;
case Message::SetMultipleSelection:
multipleSelection = wParam != 0;
InvalidateCaret();
break;
case Message::GetMultipleSelection:
return multipleSelection;
case Message::SetAdditionalSelectionTyping:
additionalSelectionTyping = wParam != 0;
InvalidateCaret();
break;
case Message::GetAdditionalSelectionTyping:
return additionalSelectionTyping;
case Message::SetMultiPaste:
multiPasteMode = static_cast<MultiPaste>(wParam);
break;
case Message::GetMultiPaste:
return static_cast<sptr_t>(multiPasteMode);
case Message::SetAdditionalCaretsBlink:
view.additionalCaretsBlink = wParam != 0;
InvalidateCaret();
break;
case Message::GetAdditionalCaretsBlink:
return view.additionalCaretsBlink;
case Message::SetAdditionalCaretsVisible:
view.additionalCaretsVisible = wParam != 0;
InvalidateCaret();
break;
case Message::GetAdditionalCaretsVisible:
return view.additionalCaretsVisible;
case Message::GetSelections:
return sel.Count();
case Message::GetSelectionEmpty:
return sel.Empty();
case Message::ClearSelections:
sel.Clear();
ContainerNeedsUpdate(Update::Selection);
Redraw();
break;
case Message::SetSelection:
sel.SetSelection(SelectionRange(PositionFromUPtr(wParam), lParam));
Redraw();
break;
case Message::AddSelection:
sel.AddSelection(SelectionRange(PositionFromUPtr(wParam), lParam));
ContainerNeedsUpdate(Update::Selection);
Redraw();
break;
case Message::DropSelectionN:
sel.DropSelection(PositionFromUPtr(wParam));
ContainerNeedsUpdate(Update::Selection);
Redraw();
break;
case Message::SetMainSelection:
sel.SetMain(PositionFromUPtr(wParam));
ContainerNeedsUpdate(Update::Selection);
Redraw();
break;
case Message::GetMainSelection:
return sel.Main();
case Message::SetSelectionNCaret:
case Message::SetSelectionNAnchor:
case Message::SetSelectionNCaretVirtualSpace:
case Message::SetSelectionNAnchorVirtualSpace:
case Message::SetSelectionNStart:
case Message::SetSelectionNEnd:
SetSelectionNMessage(iMessage, wParam, lParam);
break;
case Message::GetSelectionNCaret:
return sel.Range(wParam).caret.Position();
case Message::GetSelectionNAnchor:
return sel.Range(wParam).anchor.Position();
case Message::GetSelectionNCaretVirtualSpace:
return sel.Range(wParam).caret.VirtualSpace();
case Message::GetSelectionNAnchorVirtualSpace:
return sel.Range(wParam).anchor.VirtualSpace();
case Message::GetSelectionNStart:
return sel.Range(wParam).Start().Position();
case Message::GetSelectionNStartVirtualSpace:
return sel.Range(wParam).Start().VirtualSpace();
case Message::GetSelectionNEnd:
return sel.Range(wParam).End().Position();
case Message::GetSelectionNEndVirtualSpace:
return sel.Range(wParam).End().VirtualSpace();
case Message::SetRectangularSelectionCaret:
if (!sel.IsRectangular())
sel.Clear();
sel.selType = Selection::SelTypes::rectangle;
sel.Rectangular().caret.SetPosition(PositionFromUPtr(wParam));
SetRectangularRange();
Redraw();
break;
case Message::GetRectangularSelectionCaret:
return sel.Rectangular().caret.Position();
case Message::SetRectangularSelectionAnchor:
if (!sel.IsRectangular())
sel.Clear();
sel.selType = Selection::SelTypes::rectangle;
sel.Rectangular().anchor.SetPosition(PositionFromUPtr(wParam));
SetRectangularRange();
Redraw();
break;
case Message::GetRectangularSelectionAnchor:
return sel.Rectangular().anchor.Position();
case Message::SetRectangularSelectionCaretVirtualSpace:
if (!sel.IsRectangular())
sel.Clear();
sel.selType = Selection::SelTypes::rectangle;
sel.Rectangular().caret.SetVirtualSpace(PositionFromUPtr(wParam));
SetRectangularRange();
Redraw();
break;
case Message::GetRectangularSelectionCaretVirtualSpace:
return sel.Rectangular().caret.VirtualSpace();
case Message::SetRectangularSelectionAnchorVirtualSpace:
if (!sel.IsRectangular())
sel.Clear();
sel.selType = Selection::SelTypes::rectangle;
sel.Rectangular().anchor.SetVirtualSpace(PositionFromUPtr(wParam));
SetRectangularRange();
Redraw();
break;
case Message::GetRectangularSelectionAnchorVirtualSpace:
return sel.Rectangular().anchor.VirtualSpace();
case Message::SetVirtualSpaceOptions:
virtualSpaceOptions = static_cast<VirtualSpace>(wParam);
break;
case Message::GetVirtualSpaceOptions:
return static_cast<sptr_t>(virtualSpaceOptions);
case Message::RotateSelection:
sel.RotateMain();
InvalidateWholeSelection();
break;
case Message::SwapMainAnchorCaret:
InvalidateSelection(sel.RangeMain());
sel.RangeMain().Swap();
break;
case Message::MultipleSelectAddNext:
MultipleSelectAdd(AddNumber::one);
break;
case Message::MultipleSelectAddEach:
MultipleSelectAdd(AddNumber::each);
break;
case Message::ChangeLexerState:
pdoc->ChangeLexerState(PositionFromUPtr(wParam), lParam);
break;
case Message::SetIdentifier:
SetCtrlID(static_cast<int>(wParam));
break;
case Message::GetIdentifier:
return GetCtrlID();
case Message::SetTechnology:
// No action by default
break;
case Message::GetTechnology:
return static_cast<sptr_t>(technology);
case Message::SetAutoInsertMask:
autoInsertMask = static_cast<int>(wParam);
break;
case Message::CountCharacters:
return pdoc->CountCharacters(PositionFromUPtr(wParam), lParam);
case Message::CountCharactersAndColumns:
pdoc->CountCharactersAndColumns(lParam);
break;
case Message::CountCodeUnits:
return pdoc->CountUTF16(PositionFromUPtr(wParam), lParam);
default:
return DefWndProc(iMessage, wParam, lParam);
}
//Platform::DebugPrintf("end wnd proc\n");
return 0;
}
| [
"zufuliu@gmail.com"
] | zufuliu@gmail.com |
7302620ff93bb437cd4e59989e17f19973efee1f | aaea64c4bbe4ea5bfe289d622ad7376e930147cf | /Interface_functions.h | 182974af98129bbe6410f7274a174ad1ab43f247 | [] | no_license | meglenast/RotaGame | 0d1ffbfd666dda8ce13d1c83ebc58e5650859eed | d221a4661ee662e18135e06b275e6d8ab7a8b044 | refs/heads/master | 2022-06-01T02:47:21.305014 | 2020-04-25T18:31:29 | 2020-04-25T18:31:29 | 258,713,075 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 199 | h | #ifndef __INTERFACE_FUNCTIONS__HEADER__INCLUDED__
#define __INTERFACE_FUNCTIONS__HEADER__INCLUDED__
#include <iostream>
void clearConsole();
void pressAnyKeyToContinue();
void printTitel();
#endif | [
"meglena.stefanova98@gmail.com"
] | meglena.stefanova98@gmail.com |
610e3e1402fee3d0f749e5ec08eb22ec9178eb47 | 6f40de67648684c5f5112aeb550d7efb5bf8251b | /LightOJ/1109 - False Ordering.cpp | dc01de20828dbe23ae6716b076c0fff4b82df0bd | [] | no_license | Mohib04/Competitive-Programming | 91381fa5ba2ff2e9b6cf0aeee165f7cf31b43d0d | 529f7db770b801eff32f2f23b31a98b1b9f35e51 | refs/heads/master | 2021-10-21T07:53:03.645288 | 2019-03-03T14:53:47 | 2019-03-03T14:53:47 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 775 | cpp | #include <bits/stdc++.h>
#define pii pair<int,int>
#define MAX 2000100
using namespace std;
int divCount[1010];
int sorted[1010];
void sieveDiv() {
for(int i=1; i<=1000; i++) {
for(int j=i; j<=1000; j+=i) {
divCount[j]++;
// sorted[j].d++;
}
}
}
bool cmp (int a, int b) {
if(divCount[a] == divCount[b]) return a > b;
return divCount[a] < divCount[b];
}
int main()
{
sieveDiv();
for(int i=1; i<=1000; i++) sorted[i] = i;
sort(sorted+1, sorted+1+1000, cmp);
// for(int i=1; i<=10; i++) cout << sorted[i] << ' '; cout << endl;
int T,t;
scanf("%d", &T);
for(t=1; t<=T; t++) {
int n;
scanf("%d", &n);
printf("Case %d: %d\n", t, sorted[n]);
}
return 0;
}
| [
"shariarsajib@gmail.com"
] | shariarsajib@gmail.com |
815c7b031430460cee6411fd431f1703ccf8e7bb | c3a4658077c689710abf5ec846c8c59cbda16a51 | /test/TransposeTest.cc | cbb7a99ec1e881ea417e7674127eb2caae63d876 | [
"BSD-3-Clause"
] | permissive | jiecaoyu/FBGEMM | 6a85c5d2e9ee75e2f62bf428332c83e0366703b3 | 2c547924deafa1839483d31096de800078c35711 | refs/heads/main | 2023-03-16T23:29:36.266634 | 2022-06-03T21:05:49 | 2022-06-03T21:05:49 | 237,500,435 | 0 | 0 | NOASSERTION | 2021-11-15T23:46:24 | 2020-01-31T19:21:59 | null | UTF-8 | C++ | false | false | 2,758 | cc | /*
* Copyright (c) Meta Platforms, Inc. and affiliates.
* All rights reserved.
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree.
*/
#include <random>
#include <type_traits>
#include <vector>
#include <gtest/gtest.h>
#include "fbgemm/Utils.h"
using namespace std;
using namespace fbgemm;
template <typename T>
::testing::AssertionResult compare_tranpose_results(
vector<T> expected,
vector<T> acutal,
int m,
int n,
int ld_src,
int ld_dst) {
std::stringstream ss;
if (is_same<T, float>::value) {
ss << " float results ";
} else if (is_same<T, uint8_t>::value) {
ss << " i8 results ";
} else {
ss << " i16 results ";
}
ss << " mismatch at ";
bool match = true;
for (int i = 0; i < m; ++i) {
for (int j = 0; j < n; ++j) {
int exp = expected[i * ld_src + j];
int act = acutal[i + j * ld_dst];
if (exp != act) {
ss << "(" << i << ", " << j << "). ref " << exp << " actual " << act;
match = false;
}
}
}
if (match)
return ::testing::AssertionSuccess();
else
return ::testing::AssertionFailure() << "results differ: " << ss.str();
}
TEST(TransposeTest, TransposeTest) {
// Generate shapes to test
vector<tuple<int, int, int, int>> shapes;
uniform_int_distribution<int> dist(0, 32);
default_random_engine generator;
for (int i = 0; i < 1024; ++i) {
int m = dist(generator);
int n = dist(generator);
int ld_src = n + dist(generator);
int ld_dst = m + dist(generator);
shapes.push_back(make_tuple(m, n, ld_src, ld_dst));
}
for (const auto& shape : shapes) {
int m, n, ld_src, ld_dst;
tie(m, n, ld_src, ld_dst) = shape;
// float test
vector<float> a(m * ld_src);
vector<float> b(n * ld_dst);
generate(
a.begin(), a.end(), [&dist, &generator] { return dist(generator); });
transpose_simd(m, n, a.data(), ld_src, b.data(), ld_dst);
EXPECT_TRUE(compare_tranpose_results(a, b, m, n, ld_src, ld_dst));
// i8 test
vector<uint8_t> a_i8(m * ld_src);
vector<uint8_t> b_i8(n * ld_dst);
generate(a_i8.begin(), a_i8.end(), [&dist, &generator] {
return dist(generator);
});
transpose_simd(m, n, a_i8.data(), ld_src, b_i8.data(), ld_dst);
EXPECT_TRUE(compare_tranpose_results(a_i8, b_i8, m, n, ld_src, ld_dst));
// i16 test
vector<uint16_t> a_i16(m * ld_src);
vector<uint16_t> b_i16(n * ld_dst);
generate(a_i16.begin(), a_i16.end(), [&dist, &generator] {
return dist(generator);
});
transpose_simd(m, n, a_i16.data(), ld_src, b_i16.data(), ld_dst);
EXPECT_TRUE(compare_tranpose_results(a_i16, b_i16, m, n, ld_src, ld_dst));
}
}
| [
"facebook-github-bot@users.noreply.github.com"
] | facebook-github-bot@users.noreply.github.com |
82781df40cb0f93da186336955f652c54ad91280 | 233676e340835a58e8041bdc82c313e599af415c | /Schweizer-Messer/numpy_eigen/src/autogen_module/import_2_6_uchar.cpp | e9eff1a73ed348fdce3a0eb7d5e08340e2398af9 | [
"BSD-3-Clause"
] | permissive | ethz-asl/kalibr | 9213daa87ed191ce1e05fba9f7424204c2d9734c | 94bb8437a72a0d97a491097a7085bf3db4f93bba | refs/heads/master | 2023-08-29T17:04:47.774244 | 2023-08-14T02:08:46 | 2023-08-14T02:08:46 | 20,293,077 | 3,744 | 1,341 | NOASSERTION | 2023-09-10T02:18:47 | 2014-05-29T12:31:48 | C++ | UTF-8 | C++ | false | false | 270 | cpp | // This file automatically generated by create_export_module.py
#define NO_IMPORT_ARRAY
#include <NumpyEigenConverter.hpp>
#include <boost/cstdint.hpp>
void import_2_6_uchar()
{
NumpyEigenConverter<Eigen::Matrix< boost::uint8_t, 2, 6 > >::register_converter();
}
| [
"schneith@ethz.ch"
] | schneith@ethz.ch |
4116192bf85f0c36e44e703dc4ec3c3a380d378a | aa68ef1843b37b72e128695e6f7ed7e8d640341b | /inc/transforms.h | be8e60823eb122d9c7d71503ed5b10132c6651ea | [] | no_license | cparadis6191/ECE533-Image-Manip | 0799f2bda9d0d081c93c566798fa73aae2c24bf5 | a2b2cd683018a78512f37708d90426df7e7cdeaf | refs/heads/master | 2021-06-17T03:47:42.359615 | 2017-06-27T01:48:44 | 2017-06-27T02:00:41 | 31,731,350 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,675 | h | #pragma once
#include "image_io.h"
#include <array>
// Color mask flags
#define M_RED (1 << 0)
#define M_GREEN (1 << 1)
#define M_BLUE (1 << 2)
// Forward declaration
class image_io;
class locker {
public:
locker(image_io& image_src);
~locker();
private:
image_io& m_image;
};
// Choose a color to mask off
// gray = (0.299*r + 0.587*g + 0.114*b);
void color_mask(image_io& image_src, int mask);
// Invert color intensity
void invert(image_io& image_src);
// Apply a smoothing effect
// Utilizes a 3x3 neighborhood averaging algorithm
void smooth_mean(image_io& image_src);
// Utilizes a 3x3 neighborhood median algorithm
void smooth_median(image_io& image_src);
// Adjust constrast with histogram equalization algorithm
void hist_eq(image_io& image_src);
// Convert an image into a binary (black/white) image splitting at the threshold. All pixels equal to or greater than the threshold will be turned white, all pixels below will be black
void threshold(image_io& image_src, Uint32 threshold);
// Edge detection using the Sobel Gradient
void sobel_gradient(image_io& image_src);
// Edge detection using Laplacian Transformt
void laplacian(image_io& image_src);
// Degrade the image by n pixels
void erosion(image_io& image_src, int erode_n);
// Enlarge the iamge by n pixels
void dilation(image_io& image_src, int dilate_n);
// Compute the perimeter
int perimiter(image_io& image_src);
// Compute the area
int area(image_io& image_src);
// Compute the moment
// Returns a 4x4 matrix
std::array<std::array<double, 4>, 4> moment(image_io& image_src);
// Compute the centroid from the moment
// Returns an array of two (x, y)
std::array<double, 2> centroid(const std::array<std::array<double, 4>, 4>& M);
// Compute the central_moments
// Returns an array of the central moments
std::array<std::array<double, 4>, 4> central_moments(const std::array<std::array<double, 4>, 4>& M, const std::array<double, 2>& C);
// Calculate the 7 moment invariants
// u is a 4x4 matrix containing central moment values
std::array<double, 7> invariants(const std::array<std::array<double, 4>, 4>& u);
// Calculate the eigenvalues and eigenvectors of the covariance matrix
// Returns 2x3 matrix
std::array<std::array<double, 2>, 3> eigen(const std::array<std::array<double, 4>, 4>& M, const std::array<double, 2>& C);
// Convert an RGB pixel representation to a grayscale value
Uint8 RGB_to_gray(Uint32 RGB_pixel);
Uint8 RGB_to_red(Uint32 RGB_pixel);
Uint8 RGB_to_green(Uint32 RGB_pixel);
Uint8 RGB_to_blue(Uint32 RGB_pixel);
// Convert red/green/blue values back into RGB pixel representation
Uint32 pack_RGB(Uint8 red_value, Uint8 green_value, Uint8 blue_value);
| [
"cparadis6191@gmail.com"
] | cparadis6191@gmail.com |
562c3e8737aaf9fef1abe3f6886de53bcd5aad20 | 7d03253307865eebf9cb36333b5a3b7a56fcd68b | /DataQuality/GoodRunsLists/Root/TGoodRunsListsCint.cxx | e07a1bc65c64912b09024796432ed3f3aee2fe5a | [] | no_license | affablelochan/2013codev2 | 784419f471283c328b111a02f5b099ad9fa34ace | 6b1d3b4c50d1af6589e22df74031e0f26107fa4c | refs/heads/master | 2020-04-05T22:57:27.946264 | 2014-06-05T05:03:34 | 2014-06-05T05:03:34 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 515,988 | cxx | //
// File generated by /cvmfs/atlas.cern.ch/repo/sw/software/i686-slc5-gcc43-opt/17.2.4/sw/lcg/app/releases/ROOT/5.30.05/i686-slc5-gcc43-opt/root/bin/rootcint at Wed Jan 16 11:49:26 2013
// Do NOT change. Changes will be lost next time file is generated
//
#define R__DICTIONARY_FILENAME dOdOdIRootdITGoodRunsListsCint
#include "RConfig.h" //rootcint 4834
#if !defined(R__ACCESS_IN_SYMBOL)
//Break the privacy of classes -- Disabled for the moment
#define private public
#define protected public
#endif
// Since CINT ignores the std namespace, we need to do so in this file.
namespace std {} using namespace std;
#include "TGoodRunsListsCint.h"
#include "TCollectionProxyInfo.h"
#include "TClass.h"
#include "TBuffer.h"
#include "TMemberInspector.h"
#include "TError.h"
#ifndef G__ROOT
#define G__ROOT
#endif
#include "RtypesImp.h"
#include "TIsAProxy.h"
#include "TFileMergeInfo.h"
// START OF SHADOWS
namespace ROOT {
namespace Shadow {
#if !(defined(R__ACCESS_IN_SYMBOL) || defined(R__USE_SHADOW_CLASS))
typedef pair< int, ::Root::TGoodRun > pairlEintcORootcLcLTGoodRungR;
#else
class pairlEintcORootcLcLTGoodRungR {
public:
//friend XX;
int first; //
::Root::TGoodRun second; //
};
#endif
#if !(defined(R__ACCESS_IN_SYMBOL) || defined(R__USE_SHADOW_CLASS))
typedef pair< ::TString, ::TString > pairlETStringcOTStringgR;
#else
class pairlETStringcOTStringgR {
public:
//friend XX;
::TString first; //
::TString second; //
};
#endif
} // of namespace Shadow
} // of namespace ROOT
// END OF SHADOWS
namespace Root {
namespace ROOT {
inline ::ROOT::TGenericClassInfo *GenerateInitInstance();
static void Root_Dictionary();
// Function generating the singleton type initializer
inline ::ROOT::TGenericClassInfo *GenerateInitInstance()
{
static ::ROOT::TGenericClassInfo
instance("Root", 0 /*version*/, "./../GoodRunsLists/TGoodRunsListReader.h", 25,
::ROOT::DefineBehavior((void*)0,(void*)0),
&Root_Dictionary, 0);
return &instance;
}
// Insure that the inline function is _not_ optimized away by the compiler
::ROOT::TGenericClassInfo *(*_R__UNIQUE_(InitFunctionKeeper))() = &GenerateInitInstance;
// Static variable to force the class initialization
static ::ROOT::TGenericClassInfo *_R__UNIQUE_(Init) = GenerateInitInstance(); R__UseDummy(_R__UNIQUE_(Init));
// Dictionary for non-ClassDef classes
static void Root_Dictionary() {
GenerateInitInstance()->GetClass();
}
}
}
namespace ROOT {
void RootcLcLRegularFormula_ShowMembers(void *obj, TMemberInspector &R__insp);
static void *new_RootcLcLRegularFormula(void *p = 0);
static void *newArray_RootcLcLRegularFormula(Long_t size, void *p);
static void delete_RootcLcLRegularFormula(void *p);
static void deleteArray_RootcLcLRegularFormula(void *p);
static void destruct_RootcLcLRegularFormula(void *p);
// Function generating the singleton type initializer
static TGenericClassInfo *GenerateInitInstanceLocal(const ::Root::RegularFormula*)
{
::Root::RegularFormula *ptr = 0;
static ::TVirtualIsAProxy* isa_proxy = new ::TInstrumentedIsAProxy< ::Root::RegularFormula >(0);
static ::ROOT::TGenericClassInfo
instance("Root::RegularFormula", ::Root::RegularFormula::Class_Version(), "./../GoodRunsLists/RegularFormula.h", 18,
typeid(::Root::RegularFormula), DefineBehavior(ptr, ptr),
&::Root::RegularFormula::Dictionary, isa_proxy, 4,
sizeof(::Root::RegularFormula) );
instance.SetNew(&new_RootcLcLRegularFormula);
instance.SetNewArray(&newArray_RootcLcLRegularFormula);
instance.SetDelete(&delete_RootcLcLRegularFormula);
instance.SetDeleteArray(&deleteArray_RootcLcLRegularFormula);
instance.SetDestructor(&destruct_RootcLcLRegularFormula);
return &instance;
}
TGenericClassInfo *GenerateInitInstance(const ::Root::RegularFormula*)
{
return GenerateInitInstanceLocal((::Root::RegularFormula*)0);
}
// Static variable to force the class initialization
static ::ROOT::TGenericClassInfo *_R__UNIQUE_(Init) = GenerateInitInstanceLocal((const ::Root::RegularFormula*)0x0); R__UseDummy(_R__UNIQUE_(Init));
} // end of namespace ROOT
namespace ROOT {
void RootcLcLTLumiBlockRange_ShowMembers(void *obj, TMemberInspector &R__insp);
static void *new_RootcLcLTLumiBlockRange(void *p = 0);
static void *newArray_RootcLcLTLumiBlockRange(Long_t size, void *p);
static void delete_RootcLcLTLumiBlockRange(void *p);
static void deleteArray_RootcLcLTLumiBlockRange(void *p);
static void destruct_RootcLcLTLumiBlockRange(void *p);
// Function generating the singleton type initializer
static TGenericClassInfo *GenerateInitInstanceLocal(const ::Root::TLumiBlockRange*)
{
::Root::TLumiBlockRange *ptr = 0;
static ::TVirtualIsAProxy* isa_proxy = new ::TInstrumentedIsAProxy< ::Root::TLumiBlockRange >(0);
static ::ROOT::TGenericClassInfo
instance("Root::TLumiBlockRange", ::Root::TLumiBlockRange::Class_Version(), "../GoodRunsLists/TLumiBlockRange.h", 17,
typeid(::Root::TLumiBlockRange), DefineBehavior(ptr, ptr),
&::Root::TLumiBlockRange::Dictionary, isa_proxy, 4,
sizeof(::Root::TLumiBlockRange) );
instance.SetNew(&new_RootcLcLTLumiBlockRange);
instance.SetNewArray(&newArray_RootcLcLTLumiBlockRange);
instance.SetDelete(&delete_RootcLcLTLumiBlockRange);
instance.SetDeleteArray(&deleteArray_RootcLcLTLumiBlockRange);
instance.SetDestructor(&destruct_RootcLcLTLumiBlockRange);
return &instance;
}
TGenericClassInfo *GenerateInitInstance(const ::Root::TLumiBlockRange*)
{
return GenerateInitInstanceLocal((::Root::TLumiBlockRange*)0);
}
// Static variable to force the class initialization
static ::ROOT::TGenericClassInfo *_R__UNIQUE_(Init) = GenerateInitInstanceLocal((const ::Root::TLumiBlockRange*)0x0); R__UseDummy(_R__UNIQUE_(Init));
} // end of namespace ROOT
namespace ROOT {
void vectorlERootcLcLTLumiBlockRangecOallocatorlERootcLcLTLumiBlockRangegRsPgRcLcLiterator_ShowMembers(void *obj, TMemberInspector &R__insp);
static void vectorlERootcLcLTLumiBlockRangecOallocatorlERootcLcLTLumiBlockRangegRsPgRcLcLiterator_Dictionary();
static void *new_vectorlERootcLcLTLumiBlockRangecOallocatorlERootcLcLTLumiBlockRangegRsPgRcLcLiterator(void *p = 0);
static void *newArray_vectorlERootcLcLTLumiBlockRangecOallocatorlERootcLcLTLumiBlockRangegRsPgRcLcLiterator(Long_t size, void *p);
static void delete_vectorlERootcLcLTLumiBlockRangecOallocatorlERootcLcLTLumiBlockRangegRsPgRcLcLiterator(void *p);
static void deleteArray_vectorlERootcLcLTLumiBlockRangecOallocatorlERootcLcLTLumiBlockRangegRsPgRcLcLiterator(void *p);
static void destruct_vectorlERootcLcLTLumiBlockRangecOallocatorlERootcLcLTLumiBlockRangegRsPgRcLcLiterator(void *p);
// Function generating the singleton type initializer
static TGenericClassInfo *GenerateInitInstanceLocal(const ::vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >::iterator*)
{
::vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >::iterator *ptr = 0;
static ::TVirtualIsAProxy* isa_proxy = new ::TIsAProxy(typeid(::vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >::iterator),0);
static ::ROOT::TGenericClassInfo
instance("vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >::iterator", "/cvmfs/atlas.cern.ch/repo/sw/software/i686-slc5-gcc43-opt/17.2.4/sw/lcg/app/releases/ROOT/5.30.05/i686-slc5-gcc43-opt/root/cint/cint/lib/prec_stl/vector", 218,
typeid(::vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >::iterator), DefineBehavior(ptr, ptr),
0, &vectorlERootcLcLTLumiBlockRangecOallocatorlERootcLcLTLumiBlockRangegRsPgRcLcLiterator_Dictionary, isa_proxy, 0,
sizeof(::vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >::iterator) );
instance.SetNew(&new_vectorlERootcLcLTLumiBlockRangecOallocatorlERootcLcLTLumiBlockRangegRsPgRcLcLiterator);
instance.SetNewArray(&newArray_vectorlERootcLcLTLumiBlockRangecOallocatorlERootcLcLTLumiBlockRangegRsPgRcLcLiterator);
instance.SetDelete(&delete_vectorlERootcLcLTLumiBlockRangecOallocatorlERootcLcLTLumiBlockRangegRsPgRcLcLiterator);
instance.SetDeleteArray(&deleteArray_vectorlERootcLcLTLumiBlockRangecOallocatorlERootcLcLTLumiBlockRangegRsPgRcLcLiterator);
instance.SetDestructor(&destruct_vectorlERootcLcLTLumiBlockRangecOallocatorlERootcLcLTLumiBlockRangegRsPgRcLcLiterator);
return &instance;
}
TGenericClassInfo *GenerateInitInstance(const ::vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >::iterator*)
{
return GenerateInitInstanceLocal((::vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >::iterator*)0);
}
// Static variable to force the class initialization
static ::ROOT::TGenericClassInfo *_R__UNIQUE_(Init) = GenerateInitInstanceLocal((const ::vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >::iterator*)0x0); R__UseDummy(_R__UNIQUE_(Init));
// Dictionary for non-ClassDef classes
static void vectorlERootcLcLTLumiBlockRangecOallocatorlERootcLcLTLumiBlockRangegRsPgRcLcLiterator_Dictionary() {
::ROOT::GenerateInitInstanceLocal((const ::vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >::iterator*)0x0)->GetClass();
}
} // end of namespace ROOT
namespace ROOT {
void RootcLcLTGoodRun_ShowMembers(void *obj, TMemberInspector &R__insp);
static void *new_RootcLcLTGoodRun(void *p = 0);
static void *newArray_RootcLcLTGoodRun(Long_t size, void *p);
static void delete_RootcLcLTGoodRun(void *p);
static void deleteArray_RootcLcLTGoodRun(void *p);
static void destruct_RootcLcLTGoodRun(void *p);
// Function generating the singleton type initializer
static TGenericClassInfo *GenerateInitInstanceLocal(const ::Root::TGoodRun*)
{
::Root::TGoodRun *ptr = 0;
static ::TVirtualIsAProxy* isa_proxy = new ::TInstrumentedIsAProxy< ::Root::TGoodRun >(0);
static ::ROOT::TGenericClassInfo
instance("Root::TGoodRun", ::Root::TGoodRun::Class_Version(), "../GoodRunsLists/TGoodRun.h", 18,
typeid(::Root::TGoodRun), DefineBehavior(ptr, ptr),
&::Root::TGoodRun::Dictionary, isa_proxy, 4,
sizeof(::Root::TGoodRun) );
instance.SetNew(&new_RootcLcLTGoodRun);
instance.SetNewArray(&newArray_RootcLcLTGoodRun);
instance.SetDelete(&delete_RootcLcLTGoodRun);
instance.SetDeleteArray(&deleteArray_RootcLcLTGoodRun);
instance.SetDestructor(&destruct_RootcLcLTGoodRun);
return &instance;
}
TGenericClassInfo *GenerateInitInstance(const ::Root::TGoodRun*)
{
return GenerateInitInstanceLocal((::Root::TGoodRun*)0);
}
// Static variable to force the class initialization
static ::ROOT::TGenericClassInfo *_R__UNIQUE_(Init) = GenerateInitInstanceLocal((const ::Root::TGoodRun*)0x0); R__UseDummy(_R__UNIQUE_(Init));
} // end of namespace ROOT
namespace ROOT {
void RootcLcLTGoodRunsList_ShowMembers(void *obj, TMemberInspector &R__insp);
static void *new_RootcLcLTGoodRunsList(void *p = 0);
static void *newArray_RootcLcLTGoodRunsList(Long_t size, void *p);
static void delete_RootcLcLTGoodRunsList(void *p);
static void deleteArray_RootcLcLTGoodRunsList(void *p);
static void destruct_RootcLcLTGoodRunsList(void *p);
// Function generating the singleton type initializer
static TGenericClassInfo *GenerateInitInstanceLocal(const ::Root::TGoodRunsList*)
{
::Root::TGoodRunsList *ptr = 0;
static ::TVirtualIsAProxy* isa_proxy = new ::TInstrumentedIsAProxy< ::Root::TGoodRunsList >(0);
static ::ROOT::TGenericClassInfo
instance("Root::TGoodRunsList", ::Root::TGoodRunsList::Class_Version(), "../GoodRunsLists/TGoodRunsList.h", 21,
typeid(::Root::TGoodRunsList), DefineBehavior(ptr, ptr),
&::Root::TGoodRunsList::Dictionary, isa_proxy, 4,
sizeof(::Root::TGoodRunsList) );
instance.SetNew(&new_RootcLcLTGoodRunsList);
instance.SetNewArray(&newArray_RootcLcLTGoodRunsList);
instance.SetDelete(&delete_RootcLcLTGoodRunsList);
instance.SetDeleteArray(&deleteArray_RootcLcLTGoodRunsList);
instance.SetDestructor(&destruct_RootcLcLTGoodRunsList);
return &instance;
}
TGenericClassInfo *GenerateInitInstance(const ::Root::TGoodRunsList*)
{
return GenerateInitInstanceLocal((::Root::TGoodRunsList*)0);
}
// Static variable to force the class initialization
static ::ROOT::TGenericClassInfo *_R__UNIQUE_(Init) = GenerateInitInstanceLocal((const ::Root::TGoodRunsList*)0x0); R__UseDummy(_R__UNIQUE_(Init));
} // end of namespace ROOT
namespace ROOT {
void pairlEintcORootcLcLTGoodRungR_ShowMembers(void *obj, TMemberInspector &R__insp);
static void pairlEintcORootcLcLTGoodRungR_Dictionary();
static void *new_pairlEintcORootcLcLTGoodRungR(void *p = 0);
static void *newArray_pairlEintcORootcLcLTGoodRungR(Long_t size, void *p);
static void delete_pairlEintcORootcLcLTGoodRungR(void *p);
static void deleteArray_pairlEintcORootcLcLTGoodRungR(void *p);
static void destruct_pairlEintcORootcLcLTGoodRungR(void *p);
// Function generating the singleton type initializer
static TGenericClassInfo *GenerateInitInstanceLocal(const pair<int,Root::TGoodRun>*)
{
// Make sure the shadow class has the right sizeof
R__ASSERT(sizeof(pair<int,Root::TGoodRun>) == sizeof(::ROOT::Shadow::pairlEintcORootcLcLTGoodRungR));
pair<int,Root::TGoodRun> *ptr = 0;
static ::TVirtualIsAProxy* isa_proxy = new ::TIsAProxy(typeid(pair<int,Root::TGoodRun>),0);
static ::ROOT::TGenericClassInfo
instance("pair<int,Root::TGoodRun>", "/cvmfs/atlas.cern.ch/repo/sw/software/i686-slc5-gcc43-opt/17.2.4/sw/lcg/app/releases/ROOT/5.30.05/i686-slc5-gcc43-opt/root/cint/cint/lib/prec_stl/utility", 17,
typeid(pair<int,Root::TGoodRun>), DefineBehavior(ptr, ptr),
&pairlEintcORootcLcLTGoodRungR_ShowMembers, &pairlEintcORootcLcLTGoodRungR_Dictionary, isa_proxy, 4,
sizeof(pair<int,Root::TGoodRun>) );
instance.SetNew(&new_pairlEintcORootcLcLTGoodRungR);
instance.SetNewArray(&newArray_pairlEintcORootcLcLTGoodRungR);
instance.SetDelete(&delete_pairlEintcORootcLcLTGoodRungR);
instance.SetDeleteArray(&deleteArray_pairlEintcORootcLcLTGoodRungR);
instance.SetDestructor(&destruct_pairlEintcORootcLcLTGoodRungR);
return &instance;
}
TGenericClassInfo *GenerateInitInstance(const pair<int,Root::TGoodRun>*)
{
return GenerateInitInstanceLocal((pair<int,Root::TGoodRun>*)0);
}
// Static variable to force the class initialization
static ::ROOT::TGenericClassInfo *_R__UNIQUE_(Init) = GenerateInitInstanceLocal((const pair<int,Root::TGoodRun>*)0x0); R__UseDummy(_R__UNIQUE_(Init));
// Dictionary for non-ClassDef classes
static void pairlEintcORootcLcLTGoodRungR_Dictionary() {
::ROOT::GenerateInitInstanceLocal((const pair<int,Root::TGoodRun>*)0x0)->GetClass();
}
} // end of namespace ROOT
namespace ROOT {
void maplEintcORootcLcLTGoodRuncOlesslEintgRcOallocatorlEpairlEconstsPintcORootcLcLTGoodRungRsPgRsPgRcLcLiterator_ShowMembers(void *obj, TMemberInspector &R__insp);
static void maplEintcORootcLcLTGoodRuncOlesslEintgRcOallocatorlEpairlEconstsPintcORootcLcLTGoodRungRsPgRsPgRcLcLiterator_Dictionary();
static void *new_maplEintcORootcLcLTGoodRuncOlesslEintgRcOallocatorlEpairlEconstsPintcORootcLcLTGoodRungRsPgRsPgRcLcLiterator(void *p = 0);
static void *newArray_maplEintcORootcLcLTGoodRuncOlesslEintgRcOallocatorlEpairlEconstsPintcORootcLcLTGoodRungRsPgRsPgRcLcLiterator(Long_t size, void *p);
static void delete_maplEintcORootcLcLTGoodRuncOlesslEintgRcOallocatorlEpairlEconstsPintcORootcLcLTGoodRungRsPgRsPgRcLcLiterator(void *p);
static void deleteArray_maplEintcORootcLcLTGoodRuncOlesslEintgRcOallocatorlEpairlEconstsPintcORootcLcLTGoodRungRsPgRsPgRcLcLiterator(void *p);
static void destruct_maplEintcORootcLcLTGoodRuncOlesslEintgRcOallocatorlEpairlEconstsPintcORootcLcLTGoodRungRsPgRsPgRcLcLiterator(void *p);
// Function generating the singleton type initializer
static TGenericClassInfo *GenerateInitInstanceLocal(const ::map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > >::iterator*)
{
::map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > >::iterator *ptr = 0;
static ::TVirtualIsAProxy* isa_proxy = new ::TIsAProxy(typeid(::map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > >::iterator),0);
static ::ROOT::TGenericClassInfo
instance("map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > >::iterator", "/cvmfs/atlas.cern.ch/repo/sw/software/i686-slc5-gcc43-opt/17.2.4/sw/lcg/app/releases/ROOT/5.30.05/i686-slc5-gcc43-opt/root/cint/cint/lib/prec_stl/map", 103,
typeid(::map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > >::iterator), DefineBehavior(ptr, ptr),
0, &maplEintcORootcLcLTGoodRuncOlesslEintgRcOallocatorlEpairlEconstsPintcORootcLcLTGoodRungRsPgRsPgRcLcLiterator_Dictionary, isa_proxy, 0,
sizeof(::map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > >::iterator) );
instance.SetNew(&new_maplEintcORootcLcLTGoodRuncOlesslEintgRcOallocatorlEpairlEconstsPintcORootcLcLTGoodRungRsPgRsPgRcLcLiterator);
instance.SetNewArray(&newArray_maplEintcORootcLcLTGoodRuncOlesslEintgRcOallocatorlEpairlEconstsPintcORootcLcLTGoodRungRsPgRsPgRcLcLiterator);
instance.SetDelete(&delete_maplEintcORootcLcLTGoodRuncOlesslEintgRcOallocatorlEpairlEconstsPintcORootcLcLTGoodRungRsPgRsPgRcLcLiterator);
instance.SetDeleteArray(&deleteArray_maplEintcORootcLcLTGoodRuncOlesslEintgRcOallocatorlEpairlEconstsPintcORootcLcLTGoodRungRsPgRsPgRcLcLiterator);
instance.SetDestructor(&destruct_maplEintcORootcLcLTGoodRuncOlesslEintgRcOallocatorlEpairlEconstsPintcORootcLcLTGoodRungRsPgRsPgRcLcLiterator);
return &instance;
}
TGenericClassInfo *GenerateInitInstance(const ::map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > >::iterator*)
{
return GenerateInitInstanceLocal((::map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > >::iterator*)0);
}
// Static variable to force the class initialization
static ::ROOT::TGenericClassInfo *_R__UNIQUE_(Init) = GenerateInitInstanceLocal((const ::map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > >::iterator*)0x0); R__UseDummy(_R__UNIQUE_(Init));
// Dictionary for non-ClassDef classes
static void maplEintcORootcLcLTGoodRuncOlesslEintgRcOallocatorlEpairlEconstsPintcORootcLcLTGoodRungRsPgRsPgRcLcLiterator_Dictionary() {
::ROOT::GenerateInitInstanceLocal((const ::map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > >::iterator*)0x0)->GetClass();
}
} // end of namespace ROOT
namespace ROOT {
void pairlETStringcOTStringgR_ShowMembers(void *obj, TMemberInspector &R__insp);
static void pairlETStringcOTStringgR_Dictionary();
static void *new_pairlETStringcOTStringgR(void *p = 0);
static void *newArray_pairlETStringcOTStringgR(Long_t size, void *p);
static void delete_pairlETStringcOTStringgR(void *p);
static void deleteArray_pairlETStringcOTStringgR(void *p);
static void destruct_pairlETStringcOTStringgR(void *p);
// Function generating the singleton type initializer
static TGenericClassInfo *GenerateInitInstanceLocal(const pair<TString,TString>*)
{
// Make sure the shadow class has the right sizeof
R__ASSERT(sizeof(pair<TString,TString>) == sizeof(::ROOT::Shadow::pairlETStringcOTStringgR));
pair<TString,TString> *ptr = 0;
static ::TVirtualIsAProxy* isa_proxy = new ::TIsAProxy(typeid(pair<TString,TString>),0);
static ::ROOT::TGenericClassInfo
instance("pair<TString,TString>", "/cvmfs/atlas.cern.ch/repo/sw/software/i686-slc5-gcc43-opt/17.2.4/sw/lcg/app/releases/ROOT/5.30.05/i686-slc5-gcc43-opt/root/cint/cint/lib/prec_stl/utility", 17,
typeid(pair<TString,TString>), DefineBehavior(ptr, ptr),
&pairlETStringcOTStringgR_ShowMembers, &pairlETStringcOTStringgR_Dictionary, isa_proxy, 4,
sizeof(pair<TString,TString>) );
instance.SetNew(&new_pairlETStringcOTStringgR);
instance.SetNewArray(&newArray_pairlETStringcOTStringgR);
instance.SetDelete(&delete_pairlETStringcOTStringgR);
instance.SetDeleteArray(&deleteArray_pairlETStringcOTStringgR);
instance.SetDestructor(&destruct_pairlETStringcOTStringgR);
return &instance;
}
TGenericClassInfo *GenerateInitInstance(const pair<TString,TString>*)
{
return GenerateInitInstanceLocal((pair<TString,TString>*)0);
}
// Static variable to force the class initialization
static ::ROOT::TGenericClassInfo *_R__UNIQUE_(Init) = GenerateInitInstanceLocal((const pair<TString,TString>*)0x0); R__UseDummy(_R__UNIQUE_(Init));
// Dictionary for non-ClassDef classes
static void pairlETStringcOTStringgR_Dictionary() {
::ROOT::GenerateInitInstanceLocal((const pair<TString,TString>*)0x0)->GetClass();
}
} // end of namespace ROOT
namespace ROOT {
void vectorlERootcLcLTGoodRuncOallocatorlERootcLcLTGoodRungRsPgRcLcLiterator_ShowMembers(void *obj, TMemberInspector &R__insp);
static void vectorlERootcLcLTGoodRuncOallocatorlERootcLcLTGoodRungRsPgRcLcLiterator_Dictionary();
static void *new_vectorlERootcLcLTGoodRuncOallocatorlERootcLcLTGoodRungRsPgRcLcLiterator(void *p = 0);
static void *newArray_vectorlERootcLcLTGoodRuncOallocatorlERootcLcLTGoodRungRsPgRcLcLiterator(Long_t size, void *p);
static void delete_vectorlERootcLcLTGoodRuncOallocatorlERootcLcLTGoodRungRsPgRcLcLiterator(void *p);
static void deleteArray_vectorlERootcLcLTGoodRuncOallocatorlERootcLcLTGoodRungRsPgRcLcLiterator(void *p);
static void destruct_vectorlERootcLcLTGoodRuncOallocatorlERootcLcLTGoodRungRsPgRcLcLiterator(void *p);
// Function generating the singleton type initializer
static TGenericClassInfo *GenerateInitInstanceLocal(const ::vector<Root::TGoodRun,allocator<Root::TGoodRun> >::iterator*)
{
::vector<Root::TGoodRun,allocator<Root::TGoodRun> >::iterator *ptr = 0;
static ::TVirtualIsAProxy* isa_proxy = new ::TIsAProxy(typeid(::vector<Root::TGoodRun,allocator<Root::TGoodRun> >::iterator),0);
static ::ROOT::TGenericClassInfo
instance("vector<Root::TGoodRun,allocator<Root::TGoodRun> >::iterator", "/cvmfs/atlas.cern.ch/repo/sw/software/i686-slc5-gcc43-opt/17.2.4/sw/lcg/app/releases/ROOT/5.30.05/i686-slc5-gcc43-opt/root/cint/cint/lib/prec_stl/vector", 218,
typeid(::vector<Root::TGoodRun,allocator<Root::TGoodRun> >::iterator), DefineBehavior(ptr, ptr),
0, &vectorlERootcLcLTGoodRuncOallocatorlERootcLcLTGoodRungRsPgRcLcLiterator_Dictionary, isa_proxy, 0,
sizeof(::vector<Root::TGoodRun,allocator<Root::TGoodRun> >::iterator) );
instance.SetNew(&new_vectorlERootcLcLTGoodRuncOallocatorlERootcLcLTGoodRungRsPgRcLcLiterator);
instance.SetNewArray(&newArray_vectorlERootcLcLTGoodRuncOallocatorlERootcLcLTGoodRungRsPgRcLcLiterator);
instance.SetDelete(&delete_vectorlERootcLcLTGoodRuncOallocatorlERootcLcLTGoodRungRsPgRcLcLiterator);
instance.SetDeleteArray(&deleteArray_vectorlERootcLcLTGoodRuncOallocatorlERootcLcLTGoodRungRsPgRcLcLiterator);
instance.SetDestructor(&destruct_vectorlERootcLcLTGoodRuncOallocatorlERootcLcLTGoodRungRsPgRcLcLiterator);
return &instance;
}
TGenericClassInfo *GenerateInitInstance(const ::vector<Root::TGoodRun,allocator<Root::TGoodRun> >::iterator*)
{
return GenerateInitInstanceLocal((::vector<Root::TGoodRun,allocator<Root::TGoodRun> >::iterator*)0);
}
// Static variable to force the class initialization
static ::ROOT::TGenericClassInfo *_R__UNIQUE_(Init) = GenerateInitInstanceLocal((const ::vector<Root::TGoodRun,allocator<Root::TGoodRun> >::iterator*)0x0); R__UseDummy(_R__UNIQUE_(Init));
// Dictionary for non-ClassDef classes
static void vectorlERootcLcLTGoodRuncOallocatorlERootcLcLTGoodRungRsPgRcLcLiterator_Dictionary() {
::ROOT::GenerateInitInstanceLocal((const ::vector<Root::TGoodRun,allocator<Root::TGoodRun> >::iterator*)0x0)->GetClass();
}
} // end of namespace ROOT
namespace ROOT {
void RootcLcLTGRLCollection_ShowMembers(void *obj, TMemberInspector &R__insp);
static void *new_RootcLcLTGRLCollection(void *p = 0);
static void *newArray_RootcLcLTGRLCollection(Long_t size, void *p);
static void delete_RootcLcLTGRLCollection(void *p);
static void deleteArray_RootcLcLTGRLCollection(void *p);
static void destruct_RootcLcLTGRLCollection(void *p);
// Function generating the singleton type initializer
static TGenericClassInfo *GenerateInitInstanceLocal(const ::Root::TGRLCollection*)
{
::Root::TGRLCollection *ptr = 0;
static ::TVirtualIsAProxy* isa_proxy = new ::TInstrumentedIsAProxy< ::Root::TGRLCollection >(0);
static ::ROOT::TGenericClassInfo
instance("Root::TGRLCollection", ::Root::TGRLCollection::Class_Version(), "../GoodRunsLists/TGRLCollection.h", 20,
typeid(::Root::TGRLCollection), DefineBehavior(ptr, ptr),
&::Root::TGRLCollection::Dictionary, isa_proxy, 4,
sizeof(::Root::TGRLCollection) );
instance.SetNew(&new_RootcLcLTGRLCollection);
instance.SetNewArray(&newArray_RootcLcLTGRLCollection);
instance.SetDelete(&delete_RootcLcLTGRLCollection);
instance.SetDeleteArray(&deleteArray_RootcLcLTGRLCollection);
instance.SetDestructor(&destruct_RootcLcLTGRLCollection);
return &instance;
}
TGenericClassInfo *GenerateInitInstance(const ::Root::TGRLCollection*)
{
return GenerateInitInstanceLocal((::Root::TGRLCollection*)0);
}
// Static variable to force the class initialization
static ::ROOT::TGenericClassInfo *_R__UNIQUE_(Init) = GenerateInitInstanceLocal((const ::Root::TGRLCollection*)0x0); R__UseDummy(_R__UNIQUE_(Init));
} // end of namespace ROOT
namespace ROOT {
void vectorlERootcLcLTGoodRunsListcOallocatorlERootcLcLTGoodRunsListgRsPgRcLcLiterator_ShowMembers(void *obj, TMemberInspector &R__insp);
static void vectorlERootcLcLTGoodRunsListcOallocatorlERootcLcLTGoodRunsListgRsPgRcLcLiterator_Dictionary();
static void *new_vectorlERootcLcLTGoodRunsListcOallocatorlERootcLcLTGoodRunsListgRsPgRcLcLiterator(void *p = 0);
static void *newArray_vectorlERootcLcLTGoodRunsListcOallocatorlERootcLcLTGoodRunsListgRsPgRcLcLiterator(Long_t size, void *p);
static void delete_vectorlERootcLcLTGoodRunsListcOallocatorlERootcLcLTGoodRunsListgRsPgRcLcLiterator(void *p);
static void deleteArray_vectorlERootcLcLTGoodRunsListcOallocatorlERootcLcLTGoodRunsListgRsPgRcLcLiterator(void *p);
static void destruct_vectorlERootcLcLTGoodRunsListcOallocatorlERootcLcLTGoodRunsListgRsPgRcLcLiterator(void *p);
// Function generating the singleton type initializer
static TGenericClassInfo *GenerateInitInstanceLocal(const ::vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >::iterator*)
{
::vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >::iterator *ptr = 0;
static ::TVirtualIsAProxy* isa_proxy = new ::TIsAProxy(typeid(::vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >::iterator),0);
static ::ROOT::TGenericClassInfo
instance("vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >::iterator", "/cvmfs/atlas.cern.ch/repo/sw/software/i686-slc5-gcc43-opt/17.2.4/sw/lcg/app/releases/ROOT/5.30.05/i686-slc5-gcc43-opt/root/cint/cint/lib/prec_stl/vector", 218,
typeid(::vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >::iterator), DefineBehavior(ptr, ptr),
0, &vectorlERootcLcLTGoodRunsListcOallocatorlERootcLcLTGoodRunsListgRsPgRcLcLiterator_Dictionary, isa_proxy, 0,
sizeof(::vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >::iterator) );
instance.SetNew(&new_vectorlERootcLcLTGoodRunsListcOallocatorlERootcLcLTGoodRunsListgRsPgRcLcLiterator);
instance.SetNewArray(&newArray_vectorlERootcLcLTGoodRunsListcOallocatorlERootcLcLTGoodRunsListgRsPgRcLcLiterator);
instance.SetDelete(&delete_vectorlERootcLcLTGoodRunsListcOallocatorlERootcLcLTGoodRunsListgRsPgRcLcLiterator);
instance.SetDeleteArray(&deleteArray_vectorlERootcLcLTGoodRunsListcOallocatorlERootcLcLTGoodRunsListgRsPgRcLcLiterator);
instance.SetDestructor(&destruct_vectorlERootcLcLTGoodRunsListcOallocatorlERootcLcLTGoodRunsListgRsPgRcLcLiterator);
return &instance;
}
TGenericClassInfo *GenerateInitInstance(const ::vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >::iterator*)
{
return GenerateInitInstanceLocal((::vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >::iterator*)0);
}
// Static variable to force the class initialization
static ::ROOT::TGenericClassInfo *_R__UNIQUE_(Init) = GenerateInitInstanceLocal((const ::vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >::iterator*)0x0); R__UseDummy(_R__UNIQUE_(Init));
// Dictionary for non-ClassDef classes
static void vectorlERootcLcLTGoodRunsListcOallocatorlERootcLcLTGoodRunsListgRsPgRcLcLiterator_Dictionary() {
::ROOT::GenerateInitInstanceLocal((const ::vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >::iterator*)0x0)->GetClass();
}
} // end of namespace ROOT
namespace ROOT {
void RootcLcLTGoodRunsListWriter_ShowMembers(void *obj, TMemberInspector &R__insp);
static void *new_RootcLcLTGoodRunsListWriter(void *p = 0);
static void *newArray_RootcLcLTGoodRunsListWriter(Long_t size, void *p);
static void delete_RootcLcLTGoodRunsListWriter(void *p);
static void deleteArray_RootcLcLTGoodRunsListWriter(void *p);
static void destruct_RootcLcLTGoodRunsListWriter(void *p);
// Function generating the singleton type initializer
static TGenericClassInfo *GenerateInitInstanceLocal(const ::Root::TGoodRunsListWriter*)
{
::Root::TGoodRunsListWriter *ptr = 0;
static ::TVirtualIsAProxy* isa_proxy = new ::TInstrumentedIsAProxy< ::Root::TGoodRunsListWriter >(0);
static ::ROOT::TGenericClassInfo
instance("Root::TGoodRunsListWriter", ::Root::TGoodRunsListWriter::Class_Version(), "./../GoodRunsLists/TGoodRunsListWriter.h", 35,
typeid(::Root::TGoodRunsListWriter), DefineBehavior(ptr, ptr),
&::Root::TGoodRunsListWriter::Dictionary, isa_proxy, 4,
sizeof(::Root::TGoodRunsListWriter) );
instance.SetNew(&new_RootcLcLTGoodRunsListWriter);
instance.SetNewArray(&newArray_RootcLcLTGoodRunsListWriter);
instance.SetDelete(&delete_RootcLcLTGoodRunsListWriter);
instance.SetDeleteArray(&deleteArray_RootcLcLTGoodRunsListWriter);
instance.SetDestructor(&destruct_RootcLcLTGoodRunsListWriter);
return &instance;
}
TGenericClassInfo *GenerateInitInstance(const ::Root::TGoodRunsListWriter*)
{
return GenerateInitInstanceLocal((::Root::TGoodRunsListWriter*)0);
}
// Static variable to force the class initialization
static ::ROOT::TGenericClassInfo *_R__UNIQUE_(Init) = GenerateInitInstanceLocal((const ::Root::TGoodRunsListWriter*)0x0); R__UseDummy(_R__UNIQUE_(Init));
} // end of namespace ROOT
namespace ROOT {
void RootcLcLTGoodRunsListReader_ShowMembers(void *obj, TMemberInspector &R__insp);
static void *new_RootcLcLTGoodRunsListReader(void *p = 0);
static void *newArray_RootcLcLTGoodRunsListReader(Long_t size, void *p);
static void delete_RootcLcLTGoodRunsListReader(void *p);
static void deleteArray_RootcLcLTGoodRunsListReader(void *p);
static void destruct_RootcLcLTGoodRunsListReader(void *p);
// Function generating the singleton type initializer
static TGenericClassInfo *GenerateInitInstanceLocal(const ::Root::TGoodRunsListReader*)
{
::Root::TGoodRunsListReader *ptr = 0;
static ::TVirtualIsAProxy* isa_proxy = new ::TInstrumentedIsAProxy< ::Root::TGoodRunsListReader >(0);
static ::ROOT::TGenericClassInfo
instance("Root::TGoodRunsListReader", ::Root::TGoodRunsListReader::Class_Version(), "./../GoodRunsLists/TGoodRunsListReader.h", 32,
typeid(::Root::TGoodRunsListReader), DefineBehavior(ptr, ptr),
&::Root::TGoodRunsListReader::Dictionary, isa_proxy, 4,
sizeof(::Root::TGoodRunsListReader) );
instance.SetNew(&new_RootcLcLTGoodRunsListReader);
instance.SetNewArray(&newArray_RootcLcLTGoodRunsListReader);
instance.SetDelete(&delete_RootcLcLTGoodRunsListReader);
instance.SetDeleteArray(&deleteArray_RootcLcLTGoodRunsListReader);
instance.SetDestructor(&destruct_RootcLcLTGoodRunsListReader);
return &instance;
}
TGenericClassInfo *GenerateInitInstance(const ::Root::TGoodRunsListReader*)
{
return GenerateInitInstanceLocal((::Root::TGoodRunsListReader*)0);
}
// Static variable to force the class initialization
static ::ROOT::TGenericClassInfo *_R__UNIQUE_(Init) = GenerateInitInstanceLocal((const ::Root::TGoodRunsListReader*)0x0); R__UseDummy(_R__UNIQUE_(Init));
} // end of namespace ROOT
namespace DQ {
namespace ROOT {
inline ::ROOT::TGenericClassInfo *GenerateInitInstance();
static void DQ_Dictionary();
// Function generating the singleton type initializer
inline ::ROOT::TGenericClassInfo *GenerateInitInstance()
{
static ::ROOT::TGenericClassInfo
instance("DQ", 0 /*version*/, "./../GoodRunsLists/DQHelperFunctions.h", 5,
::ROOT::DefineBehavior((void*)0,(void*)0),
&DQ_Dictionary, 0);
return &instance;
}
// Insure that the inline function is _not_ optimized away by the compiler
::ROOT::TGenericClassInfo *(*_R__UNIQUE_(InitFunctionKeeper))() = &GenerateInitInstance;
// Static variable to force the class initialization
static ::ROOT::TGenericClassInfo *_R__UNIQUE_(Init) = GenerateInitInstance(); R__UseDummy(_R__UNIQUE_(Init));
// Dictionary for non-ClassDef classes
static void DQ_Dictionary() {
GenerateInitInstance()->GetClass();
}
}
}
namespace Root {
//______________________________________________________________________________
TClass *RegularFormula::fgIsA = 0; // static to hold class pointer
//______________________________________________________________________________
const char *RegularFormula::Class_Name()
{
return "Root::RegularFormula";
}
//______________________________________________________________________________
const char *RegularFormula::ImplFileName()
{
return ::ROOT::GenerateInitInstanceLocal((const ::Root::RegularFormula*)0x0)->GetImplFileName();
}
//______________________________________________________________________________
int RegularFormula::ImplFileLine()
{
return ::ROOT::GenerateInitInstanceLocal((const ::Root::RegularFormula*)0x0)->GetImplFileLine();
}
//______________________________________________________________________________
void RegularFormula::Dictionary()
{
fgIsA = ::ROOT::GenerateInitInstanceLocal((const ::Root::RegularFormula*)0x0)->GetClass();
}
//______________________________________________________________________________
TClass *RegularFormula::Class()
{
if (!fgIsA) fgIsA = ::ROOT::GenerateInitInstanceLocal((const ::Root::RegularFormula*)0x0)->GetClass();
return fgIsA;
}
} // namespace Root
namespace Root {
//______________________________________________________________________________
TClass *TLumiBlockRange::fgIsA = 0; // static to hold class pointer
//______________________________________________________________________________
const char *TLumiBlockRange::Class_Name()
{
return "Root::TLumiBlockRange";
}
//______________________________________________________________________________
const char *TLumiBlockRange::ImplFileName()
{
return ::ROOT::GenerateInitInstanceLocal((const ::Root::TLumiBlockRange*)0x0)->GetImplFileName();
}
//______________________________________________________________________________
int TLumiBlockRange::ImplFileLine()
{
return ::ROOT::GenerateInitInstanceLocal((const ::Root::TLumiBlockRange*)0x0)->GetImplFileLine();
}
//______________________________________________________________________________
void TLumiBlockRange::Dictionary()
{
fgIsA = ::ROOT::GenerateInitInstanceLocal((const ::Root::TLumiBlockRange*)0x0)->GetClass();
}
//______________________________________________________________________________
TClass *TLumiBlockRange::Class()
{
if (!fgIsA) fgIsA = ::ROOT::GenerateInitInstanceLocal((const ::Root::TLumiBlockRange*)0x0)->GetClass();
return fgIsA;
}
} // namespace Root
namespace Root {
//______________________________________________________________________________
TClass *TGoodRun::fgIsA = 0; // static to hold class pointer
//______________________________________________________________________________
const char *TGoodRun::Class_Name()
{
return "Root::TGoodRun";
}
//______________________________________________________________________________
const char *TGoodRun::ImplFileName()
{
return ::ROOT::GenerateInitInstanceLocal((const ::Root::TGoodRun*)0x0)->GetImplFileName();
}
//______________________________________________________________________________
int TGoodRun::ImplFileLine()
{
return ::ROOT::GenerateInitInstanceLocal((const ::Root::TGoodRun*)0x0)->GetImplFileLine();
}
//______________________________________________________________________________
void TGoodRun::Dictionary()
{
fgIsA = ::ROOT::GenerateInitInstanceLocal((const ::Root::TGoodRun*)0x0)->GetClass();
}
//______________________________________________________________________________
TClass *TGoodRun::Class()
{
if (!fgIsA) fgIsA = ::ROOT::GenerateInitInstanceLocal((const ::Root::TGoodRun*)0x0)->GetClass();
return fgIsA;
}
} // namespace Root
namespace Root {
//______________________________________________________________________________
TClass *TGoodRunsList::fgIsA = 0; // static to hold class pointer
//______________________________________________________________________________
const char *TGoodRunsList::Class_Name()
{
return "Root::TGoodRunsList";
}
//______________________________________________________________________________
const char *TGoodRunsList::ImplFileName()
{
return ::ROOT::GenerateInitInstanceLocal((const ::Root::TGoodRunsList*)0x0)->GetImplFileName();
}
//______________________________________________________________________________
int TGoodRunsList::ImplFileLine()
{
return ::ROOT::GenerateInitInstanceLocal((const ::Root::TGoodRunsList*)0x0)->GetImplFileLine();
}
//______________________________________________________________________________
void TGoodRunsList::Dictionary()
{
fgIsA = ::ROOT::GenerateInitInstanceLocal((const ::Root::TGoodRunsList*)0x0)->GetClass();
}
//______________________________________________________________________________
TClass *TGoodRunsList::Class()
{
if (!fgIsA) fgIsA = ::ROOT::GenerateInitInstanceLocal((const ::Root::TGoodRunsList*)0x0)->GetClass();
return fgIsA;
}
} // namespace Root
namespace Root {
//______________________________________________________________________________
TClass *TGRLCollection::fgIsA = 0; // static to hold class pointer
//______________________________________________________________________________
const char *TGRLCollection::Class_Name()
{
return "Root::TGRLCollection";
}
//______________________________________________________________________________
const char *TGRLCollection::ImplFileName()
{
return ::ROOT::GenerateInitInstanceLocal((const ::Root::TGRLCollection*)0x0)->GetImplFileName();
}
//______________________________________________________________________________
int TGRLCollection::ImplFileLine()
{
return ::ROOT::GenerateInitInstanceLocal((const ::Root::TGRLCollection*)0x0)->GetImplFileLine();
}
//______________________________________________________________________________
void TGRLCollection::Dictionary()
{
fgIsA = ::ROOT::GenerateInitInstanceLocal((const ::Root::TGRLCollection*)0x0)->GetClass();
}
//______________________________________________________________________________
TClass *TGRLCollection::Class()
{
if (!fgIsA) fgIsA = ::ROOT::GenerateInitInstanceLocal((const ::Root::TGRLCollection*)0x0)->GetClass();
return fgIsA;
}
} // namespace Root
namespace Root {
//______________________________________________________________________________
TClass *TGoodRunsListWriter::fgIsA = 0; // static to hold class pointer
//______________________________________________________________________________
const char *TGoodRunsListWriter::Class_Name()
{
return "Root::TGoodRunsListWriter";
}
//______________________________________________________________________________
const char *TGoodRunsListWriter::ImplFileName()
{
return ::ROOT::GenerateInitInstanceLocal((const ::Root::TGoodRunsListWriter*)0x0)->GetImplFileName();
}
//______________________________________________________________________________
int TGoodRunsListWriter::ImplFileLine()
{
return ::ROOT::GenerateInitInstanceLocal((const ::Root::TGoodRunsListWriter*)0x0)->GetImplFileLine();
}
//______________________________________________________________________________
void TGoodRunsListWriter::Dictionary()
{
fgIsA = ::ROOT::GenerateInitInstanceLocal((const ::Root::TGoodRunsListWriter*)0x0)->GetClass();
}
//______________________________________________________________________________
TClass *TGoodRunsListWriter::Class()
{
if (!fgIsA) fgIsA = ::ROOT::GenerateInitInstanceLocal((const ::Root::TGoodRunsListWriter*)0x0)->GetClass();
return fgIsA;
}
} // namespace Root
namespace Root {
//______________________________________________________________________________
TClass *TGoodRunsListReader::fgIsA = 0; // static to hold class pointer
//______________________________________________________________________________
const char *TGoodRunsListReader::Class_Name()
{
return "Root::TGoodRunsListReader";
}
//______________________________________________________________________________
const char *TGoodRunsListReader::ImplFileName()
{
return ::ROOT::GenerateInitInstanceLocal((const ::Root::TGoodRunsListReader*)0x0)->GetImplFileName();
}
//______________________________________________________________________________
int TGoodRunsListReader::ImplFileLine()
{
return ::ROOT::GenerateInitInstanceLocal((const ::Root::TGoodRunsListReader*)0x0)->GetImplFileLine();
}
//______________________________________________________________________________
void TGoodRunsListReader::Dictionary()
{
fgIsA = ::ROOT::GenerateInitInstanceLocal((const ::Root::TGoodRunsListReader*)0x0)->GetClass();
}
//______________________________________________________________________________
TClass *TGoodRunsListReader::Class()
{
if (!fgIsA) fgIsA = ::ROOT::GenerateInitInstanceLocal((const ::Root::TGoodRunsListReader*)0x0)->GetClass();
return fgIsA;
}
} // namespace Root
namespace Root {
//______________________________________________________________________________
void RegularFormula::Streamer(TBuffer &R__b)
{
// Stream an object of class Root::RegularFormula.
if (R__b.IsReading()) {
R__b.ReadClassBuffer(Root::RegularFormula::Class(),this);
} else {
R__b.WriteClassBuffer(Root::RegularFormula::Class(),this);
}
}
} // namespace Root
//______________________________________________________________________________
namespace Root {
void RegularFormula::ShowMembers(TMemberInspector &R__insp)
{
// Inspect the data members of an object of class Root::RegularFormula.
TClass *R__cl = ::Root::RegularFormula::IsA();
if (R__cl || R__insp.IsA()) { }
R__insp.Inspect(R__cl, R__insp.GetParent(), "m_expr", &m_expr);
R__insp.InspectMember(m_expr, "m_expr.");
R__insp.Inspect(R__cl, R__insp.GetParent(), "m_par", (void*)&m_par);
R__insp.InspectMember("list<TString>", (void*)&m_par, "m_par.", false);
TFormula::ShowMembers(R__insp);
}
} // namespace Root
namespace ROOT {
// Wrappers around operator new
static void *new_RootcLcLRegularFormula(void *p) {
return p ? new(p) ::Root::RegularFormula : new ::Root::RegularFormula;
}
static void *newArray_RootcLcLRegularFormula(Long_t nElements, void *p) {
return p ? new(p) ::Root::RegularFormula[nElements] : new ::Root::RegularFormula[nElements];
}
// Wrapper around operator delete
static void delete_RootcLcLRegularFormula(void *p) {
delete ((::Root::RegularFormula*)p);
}
static void deleteArray_RootcLcLRegularFormula(void *p) {
delete [] ((::Root::RegularFormula*)p);
}
static void destruct_RootcLcLRegularFormula(void *p) {
typedef ::Root::RegularFormula current_t;
((current_t*)p)->~current_t();
}
} // end of namespace ROOT for class ::Root::RegularFormula
namespace Root {
//______________________________________________________________________________
void TGoodRunsListReader::Streamer(TBuffer &R__b)
{
// Stream an object of class Root::TGoodRunsListReader.
if (R__b.IsReading()) {
R__b.ReadClassBuffer(Root::TGoodRunsListReader::Class(),this);
} else {
R__b.WriteClassBuffer(Root::TGoodRunsListReader::Class(),this);
}
}
} // namespace Root
//______________________________________________________________________________
namespace Root {
void TGoodRunsListReader::ShowMembers(TMemberInspector &R__insp)
{
// Inspect the data members of an object of class Root::TGoodRunsListReader.
TClass *R__cl = ::Root::TGoodRunsListReader::IsA();
if (R__cl || R__insp.IsA()) { }
R__insp.Inspect(R__cl, R__insp.GetParent(), "m_xmlstring", &m_xmlstring);
R__insp.InspectMember(m_xmlstring, "m_xmlstring.");
R__insp.Inspect(R__cl, R__insp.GetParent(), "m_dataCardName", &m_dataCardName);
R__insp.InspectMember(m_dataCardName, "m_dataCardName.");
R__insp.Inspect(R__cl, R__insp.GetParent(), "m_dataCardList", (void*)&m_dataCardList);
R__insp.InspectMember("vector<TString>", (void*)&m_dataCardList, "m_dataCardList.", false);
R__insp.Inspect(R__cl, R__insp.GetParent(), "m_xmlstringList", (void*)&m_xmlstringList);
R__insp.InspectMember("vector<TString>", (void*)&m_xmlstringList, "m_xmlstringList.", false);
R__insp.Inspect(R__cl, R__insp.GetParent(), "m_logger", (void*)&m_logger);
R__insp.InspectMember("Root::TMsgLogger", (void*)&m_logger, "m_logger.", false);
R__insp.Inspect(R__cl, R__insp.GetParent(), "m_grlvec", &m_grlvec);
R__insp.InspectMember(m_grlvec, "m_grlvec.");
TObject::ShowMembers(R__insp);
}
} // namespace Root
namespace ROOT {
// Wrappers around operator new
static void *new_RootcLcLTGoodRunsListReader(void *p) {
return p ? new(p) ::Root::TGoodRunsListReader : new ::Root::TGoodRunsListReader;
}
static void *newArray_RootcLcLTGoodRunsListReader(Long_t nElements, void *p) {
return p ? new(p) ::Root::TGoodRunsListReader[nElements] : new ::Root::TGoodRunsListReader[nElements];
}
// Wrapper around operator delete
static void delete_RootcLcLTGoodRunsListReader(void *p) {
delete ((::Root::TGoodRunsListReader*)p);
}
static void deleteArray_RootcLcLTGoodRunsListReader(void *p) {
delete [] ((::Root::TGoodRunsListReader*)p);
}
static void destruct_RootcLcLTGoodRunsListReader(void *p) {
typedef ::Root::TGoodRunsListReader current_t;
((current_t*)p)->~current_t();
}
} // end of namespace ROOT for class ::Root::TGoodRunsListReader
namespace Root {
//______________________________________________________________________________
void TGoodRunsListWriter::Streamer(TBuffer &R__b)
{
// Stream an object of class Root::TGoodRunsListWriter.
if (R__b.IsReading()) {
R__b.ReadClassBuffer(Root::TGoodRunsListWriter::Class(),this);
} else {
R__b.WriteClassBuffer(Root::TGoodRunsListWriter::Class(),this);
}
}
} // namespace Root
//______________________________________________________________________________
namespace Root {
void TGoodRunsListWriter::ShowMembers(TMemberInspector &R__insp)
{
// Inspect the data members of an object of class Root::TGoodRunsListWriter.
TClass *R__cl = ::Root::TGoodRunsListWriter::IsA();
if (R__cl || R__insp.IsA()) { }
R__insp.Inspect(R__cl, R__insp.GetParent(), "m_grlvec", &m_grlvec);
R__insp.InspectMember(m_grlvec, "m_grlvec.");
R__insp.Inspect(R__cl, R__insp.GetParent(), "m_grl", &m_grl);
R__insp.InspectMember(m_grl, "m_grl.");
R__insp.Inspect(R__cl, R__insp.GetParent(), "m_xmlstringVec", (void*)&m_xmlstringVec);
R__insp.InspectMember("vector<TString>", (void*)&m_xmlstringVec, "m_xmlstringVec.", false);
R__insp.Inspect(R__cl, R__insp.GetParent(), "m_xmlstring", &m_xmlstring);
R__insp.InspectMember(m_xmlstring, "m_xmlstring.");
R__insp.Inspect(R__cl, R__insp.GetParent(), "m_dataCardName", &m_dataCardName);
R__insp.InspectMember(m_dataCardName, "m_dataCardName.");
R__insp.Inspect(R__cl, R__insp.GetParent(), "m_prefix", &m_prefix);
R__insp.InspectMember(m_prefix, "m_prefix.");
R__insp.Inspect(R__cl, R__insp.GetParent(), "m_logger", (void*)&m_logger);
R__insp.InspectMember("Root::TMsgLogger", (void*)&m_logger, "m_logger.", false);
R__insp.Inspect(R__cl, R__insp.GetParent(), "m_mergegrls", &m_mergegrls);
R__insp.Inspect(R__cl, R__insp.GetParent(), "m_individuals", &m_individuals);
TObject::ShowMembers(R__insp);
}
} // namespace Root
namespace ROOT {
// Wrappers around operator new
static void *new_RootcLcLTGoodRunsListWriter(void *p) {
return p ? new(p) ::Root::TGoodRunsListWriter : new ::Root::TGoodRunsListWriter;
}
static void *newArray_RootcLcLTGoodRunsListWriter(Long_t nElements, void *p) {
return p ? new(p) ::Root::TGoodRunsListWriter[nElements] : new ::Root::TGoodRunsListWriter[nElements];
}
// Wrapper around operator delete
static void delete_RootcLcLTGoodRunsListWriter(void *p) {
delete ((::Root::TGoodRunsListWriter*)p);
}
static void deleteArray_RootcLcLTGoodRunsListWriter(void *p) {
delete [] ((::Root::TGoodRunsListWriter*)p);
}
static void destruct_RootcLcLTGoodRunsListWriter(void *p) {
typedef ::Root::TGoodRunsListWriter current_t;
((current_t*)p)->~current_t();
}
} // end of namespace ROOT for class ::Root::TGoodRunsListWriter
namespace Root {
//______________________________________________________________________________
void TLumiBlockRange::Streamer(TBuffer &R__b)
{
// Stream an object of class Root::TLumiBlockRange.
if (R__b.IsReading()) {
R__b.ReadClassBuffer(Root::TLumiBlockRange::Class(),this);
} else {
R__b.WriteClassBuffer(Root::TLumiBlockRange::Class(),this);
}
}
} // namespace Root
//______________________________________________________________________________
namespace Root {
void TLumiBlockRange::ShowMembers(TMemberInspector &R__insp)
{
// Inspect the data members of an object of class Root::TLumiBlockRange.
TClass *R__cl = ::Root::TLumiBlockRange::IsA();
if (R__cl || R__insp.IsA()) { }
R__insp.Inspect(R__cl, R__insp.GetParent(), "m_begin", &m_begin);
R__insp.Inspect(R__cl, R__insp.GetParent(), "m_end", &m_end);
TObject::ShowMembers(R__insp);
}
} // namespace Root
namespace ROOT {
// Wrappers around operator new
static void *new_RootcLcLTLumiBlockRange(void *p) {
return p ? new(p) ::Root::TLumiBlockRange : new ::Root::TLumiBlockRange;
}
static void *newArray_RootcLcLTLumiBlockRange(Long_t nElements, void *p) {
return p ? new(p) ::Root::TLumiBlockRange[nElements] : new ::Root::TLumiBlockRange[nElements];
}
// Wrapper around operator delete
static void delete_RootcLcLTLumiBlockRange(void *p) {
delete ((::Root::TLumiBlockRange*)p);
}
static void deleteArray_RootcLcLTLumiBlockRange(void *p) {
delete [] ((::Root::TLumiBlockRange*)p);
}
static void destruct_RootcLcLTLumiBlockRange(void *p) {
typedef ::Root::TLumiBlockRange current_t;
((current_t*)p)->~current_t();
}
} // end of namespace ROOT for class ::Root::TLumiBlockRange
namespace ROOT {
// Wrappers around operator new
static void *new_vectorlERootcLcLTLumiBlockRangecOallocatorlERootcLcLTLumiBlockRangegRsPgRcLcLiterator(void *p) {
return p ? ::new((::ROOT::TOperatorNewHelper*)p) ::vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >::iterator : new ::vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >::iterator;
}
static void *newArray_vectorlERootcLcLTLumiBlockRangecOallocatorlERootcLcLTLumiBlockRangegRsPgRcLcLiterator(Long_t nElements, void *p) {
return p ? ::new((::ROOT::TOperatorNewHelper*)p) ::vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >::iterator[nElements] : new ::vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >::iterator[nElements];
}
// Wrapper around operator delete
static void delete_vectorlERootcLcLTLumiBlockRangecOallocatorlERootcLcLTLumiBlockRangegRsPgRcLcLiterator(void *p) {
delete ((::vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >::iterator*)p);
}
static void deleteArray_vectorlERootcLcLTLumiBlockRangecOallocatorlERootcLcLTLumiBlockRangegRsPgRcLcLiterator(void *p) {
delete [] ((::vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >::iterator*)p);
}
static void destruct_vectorlERootcLcLTLumiBlockRangecOallocatorlERootcLcLTLumiBlockRangegRsPgRcLcLiterator(void *p) {
typedef ::vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >::iterator current_t;
((current_t*)p)->~current_t();
}
} // end of namespace ROOT for class ::vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >::iterator
namespace Root {
//______________________________________________________________________________
void TGoodRun::Streamer(TBuffer &R__b)
{
// Stream an object of class Root::TGoodRun.
if (R__b.IsReading()) {
R__b.ReadClassBuffer(Root::TGoodRun::Class(),this);
} else {
R__b.WriteClassBuffer(Root::TGoodRun::Class(),this);
}
}
} // namespace Root
//______________________________________________________________________________
namespace Root {
void TGoodRun::ShowMembers(TMemberInspector &R__insp)
{
// Inspect the data members of an object of class Root::TGoodRun.
TClass *R__cl = ::Root::TGoodRun::IsA();
if (R__cl || R__insp.IsA()) { }
R__insp.Inspect(R__cl, R__insp.GetParent(), "m_runnr", &m_runnr);
R__insp.GenericShowMembers("vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >", ( ::vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> > *) (this ), false);
TObject::ShowMembers(R__insp);
}
} // namespace Root
namespace ROOT {
// Wrappers around operator new
static void *new_RootcLcLTGoodRun(void *p) {
return p ? new(p) ::Root::TGoodRun : new ::Root::TGoodRun;
}
static void *newArray_RootcLcLTGoodRun(Long_t nElements, void *p) {
return p ? new(p) ::Root::TGoodRun[nElements] : new ::Root::TGoodRun[nElements];
}
// Wrapper around operator delete
static void delete_RootcLcLTGoodRun(void *p) {
delete ((::Root::TGoodRun*)p);
}
static void deleteArray_RootcLcLTGoodRun(void *p) {
delete [] ((::Root::TGoodRun*)p);
}
static void destruct_RootcLcLTGoodRun(void *p) {
typedef ::Root::TGoodRun current_t;
((current_t*)p)->~current_t();
}
} // end of namespace ROOT for class ::Root::TGoodRun
namespace ROOT {
// Wrappers around operator new
static void *new_vectorlERootcLcLTGoodRuncOallocatorlERootcLcLTGoodRungRsPgRcLcLiterator(void *p) {
return p ? ::new((::ROOT::TOperatorNewHelper*)p) ::vector<Root::TGoodRun,allocator<Root::TGoodRun> >::iterator : new ::vector<Root::TGoodRun,allocator<Root::TGoodRun> >::iterator;
}
static void *newArray_vectorlERootcLcLTGoodRuncOallocatorlERootcLcLTGoodRungRsPgRcLcLiterator(Long_t nElements, void *p) {
return p ? ::new((::ROOT::TOperatorNewHelper*)p) ::vector<Root::TGoodRun,allocator<Root::TGoodRun> >::iterator[nElements] : new ::vector<Root::TGoodRun,allocator<Root::TGoodRun> >::iterator[nElements];
}
// Wrapper around operator delete
static void delete_vectorlERootcLcLTGoodRuncOallocatorlERootcLcLTGoodRungRsPgRcLcLiterator(void *p) {
delete ((::vector<Root::TGoodRun,allocator<Root::TGoodRun> >::iterator*)p);
}
static void deleteArray_vectorlERootcLcLTGoodRuncOallocatorlERootcLcLTGoodRungRsPgRcLcLiterator(void *p) {
delete [] ((::vector<Root::TGoodRun,allocator<Root::TGoodRun> >::iterator*)p);
}
static void destruct_vectorlERootcLcLTGoodRuncOallocatorlERootcLcLTGoodRungRsPgRcLcLiterator(void *p) {
typedef ::vector<Root::TGoodRun,allocator<Root::TGoodRun> >::iterator current_t;
((current_t*)p)->~current_t();
}
} // end of namespace ROOT for class ::vector<Root::TGoodRun,allocator<Root::TGoodRun> >::iterator
//______________________________________________________________________________
namespace ROOT {
void pairlEintcORootcLcLTGoodRungR_ShowMembers(void *obj, TMemberInspector &R__insp)
{
// Inspect the data members of an object of class pair<int,Root::TGoodRun>.
typedef ::ROOT::Shadow::pairlEintcORootcLcLTGoodRungR ShadowClass;
ShadowClass *sobj = (ShadowClass*)obj;
if (sobj) { } // Dummy usage just in case there is no datamember.
TClass *R__cl = ::ROOT::GenerateInitInstanceLocal((const pair<int,Root::TGoodRun>*)0x0)->GetClass();
if (R__cl || R__insp.IsA()) { }
R__insp.Inspect(R__cl, R__insp.GetParent(), "first", &sobj->first);
R__insp.Inspect(R__cl, R__insp.GetParent(), "second", &sobj->second);
R__insp.InspectMember(sobj->second, "second.");
}
}
namespace ROOT {
// Wrappers around operator new
static void *new_pairlEintcORootcLcLTGoodRungR(void *p) {
return p ? ::new((::ROOT::TOperatorNewHelper*)p) pair<int,Root::TGoodRun> : new pair<int,Root::TGoodRun>;
}
static void *newArray_pairlEintcORootcLcLTGoodRungR(Long_t nElements, void *p) {
return p ? ::new((::ROOT::TOperatorNewHelper*)p) pair<int,Root::TGoodRun>[nElements] : new pair<int,Root::TGoodRun>[nElements];
}
// Wrapper around operator delete
static void delete_pairlEintcORootcLcLTGoodRungR(void *p) {
delete ((pair<int,Root::TGoodRun>*)p);
}
static void deleteArray_pairlEintcORootcLcLTGoodRungR(void *p) {
delete [] ((pair<int,Root::TGoodRun>*)p);
}
static void destruct_pairlEintcORootcLcLTGoodRungR(void *p) {
typedef pair<int,Root::TGoodRun> current_t;
((current_t*)p)->~current_t();
}
} // end of namespace ROOT for class pair<int,Root::TGoodRun>
namespace ROOT {
// Wrappers around operator new
static void *new_maplEintcORootcLcLTGoodRuncOlesslEintgRcOallocatorlEpairlEconstsPintcORootcLcLTGoodRungRsPgRsPgRcLcLiterator(void *p) {
return p ? ::new((::ROOT::TOperatorNewHelper*)p) ::map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > >::iterator : new ::map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > >::iterator;
}
static void *newArray_maplEintcORootcLcLTGoodRuncOlesslEintgRcOallocatorlEpairlEconstsPintcORootcLcLTGoodRungRsPgRsPgRcLcLiterator(Long_t nElements, void *p) {
return p ? ::new((::ROOT::TOperatorNewHelper*)p) ::map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > >::iterator[nElements] : new ::map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > >::iterator[nElements];
}
// Wrapper around operator delete
static void delete_maplEintcORootcLcLTGoodRuncOlesslEintgRcOallocatorlEpairlEconstsPintcORootcLcLTGoodRungRsPgRsPgRcLcLiterator(void *p) {
delete ((::map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > >::iterator*)p);
}
static void deleteArray_maplEintcORootcLcLTGoodRuncOlesslEintgRcOallocatorlEpairlEconstsPintcORootcLcLTGoodRungRsPgRsPgRcLcLiterator(void *p) {
delete [] ((::map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > >::iterator*)p);
}
static void destruct_maplEintcORootcLcLTGoodRuncOlesslEintgRcOallocatorlEpairlEconstsPintcORootcLcLTGoodRungRsPgRsPgRcLcLiterator(void *p) {
typedef ::map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > >::iterator current_t;
((current_t*)p)->~current_t();
}
} // end of namespace ROOT for class ::map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > >::iterator
//______________________________________________________________________________
namespace ROOT {
void pairlETStringcOTStringgR_ShowMembers(void *obj, TMemberInspector &R__insp)
{
// Inspect the data members of an object of class pair<TString,TString>.
typedef ::ROOT::Shadow::pairlETStringcOTStringgR ShadowClass;
ShadowClass *sobj = (ShadowClass*)obj;
if (sobj) { } // Dummy usage just in case there is no datamember.
TClass *R__cl = ::ROOT::GenerateInitInstanceLocal((const pair<TString,TString>*)0x0)->GetClass();
if (R__cl || R__insp.IsA()) { }
R__insp.Inspect(R__cl, R__insp.GetParent(), "first", &sobj->first);
R__insp.InspectMember(sobj->first, "first.");
R__insp.Inspect(R__cl, R__insp.GetParent(), "second", &sobj->second);
R__insp.InspectMember(sobj->second, "second.");
}
}
namespace ROOT {
// Wrappers around operator new
static void *new_pairlETStringcOTStringgR(void *p) {
return p ? ::new((::ROOT::TOperatorNewHelper*)p) pair<TString,TString> : new pair<TString,TString>;
}
static void *newArray_pairlETStringcOTStringgR(Long_t nElements, void *p) {
return p ? ::new((::ROOT::TOperatorNewHelper*)p) pair<TString,TString>[nElements] : new pair<TString,TString>[nElements];
}
// Wrapper around operator delete
static void delete_pairlETStringcOTStringgR(void *p) {
delete ((pair<TString,TString>*)p);
}
static void deleteArray_pairlETStringcOTStringgR(void *p) {
delete [] ((pair<TString,TString>*)p);
}
static void destruct_pairlETStringcOTStringgR(void *p) {
typedef pair<TString,TString> current_t;
((current_t*)p)->~current_t();
}
} // end of namespace ROOT for class pair<TString,TString>
namespace Root {
//______________________________________________________________________________
void TGoodRunsList::Streamer(TBuffer &R__b)
{
// Stream an object of class Root::TGoodRunsList.
if (R__b.IsReading()) {
R__b.ReadClassBuffer(Root::TGoodRunsList::Class(),this);
} else {
R__b.WriteClassBuffer(Root::TGoodRunsList::Class(),this);
}
}
} // namespace Root
//______________________________________________________________________________
namespace Root {
void TGoodRunsList::ShowMembers(TMemberInspector &R__insp)
{
// Inspect the data members of an object of class Root::TGoodRunsList.
TClass *R__cl = ::Root::TGoodRunsList::IsA();
if (R__cl || R__insp.IsA()) { }
R__insp.Inspect(R__cl, R__insp.GetParent(), "m_version", &m_version);
R__insp.InspectMember(m_version, "m_version.");
R__insp.Inspect(R__cl, R__insp.GetParent(), "m_metadata", (void*)&m_metadata);
R__insp.InspectMember("map<TString,TString>", (void*)&m_metadata, "m_metadata.", false);
R__insp.Inspect(R__cl, R__insp.GetParent(), "m_checkGRLInfo", &m_checkGRLInfo);
R__insp.Inspect(R__cl, R__insp.GetParent(), "m_hasRun", &m_hasRun);
R__insp.Inspect(R__cl, R__insp.GetParent(), "m_hasLB", &m_hasLB);
R__insp.Inspect(R__cl, R__insp.GetParent(), "m_prevRun", &m_prevRun);
R__insp.Inspect(R__cl, R__insp.GetParent(), "m_prevLB", &m_prevLB);
R__insp.GenericShowMembers("map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > >", ( ::map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > > *) (this ), false);
TNamed::ShowMembers(R__insp);
}
} // namespace Root
namespace ROOT {
// Wrappers around operator new
static void *new_RootcLcLTGoodRunsList(void *p) {
return p ? new(p) ::Root::TGoodRunsList : new ::Root::TGoodRunsList;
}
static void *newArray_RootcLcLTGoodRunsList(Long_t nElements, void *p) {
return p ? new(p) ::Root::TGoodRunsList[nElements] : new ::Root::TGoodRunsList[nElements];
}
// Wrapper around operator delete
static void delete_RootcLcLTGoodRunsList(void *p) {
delete ((::Root::TGoodRunsList*)p);
}
static void deleteArray_RootcLcLTGoodRunsList(void *p) {
delete [] ((::Root::TGoodRunsList*)p);
}
static void destruct_RootcLcLTGoodRunsList(void *p) {
typedef ::Root::TGoodRunsList current_t;
((current_t*)p)->~current_t();
}
} // end of namespace ROOT for class ::Root::TGoodRunsList
namespace ROOT {
// Wrappers around operator new
static void *new_vectorlERootcLcLTGoodRunsListcOallocatorlERootcLcLTGoodRunsListgRsPgRcLcLiterator(void *p) {
return p ? ::new((::ROOT::TOperatorNewHelper*)p) ::vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >::iterator : new ::vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >::iterator;
}
static void *newArray_vectorlERootcLcLTGoodRunsListcOallocatorlERootcLcLTGoodRunsListgRsPgRcLcLiterator(Long_t nElements, void *p) {
return p ? ::new((::ROOT::TOperatorNewHelper*)p) ::vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >::iterator[nElements] : new ::vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >::iterator[nElements];
}
// Wrapper around operator delete
static void delete_vectorlERootcLcLTGoodRunsListcOallocatorlERootcLcLTGoodRunsListgRsPgRcLcLiterator(void *p) {
delete ((::vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >::iterator*)p);
}
static void deleteArray_vectorlERootcLcLTGoodRunsListcOallocatorlERootcLcLTGoodRunsListgRsPgRcLcLiterator(void *p) {
delete [] ((::vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >::iterator*)p);
}
static void destruct_vectorlERootcLcLTGoodRunsListcOallocatorlERootcLcLTGoodRunsListgRsPgRcLcLiterator(void *p) {
typedef ::vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >::iterator current_t;
((current_t*)p)->~current_t();
}
} // end of namespace ROOT for class ::vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >::iterator
namespace Root {
//______________________________________________________________________________
void TGRLCollection::Streamer(TBuffer &R__b)
{
// Stream an object of class Root::TGRLCollection.
if (R__b.IsReading()) {
R__b.ReadClassBuffer(Root::TGRLCollection::Class(),this);
} else {
R__b.WriteClassBuffer(Root::TGRLCollection::Class(),this);
}
}
} // namespace Root
//______________________________________________________________________________
namespace Root {
void TGRLCollection::ShowMembers(TMemberInspector &R__insp)
{
// Inspect the data members of an object of class Root::TGRLCollection.
TClass *R__cl = ::Root::TGRLCollection::IsA();
if (R__cl || R__insp.IsA()) { }
R__insp.Inspect(R__cl, R__insp.GetParent(), "m_checkGRLInfo", &m_checkGRLInfo);
R__insp.GenericShowMembers("vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >", ( ::vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> > *) (this ), false);
TObject::ShowMembers(R__insp);
}
} // namespace Root
namespace ROOT {
// Wrappers around operator new
static void *new_RootcLcLTGRLCollection(void *p) {
return p ? new(p) ::Root::TGRLCollection : new ::Root::TGRLCollection;
}
static void *newArray_RootcLcLTGRLCollection(Long_t nElements, void *p) {
return p ? new(p) ::Root::TGRLCollection[nElements] : new ::Root::TGRLCollection[nElements];
}
// Wrapper around operator delete
static void delete_RootcLcLTGRLCollection(void *p) {
delete ((::Root::TGRLCollection*)p);
}
static void deleteArray_RootcLcLTGRLCollection(void *p) {
delete [] ((::Root::TGRLCollection*)p);
}
static void destruct_RootcLcLTGRLCollection(void *p) {
typedef ::Root::TGRLCollection current_t;
((current_t*)p)->~current_t();
}
} // end of namespace ROOT for class ::Root::TGRLCollection
namespace ROOT {
void maplETStringcOTStringgR_ShowMembers(void *obj, TMemberInspector &R__insp);
static void maplETStringcOTStringgR_Dictionary();
static void *new_maplETStringcOTStringgR(void *p = 0);
static void *newArray_maplETStringcOTStringgR(Long_t size, void *p);
static void delete_maplETStringcOTStringgR(void *p);
static void deleteArray_maplETStringcOTStringgR(void *p);
static void destruct_maplETStringcOTStringgR(void *p);
// Function generating the singleton type initializer
static TGenericClassInfo *GenerateInitInstanceLocal(const map<TString,TString>*)
{
map<TString,TString> *ptr = 0;
static ::TVirtualIsAProxy* isa_proxy = new ::TIsAProxy(typeid(map<TString,TString>),0);
static ::ROOT::TGenericClassInfo
instance("map<TString,TString>", -2, "/cvmfs/atlas.cern.ch/repo/sw/software/i686-slc5-gcc43-opt/17.2.4/sw/lcg/app/releases/ROOT/5.30.05/i686-slc5-gcc43-opt/root/cint/cint/lib/prec_stl/map", 63,
typeid(map<TString,TString>), DefineBehavior(ptr, ptr),
0, &maplETStringcOTStringgR_Dictionary, isa_proxy, 4,
sizeof(map<TString,TString>) );
instance.SetNew(&new_maplETStringcOTStringgR);
instance.SetNewArray(&newArray_maplETStringcOTStringgR);
instance.SetDelete(&delete_maplETStringcOTStringgR);
instance.SetDeleteArray(&deleteArray_maplETStringcOTStringgR);
instance.SetDestructor(&destruct_maplETStringcOTStringgR);
instance.AdoptCollectionProxyInfo(TCollectionProxyInfo::Generate(TCollectionProxyInfo::MapInsert< map<TString,TString> >()));
return &instance;
}
// Static variable to force the class initialization
static ::ROOT::TGenericClassInfo *_R__UNIQUE_(Init) = GenerateInitInstanceLocal((const map<TString,TString>*)0x0); R__UseDummy(_R__UNIQUE_(Init));
// Dictionary for non-ClassDef classes
static void maplETStringcOTStringgR_Dictionary() {
::ROOT::GenerateInitInstanceLocal((const map<TString,TString>*)0x0)->GetClass();
}
} // end of namespace ROOT
namespace ROOT {
// Wrappers around operator new
static void *new_maplETStringcOTStringgR(void *p) {
return p ? ::new((::ROOT::TOperatorNewHelper*)p) map<TString,TString> : new map<TString,TString>;
}
static void *newArray_maplETStringcOTStringgR(Long_t nElements, void *p) {
return p ? ::new((::ROOT::TOperatorNewHelper*)p) map<TString,TString>[nElements] : new map<TString,TString>[nElements];
}
// Wrapper around operator delete
static void delete_maplETStringcOTStringgR(void *p) {
delete ((map<TString,TString>*)p);
}
static void deleteArray_maplETStringcOTStringgR(void *p) {
delete [] ((map<TString,TString>*)p);
}
static void destruct_maplETStringcOTStringgR(void *p) {
typedef map<TString,TString> current_t;
((current_t*)p)->~current_t();
}
} // end of namespace ROOT for class map<TString,TString>
namespace ROOT {
void maplEintcORootcLcLTGoodRungR_ShowMembers(void *obj, TMemberInspector &R__insp);
static void maplEintcORootcLcLTGoodRungR_Dictionary();
static void *new_maplEintcORootcLcLTGoodRungR(void *p = 0);
static void *newArray_maplEintcORootcLcLTGoodRungR(Long_t size, void *p);
static void delete_maplEintcORootcLcLTGoodRungR(void *p);
static void deleteArray_maplEintcORootcLcLTGoodRungR(void *p);
static void destruct_maplEintcORootcLcLTGoodRungR(void *p);
// Function generating the singleton type initializer
static TGenericClassInfo *GenerateInitInstanceLocal(const map<int,Root::TGoodRun>*)
{
map<int,Root::TGoodRun> *ptr = 0;
static ::TVirtualIsAProxy* isa_proxy = new ::TIsAProxy(typeid(map<int,Root::TGoodRun>),0);
static ::ROOT::TGenericClassInfo
instance("map<int,Root::TGoodRun>", -2, "/cvmfs/atlas.cern.ch/repo/sw/software/i686-slc5-gcc43-opt/17.2.4/sw/lcg/app/releases/ROOT/5.30.05/i686-slc5-gcc43-opt/root/cint/cint/lib/prec_stl/map", 63,
typeid(map<int,Root::TGoodRun>), DefineBehavior(ptr, ptr),
0, &maplEintcORootcLcLTGoodRungR_Dictionary, isa_proxy, 4,
sizeof(map<int,Root::TGoodRun>) );
instance.SetNew(&new_maplEintcORootcLcLTGoodRungR);
instance.SetNewArray(&newArray_maplEintcORootcLcLTGoodRungR);
instance.SetDelete(&delete_maplEintcORootcLcLTGoodRungR);
instance.SetDeleteArray(&deleteArray_maplEintcORootcLcLTGoodRungR);
instance.SetDestructor(&destruct_maplEintcORootcLcLTGoodRungR);
instance.AdoptCollectionProxyInfo(TCollectionProxyInfo::Generate(TCollectionProxyInfo::MapInsert< map<int,Root::TGoodRun> >()));
return &instance;
}
// Static variable to force the class initialization
static ::ROOT::TGenericClassInfo *_R__UNIQUE_(Init) = GenerateInitInstanceLocal((const map<int,Root::TGoodRun>*)0x0); R__UseDummy(_R__UNIQUE_(Init));
// Dictionary for non-ClassDef classes
static void maplEintcORootcLcLTGoodRungR_Dictionary() {
::ROOT::GenerateInitInstanceLocal((const map<int,Root::TGoodRun>*)0x0)->GetClass();
}
} // end of namespace ROOT
namespace ROOT {
// Wrappers around operator new
static void *new_maplEintcORootcLcLTGoodRungR(void *p) {
return p ? ::new((::ROOT::TOperatorNewHelper*)p) map<int,Root::TGoodRun> : new map<int,Root::TGoodRun>;
}
static void *newArray_maplEintcORootcLcLTGoodRungR(Long_t nElements, void *p) {
return p ? ::new((::ROOT::TOperatorNewHelper*)p) map<int,Root::TGoodRun>[nElements] : new map<int,Root::TGoodRun>[nElements];
}
// Wrapper around operator delete
static void delete_maplEintcORootcLcLTGoodRungR(void *p) {
delete ((map<int,Root::TGoodRun>*)p);
}
static void deleteArray_maplEintcORootcLcLTGoodRungR(void *p) {
delete [] ((map<int,Root::TGoodRun>*)p);
}
static void destruct_maplEintcORootcLcLTGoodRungR(void *p) {
typedef map<int,Root::TGoodRun> current_t;
((current_t*)p)->~current_t();
}
} // end of namespace ROOT for class map<int,Root::TGoodRun>
namespace ROOT {
void vectorlERootcLcLTGoodRungR_ShowMembers(void *obj, TMemberInspector &R__insp);
static void vectorlERootcLcLTGoodRungR_Dictionary();
static void *new_vectorlERootcLcLTGoodRungR(void *p = 0);
static void *newArray_vectorlERootcLcLTGoodRungR(Long_t size, void *p);
static void delete_vectorlERootcLcLTGoodRungR(void *p);
static void deleteArray_vectorlERootcLcLTGoodRungR(void *p);
static void destruct_vectorlERootcLcLTGoodRungR(void *p);
// Function generating the singleton type initializer
static TGenericClassInfo *GenerateInitInstanceLocal(const vector<Root::TGoodRun>*)
{
vector<Root::TGoodRun> *ptr = 0;
static ::TVirtualIsAProxy* isa_proxy = new ::TIsAProxy(typeid(vector<Root::TGoodRun>),0);
static ::ROOT::TGenericClassInfo
instance("vector<Root::TGoodRun>", -2, "/cvmfs/atlas.cern.ch/repo/sw/software/i686-slc5-gcc43-opt/17.2.4/sw/lcg/app/releases/ROOT/5.30.05/i686-slc5-gcc43-opt/root/cint/cint/lib/prec_stl/vector", 49,
typeid(vector<Root::TGoodRun>), DefineBehavior(ptr, ptr),
0, &vectorlERootcLcLTGoodRungR_Dictionary, isa_proxy, 4,
sizeof(vector<Root::TGoodRun>) );
instance.SetNew(&new_vectorlERootcLcLTGoodRungR);
instance.SetNewArray(&newArray_vectorlERootcLcLTGoodRungR);
instance.SetDelete(&delete_vectorlERootcLcLTGoodRungR);
instance.SetDeleteArray(&deleteArray_vectorlERootcLcLTGoodRungR);
instance.SetDestructor(&destruct_vectorlERootcLcLTGoodRungR);
instance.AdoptCollectionProxyInfo(TCollectionProxyInfo::Generate(TCollectionProxyInfo::Pushback< vector<Root::TGoodRun> >()));
return &instance;
}
// Static variable to force the class initialization
static ::ROOT::TGenericClassInfo *_R__UNIQUE_(Init) = GenerateInitInstanceLocal((const vector<Root::TGoodRun>*)0x0); R__UseDummy(_R__UNIQUE_(Init));
// Dictionary for non-ClassDef classes
static void vectorlERootcLcLTGoodRungR_Dictionary() {
::ROOT::GenerateInitInstanceLocal((const vector<Root::TGoodRun>*)0x0)->GetClass();
}
} // end of namespace ROOT
namespace ROOT {
// Wrappers around operator new
static void *new_vectorlERootcLcLTGoodRungR(void *p) {
return p ? ::new((::ROOT::TOperatorNewHelper*)p) vector<Root::TGoodRun> : new vector<Root::TGoodRun>;
}
static void *newArray_vectorlERootcLcLTGoodRungR(Long_t nElements, void *p) {
return p ? ::new((::ROOT::TOperatorNewHelper*)p) vector<Root::TGoodRun>[nElements] : new vector<Root::TGoodRun>[nElements];
}
// Wrapper around operator delete
static void delete_vectorlERootcLcLTGoodRungR(void *p) {
delete ((vector<Root::TGoodRun>*)p);
}
static void deleteArray_vectorlERootcLcLTGoodRungR(void *p) {
delete [] ((vector<Root::TGoodRun>*)p);
}
static void destruct_vectorlERootcLcLTGoodRungR(void *p) {
typedef vector<Root::TGoodRun> current_t;
((current_t*)p)->~current_t();
}
} // end of namespace ROOT for class vector<Root::TGoodRun>
namespace ROOT {
void vectorlERootcLcLTGoodRunsListgR_ShowMembers(void *obj, TMemberInspector &R__insp);
static void vectorlERootcLcLTGoodRunsListgR_Dictionary();
static void *new_vectorlERootcLcLTGoodRunsListgR(void *p = 0);
static void *newArray_vectorlERootcLcLTGoodRunsListgR(Long_t size, void *p);
static void delete_vectorlERootcLcLTGoodRunsListgR(void *p);
static void deleteArray_vectorlERootcLcLTGoodRunsListgR(void *p);
static void destruct_vectorlERootcLcLTGoodRunsListgR(void *p);
// Function generating the singleton type initializer
static TGenericClassInfo *GenerateInitInstanceLocal(const vector<Root::TGoodRunsList>*)
{
vector<Root::TGoodRunsList> *ptr = 0;
static ::TVirtualIsAProxy* isa_proxy = new ::TIsAProxy(typeid(vector<Root::TGoodRunsList>),0);
static ::ROOT::TGenericClassInfo
instance("vector<Root::TGoodRunsList>", -2, "/cvmfs/atlas.cern.ch/repo/sw/software/i686-slc5-gcc43-opt/17.2.4/sw/lcg/app/releases/ROOT/5.30.05/i686-slc5-gcc43-opt/root/cint/cint/lib/prec_stl/vector", 49,
typeid(vector<Root::TGoodRunsList>), DefineBehavior(ptr, ptr),
0, &vectorlERootcLcLTGoodRunsListgR_Dictionary, isa_proxy, 4,
sizeof(vector<Root::TGoodRunsList>) );
instance.SetNew(&new_vectorlERootcLcLTGoodRunsListgR);
instance.SetNewArray(&newArray_vectorlERootcLcLTGoodRunsListgR);
instance.SetDelete(&delete_vectorlERootcLcLTGoodRunsListgR);
instance.SetDeleteArray(&deleteArray_vectorlERootcLcLTGoodRunsListgR);
instance.SetDestructor(&destruct_vectorlERootcLcLTGoodRunsListgR);
instance.AdoptCollectionProxyInfo(TCollectionProxyInfo::Generate(TCollectionProxyInfo::Pushback< vector<Root::TGoodRunsList> >()));
return &instance;
}
// Static variable to force the class initialization
static ::ROOT::TGenericClassInfo *_R__UNIQUE_(Init) = GenerateInitInstanceLocal((const vector<Root::TGoodRunsList>*)0x0); R__UseDummy(_R__UNIQUE_(Init));
// Dictionary for non-ClassDef classes
static void vectorlERootcLcLTGoodRunsListgR_Dictionary() {
::ROOT::GenerateInitInstanceLocal((const vector<Root::TGoodRunsList>*)0x0)->GetClass();
}
} // end of namespace ROOT
namespace ROOT {
// Wrappers around operator new
static void *new_vectorlERootcLcLTGoodRunsListgR(void *p) {
return p ? ::new((::ROOT::TOperatorNewHelper*)p) vector<Root::TGoodRunsList> : new vector<Root::TGoodRunsList>;
}
static void *newArray_vectorlERootcLcLTGoodRunsListgR(Long_t nElements, void *p) {
return p ? ::new((::ROOT::TOperatorNewHelper*)p) vector<Root::TGoodRunsList>[nElements] : new vector<Root::TGoodRunsList>[nElements];
}
// Wrapper around operator delete
static void delete_vectorlERootcLcLTGoodRunsListgR(void *p) {
delete ((vector<Root::TGoodRunsList>*)p);
}
static void deleteArray_vectorlERootcLcLTGoodRunsListgR(void *p) {
delete [] ((vector<Root::TGoodRunsList>*)p);
}
static void destruct_vectorlERootcLcLTGoodRunsListgR(void *p) {
typedef vector<Root::TGoodRunsList> current_t;
((current_t*)p)->~current_t();
}
} // end of namespace ROOT for class vector<Root::TGoodRunsList>
namespace ROOT {
void vectorlERootcLcLTLumiBlockRangegR_ShowMembers(void *obj, TMemberInspector &R__insp);
static void vectorlERootcLcLTLumiBlockRangegR_Dictionary();
static void *new_vectorlERootcLcLTLumiBlockRangegR(void *p = 0);
static void *newArray_vectorlERootcLcLTLumiBlockRangegR(Long_t size, void *p);
static void delete_vectorlERootcLcLTLumiBlockRangegR(void *p);
static void deleteArray_vectorlERootcLcLTLumiBlockRangegR(void *p);
static void destruct_vectorlERootcLcLTLumiBlockRangegR(void *p);
// Function generating the singleton type initializer
static TGenericClassInfo *GenerateInitInstanceLocal(const vector<Root::TLumiBlockRange>*)
{
vector<Root::TLumiBlockRange> *ptr = 0;
static ::TVirtualIsAProxy* isa_proxy = new ::TIsAProxy(typeid(vector<Root::TLumiBlockRange>),0);
static ::ROOT::TGenericClassInfo
instance("vector<Root::TLumiBlockRange>", -2, "/cvmfs/atlas.cern.ch/repo/sw/software/i686-slc5-gcc43-opt/17.2.4/sw/lcg/app/releases/ROOT/5.30.05/i686-slc5-gcc43-opt/root/cint/cint/lib/prec_stl/vector", 49,
typeid(vector<Root::TLumiBlockRange>), DefineBehavior(ptr, ptr),
0, &vectorlERootcLcLTLumiBlockRangegR_Dictionary, isa_proxy, 4,
sizeof(vector<Root::TLumiBlockRange>) );
instance.SetNew(&new_vectorlERootcLcLTLumiBlockRangegR);
instance.SetNewArray(&newArray_vectorlERootcLcLTLumiBlockRangegR);
instance.SetDelete(&delete_vectorlERootcLcLTLumiBlockRangegR);
instance.SetDeleteArray(&deleteArray_vectorlERootcLcLTLumiBlockRangegR);
instance.SetDestructor(&destruct_vectorlERootcLcLTLumiBlockRangegR);
instance.AdoptCollectionProxyInfo(TCollectionProxyInfo::Generate(TCollectionProxyInfo::Pushback< vector<Root::TLumiBlockRange> >()));
return &instance;
}
// Static variable to force the class initialization
static ::ROOT::TGenericClassInfo *_R__UNIQUE_(Init) = GenerateInitInstanceLocal((const vector<Root::TLumiBlockRange>*)0x0); R__UseDummy(_R__UNIQUE_(Init));
// Dictionary for non-ClassDef classes
static void vectorlERootcLcLTLumiBlockRangegR_Dictionary() {
::ROOT::GenerateInitInstanceLocal((const vector<Root::TLumiBlockRange>*)0x0)->GetClass();
}
} // end of namespace ROOT
namespace ROOT {
// Wrappers around operator new
static void *new_vectorlERootcLcLTLumiBlockRangegR(void *p) {
return p ? ::new((::ROOT::TOperatorNewHelper*)p) vector<Root::TLumiBlockRange> : new vector<Root::TLumiBlockRange>;
}
static void *newArray_vectorlERootcLcLTLumiBlockRangegR(Long_t nElements, void *p) {
return p ? ::new((::ROOT::TOperatorNewHelper*)p) vector<Root::TLumiBlockRange>[nElements] : new vector<Root::TLumiBlockRange>[nElements];
}
// Wrapper around operator delete
static void delete_vectorlERootcLcLTLumiBlockRangegR(void *p) {
delete ((vector<Root::TLumiBlockRange>*)p);
}
static void deleteArray_vectorlERootcLcLTLumiBlockRangegR(void *p) {
delete [] ((vector<Root::TLumiBlockRange>*)p);
}
static void destruct_vectorlERootcLcLTLumiBlockRangegR(void *p) {
typedef vector<Root::TLumiBlockRange> current_t;
((current_t*)p)->~current_t();
}
} // end of namespace ROOT for class vector<Root::TLumiBlockRange>
/********************************************************
* ../Root/TGoodRunsListsCint.cxx
* CAUTION: DON'T CHANGE THIS FILE. THIS FILE IS AUTOMATICALLY GENERATED
* FROM HEADER FILES LISTED IN G__setup_cpp_environmentXXX().
* CHANGE THOSE HEADER FILES AND REGENERATE THIS FILE.
********************************************************/
#ifdef G__MEMTEST
#undef malloc
#undef free
#endif
#if defined(__GNUC__) && __GNUC__ >= 4 && ((__GNUC_MINOR__ == 2 && __GNUC_PATCHLEVEL__ >= 1) || (__GNUC_MINOR__ >= 3))
#pragma GCC diagnostic ignored "-Wstrict-aliasing"
#endif
extern "C" void G__cpp_reset_tagtableTGoodRunsListsCint();
extern "C" void G__set_cpp_environmentTGoodRunsListsCint() {
G__cpp_reset_tagtableTGoodRunsListsCint();
}
#include <new>
extern "C" int G__cpp_dllrevTGoodRunsListsCint() { return(30051515); }
/*********************************************************
* Member function Interface Method
*********************************************************/
/* Root */
/* Root::RegularFormula */
static int G__TGoodRunsListsCint_216_0_1(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
Root::RegularFormula* p = NULL;
char* gvp = (char*) G__getgvp();
int n = G__getaryconstruct();
if (n) {
if ((gvp == (char*)G__PVOID) || (gvp == 0)) {
p = new Root::RegularFormula[n];
} else {
p = new((void*) gvp) Root::RegularFormula[n];
}
} else {
if ((gvp == (char*)G__PVOID) || (gvp == 0)) {
p = new Root::RegularFormula;
} else {
p = new((void*) gvp) Root::RegularFormula;
}
}
result7->obj.i = (long) p;
result7->ref = (long) p;
G__set_tagnum(result7,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_RootcLcLRegularFormula));
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_216_0_2(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
Root::RegularFormula* p = NULL;
char* gvp = (char*) G__getgvp();
//m: 2
if ((gvp == (char*)G__PVOID) || (gvp == 0)) {
p = new Root::RegularFormula((const char*) G__int(libp->para[0]), (const char*) G__int(libp->para[1]));
} else {
p = new((void*) gvp) Root::RegularFormula((const char*) G__int(libp->para[0]), (const char*) G__int(libp->para[1]));
}
result7->obj.i = (long) p;
result7->ref = (long) p;
G__set_tagnum(result7,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_RootcLcLRegularFormula));
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_216_0_3(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
Root::RegularFormula* p = NULL;
char* gvp = (char*) G__getgvp();
//m: 1
if ((gvp == (char*)G__PVOID) || (gvp == 0)) {
p = new Root::RegularFormula(*(Root::RegularFormula*) libp->para[0].ref);
} else {
p = new((void*) gvp) Root::RegularFormula(*(Root::RegularFormula*) libp->para[0].ref);
}
result7->obj.i = (long) p;
result7->ref = (long) p;
G__set_tagnum(result7,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_RootcLcLRegularFormula));
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_216_0_4(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
{
const Root::RegularFormula& obj = ((Root::RegularFormula*) G__getstructoffset())->operator=(*(Root::RegularFormula*) libp->para[0].ref);
result7->ref = (long) (&obj);
result7->obj.i = (long) (&obj);
}
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_216_0_5(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
G__letint(result7, 105, (long) ((Root::RegularFormula*) G__getstructoffset())->setFormula((const char*) G__int(libp->para[0])));
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_216_0_6(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
G__letint(result7, 104, (long) ((const Root::RegularFormula*) G__getstructoffset())->getNPars());
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_216_0_7(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
{
const list<TString>& obj = ((const Root::RegularFormula*) G__getstructoffset())->getParNames();
result7->ref = (long) (&obj);
result7->obj.i = (long) (&obj);
}
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_216_0_9(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
G__letint(result7, 85, (long) Root::RegularFormula::Class());
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_216_0_10(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
G__letint(result7, 67, (long) Root::RegularFormula::Class_Name());
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_216_0_11(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
G__letint(result7, 115, (long) Root::RegularFormula::Class_Version());
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_216_0_12(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
Root::RegularFormula::Dictionary();
G__setnull(result7);
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_216_0_16(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
((Root::RegularFormula*) G__getstructoffset())->StreamerNVirtual(*(TBuffer*) libp->para[0].ref);
G__setnull(result7);
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_216_0_17(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
G__letint(result7, 67, (long) Root::RegularFormula::DeclFileName());
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_216_0_18(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
G__letint(result7, 105, (long) Root::RegularFormula::ImplFileLine());
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_216_0_19(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
G__letint(result7, 67, (long) Root::RegularFormula::ImplFileName());
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_216_0_20(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
G__letint(result7, 105, (long) Root::RegularFormula::DeclFileLine());
return(1 || funcname || hash || result7 || libp) ;
}
// automatic destructor
typedef Root::RegularFormula G__TRootcLcLRegularFormula;
static int G__TGoodRunsListsCint_216_0_21(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
char* gvp = (char*) G__getgvp();
long soff = G__getstructoffset();
int n = G__getaryconstruct();
//
//has_a_delete: 1
//has_own_delete1arg: 0
//has_own_delete2arg: 0
//
if (!soff) {
return(1);
}
if (n) {
if (gvp == (char*)G__PVOID) {
delete[] (Root::RegularFormula*) soff;
} else {
G__setgvp((long) G__PVOID);
for (int i = n - 1; i >= 0; --i) {
((Root::RegularFormula*) (soff+(sizeof(Root::RegularFormula)*i)))->~G__TRootcLcLRegularFormula();
}
G__setgvp((long)gvp);
}
} else {
if (gvp == (char*)G__PVOID) {
delete (Root::RegularFormula*) soff;
} else {
G__setgvp((long) G__PVOID);
((Root::RegularFormula*) (soff))->~G__TRootcLcLRegularFormula();
G__setgvp((long)gvp);
}
}
G__setnull(result7);
return(1 || funcname || hash || result7 || libp) ;
}
/* Root::TLumiBlockRange */
static int G__TGoodRunsListsCint_497_0_1(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
Root::TLumiBlockRange* p = NULL;
char* gvp = (char*) G__getgvp();
int n = G__getaryconstruct();
if (n) {
if ((gvp == (char*)G__PVOID) || (gvp == 0)) {
p = new Root::TLumiBlockRange[n];
} else {
p = new((void*) gvp) Root::TLumiBlockRange[n];
}
} else {
if ((gvp == (char*)G__PVOID) || (gvp == 0)) {
p = new Root::TLumiBlockRange;
} else {
p = new((void*) gvp) Root::TLumiBlockRange;
}
}
result7->obj.i = (long) p;
result7->ref = (long) p;
G__set_tagnum(result7,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_RootcLcLTLumiBlockRange));
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_497_0_2(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
Root::TLumiBlockRange* p = NULL;
char* gvp = (char*) G__getgvp();
switch (libp->paran) {
case 2:
//m: 2
if ((gvp == (char*)G__PVOID) || (gvp == 0)) {
p = new Root::TLumiBlockRange(*(Int_t*) G__Intref(&libp->para[0]), *(Int_t*) G__Intref(&libp->para[1]));
} else {
p = new((void*) gvp) Root::TLumiBlockRange(*(Int_t*) G__Intref(&libp->para[0]), *(Int_t*) G__Intref(&libp->para[1]));
}
break;
case 1:
//m: 1
if ((gvp == (char*)G__PVOID) || (gvp == 0)) {
p = new Root::TLumiBlockRange(*(Int_t*) G__Intref(&libp->para[0]));
} else {
p = new((void*) gvp) Root::TLumiBlockRange(*(Int_t*) G__Intref(&libp->para[0]));
}
break;
}
result7->obj.i = (long) p;
result7->ref = (long) p;
G__set_tagnum(result7,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_RootcLcLTLumiBlockRange));
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_497_0_3(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
Root::TLumiBlockRange* p = NULL;
char* gvp = (char*) G__getgvp();
//m: 1
if ((gvp == (char*)G__PVOID) || (gvp == 0)) {
p = new Root::TLumiBlockRange(*(Root::TLumiBlockRange*) libp->para[0].ref);
} else {
p = new((void*) gvp) Root::TLumiBlockRange(*(Root::TLumiBlockRange*) libp->para[0].ref);
}
result7->obj.i = (long) p;
result7->ref = (long) p;
G__set_tagnum(result7,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_RootcLcLTLumiBlockRange));
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_497_0_4(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
{
const Root::TLumiBlockRange& obj = ((Root::TLumiBlockRange*) G__getstructoffset())->operator=(*(Root::TLumiBlockRange*) libp->para[0].ref);
result7->ref = (long) (&obj);
result7->obj.i = (long) (&obj);
}
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_497_0_5(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
{
const Root::TLumiBlockRange* pobj;
const Root::TLumiBlockRange xobj = ((const Root::TLumiBlockRange*) G__getstructoffset())->GetOverlapWith(*(Root::TLumiBlockRange*) libp->para[0].ref);
pobj = new Root::TLumiBlockRange(xobj);
result7->obj.i = (long) ((void*) pobj);
result7->ref = result7->obj.i;
G__store_tempobject(*result7);
}
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_497_0_6(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
{
const vector<Root::TLumiBlockRange>* pobj;
const vector<Root::TLumiBlockRange> xobj = ((const Root::TLumiBlockRange*) G__getstructoffset())->GetPartOnlyIn(*(Root::TLumiBlockRange*) libp->para[0].ref);
pobj = new vector<Root::TLumiBlockRange>(xobj);
result7->obj.i = (long) ((void*) pobj);
result7->ref = result7->obj.i;
G__store_tempobject(*result7);
}
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_497_0_7(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
{
const vector<Root::TLumiBlockRange>* pobj;
const vector<Root::TLumiBlockRange> xobj = ((const Root::TLumiBlockRange*) G__getstructoffset())->GetPartNotIn(*(Root::TLumiBlockRange*) libp->para[0].ref);
pobj = new vector<Root::TLumiBlockRange>(xobj);
result7->obj.i = (long) ((void*) pobj);
result7->ref = result7->obj.i;
G__store_tempobject(*result7);
}
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_497_0_8(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
G__letint(result7, 103, (long) ((const Root::TLumiBlockRange*) G__getstructoffset())->Contains(*(Int_t*) G__Intref(&libp->para[0])));
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_497_0_9(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
G__letint(result7, 105, (long) ((const Root::TLumiBlockRange*) G__getstructoffset())->Begin());
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_497_0_10(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
G__letint(result7, 105, (long) ((const Root::TLumiBlockRange*) G__getstructoffset())->End());
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_497_0_11(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
G__letint(result7, 103, (long) ((const Root::TLumiBlockRange*) G__getstructoffset())->IsEmpty());
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_497_0_12(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
((Root::TLumiBlockRange*) G__getstructoffset())->SetBegin(*(Int_t*) G__Intref(&libp->para[0]));
G__setnull(result7);
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_497_0_13(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
((Root::TLumiBlockRange*) G__getstructoffset())->SetEnd(*(Int_t*) G__Intref(&libp->para[0]));
G__setnull(result7);
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_497_0_14(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
((const Root::TLumiBlockRange*) G__getstructoffset())->Summary();
G__setnull(result7);
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_497_0_15(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
G__letint(result7, 85, (long) Root::TLumiBlockRange::Class());
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_497_0_16(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
G__letint(result7, 67, (long) Root::TLumiBlockRange::Class_Name());
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_497_0_17(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
G__letint(result7, 115, (long) Root::TLumiBlockRange::Class_Version());
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_497_0_18(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
Root::TLumiBlockRange::Dictionary();
G__setnull(result7);
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_497_0_22(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
((Root::TLumiBlockRange*) G__getstructoffset())->StreamerNVirtual(*(TBuffer*) libp->para[0].ref);
G__setnull(result7);
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_497_0_23(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
G__letint(result7, 67, (long) Root::TLumiBlockRange::DeclFileName());
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_497_0_24(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
G__letint(result7, 105, (long) Root::TLumiBlockRange::ImplFileLine());
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_497_0_25(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
G__letint(result7, 67, (long) Root::TLumiBlockRange::ImplFileName());
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_497_0_26(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
G__letint(result7, 105, (long) Root::TLumiBlockRange::DeclFileLine());
return(1 || funcname || hash || result7 || libp) ;
}
// automatic destructor
typedef Root::TLumiBlockRange G__TRootcLcLTLumiBlockRange;
static int G__TGoodRunsListsCint_497_0_27(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
char* gvp = (char*) G__getgvp();
long soff = G__getstructoffset();
int n = G__getaryconstruct();
//
//has_a_delete: 1
//has_own_delete1arg: 0
//has_own_delete2arg: 0
//
if (!soff) {
return(1);
}
if (n) {
if (gvp == (char*)G__PVOID) {
delete[] (Root::TLumiBlockRange*) soff;
} else {
G__setgvp((long) G__PVOID);
for (int i = n - 1; i >= 0; --i) {
((Root::TLumiBlockRange*) (soff+(sizeof(Root::TLumiBlockRange)*i)))->~G__TRootcLcLTLumiBlockRange();
}
G__setgvp((long)gvp);
}
} else {
if (gvp == (char*)G__PVOID) {
delete (Root::TLumiBlockRange*) soff;
} else {
G__setgvp((long) G__PVOID);
((Root::TLumiBlockRange*) (soff))->~G__TRootcLcLTLumiBlockRange();
G__setgvp((long)gvp);
}
}
G__setnull(result7);
return(1 || funcname || hash || result7 || libp) ;
}
/* vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> > */
static int G__TGoodRunsListsCint_499_0_1(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
{
const vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >::reference obj = ((vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >*) G__getstructoffset())->at((vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >::size_type) G__int(libp->para[0]));
result7->ref = (long) (&obj);
result7->obj.i = (long) (&obj);
}
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_499_0_2(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
{
vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >::const_reference obj = ((const vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >*) G__getstructoffset())->at((vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >::size_type) G__int(libp->para[0]));
result7->ref = (long) (&obj);
result7->obj.i = (long) (&obj);
}
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_499_0_3(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
{
vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >::iterator* pobj;
vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >::iterator xobj = ((vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >*) G__getstructoffset())->begin();
pobj = new vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >::iterator(xobj);
result7->obj.i = (long) ((void*) pobj);
result7->ref = result7->obj.i;
G__store_tempobject(*result7);
}
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_499_0_4(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
{
vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >::iterator* pobj;
vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >::iterator xobj = ((vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >*) G__getstructoffset())->end();
pobj = new vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >::iterator(xobj);
result7->obj.i = (long) ((void*) pobj);
result7->ref = result7->obj.i;
G__store_tempobject(*result7);
}
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_499_0_5(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
{
vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >::reverse_iterator* pobj;
vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >::reverse_iterator xobj = ((vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >*) G__getstructoffset())->rbegin();
pobj = new vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >::reverse_iterator(xobj);
result7->obj.i = (long) ((void*) pobj);
result7->ref = result7->obj.i;
G__store_tempobject(*result7);
}
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_499_0_6(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
{
vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >::reverse_iterator* pobj;
vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >::reverse_iterator xobj = ((vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >*) G__getstructoffset())->rend();
pobj = new vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >::reverse_iterator(xobj);
result7->obj.i = (long) ((void*) pobj);
result7->ref = result7->obj.i;
G__store_tempobject(*result7);
}
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_499_0_7(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
G__letint(result7, 104, (long) ((const vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >*) G__getstructoffset())->size());
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_499_0_8(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
G__letint(result7, 104, (long) ((const vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >*) G__getstructoffset())->max_size());
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_499_0_9(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
((vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >*) G__getstructoffset())->resize((vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >::size_type) G__int(libp->para[0]));
G__setnull(result7);
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_499_0_10(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
((vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >*) G__getstructoffset())->resize((vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >::size_type) G__int(libp->para[0]), *((Root::TLumiBlockRange*) G__int(libp->para[1])));
G__setnull(result7);
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_499_0_11(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
G__letint(result7, 104, (long) ((const vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >*) G__getstructoffset())->capacity());
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_499_0_12(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
G__letint(result7, 103, (long) ((const vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >*) G__getstructoffset())->empty());
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_499_0_13(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
{
const vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >::reference obj = ((vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >*) G__getstructoffset())->operator[]((vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >::size_type) G__int(libp->para[0]));
result7->ref = (long) (&obj);
result7->obj.i = (long) (&obj);
}
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_499_0_14(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
{
vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >::const_reference obj = ((const vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >*) G__getstructoffset())->operator[]((vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >::size_type) G__int(libp->para[0]));
result7->ref = (long) (&obj);
result7->obj.i = (long) (&obj);
}
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_499_0_15(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >* p = NULL;
char* gvp = (char*) G__getgvp();
int n = G__getaryconstruct();
if (n) {
if ((gvp == (char*)G__PVOID) || (gvp == 0)) {
p = new vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >[n];
} else {
p = new((void*) gvp) vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >[n];
}
} else {
if ((gvp == (char*)G__PVOID) || (gvp == 0)) {
p = new vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >;
} else {
p = new((void*) gvp) vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >;
}
}
result7->obj.i = (long) p;
result7->ref = (long) p;
G__set_tagnum(result7,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_vectorlERootcLcLTLumiBlockRangecOallocatorlERootcLcLTLumiBlockRangegRsPgR));
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_499_0_16(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >* p = NULL;
char* gvp = (char*) G__getgvp();
switch (libp->paran) {
case 2:
//m: 2
if ((gvp == (char*)G__PVOID) || (gvp == 0)) {
p = new vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >((vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >::size_type) G__int(libp->para[0]), *(Root::TLumiBlockRange*) libp->para[1].ref);
} else {
p = new((void*) gvp) vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >((vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >::size_type) G__int(libp->para[0]), *(Root::TLumiBlockRange*) libp->para[1].ref);
}
break;
case 1:
//m: 1
if ((gvp == (char*)G__PVOID) || (gvp == 0)) {
p = new vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >((vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >::size_type) G__int(libp->para[0]));
} else {
p = new((void*) gvp) vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >((vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >::size_type) G__int(libp->para[0]));
}
break;
}
result7->obj.i = (long) p;
result7->ref = (long) p;
G__set_tagnum(result7,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_vectorlERootcLcLTLumiBlockRangecOallocatorlERootcLcLTLumiBlockRangegRsPgR));
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_499_0_17(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >* p = NULL;
char* gvp = (char*) G__getgvp();
//m: 1
if ((gvp == (char*)G__PVOID) || (gvp == 0)) {
p = new vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >(*(vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >*) libp->para[0].ref);
} else {
p = new((void*) gvp) vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >(*(vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >*) libp->para[0].ref);
}
result7->obj.i = (long) p;
result7->ref = (long) p;
G__set_tagnum(result7,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_vectorlERootcLcLTLumiBlockRangecOallocatorlERootcLcLTLumiBlockRangegRsPgR));
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_499_0_18(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >* p = NULL;
char* gvp = (char*) G__getgvp();
//m: 2
if ((gvp == (char*)G__PVOID) || (gvp == 0)) {
p = new vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >(*((vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >::const_iterator*) G__int(libp->para[0])), *((vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >::const_iterator*) G__int(libp->para[1])));
} else {
p = new((void*) gvp) vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >(*((vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >::const_iterator*) G__int(libp->para[0])), *((vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >::const_iterator*) G__int(libp->para[1])));
}
result7->obj.i = (long) p;
result7->ref = (long) p;
G__set_tagnum(result7,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_vectorlERootcLcLTLumiBlockRangecOallocatorlERootcLcLTLumiBlockRangegRsPgR));
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_499_0_19(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
{
const vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >& obj = ((vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >*) G__getstructoffset())->operator=(*(vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >*) libp->para[0].ref);
result7->ref = (long) (&obj);
result7->obj.i = (long) (&obj);
}
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_499_0_20(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
((vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >*) G__getstructoffset())->reserve((vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >::size_type) G__int(libp->para[0]));
G__setnull(result7);
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_499_0_21(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
{
const Root::TLumiBlockRange& obj = ((vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >*) G__getstructoffset())->front();
result7->ref = (long) (&obj);
result7->obj.i = (long) (&obj);
}
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_499_0_22(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
{
const Root::TLumiBlockRange& obj = ((vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >*) G__getstructoffset())->back();
result7->ref = (long) (&obj);
result7->obj.i = (long) (&obj);
}
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_499_0_23(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
((vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >*) G__getstructoffset())->push_back(*(Root::TLumiBlockRange*) libp->para[0].ref);
G__setnull(result7);
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_499_0_24(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
((vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >*) G__getstructoffset())->swap(*(vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >*) libp->para[0].ref);
G__setnull(result7);
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_499_0_25(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
{
vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >::iterator* pobj;
vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >::iterator xobj = ((vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >*) G__getstructoffset())->insert(*((vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >::iterator*) G__int(libp->para[0])), *(Root::TLumiBlockRange*) libp->para[1].ref);
pobj = new vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >::iterator(xobj);
result7->obj.i = (long) ((void*) pobj);
result7->ref = result7->obj.i;
G__store_tempobject(*result7);
}
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_499_0_26(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
((vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >*) G__getstructoffset())->insert(*((vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >::iterator*) G__int(libp->para[0])), *((vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >::const_iterator*) G__int(libp->para[1]))
, *((vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >::const_iterator*) G__int(libp->para[2])));
G__setnull(result7);
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_499_0_27(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
((vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >*) G__getstructoffset())->insert(*((vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >::iterator*) G__int(libp->para[0])), (vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >::size_type) G__int(libp->para[1])
, *(Root::TLumiBlockRange*) libp->para[2].ref);
G__setnull(result7);
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_499_0_28(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
((vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >*) G__getstructoffset())->pop_back();
G__setnull(result7);
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_499_0_29(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
((vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >*) G__getstructoffset())->erase(*((vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >::iterator*) G__int(libp->para[0])));
G__setnull(result7);
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_499_0_30(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
((vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >*) G__getstructoffset())->erase(*((vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >::iterator*) G__int(libp->para[0])), *((vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >::iterator*) G__int(libp->para[1])));
G__setnull(result7);
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_499_0_31(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
((vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >*) G__getstructoffset())->clear();
G__setnull(result7);
return(1 || funcname || hash || result7 || libp) ;
}
// automatic destructor
typedef vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> > G__TvectorlERootcLcLTLumiBlockRangecOallocatorlERootcLcLTLumiBlockRangegRsPgR;
static int G__TGoodRunsListsCint_499_0_32(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
char* gvp = (char*) G__getgvp();
long soff = G__getstructoffset();
int n = G__getaryconstruct();
//
//has_a_delete: 0
//has_own_delete1arg: 0
//has_own_delete2arg: 0
//
if (!soff) {
return(1);
}
if (n) {
if (gvp == (char*)G__PVOID) {
delete[] (vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >*) soff;
} else {
G__setgvp((long) G__PVOID);
for (int i = n - 1; i >= 0; --i) {
((vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >*) (soff+(sizeof(vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >)*i)))->~G__TvectorlERootcLcLTLumiBlockRangecOallocatorlERootcLcLTLumiBlockRangegRsPgR();
}
G__setgvp((long)gvp);
}
} else {
if (gvp == (char*)G__PVOID) {
delete (vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >*) soff;
} else {
G__setgvp((long) G__PVOID);
((vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >*) (soff))->~G__TvectorlERootcLcLTLumiBlockRangecOallocatorlERootcLcLTLumiBlockRangegRsPgR();
G__setgvp((long)gvp);
}
}
G__setnull(result7);
return(1 || funcname || hash || result7 || libp) ;
}
/* vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >::iterator */
static int G__TGoodRunsListsCint_500_0_1(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >::iterator* p = NULL;
char* gvp = (char*) G__getgvp();
int n = G__getaryconstruct();
if (n) {
if ((gvp == (char*)G__PVOID) || (gvp == 0)) {
p = new vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >::iterator[n];
} else {
p = new((void*) gvp) vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >::iterator[n];
}
} else {
if ((gvp == (char*)G__PVOID) || (gvp == 0)) {
p = new vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >::iterator;
} else {
p = new((void*) gvp) vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >::iterator;
}
}
result7->obj.i = (long) p;
result7->ref = (long) p;
G__set_tagnum(result7,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_vectorlERootcLcLTLumiBlockRangecOallocatorlERootcLcLTLumiBlockRangegRsPgRcLcLiterator));
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_500_0_2(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >::iterator* p = NULL;
char* gvp = (char*) G__getgvp();
//m: 1
if ((gvp == (char*)G__PVOID) || (gvp == 0)) {
p = new vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >::iterator(libp->para[0].ref ? *(const vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >::iterator::pointer*) libp->para[0].ref : *(const vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >::iterator::pointer*) (void*) (&G__Mlong(libp->para[0])));
} else {
p = new((void*) gvp) vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >::iterator(libp->para[0].ref ? *(const vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >::iterator::pointer*) libp->para[0].ref : *(const vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >::iterator::pointer*) (void*) (&G__Mlong(libp->para[0])));
}
result7->obj.i = (long) p;
result7->ref = (long) p;
G__set_tagnum(result7,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_vectorlERootcLcLTLumiBlockRangecOallocatorlERootcLcLTLumiBlockRangegRsPgRcLcLiterator));
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_500_0_3(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
{
const vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >::iterator::reference obj = ((const vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >::iterator*) G__getstructoffset())->operator*();
result7->ref = (long) (&obj);
result7->obj.i = (long) (&obj);
}
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_500_0_4(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
G__letint(result7, 85, (long) ((const vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >::iterator*) G__getstructoffset())->operator->());
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_500_0_5(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
{
const vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >::iterator& obj = ((vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >::iterator*) G__getstructoffset())->operator++();
result7->ref = (long) (&obj);
result7->obj.i = (long) (&obj);
}
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_500_0_6(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
{
vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >::iterator* pobj;
vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >::iterator xobj = ((vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >::iterator*) G__getstructoffset())->operator++((int) G__int(libp->para[0]));
pobj = new vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >::iterator(xobj);
result7->obj.i = (long) ((void*) pobj);
result7->ref = result7->obj.i;
G__store_tempobject(*result7);
}
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_500_0_7(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
{
const vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >::iterator& obj = ((vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >::iterator*) G__getstructoffset())->operator--();
result7->ref = (long) (&obj);
result7->obj.i = (long) (&obj);
}
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_500_0_8(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
{
vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >::iterator* pobj;
vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >::iterator xobj = ((vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >::iterator*) G__getstructoffset())->operator--((int) G__int(libp->para[0]));
pobj = new vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >::iterator(xobj);
result7->obj.i = (long) ((void*) pobj);
result7->ref = result7->obj.i;
G__store_tempobject(*result7);
}
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_500_0_9(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
{
const vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >::iterator::reference obj = ((const vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >::iterator*) G__getstructoffset())->operator[](*(vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >::iterator::difference_type*) G__Longref(&libp->para[0]));
result7->ref = (long) (&obj);
result7->obj.i = (long) (&obj);
}
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_500_0_10(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
{
const vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >::iterator& obj = ((vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >::iterator*) G__getstructoffset())->operator+=(*(vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >::iterator::difference_type*) G__Longref(&libp->para[0]));
result7->ref = (long) (&obj);
result7->obj.i = (long) (&obj);
}
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_500_0_11(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
{
const vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >::iterator* pobj;
const vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >::iterator xobj = ((const vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >::iterator*) G__getstructoffset())->operator+(*(vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >::iterator::difference_type*) G__Longref(&libp->para[0]));
pobj = new vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >::iterator(xobj);
result7->obj.i = (long) ((void*) pobj);
result7->ref = result7->obj.i;
G__store_tempobject(*result7);
}
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_500_0_12(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
{
const vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >::iterator& obj = ((vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >::iterator*) G__getstructoffset())->operator-=(*(vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >::iterator::difference_type*) G__Longref(&libp->para[0]));
result7->ref = (long) (&obj);
result7->obj.i = (long) (&obj);
}
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_500_0_13(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
{
const vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >::iterator* pobj;
const vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >::iterator xobj = ((const vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >::iterator*) G__getstructoffset())->operator-(*(vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >::iterator::difference_type*) G__Longref(&libp->para[0]));
pobj = new vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >::iterator(xobj);
result7->obj.i = (long) ((void*) pobj);
result7->ref = result7->obj.i;
G__store_tempobject(*result7);
}
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_500_0_14(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
{
const vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >::iterator::pointer& obj = ((const vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >::iterator*) G__getstructoffset())->base();
result7->ref = (long) (&obj);
G__letint(result7, 'U', (long)obj);
}
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_500_0_15(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
{
vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >::iterator* pobj;
vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >::iterator xobj = ((vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >::iterator*) G__getstructoffset())->operator=(*(vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >::iterator*) libp->para[0].ref);
pobj = new vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >::iterator(xobj);
result7->obj.i = (long) ((void*) pobj);
result7->ref = result7->obj.i;
G__store_tempobject(*result7);
}
return(1 || funcname || hash || result7 || libp) ;
}
// automatic copy constructor
static int G__TGoodRunsListsCint_500_0_16(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >::iterator* p;
void* tmp = (void*) G__int(libp->para[0]);
p = new vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >::iterator(*(vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >::iterator*) tmp);
result7->obj.i = (long) p;
result7->ref = (long) p;
G__set_tagnum(result7,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_vectorlERootcLcLTLumiBlockRangecOallocatorlERootcLcLTLumiBlockRangegRsPgRcLcLiterator));
return(1 || funcname || hash || result7 || libp) ;
}
// automatic destructor
typedef vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >::iterator G__TvectorlERootcLcLTLumiBlockRangecOallocatorlERootcLcLTLumiBlockRangegRsPgRcLcLiterator;
static int G__TGoodRunsListsCint_500_0_17(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
char* gvp = (char*) G__getgvp();
long soff = G__getstructoffset();
int n = G__getaryconstruct();
//
//has_a_delete: 0
//has_own_delete1arg: 0
//has_own_delete2arg: 0
//
if (!soff) {
return(1);
}
if (n) {
if (gvp == (char*)G__PVOID) {
delete[] (vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >::iterator*) soff;
} else {
G__setgvp((long) G__PVOID);
for (int i = n - 1; i >= 0; --i) {
((vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >::iterator*) (soff+(sizeof(vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >::iterator)*i)))->~G__TvectorlERootcLcLTLumiBlockRangecOallocatorlERootcLcLTLumiBlockRangegRsPgRcLcLiterator();
}
G__setgvp((long)gvp);
}
} else {
if (gvp == (char*)G__PVOID) {
delete (vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >::iterator*) soff;
} else {
G__setgvp((long) G__PVOID);
((vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >::iterator*) (soff))->~G__TvectorlERootcLcLTLumiBlockRangecOallocatorlERootcLcLTLumiBlockRangegRsPgRcLcLiterator();
G__setgvp((long)gvp);
}
}
G__setnull(result7);
return(1 || funcname || hash || result7 || libp) ;
}
/* Root::TGoodRun */
static int G__TGoodRunsListsCint_502_0_1(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
Root::TGoodRun* p = NULL;
char* gvp = (char*) G__getgvp();
int n = G__getaryconstruct();
if (n) {
if ((gvp == (char*)G__PVOID) || (gvp == 0)) {
p = new Root::TGoodRun[n];
} else {
p = new((void*) gvp) Root::TGoodRun[n];
}
} else {
if ((gvp == (char*)G__PVOID) || (gvp == 0)) {
p = new Root::TGoodRun;
} else {
p = new((void*) gvp) Root::TGoodRun;
}
}
result7->obj.i = (long) p;
result7->ref = (long) p;
G__set_tagnum(result7,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_RootcLcLTGoodRun));
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_502_0_2(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
Root::TGoodRun* p = NULL;
char* gvp = (char*) G__getgvp();
//m: 1
if ((gvp == (char*)G__PVOID) || (gvp == 0)) {
p = new Root::TGoodRun(*(Int_t*) G__Intref(&libp->para[0]));
} else {
p = new((void*) gvp) Root::TGoodRun(*(Int_t*) G__Intref(&libp->para[0]));
}
result7->obj.i = (long) p;
result7->ref = (long) p;
G__set_tagnum(result7,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_RootcLcLTGoodRun));
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_502_0_3(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
Root::TGoodRun* p = NULL;
char* gvp = (char*) G__getgvp();
//m: 1
if ((gvp == (char*)G__PVOID) || (gvp == 0)) {
p = new Root::TGoodRun(*(Root::TGoodRun*) libp->para[0].ref);
} else {
p = new((void*) gvp) Root::TGoodRun(*(Root::TGoodRun*) libp->para[0].ref);
}
result7->obj.i = (long) p;
result7->ref = (long) p;
G__set_tagnum(result7,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_RootcLcLTGoodRun));
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_502_0_4(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
{
const Root::TGoodRun& obj = ((Root::TGoodRun*) G__getstructoffset())->operator=(*(Root::TGoodRun*) libp->para[0].ref);
result7->ref = (long) (&obj);
result7->obj.i = (long) (&obj);
}
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_502_0_5(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
{
const Root::TGoodRun* pobj;
const Root::TGoodRun xobj = ((const Root::TGoodRun*) G__getstructoffset())->GetOverlapWith(*(Root::TGoodRun*) libp->para[0].ref);
pobj = new Root::TGoodRun(xobj);
result7->obj.i = (long) ((void*) pobj);
result7->ref = result7->obj.i;
G__store_tempobject(*result7);
}
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_502_0_6(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
{
const Root::TGoodRun* pobj;
const Root::TGoodRun xobj = ((const Root::TGoodRun*) G__getstructoffset())->GetSumWith(*(Root::TGoodRun*) libp->para[0].ref);
pobj = new Root::TGoodRun(xobj);
result7->obj.i = (long) ((void*) pobj);
result7->ref = result7->obj.i;
G__store_tempobject(*result7);
}
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_502_0_7(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
{
const Root::TGoodRun* pobj;
const Root::TGoodRun xobj = ((const Root::TGoodRun*) G__getstructoffset())->GetPartOnlyIn(*(Root::TGoodRun*) libp->para[0].ref);
pobj = new Root::TGoodRun(xobj);
result7->obj.i = (long) ((void*) pobj);
result7->ref = result7->obj.i;
G__store_tempobject(*result7);
}
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_502_0_8(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
{
const Root::TGoodRun* pobj;
const Root::TGoodRun xobj = ((const Root::TGoodRun*) G__getstructoffset())->GetPartNotIn(*(Root::TGoodRun*) libp->para[0].ref);
pobj = new Root::TGoodRun(xobj);
result7->obj.i = (long) ((void*) pobj);
result7->ref = result7->obj.i;
G__store_tempobject(*result7);
}
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_502_0_9(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
G__letint(result7, 103, (long) ((const Root::TGoodRun*) G__getstructoffset())->IsEmpty());
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_502_0_10(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
G__letint(result7, 103, (long) ((const Root::TGoodRun*) G__getstructoffset())->HasLB(*(Int_t*) G__Intref(&libp->para[0])));
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_502_0_11(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
{
vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >::iterator* pobj;
vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >::iterator xobj = ((Root::TGoodRun*) G__getstructoffset())->Find(*(Int_t*) G__Intref(&libp->para[0]));
pobj = new vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >::iterator(xobj);
result7->obj.i = (long) ((void*) pobj);
result7->ref = result7->obj.i;
G__store_tempobject(*result7);
}
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_502_0_12(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
{
const vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >::const_iterator* pobj;
const vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >::const_iterator xobj = ((const Root::TGoodRun*) G__getstructoffset())->Find(*(Int_t*) G__Intref(&libp->para[0]));
pobj = new vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >::const_iterator(xobj);
result7->obj.i = (long) ((void*) pobj);
result7->ref = result7->obj.i;
G__store_tempobject(*result7);
}
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_502_0_13(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
G__letint(result7, 105, (long) ((const Root::TGoodRun*) G__getstructoffset())->GetRunNumber());
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_502_0_14(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
((Root::TGoodRun*) G__getstructoffset())->SetRunNumber(*(Int_t*) G__Intref(&libp->para[0]));
G__setnull(result7);
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_502_0_15(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
((const Root::TGoodRun*) G__getstructoffset())->Summary();
G__setnull(result7);
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_502_0_16(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
((Root::TGoodRun*) G__getstructoffset())->Sort();
G__setnull(result7);
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_502_0_17(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
((Root::TGoodRun*) G__getstructoffset())->Compress();
G__setnull(result7);
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_502_0_18(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
((Root::TGoodRun*) G__getstructoffset())->AddLB(*(Int_t*) G__Intref(&libp->para[0]));
G__setnull(result7);
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_502_0_19(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
G__letint(result7, 85, (long) Root::TGoodRun::Class());
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_502_0_20(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
G__letint(result7, 67, (long) Root::TGoodRun::Class_Name());
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_502_0_21(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
G__letint(result7, 115, (long) Root::TGoodRun::Class_Version());
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_502_0_22(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
Root::TGoodRun::Dictionary();
G__setnull(result7);
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_502_0_26(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
((Root::TGoodRun*) G__getstructoffset())->StreamerNVirtual(*(TBuffer*) libp->para[0].ref);
G__setnull(result7);
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_502_0_27(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
G__letint(result7, 67, (long) Root::TGoodRun::DeclFileName());
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_502_0_28(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
G__letint(result7, 105, (long) Root::TGoodRun::ImplFileLine());
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_502_0_29(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
G__letint(result7, 67, (long) Root::TGoodRun::ImplFileName());
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_502_0_30(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
G__letint(result7, 105, (long) Root::TGoodRun::DeclFileLine());
return(1 || funcname || hash || result7 || libp) ;
}
// automatic destructor
typedef Root::TGoodRun G__TRootcLcLTGoodRun;
static int G__TGoodRunsListsCint_502_0_31(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
char* gvp = (char*) G__getgvp();
long soff = G__getstructoffset();
int n = G__getaryconstruct();
//
//has_a_delete: 1
//has_own_delete1arg: 0
//has_own_delete2arg: 0
//
if (!soff) {
return(1);
}
if (n) {
if (gvp == (char*)G__PVOID) {
delete[] (Root::TGoodRun*) soff;
} else {
G__setgvp((long) G__PVOID);
for (int i = n - 1; i >= 0; --i) {
((Root::TGoodRun*) (soff+(sizeof(Root::TGoodRun)*i)))->~G__TRootcLcLTGoodRun();
}
G__setgvp((long)gvp);
}
} else {
if (gvp == (char*)G__PVOID) {
delete (Root::TGoodRun*) soff;
} else {
G__setgvp((long) G__PVOID);
((Root::TGoodRun*) (soff))->~G__TRootcLcLTGoodRun();
G__setgvp((long)gvp);
}
}
G__setnull(result7);
return(1 || funcname || hash || result7 || libp) ;
}
/* Root::TGoodRunsList */
static int G__TGoodRunsListsCint_504_0_1(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
Root::TGoodRunsList* p = NULL;
char* gvp = (char*) G__getgvp();
int n = G__getaryconstruct();
if (n) {
if ((gvp == (char*)G__PVOID) || (gvp == 0)) {
p = new Root::TGoodRunsList[n];
} else {
p = new((void*) gvp) Root::TGoodRunsList[n];
}
} else {
if ((gvp == (char*)G__PVOID) || (gvp == 0)) {
p = new Root::TGoodRunsList;
} else {
p = new((void*) gvp) Root::TGoodRunsList;
}
}
result7->obj.i = (long) p;
result7->ref = (long) p;
G__set_tagnum(result7,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_RootcLcLTGoodRunsList));
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_504_0_2(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
Root::TGoodRunsList* p = NULL;
char* gvp = (char*) G__getgvp();
//m: 1
if ((gvp == (char*)G__PVOID) || (gvp == 0)) {
p = new Root::TGoodRunsList((const char*) G__int(libp->para[0]));
} else {
p = new((void*) gvp) Root::TGoodRunsList((const char*) G__int(libp->para[0]));
}
result7->obj.i = (long) p;
result7->ref = (long) p;
G__set_tagnum(result7,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_RootcLcLTGoodRunsList));
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_504_0_3(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
Root::TGoodRunsList* p = NULL;
char* gvp = (char*) G__getgvp();
//m: 1
if ((gvp == (char*)G__PVOID) || (gvp == 0)) {
p = new Root::TGoodRunsList(*(Root::TGoodRunsList*) libp->para[0].ref);
} else {
p = new((void*) gvp) Root::TGoodRunsList(*(Root::TGoodRunsList*) libp->para[0].ref);
}
result7->obj.i = (long) p;
result7->ref = (long) p;
G__set_tagnum(result7,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_RootcLcLTGoodRunsList));
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_504_0_4(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
{
const Root::TGoodRunsList& obj = ((Root::TGoodRunsList*) G__getstructoffset())->operator=(*(Root::TGoodRunsList*) libp->para[0].ref);
result7->ref = (long) (&obj);
result7->obj.i = (long) (&obj);
}
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_504_0_5(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
((Root::TGoodRunsList*) G__getstructoffset())->AddGRL(*(Root::TGoodRunsList*) libp->para[0].ref);
G__setnull(result7);
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_504_0_6(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
{
const Root::TGoodRunsList* pobj;
const Root::TGoodRunsList xobj = ((const Root::TGoodRunsList*) G__getstructoffset())->GetOverlapWith(*(Root::TGoodRunsList*) libp->para[0].ref);
pobj = new Root::TGoodRunsList(xobj);
result7->obj.i = (long) ((void*) pobj);
result7->ref = result7->obj.i;
G__store_tempobject(*result7);
}
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_504_0_7(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
{
const Root::TGoodRunsList* pobj;
const Root::TGoodRunsList xobj = ((const Root::TGoodRunsList*) G__getstructoffset())->GetSumWith(*(Root::TGoodRunsList*) libp->para[0].ref);
pobj = new Root::TGoodRunsList(xobj);
result7->obj.i = (long) ((void*) pobj);
result7->ref = result7->obj.i;
G__store_tempobject(*result7);
}
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_504_0_8(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
{
const Root::TGoodRunsList* pobj;
const Root::TGoodRunsList xobj = ((const Root::TGoodRunsList*) G__getstructoffset())->GetPartOnlyIn(*(Root::TGoodRunsList*) libp->para[0].ref);
pobj = new Root::TGoodRunsList(xobj);
result7->obj.i = (long) ((void*) pobj);
result7->ref = result7->obj.i;
G__store_tempobject(*result7);
}
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_504_0_9(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
{
const Root::TGoodRunsList* pobj;
const Root::TGoodRunsList xobj = ((const Root::TGoodRunsList*) G__getstructoffset())->GetPartNotIn(*(Root::TGoodRunsList*) libp->para[0].ref);
pobj = new Root::TGoodRunsList(xobj);
result7->obj.i = (long) ((void*) pobj);
result7->ref = result7->obj.i;
G__store_tempobject(*result7);
}
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_504_0_10(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
G__letint(result7, 103, (long) ((const Root::TGoodRunsList*) G__getstructoffset())->HasTriggerInfo());
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_504_0_11(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
G__letint(result7, 103, (long) ((const Root::TGoodRunsList*) G__getstructoffset())->HasRun(*(Int_t*) G__Intref(&libp->para[0])));
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_504_0_12(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
G__letint(result7, 103, (long) ((const Root::TGoodRunsList*) G__getstructoffset())->HasRunLumiBlock(*(Int_t*) G__Intref(&libp->para[0]), *(Int_t*) G__Intref(&libp->para[1])));
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_504_0_13(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
G__letint(result7, 103, (long) ((const Root::TGoodRunsList*) G__getstructoffset())->HasSameGRLInfo(*(Root::TGoodRunsList*) libp->para[0].ref));
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_504_0_14(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
switch (libp->paran) {
case 2:
G__letint(result7, 103, (long) ((const Root::TGoodRunsList*) G__getstructoffset())->HasOverlapWith(*(Root::TGoodRunsList*) libp->para[0].ref, (bool) G__int(libp->para[1])));
break;
case 1:
G__letint(result7, 103, (long) ((const Root::TGoodRunsList*) G__getstructoffset())->HasOverlapWith(*(Root::TGoodRunsList*) libp->para[0].ref));
break;
}
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_504_0_15(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
((Root::TGoodRunsList*) G__getstructoffset())->AddRunLumiBlock(*(Int_t*) G__Intref(&libp->para[0]), *(Int_t*) G__Intref(&libp->para[1]));
G__setnull(result7);
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_504_0_16(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
((Root::TGoodRunsList*) G__getstructoffset())->SetVersion(*(TString*) libp->para[0].ref);
G__setnull(result7);
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_504_0_17(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
((Root::TGoodRunsList*) G__getstructoffset())->AddMetaData(*(TString*) libp->para[0].ref, *(TString*) libp->para[1].ref);
G__setnull(result7);
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_504_0_18(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
((Root::TGoodRunsList*) G__getstructoffset())->SetMetaData(*(map<TString,TString>*) libp->para[0].ref);
G__setnull(result7);
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_504_0_19(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
switch (libp->paran) {
case 1:
((Root::TGoodRunsList*) G__getstructoffset())->SetCheckGRLInfo((Bool_t) G__int(libp->para[0]));
G__setnull(result7);
break;
case 0:
((Root::TGoodRunsList*) G__getstructoffset())->SetCheckGRLInfo();
G__setnull(result7);
break;
}
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_504_0_20(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
{
const Bool_t& obj = ((const Root::TGoodRunsList*) G__getstructoffset())->GetCheckGRLInfo();
result7->ref = (long) (&obj);
G__letint(result7, 'g', (long)obj);
}
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_504_0_21(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
{
const TString& obj = ((const Root::TGoodRunsList*) G__getstructoffset())->GetVersion();
result7->ref = (long) (&obj);
result7->obj.i = (long) (&obj);
}
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_504_0_22(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
{
const map<TString,TString>& obj = ((const Root::TGoodRunsList*) G__getstructoffset())->GetMetaData();
result7->ref = (long) (&obj);
result7->obj.i = (long) (&obj);
}
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_504_0_23(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
G__letint(result7, 104, (long) ((const Root::TGoodRunsList*) G__getstructoffset())->GetMetaDataSize());
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_504_0_24(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
switch (libp->paran) {
case 1:
((const Root::TGoodRunsList*) G__getstructoffset())->Summary((Bool_t) G__int(libp->para[0]));
G__setnull(result7);
break;
case 0:
((const Root::TGoodRunsList*) G__getstructoffset())->Summary();
G__setnull(result7);
break;
}
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_504_0_25(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
G__letint(result7, 103, (long) ((const Root::TGoodRunsList*) G__getstructoffset())->IsEmpty());
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_504_0_26(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
{
const vector<int>* pobj;
const vector<int> xobj = ((const Root::TGoodRunsList*) G__getstructoffset())->GetRunlist();
pobj = new vector<int>(xobj);
result7->obj.i = (long) ((void*) pobj);
result7->ref = result7->obj.i;
G__store_tempobject(*result7);
}
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_504_0_27(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
{
const vector<Root::TGoodRun>* pobj;
const vector<Root::TGoodRun> xobj = ((const Root::TGoodRunsList*) G__getstructoffset())->GetGoodRuns();
pobj = new vector<Root::TGoodRun>(xobj);
result7->obj.i = (long) ((void*) pobj);
result7->ref = result7->obj.i;
G__store_tempobject(*result7);
}
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_504_0_28(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
{
const vector<std::string>* pobj;
const vector<std::string> xobj = ((const Root::TGoodRunsList*) G__getstructoffset())->GetTriggerList();
pobj = new vector<std::string>(xobj);
result7->obj.i = (long) ((void*) pobj);
result7->ref = result7->obj.i;
G__store_tempobject(*result7);
}
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_504_0_29(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
{
const vector<std::string>* pobj;
const vector<std::string> xobj = ((const Root::TGoodRunsList*) G__getstructoffset())->GetStreamList();
pobj = new vector<std::string>(xobj);
result7->obj.i = (long) ((void*) pobj);
result7->ref = result7->obj.i;
G__store_tempobject(*result7);
}
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_504_0_30(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
{
const TString* pobj;
const TString xobj = ((const Root::TGoodRunsList*) G__getstructoffset())->GetSuggestedName();
pobj = new TString(xobj);
result7->obj.i = (long) ((void*) pobj);
result7->ref = result7->obj.i;
G__store_tempobject(*result7);
}
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_504_0_31(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
((Root::TGoodRunsList*) G__getstructoffset())->Compress();
G__setnull(result7);
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_504_0_32(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
G__letint(result7, 85, (long) Root::TGoodRunsList::Class());
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_504_0_33(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
G__letint(result7, 67, (long) Root::TGoodRunsList::Class_Name());
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_504_0_34(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
G__letint(result7, 115, (long) Root::TGoodRunsList::Class_Version());
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_504_0_35(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
Root::TGoodRunsList::Dictionary();
G__setnull(result7);
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_504_0_39(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
((Root::TGoodRunsList*) G__getstructoffset())->StreamerNVirtual(*(TBuffer*) libp->para[0].ref);
G__setnull(result7);
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_504_0_40(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
G__letint(result7, 67, (long) Root::TGoodRunsList::DeclFileName());
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_504_0_41(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
G__letint(result7, 105, (long) Root::TGoodRunsList::ImplFileLine());
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_504_0_42(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
G__letint(result7, 67, (long) Root::TGoodRunsList::ImplFileName());
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_504_0_43(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
G__letint(result7, 105, (long) Root::TGoodRunsList::DeclFileLine());
return(1 || funcname || hash || result7 || libp) ;
}
// automatic destructor
typedef Root::TGoodRunsList G__TRootcLcLTGoodRunsList;
static int G__TGoodRunsListsCint_504_0_44(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
char* gvp = (char*) G__getgvp();
long soff = G__getstructoffset();
int n = G__getaryconstruct();
//
//has_a_delete: 1
//has_own_delete1arg: 0
//has_own_delete2arg: 0
//
if (!soff) {
return(1);
}
if (n) {
if (gvp == (char*)G__PVOID) {
delete[] (Root::TGoodRunsList*) soff;
} else {
G__setgvp((long) G__PVOID);
for (int i = n - 1; i >= 0; --i) {
((Root::TGoodRunsList*) (soff+(sizeof(Root::TGoodRunsList)*i)))->~G__TRootcLcLTGoodRunsList();
}
G__setgvp((long)gvp);
}
} else {
if (gvp == (char*)G__PVOID) {
delete (Root::TGoodRunsList*) soff;
} else {
G__setgvp((long) G__PVOID);
((Root::TGoodRunsList*) (soff))->~G__TRootcLcLTGoodRunsList();
G__setgvp((long)gvp);
}
}
G__setnull(result7);
return(1 || funcname || hash || result7 || libp) ;
}
/* map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > > */
static int G__TGoodRunsListsCint_507_0_1(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > >* p = NULL;
char* gvp = (char*) G__getgvp();
int n = G__getaryconstruct();
if (n) {
if ((gvp == (char*)G__PVOID) || (gvp == 0)) {
p = new map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > >[n];
} else {
p = new((void*) gvp) map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > >[n];
}
} else {
if ((gvp == (char*)G__PVOID) || (gvp == 0)) {
p = new map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > >;
} else {
p = new((void*) gvp) map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > >;
}
}
result7->obj.i = (long) p;
result7->ref = (long) p;
G__set_tagnum(result7,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_maplEintcORootcLcLTGoodRuncOlesslEintgRcOallocatorlEpairlEconstsPintcORootcLcLTGoodRungRsPgRsPgR));
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_507_0_2(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > >* p = NULL;
char* gvp = (char*) G__getgvp();
//m: 2
if ((gvp == (char*)G__PVOID) || (gvp == 0)) {
p = new map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > >(*((map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > >::iterator*) G__int(libp->para[0])), *((map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > >::iterator*) G__int(libp->para[1])));
} else {
p = new((void*) gvp) map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > >(*((map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > >::iterator*) G__int(libp->para[0])), *((map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > >::iterator*) G__int(libp->para[1])));
}
result7->obj.i = (long) p;
result7->ref = (long) p;
G__set_tagnum(result7,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_maplEintcORootcLcLTGoodRuncOlesslEintgRcOallocatorlEpairlEconstsPintcORootcLcLTGoodRungRsPgRsPgR));
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_507_0_3(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > >* p = NULL;
char* gvp = (char*) G__getgvp();
//m: 2
if ((gvp == (char*)G__PVOID) || (gvp == 0)) {
p = new map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > >(*((map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > >::reverse_iterator*) G__int(libp->para[0])), *((map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > >::reverse_iterator*) G__int(libp->para[1])));
} else {
p = new((void*) gvp) map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > >(*((map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > >::reverse_iterator*) G__int(libp->para[0])), *((map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > >::reverse_iterator*) G__int(libp->para[1])));
}
result7->obj.i = (long) p;
result7->ref = (long) p;
G__set_tagnum(result7,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_maplEintcORootcLcLTGoodRuncOlesslEintgRcOallocatorlEpairlEconstsPintcORootcLcLTGoodRungRsPgRsPgR));
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_507_0_4(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > >* p = NULL;
char* gvp = (char*) G__getgvp();
//m: 1
if ((gvp == (char*)G__PVOID) || (gvp == 0)) {
p = new map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > >(*(map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > >*) libp->para[0].ref);
} else {
p = new((void*) gvp) map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > >(*(map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > >*) libp->para[0].ref);
}
result7->obj.i = (long) p;
result7->ref = (long) p;
G__set_tagnum(result7,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_maplEintcORootcLcLTGoodRuncOlesslEintgRcOallocatorlEpairlEconstsPintcORootcLcLTGoodRungRsPgRsPgR));
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_507_0_5(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
{
const map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > >& obj = ((map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > >*) G__getstructoffset())->operator=(*(map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > >*) libp->para[0].ref);
result7->ref = (long) (&obj);
result7->obj.i = (long) (&obj);
}
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_507_0_6(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
{
map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > >::iterator* pobj;
map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > >::iterator xobj = ((map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > >*) G__getstructoffset())->begin();
pobj = new map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > >::iterator(xobj);
result7->obj.i = (long) ((void*) pobj);
result7->ref = result7->obj.i;
G__store_tempobject(*result7);
}
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_507_0_7(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
{
map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > >::iterator* pobj;
map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > >::iterator xobj = ((map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > >*) G__getstructoffset())->end();
pobj = new map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > >::iterator(xobj);
result7->obj.i = (long) ((void*) pobj);
result7->ref = result7->obj.i;
G__store_tempobject(*result7);
}
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_507_0_8(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
{
map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > >::reverse_iterator* pobj;
map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > >::reverse_iterator xobj = ((map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > >*) G__getstructoffset())->rbegin();
pobj = new map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > >::reverse_iterator(xobj);
result7->obj.i = (long) ((void*) pobj);
result7->ref = result7->obj.i;
G__store_tempobject(*result7);
}
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_507_0_9(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
{
map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > >::reverse_iterator* pobj;
map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > >::reverse_iterator xobj = ((map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > >*) G__getstructoffset())->rend();
pobj = new map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > >::reverse_iterator(xobj);
result7->obj.i = (long) ((void*) pobj);
result7->ref = result7->obj.i;
G__store_tempobject(*result7);
}
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_507_0_10(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
G__letint(result7, 103, (long) ((const map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > >*) G__getstructoffset())->empty());
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_507_0_11(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
G__letint(result7, 104, (long) ((const map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > >*) G__getstructoffset())->size());
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_507_0_12(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
G__letint(result7, 104, (long) ((const map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > >*) G__getstructoffset())->max_size());
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_507_0_13(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
{
const Root::TGoodRun& obj = ((map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > >*) G__getstructoffset())->operator[](*(int*) G__Intref(&libp->para[0]));
result7->ref = (long) (&obj);
result7->obj.i = (long) (&obj);
}
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_507_0_14(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
{
pair<map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > >::iterator,bool>* pobj;
pair<map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > >::iterator,bool> xobj = ((map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > >*) G__getstructoffset())->insert(*(map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > >::value_type*) libp->para[0].ref);
pobj = new pair<map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > >::iterator,bool>(xobj);
result7->obj.i = (long) ((void*) pobj);
result7->ref = result7->obj.i;
G__store_tempobject(*result7);
}
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_507_0_15(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
{
map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > >::iterator* pobj;
map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > >::iterator xobj = ((map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > >*) G__getstructoffset())->insert(*((map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > >::iterator*) G__int(libp->para[0])), *(map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > >::value_type*) libp->para[1].ref);
pobj = new map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > >::iterator(xobj);
result7->obj.i = (long) ((void*) pobj);
result7->ref = result7->obj.i;
G__store_tempobject(*result7);
}
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_507_0_16(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
((map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > >*) G__getstructoffset())->insert(*((map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > >::iterator*) G__int(libp->para[0])), *((map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > >::iterator*) G__int(libp->para[1])));
G__setnull(result7);
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_507_0_17(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
((map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > >*) G__getstructoffset())->insert(*((map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > >::reverse_iterator*) G__int(libp->para[0])), *((map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > >::reverse_iterator*) G__int(libp->para[1])));
G__setnull(result7);
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_507_0_18(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
((map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > >*) G__getstructoffset())->erase(*((map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > >::iterator*) G__int(libp->para[0])));
G__setnull(result7);
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_507_0_19(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
G__letint(result7, 104, (long) ((map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > >*) G__getstructoffset())->erase(*(int*) G__Intref(&libp->para[0])));
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_507_0_20(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
((map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > >*) G__getstructoffset())->erase(*((map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > >::iterator*) G__int(libp->para[0])), *((map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > >::iterator*) G__int(libp->para[1])));
G__setnull(result7);
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_507_0_21(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
((map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > >*) G__getstructoffset())->swap(*(map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > >*) libp->para[0].ref);
G__setnull(result7);
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_507_0_22(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
((map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > >*) G__getstructoffset())->clear();
G__setnull(result7);
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_507_0_23(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
{
map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > >::iterator* pobj;
map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > >::iterator xobj = ((map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > >*) G__getstructoffset())->find(*(int*) G__Intref(&libp->para[0]));
pobj = new map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > >::iterator(xobj);
result7->obj.i = (long) ((void*) pobj);
result7->ref = result7->obj.i;
G__store_tempobject(*result7);
}
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_507_0_24(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
G__letint(result7, 104, (long) ((const map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > >*) G__getstructoffset())->count(*(int*) G__Intref(&libp->para[0])));
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_507_0_25(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
{
map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > >::iterator* pobj;
map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > >::iterator xobj = ((map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > >*) G__getstructoffset())->lower_bound(*(int*) G__Intref(&libp->para[0]));
pobj = new map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > >::iterator(xobj);
result7->obj.i = (long) ((void*) pobj);
result7->ref = result7->obj.i;
G__store_tempobject(*result7);
}
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_507_0_26(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
{
map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > >::iterator* pobj;
map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > >::iterator xobj = ((map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > >*) G__getstructoffset())->upper_bound(*(int*) G__Intref(&libp->para[0]));
pobj = new map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > >::iterator(xobj);
result7->obj.i = (long) ((void*) pobj);
result7->ref = result7->obj.i;
G__store_tempobject(*result7);
}
return(1 || funcname || hash || result7 || libp) ;
}
// automatic destructor
typedef map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > > G__TmaplEintcORootcLcLTGoodRuncOlesslEintgRcOallocatorlEpairlEconstsPintcORootcLcLTGoodRungRsPgRsPgR;
static int G__TGoodRunsListsCint_507_0_27(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
char* gvp = (char*) G__getgvp();
long soff = G__getstructoffset();
int n = G__getaryconstruct();
//
//has_a_delete: 0
//has_own_delete1arg: 0
//has_own_delete2arg: 0
//
if (!soff) {
return(1);
}
if (n) {
if (gvp == (char*)G__PVOID) {
delete[] (map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > >*) soff;
} else {
G__setgvp((long) G__PVOID);
for (int i = n - 1; i >= 0; --i) {
((map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > >*) (soff+(sizeof(map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > >)*i)))->~G__TmaplEintcORootcLcLTGoodRuncOlesslEintgRcOallocatorlEpairlEconstsPintcORootcLcLTGoodRungRsPgRsPgR();
}
G__setgvp((long)gvp);
}
} else {
if (gvp == (char*)G__PVOID) {
delete (map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > >*) soff;
} else {
G__setgvp((long) G__PVOID);
((map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > >*) (soff))->~G__TmaplEintcORootcLcLTGoodRuncOlesslEintgRcOallocatorlEpairlEconstsPintcORootcLcLTGoodRungRsPgRsPgR();
G__setgvp((long)gvp);
}
}
G__setnull(result7);
return(1 || funcname || hash || result7 || libp) ;
}
/* pair<int,Root::TGoodRun> */
static int G__TGoodRunsListsCint_508_0_1(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
pair<int,Root::TGoodRun>* p = NULL;
char* gvp = (char*) G__getgvp();
int n = G__getaryconstruct();
if (n) {
if ((gvp == (char*)G__PVOID) || (gvp == 0)) {
p = new pair<int,Root::TGoodRun>[n];
} else {
p = new((void*) gvp) pair<int,Root::TGoodRun>[n];
}
} else {
if ((gvp == (char*)G__PVOID) || (gvp == 0)) {
p = new pair<int,Root::TGoodRun>;
} else {
p = new((void*) gvp) pair<int,Root::TGoodRun>;
}
}
result7->obj.i = (long) p;
result7->ref = (long) p;
G__set_tagnum(result7,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_pairlEintcORootcLcLTGoodRungR));
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_508_0_2(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
pair<int,Root::TGoodRun>* p = NULL;
char* gvp = (char*) G__getgvp();
//m: 2
if ((gvp == (char*)G__PVOID) || (gvp == 0)) {
p = new pair<int,Root::TGoodRun>(*(int*) G__Intref(&libp->para[0]), *(Root::TGoodRun*) libp->para[1].ref);
} else {
p = new((void*) gvp) pair<int,Root::TGoodRun>(*(int*) G__Intref(&libp->para[0]), *(Root::TGoodRun*) libp->para[1].ref);
}
result7->obj.i = (long) p;
result7->ref = (long) p;
G__set_tagnum(result7,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_pairlEintcORootcLcLTGoodRungR));
return(1 || funcname || hash || result7 || libp) ;
}
// automatic copy constructor
static int G__TGoodRunsListsCint_508_0_4(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
pair<int,Root::TGoodRun>* p;
void* tmp = (void*) G__int(libp->para[0]);
p = new pair<int,Root::TGoodRun>(*(pair<int,Root::TGoodRun>*) tmp);
result7->obj.i = (long) p;
result7->ref = (long) p;
G__set_tagnum(result7,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_pairlEintcORootcLcLTGoodRungR));
return(1 || funcname || hash || result7 || libp) ;
}
// automatic destructor
typedef pair<int,Root::TGoodRun> G__TpairlEintcORootcLcLTGoodRungR;
static int G__TGoodRunsListsCint_508_0_5(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
char* gvp = (char*) G__getgvp();
long soff = G__getstructoffset();
int n = G__getaryconstruct();
//
//has_a_delete: 0
//has_own_delete1arg: 0
//has_own_delete2arg: 0
//
if (!soff) {
return(1);
}
if (n) {
if (gvp == (char*)G__PVOID) {
delete[] (pair<int,Root::TGoodRun>*) soff;
} else {
G__setgvp((long) G__PVOID);
for (int i = n - 1; i >= 0; --i) {
((pair<int,Root::TGoodRun>*) (soff+(sizeof(pair<int,Root::TGoodRun>)*i)))->~G__TpairlEintcORootcLcLTGoodRungR();
}
G__setgvp((long)gvp);
}
} else {
if (gvp == (char*)G__PVOID) {
delete (pair<int,Root::TGoodRun>*) soff;
} else {
G__setgvp((long) G__PVOID);
((pair<int,Root::TGoodRun>*) (soff))->~G__TpairlEintcORootcLcLTGoodRungR();
G__setgvp((long)gvp);
}
}
G__setnull(result7);
return(1 || funcname || hash || result7 || libp) ;
}
/* map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > >::iterator */
static int G__TGoodRunsListsCint_509_0_1(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > >::iterator* p = NULL;
char* gvp = (char*) G__getgvp();
int n = G__getaryconstruct();
if (n) {
if ((gvp == (char*)G__PVOID) || (gvp == 0)) {
p = new map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > >::iterator[n];
} else {
p = new((void*) gvp) map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > >::iterator[n];
}
} else {
if ((gvp == (char*)G__PVOID) || (gvp == 0)) {
p = new map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > >::iterator;
} else {
p = new((void*) gvp) map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > >::iterator;
}
}
result7->obj.i = (long) p;
result7->ref = (long) p;
G__set_tagnum(result7,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_maplEintcORootcLcLTGoodRuncOlesslEintgRcOallocatorlEpairlEconstsPintcORootcLcLTGoodRungRsPgRsPgRcLcLiterator));
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_509_0_2(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > >::iterator* p = NULL;
char* gvp = (char*) G__getgvp();
//m: 1
if ((gvp == (char*)G__PVOID) || (gvp == 0)) {
p = new map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > >::iterator(*(map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > >::iterator*) libp->para[0].ref);
} else {
p = new((void*) gvp) map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > >::iterator(*(map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > >::iterator*) libp->para[0].ref);
}
result7->obj.i = (long) p;
result7->ref = (long) p;
G__set_tagnum(result7,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_maplEintcORootcLcLTGoodRuncOlesslEintgRcOallocatorlEpairlEconstsPintcORootcLcLTGoodRungRsPgRsPgRcLcLiterator));
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_509_0_3(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
{
const map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > >::iterator& obj = ((map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > >::iterator*) G__getstructoffset())->operator=(*(map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > >::iterator*) libp->para[0].ref);
result7->ref = (long) (&obj);
result7->obj.i = (long) (&obj);
}
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_509_0_4(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
{
const map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > >::value_type& obj = ((map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > >::iterator*) G__getstructoffset())->operator*();
result7->ref = (long) (&obj);
result7->obj.i = (long) (&obj);
}
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_509_0_5(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
G__letint(result7, 85, (long) ((map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > >::iterator*) G__getstructoffset())->operator->());
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_509_0_6(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
{
const map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > >::iterator& obj = ((map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > >::iterator*) G__getstructoffset())->operator++();
result7->ref = (long) (&obj);
result7->obj.i = (long) (&obj);
}
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_509_0_7(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
{
map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > >::iterator* pobj;
map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > >::iterator xobj = ((map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > >::iterator*) G__getstructoffset())->operator++((int) G__int(libp->para[0]));
pobj = new map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > >::iterator(xobj);
result7->obj.i = (long) ((void*) pobj);
result7->ref = result7->obj.i;
G__store_tempobject(*result7);
}
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_509_0_8(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
{
const map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > >::iterator& obj = ((map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > >::iterator*) G__getstructoffset())->operator--();
result7->ref = (long) (&obj);
result7->obj.i = (long) (&obj);
}
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_509_0_9(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
{
map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > >::iterator* pobj;
map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > >::iterator xobj = ((map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > >::iterator*) G__getstructoffset())->operator--((int) G__int(libp->para[0]));
pobj = new map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > >::iterator(xobj);
result7->obj.i = (long) ((void*) pobj);
result7->ref = result7->obj.i;
G__store_tempobject(*result7);
}
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_509_0_10(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
G__letint(result7, 103, (long) ((map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > >::iterator*) G__getstructoffset())->operator==(*(map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > >::iterator*) libp->para[0].ref));
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_509_0_11(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
G__letint(result7, 103, (long) ((map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > >::iterator*) G__getstructoffset())->operator!=(*(map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > >::iterator*) libp->para[0].ref));
return(1 || funcname || hash || result7 || libp) ;
}
// automatic destructor
typedef map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > >::iterator G__TmaplEintcORootcLcLTGoodRuncOlesslEintgRcOallocatorlEpairlEconstsPintcORootcLcLTGoodRungRsPgRsPgRcLcLiterator;
static int G__TGoodRunsListsCint_509_0_12(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
char* gvp = (char*) G__getgvp();
long soff = G__getstructoffset();
int n = G__getaryconstruct();
//
//has_a_delete: 0
//has_own_delete1arg: 0
//has_own_delete2arg: 0
//
if (!soff) {
return(1);
}
if (n) {
if (gvp == (char*)G__PVOID) {
delete[] (map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > >::iterator*) soff;
} else {
G__setgvp((long) G__PVOID);
for (int i = n - 1; i >= 0; --i) {
((map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > >::iterator*) (soff+(sizeof(map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > >::iterator)*i)))->~G__TmaplEintcORootcLcLTGoodRuncOlesslEintgRcOallocatorlEpairlEconstsPintcORootcLcLTGoodRungRsPgRsPgRcLcLiterator();
}
G__setgvp((long)gvp);
}
} else {
if (gvp == (char*)G__PVOID) {
delete (map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > >::iterator*) soff;
} else {
G__setgvp((long) G__PVOID);
((map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > >::iterator*) (soff))->~G__TmaplEintcORootcLcLTGoodRuncOlesslEintgRcOallocatorlEpairlEconstsPintcORootcLcLTGoodRungRsPgRsPgRcLcLiterator();
G__setgvp((long)gvp);
}
}
G__setnull(result7);
return(1 || funcname || hash || result7 || libp) ;
}
/* map<TString,TString,less<TString>,allocator<pair<const TString,TString> > > */
static int G__TGoodRunsListsCint_516_0_1(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
map<TString,TString,less<TString>,allocator<pair<const TString,TString> > >* p = NULL;
char* gvp = (char*) G__getgvp();
int n = G__getaryconstruct();
if (n) {
if ((gvp == (char*)G__PVOID) || (gvp == 0)) {
p = new map<TString,TString,less<TString>,allocator<pair<const TString,TString> > >[n];
} else {
p = new((void*) gvp) map<TString,TString,less<TString>,allocator<pair<const TString,TString> > >[n];
}
} else {
if ((gvp == (char*)G__PVOID) || (gvp == 0)) {
p = new map<TString,TString,less<TString>,allocator<pair<const TString,TString> > >;
} else {
p = new((void*) gvp) map<TString,TString,less<TString>,allocator<pair<const TString,TString> > >;
}
}
result7->obj.i = (long) p;
result7->ref = (long) p;
G__set_tagnum(result7,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_maplETStringcOTStringcOlesslETStringgRcOallocatorlEpairlEconstsPTStringcOTStringgRsPgRsPgR));
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_516_0_2(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
map<TString,TString,less<TString>,allocator<pair<const TString,TString> > >* p = NULL;
char* gvp = (char*) G__getgvp();
//m: 2
if ((gvp == (char*)G__PVOID) || (gvp == 0)) {
p = new map<TString,TString,less<TString>,allocator<pair<const TString,TString> > >(*((map<TString,TString,less<TString>,allocator<pair<const TString,TString> > >::iterator*) G__int(libp->para[0])), *((map<TString,TString,less<TString>,allocator<pair<const TString,TString> > >::iterator*) G__int(libp->para[1])));
} else {
p = new((void*) gvp) map<TString,TString,less<TString>,allocator<pair<const TString,TString> > >(*((map<TString,TString,less<TString>,allocator<pair<const TString,TString> > >::iterator*) G__int(libp->para[0])), *((map<TString,TString,less<TString>,allocator<pair<const TString,TString> > >::iterator*) G__int(libp->para[1])));
}
result7->obj.i = (long) p;
result7->ref = (long) p;
G__set_tagnum(result7,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_maplETStringcOTStringcOlesslETStringgRcOallocatorlEpairlEconstsPTStringcOTStringgRsPgRsPgR));
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_516_0_3(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
map<TString,TString,less<TString>,allocator<pair<const TString,TString> > >* p = NULL;
char* gvp = (char*) G__getgvp();
//m: 2
if ((gvp == (char*)G__PVOID) || (gvp == 0)) {
p = new map<TString,TString,less<TString>,allocator<pair<const TString,TString> > >(*((map<TString,TString,less<TString>,allocator<pair<const TString,TString> > >::reverse_iterator*) G__int(libp->para[0])), *((map<TString,TString,less<TString>,allocator<pair<const TString,TString> > >::reverse_iterator*) G__int(libp->para[1])));
} else {
p = new((void*) gvp) map<TString,TString,less<TString>,allocator<pair<const TString,TString> > >(*((map<TString,TString,less<TString>,allocator<pair<const TString,TString> > >::reverse_iterator*) G__int(libp->para[0])), *((map<TString,TString,less<TString>,allocator<pair<const TString,TString> > >::reverse_iterator*) G__int(libp->para[1])));
}
result7->obj.i = (long) p;
result7->ref = (long) p;
G__set_tagnum(result7,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_maplETStringcOTStringcOlesslETStringgRcOallocatorlEpairlEconstsPTStringcOTStringgRsPgRsPgR));
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_516_0_4(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
map<TString,TString,less<TString>,allocator<pair<const TString,TString> > >* p = NULL;
char* gvp = (char*) G__getgvp();
//m: 1
if ((gvp == (char*)G__PVOID) || (gvp == 0)) {
p = new map<TString,TString,less<TString>,allocator<pair<const TString,TString> > >(*(map<TString,TString,less<TString>,allocator<pair<const TString,TString> > >*) libp->para[0].ref);
} else {
p = new((void*) gvp) map<TString,TString,less<TString>,allocator<pair<const TString,TString> > >(*(map<TString,TString,less<TString>,allocator<pair<const TString,TString> > >*) libp->para[0].ref);
}
result7->obj.i = (long) p;
result7->ref = (long) p;
G__set_tagnum(result7,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_maplETStringcOTStringcOlesslETStringgRcOallocatorlEpairlEconstsPTStringcOTStringgRsPgRsPgR));
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_516_0_5(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
{
const map<TString,TString,less<TString>,allocator<pair<const TString,TString> > >& obj = ((map<TString,TString,less<TString>,allocator<pair<const TString,TString> > >*) G__getstructoffset())->operator=(*(map<TString,TString,less<TString>,allocator<pair<const TString,TString> > >*) libp->para[0].ref);
result7->ref = (long) (&obj);
result7->obj.i = (long) (&obj);
}
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_516_0_6(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
{
map<TString,TString,less<TString>,allocator<pair<const TString,TString> > >::iterator* pobj;
map<TString,TString,less<TString>,allocator<pair<const TString,TString> > >::iterator xobj = ((map<TString,TString,less<TString>,allocator<pair<const TString,TString> > >*) G__getstructoffset())->begin();
pobj = new map<TString,TString,less<TString>,allocator<pair<const TString,TString> > >::iterator(xobj);
result7->obj.i = (long) ((void*) pobj);
result7->ref = result7->obj.i;
G__store_tempobject(*result7);
}
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_516_0_7(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
{
map<TString,TString,less<TString>,allocator<pair<const TString,TString> > >::iterator* pobj;
map<TString,TString,less<TString>,allocator<pair<const TString,TString> > >::iterator xobj = ((map<TString,TString,less<TString>,allocator<pair<const TString,TString> > >*) G__getstructoffset())->end();
pobj = new map<TString,TString,less<TString>,allocator<pair<const TString,TString> > >::iterator(xobj);
result7->obj.i = (long) ((void*) pobj);
result7->ref = result7->obj.i;
G__store_tempobject(*result7);
}
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_516_0_8(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
{
map<TString,TString,less<TString>,allocator<pair<const TString,TString> > >::reverse_iterator* pobj;
map<TString,TString,less<TString>,allocator<pair<const TString,TString> > >::reverse_iterator xobj = ((map<TString,TString,less<TString>,allocator<pair<const TString,TString> > >*) G__getstructoffset())->rbegin();
pobj = new map<TString,TString,less<TString>,allocator<pair<const TString,TString> > >::reverse_iterator(xobj);
result7->obj.i = (long) ((void*) pobj);
result7->ref = result7->obj.i;
G__store_tempobject(*result7);
}
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_516_0_9(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
{
map<TString,TString,less<TString>,allocator<pair<const TString,TString> > >::reverse_iterator* pobj;
map<TString,TString,less<TString>,allocator<pair<const TString,TString> > >::reverse_iterator xobj = ((map<TString,TString,less<TString>,allocator<pair<const TString,TString> > >*) G__getstructoffset())->rend();
pobj = new map<TString,TString,less<TString>,allocator<pair<const TString,TString> > >::reverse_iterator(xobj);
result7->obj.i = (long) ((void*) pobj);
result7->ref = result7->obj.i;
G__store_tempobject(*result7);
}
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_516_0_10(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
G__letint(result7, 103, (long) ((const map<TString,TString,less<TString>,allocator<pair<const TString,TString> > >*) G__getstructoffset())->empty());
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_516_0_11(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
G__letint(result7, 104, (long) ((const map<TString,TString,less<TString>,allocator<pair<const TString,TString> > >*) G__getstructoffset())->size());
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_516_0_12(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
G__letint(result7, 104, (long) ((const map<TString,TString,less<TString>,allocator<pair<const TString,TString> > >*) G__getstructoffset())->max_size());
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_516_0_13(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
{
const TString& obj = ((map<TString,TString,less<TString>,allocator<pair<const TString,TString> > >*) G__getstructoffset())->operator[](*(TString*) libp->para[0].ref);
result7->ref = (long) (&obj);
result7->obj.i = (long) (&obj);
}
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_516_0_14(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
{
pair<map<TString,TString,less<TString>,allocator<pair<const TString,TString> > >::iterator,bool>* pobj;
pair<map<TString,TString,less<TString>,allocator<pair<const TString,TString> > >::iterator,bool> xobj = ((map<TString,TString,less<TString>,allocator<pair<const TString,TString> > >*) G__getstructoffset())->insert(*(map<TString,TString,less<TString>,allocator<pair<const TString,TString> > >::value_type*) libp->para[0].ref);
pobj = new pair<map<TString,TString,less<TString>,allocator<pair<const TString,TString> > >::iterator,bool>(xobj);
result7->obj.i = (long) ((void*) pobj);
result7->ref = result7->obj.i;
G__store_tempobject(*result7);
}
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_516_0_15(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
{
map<TString,TString,less<TString>,allocator<pair<const TString,TString> > >::iterator* pobj;
map<TString,TString,less<TString>,allocator<pair<const TString,TString> > >::iterator xobj = ((map<TString,TString,less<TString>,allocator<pair<const TString,TString> > >*) G__getstructoffset())->insert(*((map<TString,TString,less<TString>,allocator<pair<const TString,TString> > >::iterator*) G__int(libp->para[0])), *(map<TString,TString,less<TString>,allocator<pair<const TString,TString> > >::value_type*) libp->para[1].ref);
pobj = new map<TString,TString,less<TString>,allocator<pair<const TString,TString> > >::iterator(xobj);
result7->obj.i = (long) ((void*) pobj);
result7->ref = result7->obj.i;
G__store_tempobject(*result7);
}
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_516_0_16(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
((map<TString,TString,less<TString>,allocator<pair<const TString,TString> > >*) G__getstructoffset())->insert(*((map<TString,TString,less<TString>,allocator<pair<const TString,TString> > >::iterator*) G__int(libp->para[0])), *((map<TString,TString,less<TString>,allocator<pair<const TString,TString> > >::iterator*) G__int(libp->para[1])));
G__setnull(result7);
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_516_0_17(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
((map<TString,TString,less<TString>,allocator<pair<const TString,TString> > >*) G__getstructoffset())->insert(*((map<TString,TString,less<TString>,allocator<pair<const TString,TString> > >::reverse_iterator*) G__int(libp->para[0])), *((map<TString,TString,less<TString>,allocator<pair<const TString,TString> > >::reverse_iterator*) G__int(libp->para[1])));
G__setnull(result7);
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_516_0_18(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
((map<TString,TString,less<TString>,allocator<pair<const TString,TString> > >*) G__getstructoffset())->erase(*((map<TString,TString,less<TString>,allocator<pair<const TString,TString> > >::iterator*) G__int(libp->para[0])));
G__setnull(result7);
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_516_0_19(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
G__letint(result7, 104, (long) ((map<TString,TString,less<TString>,allocator<pair<const TString,TString> > >*) G__getstructoffset())->erase(*(TString*) libp->para[0].ref));
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_516_0_20(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
((map<TString,TString,less<TString>,allocator<pair<const TString,TString> > >*) G__getstructoffset())->erase(*((map<TString,TString,less<TString>,allocator<pair<const TString,TString> > >::iterator*) G__int(libp->para[0])), *((map<TString,TString,less<TString>,allocator<pair<const TString,TString> > >::iterator*) G__int(libp->para[1])));
G__setnull(result7);
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_516_0_21(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
((map<TString,TString,less<TString>,allocator<pair<const TString,TString> > >*) G__getstructoffset())->swap(*(map<TString,TString,less<TString>,allocator<pair<const TString,TString> > >*) libp->para[0].ref);
G__setnull(result7);
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_516_0_22(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
((map<TString,TString,less<TString>,allocator<pair<const TString,TString> > >*) G__getstructoffset())->clear();
G__setnull(result7);
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_516_0_23(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
{
map<TString,TString,less<TString>,allocator<pair<const TString,TString> > >::iterator* pobj;
map<TString,TString,less<TString>,allocator<pair<const TString,TString> > >::iterator xobj = ((map<TString,TString,less<TString>,allocator<pair<const TString,TString> > >*) G__getstructoffset())->find(*(TString*) libp->para[0].ref);
pobj = new map<TString,TString,less<TString>,allocator<pair<const TString,TString> > >::iterator(xobj);
result7->obj.i = (long) ((void*) pobj);
result7->ref = result7->obj.i;
G__store_tempobject(*result7);
}
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_516_0_24(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
G__letint(result7, 104, (long) ((const map<TString,TString,less<TString>,allocator<pair<const TString,TString> > >*) G__getstructoffset())->count(*(TString*) libp->para[0].ref));
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_516_0_25(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
{
map<TString,TString,less<TString>,allocator<pair<const TString,TString> > >::iterator* pobj;
map<TString,TString,less<TString>,allocator<pair<const TString,TString> > >::iterator xobj = ((map<TString,TString,less<TString>,allocator<pair<const TString,TString> > >*) G__getstructoffset())->lower_bound(*(TString*) libp->para[0].ref);
pobj = new map<TString,TString,less<TString>,allocator<pair<const TString,TString> > >::iterator(xobj);
result7->obj.i = (long) ((void*) pobj);
result7->ref = result7->obj.i;
G__store_tempobject(*result7);
}
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_516_0_26(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
{
map<TString,TString,less<TString>,allocator<pair<const TString,TString> > >::iterator* pobj;
map<TString,TString,less<TString>,allocator<pair<const TString,TString> > >::iterator xobj = ((map<TString,TString,less<TString>,allocator<pair<const TString,TString> > >*) G__getstructoffset())->upper_bound(*(TString*) libp->para[0].ref);
pobj = new map<TString,TString,less<TString>,allocator<pair<const TString,TString> > >::iterator(xobj);
result7->obj.i = (long) ((void*) pobj);
result7->ref = result7->obj.i;
G__store_tempobject(*result7);
}
return(1 || funcname || hash || result7 || libp) ;
}
// automatic destructor
typedef map<TString,TString,less<TString>,allocator<pair<const TString,TString> > > G__TmaplETStringcOTStringcOlesslETStringgRcOallocatorlEpairlEconstsPTStringcOTStringgRsPgRsPgR;
static int G__TGoodRunsListsCint_516_0_27(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
char* gvp = (char*) G__getgvp();
long soff = G__getstructoffset();
int n = G__getaryconstruct();
//
//has_a_delete: 0
//has_own_delete1arg: 0
//has_own_delete2arg: 0
//
if (!soff) {
return(1);
}
if (n) {
if (gvp == (char*)G__PVOID) {
delete[] (map<TString,TString,less<TString>,allocator<pair<const TString,TString> > >*) soff;
} else {
G__setgvp((long) G__PVOID);
for (int i = n - 1; i >= 0; --i) {
((map<TString,TString,less<TString>,allocator<pair<const TString,TString> > >*) (soff+(sizeof(map<TString,TString,less<TString>,allocator<pair<const TString,TString> > >)*i)))->~G__TmaplETStringcOTStringcOlesslETStringgRcOallocatorlEpairlEconstsPTStringcOTStringgRsPgRsPgR();
}
G__setgvp((long)gvp);
}
} else {
if (gvp == (char*)G__PVOID) {
delete (map<TString,TString,less<TString>,allocator<pair<const TString,TString> > >*) soff;
} else {
G__setgvp((long) G__PVOID);
((map<TString,TString,less<TString>,allocator<pair<const TString,TString> > >*) (soff))->~G__TmaplETStringcOTStringcOlesslETStringgRcOallocatorlEpairlEconstsPTStringcOTStringgRsPgRsPgR();
G__setgvp((long)gvp);
}
}
G__setnull(result7);
return(1 || funcname || hash || result7 || libp) ;
}
/* pair<TString,TString> */
static int G__TGoodRunsListsCint_517_0_1(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
pair<TString,TString>* p = NULL;
char* gvp = (char*) G__getgvp();
int n = G__getaryconstruct();
if (n) {
if ((gvp == (char*)G__PVOID) || (gvp == 0)) {
p = new pair<TString,TString>[n];
} else {
p = new((void*) gvp) pair<TString,TString>[n];
}
} else {
if ((gvp == (char*)G__PVOID) || (gvp == 0)) {
p = new pair<TString,TString>;
} else {
p = new((void*) gvp) pair<TString,TString>;
}
}
result7->obj.i = (long) p;
result7->ref = (long) p;
G__set_tagnum(result7,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_pairlETStringcOTStringgR));
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_517_0_2(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
pair<TString,TString>* p = NULL;
char* gvp = (char*) G__getgvp();
//m: 2
if ((gvp == (char*)G__PVOID) || (gvp == 0)) {
p = new pair<TString,TString>(*(TString*) libp->para[0].ref, *(TString*) libp->para[1].ref);
} else {
p = new((void*) gvp) pair<TString,TString>(*(TString*) libp->para[0].ref, *(TString*) libp->para[1].ref);
}
result7->obj.i = (long) p;
result7->ref = (long) p;
G__set_tagnum(result7,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_pairlETStringcOTStringgR));
return(1 || funcname || hash || result7 || libp) ;
}
// automatic copy constructor
static int G__TGoodRunsListsCint_517_0_4(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
pair<TString,TString>* p;
void* tmp = (void*) G__int(libp->para[0]);
p = new pair<TString,TString>(*(pair<TString,TString>*) tmp);
result7->obj.i = (long) p;
result7->ref = (long) p;
G__set_tagnum(result7,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_pairlETStringcOTStringgR));
return(1 || funcname || hash || result7 || libp) ;
}
// automatic destructor
typedef pair<TString,TString> G__TpairlETStringcOTStringgR;
static int G__TGoodRunsListsCint_517_0_5(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
char* gvp = (char*) G__getgvp();
long soff = G__getstructoffset();
int n = G__getaryconstruct();
//
//has_a_delete: 0
//has_own_delete1arg: 0
//has_own_delete2arg: 0
//
if (!soff) {
return(1);
}
if (n) {
if (gvp == (char*)G__PVOID) {
delete[] (pair<TString,TString>*) soff;
} else {
G__setgvp((long) G__PVOID);
for (int i = n - 1; i >= 0; --i) {
((pair<TString,TString>*) (soff+(sizeof(pair<TString,TString>)*i)))->~G__TpairlETStringcOTStringgR();
}
G__setgvp((long)gvp);
}
} else {
if (gvp == (char*)G__PVOID) {
delete (pair<TString,TString>*) soff;
} else {
G__setgvp((long) G__PVOID);
((pair<TString,TString>*) (soff))->~G__TpairlETStringcOTStringgR();
G__setgvp((long)gvp);
}
}
G__setnull(result7);
return(1 || funcname || hash || result7 || libp) ;
}
/* vector<Root::TGoodRun,allocator<Root::TGoodRun> > */
static int G__TGoodRunsListsCint_525_0_1(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
{
const vector<Root::TGoodRun,allocator<Root::TGoodRun> >::reference obj = ((vector<Root::TGoodRun,allocator<Root::TGoodRun> >*) G__getstructoffset())->at((vector<Root::TGoodRun,allocator<Root::TGoodRun> >::size_type) G__int(libp->para[0]));
result7->ref = (long) (&obj);
result7->obj.i = (long) (&obj);
}
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_525_0_2(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
{
vector<Root::TGoodRun,allocator<Root::TGoodRun> >::const_reference obj = ((const vector<Root::TGoodRun,allocator<Root::TGoodRun> >*) G__getstructoffset())->at((vector<Root::TGoodRun,allocator<Root::TGoodRun> >::size_type) G__int(libp->para[0]));
result7->ref = (long) (&obj);
result7->obj.i = (long) (&obj);
}
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_525_0_3(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
{
vector<Root::TGoodRun,allocator<Root::TGoodRun> >::iterator* pobj;
vector<Root::TGoodRun,allocator<Root::TGoodRun> >::iterator xobj = ((vector<Root::TGoodRun,allocator<Root::TGoodRun> >*) G__getstructoffset())->begin();
pobj = new vector<Root::TGoodRun,allocator<Root::TGoodRun> >::iterator(xobj);
result7->obj.i = (long) ((void*) pobj);
result7->ref = result7->obj.i;
G__store_tempobject(*result7);
}
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_525_0_4(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
{
vector<Root::TGoodRun,allocator<Root::TGoodRun> >::iterator* pobj;
vector<Root::TGoodRun,allocator<Root::TGoodRun> >::iterator xobj = ((vector<Root::TGoodRun,allocator<Root::TGoodRun> >*) G__getstructoffset())->end();
pobj = new vector<Root::TGoodRun,allocator<Root::TGoodRun> >::iterator(xobj);
result7->obj.i = (long) ((void*) pobj);
result7->ref = result7->obj.i;
G__store_tempobject(*result7);
}
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_525_0_5(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
{
vector<Root::TGoodRun,allocator<Root::TGoodRun> >::reverse_iterator* pobj;
vector<Root::TGoodRun,allocator<Root::TGoodRun> >::reverse_iterator xobj = ((vector<Root::TGoodRun,allocator<Root::TGoodRun> >*) G__getstructoffset())->rbegin();
pobj = new vector<Root::TGoodRun,allocator<Root::TGoodRun> >::reverse_iterator(xobj);
result7->obj.i = (long) ((void*) pobj);
result7->ref = result7->obj.i;
G__store_tempobject(*result7);
}
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_525_0_6(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
{
vector<Root::TGoodRun,allocator<Root::TGoodRun> >::reverse_iterator* pobj;
vector<Root::TGoodRun,allocator<Root::TGoodRun> >::reverse_iterator xobj = ((vector<Root::TGoodRun,allocator<Root::TGoodRun> >*) G__getstructoffset())->rend();
pobj = new vector<Root::TGoodRun,allocator<Root::TGoodRun> >::reverse_iterator(xobj);
result7->obj.i = (long) ((void*) pobj);
result7->ref = result7->obj.i;
G__store_tempobject(*result7);
}
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_525_0_7(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
G__letint(result7, 104, (long) ((const vector<Root::TGoodRun,allocator<Root::TGoodRun> >*) G__getstructoffset())->size());
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_525_0_8(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
G__letint(result7, 104, (long) ((const vector<Root::TGoodRun,allocator<Root::TGoodRun> >*) G__getstructoffset())->max_size());
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_525_0_9(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
((vector<Root::TGoodRun,allocator<Root::TGoodRun> >*) G__getstructoffset())->resize((vector<Root::TGoodRun,allocator<Root::TGoodRun> >::size_type) G__int(libp->para[0]));
G__setnull(result7);
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_525_0_10(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
((vector<Root::TGoodRun,allocator<Root::TGoodRun> >*) G__getstructoffset())->resize((vector<Root::TGoodRun,allocator<Root::TGoodRun> >::size_type) G__int(libp->para[0]), *((Root::TGoodRun*) G__int(libp->para[1])));
G__setnull(result7);
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_525_0_11(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
G__letint(result7, 104, (long) ((const vector<Root::TGoodRun,allocator<Root::TGoodRun> >*) G__getstructoffset())->capacity());
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_525_0_12(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
G__letint(result7, 103, (long) ((const vector<Root::TGoodRun,allocator<Root::TGoodRun> >*) G__getstructoffset())->empty());
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_525_0_13(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
{
const vector<Root::TGoodRun,allocator<Root::TGoodRun> >::reference obj = ((vector<Root::TGoodRun,allocator<Root::TGoodRun> >*) G__getstructoffset())->operator[]((vector<Root::TGoodRun,allocator<Root::TGoodRun> >::size_type) G__int(libp->para[0]));
result7->ref = (long) (&obj);
result7->obj.i = (long) (&obj);
}
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_525_0_14(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
{
vector<Root::TGoodRun,allocator<Root::TGoodRun> >::const_reference obj = ((const vector<Root::TGoodRun,allocator<Root::TGoodRun> >*) G__getstructoffset())->operator[]((vector<Root::TGoodRun,allocator<Root::TGoodRun> >::size_type) G__int(libp->para[0]));
result7->ref = (long) (&obj);
result7->obj.i = (long) (&obj);
}
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_525_0_15(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
vector<Root::TGoodRun,allocator<Root::TGoodRun> >* p = NULL;
char* gvp = (char*) G__getgvp();
int n = G__getaryconstruct();
if (n) {
if ((gvp == (char*)G__PVOID) || (gvp == 0)) {
p = new vector<Root::TGoodRun,allocator<Root::TGoodRun> >[n];
} else {
p = new((void*) gvp) vector<Root::TGoodRun,allocator<Root::TGoodRun> >[n];
}
} else {
if ((gvp == (char*)G__PVOID) || (gvp == 0)) {
p = new vector<Root::TGoodRun,allocator<Root::TGoodRun> >;
} else {
p = new((void*) gvp) vector<Root::TGoodRun,allocator<Root::TGoodRun> >;
}
}
result7->obj.i = (long) p;
result7->ref = (long) p;
G__set_tagnum(result7,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_vectorlERootcLcLTGoodRuncOallocatorlERootcLcLTGoodRungRsPgR));
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_525_0_16(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
vector<Root::TGoodRun,allocator<Root::TGoodRun> >* p = NULL;
char* gvp = (char*) G__getgvp();
switch (libp->paran) {
case 2:
//m: 2
if ((gvp == (char*)G__PVOID) || (gvp == 0)) {
p = new vector<Root::TGoodRun,allocator<Root::TGoodRun> >((vector<Root::TGoodRun,allocator<Root::TGoodRun> >::size_type) G__int(libp->para[0]), *(Root::TGoodRun*) libp->para[1].ref);
} else {
p = new((void*) gvp) vector<Root::TGoodRun,allocator<Root::TGoodRun> >((vector<Root::TGoodRun,allocator<Root::TGoodRun> >::size_type) G__int(libp->para[0]), *(Root::TGoodRun*) libp->para[1].ref);
}
break;
case 1:
//m: 1
if ((gvp == (char*)G__PVOID) || (gvp == 0)) {
p = new vector<Root::TGoodRun,allocator<Root::TGoodRun> >((vector<Root::TGoodRun,allocator<Root::TGoodRun> >::size_type) G__int(libp->para[0]));
} else {
p = new((void*) gvp) vector<Root::TGoodRun,allocator<Root::TGoodRun> >((vector<Root::TGoodRun,allocator<Root::TGoodRun> >::size_type) G__int(libp->para[0]));
}
break;
}
result7->obj.i = (long) p;
result7->ref = (long) p;
G__set_tagnum(result7,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_vectorlERootcLcLTGoodRuncOallocatorlERootcLcLTGoodRungRsPgR));
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_525_0_17(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
vector<Root::TGoodRun,allocator<Root::TGoodRun> >* p = NULL;
char* gvp = (char*) G__getgvp();
//m: 1
if ((gvp == (char*)G__PVOID) || (gvp == 0)) {
p = new vector<Root::TGoodRun,allocator<Root::TGoodRun> >(*(vector<Root::TGoodRun,allocator<Root::TGoodRun> >*) libp->para[0].ref);
} else {
p = new((void*) gvp) vector<Root::TGoodRun,allocator<Root::TGoodRun> >(*(vector<Root::TGoodRun,allocator<Root::TGoodRun> >*) libp->para[0].ref);
}
result7->obj.i = (long) p;
result7->ref = (long) p;
G__set_tagnum(result7,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_vectorlERootcLcLTGoodRuncOallocatorlERootcLcLTGoodRungRsPgR));
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_525_0_18(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
vector<Root::TGoodRun,allocator<Root::TGoodRun> >* p = NULL;
char* gvp = (char*) G__getgvp();
//m: 2
if ((gvp == (char*)G__PVOID) || (gvp == 0)) {
p = new vector<Root::TGoodRun,allocator<Root::TGoodRun> >(*((vector<Root::TGoodRun,allocator<Root::TGoodRun> >::const_iterator*) G__int(libp->para[0])), *((vector<Root::TGoodRun,allocator<Root::TGoodRun> >::const_iterator*) G__int(libp->para[1])));
} else {
p = new((void*) gvp) vector<Root::TGoodRun,allocator<Root::TGoodRun> >(*((vector<Root::TGoodRun,allocator<Root::TGoodRun> >::const_iterator*) G__int(libp->para[0])), *((vector<Root::TGoodRun,allocator<Root::TGoodRun> >::const_iterator*) G__int(libp->para[1])));
}
result7->obj.i = (long) p;
result7->ref = (long) p;
G__set_tagnum(result7,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_vectorlERootcLcLTGoodRuncOallocatorlERootcLcLTGoodRungRsPgR));
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_525_0_19(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
{
const vector<Root::TGoodRun,allocator<Root::TGoodRun> >& obj = ((vector<Root::TGoodRun,allocator<Root::TGoodRun> >*) G__getstructoffset())->operator=(*(vector<Root::TGoodRun,allocator<Root::TGoodRun> >*) libp->para[0].ref);
result7->ref = (long) (&obj);
result7->obj.i = (long) (&obj);
}
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_525_0_20(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
((vector<Root::TGoodRun,allocator<Root::TGoodRun> >*) G__getstructoffset())->reserve((vector<Root::TGoodRun,allocator<Root::TGoodRun> >::size_type) G__int(libp->para[0]));
G__setnull(result7);
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_525_0_21(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
{
const Root::TGoodRun& obj = ((vector<Root::TGoodRun,allocator<Root::TGoodRun> >*) G__getstructoffset())->front();
result7->ref = (long) (&obj);
result7->obj.i = (long) (&obj);
}
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_525_0_22(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
{
const Root::TGoodRun& obj = ((vector<Root::TGoodRun,allocator<Root::TGoodRun> >*) G__getstructoffset())->back();
result7->ref = (long) (&obj);
result7->obj.i = (long) (&obj);
}
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_525_0_23(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
((vector<Root::TGoodRun,allocator<Root::TGoodRun> >*) G__getstructoffset())->push_back(*(Root::TGoodRun*) libp->para[0].ref);
G__setnull(result7);
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_525_0_24(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
((vector<Root::TGoodRun,allocator<Root::TGoodRun> >*) G__getstructoffset())->swap(*(vector<Root::TGoodRun,allocator<Root::TGoodRun> >*) libp->para[0].ref);
G__setnull(result7);
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_525_0_25(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
{
vector<Root::TGoodRun,allocator<Root::TGoodRun> >::iterator* pobj;
vector<Root::TGoodRun,allocator<Root::TGoodRun> >::iterator xobj = ((vector<Root::TGoodRun,allocator<Root::TGoodRun> >*) G__getstructoffset())->insert(*((vector<Root::TGoodRun,allocator<Root::TGoodRun> >::iterator*) G__int(libp->para[0])), *(Root::TGoodRun*) libp->para[1].ref);
pobj = new vector<Root::TGoodRun,allocator<Root::TGoodRun> >::iterator(xobj);
result7->obj.i = (long) ((void*) pobj);
result7->ref = result7->obj.i;
G__store_tempobject(*result7);
}
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_525_0_26(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
((vector<Root::TGoodRun,allocator<Root::TGoodRun> >*) G__getstructoffset())->insert(*((vector<Root::TGoodRun,allocator<Root::TGoodRun> >::iterator*) G__int(libp->para[0])), *((vector<Root::TGoodRun,allocator<Root::TGoodRun> >::const_iterator*) G__int(libp->para[1]))
, *((vector<Root::TGoodRun,allocator<Root::TGoodRun> >::const_iterator*) G__int(libp->para[2])));
G__setnull(result7);
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_525_0_27(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
((vector<Root::TGoodRun,allocator<Root::TGoodRun> >*) G__getstructoffset())->insert(*((vector<Root::TGoodRun,allocator<Root::TGoodRun> >::iterator*) G__int(libp->para[0])), (vector<Root::TGoodRun,allocator<Root::TGoodRun> >::size_type) G__int(libp->para[1])
, *(Root::TGoodRun*) libp->para[2].ref);
G__setnull(result7);
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_525_0_28(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
((vector<Root::TGoodRun,allocator<Root::TGoodRun> >*) G__getstructoffset())->pop_back();
G__setnull(result7);
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_525_0_29(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
((vector<Root::TGoodRun,allocator<Root::TGoodRun> >*) G__getstructoffset())->erase(*((vector<Root::TGoodRun,allocator<Root::TGoodRun> >::iterator*) G__int(libp->para[0])));
G__setnull(result7);
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_525_0_30(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
((vector<Root::TGoodRun,allocator<Root::TGoodRun> >*) G__getstructoffset())->erase(*((vector<Root::TGoodRun,allocator<Root::TGoodRun> >::iterator*) G__int(libp->para[0])), *((vector<Root::TGoodRun,allocator<Root::TGoodRun> >::iterator*) G__int(libp->para[1])));
G__setnull(result7);
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_525_0_31(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
((vector<Root::TGoodRun,allocator<Root::TGoodRun> >*) G__getstructoffset())->clear();
G__setnull(result7);
return(1 || funcname || hash || result7 || libp) ;
}
// automatic destructor
typedef vector<Root::TGoodRun,allocator<Root::TGoodRun> > G__TvectorlERootcLcLTGoodRuncOallocatorlERootcLcLTGoodRungRsPgR;
static int G__TGoodRunsListsCint_525_0_32(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
char* gvp = (char*) G__getgvp();
long soff = G__getstructoffset();
int n = G__getaryconstruct();
//
//has_a_delete: 0
//has_own_delete1arg: 0
//has_own_delete2arg: 0
//
if (!soff) {
return(1);
}
if (n) {
if (gvp == (char*)G__PVOID) {
delete[] (vector<Root::TGoodRun,allocator<Root::TGoodRun> >*) soff;
} else {
G__setgvp((long) G__PVOID);
for (int i = n - 1; i >= 0; --i) {
((vector<Root::TGoodRun,allocator<Root::TGoodRun> >*) (soff+(sizeof(vector<Root::TGoodRun,allocator<Root::TGoodRun> >)*i)))->~G__TvectorlERootcLcLTGoodRuncOallocatorlERootcLcLTGoodRungRsPgR();
}
G__setgvp((long)gvp);
}
} else {
if (gvp == (char*)G__PVOID) {
delete (vector<Root::TGoodRun,allocator<Root::TGoodRun> >*) soff;
} else {
G__setgvp((long) G__PVOID);
((vector<Root::TGoodRun,allocator<Root::TGoodRun> >*) (soff))->~G__TvectorlERootcLcLTGoodRuncOallocatorlERootcLcLTGoodRungRsPgR();
G__setgvp((long)gvp);
}
}
G__setnull(result7);
return(1 || funcname || hash || result7 || libp) ;
}
/* vector<Root::TGoodRun,allocator<Root::TGoodRun> >::iterator */
static int G__TGoodRunsListsCint_526_0_1(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
vector<Root::TGoodRun,allocator<Root::TGoodRun> >::iterator* p = NULL;
char* gvp = (char*) G__getgvp();
int n = G__getaryconstruct();
if (n) {
if ((gvp == (char*)G__PVOID) || (gvp == 0)) {
p = new vector<Root::TGoodRun,allocator<Root::TGoodRun> >::iterator[n];
} else {
p = new((void*) gvp) vector<Root::TGoodRun,allocator<Root::TGoodRun> >::iterator[n];
}
} else {
if ((gvp == (char*)G__PVOID) || (gvp == 0)) {
p = new vector<Root::TGoodRun,allocator<Root::TGoodRun> >::iterator;
} else {
p = new((void*) gvp) vector<Root::TGoodRun,allocator<Root::TGoodRun> >::iterator;
}
}
result7->obj.i = (long) p;
result7->ref = (long) p;
G__set_tagnum(result7,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_vectorlERootcLcLTGoodRuncOallocatorlERootcLcLTGoodRungRsPgRcLcLiterator));
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_526_0_2(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
vector<Root::TGoodRun,allocator<Root::TGoodRun> >::iterator* p = NULL;
char* gvp = (char*) G__getgvp();
//m: 1
if ((gvp == (char*)G__PVOID) || (gvp == 0)) {
p = new vector<Root::TGoodRun,allocator<Root::TGoodRun> >::iterator(libp->para[0].ref ? *(const vector<Root::TGoodRun,allocator<Root::TGoodRun> >::iterator::pointer*) libp->para[0].ref : *(const vector<Root::TGoodRun,allocator<Root::TGoodRun> >::iterator::pointer*) (void*) (&G__Mlong(libp->para[0])));
} else {
p = new((void*) gvp) vector<Root::TGoodRun,allocator<Root::TGoodRun> >::iterator(libp->para[0].ref ? *(const vector<Root::TGoodRun,allocator<Root::TGoodRun> >::iterator::pointer*) libp->para[0].ref : *(const vector<Root::TGoodRun,allocator<Root::TGoodRun> >::iterator::pointer*) (void*) (&G__Mlong(libp->para[0])));
}
result7->obj.i = (long) p;
result7->ref = (long) p;
G__set_tagnum(result7,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_vectorlERootcLcLTGoodRuncOallocatorlERootcLcLTGoodRungRsPgRcLcLiterator));
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_526_0_3(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
{
const vector<Root::TGoodRun,allocator<Root::TGoodRun> >::iterator::reference obj = ((const vector<Root::TGoodRun,allocator<Root::TGoodRun> >::iterator*) G__getstructoffset())->operator*();
result7->ref = (long) (&obj);
result7->obj.i = (long) (&obj);
}
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_526_0_4(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
G__letint(result7, 85, (long) ((const vector<Root::TGoodRun,allocator<Root::TGoodRun> >::iterator*) G__getstructoffset())->operator->());
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_526_0_5(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
{
const vector<Root::TGoodRun,allocator<Root::TGoodRun> >::iterator& obj = ((vector<Root::TGoodRun,allocator<Root::TGoodRun> >::iterator*) G__getstructoffset())->operator++();
result7->ref = (long) (&obj);
result7->obj.i = (long) (&obj);
}
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_526_0_6(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
{
vector<Root::TGoodRun,allocator<Root::TGoodRun> >::iterator* pobj;
vector<Root::TGoodRun,allocator<Root::TGoodRun> >::iterator xobj = ((vector<Root::TGoodRun,allocator<Root::TGoodRun> >::iterator*) G__getstructoffset())->operator++((int) G__int(libp->para[0]));
pobj = new vector<Root::TGoodRun,allocator<Root::TGoodRun> >::iterator(xobj);
result7->obj.i = (long) ((void*) pobj);
result7->ref = result7->obj.i;
G__store_tempobject(*result7);
}
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_526_0_7(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
{
const vector<Root::TGoodRun,allocator<Root::TGoodRun> >::iterator& obj = ((vector<Root::TGoodRun,allocator<Root::TGoodRun> >::iterator*) G__getstructoffset())->operator--();
result7->ref = (long) (&obj);
result7->obj.i = (long) (&obj);
}
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_526_0_8(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
{
vector<Root::TGoodRun,allocator<Root::TGoodRun> >::iterator* pobj;
vector<Root::TGoodRun,allocator<Root::TGoodRun> >::iterator xobj = ((vector<Root::TGoodRun,allocator<Root::TGoodRun> >::iterator*) G__getstructoffset())->operator--((int) G__int(libp->para[0]));
pobj = new vector<Root::TGoodRun,allocator<Root::TGoodRun> >::iterator(xobj);
result7->obj.i = (long) ((void*) pobj);
result7->ref = result7->obj.i;
G__store_tempobject(*result7);
}
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_526_0_9(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
{
const vector<Root::TGoodRun,allocator<Root::TGoodRun> >::iterator::reference obj = ((const vector<Root::TGoodRun,allocator<Root::TGoodRun> >::iterator*) G__getstructoffset())->operator[](*(vector<Root::TGoodRun,allocator<Root::TGoodRun> >::iterator::difference_type*) G__Longref(&libp->para[0]));
result7->ref = (long) (&obj);
result7->obj.i = (long) (&obj);
}
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_526_0_10(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
{
const vector<Root::TGoodRun,allocator<Root::TGoodRun> >::iterator& obj = ((vector<Root::TGoodRun,allocator<Root::TGoodRun> >::iterator*) G__getstructoffset())->operator+=(*(vector<Root::TGoodRun,allocator<Root::TGoodRun> >::iterator::difference_type*) G__Longref(&libp->para[0]));
result7->ref = (long) (&obj);
result7->obj.i = (long) (&obj);
}
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_526_0_11(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
{
const vector<Root::TGoodRun,allocator<Root::TGoodRun> >::iterator* pobj;
const vector<Root::TGoodRun,allocator<Root::TGoodRun> >::iterator xobj = ((const vector<Root::TGoodRun,allocator<Root::TGoodRun> >::iterator*) G__getstructoffset())->operator+(*(vector<Root::TGoodRun,allocator<Root::TGoodRun> >::iterator::difference_type*) G__Longref(&libp->para[0]));
pobj = new vector<Root::TGoodRun,allocator<Root::TGoodRun> >::iterator(xobj);
result7->obj.i = (long) ((void*) pobj);
result7->ref = result7->obj.i;
G__store_tempobject(*result7);
}
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_526_0_12(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
{
const vector<Root::TGoodRun,allocator<Root::TGoodRun> >::iterator& obj = ((vector<Root::TGoodRun,allocator<Root::TGoodRun> >::iterator*) G__getstructoffset())->operator-=(*(vector<Root::TGoodRun,allocator<Root::TGoodRun> >::iterator::difference_type*) G__Longref(&libp->para[0]));
result7->ref = (long) (&obj);
result7->obj.i = (long) (&obj);
}
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_526_0_13(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
{
const vector<Root::TGoodRun,allocator<Root::TGoodRun> >::iterator* pobj;
const vector<Root::TGoodRun,allocator<Root::TGoodRun> >::iterator xobj = ((const vector<Root::TGoodRun,allocator<Root::TGoodRun> >::iterator*) G__getstructoffset())->operator-(*(vector<Root::TGoodRun,allocator<Root::TGoodRun> >::iterator::difference_type*) G__Longref(&libp->para[0]));
pobj = new vector<Root::TGoodRun,allocator<Root::TGoodRun> >::iterator(xobj);
result7->obj.i = (long) ((void*) pobj);
result7->ref = result7->obj.i;
G__store_tempobject(*result7);
}
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_526_0_14(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
{
const vector<Root::TGoodRun,allocator<Root::TGoodRun> >::iterator::pointer& obj = ((const vector<Root::TGoodRun,allocator<Root::TGoodRun> >::iterator*) G__getstructoffset())->base();
result7->ref = (long) (&obj);
G__letint(result7, 'U', (long)obj);
}
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_526_0_15(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
{
vector<Root::TGoodRun,allocator<Root::TGoodRun> >::iterator* pobj;
vector<Root::TGoodRun,allocator<Root::TGoodRun> >::iterator xobj = ((vector<Root::TGoodRun,allocator<Root::TGoodRun> >::iterator*) G__getstructoffset())->operator=(*(vector<Root::TGoodRun,allocator<Root::TGoodRun> >::iterator*) libp->para[0].ref);
pobj = new vector<Root::TGoodRun,allocator<Root::TGoodRun> >::iterator(xobj);
result7->obj.i = (long) ((void*) pobj);
result7->ref = result7->obj.i;
G__store_tempobject(*result7);
}
return(1 || funcname || hash || result7 || libp) ;
}
// automatic copy constructor
static int G__TGoodRunsListsCint_526_0_16(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
vector<Root::TGoodRun,allocator<Root::TGoodRun> >::iterator* p;
void* tmp = (void*) G__int(libp->para[0]);
p = new vector<Root::TGoodRun,allocator<Root::TGoodRun> >::iterator(*(vector<Root::TGoodRun,allocator<Root::TGoodRun> >::iterator*) tmp);
result7->obj.i = (long) p;
result7->ref = (long) p;
G__set_tagnum(result7,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_vectorlERootcLcLTGoodRuncOallocatorlERootcLcLTGoodRungRsPgRcLcLiterator));
return(1 || funcname || hash || result7 || libp) ;
}
// automatic destructor
typedef vector<Root::TGoodRun,allocator<Root::TGoodRun> >::iterator G__TvectorlERootcLcLTGoodRuncOallocatorlERootcLcLTGoodRungRsPgRcLcLiterator;
static int G__TGoodRunsListsCint_526_0_17(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
char* gvp = (char*) G__getgvp();
long soff = G__getstructoffset();
int n = G__getaryconstruct();
//
//has_a_delete: 0
//has_own_delete1arg: 0
//has_own_delete2arg: 0
//
if (!soff) {
return(1);
}
if (n) {
if (gvp == (char*)G__PVOID) {
delete[] (vector<Root::TGoodRun,allocator<Root::TGoodRun> >::iterator*) soff;
} else {
G__setgvp((long) G__PVOID);
for (int i = n - 1; i >= 0; --i) {
((vector<Root::TGoodRun,allocator<Root::TGoodRun> >::iterator*) (soff+(sizeof(vector<Root::TGoodRun,allocator<Root::TGoodRun> >::iterator)*i)))->~G__TvectorlERootcLcLTGoodRuncOallocatorlERootcLcLTGoodRungRsPgRcLcLiterator();
}
G__setgvp((long)gvp);
}
} else {
if (gvp == (char*)G__PVOID) {
delete (vector<Root::TGoodRun,allocator<Root::TGoodRun> >::iterator*) soff;
} else {
G__setgvp((long) G__PVOID);
((vector<Root::TGoodRun,allocator<Root::TGoodRun> >::iterator*) (soff))->~G__TvectorlERootcLcLTGoodRuncOallocatorlERootcLcLTGoodRungRsPgRcLcLiterator();
G__setgvp((long)gvp);
}
}
G__setnull(result7);
return(1 || funcname || hash || result7 || libp) ;
}
/* Root::TGRLCollection */
static int G__TGoodRunsListsCint_529_0_1(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
Root::TGRLCollection* p = NULL;
char* gvp = (char*) G__getgvp();
switch (libp->paran) {
case 1:
//m: 1
if ((gvp == (char*)G__PVOID) || (gvp == 0)) {
p = new Root::TGRLCollection((Bool_t) G__int(libp->para[0]));
} else {
p = new((void*) gvp) Root::TGRLCollection((Bool_t) G__int(libp->para[0]));
}
break;
case 0:
int n = G__getaryconstruct();
if (n) {
if ((gvp == (char*)G__PVOID) || (gvp == 0)) {
p = new Root::TGRLCollection[n];
} else {
p = new((void*) gvp) Root::TGRLCollection[n];
}
} else {
if ((gvp == (char*)G__PVOID) || (gvp == 0)) {
p = new Root::TGRLCollection;
} else {
p = new((void*) gvp) Root::TGRLCollection;
}
}
break;
}
result7->obj.i = (long) p;
result7->ref = (long) p;
G__set_tagnum(result7,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_RootcLcLTGRLCollection));
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_529_0_2(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
Root::TGRLCollection* p = NULL;
char* gvp = (char*) G__getgvp();
//m: 1
if ((gvp == (char*)G__PVOID) || (gvp == 0)) {
p = new Root::TGRLCollection(*(Root::TGRLCollection*) libp->para[0].ref);
} else {
p = new((void*) gvp) Root::TGRLCollection(*(Root::TGRLCollection*) libp->para[0].ref);
}
result7->obj.i = (long) p;
result7->ref = (long) p;
G__set_tagnum(result7,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_RootcLcLTGRLCollection));
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_529_0_3(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
{
const Root::TGRLCollection& obj = ((Root::TGRLCollection*) G__getstructoffset())->operator=(*(Root::TGRLCollection*) libp->para[0].ref);
result7->ref = (long) (&obj);
result7->obj.i = (long) (&obj);
}
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_529_0_4(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
((Root::TGRLCollection*) G__getstructoffset())->SetVersion(*(TString*) libp->para[0].ref);
G__setnull(result7);
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_529_0_5(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
((Root::TGRLCollection*) G__getstructoffset())->SetMetaData(*(map<TString,TString>*) libp->para[0].ref);
G__setnull(result7);
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_529_0_6(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
switch (libp->paran) {
case 1:
((Root::TGRLCollection*) G__getstructoffset())->SetCheckGRLInfo((Bool_t) G__int(libp->para[0]));
G__setnull(result7);
break;
case 0:
((Root::TGRLCollection*) G__getstructoffset())->SetCheckGRLInfo();
G__setnull(result7);
break;
}
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_529_0_7(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
G__letint(result7, 103, (long) ((const Root::TGRLCollection*) G__getstructoffset())->HasRun(*(Int_t*) G__Intref(&libp->para[0])));
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_529_0_8(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
G__letint(result7, 103, (long) ((const Root::TGRLCollection*) G__getstructoffset())->HasRunLumiBlock(*(Int_t*) G__Intref(&libp->para[0]), *(Int_t*) G__Intref(&libp->para[1])));
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_529_0_9(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
G__letint(result7, 103, (long) ((const Root::TGRLCollection*) G__getstructoffset())->IsEmpty());
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_529_0_10(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
G__letint(result7, 103, (long) ((const Root::TGRLCollection*) G__getstructoffset())->HasGoodRunsList(*(TString*) libp->para[0].ref));
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_529_0_11(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
switch (libp->paran) {
case 1:
{
const Root::TGoodRunsList* pobj;
const Root::TGoodRunsList xobj = ((const Root::TGRLCollection*) G__getstructoffset())->GetMergedGoodRunsList(*(Root::BoolOperation*) libp->para[0].ref);
pobj = new Root::TGoodRunsList(xobj);
result7->obj.i = (long) ((void*) pobj);
result7->ref = result7->obj.i;
G__store_tempobject(*result7);
}
break;
case 0:
{
const Root::TGoodRunsList* pobj;
const Root::TGoodRunsList xobj = ((const Root::TGRLCollection*) G__getstructoffset())->GetMergedGoodRunsList();
pobj = new Root::TGoodRunsList(xobj);
result7->obj.i = (long) ((void*) pobj);
result7->ref = result7->obj.i;
G__store_tempobject(*result7);
}
break;
}
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_529_0_12(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
{
const Root::TGoodRunsList* pobj;
const Root::TGoodRunsList xobj = ((const Root::TGRLCollection*) G__getstructoffset())->GetGoodRunsList((unsigned int) G__int(libp->para[0]));
pobj = new Root::TGoodRunsList(xobj);
result7->obj.i = (long) ((void*) pobj);
result7->ref = result7->obj.i;
G__store_tempobject(*result7);
}
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_529_0_13(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
{
vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >::iterator* pobj;
vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >::iterator xobj = ((Root::TGRLCollection*) G__getstructoffset())->find(*(TString*) libp->para[0].ref);
pobj = new vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >::iterator(xobj);
result7->obj.i = (long) ((void*) pobj);
result7->ref = result7->obj.i;
G__store_tempobject(*result7);
}
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_529_0_14(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
{
const vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >::const_iterator* pobj;
const vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >::const_iterator xobj = ((const Root::TGRLCollection*) G__getstructoffset())->find(*(TString*) libp->para[0].ref);
pobj = new vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >::const_iterator(xobj);
result7->obj.i = (long) ((void*) pobj);
result7->ref = result7->obj.i;
G__store_tempobject(*result7);
}
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_529_0_15(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
switch (libp->paran) {
case 1:
{
const Root::TGRLCollection* pobj;
const Root::TGRLCollection xobj = ((const Root::TGRLCollection*) G__getstructoffset())->GetMergedGRLCollection(*(Root::BoolOperation*) libp->para[0].ref);
pobj = new Root::TGRLCollection(xobj);
result7->obj.i = (long) ((void*) pobj);
result7->ref = result7->obj.i;
G__store_tempobject(*result7);
}
break;
case 0:
{
const Root::TGRLCollection* pobj;
const Root::TGRLCollection xobj = ((const Root::TGRLCollection*) G__getstructoffset())->GetMergedGRLCollection();
pobj = new Root::TGRLCollection(xobj);
result7->obj.i = (long) ((void*) pobj);
result7->ref = result7->obj.i;
G__store_tempobject(*result7);
}
break;
}
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_529_0_16(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
{
const Root::TGRLCollection* pobj;
const Root::TGRLCollection xobj = ((const Root::TGRLCollection*) G__getstructoffset())->GetOverlapWith(*(Root::TGoodRunsList*) libp->para[0].ref);
pobj = new Root::TGRLCollection(xobj);
result7->obj.i = (long) ((void*) pobj);
result7->ref = result7->obj.i;
G__store_tempobject(*result7);
}
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_529_0_17(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
((Root::TGRLCollection*) G__getstructoffset())->Reset();
G__setnull(result7);
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_529_0_18(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
switch (libp->paran) {
case 1:
((const Root::TGRLCollection*) G__getstructoffset())->Summary((Bool_t) G__int(libp->para[0]));
G__setnull(result7);
break;
case 0:
((const Root::TGRLCollection*) G__getstructoffset())->Summary();
G__setnull(result7);
break;
}
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_529_0_19(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
G__letint(result7, 85, (long) Root::TGRLCollection::Class());
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_529_0_20(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
G__letint(result7, 67, (long) Root::TGRLCollection::Class_Name());
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_529_0_21(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
G__letint(result7, 115, (long) Root::TGRLCollection::Class_Version());
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_529_0_22(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
Root::TGRLCollection::Dictionary();
G__setnull(result7);
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_529_0_26(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
((Root::TGRLCollection*) G__getstructoffset())->StreamerNVirtual(*(TBuffer*) libp->para[0].ref);
G__setnull(result7);
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_529_0_27(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
G__letint(result7, 67, (long) Root::TGRLCollection::DeclFileName());
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_529_0_28(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
G__letint(result7, 105, (long) Root::TGRLCollection::ImplFileLine());
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_529_0_29(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
G__letint(result7, 67, (long) Root::TGRLCollection::ImplFileName());
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_529_0_30(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
G__letint(result7, 105, (long) Root::TGRLCollection::DeclFileLine());
return(1 || funcname || hash || result7 || libp) ;
}
// automatic destructor
typedef Root::TGRLCollection G__TRootcLcLTGRLCollection;
static int G__TGoodRunsListsCint_529_0_31(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
char* gvp = (char*) G__getgvp();
long soff = G__getstructoffset();
int n = G__getaryconstruct();
//
//has_a_delete: 1
//has_own_delete1arg: 0
//has_own_delete2arg: 0
//
if (!soff) {
return(1);
}
if (n) {
if (gvp == (char*)G__PVOID) {
delete[] (Root::TGRLCollection*) soff;
} else {
G__setgvp((long) G__PVOID);
for (int i = n - 1; i >= 0; --i) {
((Root::TGRLCollection*) (soff+(sizeof(Root::TGRLCollection)*i)))->~G__TRootcLcLTGRLCollection();
}
G__setgvp((long)gvp);
}
} else {
if (gvp == (char*)G__PVOID) {
delete (Root::TGRLCollection*) soff;
} else {
G__setgvp((long) G__PVOID);
((Root::TGRLCollection*) (soff))->~G__TRootcLcLTGRLCollection();
G__setgvp((long)gvp);
}
}
G__setnull(result7);
return(1 || funcname || hash || result7 || libp) ;
}
/* vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> > */
static int G__TGoodRunsListsCint_531_0_1(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
{
const vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >::reference obj = ((vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >*) G__getstructoffset())->at((vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >::size_type) G__int(libp->para[0]));
result7->ref = (long) (&obj);
result7->obj.i = (long) (&obj);
}
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_531_0_2(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
{
vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >::const_reference obj = ((const vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >*) G__getstructoffset())->at((vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >::size_type) G__int(libp->para[0]));
result7->ref = (long) (&obj);
result7->obj.i = (long) (&obj);
}
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_531_0_3(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
{
vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >::iterator* pobj;
vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >::iterator xobj = ((vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >*) G__getstructoffset())->begin();
pobj = new vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >::iterator(xobj);
result7->obj.i = (long) ((void*) pobj);
result7->ref = result7->obj.i;
G__store_tempobject(*result7);
}
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_531_0_4(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
{
vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >::iterator* pobj;
vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >::iterator xobj = ((vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >*) G__getstructoffset())->end();
pobj = new vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >::iterator(xobj);
result7->obj.i = (long) ((void*) pobj);
result7->ref = result7->obj.i;
G__store_tempobject(*result7);
}
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_531_0_5(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
{
vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >::reverse_iterator* pobj;
vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >::reverse_iterator xobj = ((vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >*) G__getstructoffset())->rbegin();
pobj = new vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >::reverse_iterator(xobj);
result7->obj.i = (long) ((void*) pobj);
result7->ref = result7->obj.i;
G__store_tempobject(*result7);
}
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_531_0_6(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
{
vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >::reverse_iterator* pobj;
vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >::reverse_iterator xobj = ((vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >*) G__getstructoffset())->rend();
pobj = new vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >::reverse_iterator(xobj);
result7->obj.i = (long) ((void*) pobj);
result7->ref = result7->obj.i;
G__store_tempobject(*result7);
}
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_531_0_7(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
G__letint(result7, 104, (long) ((const vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >*) G__getstructoffset())->size());
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_531_0_8(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
G__letint(result7, 104, (long) ((const vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >*) G__getstructoffset())->max_size());
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_531_0_9(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
((vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >*) G__getstructoffset())->resize((vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >::size_type) G__int(libp->para[0]));
G__setnull(result7);
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_531_0_10(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
((vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >*) G__getstructoffset())->resize((vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >::size_type) G__int(libp->para[0]), *((Root::TGoodRunsList*) G__int(libp->para[1])));
G__setnull(result7);
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_531_0_11(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
G__letint(result7, 104, (long) ((const vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >*) G__getstructoffset())->capacity());
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_531_0_12(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
G__letint(result7, 103, (long) ((const vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >*) G__getstructoffset())->empty());
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_531_0_13(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
{
const vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >::reference obj = ((vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >*) G__getstructoffset())->operator[]((vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >::size_type) G__int(libp->para[0]));
result7->ref = (long) (&obj);
result7->obj.i = (long) (&obj);
}
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_531_0_14(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
{
vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >::const_reference obj = ((const vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >*) G__getstructoffset())->operator[]((vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >::size_type) G__int(libp->para[0]));
result7->ref = (long) (&obj);
result7->obj.i = (long) (&obj);
}
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_531_0_15(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >* p = NULL;
char* gvp = (char*) G__getgvp();
int n = G__getaryconstruct();
if (n) {
if ((gvp == (char*)G__PVOID) || (gvp == 0)) {
p = new vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >[n];
} else {
p = new((void*) gvp) vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >[n];
}
} else {
if ((gvp == (char*)G__PVOID) || (gvp == 0)) {
p = new vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >;
} else {
p = new((void*) gvp) vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >;
}
}
result7->obj.i = (long) p;
result7->ref = (long) p;
G__set_tagnum(result7,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_vectorlERootcLcLTGoodRunsListcOallocatorlERootcLcLTGoodRunsListgRsPgR));
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_531_0_16(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >* p = NULL;
char* gvp = (char*) G__getgvp();
switch (libp->paran) {
case 2:
//m: 2
if ((gvp == (char*)G__PVOID) || (gvp == 0)) {
p = new vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >((vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >::size_type) G__int(libp->para[0]), *(Root::TGoodRunsList*) libp->para[1].ref);
} else {
p = new((void*) gvp) vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >((vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >::size_type) G__int(libp->para[0]), *(Root::TGoodRunsList*) libp->para[1].ref);
}
break;
case 1:
//m: 1
if ((gvp == (char*)G__PVOID) || (gvp == 0)) {
p = new vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >((vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >::size_type) G__int(libp->para[0]));
} else {
p = new((void*) gvp) vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >((vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >::size_type) G__int(libp->para[0]));
}
break;
}
result7->obj.i = (long) p;
result7->ref = (long) p;
G__set_tagnum(result7,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_vectorlERootcLcLTGoodRunsListcOallocatorlERootcLcLTGoodRunsListgRsPgR));
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_531_0_17(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >* p = NULL;
char* gvp = (char*) G__getgvp();
//m: 1
if ((gvp == (char*)G__PVOID) || (gvp == 0)) {
p = new vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >(*(vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >*) libp->para[0].ref);
} else {
p = new((void*) gvp) vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >(*(vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >*) libp->para[0].ref);
}
result7->obj.i = (long) p;
result7->ref = (long) p;
G__set_tagnum(result7,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_vectorlERootcLcLTGoodRunsListcOallocatorlERootcLcLTGoodRunsListgRsPgR));
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_531_0_18(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >* p = NULL;
char* gvp = (char*) G__getgvp();
//m: 2
if ((gvp == (char*)G__PVOID) || (gvp == 0)) {
p = new vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >(*((vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >::const_iterator*) G__int(libp->para[0])), *((vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >::const_iterator*) G__int(libp->para[1])));
} else {
p = new((void*) gvp) vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >(*((vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >::const_iterator*) G__int(libp->para[0])), *((vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >::const_iterator*) G__int(libp->para[1])));
}
result7->obj.i = (long) p;
result7->ref = (long) p;
G__set_tagnum(result7,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_vectorlERootcLcLTGoodRunsListcOallocatorlERootcLcLTGoodRunsListgRsPgR));
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_531_0_19(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
{
const vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >& obj = ((vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >*) G__getstructoffset())->operator=(*(vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >*) libp->para[0].ref);
result7->ref = (long) (&obj);
result7->obj.i = (long) (&obj);
}
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_531_0_20(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
((vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >*) G__getstructoffset())->reserve((vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >::size_type) G__int(libp->para[0]));
G__setnull(result7);
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_531_0_21(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
{
const Root::TGoodRunsList& obj = ((vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >*) G__getstructoffset())->front();
result7->ref = (long) (&obj);
result7->obj.i = (long) (&obj);
}
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_531_0_22(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
{
const Root::TGoodRunsList& obj = ((vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >*) G__getstructoffset())->back();
result7->ref = (long) (&obj);
result7->obj.i = (long) (&obj);
}
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_531_0_23(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
((vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >*) G__getstructoffset())->push_back(*(Root::TGoodRunsList*) libp->para[0].ref);
G__setnull(result7);
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_531_0_24(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
((vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >*) G__getstructoffset())->swap(*(vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >*) libp->para[0].ref);
G__setnull(result7);
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_531_0_25(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
{
vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >::iterator* pobj;
vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >::iterator xobj = ((vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >*) G__getstructoffset())->insert(*((vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >::iterator*) G__int(libp->para[0])), *(Root::TGoodRunsList*) libp->para[1].ref);
pobj = new vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >::iterator(xobj);
result7->obj.i = (long) ((void*) pobj);
result7->ref = result7->obj.i;
G__store_tempobject(*result7);
}
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_531_0_26(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
((vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >*) G__getstructoffset())->insert(*((vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >::iterator*) G__int(libp->para[0])), *((vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >::const_iterator*) G__int(libp->para[1]))
, *((vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >::const_iterator*) G__int(libp->para[2])));
G__setnull(result7);
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_531_0_27(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
((vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >*) G__getstructoffset())->insert(*((vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >::iterator*) G__int(libp->para[0])), (vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >::size_type) G__int(libp->para[1])
, *(Root::TGoodRunsList*) libp->para[2].ref);
G__setnull(result7);
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_531_0_28(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
((vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >*) G__getstructoffset())->pop_back();
G__setnull(result7);
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_531_0_29(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
((vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >*) G__getstructoffset())->erase(*((vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >::iterator*) G__int(libp->para[0])));
G__setnull(result7);
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_531_0_30(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
((vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >*) G__getstructoffset())->erase(*((vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >::iterator*) G__int(libp->para[0])), *((vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >::iterator*) G__int(libp->para[1])));
G__setnull(result7);
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_531_0_31(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
((vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >*) G__getstructoffset())->clear();
G__setnull(result7);
return(1 || funcname || hash || result7 || libp) ;
}
// automatic destructor
typedef vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> > G__TvectorlERootcLcLTGoodRunsListcOallocatorlERootcLcLTGoodRunsListgRsPgR;
static int G__TGoodRunsListsCint_531_0_32(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
char* gvp = (char*) G__getgvp();
long soff = G__getstructoffset();
int n = G__getaryconstruct();
//
//has_a_delete: 0
//has_own_delete1arg: 0
//has_own_delete2arg: 0
//
if (!soff) {
return(1);
}
if (n) {
if (gvp == (char*)G__PVOID) {
delete[] (vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >*) soff;
} else {
G__setgvp((long) G__PVOID);
for (int i = n - 1; i >= 0; --i) {
((vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >*) (soff+(sizeof(vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >)*i)))->~G__TvectorlERootcLcLTGoodRunsListcOallocatorlERootcLcLTGoodRunsListgRsPgR();
}
G__setgvp((long)gvp);
}
} else {
if (gvp == (char*)G__PVOID) {
delete (vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >*) soff;
} else {
G__setgvp((long) G__PVOID);
((vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >*) (soff))->~G__TvectorlERootcLcLTGoodRunsListcOallocatorlERootcLcLTGoodRunsListgRsPgR();
G__setgvp((long)gvp);
}
}
G__setnull(result7);
return(1 || funcname || hash || result7 || libp) ;
}
/* vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >::iterator */
static int G__TGoodRunsListsCint_532_0_1(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >::iterator* p = NULL;
char* gvp = (char*) G__getgvp();
int n = G__getaryconstruct();
if (n) {
if ((gvp == (char*)G__PVOID) || (gvp == 0)) {
p = new vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >::iterator[n];
} else {
p = new((void*) gvp) vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >::iterator[n];
}
} else {
if ((gvp == (char*)G__PVOID) || (gvp == 0)) {
p = new vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >::iterator;
} else {
p = new((void*) gvp) vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >::iterator;
}
}
result7->obj.i = (long) p;
result7->ref = (long) p;
G__set_tagnum(result7,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_vectorlERootcLcLTGoodRunsListcOallocatorlERootcLcLTGoodRunsListgRsPgRcLcLiterator));
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_532_0_2(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >::iterator* p = NULL;
char* gvp = (char*) G__getgvp();
//m: 1
if ((gvp == (char*)G__PVOID) || (gvp == 0)) {
p = new vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >::iterator(libp->para[0].ref ? *(const vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >::iterator::pointer*) libp->para[0].ref : *(const vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >::iterator::pointer*) (void*) (&G__Mlong(libp->para[0])));
} else {
p = new((void*) gvp) vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >::iterator(libp->para[0].ref ? *(const vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >::iterator::pointer*) libp->para[0].ref : *(const vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >::iterator::pointer*) (void*) (&G__Mlong(libp->para[0])));
}
result7->obj.i = (long) p;
result7->ref = (long) p;
G__set_tagnum(result7,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_vectorlERootcLcLTGoodRunsListcOallocatorlERootcLcLTGoodRunsListgRsPgRcLcLiterator));
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_532_0_3(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
{
const vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >::iterator::reference obj = ((const vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >::iterator*) G__getstructoffset())->operator*();
result7->ref = (long) (&obj);
result7->obj.i = (long) (&obj);
}
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_532_0_4(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
G__letint(result7, 85, (long) ((const vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >::iterator*) G__getstructoffset())->operator->());
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_532_0_5(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
{
const vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >::iterator& obj = ((vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >::iterator*) G__getstructoffset())->operator++();
result7->ref = (long) (&obj);
result7->obj.i = (long) (&obj);
}
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_532_0_6(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
{
vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >::iterator* pobj;
vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >::iterator xobj = ((vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >::iterator*) G__getstructoffset())->operator++((int) G__int(libp->para[0]));
pobj = new vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >::iterator(xobj);
result7->obj.i = (long) ((void*) pobj);
result7->ref = result7->obj.i;
G__store_tempobject(*result7);
}
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_532_0_7(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
{
const vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >::iterator& obj = ((vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >::iterator*) G__getstructoffset())->operator--();
result7->ref = (long) (&obj);
result7->obj.i = (long) (&obj);
}
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_532_0_8(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
{
vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >::iterator* pobj;
vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >::iterator xobj = ((vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >::iterator*) G__getstructoffset())->operator--((int) G__int(libp->para[0]));
pobj = new vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >::iterator(xobj);
result7->obj.i = (long) ((void*) pobj);
result7->ref = result7->obj.i;
G__store_tempobject(*result7);
}
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_532_0_9(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
{
const vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >::iterator::reference obj = ((const vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >::iterator*) G__getstructoffset())->operator[](*(vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >::iterator::difference_type*) G__Longref(&libp->para[0]));
result7->ref = (long) (&obj);
result7->obj.i = (long) (&obj);
}
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_532_0_10(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
{
const vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >::iterator& obj = ((vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >::iterator*) G__getstructoffset())->operator+=(*(vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >::iterator::difference_type*) G__Longref(&libp->para[0]));
result7->ref = (long) (&obj);
result7->obj.i = (long) (&obj);
}
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_532_0_11(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
{
const vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >::iterator* pobj;
const vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >::iterator xobj = ((const vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >::iterator*) G__getstructoffset())->operator+(*(vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >::iterator::difference_type*) G__Longref(&libp->para[0]));
pobj = new vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >::iterator(xobj);
result7->obj.i = (long) ((void*) pobj);
result7->ref = result7->obj.i;
G__store_tempobject(*result7);
}
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_532_0_12(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
{
const vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >::iterator& obj = ((vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >::iterator*) G__getstructoffset())->operator-=(*(vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >::iterator::difference_type*) G__Longref(&libp->para[0]));
result7->ref = (long) (&obj);
result7->obj.i = (long) (&obj);
}
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_532_0_13(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
{
const vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >::iterator* pobj;
const vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >::iterator xobj = ((const vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >::iterator*) G__getstructoffset())->operator-(*(vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >::iterator::difference_type*) G__Longref(&libp->para[0]));
pobj = new vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >::iterator(xobj);
result7->obj.i = (long) ((void*) pobj);
result7->ref = result7->obj.i;
G__store_tempobject(*result7);
}
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_532_0_14(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
{
const vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >::iterator::pointer& obj = ((const vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >::iterator*) G__getstructoffset())->base();
result7->ref = (long) (&obj);
G__letint(result7, 'U', (long)obj);
}
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_532_0_15(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
{
vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >::iterator* pobj;
vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >::iterator xobj = ((vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >::iterator*) G__getstructoffset())->operator=(*(vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >::iterator*) libp->para[0].ref);
pobj = new vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >::iterator(xobj);
result7->obj.i = (long) ((void*) pobj);
result7->ref = result7->obj.i;
G__store_tempobject(*result7);
}
return(1 || funcname || hash || result7 || libp) ;
}
// automatic copy constructor
static int G__TGoodRunsListsCint_532_0_16(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >::iterator* p;
void* tmp = (void*) G__int(libp->para[0]);
p = new vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >::iterator(*(vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >::iterator*) tmp);
result7->obj.i = (long) p;
result7->ref = (long) p;
G__set_tagnum(result7,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_vectorlERootcLcLTGoodRunsListcOallocatorlERootcLcLTGoodRunsListgRsPgRcLcLiterator));
return(1 || funcname || hash || result7 || libp) ;
}
// automatic destructor
typedef vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >::iterator G__TvectorlERootcLcLTGoodRunsListcOallocatorlERootcLcLTGoodRunsListgRsPgRcLcLiterator;
static int G__TGoodRunsListsCint_532_0_17(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
char* gvp = (char*) G__getgvp();
long soff = G__getstructoffset();
int n = G__getaryconstruct();
//
//has_a_delete: 0
//has_own_delete1arg: 0
//has_own_delete2arg: 0
//
if (!soff) {
return(1);
}
if (n) {
if (gvp == (char*)G__PVOID) {
delete[] (vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >::iterator*) soff;
} else {
G__setgvp((long) G__PVOID);
for (int i = n - 1; i >= 0; --i) {
((vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >::iterator*) (soff+(sizeof(vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >::iterator)*i)))->~G__TvectorlERootcLcLTGoodRunsListcOallocatorlERootcLcLTGoodRunsListgRsPgRcLcLiterator();
}
G__setgvp((long)gvp);
}
} else {
if (gvp == (char*)G__PVOID) {
delete (vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >::iterator*) soff;
} else {
G__setgvp((long) G__PVOID);
((vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >::iterator*) (soff))->~G__TvectorlERootcLcLTGoodRunsListcOallocatorlERootcLcLTGoodRunsListgRsPgRcLcLiterator();
G__setgvp((long)gvp);
}
}
G__setnull(result7);
return(1 || funcname || hash || result7 || libp) ;
}
/* Root::TGoodRunsListWriter */
static int G__TGoodRunsListsCint_535_0_1(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
Root::TGoodRunsListWriter* p = NULL;
char* gvp = (char*) G__getgvp();
int n = G__getaryconstruct();
if (n) {
if ((gvp == (char*)G__PVOID) || (gvp == 0)) {
p = new Root::TGoodRunsListWriter[n];
} else {
p = new((void*) gvp) Root::TGoodRunsListWriter[n];
}
} else {
if ((gvp == (char*)G__PVOID) || (gvp == 0)) {
p = new Root::TGoodRunsListWriter;
} else {
p = new((void*) gvp) Root::TGoodRunsListWriter;
}
}
result7->obj.i = (long) p;
result7->ref = (long) p;
G__set_tagnum(result7,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_RootcLcLTGoodRunsListWriter));
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_535_0_2(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
Root::TGoodRunsListWriter* p = NULL;
char* gvp = (char*) G__getgvp();
//m: 2
if ((gvp == (char*)G__PVOID) || (gvp == 0)) {
p = new Root::TGoodRunsListWriter(*(Root::TGoodRunsList*) libp->para[0].ref, *(TString*) libp->para[1].ref);
} else {
p = new((void*) gvp) Root::TGoodRunsListWriter(*(Root::TGoodRunsList*) libp->para[0].ref, *(TString*) libp->para[1].ref);
}
result7->obj.i = (long) p;
result7->ref = (long) p;
G__set_tagnum(result7,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_RootcLcLTGoodRunsListWriter));
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_535_0_3(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
G__letint(result7, 103, (long) ((Root::TGoodRunsListWriter*) G__getstructoffset())->WriteXMLFile());
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_535_0_4(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
G__letint(result7, 103, (long) ((Root::TGoodRunsListWriter*) G__getstructoffset())->WriteXMLFiles());
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_535_0_5(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
{
const TString& obj = ((Root::TGoodRunsListWriter*) G__getstructoffset())->GetXMLString();
result7->ref = (long) (&obj);
result7->obj.i = (long) (&obj);
}
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_535_0_6(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
{
const vector<TString>& obj = ((Root::TGoodRunsListWriter*) G__getstructoffset())->GetXMLStrings();
result7->ref = (long) (&obj);
result7->obj.i = (long) (&obj);
}
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_535_0_7(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
{
const TString& obj = ((const Root::TGoodRunsListWriter*) G__getstructoffset())->GetFilename();
result7->ref = (long) (&obj);
result7->obj.i = (long) (&obj);
}
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_535_0_8(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
switch (libp->paran) {
case 1:
{
const Root::TGoodRunsList* pobj;
const Root::TGoodRunsList xobj = ((const Root::TGoodRunsListWriter*) G__getstructoffset())->GetMergedGoodRunsList(*(Root::BoolOperation*) libp->para[0].ref);
pobj = new Root::TGoodRunsList(xobj);
result7->obj.i = (long) ((void*) pobj);
result7->ref = result7->obj.i;
G__store_tempobject(*result7);
}
break;
case 0:
{
const Root::TGoodRunsList* pobj;
const Root::TGoodRunsList xobj = ((const Root::TGoodRunsListWriter*) G__getstructoffset())->GetMergedGoodRunsList();
pobj = new Root::TGoodRunsList(xobj);
result7->obj.i = (long) ((void*) pobj);
result7->ref = result7->obj.i;
G__store_tempobject(*result7);
}
break;
}
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_535_0_9(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
{
const Root::TGRLCollection& obj = ((const Root::TGoodRunsListWriter*) G__getstructoffset())->GetGRLCollection();
result7->ref = (long) (&obj);
result7->obj.i = (long) (&obj);
}
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_535_0_10(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
switch (libp->paran) {
case 1:
((Root::TGoodRunsListWriter*) G__getstructoffset())->SetMergeGoodRunsLists((bool) G__int(libp->para[0]));
G__setnull(result7);
break;
case 0:
((Root::TGoodRunsListWriter*) G__getstructoffset())->SetMergeGoodRunsLists();
G__setnull(result7);
break;
}
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_535_0_11(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
switch (libp->paran) {
case 1:
((Root::TGoodRunsListWriter*) G__getstructoffset())->SetCheckGRLInfo((bool) G__int(libp->para[0]));
G__setnull(result7);
break;
case 0:
((Root::TGoodRunsListWriter*) G__getstructoffset())->SetCheckGRLInfo();
G__setnull(result7);
break;
}
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_535_0_12(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
switch (libp->paran) {
case 1:
((Root::TGoodRunsListWriter*) G__getstructoffset())->SetIndividuals((bool) G__int(libp->para[0]));
G__setnull(result7);
break;
case 0:
((Root::TGoodRunsListWriter*) G__getstructoffset())->SetIndividuals();
G__setnull(result7);
break;
}
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_535_0_13(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
((Root::TGoodRunsListWriter*) G__getstructoffset())->SetGRLCollection(*(Root::TGRLCollection*) libp->para[0].ref);
G__setnull(result7);
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_535_0_14(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
((Root::TGoodRunsListWriter*) G__getstructoffset())->SetGoodRunsList(*(Root::TGoodRunsList*) libp->para[0].ref);
G__setnull(result7);
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_535_0_15(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
((Root::TGoodRunsListWriter*) G__getstructoffset())->SetFilename(*(TString*) libp->para[0].ref);
G__setnull(result7);
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_535_0_16(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
((Root::TGoodRunsListWriter*) G__getstructoffset())->SetPrefix(*(TString*) libp->para[0].ref);
G__setnull(result7);
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_535_0_17(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
((Root::TGoodRunsListWriter*) G__getstructoffset())->AddGoodRunsList(*(Root::TGoodRunsList*) libp->para[0].ref);
G__setnull(result7);
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_535_0_25(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
G__letint(result7, 85, (long) Root::TGoodRunsListWriter::Class());
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_535_0_26(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
G__letint(result7, 67, (long) Root::TGoodRunsListWriter::Class_Name());
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_535_0_27(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
G__letint(result7, 115, (long) Root::TGoodRunsListWriter::Class_Version());
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_535_0_28(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
Root::TGoodRunsListWriter::Dictionary();
G__setnull(result7);
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_535_0_32(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
((Root::TGoodRunsListWriter*) G__getstructoffset())->StreamerNVirtual(*(TBuffer*) libp->para[0].ref);
G__setnull(result7);
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_535_0_33(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
G__letint(result7, 67, (long) Root::TGoodRunsListWriter::DeclFileName());
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_535_0_34(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
G__letint(result7, 105, (long) Root::TGoodRunsListWriter::ImplFileLine());
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_535_0_35(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
G__letint(result7, 67, (long) Root::TGoodRunsListWriter::ImplFileName());
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_535_0_36(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
G__letint(result7, 105, (long) Root::TGoodRunsListWriter::DeclFileLine());
return(1 || funcname || hash || result7 || libp) ;
}
// automatic destructor
typedef Root::TGoodRunsListWriter G__TRootcLcLTGoodRunsListWriter;
static int G__TGoodRunsListsCint_535_0_37(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
char* gvp = (char*) G__getgvp();
long soff = G__getstructoffset();
int n = G__getaryconstruct();
//
//has_a_delete: 1
//has_own_delete1arg: 0
//has_own_delete2arg: 0
//
if (!soff) {
return(1);
}
if (n) {
if (gvp == (char*)G__PVOID) {
delete[] (Root::TGoodRunsListWriter*) soff;
} else {
G__setgvp((long) G__PVOID);
for (int i = n - 1; i >= 0; --i) {
((Root::TGoodRunsListWriter*) (soff+(sizeof(Root::TGoodRunsListWriter)*i)))->~G__TRootcLcLTGoodRunsListWriter();
}
G__setgvp((long)gvp);
}
} else {
if (gvp == (char*)G__PVOID) {
delete (Root::TGoodRunsListWriter*) soff;
} else {
G__setgvp((long) G__PVOID);
((Root::TGoodRunsListWriter*) (soff))->~G__TRootcLcLTGoodRunsListWriter();
G__setgvp((long)gvp);
}
}
G__setnull(result7);
return(1 || funcname || hash || result7 || libp) ;
}
/* Root::TGoodRunsListReader */
static int G__TGoodRunsListsCint_541_0_1(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
Root::TGoodRunsListReader* p = NULL;
char* gvp = (char*) G__getgvp();
switch (libp->paran) {
case 1:
//m: 1
if ((gvp == (char*)G__PVOID) || (gvp == 0)) {
p = new Root::TGoodRunsListReader((Bool_t) G__int(libp->para[0]));
} else {
p = new((void*) gvp) Root::TGoodRunsListReader((Bool_t) G__int(libp->para[0]));
}
break;
case 0:
int n = G__getaryconstruct();
if (n) {
if ((gvp == (char*)G__PVOID) || (gvp == 0)) {
p = new Root::TGoodRunsListReader[n];
} else {
p = new((void*) gvp) Root::TGoodRunsListReader[n];
}
} else {
if ((gvp == (char*)G__PVOID) || (gvp == 0)) {
p = new Root::TGoodRunsListReader;
} else {
p = new((void*) gvp) Root::TGoodRunsListReader;
}
}
break;
}
result7->obj.i = (long) p;
result7->ref = (long) p;
G__set_tagnum(result7,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_RootcLcLTGoodRunsListReader));
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_541_0_2(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
Root::TGoodRunsListReader* p = NULL;
char* gvp = (char*) G__getgvp();
switch (libp->paran) {
case 2:
//m: 2
if ((gvp == (char*)G__PVOID) || (gvp == 0)) {
p = new Root::TGoodRunsListReader(*(TString*) libp->para[0].ref, (Bool_t) G__int(libp->para[1]));
} else {
p = new((void*) gvp) Root::TGoodRunsListReader(*(TString*) libp->para[0].ref, (Bool_t) G__int(libp->para[1]));
}
break;
case 1:
//m: 1
if ((gvp == (char*)G__PVOID) || (gvp == 0)) {
p = new Root::TGoodRunsListReader(*(TString*) libp->para[0].ref);
} else {
p = new((void*) gvp) Root::TGoodRunsListReader(*(TString*) libp->para[0].ref);
}
break;
}
result7->obj.i = (long) p;
result7->ref = (long) p;
G__set_tagnum(result7,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_RootcLcLTGoodRunsListReader));
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_541_0_3(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
G__letint(result7, 103, (long) ((Root::TGoodRunsListReader*) G__getstructoffset())->Interpret());
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_541_0_4(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
{
const TString& obj = ((const Root::TGoodRunsListReader*) G__getstructoffset())->GetXMLString();
result7->ref = (long) (&obj);
result7->obj.i = (long) (&obj);
}
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_541_0_5(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
{
const TString& obj = ((const Root::TGoodRunsListReader*) G__getstructoffset())->GetXMLFilename();
result7->ref = (long) (&obj);
result7->obj.i = (long) (&obj);
}
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_541_0_6(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
((Root::TGoodRunsListReader*) G__getstructoffset())->AddXMLFile(*(TString*) libp->para[0].ref);
G__setnull(result7);
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_541_0_7(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
((Root::TGoodRunsListReader*) G__getstructoffset())->AddXMLString(*(TString*) libp->para[0].ref);
G__setnull(result7);
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_541_0_8(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
((Root::TGoodRunsListReader*) G__getstructoffset())->SetXMLString(*(TString*) libp->para[0].ref);
G__setnull(result7);
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_541_0_9(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
((Root::TGoodRunsListReader*) G__getstructoffset())->SetXMLFile(*(TString*) libp->para[0].ref);
G__setnull(result7);
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_541_0_10(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
switch (libp->paran) {
case 1:
((Root::TGoodRunsListReader*) G__getstructoffset())->SetCheckGRLInfo((Bool_t) G__int(libp->para[0]));
G__setnull(result7);
break;
case 0:
((Root::TGoodRunsListReader*) G__getstructoffset())->SetCheckGRLInfo();
G__setnull(result7);
break;
}
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_541_0_11(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
switch (libp->paran) {
case 1:
{
const Root::TGoodRunsList* pobj;
const Root::TGoodRunsList xobj = ((const Root::TGoodRunsListReader*) G__getstructoffset())->GetMergedGoodRunsList(*(Root::BoolOperation*) libp->para[0].ref);
pobj = new Root::TGoodRunsList(xobj);
result7->obj.i = (long) ((void*) pobj);
result7->ref = result7->obj.i;
G__store_tempobject(*result7);
}
break;
case 0:
{
const Root::TGoodRunsList* pobj;
const Root::TGoodRunsList xobj = ((const Root::TGoodRunsListReader*) G__getstructoffset())->GetMergedGoodRunsList();
pobj = new Root::TGoodRunsList(xobj);
result7->obj.i = (long) ((void*) pobj);
result7->ref = result7->obj.i;
G__store_tempobject(*result7);
}
break;
}
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_541_0_12(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
{
const Root::TGoodRunsList* pobj;
const Root::TGoodRunsList xobj = ((const Root::TGoodRunsListReader*) G__getstructoffset())->GetGoodRunsList((unsigned int) G__int(libp->para[0]));
pobj = new Root::TGoodRunsList(xobj);
result7->obj.i = (long) ((void*) pobj);
result7->ref = result7->obj.i;
G__store_tempobject(*result7);
}
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_541_0_13(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
{
const Root::TGRLCollection* pobj;
const Root::TGRLCollection xobj = ((const Root::TGoodRunsListReader*) G__getstructoffset())->GetGRLCollection();
pobj = new Root::TGRLCollection(xobj);
result7->obj.i = (long) ((void*) pobj);
result7->ref = result7->obj.i;
G__store_tempobject(*result7);
}
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_541_0_14(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
switch (libp->paran) {
case 1:
{
const Root::TGRLCollection* pobj;
const Root::TGRLCollection xobj = ((const Root::TGoodRunsListReader*) G__getstructoffset())->GetMergedGRLCollection(*(Root::BoolOperation*) libp->para[0].ref);
pobj = new Root::TGRLCollection(xobj);
result7->obj.i = (long) ((void*) pobj);
result7->ref = result7->obj.i;
G__store_tempobject(*result7);
}
break;
case 0:
{
const Root::TGRLCollection* pobj;
const Root::TGRLCollection xobj = ((const Root::TGoodRunsListReader*) G__getstructoffset())->GetMergedGRLCollection();
pobj = new Root::TGRLCollection(xobj);
result7->obj.i = (long) ((void*) pobj);
result7->ref = result7->obj.i;
G__store_tempobject(*result7);
}
break;
}
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_541_0_15(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
((Root::TGoodRunsListReader*) G__getstructoffset())->Reset();
G__setnull(result7);
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_541_0_20(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
G__letint(result7, 85, (long) Root::TGoodRunsListReader::Class());
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_541_0_21(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
G__letint(result7, 67, (long) Root::TGoodRunsListReader::Class_Name());
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_541_0_22(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
G__letint(result7, 115, (long) Root::TGoodRunsListReader::Class_Version());
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_541_0_23(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
Root::TGoodRunsListReader::Dictionary();
G__setnull(result7);
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_541_0_27(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
((Root::TGoodRunsListReader*) G__getstructoffset())->StreamerNVirtual(*(TBuffer*) libp->para[0].ref);
G__setnull(result7);
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_541_0_28(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
G__letint(result7, 67, (long) Root::TGoodRunsListReader::DeclFileName());
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_541_0_29(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
G__letint(result7, 105, (long) Root::TGoodRunsListReader::ImplFileLine());
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_541_0_30(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
G__letint(result7, 67, (long) Root::TGoodRunsListReader::ImplFileName());
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_541_0_31(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
G__letint(result7, 105, (long) Root::TGoodRunsListReader::DeclFileLine());
return(1 || funcname || hash || result7 || libp) ;
}
// automatic destructor
typedef Root::TGoodRunsListReader G__TRootcLcLTGoodRunsListReader;
static int G__TGoodRunsListsCint_541_0_32(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
char* gvp = (char*) G__getgvp();
long soff = G__getstructoffset();
int n = G__getaryconstruct();
//
//has_a_delete: 1
//has_own_delete1arg: 0
//has_own_delete2arg: 0
//
if (!soff) {
return(1);
}
if (n) {
if (gvp == (char*)G__PVOID) {
delete[] (Root::TGoodRunsListReader*) soff;
} else {
G__setgvp((long) G__PVOID);
for (int i = n - 1; i >= 0; --i) {
((Root::TGoodRunsListReader*) (soff+(sizeof(Root::TGoodRunsListReader)*i)))->~G__TRootcLcLTGoodRunsListReader();
}
G__setgvp((long)gvp);
}
} else {
if (gvp == (char*)G__PVOID) {
delete (Root::TGoodRunsListReader*) soff;
} else {
G__setgvp((long) G__PVOID);
((Root::TGoodRunsListReader*) (soff))->~G__TRootcLcLTGoodRunsListReader();
G__setgvp((long)gvp);
}
}
G__setnull(result7);
return(1 || funcname || hash || result7 || libp) ;
}
/* DQ */
static int G__TGoodRunsListsCint_542_0_1(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
DQ::SetXMLFile(*(TString*) libp->para[0].ref);
G__setnull(result7);
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_542_0_2(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
{
const Root::TGoodRunsList& obj = DQ::GetGRL();
result7->ref = (long) (&obj);
result7->obj.i = (long) (&obj);
}
return(1 || funcname || hash || result7 || libp) ;
}
static int G__TGoodRunsListsCint_542_0_3(G__value* result7, G__CONST char* funcname, struct G__param* libp, int hash)
{
G__letint(result7, 103, (long) DQ::PassRunLB((int) G__int(libp->para[0]), (int) G__int(libp->para[1])));
return(1 || funcname || hash || result7 || libp) ;
}
/* Setting up global function */
/*********************************************************
* Member function Stub
*********************************************************/
/* Root */
/* Root::RegularFormula */
/* Root::TLumiBlockRange */
/* vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> > */
/* vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >::iterator */
/* Root::TGoodRun */
/* Root::TGoodRunsList */
/* map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > > */
/* pair<int,Root::TGoodRun> */
/* map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > >::iterator */
/* map<TString,TString,less<TString>,allocator<pair<const TString,TString> > > */
/* pair<TString,TString> */
/* vector<Root::TGoodRun,allocator<Root::TGoodRun> > */
/* vector<Root::TGoodRun,allocator<Root::TGoodRun> >::iterator */
/* Root::TGRLCollection */
/* vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> > */
/* vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >::iterator */
/* Root::TGoodRunsListWriter */
/* Root::TGoodRunsListReader */
/* DQ */
/*********************************************************
* Global function Stub
*********************************************************/
/*********************************************************
* Get size of pointer to member function
*********************************************************/
class G__Sizep2memfuncTGoodRunsListsCint {
public:
G__Sizep2memfuncTGoodRunsListsCint(): p(&G__Sizep2memfuncTGoodRunsListsCint::sizep2memfunc) {}
size_t sizep2memfunc() { return(sizeof(p)); }
private:
size_t (G__Sizep2memfuncTGoodRunsListsCint::*p)();
};
size_t G__get_sizep2memfuncTGoodRunsListsCint()
{
G__Sizep2memfuncTGoodRunsListsCint a;
G__setsizep2memfunc((int)a.sizep2memfunc());
return((size_t)a.sizep2memfunc());
}
/*********************************************************
* virtual base class offset calculation interface
*********************************************************/
/* Setting up class inheritance */
/*********************************************************
* Inheritance information setup/
*********************************************************/
extern "C" void G__cpp_setup_inheritanceTGoodRunsListsCint() {
/* Setting up class inheritance */
if(0==G__getnumbaseclass(G__get_linked_tagnum(&G__TGoodRunsListsCintLN_RootcLcLRegularFormula))) {
Root::RegularFormula *G__Lderived;
G__Lderived=(Root::RegularFormula*)0x1000;
{
TFormula *G__Lpbase=(TFormula*)G__Lderived;
G__inheritance_setup(G__get_linked_tagnum(&G__TGoodRunsListsCintLN_RootcLcLRegularFormula),G__get_linked_tagnum(&G__TGoodRunsListsCintLN_TFormula),(long)G__Lpbase-(long)G__Lderived,1,1);
}
{
TNamed *G__Lpbase=(TNamed*)G__Lderived;
G__inheritance_setup(G__get_linked_tagnum(&G__TGoodRunsListsCintLN_RootcLcLRegularFormula),G__get_linked_tagnum(&G__TGoodRunsListsCintLN_TNamed),(long)G__Lpbase-(long)G__Lderived,1,0);
}
{
TObject *G__Lpbase=(TObject*)G__Lderived;
G__inheritance_setup(G__get_linked_tagnum(&G__TGoodRunsListsCintLN_RootcLcLRegularFormula),G__get_linked_tagnum(&G__TGoodRunsListsCintLN_TObject),(long)G__Lpbase-(long)G__Lderived,1,0);
}
}
if(0==G__getnumbaseclass(G__get_linked_tagnum(&G__TGoodRunsListsCintLN_RootcLcLTLumiBlockRange))) {
Root::TLumiBlockRange *G__Lderived;
G__Lderived=(Root::TLumiBlockRange*)0x1000;
{
TObject *G__Lpbase=(TObject*)G__Lderived;
G__inheritance_setup(G__get_linked_tagnum(&G__TGoodRunsListsCintLN_RootcLcLTLumiBlockRange),G__get_linked_tagnum(&G__TGoodRunsListsCintLN_TObject),(long)G__Lpbase-(long)G__Lderived,1,1);
}
}
if(0==G__getnumbaseclass(G__get_linked_tagnum(&G__TGoodRunsListsCintLN_RootcLcLTGoodRun))) {
Root::TGoodRun *G__Lderived;
G__Lderived=(Root::TGoodRun*)0x1000;
{
vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> > *G__Lpbase=(vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >*)G__Lderived;
G__inheritance_setup(G__get_linked_tagnum(&G__TGoodRunsListsCintLN_RootcLcLTGoodRun),G__get_linked_tagnum(&G__TGoodRunsListsCintLN_vectorlERootcLcLTLumiBlockRangecOallocatorlERootcLcLTLumiBlockRangegRsPgR),(long)G__Lpbase-(long)G__Lderived,1,1);
}
{
TObject *G__Lpbase=(TObject*)G__Lderived;
G__inheritance_setup(G__get_linked_tagnum(&G__TGoodRunsListsCintLN_RootcLcLTGoodRun),G__get_linked_tagnum(&G__TGoodRunsListsCintLN_TObject),(long)G__Lpbase-(long)G__Lderived,1,1);
}
}
if(0==G__getnumbaseclass(G__get_linked_tagnum(&G__TGoodRunsListsCintLN_RootcLcLTGoodRunsList))) {
Root::TGoodRunsList *G__Lderived;
G__Lderived=(Root::TGoodRunsList*)0x1000;
{
map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > > *G__Lpbase=(map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > >*)G__Lderived;
G__inheritance_setup(G__get_linked_tagnum(&G__TGoodRunsListsCintLN_RootcLcLTGoodRunsList),G__get_linked_tagnum(&G__TGoodRunsListsCintLN_maplEintcORootcLcLTGoodRuncOlesslEintgRcOallocatorlEpairlEconstsPintcORootcLcLTGoodRungRsPgRsPgR),(long)G__Lpbase-(long)G__Lderived,1,1);
}
{
TNamed *G__Lpbase=(TNamed*)G__Lderived;
G__inheritance_setup(G__get_linked_tagnum(&G__TGoodRunsListsCintLN_RootcLcLTGoodRunsList),G__get_linked_tagnum(&G__TGoodRunsListsCintLN_TNamed),(long)G__Lpbase-(long)G__Lderived,1,1);
}
{
TObject *G__Lpbase=(TObject*)G__Lderived;
G__inheritance_setup(G__get_linked_tagnum(&G__TGoodRunsListsCintLN_RootcLcLTGoodRunsList),G__get_linked_tagnum(&G__TGoodRunsListsCintLN_TObject),(long)G__Lpbase-(long)G__Lderived,1,0);
}
}
if(0==G__getnumbaseclass(G__get_linked_tagnum(&G__TGoodRunsListsCintLN_RootcLcLTGRLCollection))) {
Root::TGRLCollection *G__Lderived;
G__Lderived=(Root::TGRLCollection*)0x1000;
{
vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> > *G__Lpbase=(vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >*)G__Lderived;
G__inheritance_setup(G__get_linked_tagnum(&G__TGoodRunsListsCintLN_RootcLcLTGRLCollection),G__get_linked_tagnum(&G__TGoodRunsListsCintLN_vectorlERootcLcLTGoodRunsListcOallocatorlERootcLcLTGoodRunsListgRsPgR),(long)G__Lpbase-(long)G__Lderived,1,1);
}
{
TObject *G__Lpbase=(TObject*)G__Lderived;
G__inheritance_setup(G__get_linked_tagnum(&G__TGoodRunsListsCintLN_RootcLcLTGRLCollection),G__get_linked_tagnum(&G__TGoodRunsListsCintLN_TObject),(long)G__Lpbase-(long)G__Lderived,1,1);
}
}
if(0==G__getnumbaseclass(G__get_linked_tagnum(&G__TGoodRunsListsCintLN_RootcLcLTGoodRunsListWriter))) {
Root::TGoodRunsListWriter *G__Lderived;
G__Lderived=(Root::TGoodRunsListWriter*)0x1000;
{
TObject *G__Lpbase=(TObject*)G__Lderived;
G__inheritance_setup(G__get_linked_tagnum(&G__TGoodRunsListsCintLN_RootcLcLTGoodRunsListWriter),G__get_linked_tagnum(&G__TGoodRunsListsCintLN_TObject),(long)G__Lpbase-(long)G__Lderived,1,1);
}
}
if(0==G__getnumbaseclass(G__get_linked_tagnum(&G__TGoodRunsListsCintLN_RootcLcLTGoodRunsListReader))) {
Root::TGoodRunsListReader *G__Lderived;
G__Lderived=(Root::TGoodRunsListReader*)0x1000;
{
TObject *G__Lpbase=(TObject*)G__Lderived;
G__inheritance_setup(G__get_linked_tagnum(&G__TGoodRunsListsCintLN_RootcLcLTGoodRunsListReader),G__get_linked_tagnum(&G__TGoodRunsListsCintLN_TObject),(long)G__Lpbase-(long)G__Lderived,1,1);
}
}
}
/*********************************************************
* typedef information setup/
*********************************************************/
extern "C" void G__cpp_setup_typetableTGoodRunsListsCint() {
/* Setting up typedef entry */
G__search_typename2("Int_t",105,-1,0,-1);
G__setnewtype(-1,"Signed integer 4 bytes (int)",0);
G__search_typename2("Bool_t",103,-1,0,-1);
G__setnewtype(-1,"Boolean (0=false, 1=true) (bool)",0);
G__search_typename2("Version_t",115,-1,0,-1);
G__setnewtype(-1,"Class version identifier (short)",0);
G__search_typename2("vector<ROOT::TSchemaHelper>",117,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_vectorlEROOTcLcLTSchemaHelpercOallocatorlEROOTcLcLTSchemaHelpergRsPgR),0,-1);
G__setnewtype(-1,NULL,0);
G__search_typename2("reverse_iterator<const_iterator>",117,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_reverse_iteratorlEvectorlEROOTcLcLTSchemaHelpercOallocatorlEROOTcLcLTSchemaHelpergRsPgRcLcLiteratorgR),0,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_vectorlEROOTcLcLTSchemaHelpercOallocatorlEROOTcLcLTSchemaHelpergRsPgR));
G__setnewtype(-1,NULL,0);
G__search_typename2("reverse_iterator<iterator>",117,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_reverse_iteratorlEvectorlEROOTcLcLTSchemaHelpercOallocatorlEROOTcLcLTSchemaHelpergRsPgRcLcLiteratorgR),0,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_vectorlEROOTcLcLTSchemaHelpercOallocatorlEROOTcLcLTSchemaHelpergRsPgR));
G__setnewtype(-1,NULL,0);
G__search_typename2("vector<TVirtualArray*>",117,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_vectorlETVirtualArraymUcOallocatorlETVirtualArraymUgRsPgR),0,-1);
G__setnewtype(-1,NULL,0);
G__search_typename2("reverse_iterator<const_iterator>",117,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_reverse_iteratorlEvectorlETVirtualArraymUcOallocatorlETVirtualArraymUgRsPgRcLcLiteratorgR),0,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_vectorlETVirtualArraymUcOallocatorlETVirtualArraymUgRsPgR));
G__setnewtype(-1,NULL,0);
G__search_typename2("reverse_iterator<iterator>",117,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_reverse_iteratorlEvectorlETVirtualArraymUcOallocatorlETVirtualArraymUgRsPgRcLcLiteratorgR),0,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_vectorlETVirtualArraymUcOallocatorlETVirtualArraymUgRsPgR));
G__setnewtype(-1,NULL,0);
G__search_typename2("iterator<std::bidirectional_iterator_tag,TObject*,std::ptrdiff_t,const TObject**,const TObject*&>",117,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_iteratorlEbidirectional_iterator_tagcOTObjectmUcOlongcOconstsPTObjectmUmUcOconstsPTObjectmUaNgR),0,-1);
G__setnewtype(-1,NULL,0);
G__search_typename2("iterator<bidirectional_iterator_tag,TObject*>",117,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_iteratorlEbidirectional_iterator_tagcOTObjectmUcOlongcOconstsPTObjectmUmUcOconstsPTObjectmUaNgR),0,-1);
G__setnewtype(-1,NULL,0);
G__search_typename2("iterator<bidirectional_iterator_tag,TObject*,long>",117,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_iteratorlEbidirectional_iterator_tagcOTObjectmUcOlongcOconstsPTObjectmUmUcOconstsPTObjectmUaNgR),0,-1);
G__setnewtype(-1,NULL,0);
G__search_typename2("iterator<bidirectional_iterator_tag,TObject*,long,const TObject**>",117,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_iteratorlEbidirectional_iterator_tagcOTObjectmUcOlongcOconstsPTObjectmUmUcOconstsPTObjectmUaNgR),0,-1);
G__setnewtype(-1,NULL,0);
G__search_typename2("list<TString>",117,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_listlETStringcOallocatorlETStringgRsPgR),0,-1);
G__setnewtype(-1,NULL,0);
G__search_typename2("vector<string>",117,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_vectorlEstringcOallocatorlEstringgRsPgR),0,-1);
G__setnewtype(-1,NULL,0);
G__search_typename2("reverse_iterator<const_iterator>",117,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_reverse_iteratorlEvectorlEstringcOallocatorlEstringgRsPgRcLcLiteratorgR),0,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_vectorlEstringcOallocatorlEstringgRsPgR));
G__setnewtype(-1,NULL,0);
G__search_typename2("reverse_iterator<iterator>",117,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_reverse_iteratorlEvectorlEstringcOallocatorlEstringgRsPgRcLcLiteratorgR),0,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_vectorlEstringcOallocatorlEstringgRsPgR));
G__setnewtype(-1,NULL,0);
G__search_typename2("map<TMsgLevel,std::string>",117,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_maplERootcLcLTMsgLevelcOstringcOlesslERootcLcLTMsgLevelgRcOallocatorlEpairlEconstsPRootcLcLTMsgLevelcOstringgRsPgRsPgR),0,-1);
G__setnewtype(-1,NULL,0);
G__search_typename2("map<Root::TMsgLevel,string>",117,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_maplERootcLcLTMsgLevelcOstringcOlesslERootcLcLTMsgLevelgRcOallocatorlEpairlEconstsPRootcLcLTMsgLevelcOstringgRsPgRsPgR),0,-1);
G__setnewtype(-1,NULL,0);
G__search_typename2("map<Root::TMsgLevel,string,less<Root::TMsgLevel> >",117,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_maplERootcLcLTMsgLevelcOstringcOlesslERootcLcLTMsgLevelgRcOallocatorlEpairlEconstsPRootcLcLTMsgLevelcOstringgRsPgRsPgR),0,-1);
G__setnewtype(-1,NULL,0);
G__search_typename2("vector<Root::TLumiBlockRange>",117,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_vectorlERootcLcLTLumiBlockRangecOallocatorlERootcLcLTLumiBlockRangegRsPgR),0,-1);
G__setnewtype(-1,NULL,0);
G__search_typename2("value_type",117,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_RootcLcLTLumiBlockRange),0,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_vectorlERootcLcLTLumiBlockRangecOallocatorlERootcLcLTLumiBlockRangegRsPgR));
G__setnewtype(-1,NULL,0);
G__search_typename2("pointer",85,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_RootcLcLTLumiBlockRange),0,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_vectorlERootcLcLTLumiBlockRangecOallocatorlERootcLcLTLumiBlockRangegRsPgR));
G__setnewtype(-1,NULL,0);
G__search_typename2("const_pointer",85,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_RootcLcLTLumiBlockRange),256,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_vectorlERootcLcLTLumiBlockRangecOallocatorlERootcLcLTLumiBlockRangegRsPgR));
G__setnewtype(-1,NULL,0);
G__search_typename2("reference",117,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_RootcLcLTLumiBlockRange),1,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_vectorlERootcLcLTLumiBlockRangecOallocatorlERootcLcLTLumiBlockRangegRsPgR));
G__setnewtype(-1,NULL,0);
G__search_typename2("const_reference",117,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_RootcLcLTLumiBlockRange),257,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_vectorlERootcLcLTLumiBlockRangecOallocatorlERootcLcLTLumiBlockRangegRsPgR));
G__setnewtype(-1,NULL,0);
G__search_typename2("size_type",104,-1,0,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_vectorlERootcLcLTLumiBlockRangecOallocatorlERootcLcLTLumiBlockRangegRsPgR));
G__setnewtype(-1,NULL,0);
G__search_typename2("difference_type",108,-1,0,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_vectorlERootcLcLTLumiBlockRangecOallocatorlERootcLcLTLumiBlockRangegRsPgR));
G__setnewtype(-1,NULL,0);
G__search_typename2("pointer",85,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_RootcLcLTLumiBlockRange),0,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_vectorlERootcLcLTLumiBlockRangecOallocatorlERootcLcLTLumiBlockRangegRsPgRcLcLiterator));
G__setnewtype(-1,NULL,0);
G__search_typename2("const_pointer",85,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_RootcLcLTLumiBlockRange),0,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_vectorlERootcLcLTLumiBlockRangecOallocatorlERootcLcLTLumiBlockRangegRsPgRcLcLiterator));
G__setnewtype(-1,NULL,0);
G__search_typename2("reference",117,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_RootcLcLTLumiBlockRange),1,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_vectorlERootcLcLTLumiBlockRangecOallocatorlERootcLcLTLumiBlockRangegRsPgRcLcLiterator));
G__setnewtype(-1,NULL,0);
G__search_typename2("const_reference",117,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_RootcLcLTLumiBlockRange),1,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_vectorlERootcLcLTLumiBlockRangecOallocatorlERootcLcLTLumiBlockRangegRsPgRcLcLiterator));
G__setnewtype(-1,NULL,0);
G__search_typename2("size_type",104,-1,0,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_vectorlERootcLcLTLumiBlockRangecOallocatorlERootcLcLTLumiBlockRangegRsPgRcLcLiterator));
G__setnewtype(-1,NULL,0);
G__search_typename2("difference_type",108,-1,0,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_vectorlERootcLcLTLumiBlockRangecOallocatorlERootcLcLTLumiBlockRangegRsPgRcLcLiterator));
G__setnewtype(-1,NULL,0);
G__search_typename2("const_iterator",117,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_vectorlERootcLcLTLumiBlockRangecOallocatorlERootcLcLTLumiBlockRangegRsPgRcLcLiterator),256,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_vectorlERootcLcLTLumiBlockRangecOallocatorlERootcLcLTLumiBlockRangegRsPgR));
G__setnewtype(-1,NULL,0);
G__search_typename2("reverse_iterator<const_iterator>",117,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_reverse_iteratorlEvectorlERootcLcLTLumiBlockRangecOallocatorlERootcLcLTLumiBlockRangegRsPgRcLcLiteratorgR),0,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_vectorlERootcLcLTLumiBlockRangecOallocatorlERootcLcLTLumiBlockRangegRsPgR));
G__setnewtype(-1,NULL,0);
G__search_typename2("const_reverse_iterator",117,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_reverse_iteratorlEvectorlERootcLcLTLumiBlockRangecOallocatorlERootcLcLTLumiBlockRangegRsPgRcLcLiteratorgR),0,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_vectorlERootcLcLTLumiBlockRangecOallocatorlERootcLcLTLumiBlockRangegRsPgR));
G__setnewtype(-1,NULL,0);
G__search_typename2("reverse_iterator<iterator>",117,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_reverse_iteratorlEvectorlERootcLcLTLumiBlockRangecOallocatorlERootcLcLTLumiBlockRangegRsPgRcLcLiteratorgR),0,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_vectorlERootcLcLTLumiBlockRangecOallocatorlERootcLcLTLumiBlockRangegRsPgR));
G__setnewtype(-1,NULL,0);
G__search_typename2("reverse_iterator",117,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_reverse_iteratorlEvectorlERootcLcLTLumiBlockRangecOallocatorlERootcLcLTLumiBlockRangegRsPgRcLcLiteratorgR),0,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_vectorlERootcLcLTLumiBlockRangecOallocatorlERootcLcLTLumiBlockRangegRsPgR));
G__setnewtype(-1,NULL,0);
G__search_typename2("vector<TLumiBlockRange>",117,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_vectorlERootcLcLTLumiBlockRangecOallocatorlERootcLcLTLumiBlockRangegRsPgR),0,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_Root));
G__setnewtype(-1,NULL,0);
G__search_typename2("map<Int_t,TGoodRun>",117,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_maplEintcORootcLcLTGoodRuncOlesslEintgRcOallocatorlEpairlEconstsPintcORootcLcLTGoodRungRsPgRsPgR),0,-1);
G__setnewtype(-1,NULL,0);
G__search_typename2("key_type",105,-1,0,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_maplEintcORootcLcLTGoodRuncOlesslEintgRcOallocatorlEpairlEconstsPintcORootcLcLTGoodRungRsPgRsPgR));
G__setnewtype(-1,NULL,0);
G__search_typename2("mapped_type",117,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_RootcLcLTGoodRun),0,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_maplEintcORootcLcLTGoodRuncOlesslEintgRcOallocatorlEpairlEconstsPintcORootcLcLTGoodRungRsPgRsPgR));
G__setnewtype(-1,NULL,0);
G__search_typename2("value_type",117,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_pairlEintcORootcLcLTGoodRungR),0,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_maplEintcORootcLcLTGoodRuncOlesslEintgRcOallocatorlEpairlEconstsPintcORootcLcLTGoodRungRsPgRsPgR));
G__setnewtype(-1,NULL,0);
G__search_typename2("key_compare",117,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_lesslEintgR),0,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_maplEintcORootcLcLTGoodRuncOlesslEintgRcOallocatorlEpairlEconstsPintcORootcLcLTGoodRungRsPgRsPgR));
G__setnewtype(-1,NULL,0);
G__search_typename2("allocator_type",117,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_allocatorlEpairlEconstsPintcORootcLcLTGoodRungRsPgR),0,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_maplEintcORootcLcLTGoodRuncOlesslEintgRcOallocatorlEpairlEconstsPintcORootcLcLTGoodRungRsPgRsPgR));
G__setnewtype(-1,NULL,0);
G__search_typename2("size_type",104,-1,0,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_maplEintcORootcLcLTGoodRuncOlesslEintgRcOallocatorlEpairlEconstsPintcORootcLcLTGoodRungRsPgRsPgR));
G__setnewtype(-1,NULL,0);
G__search_typename2("difference_type",108,-1,0,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_maplEintcORootcLcLTGoodRuncOlesslEintgRcOallocatorlEpairlEconstsPintcORootcLcLTGoodRungRsPgRsPgR));
G__setnewtype(-1,NULL,0);
G__search_typename2("const_iterator",117,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_maplEintcORootcLcLTGoodRuncOlesslEintgRcOallocatorlEpairlEconstsPintcORootcLcLTGoodRungRsPgRsPgRcLcLiterator),256,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_maplEintcORootcLcLTGoodRuncOlesslEintgRcOallocatorlEpairlEconstsPintcORootcLcLTGoodRungRsPgRsPgR));
G__setnewtype(-1,NULL,0);
G__search_typename2("const_reverse_iterator",117,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_maplEintcORootcLcLTGoodRuncOlesslEintgRcOallocatorlEpairlEconstsPintcORootcLcLTGoodRungRsPgRsPgRcLcLreverse_iterator),256,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_maplEintcORootcLcLTGoodRuncOlesslEintgRcOallocatorlEpairlEconstsPintcORootcLcLTGoodRungRsPgRsPgR));
G__setnewtype(-1,NULL,0);
G__search_typename2("map<int,Root::TGoodRun>",117,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_maplEintcORootcLcLTGoodRuncOlesslEintgRcOallocatorlEpairlEconstsPintcORootcLcLTGoodRungRsPgRsPgR),0,-1);
G__setnewtype(-1,NULL,0);
G__search_typename2("map<int,Root::TGoodRun,less<int> >",117,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_maplEintcORootcLcLTGoodRuncOlesslEintgRcOallocatorlEpairlEconstsPintcORootcLcLTGoodRungRsPgRsPgR),0,-1);
G__setnewtype(-1,NULL,0);
G__search_typename2("map<TString,TString>",117,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_maplETStringcOTStringcOlesslETStringgRcOallocatorlEpairlEconstsPTStringcOTStringgRsPgRsPgR),0,-1);
G__setnewtype(-1,NULL,0);
G__search_typename2("key_type",117,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_TString),0,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_maplETStringcOTStringcOlesslETStringgRcOallocatorlEpairlEconstsPTStringcOTStringgRsPgRsPgR));
G__setnewtype(-1,NULL,0);
G__search_typename2("mapped_type",117,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_TString),0,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_maplETStringcOTStringcOlesslETStringgRcOallocatorlEpairlEconstsPTStringcOTStringgRsPgRsPgR));
G__setnewtype(-1,NULL,0);
G__search_typename2("value_type",117,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_pairlETStringcOTStringgR),0,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_maplETStringcOTStringcOlesslETStringgRcOallocatorlEpairlEconstsPTStringcOTStringgRsPgRsPgR));
G__setnewtype(-1,NULL,0);
G__search_typename2("key_compare",117,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_lesslETStringgR),0,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_maplETStringcOTStringcOlesslETStringgRcOallocatorlEpairlEconstsPTStringcOTStringgRsPgRsPgR));
G__setnewtype(-1,NULL,0);
G__search_typename2("allocator_type",117,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_allocatorlEpairlEconstsPTStringcOTStringgRsPgR),0,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_maplETStringcOTStringcOlesslETStringgRcOallocatorlEpairlEconstsPTStringcOTStringgRsPgRsPgR));
G__setnewtype(-1,NULL,0);
G__search_typename2("size_type",104,-1,0,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_maplETStringcOTStringcOlesslETStringgRcOallocatorlEpairlEconstsPTStringcOTStringgRsPgRsPgR));
G__setnewtype(-1,NULL,0);
G__search_typename2("difference_type",108,-1,0,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_maplETStringcOTStringcOlesslETStringgRcOallocatorlEpairlEconstsPTStringcOTStringgRsPgRsPgR));
G__setnewtype(-1,NULL,0);
G__search_typename2("const_iterator",117,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_maplETStringcOTStringcOlesslETStringgRcOallocatorlEpairlEconstsPTStringcOTStringgRsPgRsPgRcLcLiterator),256,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_maplETStringcOTStringcOlesslETStringgRcOallocatorlEpairlEconstsPTStringcOTStringgRsPgRsPgR));
G__setnewtype(-1,NULL,0);
G__search_typename2("const_reverse_iterator",117,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_maplETStringcOTStringcOlesslETStringgRcOallocatorlEpairlEconstsPTStringcOTStringgRsPgRsPgRcLcLreverse_iterator),256,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_maplETStringcOTStringcOlesslETStringgRcOallocatorlEpairlEconstsPTStringcOTStringgRsPgRsPgR));
G__setnewtype(-1,NULL,0);
G__search_typename2("map<TString,TString,less<TString> >",117,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_maplETStringcOTStringcOlesslETStringgRcOallocatorlEpairlEconstsPTStringcOTStringgRsPgRsPgR),0,-1);
G__setnewtype(-1,NULL,0);
G__search_typename2("vector<int>",117,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_vectorlEintcOallocatorlEintgRsPgR),0,-1);
G__setnewtype(-1,NULL,0);
G__search_typename2("reverse_iterator<const_iterator>",117,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_reverse_iteratorlEvectorlEintcOallocatorlEintgRsPgRcLcLiteratorgR),0,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_vectorlEintcOallocatorlEintgRsPgR));
G__setnewtype(-1,NULL,0);
G__search_typename2("reverse_iterator<iterator>",117,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_reverse_iteratorlEvectorlEintcOallocatorlEintgRsPgRcLcLiteratorgR),0,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_vectorlEintcOallocatorlEintgRsPgR));
G__setnewtype(-1,NULL,0);
G__search_typename2("vector<Root::TGoodRun>",117,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_vectorlERootcLcLTGoodRuncOallocatorlERootcLcLTGoodRungRsPgR),0,-1);
G__setnewtype(-1,NULL,0);
G__search_typename2("value_type",117,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_RootcLcLTGoodRun),0,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_vectorlERootcLcLTGoodRuncOallocatorlERootcLcLTGoodRungRsPgR));
G__setnewtype(-1,NULL,0);
G__search_typename2("pointer",85,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_RootcLcLTGoodRun),0,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_vectorlERootcLcLTGoodRuncOallocatorlERootcLcLTGoodRungRsPgR));
G__setnewtype(-1,NULL,0);
G__search_typename2("const_pointer",85,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_RootcLcLTGoodRun),256,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_vectorlERootcLcLTGoodRuncOallocatorlERootcLcLTGoodRungRsPgR));
G__setnewtype(-1,NULL,0);
G__search_typename2("reference",117,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_RootcLcLTGoodRun),1,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_vectorlERootcLcLTGoodRuncOallocatorlERootcLcLTGoodRungRsPgR));
G__setnewtype(-1,NULL,0);
G__search_typename2("const_reference",117,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_RootcLcLTGoodRun),257,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_vectorlERootcLcLTGoodRuncOallocatorlERootcLcLTGoodRungRsPgR));
G__setnewtype(-1,NULL,0);
G__search_typename2("size_type",104,-1,0,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_vectorlERootcLcLTGoodRuncOallocatorlERootcLcLTGoodRungRsPgR));
G__setnewtype(-1,NULL,0);
G__search_typename2("difference_type",108,-1,0,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_vectorlERootcLcLTGoodRuncOallocatorlERootcLcLTGoodRungRsPgR));
G__setnewtype(-1,NULL,0);
G__search_typename2("pointer",85,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_RootcLcLTGoodRun),0,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_vectorlERootcLcLTGoodRuncOallocatorlERootcLcLTGoodRungRsPgRcLcLiterator));
G__setnewtype(-1,NULL,0);
G__search_typename2("const_pointer",85,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_RootcLcLTGoodRun),0,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_vectorlERootcLcLTGoodRuncOallocatorlERootcLcLTGoodRungRsPgRcLcLiterator));
G__setnewtype(-1,NULL,0);
G__search_typename2("reference",117,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_RootcLcLTGoodRun),1,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_vectorlERootcLcLTGoodRuncOallocatorlERootcLcLTGoodRungRsPgRcLcLiterator));
G__setnewtype(-1,NULL,0);
G__search_typename2("const_reference",117,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_RootcLcLTGoodRun),1,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_vectorlERootcLcLTGoodRuncOallocatorlERootcLcLTGoodRungRsPgRcLcLiterator));
G__setnewtype(-1,NULL,0);
G__search_typename2("size_type",104,-1,0,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_vectorlERootcLcLTGoodRuncOallocatorlERootcLcLTGoodRungRsPgRcLcLiterator));
G__setnewtype(-1,NULL,0);
G__search_typename2("difference_type",108,-1,0,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_vectorlERootcLcLTGoodRuncOallocatorlERootcLcLTGoodRungRsPgRcLcLiterator));
G__setnewtype(-1,NULL,0);
G__search_typename2("const_iterator",117,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_vectorlERootcLcLTGoodRuncOallocatorlERootcLcLTGoodRungRsPgRcLcLiterator),256,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_vectorlERootcLcLTGoodRuncOallocatorlERootcLcLTGoodRungRsPgR));
G__setnewtype(-1,NULL,0);
G__search_typename2("reverse_iterator<const_iterator>",117,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_reverse_iteratorlEvectorlERootcLcLTGoodRuncOallocatorlERootcLcLTGoodRungRsPgRcLcLiteratorgR),0,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_vectorlERootcLcLTGoodRuncOallocatorlERootcLcLTGoodRungRsPgR));
G__setnewtype(-1,NULL,0);
G__search_typename2("const_reverse_iterator",117,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_reverse_iteratorlEvectorlERootcLcLTGoodRuncOallocatorlERootcLcLTGoodRungRsPgRcLcLiteratorgR),0,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_vectorlERootcLcLTGoodRuncOallocatorlERootcLcLTGoodRungRsPgR));
G__setnewtype(-1,NULL,0);
G__search_typename2("reverse_iterator<iterator>",117,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_reverse_iteratorlEvectorlERootcLcLTGoodRuncOallocatorlERootcLcLTGoodRungRsPgRcLcLiteratorgR),0,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_vectorlERootcLcLTGoodRuncOallocatorlERootcLcLTGoodRungRsPgR));
G__setnewtype(-1,NULL,0);
G__search_typename2("reverse_iterator",117,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_reverse_iteratorlEvectorlERootcLcLTGoodRuncOallocatorlERootcLcLTGoodRungRsPgRcLcLiteratorgR),0,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_vectorlERootcLcLTGoodRuncOallocatorlERootcLcLTGoodRungRsPgR));
G__setnewtype(-1,NULL,0);
G__search_typename2("vector<std::string>",117,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_vectorlEstringcOallocatorlEstringgRsPgR),0,-1);
G__setnewtype(-1,NULL,0);
G__search_typename2("vector<TGoodRunsList>",117,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_vectorlERootcLcLTGoodRunsListcOallocatorlERootcLcLTGoodRunsListgRsPgR),0,-1);
G__setnewtype(-1,NULL,0);
G__search_typename2("value_type",117,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_RootcLcLTGoodRunsList),0,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_vectorlERootcLcLTGoodRunsListcOallocatorlERootcLcLTGoodRunsListgRsPgR));
G__setnewtype(-1,NULL,0);
G__search_typename2("pointer",85,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_RootcLcLTGoodRunsList),0,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_vectorlERootcLcLTGoodRunsListcOallocatorlERootcLcLTGoodRunsListgRsPgR));
G__setnewtype(-1,NULL,0);
G__search_typename2("const_pointer",85,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_RootcLcLTGoodRunsList),256,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_vectorlERootcLcLTGoodRunsListcOallocatorlERootcLcLTGoodRunsListgRsPgR));
G__setnewtype(-1,NULL,0);
G__search_typename2("reference",117,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_RootcLcLTGoodRunsList),1,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_vectorlERootcLcLTGoodRunsListcOallocatorlERootcLcLTGoodRunsListgRsPgR));
G__setnewtype(-1,NULL,0);
G__search_typename2("const_reference",117,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_RootcLcLTGoodRunsList),257,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_vectorlERootcLcLTGoodRunsListcOallocatorlERootcLcLTGoodRunsListgRsPgR));
G__setnewtype(-1,NULL,0);
G__search_typename2("size_type",104,-1,0,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_vectorlERootcLcLTGoodRunsListcOallocatorlERootcLcLTGoodRunsListgRsPgR));
G__setnewtype(-1,NULL,0);
G__search_typename2("difference_type",108,-1,0,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_vectorlERootcLcLTGoodRunsListcOallocatorlERootcLcLTGoodRunsListgRsPgR));
G__setnewtype(-1,NULL,0);
G__search_typename2("pointer",85,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_RootcLcLTGoodRunsList),0,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_vectorlERootcLcLTGoodRunsListcOallocatorlERootcLcLTGoodRunsListgRsPgRcLcLiterator));
G__setnewtype(-1,NULL,0);
G__search_typename2("const_pointer",85,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_RootcLcLTGoodRunsList),0,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_vectorlERootcLcLTGoodRunsListcOallocatorlERootcLcLTGoodRunsListgRsPgRcLcLiterator));
G__setnewtype(-1,NULL,0);
G__search_typename2("reference",117,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_RootcLcLTGoodRunsList),1,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_vectorlERootcLcLTGoodRunsListcOallocatorlERootcLcLTGoodRunsListgRsPgRcLcLiterator));
G__setnewtype(-1,NULL,0);
G__search_typename2("const_reference",117,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_RootcLcLTGoodRunsList),1,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_vectorlERootcLcLTGoodRunsListcOallocatorlERootcLcLTGoodRunsListgRsPgRcLcLiterator));
G__setnewtype(-1,NULL,0);
G__search_typename2("size_type",104,-1,0,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_vectorlERootcLcLTGoodRunsListcOallocatorlERootcLcLTGoodRunsListgRsPgRcLcLiterator));
G__setnewtype(-1,NULL,0);
G__search_typename2("difference_type",108,-1,0,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_vectorlERootcLcLTGoodRunsListcOallocatorlERootcLcLTGoodRunsListgRsPgRcLcLiterator));
G__setnewtype(-1,NULL,0);
G__search_typename2("const_iterator",117,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_vectorlERootcLcLTGoodRunsListcOallocatorlERootcLcLTGoodRunsListgRsPgRcLcLiterator),256,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_vectorlERootcLcLTGoodRunsListcOallocatorlERootcLcLTGoodRunsListgRsPgR));
G__setnewtype(-1,NULL,0);
G__search_typename2("reverse_iterator<const_iterator>",117,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_reverse_iteratorlEvectorlERootcLcLTGoodRunsListcOallocatorlERootcLcLTGoodRunsListgRsPgRcLcLiteratorgR),0,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_vectorlERootcLcLTGoodRunsListcOallocatorlERootcLcLTGoodRunsListgRsPgR));
G__setnewtype(-1,NULL,0);
G__search_typename2("const_reverse_iterator",117,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_reverse_iteratorlEvectorlERootcLcLTGoodRunsListcOallocatorlERootcLcLTGoodRunsListgRsPgRcLcLiteratorgR),0,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_vectorlERootcLcLTGoodRunsListcOallocatorlERootcLcLTGoodRunsListgRsPgR));
G__setnewtype(-1,NULL,0);
G__search_typename2("reverse_iterator<iterator>",117,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_reverse_iteratorlEvectorlERootcLcLTGoodRunsListcOallocatorlERootcLcLTGoodRunsListgRsPgRcLcLiteratorgR),0,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_vectorlERootcLcLTGoodRunsListcOallocatorlERootcLcLTGoodRunsListgRsPgR));
G__setnewtype(-1,NULL,0);
G__search_typename2("reverse_iterator",117,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_reverse_iteratorlEvectorlERootcLcLTGoodRunsListcOallocatorlERootcLcLTGoodRunsListgRsPgRcLcLiteratorgR),0,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_vectorlERootcLcLTGoodRunsListcOallocatorlERootcLcLTGoodRunsListgRsPgR));
G__setnewtype(-1,NULL,0);
G__search_typename2("vector<Root::TGoodRunsList>",117,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_vectorlERootcLcLTGoodRunsListcOallocatorlERootcLcLTGoodRunsListgRsPgR),0,-1);
G__setnewtype(-1,NULL,0);
G__search_typename2("vector<TString>",117,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_vectorlETStringcOallocatorlETStringgRsPgR),0,-1);
G__setnewtype(-1,NULL,0);
G__search_typename2("reverse_iterator<const_iterator>",117,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_reverse_iteratorlEvectorlETStringcOallocatorlETStringgRsPgRcLcLiteratorgR),0,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_vectorlETStringcOallocatorlETStringgRsPgR));
G__setnewtype(-1,NULL,0);
G__search_typename2("reverse_iterator<iterator>",117,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_reverse_iteratorlEvectorlETStringcOallocatorlETStringgRsPgRcLcLiteratorgR),0,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_vectorlETStringcOallocatorlETStringgRsPgR));
G__setnewtype(-1,NULL,0);
}
/*********************************************************
* Data Member information setup/
*********************************************************/
/* Setting up class,struct,union tag member variable */
/* Root */
static void G__setup_memvarRoot(void) {
G__tag_memvar_setup(G__get_linked_tagnum(&G__TGoodRunsListsCintLN_Root));
{
G__memvar_setup((void*)G__PVOID,105,0,1,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_RootcLcLTMsgLevel),-1,-2,1,G__FastAllocString(4096).Format("kVERBOSE=%lldLL",(long long)Root::kVERBOSE).data(),0,(char*)NULL);
G__memvar_setup((void*)G__PVOID,105,0,1,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_RootcLcLTMsgLevel),-1,-2,1,G__FastAllocString(4096).Format("kDEBUG=%lldLL",(long long)Root::kDEBUG).data(),0,(char*)NULL);
G__memvar_setup((void*)G__PVOID,105,0,1,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_RootcLcLTMsgLevel),-1,-2,1,G__FastAllocString(4096).Format("kINFO=%lldLL",(long long)Root::kINFO).data(),0,(char*)NULL);
G__memvar_setup((void*)G__PVOID,105,0,1,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_RootcLcLTMsgLevel),-1,-2,1,G__FastAllocString(4096).Format("kWARNING=%lldLL",(long long)Root::kWARNING).data(),0,(char*)NULL);
G__memvar_setup((void*)G__PVOID,105,0,1,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_RootcLcLTMsgLevel),-1,-2,1,G__FastAllocString(4096).Format("kERROR=%lldLL",(long long)Root::kERROR).data(),0,(char*)NULL);
G__memvar_setup((void*)G__PVOID,105,0,1,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_RootcLcLTMsgLevel),-1,-2,1,G__FastAllocString(4096).Format("kFATAL=%lldLL",(long long)Root::kFATAL).data(),0,(char*)NULL);
G__memvar_setup((void*)G__PVOID,105,0,1,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_RootcLcLTMsgLevel),-1,-2,1,G__FastAllocString(4096).Format("kALWAYS=%lldLL",(long long)Root::kALWAYS).data(),0,(char*)NULL);
G__memvar_setup((void*)G__PVOID,105,0,1,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_RootcLcLBoolOperation),-1,-2,1,G__FastAllocString(4096).Format("OR=%lldLL",(long long)Root::OR).data(),0,(char*)NULL);
G__memvar_setup((void*)G__PVOID,105,0,1,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_RootcLcLBoolOperation),-1,-2,1,G__FastAllocString(4096).Format("AND=%lldLL",(long long)Root::AND).data(),0,(char*)NULL);
}
G__tag_memvar_reset();
}
/* Root::RegularFormula */
static void G__setup_memvarRootcLcLRegularFormula(void) {
G__tag_memvar_setup(G__get_linked_tagnum(&G__TGoodRunsListsCintLN_RootcLcLRegularFormula));
{ Root::RegularFormula *p; p=(Root::RegularFormula*)0x1000; if (p) { }
G__memvar_setup((void*)0,117,0,0,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_TString),-1,-1,4,"m_expr=",0,(char*)NULL);
G__memvar_setup((void*)0,117,0,0,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_listlETStringcOallocatorlETStringgRsPgR),G__defined_typename("list<TString>"),-1,4,"m_par=",0,(char*)NULL);
G__memvar_setup((void*)0,85,0,0,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_TClass),-1,-2,4,"fgIsA=",0,(char*)NULL);
}
G__tag_memvar_reset();
}
/* Root::TLumiBlockRange */
static void G__setup_memvarRootcLcLTLumiBlockRange(void) {
G__tag_memvar_setup(G__get_linked_tagnum(&G__TGoodRunsListsCintLN_RootcLcLTLumiBlockRange));
{ Root::TLumiBlockRange *p; p=(Root::TLumiBlockRange*)0x1000; if (p) { }
G__memvar_setup((void*)0,105,0,0,-1,G__defined_typename("Int_t"),-1,4,"m_begin=",0,(char*)NULL);
G__memvar_setup((void*)0,105,0,0,-1,G__defined_typename("Int_t"),-1,4,"m_end=",0,(char*)NULL);
G__memvar_setup((void*)0,85,0,0,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_TClass),-1,-2,4,"fgIsA=",0,(char*)NULL);
}
G__tag_memvar_reset();
}
/* vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> > */
static void G__setup_memvarvectorlERootcLcLTLumiBlockRangecOallocatorlERootcLcLTLumiBlockRangegRsPgR(void) {
G__tag_memvar_setup(G__get_linked_tagnum(&G__TGoodRunsListsCintLN_vectorlERootcLcLTLumiBlockRangecOallocatorlERootcLcLTLumiBlockRangegRsPgR));
{ vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> > *p; p=(vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >*)0x1000; if (p) { }
}
G__tag_memvar_reset();
}
/* vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >::iterator */
static void G__setup_memvarvectorlERootcLcLTLumiBlockRangecOallocatorlERootcLcLTLumiBlockRangegRsPgRcLcLiterator(void) {
G__tag_memvar_setup(G__get_linked_tagnum(&G__TGoodRunsListsCintLN_vectorlERootcLcLTLumiBlockRangecOallocatorlERootcLcLTLumiBlockRangegRsPgRcLcLiterator));
{ vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >::iterator *p; p=(vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >::iterator*)0x1000; if (p) { }
}
G__tag_memvar_reset();
}
/* Root::TGoodRun */
static void G__setup_memvarRootcLcLTGoodRun(void) {
G__tag_memvar_setup(G__get_linked_tagnum(&G__TGoodRunsListsCintLN_RootcLcLTGoodRun));
{ Root::TGoodRun *p; p=(Root::TGoodRun*)0x1000; if (p) { }
G__memvar_setup((void*)0,105,0,0,-1,G__defined_typename("Int_t"),-1,4,"m_runnr=",0,(char*)NULL);
G__memvar_setup((void*)0,85,0,0,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_TClass),-1,-2,4,"fgIsA=",0,(char*)NULL);
}
G__tag_memvar_reset();
}
/* Root::TGoodRunsList */
static void G__setup_memvarRootcLcLTGoodRunsList(void) {
G__tag_memvar_setup(G__get_linked_tagnum(&G__TGoodRunsListsCintLN_RootcLcLTGoodRunsList));
{ Root::TGoodRunsList *p; p=(Root::TGoodRunsList*)0x1000; if (p) { }
G__memvar_setup((void*)0,117,0,0,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_TString),-1,-1,4,"m_version=",0,(char*)NULL);
G__memvar_setup((void*)0,117,0,0,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_maplETStringcOTStringcOlesslETStringgRcOallocatorlEpairlEconstsPTStringcOTStringgRsPgRsPgR),G__defined_typename("map<TString,TString>"),-1,4,"m_metadata=",0,(char*)NULL);
G__memvar_setup((void*)0,103,0,0,-1,G__defined_typename("Bool_t"),-1,4,"m_checkGRLInfo=",0,(char*)NULL);
G__memvar_setup((void*)0,103,0,0,-1,G__defined_typename("Bool_t"),-1,4,"m_hasRun=",0,(char*)NULL);
G__memvar_setup((void*)0,103,0,0,-1,G__defined_typename("Bool_t"),-1,4,"m_hasLB=",0,(char*)NULL);
G__memvar_setup((void*)0,105,0,0,-1,G__defined_typename("Int_t"),-1,4,"m_prevRun=",0,(char*)NULL);
G__memvar_setup((void*)0,105,0,0,-1,G__defined_typename("Int_t"),-1,4,"m_prevLB=",0,(char*)NULL);
G__memvar_setup((void*)0,85,0,0,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_TClass),-1,-2,4,"fgIsA=",0,(char*)NULL);
}
G__tag_memvar_reset();
}
/* map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > > */
static void G__setup_memvarmaplEintcORootcLcLTGoodRuncOlesslEintgRcOallocatorlEpairlEconstsPintcORootcLcLTGoodRungRsPgRsPgR(void) {
G__tag_memvar_setup(G__get_linked_tagnum(&G__TGoodRunsListsCintLN_maplEintcORootcLcLTGoodRuncOlesslEintgRcOallocatorlEpairlEconstsPintcORootcLcLTGoodRungRsPgRsPgR));
{ map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > > *p; p=(map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > >*)0x1000; if (p) { }
}
G__tag_memvar_reset();
}
/* pair<int,Root::TGoodRun> */
static void G__setup_memvarpairlEintcORootcLcLTGoodRungR(void) {
G__tag_memvar_setup(G__get_linked_tagnum(&G__TGoodRunsListsCintLN_pairlEintcORootcLcLTGoodRungR));
{ pair<int,Root::TGoodRun> *p; p=(pair<int,Root::TGoodRun>*)0x1000; if (p) { }
G__memvar_setup((void*)((long)(&p->first)-(long)(p)),105,0,0,-1,-1,-1,1,"first=",0,(char*)NULL);
G__memvar_setup((void*)((long)(&p->second)-(long)(p)),117,0,0,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_RootcLcLTGoodRun),-1,-1,1,"second=",0,(char*)NULL);
}
G__tag_memvar_reset();
}
/* map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > >::iterator */
static void G__setup_memvarmaplEintcORootcLcLTGoodRuncOlesslEintgRcOallocatorlEpairlEconstsPintcORootcLcLTGoodRungRsPgRsPgRcLcLiterator(void) {
G__tag_memvar_setup(G__get_linked_tagnum(&G__TGoodRunsListsCintLN_maplEintcORootcLcLTGoodRuncOlesslEintgRcOallocatorlEpairlEconstsPintcORootcLcLTGoodRungRsPgRsPgRcLcLiterator));
{ map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > >::iterator *p; p=(map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > >::iterator*)0x1000; if (p) { }
}
G__tag_memvar_reset();
}
/* map<TString,TString,less<TString>,allocator<pair<const TString,TString> > > */
static void G__setup_memvarmaplETStringcOTStringcOlesslETStringgRcOallocatorlEpairlEconstsPTStringcOTStringgRsPgRsPgR(void) {
G__tag_memvar_setup(G__get_linked_tagnum(&G__TGoodRunsListsCintLN_maplETStringcOTStringcOlesslETStringgRcOallocatorlEpairlEconstsPTStringcOTStringgRsPgRsPgR));
{ map<TString,TString,less<TString>,allocator<pair<const TString,TString> > > *p; p=(map<TString,TString,less<TString>,allocator<pair<const TString,TString> > >*)0x1000; if (p) { }
}
G__tag_memvar_reset();
}
/* pair<TString,TString> */
static void G__setup_memvarpairlETStringcOTStringgR(void) {
G__tag_memvar_setup(G__get_linked_tagnum(&G__TGoodRunsListsCintLN_pairlETStringcOTStringgR));
{ pair<TString,TString> *p; p=(pair<TString,TString>*)0x1000; if (p) { }
G__memvar_setup((void*)((long)(&p->first)-(long)(p)),117,0,0,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_TString),-1,-1,1,"first=",0,(char*)NULL);
G__memvar_setup((void*)((long)(&p->second)-(long)(p)),117,0,0,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_TString),-1,-1,1,"second=",0,(char*)NULL);
}
G__tag_memvar_reset();
}
/* vector<Root::TGoodRun,allocator<Root::TGoodRun> > */
static void G__setup_memvarvectorlERootcLcLTGoodRuncOallocatorlERootcLcLTGoodRungRsPgR(void) {
G__tag_memvar_setup(G__get_linked_tagnum(&G__TGoodRunsListsCintLN_vectorlERootcLcLTGoodRuncOallocatorlERootcLcLTGoodRungRsPgR));
{ vector<Root::TGoodRun,allocator<Root::TGoodRun> > *p; p=(vector<Root::TGoodRun,allocator<Root::TGoodRun> >*)0x1000; if (p) { }
}
G__tag_memvar_reset();
}
/* vector<Root::TGoodRun,allocator<Root::TGoodRun> >::iterator */
static void G__setup_memvarvectorlERootcLcLTGoodRuncOallocatorlERootcLcLTGoodRungRsPgRcLcLiterator(void) {
G__tag_memvar_setup(G__get_linked_tagnum(&G__TGoodRunsListsCintLN_vectorlERootcLcLTGoodRuncOallocatorlERootcLcLTGoodRungRsPgRcLcLiterator));
{ vector<Root::TGoodRun,allocator<Root::TGoodRun> >::iterator *p; p=(vector<Root::TGoodRun,allocator<Root::TGoodRun> >::iterator*)0x1000; if (p) { }
}
G__tag_memvar_reset();
}
/* Root::TGRLCollection */
static void G__setup_memvarRootcLcLTGRLCollection(void) {
G__tag_memvar_setup(G__get_linked_tagnum(&G__TGoodRunsListsCintLN_RootcLcLTGRLCollection));
{ Root::TGRLCollection *p; p=(Root::TGRLCollection*)0x1000; if (p) { }
G__memvar_setup((void*)0,103,0,0,-1,G__defined_typename("Bool_t"),-1,4,"m_checkGRLInfo=",0,(char*)NULL);
G__memvar_setup((void*)0,85,0,0,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_TClass),-1,-2,4,"fgIsA=",0,(char*)NULL);
}
G__tag_memvar_reset();
}
/* vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> > */
static void G__setup_memvarvectorlERootcLcLTGoodRunsListcOallocatorlERootcLcLTGoodRunsListgRsPgR(void) {
G__tag_memvar_setup(G__get_linked_tagnum(&G__TGoodRunsListsCintLN_vectorlERootcLcLTGoodRunsListcOallocatorlERootcLcLTGoodRunsListgRsPgR));
{ vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> > *p; p=(vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >*)0x1000; if (p) { }
}
G__tag_memvar_reset();
}
/* vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >::iterator */
static void G__setup_memvarvectorlERootcLcLTGoodRunsListcOallocatorlERootcLcLTGoodRunsListgRsPgRcLcLiterator(void) {
G__tag_memvar_setup(G__get_linked_tagnum(&G__TGoodRunsListsCintLN_vectorlERootcLcLTGoodRunsListcOallocatorlERootcLcLTGoodRunsListgRsPgRcLcLiterator));
{ vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >::iterator *p; p=(vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >::iterator*)0x1000; if (p) { }
}
G__tag_memvar_reset();
}
/* Root::TGoodRunsListWriter */
static void G__setup_memvarRootcLcLTGoodRunsListWriter(void) {
G__tag_memvar_setup(G__get_linked_tagnum(&G__TGoodRunsListsCintLN_RootcLcLTGoodRunsListWriter));
{ Root::TGoodRunsListWriter *p; p=(Root::TGoodRunsListWriter*)0x1000; if (p) { }
G__memvar_setup((void*)0,117,0,0,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_RootcLcLTGRLCollection),-1,-1,4,"m_grlvec=",0,(char*)NULL);
G__memvar_setup((void*)0,117,0,0,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_RootcLcLTGoodRunsList),-1,-1,4,"m_grl=",0,(char*)NULL);
G__memvar_setup((void*)0,117,0,0,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_vectorlETStringcOallocatorlETStringgRsPgR),G__defined_typename("vector<TString>"),-1,4,"m_xmlstringVec=",0,(char*)NULL);
G__memvar_setup((void*)0,117,0,0,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_TString),-1,-1,4,"m_xmlstring=",0,(char*)NULL);
G__memvar_setup((void*)0,117,0,0,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_TString),-1,-1,4,"m_dataCardName=",0,(char*)NULL);
G__memvar_setup((void*)0,117,0,0,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_TString),-1,-1,4,"m_prefix=",0,(char*)NULL);
G__memvar_setup((void*)0,117,0,0,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_RootcLcLTMsgLogger),-1,-1,4,"m_logger=",0,(char*)NULL);
G__memvar_setup((void*)0,103,0,0,-1,G__defined_typename("Bool_t"),-1,4,"m_mergegrls=",0,(char*)NULL);
G__memvar_setup((void*)0,103,0,0,-1,G__defined_typename("Bool_t"),-1,4,"m_individuals=",0,(char*)NULL);
G__memvar_setup((void*)0,85,0,0,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_TClass),-1,-2,4,"fgIsA=",0,(char*)NULL);
}
G__tag_memvar_reset();
}
/* Root::TGoodRunsListReader */
static void G__setup_memvarRootcLcLTGoodRunsListReader(void) {
G__tag_memvar_setup(G__get_linked_tagnum(&G__TGoodRunsListsCintLN_RootcLcLTGoodRunsListReader));
{ Root::TGoodRunsListReader *p; p=(Root::TGoodRunsListReader*)0x1000; if (p) { }
G__memvar_setup((void*)0,117,0,0,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_TString),-1,-1,4,"m_xmlstring=",0,(char*)NULL);
G__memvar_setup((void*)0,117,0,0,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_TString),-1,-1,4,"m_dataCardName=",0,"current xmlfile processed");
G__memvar_setup((void*)0,117,0,0,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_vectorlETStringcOallocatorlETStringgRsPgR),G__defined_typename("vector<TString>"),-1,4,"m_dataCardList=",0,(char*)NULL);
G__memvar_setup((void*)0,117,0,0,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_vectorlETStringcOallocatorlETStringgRsPgR),G__defined_typename("vector<TString>"),-1,4,"m_xmlstringList=",0,(char*)NULL);
G__memvar_setup((void*)0,117,0,0,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_RootcLcLTMsgLogger),-1,-1,4,"m_logger=",0,(char*)NULL);
G__memvar_setup((void*)0,117,0,0,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_RootcLcLTGRLCollection),-1,-1,4,"m_grlvec=",0,(char*)NULL);
G__memvar_setup((void*)0,85,0,0,G__get_linked_tagnum(&G__TGoodRunsListsCintLN_TClass),-1,-2,4,"fgIsA=",0,(char*)NULL);
}
G__tag_memvar_reset();
}
/* DQ */
static void G__setup_memvarDQ(void) {
G__tag_memvar_setup(G__get_linked_tagnum(&G__TGoodRunsListsCintLN_DQ));
{
}
G__tag_memvar_reset();
}
extern "C" void G__cpp_setup_memvarTGoodRunsListsCint() {
}
/***********************************************************
************************************************************
************************************************************
************************************************************
************************************************************
************************************************************
************************************************************
***********************************************************/
/*********************************************************
* Member function information setup for each class
*********************************************************/
static void G__setup_memfuncRoot(void) {
/* Root */
G__tag_memfunc_setup(G__get_linked_tagnum(&G__TGoodRunsListsCintLN_Root));
G__tag_memfunc_reset();
}
static void G__setup_memfuncRootcLcLRegularFormula(void) {
/* Root::RegularFormula */
G__tag_memfunc_setup(G__get_linked_tagnum(&G__TGoodRunsListsCintLN_RootcLcLRegularFormula));
G__memfunc_setup("RegularFormula",1448,G__TGoodRunsListsCint_216_0_1, 105, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_RootcLcLRegularFormula), -1, 0, 0, 1, 1, 0, "", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("RegularFormula",1448,G__TGoodRunsListsCint_216_0_2, 105, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_RootcLcLRegularFormula), -1, 0, 2, 1, 1, 0,
"C - - 10 - name C - - 10 - expression", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("RegularFormula",1448,G__TGoodRunsListsCint_216_0_3, 105, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_RootcLcLRegularFormula), -1, 0, 1, 1, 1, 0, "u 'Root::RegularFormula' - 11 - other", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("operator=",937,G__TGoodRunsListsCint_216_0_4, 117, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_RootcLcLRegularFormula), -1, 1, 1, 1, 1, 0, "u 'Root::RegularFormula' - 11 - other", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("setFormula",1058,G__TGoodRunsListsCint_216_0_5, 105, -1, G__defined_typename("Int_t"), 0, 1, 1, 1, 0, "C - - 10 - expression", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("getNPars",804,G__TGoodRunsListsCint_216_0_6, 104, -1, -1, 0, 0, 1, 1, 8, "", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("getParNames",1111,G__TGoodRunsListsCint_216_0_7, 117, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_listlETStringcOallocatorlETStringgRsPgR), G__defined_typename("list<TString>"), 1, 0, 1, 1, 9, "", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("parseExpression",1611,(G__InterfaceMethod) NULL, 121, -1, -1, 0, 2, 1, 4, 0,
"C - - 10 - expression u 'TString' - 1 - expr", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("Class",502,G__TGoodRunsListsCint_216_0_9, 85, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_TClass), -1, 0, 0, 3, 1, 0, "", (char*)NULL, (void*) G__func2void( (TClass* (*)())(&Root::RegularFormula::Class) ), 0);
G__memfunc_setup("Class_Name",982,G__TGoodRunsListsCint_216_0_10, 67, -1, -1, 0, 0, 3, 1, 1, "", (char*)NULL, (void*) G__func2void( (const char* (*)())(&Root::RegularFormula::Class_Name) ), 0);
G__memfunc_setup("Class_Version",1339,G__TGoodRunsListsCint_216_0_11, 115, -1, G__defined_typename("Version_t"), 0, 0, 3, 1, 0, "", (char*)NULL, (void*) G__func2void( (Version_t (*)())(&Root::RegularFormula::Class_Version) ), 0);
G__memfunc_setup("Dictionary",1046,G__TGoodRunsListsCint_216_0_12, 121, -1, -1, 0, 0, 3, 1, 0, "", (char*)NULL, (void*) G__func2void( (void (*)())(&Root::RegularFormula::Dictionary) ), 0);
G__memfunc_setup("IsA",253,(G__InterfaceMethod) NULL,85, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_TClass), -1, 0, 0, 1, 1, 8, "", (char*)NULL, (void*) NULL, 1);
G__memfunc_setup("ShowMembers",1132,(G__InterfaceMethod) NULL,121, -1, -1, 0, 1, 1, 1, 0, "u 'TMemberInspector' - 1 - insp", (char*)NULL, (void*) NULL, 1);
G__memfunc_setup("Streamer",835,(G__InterfaceMethod) NULL,121, -1, -1, 0, 1, 1, 1, 0, "u 'TBuffer' - 1 - b", (char*)NULL, (void*) NULL, 1);
G__memfunc_setup("StreamerNVirtual",1656,G__TGoodRunsListsCint_216_0_16, 121, -1, -1, 0, 1, 1, 1, 0, "u 'TBuffer' - 1 - b", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("DeclFileName",1145,G__TGoodRunsListsCint_216_0_17, 67, -1, -1, 0, 0, 3, 1, 1, "", (char*)NULL, (void*) G__func2void( (const char* (*)())(&Root::RegularFormula::DeclFileName) ), 0);
G__memfunc_setup("ImplFileLine",1178,G__TGoodRunsListsCint_216_0_18, 105, -1, -1, 0, 0, 3, 1, 0, "", (char*)NULL, (void*) G__func2void( (int (*)())(&Root::RegularFormula::ImplFileLine) ), 0);
G__memfunc_setup("ImplFileName",1171,G__TGoodRunsListsCint_216_0_19, 67, -1, -1, 0, 0, 3, 1, 1, "", (char*)NULL, (void*) G__func2void( (const char* (*)())(&Root::RegularFormula::ImplFileName) ), 0);
G__memfunc_setup("DeclFileLine",1152,G__TGoodRunsListsCint_216_0_20, 105, -1, -1, 0, 0, 3, 1, 0, "", (char*)NULL, (void*) G__func2void( (int (*)())(&Root::RegularFormula::DeclFileLine) ), 0);
// automatic destructor
G__memfunc_setup("~RegularFormula", 1574, G__TGoodRunsListsCint_216_0_21, (int) ('y'), -1, -1, 0, 0, 1, 1, 0, "", (char*) NULL, (void*) NULL, 1);
G__tag_memfunc_reset();
}
static void G__setup_memfuncRootcLcLTLumiBlockRange(void) {
/* Root::TLumiBlockRange */
G__tag_memfunc_setup(G__get_linked_tagnum(&G__TGoodRunsListsCintLN_RootcLcLTLumiBlockRange));
G__memfunc_setup("TLumiBlockRange",1475,G__TGoodRunsListsCint_497_0_1, 105, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_RootcLcLTLumiBlockRange), -1, 0, 0, 1, 1, 0, "", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("TLumiBlockRange",1475,G__TGoodRunsListsCint_497_0_2, 105, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_RootcLcLTLumiBlockRange), -1, 0, 2, 1, 1, 0,
"i - 'Int_t' 11 - start i - 'Int_t' 11 '2147483647' end", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("TLumiBlockRange",1475,G__TGoodRunsListsCint_497_0_3, 105, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_RootcLcLTLumiBlockRange), -1, 0, 1, 1, 1, 0, "u 'Root::TLumiBlockRange' - 11 - other", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("operator=",937,G__TGoodRunsListsCint_497_0_4, 117, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_RootcLcLTLumiBlockRange), -1, 1, 1, 1, 1, 0, "u 'Root::TLumiBlockRange' - 11 - other", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("GetOverlapWith",1429,G__TGoodRunsListsCint_497_0_5, 117, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_RootcLcLTLumiBlockRange), -1, 0, 1, 1, 1, 9, "u 'Root::TLumiBlockRange' - 11 - other", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("GetPartOnlyIn",1296,G__TGoodRunsListsCint_497_0_6, 117, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_vectorlERootcLcLTLumiBlockRangecOallocatorlERootcLcLTLumiBlockRangegRsPgR), G__defined_typename("vector<Root::TLumiBlockRange>"), 0, 1, 1, 1, 9, "u 'Root::TLumiBlockRange' - 11 - other", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("GetPartNotIn",1183,G__TGoodRunsListsCint_497_0_7, 117, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_vectorlERootcLcLTLumiBlockRangecOallocatorlERootcLcLTLumiBlockRangegRsPgR), G__defined_typename("vector<Root::TLumiBlockRange>"), 0, 1, 1, 1, 9, "u 'Root::TLumiBlockRange' - 11 - other", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("Contains",831,G__TGoodRunsListsCint_497_0_8, 103, -1, G__defined_typename("Bool_t"), 0, 1, 1, 1, 8, "i - 'Int_t' 11 - number", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("Begin",485,G__TGoodRunsListsCint_497_0_9, 105, -1, G__defined_typename("Int_t"), 0, 0, 1, 1, 8, "", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("End",279,G__TGoodRunsListsCint_497_0_10, 105, -1, G__defined_typename("Int_t"), 0, 0, 1, 1, 8, "", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("IsEmpty",715,G__TGoodRunsListsCint_497_0_11, 103, -1, G__defined_typename("Bool_t"), 0, 0, 1, 1, 8, "", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("SetBegin",785,G__TGoodRunsListsCint_497_0_12, 121, -1, -1, 0, 1, 1, 1, 0, "i - 'Int_t' 11 - begin", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("SetEnd",579,G__TGoodRunsListsCint_497_0_13, 121, -1, -1, 0, 1, 1, 1, 0, "i - 'Int_t' 11 - end", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("Summary",750,G__TGoodRunsListsCint_497_0_14, 121, -1, -1, 0, 0, 1, 1, 8, "", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("Class",502,G__TGoodRunsListsCint_497_0_15, 85, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_TClass), -1, 0, 0, 3, 1, 0, "", (char*)NULL, (void*) G__func2void( (TClass* (*)())(&Root::TLumiBlockRange::Class) ), 0);
G__memfunc_setup("Class_Name",982,G__TGoodRunsListsCint_497_0_16, 67, -1, -1, 0, 0, 3, 1, 1, "", (char*)NULL, (void*) G__func2void( (const char* (*)())(&Root::TLumiBlockRange::Class_Name) ), 0);
G__memfunc_setup("Class_Version",1339,G__TGoodRunsListsCint_497_0_17, 115, -1, G__defined_typename("Version_t"), 0, 0, 3, 1, 0, "", (char*)NULL, (void*) G__func2void( (Version_t (*)())(&Root::TLumiBlockRange::Class_Version) ), 0);
G__memfunc_setup("Dictionary",1046,G__TGoodRunsListsCint_497_0_18, 121, -1, -1, 0, 0, 3, 1, 0, "", (char*)NULL, (void*) G__func2void( (void (*)())(&Root::TLumiBlockRange::Dictionary) ), 0);
G__memfunc_setup("IsA",253,(G__InterfaceMethod) NULL,85, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_TClass), -1, 0, 0, 1, 1, 8, "", (char*)NULL, (void*) NULL, 1);
G__memfunc_setup("ShowMembers",1132,(G__InterfaceMethod) NULL,121, -1, -1, 0, 1, 1, 1, 0, "u 'TMemberInspector' - 1 - insp", (char*)NULL, (void*) NULL, 1);
G__memfunc_setup("Streamer",835,(G__InterfaceMethod) NULL,121, -1, -1, 0, 1, 1, 1, 0, "u 'TBuffer' - 1 - b", (char*)NULL, (void*) NULL, 1);
G__memfunc_setup("StreamerNVirtual",1656,G__TGoodRunsListsCint_497_0_22, 121, -1, -1, 0, 1, 1, 1, 0, "u 'TBuffer' - 1 - b", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("DeclFileName",1145,G__TGoodRunsListsCint_497_0_23, 67, -1, -1, 0, 0, 3, 1, 1, "", (char*)NULL, (void*) G__func2void( (const char* (*)())(&Root::TLumiBlockRange::DeclFileName) ), 0);
G__memfunc_setup("ImplFileLine",1178,G__TGoodRunsListsCint_497_0_24, 105, -1, -1, 0, 0, 3, 1, 0, "", (char*)NULL, (void*) G__func2void( (int (*)())(&Root::TLumiBlockRange::ImplFileLine) ), 0);
G__memfunc_setup("ImplFileName",1171,G__TGoodRunsListsCint_497_0_25, 67, -1, -1, 0, 0, 3, 1, 1, "", (char*)NULL, (void*) G__func2void( (const char* (*)())(&Root::TLumiBlockRange::ImplFileName) ), 0);
G__memfunc_setup("DeclFileLine",1152,G__TGoodRunsListsCint_497_0_26, 105, -1, -1, 0, 0, 3, 1, 0, "", (char*)NULL, (void*) G__func2void( (int (*)())(&Root::TLumiBlockRange::DeclFileLine) ), 0);
// automatic destructor
G__memfunc_setup("~TLumiBlockRange", 1601, G__TGoodRunsListsCint_497_0_27, (int) ('y'), -1, -1, 0, 0, 1, 1, 0, "", (char*) NULL, (void*) NULL, 1);
G__tag_memfunc_reset();
}
static void G__setup_memfuncvectorlERootcLcLTLumiBlockRangecOallocatorlERootcLcLTLumiBlockRangegRsPgR(void) {
/* vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> > */
G__tag_memfunc_setup(G__get_linked_tagnum(&G__TGoodRunsListsCintLN_vectorlERootcLcLTLumiBlockRangecOallocatorlERootcLcLTLumiBlockRangegRsPgR));
G__memfunc_setup("at",213,G__TGoodRunsListsCint_499_0_1, 117, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_RootcLcLTLumiBlockRange), G__defined_typename("vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >::reference"), 1, 1, 1, 1, 0, "h - 'vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >::size_type' 0 - n", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("at",213,G__TGoodRunsListsCint_499_0_2, 117, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_RootcLcLTLumiBlockRange), G__defined_typename("vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >::const_reference"), 1, 1, 1, 1, 8, "h - 'vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >::size_type' 0 - n", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("begin",517,G__TGoodRunsListsCint_499_0_3, 117, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_vectorlERootcLcLTLumiBlockRangecOallocatorlERootcLcLTLumiBlockRangegRsPgRcLcLiterator), -1, 0, 0, 1, 1, 0, "", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("end",311,G__TGoodRunsListsCint_499_0_4, 117, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_vectorlERootcLcLTLumiBlockRangecOallocatorlERootcLcLTLumiBlockRangegRsPgRcLcLiterator), -1, 0, 0, 1, 1, 0, "", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("rbegin",631,G__TGoodRunsListsCint_499_0_5, 117, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_reverse_iteratorlEvectorlERootcLcLTLumiBlockRangecOallocatorlERootcLcLTLumiBlockRangegRsPgRcLcLiteratorgR), G__defined_typename("vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >::reverse_iterator"), 0, 0, 1, 1, 0, "", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("rend",425,G__TGoodRunsListsCint_499_0_6, 117, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_reverse_iteratorlEvectorlERootcLcLTLumiBlockRangecOallocatorlERootcLcLTLumiBlockRangegRsPgRcLcLiteratorgR), G__defined_typename("vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >::reverse_iterator"), 0, 0, 1, 1, 0, "", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("size",443,G__TGoodRunsListsCint_499_0_7, 104, -1, G__defined_typename("vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >::size_type"), 0, 0, 1, 1, 8, "", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("max_size",864,G__TGoodRunsListsCint_499_0_8, 104, -1, G__defined_typename("vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >::size_type"), 0, 0, 1, 1, 8, "", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("resize",658,G__TGoodRunsListsCint_499_0_9, 121, -1, -1, 0, 1, 1, 1, 0, "h - 'vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >::size_type' 0 - sz", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("resize",658,G__TGoodRunsListsCint_499_0_10, 121, -1, -1, 0, 2, 1, 1, 0,
"h - 'vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >::size_type' 0 - sz u 'Root::TLumiBlockRange' - 0 - c", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("capacity",846,G__TGoodRunsListsCint_499_0_11, 104, -1, G__defined_typename("vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >::size_type"), 0, 0, 1, 1, 8, "", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("empty",559,G__TGoodRunsListsCint_499_0_12, 103, -1, -1, 0, 0, 1, 1, 8, "", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("operator[]",1060,G__TGoodRunsListsCint_499_0_13, 117, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_RootcLcLTLumiBlockRange), G__defined_typename("vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >::reference"), 1, 1, 1, 1, 0, "h - 'vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >::size_type' 0 - n", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("operator[]",1060,G__TGoodRunsListsCint_499_0_14, 117, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_RootcLcLTLumiBlockRange), G__defined_typename("vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >::const_reference"), 1, 1, 1, 1, 8, "h - 'vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >::size_type' 0 - n", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >",5962,G__TGoodRunsListsCint_499_0_15, 105, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_vectorlERootcLcLTLumiBlockRangecOallocatorlERootcLcLTLumiBlockRangegRsPgR), -1, 0, 0, 1, 1, 0, "", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >",5962,G__TGoodRunsListsCint_499_0_16, 105, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_vectorlERootcLcLTLumiBlockRangecOallocatorlERootcLcLTLumiBlockRangegRsPgR), -1, 0, 2, 1, 1, 0,
"h - 'vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >::size_type' 0 - n u 'Root::TLumiBlockRange' - 11 'Root::TLumiBlockRange()' value", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >",5962,G__TGoodRunsListsCint_499_0_17, 105, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_vectorlERootcLcLTLumiBlockRangecOallocatorlERootcLcLTLumiBlockRangegRsPgR), -1, 0, 1, 1, 1, 0, "u 'vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >' - 11 - x", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >",5962,G__TGoodRunsListsCint_499_0_18, 105, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_vectorlERootcLcLTLumiBlockRangecOallocatorlERootcLcLTLumiBlockRangegRsPgR), -1, 0, 2, 1, 1, 0,
"u 'vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >::iterator' 'vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >::const_iterator' 10 - first u 'vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >::iterator' 'vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >::const_iterator' 10 - last", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("operator=",937,G__TGoodRunsListsCint_499_0_19, 117, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_vectorlERootcLcLTLumiBlockRangecOallocatorlERootcLcLTLumiBlockRangegRsPgR), -1, 1, 1, 1, 1, 0, "u 'vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >' - 11 - x", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("reserve",764,G__TGoodRunsListsCint_499_0_20, 121, -1, -1, 0, 1, 1, 1, 0, "h - 'vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >::size_type' 0 - n", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("front",553,G__TGoodRunsListsCint_499_0_21, 117, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_RootcLcLTLumiBlockRange), -1, 1, 0, 1, 1, 0, "", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("back",401,G__TGoodRunsListsCint_499_0_22, 117, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_RootcLcLTLumiBlockRange), -1, 1, 0, 1, 1, 0, "", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("push_back",944,G__TGoodRunsListsCint_499_0_23, 121, -1, -1, 0, 1, 1, 1, 0, "u 'Root::TLumiBlockRange' - 11 - x", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("swap",443,G__TGoodRunsListsCint_499_0_24, 121, -1, -1, 0, 1, 1, 1, 0, "u 'vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >' - 1 - x", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("insert",661,G__TGoodRunsListsCint_499_0_25, 117, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_vectorlERootcLcLTLumiBlockRangecOallocatorlERootcLcLTLumiBlockRangegRsPgRcLcLiterator), -1, 0, 2, 1, 1, 0,
"u 'vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >::iterator' - 0 - position u 'Root::TLumiBlockRange' - 11 - x", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("insert",661,G__TGoodRunsListsCint_499_0_26, 121, -1, -1, 0, 3, 1, 1, 0,
"u 'vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >::iterator' - 0 - position u 'vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >::iterator' 'vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >::const_iterator' 10 - first "
"u 'vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >::iterator' 'vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >::const_iterator' 10 - last", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("insert",661,G__TGoodRunsListsCint_499_0_27, 121, -1, -1, 0, 3, 1, 1, 0,
"u 'vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >::iterator' - 0 - position h - 'vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >::size_type' 0 - n "
"u 'Root::TLumiBlockRange' - 11 - x", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("pop_back",831,G__TGoodRunsListsCint_499_0_28, 121, -1, -1, 0, 0, 1, 1, 0, "", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("erase",528,G__TGoodRunsListsCint_499_0_29, 121, -1, -1, 0, 1, 1, 1, 0, "u 'vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >::iterator' - 0 - position", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("erase",528,G__TGoodRunsListsCint_499_0_30, 121, -1, -1, 0, 2, 1, 1, 0,
"u 'vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >::iterator' - 0 - first u 'vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >::iterator' - 0 - last", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("clear",519,G__TGoodRunsListsCint_499_0_31, 121, -1, -1, 0, 0, 1, 1, 0, "", (char*)NULL, (void*) NULL, 0);
// automatic destructor
G__memfunc_setup("~vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >", 6088, G__TGoodRunsListsCint_499_0_32, (int) ('y'), -1, -1, 0, 0, 1, 1, 0, "", (char*) NULL, (void*) NULL, 0);
G__tag_memfunc_reset();
}
static void G__setup_memfuncvectorlERootcLcLTLumiBlockRangecOallocatorlERootcLcLTLumiBlockRangegRsPgRcLcLiterator(void) {
/* vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >::iterator */
G__tag_memfunc_setup(G__get_linked_tagnum(&G__TGoodRunsListsCintLN_vectorlERootcLcLTLumiBlockRangecOallocatorlERootcLcLTLumiBlockRangegRsPgRcLcLiterator));
G__memfunc_setup("iterator",874,G__TGoodRunsListsCint_500_0_1, 105, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_vectorlERootcLcLTLumiBlockRangecOallocatorlERootcLcLTLumiBlockRangegRsPgRcLcLiterator), -1, 0, 0, 1, 1, 0, "", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("iterator",874,G__TGoodRunsListsCint_500_0_2, 105, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_vectorlERootcLcLTLumiBlockRangecOallocatorlERootcLcLTLumiBlockRangegRsPgRcLcLiterator), -1, 0, 1, 5, 1, 0, "U 'Root::TLumiBlockRange' 'vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >::iterator::pointer' 11 - __i", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("operator*",918,G__TGoodRunsListsCint_500_0_3, 117, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_RootcLcLTLumiBlockRange), G__defined_typename("vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >::iterator::reference"), 1, 0, 1, 1, 8, "", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("operator->",983,G__TGoodRunsListsCint_500_0_4, 85, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_RootcLcLTLumiBlockRange), G__defined_typename("vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >::iterator::pointer"), 0, 0, 1, 1, 8, "", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("operator++",962,G__TGoodRunsListsCint_500_0_5, 117, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_vectorlERootcLcLTLumiBlockRangecOallocatorlERootcLcLTLumiBlockRangegRsPgRcLcLiterator), -1, 1, 0, 1, 1, 0, "", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("operator++",962,G__TGoodRunsListsCint_500_0_6, 117, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_vectorlERootcLcLTLumiBlockRangecOallocatorlERootcLcLTLumiBlockRangegRsPgRcLcLiterator), -1, 0, 1, 1, 1, 0, "i - - 0 - -", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("operator--",966,G__TGoodRunsListsCint_500_0_7, 117, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_vectorlERootcLcLTLumiBlockRangecOallocatorlERootcLcLTLumiBlockRangegRsPgRcLcLiterator), -1, 1, 0, 1, 1, 0, "", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("operator--",966,G__TGoodRunsListsCint_500_0_8, 117, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_vectorlERootcLcLTLumiBlockRangecOallocatorlERootcLcLTLumiBlockRangegRsPgRcLcLiterator), -1, 0, 1, 1, 1, 0, "i - - 0 - -", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("operator[]",1060,G__TGoodRunsListsCint_500_0_9, 117, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_RootcLcLTLumiBlockRange), G__defined_typename("vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >::iterator::reference"), 1, 1, 1, 1, 8, "l - 'vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >::iterator::difference_type' 11 - __n", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("operator+=",980,G__TGoodRunsListsCint_500_0_10, 117, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_vectorlERootcLcLTLumiBlockRangecOallocatorlERootcLcLTLumiBlockRangegRsPgRcLcLiterator), -1, 1, 1, 1, 1, 0, "l - 'vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >::iterator::difference_type' 11 - __n", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("operator+",919,G__TGoodRunsListsCint_500_0_11, 117, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_vectorlERootcLcLTLumiBlockRangecOallocatorlERootcLcLTLumiBlockRangegRsPgRcLcLiterator), -1, 0, 1, 1, 1, 8, "l - 'vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >::iterator::difference_type' 11 - __n", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("operator-=",982,G__TGoodRunsListsCint_500_0_12, 117, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_vectorlERootcLcLTLumiBlockRangecOallocatorlERootcLcLTLumiBlockRangegRsPgRcLcLiterator), -1, 1, 1, 1, 1, 0, "l - 'vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >::iterator::difference_type' 11 - __n", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("operator-",921,G__TGoodRunsListsCint_500_0_13, 117, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_vectorlERootcLcLTLumiBlockRangecOallocatorlERootcLcLTLumiBlockRangegRsPgRcLcLiterator), -1, 0, 1, 1, 1, 8, "l - 'vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >::iterator::difference_type' 11 - __n", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("base",411,G__TGoodRunsListsCint_500_0_14, 85, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_RootcLcLTLumiBlockRange), G__defined_typename("vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >::iterator::pointer"), 1, 0, 1, 1, 9, "", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("operator=",937,G__TGoodRunsListsCint_500_0_15, 117, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_vectorlERootcLcLTLumiBlockRangecOallocatorlERootcLcLTLumiBlockRangegRsPgRcLcLiterator), -1, 0, 1, 1, 1, 0, "u 'vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >::iterator' - 11 - x", (char*)NULL, (void*) NULL, 0);
// automatic copy constructor
G__memfunc_setup("iterator", 874, G__TGoodRunsListsCint_500_0_16, (int) ('i'), G__get_linked_tagnum(&G__TGoodRunsListsCintLN_vectorlERootcLcLTLumiBlockRangecOallocatorlERootcLcLTLumiBlockRangegRsPgRcLcLiterator), -1, 0, 1, 1, 1, 0, "u 'vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >::iterator' - 11 - -", (char*) NULL, (void*) NULL, 0);
// automatic destructor
G__memfunc_setup("~iterator", 1000, G__TGoodRunsListsCint_500_0_17, (int) ('y'), -1, -1, 0, 0, 1, 1, 0, "", (char*) NULL, (void*) NULL, 0);
G__tag_memfunc_reset();
}
static void G__setup_memfuncRootcLcLTGoodRun(void) {
/* Root::TGoodRun */
G__tag_memfunc_setup(G__get_linked_tagnum(&G__TGoodRunsListsCintLN_RootcLcLTGoodRun));
G__memfunc_setup("TGoodRun",786,G__TGoodRunsListsCint_502_0_1, 105, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_RootcLcLTGoodRun), -1, 0, 0, 1, 1, 0, "", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("TGoodRun",786,G__TGoodRunsListsCint_502_0_2, 105, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_RootcLcLTGoodRun), -1, 0, 1, 1, 1, 0, "i - 'Int_t' 11 - runnr", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("TGoodRun",786,G__TGoodRunsListsCint_502_0_3, 105, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_RootcLcLTGoodRun), -1, 0, 1, 1, 1, 0, "u 'Root::TGoodRun' - 11 - other", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("operator=",937,G__TGoodRunsListsCint_502_0_4, 117, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_RootcLcLTGoodRun), -1, 1, 1, 1, 1, 0, "u 'Root::TGoodRun' - 11 - other", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("GetOverlapWith",1429,G__TGoodRunsListsCint_502_0_5, 117, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_RootcLcLTGoodRun), -1, 0, 1, 1, 1, 9, "u 'Root::TGoodRun' - 11 - other", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("GetSumWith",1009,G__TGoodRunsListsCint_502_0_6, 117, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_RootcLcLTGoodRun), -1, 0, 1, 1, 1, 9, "u 'Root::TGoodRun' - 11 - other", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("GetPartOnlyIn",1296,G__TGoodRunsListsCint_502_0_7, 117, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_RootcLcLTGoodRun), -1, 0, 1, 1, 1, 9, "u 'Root::TGoodRun' - 11 - other", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("GetPartNotIn",1183,G__TGoodRunsListsCint_502_0_8, 117, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_RootcLcLTGoodRun), -1, 0, 1, 1, 1, 9, "u 'Root::TGoodRun' - 11 - other", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("IsEmpty",715,G__TGoodRunsListsCint_502_0_9, 103, -1, G__defined_typename("Bool_t"), 0, 0, 1, 1, 8, "", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("HasLB",426,G__TGoodRunsListsCint_502_0_10, 103, -1, G__defined_typename("Bool_t"), 0, 1, 1, 1, 8, "i - 'Int_t' 11 - lumiblocknr", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("Find",385,G__TGoodRunsListsCint_502_0_11, 117, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_vectorlERootcLcLTLumiBlockRangecOallocatorlERootcLcLTLumiBlockRangegRsPgRcLcLiterator), -1, 0, 1, 1, 1, 0, "i - 'Int_t' 11 - lumiblocknr", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("Find",385,G__TGoodRunsListsCint_502_0_12, 117, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_vectorlERootcLcLTLumiBlockRangecOallocatorlERootcLcLTLumiBlockRangegRsPgRcLcLiterator), G__defined_typename("vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >::const_iterator"), 0, 1, 1, 1, 8, "i - 'Int_t' 11 - lumiblocknr", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("GetRunNumber",1214,G__TGoodRunsListsCint_502_0_13, 105, -1, G__defined_typename("Int_t"), 0, 0, 1, 1, 8, "", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("SetRunNumber",1226,G__TGoodRunsListsCint_502_0_14, 121, -1, -1, 0, 1, 1, 1, 0, "i - 'Int_t' 11 - runnr", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("Summary",750,G__TGoodRunsListsCint_502_0_15, 121, -1, -1, 0, 0, 1, 1, 8, "", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("Sort",424,G__TGoodRunsListsCint_502_0_16, 121, -1, -1, 0, 0, 1, 1, 0, "", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("Compress",844,G__TGoodRunsListsCint_502_0_17, 121, -1, -1, 0, 0, 1, 1, 0, "", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("AddLB",407,G__TGoodRunsListsCint_502_0_18, 121, -1, -1, 0, 1, 1, 1, 0, "i - 'Int_t' 11 - lumiblocknr", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("Class",502,G__TGoodRunsListsCint_502_0_19, 85, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_TClass), -1, 0, 0, 3, 1, 0, "", (char*)NULL, (void*) G__func2void( (TClass* (*)())(&Root::TGoodRun::Class) ), 0);
G__memfunc_setup("Class_Name",982,G__TGoodRunsListsCint_502_0_20, 67, -1, -1, 0, 0, 3, 1, 1, "", (char*)NULL, (void*) G__func2void( (const char* (*)())(&Root::TGoodRun::Class_Name) ), 0);
G__memfunc_setup("Class_Version",1339,G__TGoodRunsListsCint_502_0_21, 115, -1, G__defined_typename("Version_t"), 0, 0, 3, 1, 0, "", (char*)NULL, (void*) G__func2void( (Version_t (*)())(&Root::TGoodRun::Class_Version) ), 0);
G__memfunc_setup("Dictionary",1046,G__TGoodRunsListsCint_502_0_22, 121, -1, -1, 0, 0, 3, 1, 0, "", (char*)NULL, (void*) G__func2void( (void (*)())(&Root::TGoodRun::Dictionary) ), 0);
G__memfunc_setup("IsA",253,(G__InterfaceMethod) NULL,85, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_TClass), -1, 0, 0, 1, 1, 8, "", (char*)NULL, (void*) NULL, 1);
G__memfunc_setup("ShowMembers",1132,(G__InterfaceMethod) NULL,121, -1, -1, 0, 1, 1, 1, 0, "u 'TMemberInspector' - 1 - insp", (char*)NULL, (void*) NULL, 1);
G__memfunc_setup("Streamer",835,(G__InterfaceMethod) NULL,121, -1, -1, 0, 1, 1, 1, 0, "u 'TBuffer' - 1 - b", (char*)NULL, (void*) NULL, 1);
G__memfunc_setup("StreamerNVirtual",1656,G__TGoodRunsListsCint_502_0_26, 121, -1, -1, 0, 1, 1, 1, 0, "u 'TBuffer' - 1 - b", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("DeclFileName",1145,G__TGoodRunsListsCint_502_0_27, 67, -1, -1, 0, 0, 3, 1, 1, "", (char*)NULL, (void*) G__func2void( (const char* (*)())(&Root::TGoodRun::DeclFileName) ), 0);
G__memfunc_setup("ImplFileLine",1178,G__TGoodRunsListsCint_502_0_28, 105, -1, -1, 0, 0, 3, 1, 0, "", (char*)NULL, (void*) G__func2void( (int (*)())(&Root::TGoodRun::ImplFileLine) ), 0);
G__memfunc_setup("ImplFileName",1171,G__TGoodRunsListsCint_502_0_29, 67, -1, -1, 0, 0, 3, 1, 1, "", (char*)NULL, (void*) G__func2void( (const char* (*)())(&Root::TGoodRun::ImplFileName) ), 0);
G__memfunc_setup("DeclFileLine",1152,G__TGoodRunsListsCint_502_0_30, 105, -1, -1, 0, 0, 3, 1, 0, "", (char*)NULL, (void*) G__func2void( (int (*)())(&Root::TGoodRun::DeclFileLine) ), 0);
// automatic destructor
G__memfunc_setup("~TGoodRun", 912, G__TGoodRunsListsCint_502_0_31, (int) ('y'), -1, -1, 0, 0, 1, 1, 0, "", (char*) NULL, (void*) NULL, 1);
G__tag_memfunc_reset();
}
static void G__setup_memfuncRootcLcLTGoodRunsList(void) {
/* Root::TGoodRunsList */
G__tag_memfunc_setup(G__get_linked_tagnum(&G__TGoodRunsListsCintLN_RootcLcLTGoodRunsList));
G__memfunc_setup("TGoodRunsList",1313,G__TGoodRunsListsCint_504_0_1, 105, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_RootcLcLTGoodRunsList), -1, 0, 0, 1, 1, 0, "", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("TGoodRunsList",1313,G__TGoodRunsListsCint_504_0_2, 105, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_RootcLcLTGoodRunsList), -1, 0, 1, 1, 1, 0, "C - - 10 - name", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("TGoodRunsList",1313,G__TGoodRunsListsCint_504_0_3, 105, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_RootcLcLTGoodRunsList), -1, 0, 1, 1, 1, 0, "u 'Root::TGoodRunsList' - 11 - other", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("operator=",937,G__TGoodRunsListsCint_504_0_4, 117, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_RootcLcLTGoodRunsList), -1, 1, 1, 1, 1, 0, "u 'Root::TGoodRunsList' - 11 - other", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("AddGRL",494,G__TGoodRunsListsCint_504_0_5, 121, -1, -1, 0, 1, 1, 1, 0, "u 'Root::TGoodRunsList' - 11 - other", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("GetOverlapWith",1429,G__TGoodRunsListsCint_504_0_6, 117, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_RootcLcLTGoodRunsList), -1, 0, 1, 1, 1, 9, "u 'Root::TGoodRunsList' - 11 - other", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("GetSumWith",1009,G__TGoodRunsListsCint_504_0_7, 117, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_RootcLcLTGoodRunsList), -1, 0, 1, 1, 1, 9, "u 'Root::TGoodRunsList' - 11 - other", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("GetPartOnlyIn",1296,G__TGoodRunsListsCint_504_0_8, 117, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_RootcLcLTGoodRunsList), -1, 0, 1, 1, 1, 9, "u 'Root::TGoodRunsList' - 11 - other", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("GetPartNotIn",1183,G__TGoodRunsListsCint_504_0_9, 117, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_RootcLcLTGoodRunsList), -1, 0, 1, 1, 1, 9, "u 'Root::TGoodRunsList' - 11 - other", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("HasTriggerInfo",1404,G__TGoodRunsListsCint_504_0_10, 103, -1, G__defined_typename("Bool_t"), 0, 0, 1, 1, 8, "", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("HasRun",593,G__TGoodRunsListsCint_504_0_11, 103, -1, G__defined_typename("Bool_t"), 0, 1, 1, 1, 8, "i - 'Int_t' 11 - runnr", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("HasRunLumiBlock",1491,G__TGoodRunsListsCint_504_0_12, 103, -1, G__defined_typename("Bool_t"), 0, 2, 1, 1, 8,
"i - 'Int_t' 11 - runnr i - 'Int_t' 11 - lumiblocknr", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("HasSameGRLInfo",1299,G__TGoodRunsListsCint_504_0_13, 103, -1, G__defined_typename("Bool_t"), 0, 1, 1, 1, 8, "u 'Root::TGoodRunsList' - 11 - other", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("HasOverlapWith",1425,G__TGoodRunsListsCint_504_0_14, 103, -1, G__defined_typename("Bool_t"), 0, 2, 1, 1, 8,
"u 'Root::TGoodRunsList' - 11 - other g - - 0 'false' verb", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("AddRunLumiBlock",1472,G__TGoodRunsListsCint_504_0_15, 121, -1, -1, 0, 2, 1, 1, 0,
"i - 'Int_t' 11 - runnr i - 'Int_t' 11 - lumiblocknr", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("SetVersion",1042,G__TGoodRunsListsCint_504_0_16, 121, -1, -1, 0, 1, 1, 1, 0, "u 'TString' - 11 - version", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("AddMetaData",1034,G__TGoodRunsListsCint_504_0_17, 121, -1, -1, 0, 2, 1, 1, 0,
"u 'TString' - 11 - key u 'TString' - 11 - value", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("SetMetaData",1069,G__TGoodRunsListsCint_504_0_18, 121, -1, -1, 0, 1, 1, 1, 0, "u 'map<TString,TString,less<TString>,allocator<pair<const TString,TString> > >' 'map<TString,TString>' 11 - metadata", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("SetCheckGRLInfo",1403,G__TGoodRunsListsCint_504_0_19, 121, -1, -1, 0, 1, 1, 1, 0, "g - 'Bool_t' 0 'kTRUE' check", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("GetCheckGRLInfo",1391,G__TGoodRunsListsCint_504_0_20, 103, -1, G__defined_typename("Bool_t"), 1, 0, 1, 1, 9, "", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("GetVersion",1030,G__TGoodRunsListsCint_504_0_21, 117, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_TString), -1, 1, 0, 1, 1, 9, "", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("GetMetaData",1057,G__TGoodRunsListsCint_504_0_22, 117, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_maplETStringcOTStringcOlesslETStringgRcOallocatorlEpairlEconstsPTStringcOTStringgRsPgRsPgR), G__defined_typename("map<TString,TString>"), 1, 0, 1, 1, 9, "", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("GetMetaDataSize",1468,G__TGoodRunsListsCint_504_0_23, 104, -1, -1, 0, 0, 1, 1, 8, "", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("Summary",750,G__TGoodRunsListsCint_504_0_24, 121, -1, -1, 0, 1, 1, 1, 8, "g - 'Bool_t' 0 'kFALSE' verbose", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("IsEmpty",715,G__TGoodRunsListsCint_504_0_25, 103, -1, G__defined_typename("Bool_t"), 0, 0, 1, 1, 8, "", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("GetRunlist",1041,G__TGoodRunsListsCint_504_0_26, 117, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_vectorlEintcOallocatorlEintgRsPgR), G__defined_typename("vector<int>"), 0, 0, 1, 1, 9, "", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("GetGoodRuns",1105,G__TGoodRunsListsCint_504_0_27, 117, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_vectorlERootcLcLTGoodRuncOallocatorlERootcLcLTGoodRungRsPgR), G__defined_typename("vector<Root::TGoodRun>"), 0, 0, 1, 1, 9, "", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("GetTriggerList",1424,G__TGoodRunsListsCint_504_0_28, 117, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_vectorlEstringcOallocatorlEstringgRsPgR), G__defined_typename("vector<std::string>"), 0, 0, 1, 1, 9, "", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("GetStreamList",1320,G__TGoodRunsListsCint_504_0_29, 117, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_vectorlEstringcOallocatorlEstringgRsPgR), G__defined_typename("vector<std::string>"), 0, 0, 1, 1, 9, "", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("GetSuggestedName",1612,G__TGoodRunsListsCint_504_0_30, 117, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_TString), -1, 0, 0, 1, 1, 9, "", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("Compress",844,G__TGoodRunsListsCint_504_0_31, 121, -1, -1, 0, 0, 1, 1, 0, "", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("Class",502,G__TGoodRunsListsCint_504_0_32, 85, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_TClass), -1, 0, 0, 3, 1, 0, "", (char*)NULL, (void*) G__func2void( (TClass* (*)())(&Root::TGoodRunsList::Class) ), 0);
G__memfunc_setup("Class_Name",982,G__TGoodRunsListsCint_504_0_33, 67, -1, -1, 0, 0, 3, 1, 1, "", (char*)NULL, (void*) G__func2void( (const char* (*)())(&Root::TGoodRunsList::Class_Name) ), 0);
G__memfunc_setup("Class_Version",1339,G__TGoodRunsListsCint_504_0_34, 115, -1, G__defined_typename("Version_t"), 0, 0, 3, 1, 0, "", (char*)NULL, (void*) G__func2void( (Version_t (*)())(&Root::TGoodRunsList::Class_Version) ), 0);
G__memfunc_setup("Dictionary",1046,G__TGoodRunsListsCint_504_0_35, 121, -1, -1, 0, 0, 3, 1, 0, "", (char*)NULL, (void*) G__func2void( (void (*)())(&Root::TGoodRunsList::Dictionary) ), 0);
G__memfunc_setup("IsA",253,(G__InterfaceMethod) NULL,85, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_TClass), -1, 0, 0, 1, 1, 8, "", (char*)NULL, (void*) NULL, 1);
G__memfunc_setup("ShowMembers",1132,(G__InterfaceMethod) NULL,121, -1, -1, 0, 1, 1, 1, 0, "u 'TMemberInspector' - 1 - insp", (char*)NULL, (void*) NULL, 1);
G__memfunc_setup("Streamer",835,(G__InterfaceMethod) NULL,121, -1, -1, 0, 1, 1, 1, 0, "u 'TBuffer' - 1 - b", (char*)NULL, (void*) NULL, 1);
G__memfunc_setup("StreamerNVirtual",1656,G__TGoodRunsListsCint_504_0_39, 121, -1, -1, 0, 1, 1, 1, 0, "u 'TBuffer' - 1 - b", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("DeclFileName",1145,G__TGoodRunsListsCint_504_0_40, 67, -1, -1, 0, 0, 3, 1, 1, "", (char*)NULL, (void*) G__func2void( (const char* (*)())(&Root::TGoodRunsList::DeclFileName) ), 0);
G__memfunc_setup("ImplFileLine",1178,G__TGoodRunsListsCint_504_0_41, 105, -1, -1, 0, 0, 3, 1, 0, "", (char*)NULL, (void*) G__func2void( (int (*)())(&Root::TGoodRunsList::ImplFileLine) ), 0);
G__memfunc_setup("ImplFileName",1171,G__TGoodRunsListsCint_504_0_42, 67, -1, -1, 0, 0, 3, 1, 1, "", (char*)NULL, (void*) G__func2void( (const char* (*)())(&Root::TGoodRunsList::ImplFileName) ), 0);
G__memfunc_setup("DeclFileLine",1152,G__TGoodRunsListsCint_504_0_43, 105, -1, -1, 0, 0, 3, 1, 0, "", (char*)NULL, (void*) G__func2void( (int (*)())(&Root::TGoodRunsList::DeclFileLine) ), 0);
// automatic destructor
G__memfunc_setup("~TGoodRunsList", 1439, G__TGoodRunsListsCint_504_0_44, (int) ('y'), -1, -1, 0, 0, 1, 1, 0, "", (char*) NULL, (void*) NULL, 1);
G__tag_memfunc_reset();
}
static void G__setup_memfuncmaplEintcORootcLcLTGoodRuncOlesslEintgRcOallocatorlEpairlEconstsPintcORootcLcLTGoodRungRsPgRsPgR(void) {
/* map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > > */
G__tag_memfunc_setup(G__get_linked_tagnum(&G__TGoodRunsListsCintLN_maplEintcORootcLcLTGoodRuncOlesslEintgRcOallocatorlEpairlEconstsPintcORootcLcLTGoodRungRsPgRsPgR));
G__memfunc_setup("map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > >",7094,G__TGoodRunsListsCint_507_0_1, 105, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_maplEintcORootcLcLTGoodRuncOlesslEintgRcOallocatorlEpairlEconstsPintcORootcLcLTGoodRungRsPgRsPgR), -1, 0, 0, 1, 1, 0, "", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > >",7094,G__TGoodRunsListsCint_507_0_2, 105, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_maplEintcORootcLcLTGoodRuncOlesslEintgRcOallocatorlEpairlEconstsPintcORootcLcLTGoodRungRsPgRsPgR), -1, 0, 2, 1, 1, 0,
"u 'map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > >::iterator' - 0 - first u 'map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > >::iterator' - 0 - last", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > >",7094,G__TGoodRunsListsCint_507_0_3, 105, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_maplEintcORootcLcLTGoodRuncOlesslEintgRcOallocatorlEpairlEconstsPintcORootcLcLTGoodRungRsPgRsPgR), -1, 0, 2, 1, 1, 0,
"u 'map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > >::reverse_iterator' - 0 - first u 'map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > >::reverse_iterator' - 0 - last", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > >",7094,G__TGoodRunsListsCint_507_0_4, 105, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_maplEintcORootcLcLTGoodRuncOlesslEintgRcOallocatorlEpairlEconstsPintcORootcLcLTGoodRungRsPgRsPgR), -1, 0, 1, 1, 1, 0, "u 'map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > >' - 11 - x", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("operator=",937,G__TGoodRunsListsCint_507_0_5, 117, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_maplEintcORootcLcLTGoodRuncOlesslEintgRcOallocatorlEpairlEconstsPintcORootcLcLTGoodRungRsPgRsPgR), -1, 1, 1, 1, 1, 0, "u 'map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > >' - 11 - x", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("begin",517,G__TGoodRunsListsCint_507_0_6, 117, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_maplEintcORootcLcLTGoodRuncOlesslEintgRcOallocatorlEpairlEconstsPintcORootcLcLTGoodRungRsPgRsPgRcLcLiterator), -1, 0, 0, 1, 1, 0, "", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("end",311,G__TGoodRunsListsCint_507_0_7, 117, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_maplEintcORootcLcLTGoodRuncOlesslEintgRcOallocatorlEpairlEconstsPintcORootcLcLTGoodRungRsPgRsPgRcLcLiterator), -1, 0, 0, 1, 1, 0, "", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("rbegin",631,G__TGoodRunsListsCint_507_0_8, 117, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_maplEintcORootcLcLTGoodRuncOlesslEintgRcOallocatorlEpairlEconstsPintcORootcLcLTGoodRungRsPgRsPgRcLcLreverse_iterator), -1, 0, 0, 1, 1, 0, "", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("rend",425,G__TGoodRunsListsCint_507_0_9, 117, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_maplEintcORootcLcLTGoodRuncOlesslEintgRcOallocatorlEpairlEconstsPintcORootcLcLTGoodRungRsPgRsPgRcLcLreverse_iterator), -1, 0, 0, 1, 1, 0, "", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("empty",559,G__TGoodRunsListsCint_507_0_10, 103, -1, -1, 0, 0, 1, 1, 8, "", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("size",443,G__TGoodRunsListsCint_507_0_11, 104, -1, G__defined_typename("map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > >::size_type"), 0, 0, 1, 1, 8, "", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("max_size",864,G__TGoodRunsListsCint_507_0_12, 104, -1, G__defined_typename("map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > >::size_type"), 0, 0, 1, 1, 8, "", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("operator[]",1060,G__TGoodRunsListsCint_507_0_13, 117, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_RootcLcLTGoodRun), -1, 1, 1, 1, 1, 0, "i - - 11 - x", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("insert",661,G__TGoodRunsListsCint_507_0_14, 117, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_pairlEmaplEintcORootcLcLTGoodRuncOlesslEintgRcOallocatorlEpairlEconstsPintcORootcLcLTGoodRungRsPgRsPgRcLcLiteratorcOboolgR), -1, 0, 1, 1, 1, 0, "u 'pair<int,Root::TGoodRun>' 'map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > >::value_type' 11 - x", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("insert",661,G__TGoodRunsListsCint_507_0_15, 117, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_maplEintcORootcLcLTGoodRuncOlesslEintgRcOallocatorlEpairlEconstsPintcORootcLcLTGoodRungRsPgRsPgRcLcLiterator), -1, 0, 2, 1, 1, 0,
"u 'map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > >::iterator' - 0 - position u 'pair<int,Root::TGoodRun>' 'map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > >::value_type' 11 - x", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("insert",661,G__TGoodRunsListsCint_507_0_16, 121, -1, -1, 0, 2, 1, 1, 0,
"u 'map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > >::iterator' - 0 - first u 'map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > >::iterator' - 0 - last", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("insert",661,G__TGoodRunsListsCint_507_0_17, 121, -1, -1, 0, 2, 1, 1, 0,
"u 'map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > >::reverse_iterator' - 0 - first u 'map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > >::reverse_iterator' - 0 - last", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("erase",528,G__TGoodRunsListsCint_507_0_18, 121, -1, -1, 0, 1, 1, 1, 0, "u 'map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > >::iterator' - 0 - position", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("erase",528,G__TGoodRunsListsCint_507_0_19, 104, -1, G__defined_typename("map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > >::size_type"), 0, 1, 1, 1, 0, "i - - 11 - x", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("erase",528,G__TGoodRunsListsCint_507_0_20, 121, -1, -1, 0, 2, 1, 1, 0,
"u 'map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > >::iterator' - 0 - first u 'map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > >::iterator' - 0 - last", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("swap",443,G__TGoodRunsListsCint_507_0_21, 121, -1, -1, 0, 1, 1, 1, 0, "u 'map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > >' - 1 - -", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("clear",519,G__TGoodRunsListsCint_507_0_22, 121, -1, -1, 0, 0, 1, 1, 0, "", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("find",417,G__TGoodRunsListsCint_507_0_23, 117, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_maplEintcORootcLcLTGoodRuncOlesslEintgRcOallocatorlEpairlEconstsPintcORootcLcLTGoodRungRsPgRsPgRcLcLiterator), -1, 0, 1, 1, 1, 0, "i - - 11 - x", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("count",553,G__TGoodRunsListsCint_507_0_24, 104, -1, G__defined_typename("map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > >::size_type"), 0, 1, 1, 1, 8, "i - - 11 - x", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("lower_bound",1184,G__TGoodRunsListsCint_507_0_25, 117, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_maplEintcORootcLcLTGoodRuncOlesslEintgRcOallocatorlEpairlEconstsPintcORootcLcLTGoodRungRsPgRsPgRcLcLiterator), -1, 0, 1, 1, 1, 0, "i - - 11 - x", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("upper_bound",1187,G__TGoodRunsListsCint_507_0_26, 117, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_maplEintcORootcLcLTGoodRuncOlesslEintgRcOallocatorlEpairlEconstsPintcORootcLcLTGoodRungRsPgRsPgRcLcLiterator), -1, 0, 1, 1, 1, 0, "i - - 11 - x", (char*)NULL, (void*) NULL, 0);
// automatic destructor
G__memfunc_setup("~map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > >", 7220, G__TGoodRunsListsCint_507_0_27, (int) ('y'), -1, -1, 0, 0, 1, 1, 0, "", (char*) NULL, (void*) NULL, 0);
G__tag_memfunc_reset();
}
static void G__setup_memfuncpairlEintcORootcLcLTGoodRungR(void) {
/* pair<int,Root::TGoodRun> */
G__tag_memfunc_setup(G__get_linked_tagnum(&G__TGoodRunsListsCintLN_pairlEintcORootcLcLTGoodRungR));
G__memfunc_setup("pair<int,Root::TGoodRun>",2247,G__TGoodRunsListsCint_508_0_1, 105, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_pairlEintcORootcLcLTGoodRungR), -1, 0, 0, 1, 1, 0, "", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("pair<int,Root::TGoodRun>",2247,G__TGoodRunsListsCint_508_0_2, 105, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_pairlEintcORootcLcLTGoodRungR), -1, 0, 2, 1, 1, 0,
"i - - 11 - a u 'Root::TGoodRun' - 11 - b", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("operator=",937,(G__InterfaceMethod) NULL, 117, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_pairlEintcORootcLcLTGoodRungR), -1, 1, 1, 1, 4, 0, "u 'pair<int,Root::TGoodRun>' - 11 - x", (char*)NULL, (void*) NULL, 0);
// automatic copy constructor
G__memfunc_setup("pair<int,Root::TGoodRun>", 2247, G__TGoodRunsListsCint_508_0_4, (int) ('i'),
G__get_linked_tagnum(&G__TGoodRunsListsCintLN_pairlEintcORootcLcLTGoodRungR), -1, 0, 1, 1, 1, 0, "u 'pair<int,Root::TGoodRun>' - 11 - -", (char*) NULL, (void*) NULL, 0);
// automatic destructor
G__memfunc_setup("~pair<int,Root::TGoodRun>", 2373, G__TGoodRunsListsCint_508_0_5, (int) ('y'), -1, -1, 0, 0, 1, 1, 0, "", (char*) NULL, (void*) NULL, 0);
G__tag_memfunc_reset();
}
static void G__setup_memfuncmaplEintcORootcLcLTGoodRuncOlesslEintgRcOallocatorlEpairlEconstsPintcORootcLcLTGoodRungRsPgRsPgRcLcLiterator(void) {
/* map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > >::iterator */
G__tag_memfunc_setup(G__get_linked_tagnum(&G__TGoodRunsListsCintLN_maplEintcORootcLcLTGoodRuncOlesslEintgRcOallocatorlEpairlEconstsPintcORootcLcLTGoodRungRsPgRsPgRcLcLiterator));
G__memfunc_setup("iterator",874,G__TGoodRunsListsCint_509_0_1, 105, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_maplEintcORootcLcLTGoodRuncOlesslEintgRcOallocatorlEpairlEconstsPintcORootcLcLTGoodRungRsPgRsPgRcLcLiterator), -1, 0, 0, 1, 1, 0, "", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("iterator",874,G__TGoodRunsListsCint_509_0_2, 105, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_maplEintcORootcLcLTGoodRuncOlesslEintgRcOallocatorlEpairlEconstsPintcORootcLcLTGoodRungRsPgRsPgRcLcLiterator), -1, 0, 1, 1, 1, 0, "u 'map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > >::iterator' - 11 - x", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("operator=",937,G__TGoodRunsListsCint_509_0_3, 117, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_maplEintcORootcLcLTGoodRuncOlesslEintgRcOallocatorlEpairlEconstsPintcORootcLcLTGoodRungRsPgRsPgRcLcLiterator), -1, 1, 1, 1, 1, 0, "u 'map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > >::iterator' - 11 - x", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("operator*",918,G__TGoodRunsListsCint_509_0_4, 117, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_pairlEintcORootcLcLTGoodRungR), G__defined_typename("map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > >::value_type"), 1, 0, 1, 1, 0, "", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("operator->",983,G__TGoodRunsListsCint_509_0_5, 85, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_pairlEintcORootcLcLTGoodRungR), G__defined_typename("map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > >::value_type"), 0, 0, 1, 1, 0, "", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("operator++",962,G__TGoodRunsListsCint_509_0_6, 117, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_maplEintcORootcLcLTGoodRuncOlesslEintgRcOallocatorlEpairlEconstsPintcORootcLcLTGoodRungRsPgRsPgRcLcLiterator), -1, 1, 0, 1, 1, 0, "", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("operator++",962,G__TGoodRunsListsCint_509_0_7, 117, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_maplEintcORootcLcLTGoodRuncOlesslEintgRcOallocatorlEpairlEconstsPintcORootcLcLTGoodRungRsPgRsPgRcLcLiterator), -1, 0, 1, 1, 1, 0, "i - - 0 - a", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("operator--",966,G__TGoodRunsListsCint_509_0_8, 117, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_maplEintcORootcLcLTGoodRuncOlesslEintgRcOallocatorlEpairlEconstsPintcORootcLcLTGoodRungRsPgRsPgRcLcLiterator), -1, 1, 0, 1, 1, 0, "", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("operator--",966,G__TGoodRunsListsCint_509_0_9, 117, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_maplEintcORootcLcLTGoodRuncOlesslEintgRcOallocatorlEpairlEconstsPintcORootcLcLTGoodRungRsPgRsPgRcLcLiterator), -1, 0, 1, 1, 1, 0, "i - - 0 - a", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("operator==",998,G__TGoodRunsListsCint_509_0_10, 103, -1, -1, 0, 1, 1, 1, 0, "u 'map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > >::iterator' - 11 - x", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("operator!=",970,G__TGoodRunsListsCint_509_0_11, 103, -1, -1, 0, 1, 1, 1, 0, "u 'map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > >::iterator' - 11 - x", (char*)NULL, (void*) NULL, 0);
// automatic destructor
G__memfunc_setup("~iterator", 1000, G__TGoodRunsListsCint_509_0_12, (int) ('y'), -1, -1, 0, 0, 1, 1, 0, "", (char*) NULL, (void*) NULL, 0);
G__tag_memfunc_reset();
}
static void G__setup_memfuncmaplETStringcOTStringcOlesslETStringgRcOallocatorlEpairlEconstsPTStringcOTStringgRsPgRsPgR(void) {
/* map<TString,TString,less<TString>,allocator<pair<const TString,TString> > > */
G__tag_memfunc_setup(G__get_linked_tagnum(&G__TGoodRunsListsCintLN_maplETStringcOTStringcOlesslETStringgRcOallocatorlEpairlEconstsPTStringcOTStringgRsPgRsPgR));
G__memfunc_setup("map<TString,TString,less<TString>,allocator<pair<const TString,TString> > >",7032,G__TGoodRunsListsCint_516_0_1, 105, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_maplETStringcOTStringcOlesslETStringgRcOallocatorlEpairlEconstsPTStringcOTStringgRsPgRsPgR), -1, 0, 0, 1, 1, 0, "", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("map<TString,TString,less<TString>,allocator<pair<const TString,TString> > >",7032,G__TGoodRunsListsCint_516_0_2, 105, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_maplETStringcOTStringcOlesslETStringgRcOallocatorlEpairlEconstsPTStringcOTStringgRsPgRsPgR), -1, 0, 2, 1, 1, 0,
"u 'map<TString,TString,less<TString>,allocator<pair<const TString,TString> > >::iterator' - 0 - first u 'map<TString,TString,less<TString>,allocator<pair<const TString,TString> > >::iterator' - 0 - last", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("map<TString,TString,less<TString>,allocator<pair<const TString,TString> > >",7032,G__TGoodRunsListsCint_516_0_3, 105, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_maplETStringcOTStringcOlesslETStringgRcOallocatorlEpairlEconstsPTStringcOTStringgRsPgRsPgR), -1, 0, 2, 1, 1, 0,
"u 'map<TString,TString,less<TString>,allocator<pair<const TString,TString> > >::reverse_iterator' - 0 - first u 'map<TString,TString,less<TString>,allocator<pair<const TString,TString> > >::reverse_iterator' - 0 - last", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("map<TString,TString,less<TString>,allocator<pair<const TString,TString> > >",7032,G__TGoodRunsListsCint_516_0_4, 105, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_maplETStringcOTStringcOlesslETStringgRcOallocatorlEpairlEconstsPTStringcOTStringgRsPgRsPgR), -1, 0, 1, 1, 1, 0, "u 'map<TString,TString,less<TString>,allocator<pair<const TString,TString> > >' - 11 - x", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("operator=",937,G__TGoodRunsListsCint_516_0_5, 117, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_maplETStringcOTStringcOlesslETStringgRcOallocatorlEpairlEconstsPTStringcOTStringgRsPgRsPgR), -1, 1, 1, 1, 1, 0, "u 'map<TString,TString,less<TString>,allocator<pair<const TString,TString> > >' - 11 - x", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("begin",517,G__TGoodRunsListsCint_516_0_6, 117, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_maplETStringcOTStringcOlesslETStringgRcOallocatorlEpairlEconstsPTStringcOTStringgRsPgRsPgRcLcLiterator), -1, 0, 0, 1, 1, 0, "", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("end",311,G__TGoodRunsListsCint_516_0_7, 117, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_maplETStringcOTStringcOlesslETStringgRcOallocatorlEpairlEconstsPTStringcOTStringgRsPgRsPgRcLcLiterator), -1, 0, 0, 1, 1, 0, "", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("rbegin",631,G__TGoodRunsListsCint_516_0_8, 117, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_maplETStringcOTStringcOlesslETStringgRcOallocatorlEpairlEconstsPTStringcOTStringgRsPgRsPgRcLcLreverse_iterator), -1, 0, 0, 1, 1, 0, "", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("rend",425,G__TGoodRunsListsCint_516_0_9, 117, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_maplETStringcOTStringcOlesslETStringgRcOallocatorlEpairlEconstsPTStringcOTStringgRsPgRsPgRcLcLreverse_iterator), -1, 0, 0, 1, 1, 0, "", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("empty",559,G__TGoodRunsListsCint_516_0_10, 103, -1, -1, 0, 0, 1, 1, 8, "", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("size",443,G__TGoodRunsListsCint_516_0_11, 104, -1, G__defined_typename("map<TString,TString,less<TString>,allocator<pair<const TString,TString> > >::size_type"), 0, 0, 1, 1, 8, "", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("max_size",864,G__TGoodRunsListsCint_516_0_12, 104, -1, G__defined_typename("map<TString,TString,less<TString>,allocator<pair<const TString,TString> > >::size_type"), 0, 0, 1, 1, 8, "", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("operator[]",1060,G__TGoodRunsListsCint_516_0_13, 117, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_TString), -1, 1, 1, 1, 1, 0, "u 'TString' - 11 - x", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("insert",661,G__TGoodRunsListsCint_516_0_14, 117, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_pairlEmaplETStringcOTStringcOlesslETStringgRcOallocatorlEpairlEconstsPTStringcOTStringgRsPgRsPgRcLcLiteratorcOboolgR), -1, 0, 1, 1, 1, 0, "u 'pair<TString,TString>' 'map<TString,TString,less<TString>,allocator<pair<const TString,TString> > >::value_type' 11 - x", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("insert",661,G__TGoodRunsListsCint_516_0_15, 117, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_maplETStringcOTStringcOlesslETStringgRcOallocatorlEpairlEconstsPTStringcOTStringgRsPgRsPgRcLcLiterator), -1, 0, 2, 1, 1, 0,
"u 'map<TString,TString,less<TString>,allocator<pair<const TString,TString> > >::iterator' - 0 - position u 'pair<TString,TString>' 'map<TString,TString,less<TString>,allocator<pair<const TString,TString> > >::value_type' 11 - x", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("insert",661,G__TGoodRunsListsCint_516_0_16, 121, -1, -1, 0, 2, 1, 1, 0,
"u 'map<TString,TString,less<TString>,allocator<pair<const TString,TString> > >::iterator' - 0 - first u 'map<TString,TString,less<TString>,allocator<pair<const TString,TString> > >::iterator' - 0 - last", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("insert",661,G__TGoodRunsListsCint_516_0_17, 121, -1, -1, 0, 2, 1, 1, 0,
"u 'map<TString,TString,less<TString>,allocator<pair<const TString,TString> > >::reverse_iterator' - 0 - first u 'map<TString,TString,less<TString>,allocator<pair<const TString,TString> > >::reverse_iterator' - 0 - last", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("erase",528,G__TGoodRunsListsCint_516_0_18, 121, -1, -1, 0, 1, 1, 1, 0, "u 'map<TString,TString,less<TString>,allocator<pair<const TString,TString> > >::iterator' - 0 - position", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("erase",528,G__TGoodRunsListsCint_516_0_19, 104, -1, G__defined_typename("map<TString,TString,less<TString>,allocator<pair<const TString,TString> > >::size_type"), 0, 1, 1, 1, 0, "u 'TString' - 11 - x", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("erase",528,G__TGoodRunsListsCint_516_0_20, 121, -1, -1, 0, 2, 1, 1, 0,
"u 'map<TString,TString,less<TString>,allocator<pair<const TString,TString> > >::iterator' - 0 - first u 'map<TString,TString,less<TString>,allocator<pair<const TString,TString> > >::iterator' - 0 - last", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("swap",443,G__TGoodRunsListsCint_516_0_21, 121, -1, -1, 0, 1, 1, 1, 0, "u 'map<TString,TString,less<TString>,allocator<pair<const TString,TString> > >' - 1 - -", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("clear",519,G__TGoodRunsListsCint_516_0_22, 121, -1, -1, 0, 0, 1, 1, 0, "", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("find",417,G__TGoodRunsListsCint_516_0_23, 117, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_maplETStringcOTStringcOlesslETStringgRcOallocatorlEpairlEconstsPTStringcOTStringgRsPgRsPgRcLcLiterator), -1, 0, 1, 1, 1, 0, "u 'TString' - 11 - x", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("count",553,G__TGoodRunsListsCint_516_0_24, 104, -1, G__defined_typename("map<TString,TString,less<TString>,allocator<pair<const TString,TString> > >::size_type"), 0, 1, 1, 1, 8, "u 'TString' - 11 - x", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("lower_bound",1184,G__TGoodRunsListsCint_516_0_25, 117, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_maplETStringcOTStringcOlesslETStringgRcOallocatorlEpairlEconstsPTStringcOTStringgRsPgRsPgRcLcLiterator), -1, 0, 1, 1, 1, 0, "u 'TString' - 11 - x", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("upper_bound",1187,G__TGoodRunsListsCint_516_0_26, 117, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_maplETStringcOTStringcOlesslETStringgRcOallocatorlEpairlEconstsPTStringcOTStringgRsPgRsPgRcLcLiterator), -1, 0, 1, 1, 1, 0, "u 'TString' - 11 - x", (char*)NULL, (void*) NULL, 0);
// automatic destructor
G__memfunc_setup("~map<TString,TString,less<TString>,allocator<pair<const TString,TString> > >", 7158, G__TGoodRunsListsCint_516_0_27, (int) ('y'), -1, -1, 0, 0, 1, 1, 0, "", (char*) NULL, (void*) NULL, 0);
G__tag_memfunc_reset();
}
static void G__setup_memfuncpairlETStringcOTStringgR(void) {
/* pair<TString,TString> */
G__tag_memfunc_setup(G__get_linked_tagnum(&G__TGoodRunsListsCintLN_pairlETStringcOTStringgR));
G__memfunc_setup("pair<TString,TString>",2024,G__TGoodRunsListsCint_517_0_1, 105, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_pairlETStringcOTStringgR), -1, 0, 0, 1, 1, 0, "", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("pair<TString,TString>",2024,G__TGoodRunsListsCint_517_0_2, 105, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_pairlETStringcOTStringgR), -1, 0, 2, 1, 1, 0,
"u 'TString' - 11 - a u 'TString' - 11 - b", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("operator=",937,(G__InterfaceMethod) NULL, 117, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_pairlETStringcOTStringgR), -1, 1, 1, 1, 4, 0, "u 'pair<TString,TString>' - 11 - x", (char*)NULL, (void*) NULL, 0);
// automatic copy constructor
G__memfunc_setup("pair<TString,TString>", 2024, G__TGoodRunsListsCint_517_0_4, (int) ('i'),
G__get_linked_tagnum(&G__TGoodRunsListsCintLN_pairlETStringcOTStringgR), -1, 0, 1, 1, 1, 0, "u 'pair<TString,TString>' - 11 - -", (char*) NULL, (void*) NULL, 0);
// automatic destructor
G__memfunc_setup("~pair<TString,TString>", 2150, G__TGoodRunsListsCint_517_0_5, (int) ('y'), -1, -1, 0, 0, 1, 1, 0, "", (char*) NULL, (void*) NULL, 0);
G__tag_memfunc_reset();
}
static void G__setup_memfuncvectorlERootcLcLTGoodRuncOallocatorlERootcLcLTGoodRungRsPgR(void) {
/* vector<Root::TGoodRun,allocator<Root::TGoodRun> > */
G__tag_memfunc_setup(G__get_linked_tagnum(&G__TGoodRunsListsCintLN_vectorlERootcLcLTGoodRuncOallocatorlERootcLcLTGoodRungRsPgR));
G__memfunc_setup("at",213,G__TGoodRunsListsCint_525_0_1, 117, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_RootcLcLTGoodRun), G__defined_typename("vector<Root::TGoodRun,allocator<Root::TGoodRun> >::reference"), 1, 1, 1, 1, 0, "h - 'vector<Root::TGoodRun,allocator<Root::TGoodRun> >::size_type' 0 - n", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("at",213,G__TGoodRunsListsCint_525_0_2, 117, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_RootcLcLTGoodRun), G__defined_typename("vector<Root::TGoodRun,allocator<Root::TGoodRun> >::const_reference"), 1, 1, 1, 1, 8, "h - 'vector<Root::TGoodRun,allocator<Root::TGoodRun> >::size_type' 0 - n", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("begin",517,G__TGoodRunsListsCint_525_0_3, 117, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_vectorlERootcLcLTGoodRuncOallocatorlERootcLcLTGoodRungRsPgRcLcLiterator), -1, 0, 0, 1, 1, 0, "", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("end",311,G__TGoodRunsListsCint_525_0_4, 117, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_vectorlERootcLcLTGoodRuncOallocatorlERootcLcLTGoodRungRsPgRcLcLiterator), -1, 0, 0, 1, 1, 0, "", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("rbegin",631,G__TGoodRunsListsCint_525_0_5, 117, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_reverse_iteratorlEvectorlERootcLcLTGoodRuncOallocatorlERootcLcLTGoodRungRsPgRcLcLiteratorgR), G__defined_typename("vector<Root::TGoodRun,allocator<Root::TGoodRun> >::reverse_iterator"), 0, 0, 1, 1, 0, "", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("rend",425,G__TGoodRunsListsCint_525_0_6, 117, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_reverse_iteratorlEvectorlERootcLcLTGoodRuncOallocatorlERootcLcLTGoodRungRsPgRcLcLiteratorgR), G__defined_typename("vector<Root::TGoodRun,allocator<Root::TGoodRun> >::reverse_iterator"), 0, 0, 1, 1, 0, "", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("size",443,G__TGoodRunsListsCint_525_0_7, 104, -1, G__defined_typename("vector<Root::TGoodRun,allocator<Root::TGoodRun> >::size_type"), 0, 0, 1, 1, 8, "", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("max_size",864,G__TGoodRunsListsCint_525_0_8, 104, -1, G__defined_typename("vector<Root::TGoodRun,allocator<Root::TGoodRun> >::size_type"), 0, 0, 1, 1, 8, "", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("resize",658,G__TGoodRunsListsCint_525_0_9, 121, -1, -1, 0, 1, 1, 1, 0, "h - 'vector<Root::TGoodRun,allocator<Root::TGoodRun> >::size_type' 0 - sz", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("resize",658,G__TGoodRunsListsCint_525_0_10, 121, -1, -1, 0, 2, 1, 1, 0,
"h - 'vector<Root::TGoodRun,allocator<Root::TGoodRun> >::size_type' 0 - sz u 'Root::TGoodRun' - 0 - c", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("capacity",846,G__TGoodRunsListsCint_525_0_11, 104, -1, G__defined_typename("vector<Root::TGoodRun,allocator<Root::TGoodRun> >::size_type"), 0, 0, 1, 1, 8, "", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("empty",559,G__TGoodRunsListsCint_525_0_12, 103, -1, -1, 0, 0, 1, 1, 8, "", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("operator[]",1060,G__TGoodRunsListsCint_525_0_13, 117, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_RootcLcLTGoodRun), G__defined_typename("vector<Root::TGoodRun,allocator<Root::TGoodRun> >::reference"), 1, 1, 1, 1, 0, "h - 'vector<Root::TGoodRun,allocator<Root::TGoodRun> >::size_type' 0 - n", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("operator[]",1060,G__TGoodRunsListsCint_525_0_14, 117, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_RootcLcLTGoodRun), G__defined_typename("vector<Root::TGoodRun,allocator<Root::TGoodRun> >::const_reference"), 1, 1, 1, 1, 8, "h - 'vector<Root::TGoodRun,allocator<Root::TGoodRun> >::size_type' 0 - n", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("vector<Root::TGoodRun,allocator<Root::TGoodRun> >",4584,G__TGoodRunsListsCint_525_0_15, 105, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_vectorlERootcLcLTGoodRuncOallocatorlERootcLcLTGoodRungRsPgR), -1, 0, 0, 1, 1, 0, "", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("vector<Root::TGoodRun,allocator<Root::TGoodRun> >",4584,G__TGoodRunsListsCint_525_0_16, 105, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_vectorlERootcLcLTGoodRuncOallocatorlERootcLcLTGoodRungRsPgR), -1, 0, 2, 1, 1, 0,
"h - 'vector<Root::TGoodRun,allocator<Root::TGoodRun> >::size_type' 0 - n u 'Root::TGoodRun' - 11 'Root::TGoodRun()' value", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("vector<Root::TGoodRun,allocator<Root::TGoodRun> >",4584,G__TGoodRunsListsCint_525_0_17, 105, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_vectorlERootcLcLTGoodRuncOallocatorlERootcLcLTGoodRungRsPgR), -1, 0, 1, 1, 1, 0, "u 'vector<Root::TGoodRun,allocator<Root::TGoodRun> >' - 11 - x", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("vector<Root::TGoodRun,allocator<Root::TGoodRun> >",4584,G__TGoodRunsListsCint_525_0_18, 105, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_vectorlERootcLcLTGoodRuncOallocatorlERootcLcLTGoodRungRsPgR), -1, 0, 2, 1, 1, 0,
"u 'vector<Root::TGoodRun,allocator<Root::TGoodRun> >::iterator' 'vector<Root::TGoodRun,allocator<Root::TGoodRun> >::const_iterator' 10 - first u 'vector<Root::TGoodRun,allocator<Root::TGoodRun> >::iterator' 'vector<Root::TGoodRun,allocator<Root::TGoodRun> >::const_iterator' 10 - last", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("operator=",937,G__TGoodRunsListsCint_525_0_19, 117, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_vectorlERootcLcLTGoodRuncOallocatorlERootcLcLTGoodRungRsPgR), -1, 1, 1, 1, 1, 0, "u 'vector<Root::TGoodRun,allocator<Root::TGoodRun> >' - 11 - x", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("reserve",764,G__TGoodRunsListsCint_525_0_20, 121, -1, -1, 0, 1, 1, 1, 0, "h - 'vector<Root::TGoodRun,allocator<Root::TGoodRun> >::size_type' 0 - n", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("front",553,G__TGoodRunsListsCint_525_0_21, 117, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_RootcLcLTGoodRun), -1, 1, 0, 1, 1, 0, "", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("back",401,G__TGoodRunsListsCint_525_0_22, 117, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_RootcLcLTGoodRun), -1, 1, 0, 1, 1, 0, "", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("push_back",944,G__TGoodRunsListsCint_525_0_23, 121, -1, -1, 0, 1, 1, 1, 0, "u 'Root::TGoodRun' - 11 - x", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("swap",443,G__TGoodRunsListsCint_525_0_24, 121, -1, -1, 0, 1, 1, 1, 0, "u 'vector<Root::TGoodRun,allocator<Root::TGoodRun> >' - 1 - x", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("insert",661,G__TGoodRunsListsCint_525_0_25, 117, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_vectorlERootcLcLTGoodRuncOallocatorlERootcLcLTGoodRungRsPgRcLcLiterator), -1, 0, 2, 1, 1, 0,
"u 'vector<Root::TGoodRun,allocator<Root::TGoodRun> >::iterator' - 0 - position u 'Root::TGoodRun' - 11 - x", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("insert",661,G__TGoodRunsListsCint_525_0_26, 121, -1, -1, 0, 3, 1, 1, 0,
"u 'vector<Root::TGoodRun,allocator<Root::TGoodRun> >::iterator' - 0 - position u 'vector<Root::TGoodRun,allocator<Root::TGoodRun> >::iterator' 'vector<Root::TGoodRun,allocator<Root::TGoodRun> >::const_iterator' 10 - first "
"u 'vector<Root::TGoodRun,allocator<Root::TGoodRun> >::iterator' 'vector<Root::TGoodRun,allocator<Root::TGoodRun> >::const_iterator' 10 - last", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("insert",661,G__TGoodRunsListsCint_525_0_27, 121, -1, -1, 0, 3, 1, 1, 0,
"u 'vector<Root::TGoodRun,allocator<Root::TGoodRun> >::iterator' - 0 - position h - 'vector<Root::TGoodRun,allocator<Root::TGoodRun> >::size_type' 0 - n "
"u 'Root::TGoodRun' - 11 - x", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("pop_back",831,G__TGoodRunsListsCint_525_0_28, 121, -1, -1, 0, 0, 1, 1, 0, "", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("erase",528,G__TGoodRunsListsCint_525_0_29, 121, -1, -1, 0, 1, 1, 1, 0, "u 'vector<Root::TGoodRun,allocator<Root::TGoodRun> >::iterator' - 0 - position", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("erase",528,G__TGoodRunsListsCint_525_0_30, 121, -1, -1, 0, 2, 1, 1, 0,
"u 'vector<Root::TGoodRun,allocator<Root::TGoodRun> >::iterator' - 0 - first u 'vector<Root::TGoodRun,allocator<Root::TGoodRun> >::iterator' - 0 - last", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("clear",519,G__TGoodRunsListsCint_525_0_31, 121, -1, -1, 0, 0, 1, 1, 0, "", (char*)NULL, (void*) NULL, 0);
// automatic destructor
G__memfunc_setup("~vector<Root::TGoodRun,allocator<Root::TGoodRun> >", 4710, G__TGoodRunsListsCint_525_0_32, (int) ('y'), -1, -1, 0, 0, 1, 1, 0, "", (char*) NULL, (void*) NULL, 0);
G__tag_memfunc_reset();
}
static void G__setup_memfuncvectorlERootcLcLTGoodRuncOallocatorlERootcLcLTGoodRungRsPgRcLcLiterator(void) {
/* vector<Root::TGoodRun,allocator<Root::TGoodRun> >::iterator */
G__tag_memfunc_setup(G__get_linked_tagnum(&G__TGoodRunsListsCintLN_vectorlERootcLcLTGoodRuncOallocatorlERootcLcLTGoodRungRsPgRcLcLiterator));
G__memfunc_setup("iterator",874,G__TGoodRunsListsCint_526_0_1, 105, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_vectorlERootcLcLTGoodRuncOallocatorlERootcLcLTGoodRungRsPgRcLcLiterator), -1, 0, 0, 1, 1, 0, "", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("iterator",874,G__TGoodRunsListsCint_526_0_2, 105, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_vectorlERootcLcLTGoodRuncOallocatorlERootcLcLTGoodRungRsPgRcLcLiterator), -1, 0, 1, 5, 1, 0, "U 'Root::TGoodRun' 'vector<Root::TGoodRun,allocator<Root::TGoodRun> >::iterator::pointer' 11 - __i", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("operator*",918,G__TGoodRunsListsCint_526_0_3, 117, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_RootcLcLTGoodRun), G__defined_typename("vector<Root::TGoodRun,allocator<Root::TGoodRun> >::iterator::reference"), 1, 0, 1, 1, 8, "", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("operator->",983,G__TGoodRunsListsCint_526_0_4, 85, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_RootcLcLTGoodRun), G__defined_typename("vector<Root::TGoodRun,allocator<Root::TGoodRun> >::iterator::pointer"), 0, 0, 1, 1, 8, "", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("operator++",962,G__TGoodRunsListsCint_526_0_5, 117, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_vectorlERootcLcLTGoodRuncOallocatorlERootcLcLTGoodRungRsPgRcLcLiterator), -1, 1, 0, 1, 1, 0, "", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("operator++",962,G__TGoodRunsListsCint_526_0_6, 117, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_vectorlERootcLcLTGoodRuncOallocatorlERootcLcLTGoodRungRsPgRcLcLiterator), -1, 0, 1, 1, 1, 0, "i - - 0 - -", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("operator--",966,G__TGoodRunsListsCint_526_0_7, 117, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_vectorlERootcLcLTGoodRuncOallocatorlERootcLcLTGoodRungRsPgRcLcLiterator), -1, 1, 0, 1, 1, 0, "", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("operator--",966,G__TGoodRunsListsCint_526_0_8, 117, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_vectorlERootcLcLTGoodRuncOallocatorlERootcLcLTGoodRungRsPgRcLcLiterator), -1, 0, 1, 1, 1, 0, "i - - 0 - -", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("operator[]",1060,G__TGoodRunsListsCint_526_0_9, 117, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_RootcLcLTGoodRun), G__defined_typename("vector<Root::TGoodRun,allocator<Root::TGoodRun> >::iterator::reference"), 1, 1, 1, 1, 8, "l - 'vector<Root::TGoodRun,allocator<Root::TGoodRun> >::iterator::difference_type' 11 - __n", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("operator+=",980,G__TGoodRunsListsCint_526_0_10, 117, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_vectorlERootcLcLTGoodRuncOallocatorlERootcLcLTGoodRungRsPgRcLcLiterator), -1, 1, 1, 1, 1, 0, "l - 'vector<Root::TGoodRun,allocator<Root::TGoodRun> >::iterator::difference_type' 11 - __n", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("operator+",919,G__TGoodRunsListsCint_526_0_11, 117, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_vectorlERootcLcLTGoodRuncOallocatorlERootcLcLTGoodRungRsPgRcLcLiterator), -1, 0, 1, 1, 1, 8, "l - 'vector<Root::TGoodRun,allocator<Root::TGoodRun> >::iterator::difference_type' 11 - __n", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("operator-=",982,G__TGoodRunsListsCint_526_0_12, 117, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_vectorlERootcLcLTGoodRuncOallocatorlERootcLcLTGoodRungRsPgRcLcLiterator), -1, 1, 1, 1, 1, 0, "l - 'vector<Root::TGoodRun,allocator<Root::TGoodRun> >::iterator::difference_type' 11 - __n", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("operator-",921,G__TGoodRunsListsCint_526_0_13, 117, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_vectorlERootcLcLTGoodRuncOallocatorlERootcLcLTGoodRungRsPgRcLcLiterator), -1, 0, 1, 1, 1, 8, "l - 'vector<Root::TGoodRun,allocator<Root::TGoodRun> >::iterator::difference_type' 11 - __n", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("base",411,G__TGoodRunsListsCint_526_0_14, 85, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_RootcLcLTGoodRun), G__defined_typename("vector<Root::TGoodRun,allocator<Root::TGoodRun> >::iterator::pointer"), 1, 0, 1, 1, 9, "", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("operator=",937,G__TGoodRunsListsCint_526_0_15, 117, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_vectorlERootcLcLTGoodRuncOallocatorlERootcLcLTGoodRungRsPgRcLcLiterator), -1, 0, 1, 1, 1, 0, "u 'vector<Root::TGoodRun,allocator<Root::TGoodRun> >::iterator' - 11 - x", (char*)NULL, (void*) NULL, 0);
// automatic copy constructor
G__memfunc_setup("iterator", 874, G__TGoodRunsListsCint_526_0_16, (int) ('i'), G__get_linked_tagnum(&G__TGoodRunsListsCintLN_vectorlERootcLcLTGoodRuncOallocatorlERootcLcLTGoodRungRsPgRcLcLiterator), -1, 0, 1, 1, 1, 0, "u 'vector<Root::TGoodRun,allocator<Root::TGoodRun> >::iterator' - 11 - -", (char*) NULL, (void*) NULL, 0);
// automatic destructor
G__memfunc_setup("~iterator", 1000, G__TGoodRunsListsCint_526_0_17, (int) ('y'), -1, -1, 0, 0, 1, 1, 0, "", (char*) NULL, (void*) NULL, 0);
G__tag_memfunc_reset();
}
static void G__setup_memfuncRootcLcLTGRLCollection(void) {
/* Root::TGRLCollection */
G__tag_memfunc_setup(G__get_linked_tagnum(&G__TGoodRunsListsCintLN_RootcLcLTGRLCollection));
G__memfunc_setup("TGRLCollection",1349,G__TGoodRunsListsCint_529_0_1, 105, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_RootcLcLTGRLCollection), -1, 0, 1, 1, 1, 0, "g - 'Bool_t' 0 'kFALSE' checkGRLInfo", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("TGRLCollection",1349,G__TGoodRunsListsCint_529_0_2, 105, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_RootcLcLTGRLCollection), -1, 0, 1, 1, 1, 0, "u 'Root::TGRLCollection' - 11 - other", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("operator=",937,G__TGoodRunsListsCint_529_0_3, 117, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_RootcLcLTGRLCollection), -1, 1, 1, 1, 1, 0, "u 'Root::TGRLCollection' - 11 - other", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("SetVersion",1042,G__TGoodRunsListsCint_529_0_4, 121, -1, -1, 0, 1, 1, 1, 0, "u 'TString' - 11 - version", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("SetMetaData",1069,G__TGoodRunsListsCint_529_0_5, 121, -1, -1, 0, 1, 1, 1, 0, "u 'map<TString,TString,less<TString>,allocator<pair<const TString,TString> > >' 'map<TString,TString>' 11 - metadata", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("SetCheckGRLInfo",1403,G__TGoodRunsListsCint_529_0_6, 121, -1, -1, 0, 1, 1, 1, 0, "g - 'Bool_t' 0 'kTRUE' check", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("HasRun",593,G__TGoodRunsListsCint_529_0_7, 103, -1, G__defined_typename("Bool_t"), 0, 1, 1, 1, 8, "i - 'Int_t' 11 - runnr", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("HasRunLumiBlock",1491,G__TGoodRunsListsCint_529_0_8, 103, -1, G__defined_typename("Bool_t"), 0, 2, 1, 1, 8,
"i - 'Int_t' 11 - runnr i - 'Int_t' 11 - lumiblocknr", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("IsEmpty",715,G__TGoodRunsListsCint_529_0_9, 103, -1, G__defined_typename("Bool_t"), 0, 0, 1, 1, 8, "", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("HasGoodRunsList",1513,G__TGoodRunsListsCint_529_0_10, 103, -1, G__defined_typename("Bool_t"), 0, 1, 1, 1, 8, "u 'TString' - 11 - name", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("GetMergedGoodRunsList",2113,G__TGoodRunsListsCint_529_0_11, 117, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_RootcLcLTGoodRunsList), -1, 0, 1, 1, 1, 9, "i 'Root::BoolOperation' - 11 'OR' operation", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("GetGoodRunsList",1517,G__TGoodRunsListsCint_529_0_12, 117, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_RootcLcLTGoodRunsList), -1, 0, 1, 1, 1, 9, "h - - 0 - idx", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("find",417,G__TGoodRunsListsCint_529_0_13, 117, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_vectorlERootcLcLTGoodRunsListcOallocatorlERootcLcLTGoodRunsListgRsPgRcLcLiterator), -1, 0, 1, 1, 1, 0, "u 'TString' - 11 - name", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("find",417,G__TGoodRunsListsCint_529_0_14, 117, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_vectorlERootcLcLTGoodRunsListcOallocatorlERootcLcLTGoodRunsListgRsPgRcLcLiterator), G__defined_typename("vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >::const_iterator"), 0, 1, 1, 1, 8, "u 'TString' - 11 - name", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("GetMergedGRLCollection",2149,G__TGoodRunsListsCint_529_0_15, 117, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_RootcLcLTGRLCollection), -1, 0, 1, 1, 1, 9, "i 'Root::BoolOperation' - 11 'OR' operation", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("GetOverlapWith",1429,G__TGoodRunsListsCint_529_0_16, 117, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_RootcLcLTGRLCollection), -1, 0, 1, 1, 1, 9, "u 'Root::TGoodRunsList' - 11 - other", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("Reset",515,G__TGoodRunsListsCint_529_0_17, 121, -1, -1, 0, 0, 1, 1, 0, "", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("Summary",750,G__TGoodRunsListsCint_529_0_18, 121, -1, -1, 0, 1, 1, 1, 8, "g - 'Bool_t' 0 'kFALSE' verbose", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("Class",502,G__TGoodRunsListsCint_529_0_19, 85, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_TClass), -1, 0, 0, 3, 1, 0, "", (char*)NULL, (void*) G__func2void( (TClass* (*)())(&Root::TGRLCollection::Class) ), 0);
G__memfunc_setup("Class_Name",982,G__TGoodRunsListsCint_529_0_20, 67, -1, -1, 0, 0, 3, 1, 1, "", (char*)NULL, (void*) G__func2void( (const char* (*)())(&Root::TGRLCollection::Class_Name) ), 0);
G__memfunc_setup("Class_Version",1339,G__TGoodRunsListsCint_529_0_21, 115, -1, G__defined_typename("Version_t"), 0, 0, 3, 1, 0, "", (char*)NULL, (void*) G__func2void( (Version_t (*)())(&Root::TGRLCollection::Class_Version) ), 0);
G__memfunc_setup("Dictionary",1046,G__TGoodRunsListsCint_529_0_22, 121, -1, -1, 0, 0, 3, 1, 0, "", (char*)NULL, (void*) G__func2void( (void (*)())(&Root::TGRLCollection::Dictionary) ), 0);
G__memfunc_setup("IsA",253,(G__InterfaceMethod) NULL,85, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_TClass), -1, 0, 0, 1, 1, 8, "", (char*)NULL, (void*) NULL, 1);
G__memfunc_setup("ShowMembers",1132,(G__InterfaceMethod) NULL,121, -1, -1, 0, 1, 1, 1, 0, "u 'TMemberInspector' - 1 - insp", (char*)NULL, (void*) NULL, 1);
G__memfunc_setup("Streamer",835,(G__InterfaceMethod) NULL,121, -1, -1, 0, 1, 1, 1, 0, "u 'TBuffer' - 1 - b", (char*)NULL, (void*) NULL, 1);
G__memfunc_setup("StreamerNVirtual",1656,G__TGoodRunsListsCint_529_0_26, 121, -1, -1, 0, 1, 1, 1, 0, "u 'TBuffer' - 1 - b", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("DeclFileName",1145,G__TGoodRunsListsCint_529_0_27, 67, -1, -1, 0, 0, 3, 1, 1, "", (char*)NULL, (void*) G__func2void( (const char* (*)())(&Root::TGRLCollection::DeclFileName) ), 0);
G__memfunc_setup("ImplFileLine",1178,G__TGoodRunsListsCint_529_0_28, 105, -1, -1, 0, 0, 3, 1, 0, "", (char*)NULL, (void*) G__func2void( (int (*)())(&Root::TGRLCollection::ImplFileLine) ), 0);
G__memfunc_setup("ImplFileName",1171,G__TGoodRunsListsCint_529_0_29, 67, -1, -1, 0, 0, 3, 1, 1, "", (char*)NULL, (void*) G__func2void( (const char* (*)())(&Root::TGRLCollection::ImplFileName) ), 0);
G__memfunc_setup("DeclFileLine",1152,G__TGoodRunsListsCint_529_0_30, 105, -1, -1, 0, 0, 3, 1, 0, "", (char*)NULL, (void*) G__func2void( (int (*)())(&Root::TGRLCollection::DeclFileLine) ), 0);
// automatic destructor
G__memfunc_setup("~TGRLCollection", 1475, G__TGoodRunsListsCint_529_0_31, (int) ('y'), -1, -1, 0, 0, 1, 1, 0, "", (char*) NULL, (void*) NULL, 1);
G__tag_memfunc_reset();
}
static void G__setup_memfuncvectorlERootcLcLTGoodRunsListcOallocatorlERootcLcLTGoodRunsListgRsPgR(void) {
/* vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> > */
G__tag_memfunc_setup(G__get_linked_tagnum(&G__TGoodRunsListsCintLN_vectorlERootcLcLTGoodRunsListcOallocatorlERootcLcLTGoodRunsListgRsPgR));
G__memfunc_setup("at",213,G__TGoodRunsListsCint_531_0_1, 117, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_RootcLcLTGoodRunsList), G__defined_typename("vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >::reference"), 1, 1, 1, 1, 0, "h - 'vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >::size_type' 0 - n", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("at",213,G__TGoodRunsListsCint_531_0_2, 117, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_RootcLcLTGoodRunsList), G__defined_typename("vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >::const_reference"), 1, 1, 1, 1, 8, "h - 'vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >::size_type' 0 - n", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("begin",517,G__TGoodRunsListsCint_531_0_3, 117, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_vectorlERootcLcLTGoodRunsListcOallocatorlERootcLcLTGoodRunsListgRsPgRcLcLiterator), -1, 0, 0, 1, 1, 0, "", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("end",311,G__TGoodRunsListsCint_531_0_4, 117, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_vectorlERootcLcLTGoodRunsListcOallocatorlERootcLcLTGoodRunsListgRsPgRcLcLiterator), -1, 0, 0, 1, 1, 0, "", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("rbegin",631,G__TGoodRunsListsCint_531_0_5, 117, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_reverse_iteratorlEvectorlERootcLcLTGoodRunsListcOallocatorlERootcLcLTGoodRunsListgRsPgRcLcLiteratorgR), G__defined_typename("vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >::reverse_iterator"), 0, 0, 1, 1, 0, "", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("rend",425,G__TGoodRunsListsCint_531_0_6, 117, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_reverse_iteratorlEvectorlERootcLcLTGoodRunsListcOallocatorlERootcLcLTGoodRunsListgRsPgRcLcLiteratorgR), G__defined_typename("vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >::reverse_iterator"), 0, 0, 1, 1, 0, "", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("size",443,G__TGoodRunsListsCint_531_0_7, 104, -1, G__defined_typename("vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >::size_type"), 0, 0, 1, 1, 8, "", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("max_size",864,G__TGoodRunsListsCint_531_0_8, 104, -1, G__defined_typename("vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >::size_type"), 0, 0, 1, 1, 8, "", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("resize",658,G__TGoodRunsListsCint_531_0_9, 121, -1, -1, 0, 1, 1, 1, 0, "h - 'vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >::size_type' 0 - sz", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("resize",658,G__TGoodRunsListsCint_531_0_10, 121, -1, -1, 0, 2, 1, 1, 0,
"h - 'vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >::size_type' 0 - sz u 'Root::TGoodRunsList' - 0 - c", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("capacity",846,G__TGoodRunsListsCint_531_0_11, 104, -1, G__defined_typename("vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >::size_type"), 0, 0, 1, 1, 8, "", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("empty",559,G__TGoodRunsListsCint_531_0_12, 103, -1, -1, 0, 0, 1, 1, 8, "", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("operator[]",1060,G__TGoodRunsListsCint_531_0_13, 117, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_RootcLcLTGoodRunsList), G__defined_typename("vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >::reference"), 1, 1, 1, 1, 0, "h - 'vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >::size_type' 0 - n", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("operator[]",1060,G__TGoodRunsListsCint_531_0_14, 117, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_RootcLcLTGoodRunsList), G__defined_typename("vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >::const_reference"), 1, 1, 1, 1, 8, "h - 'vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >::size_type' 0 - n", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >",5638,G__TGoodRunsListsCint_531_0_15, 105, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_vectorlERootcLcLTGoodRunsListcOallocatorlERootcLcLTGoodRunsListgRsPgR), -1, 0, 0, 1, 1, 0, "", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >",5638,G__TGoodRunsListsCint_531_0_16, 105, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_vectorlERootcLcLTGoodRunsListcOallocatorlERootcLcLTGoodRunsListgRsPgR), -1, 0, 2, 1, 1, 0,
"h - 'vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >::size_type' 0 - n u 'Root::TGoodRunsList' - 11 'Root::TGoodRunsList()' value", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >",5638,G__TGoodRunsListsCint_531_0_17, 105, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_vectorlERootcLcLTGoodRunsListcOallocatorlERootcLcLTGoodRunsListgRsPgR), -1, 0, 1, 1, 1, 0, "u 'vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >' - 11 - x", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >",5638,G__TGoodRunsListsCint_531_0_18, 105, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_vectorlERootcLcLTGoodRunsListcOallocatorlERootcLcLTGoodRunsListgRsPgR), -1, 0, 2, 1, 1, 0,
"u 'vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >::iterator' 'vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >::const_iterator' 10 - first u 'vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >::iterator' 'vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >::const_iterator' 10 - last", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("operator=",937,G__TGoodRunsListsCint_531_0_19, 117, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_vectorlERootcLcLTGoodRunsListcOallocatorlERootcLcLTGoodRunsListgRsPgR), -1, 1, 1, 1, 1, 0, "u 'vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >' - 11 - x", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("reserve",764,G__TGoodRunsListsCint_531_0_20, 121, -1, -1, 0, 1, 1, 1, 0, "h - 'vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >::size_type' 0 - n", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("front",553,G__TGoodRunsListsCint_531_0_21, 117, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_RootcLcLTGoodRunsList), -1, 1, 0, 1, 1, 0, "", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("back",401,G__TGoodRunsListsCint_531_0_22, 117, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_RootcLcLTGoodRunsList), -1, 1, 0, 1, 1, 0, "", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("push_back",944,G__TGoodRunsListsCint_531_0_23, 121, -1, -1, 0, 1, 1, 1, 0, "u 'Root::TGoodRunsList' - 11 - x", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("swap",443,G__TGoodRunsListsCint_531_0_24, 121, -1, -1, 0, 1, 1, 1, 0, "u 'vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >' - 1 - x", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("insert",661,G__TGoodRunsListsCint_531_0_25, 117, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_vectorlERootcLcLTGoodRunsListcOallocatorlERootcLcLTGoodRunsListgRsPgRcLcLiterator), -1, 0, 2, 1, 1, 0,
"u 'vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >::iterator' - 0 - position u 'Root::TGoodRunsList' - 11 - x", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("insert",661,G__TGoodRunsListsCint_531_0_26, 121, -1, -1, 0, 3, 1, 1, 0,
"u 'vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >::iterator' - 0 - position u 'vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >::iterator' 'vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >::const_iterator' 10 - first "
"u 'vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >::iterator' 'vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >::const_iterator' 10 - last", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("insert",661,G__TGoodRunsListsCint_531_0_27, 121, -1, -1, 0, 3, 1, 1, 0,
"u 'vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >::iterator' - 0 - position h - 'vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >::size_type' 0 - n "
"u 'Root::TGoodRunsList' - 11 - x", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("pop_back",831,G__TGoodRunsListsCint_531_0_28, 121, -1, -1, 0, 0, 1, 1, 0, "", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("erase",528,G__TGoodRunsListsCint_531_0_29, 121, -1, -1, 0, 1, 1, 1, 0, "u 'vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >::iterator' - 0 - position", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("erase",528,G__TGoodRunsListsCint_531_0_30, 121, -1, -1, 0, 2, 1, 1, 0,
"u 'vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >::iterator' - 0 - first u 'vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >::iterator' - 0 - last", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("clear",519,G__TGoodRunsListsCint_531_0_31, 121, -1, -1, 0, 0, 1, 1, 0, "", (char*)NULL, (void*) NULL, 0);
// automatic destructor
G__memfunc_setup("~vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >", 5764, G__TGoodRunsListsCint_531_0_32, (int) ('y'), -1, -1, 0, 0, 1, 1, 0, "", (char*) NULL, (void*) NULL, 0);
G__tag_memfunc_reset();
}
static void G__setup_memfuncvectorlERootcLcLTGoodRunsListcOallocatorlERootcLcLTGoodRunsListgRsPgRcLcLiterator(void) {
/* vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >::iterator */
G__tag_memfunc_setup(G__get_linked_tagnum(&G__TGoodRunsListsCintLN_vectorlERootcLcLTGoodRunsListcOallocatorlERootcLcLTGoodRunsListgRsPgRcLcLiterator));
G__memfunc_setup("iterator",874,G__TGoodRunsListsCint_532_0_1, 105, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_vectorlERootcLcLTGoodRunsListcOallocatorlERootcLcLTGoodRunsListgRsPgRcLcLiterator), -1, 0, 0, 1, 1, 0, "", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("iterator",874,G__TGoodRunsListsCint_532_0_2, 105, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_vectorlERootcLcLTGoodRunsListcOallocatorlERootcLcLTGoodRunsListgRsPgRcLcLiterator), -1, 0, 1, 5, 1, 0, "U 'Root::TGoodRunsList' 'vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >::iterator::pointer' 11 - __i", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("operator*",918,G__TGoodRunsListsCint_532_0_3, 117, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_RootcLcLTGoodRunsList), G__defined_typename("vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >::iterator::reference"), 1, 0, 1, 1, 8, "", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("operator->",983,G__TGoodRunsListsCint_532_0_4, 85, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_RootcLcLTGoodRunsList), G__defined_typename("vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >::iterator::pointer"), 0, 0, 1, 1, 8, "", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("operator++",962,G__TGoodRunsListsCint_532_0_5, 117, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_vectorlERootcLcLTGoodRunsListcOallocatorlERootcLcLTGoodRunsListgRsPgRcLcLiterator), -1, 1, 0, 1, 1, 0, "", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("operator++",962,G__TGoodRunsListsCint_532_0_6, 117, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_vectorlERootcLcLTGoodRunsListcOallocatorlERootcLcLTGoodRunsListgRsPgRcLcLiterator), -1, 0, 1, 1, 1, 0, "i - - 0 - -", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("operator--",966,G__TGoodRunsListsCint_532_0_7, 117, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_vectorlERootcLcLTGoodRunsListcOallocatorlERootcLcLTGoodRunsListgRsPgRcLcLiterator), -1, 1, 0, 1, 1, 0, "", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("operator--",966,G__TGoodRunsListsCint_532_0_8, 117, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_vectorlERootcLcLTGoodRunsListcOallocatorlERootcLcLTGoodRunsListgRsPgRcLcLiterator), -1, 0, 1, 1, 1, 0, "i - - 0 - -", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("operator[]",1060,G__TGoodRunsListsCint_532_0_9, 117, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_RootcLcLTGoodRunsList), G__defined_typename("vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >::iterator::reference"), 1, 1, 1, 1, 8, "l - 'vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >::iterator::difference_type' 11 - __n", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("operator+=",980,G__TGoodRunsListsCint_532_0_10, 117, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_vectorlERootcLcLTGoodRunsListcOallocatorlERootcLcLTGoodRunsListgRsPgRcLcLiterator), -1, 1, 1, 1, 1, 0, "l - 'vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >::iterator::difference_type' 11 - __n", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("operator+",919,G__TGoodRunsListsCint_532_0_11, 117, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_vectorlERootcLcLTGoodRunsListcOallocatorlERootcLcLTGoodRunsListgRsPgRcLcLiterator), -1, 0, 1, 1, 1, 8, "l - 'vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >::iterator::difference_type' 11 - __n", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("operator-=",982,G__TGoodRunsListsCint_532_0_12, 117, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_vectorlERootcLcLTGoodRunsListcOallocatorlERootcLcLTGoodRunsListgRsPgRcLcLiterator), -1, 1, 1, 1, 1, 0, "l - 'vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >::iterator::difference_type' 11 - __n", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("operator-",921,G__TGoodRunsListsCint_532_0_13, 117, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_vectorlERootcLcLTGoodRunsListcOallocatorlERootcLcLTGoodRunsListgRsPgRcLcLiterator), -1, 0, 1, 1, 1, 8, "l - 'vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >::iterator::difference_type' 11 - __n", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("base",411,G__TGoodRunsListsCint_532_0_14, 85, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_RootcLcLTGoodRunsList), G__defined_typename("vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >::iterator::pointer"), 1, 0, 1, 1, 9, "", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("operator=",937,G__TGoodRunsListsCint_532_0_15, 117, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_vectorlERootcLcLTGoodRunsListcOallocatorlERootcLcLTGoodRunsListgRsPgRcLcLiterator), -1, 0, 1, 1, 1, 0, "u 'vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >::iterator' - 11 - x", (char*)NULL, (void*) NULL, 0);
// automatic copy constructor
G__memfunc_setup("iterator", 874, G__TGoodRunsListsCint_532_0_16, (int) ('i'), G__get_linked_tagnum(&G__TGoodRunsListsCintLN_vectorlERootcLcLTGoodRunsListcOallocatorlERootcLcLTGoodRunsListgRsPgRcLcLiterator), -1, 0, 1, 1, 1, 0, "u 'vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >::iterator' - 11 - -", (char*) NULL, (void*) NULL, 0);
// automatic destructor
G__memfunc_setup("~iterator", 1000, G__TGoodRunsListsCint_532_0_17, (int) ('y'), -1, -1, 0, 0, 1, 1, 0, "", (char*) NULL, (void*) NULL, 0);
G__tag_memfunc_reset();
}
static void G__setup_memfuncRootcLcLTGoodRunsListWriter(void) {
/* Root::TGoodRunsListWriter */
G__tag_memfunc_setup(G__get_linked_tagnum(&G__TGoodRunsListsCintLN_RootcLcLTGoodRunsListWriter));
G__memfunc_setup("TGoodRunsListWriter",1950,G__TGoodRunsListsCint_535_0_1, 105, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_RootcLcLTGoodRunsListWriter), -1, 0, 0, 1, 1, 0, "", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("TGoodRunsListWriter",1950,G__TGoodRunsListsCint_535_0_2, 105, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_RootcLcLTGoodRunsListWriter), -1, 0, 2, 1, 1, 0,
"u 'Root::TGoodRunsList' - 11 - goodrunslist u 'TString' - 11 - dataCardName", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("WriteXMLFile",1148,G__TGoodRunsListsCint_535_0_3, 103, -1, G__defined_typename("Bool_t"), 0, 0, 1, 1, 0, "", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("WriteXMLFiles",1263,G__TGoodRunsListsCint_535_0_4, 103, -1, G__defined_typename("Bool_t"), 0, 0, 1, 1, 0, "", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("GetXMLString",1160,G__TGoodRunsListsCint_535_0_5, 117, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_TString), -1, 1, 0, 1, 1, 1, "", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("GetXMLStrings",1275,G__TGoodRunsListsCint_535_0_6, 117, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_vectorlETStringcOallocatorlETStringgRsPgR), G__defined_typename("vector<TString>"), 1, 0, 1, 1, 1, "", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("GetFilename",1089,G__TGoodRunsListsCint_535_0_7, 117, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_TString), -1, 1, 0, 1, 1, 9, "", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("GetMergedGoodRunsList",2113,G__TGoodRunsListsCint_535_0_8, 117, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_RootcLcLTGoodRunsList), -1, 0, 1, 1, 1, 9, "i 'Root::BoolOperation' - 11 'OR' operation", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("GetGRLCollection",1553,G__TGoodRunsListsCint_535_0_9, 117, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_RootcLcLTGRLCollection), -1, 1, 0, 1, 1, 9, "", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("SetMergeGoodRunsLists",2140,G__TGoodRunsListsCint_535_0_10, 121, -1, -1, 0, 1, 1, 1, 0, "g - - 0 'true' merge", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("SetCheckGRLInfo",1403,G__TGoodRunsListsCint_535_0_11, 121, -1, -1, 0, 1, 1, 1, 0, "g - - 0 'true' check", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("SetIndividuals",1448,G__TGoodRunsListsCint_535_0_12, 121, -1, -1, 0, 1, 1, 1, 0, "g - - 0 'true' indf", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("SetGRLCollection",1565,G__TGoodRunsListsCint_535_0_13, 121, -1, -1, 0, 1, 1, 1, 0, "u 'Root::TGRLCollection' - 11 - grlvec", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("SetGoodRunsList",1529,G__TGoodRunsListsCint_535_0_14, 121, -1, -1, 0, 1, 1, 1, 0, "u 'Root::TGoodRunsList' - 11 - goodrunslist", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("SetFilename",1101,G__TGoodRunsListsCint_535_0_15, 121, -1, -1, 0, 1, 1, 1, 0, "u 'TString' - 11 - dataCardName", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("SetPrefix",922,G__TGoodRunsListsCint_535_0_16, 121, -1, -1, 0, 1, 1, 1, 0, "u 'TString' - 11 - prefix", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("AddGoodRunsList",1494,G__TGoodRunsListsCint_535_0_17, 121, -1, -1, 0, 1, 1, 1, 0, "u 'Root::TGoodRunsList' - 11 - goodrunslist", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("reset",547,(G__InterfaceMethod) NULL, 121, -1, -1, 0, 0, 1, 4, 0, "", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("WriteLumiRangeCollection",2459,(G__InterfaceMethod) NULL, 103, -1, G__defined_typename("Bool_t"), 0, 1, 1, 4, 0, "U '_xmlTextWriter' 'xmlTextWriterPtr' 0 - writer", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("WriteNamedLumiRange",1908,(G__InterfaceMethod) NULL, 103, -1, G__defined_typename("Bool_t"), 0, 1, 1, 4, 0, "U '_xmlTextWriter' 'xmlTextWriterPtr' 0 - writer", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("WriteMetadata",1324,(G__InterfaceMethod) NULL, 103, -1, G__defined_typename("Bool_t"), 0, 1, 1, 4, 0, "U '_xmlTextWriter' 'xmlTextWriterPtr' 0 - writer", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("WriteLumiBlockCollection",2457,(G__InterfaceMethod) NULL, 103, -1, G__defined_typename("Bool_t"), 0, 2, 1, 4, 0,
"U '_xmlTextWriter' 'xmlTextWriterPtr' 0 - writer u 'Root::TGoodRun' - 11 - goodrun", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("WriteElement",1237,(G__InterfaceMethod) NULL, 103, -1, G__defined_typename("Bool_t"), 0, 7, 1, 4, 0,
"U '_xmlTextWriter' 'xmlTextWriterPtr' 0 - writer C - - 10 - name "
"C - - 10 '0' value C - - 10 '0' atr1 "
"C - - 10 '0' val1 C - - 10 '0' atr2 "
"C - - 10 '0' val2", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("ConvertInput",1265,(G__InterfaceMethod) NULL, 66, -1, G__defined_typename("xmlChar"), 0, 2, 1, 4, 0,
"C - - 10 - in C - - 10 - encoding", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("Class",502,G__TGoodRunsListsCint_535_0_25, 85, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_TClass), -1, 0, 0, 3, 1, 0, "", (char*)NULL, (void*) G__func2void( (TClass* (*)())(&Root::TGoodRunsListWriter::Class) ), 0);
G__memfunc_setup("Class_Name",982,G__TGoodRunsListsCint_535_0_26, 67, -1, -1, 0, 0, 3, 1, 1, "", (char*)NULL, (void*) G__func2void( (const char* (*)())(&Root::TGoodRunsListWriter::Class_Name) ), 0);
G__memfunc_setup("Class_Version",1339,G__TGoodRunsListsCint_535_0_27, 115, -1, G__defined_typename("Version_t"), 0, 0, 3, 1, 0, "", (char*)NULL, (void*) G__func2void( (Version_t (*)())(&Root::TGoodRunsListWriter::Class_Version) ), 0);
G__memfunc_setup("Dictionary",1046,G__TGoodRunsListsCint_535_0_28, 121, -1, -1, 0, 0, 3, 1, 0, "", (char*)NULL, (void*) G__func2void( (void (*)())(&Root::TGoodRunsListWriter::Dictionary) ), 0);
G__memfunc_setup("IsA",253,(G__InterfaceMethod) NULL,85, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_TClass), -1, 0, 0, 1, 1, 8, "", (char*)NULL, (void*) NULL, 1);
G__memfunc_setup("ShowMembers",1132,(G__InterfaceMethod) NULL,121, -1, -1, 0, 1, 1, 1, 0, "u 'TMemberInspector' - 1 - insp", (char*)NULL, (void*) NULL, 1);
G__memfunc_setup("Streamer",835,(G__InterfaceMethod) NULL,121, -1, -1, 0, 1, 1, 1, 0, "u 'TBuffer' - 1 - b", (char*)NULL, (void*) NULL, 1);
G__memfunc_setup("StreamerNVirtual",1656,G__TGoodRunsListsCint_535_0_32, 121, -1, -1, 0, 1, 1, 1, 0, "u 'TBuffer' - 1 - b", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("DeclFileName",1145,G__TGoodRunsListsCint_535_0_33, 67, -1, -1, 0, 0, 3, 1, 1, "", (char*)NULL, (void*) G__func2void( (const char* (*)())(&Root::TGoodRunsListWriter::DeclFileName) ), 0);
G__memfunc_setup("ImplFileLine",1178,G__TGoodRunsListsCint_535_0_34, 105, -1, -1, 0, 0, 3, 1, 0, "", (char*)NULL, (void*) G__func2void( (int (*)())(&Root::TGoodRunsListWriter::ImplFileLine) ), 0);
G__memfunc_setup("ImplFileName",1171,G__TGoodRunsListsCint_535_0_35, 67, -1, -1, 0, 0, 3, 1, 1, "", (char*)NULL, (void*) G__func2void( (const char* (*)())(&Root::TGoodRunsListWriter::ImplFileName) ), 0);
G__memfunc_setup("DeclFileLine",1152,G__TGoodRunsListsCint_535_0_36, 105, -1, -1, 0, 0, 3, 1, 0, "", (char*)NULL, (void*) G__func2void( (int (*)())(&Root::TGoodRunsListWriter::DeclFileLine) ), 0);
// automatic destructor
G__memfunc_setup("~TGoodRunsListWriter", 2076, G__TGoodRunsListsCint_535_0_37, (int) ('y'), -1, -1, 0, 0, 1, 1, 0, "", (char*) NULL, (void*) NULL, 1);
G__tag_memfunc_reset();
}
static void G__setup_memfuncRootcLcLTGoodRunsListReader(void) {
/* Root::TGoodRunsListReader */
G__tag_memfunc_setup(G__get_linked_tagnum(&G__TGoodRunsListsCintLN_RootcLcLTGoodRunsListReader));
G__memfunc_setup("TGoodRunsListReader",1908,G__TGoodRunsListsCint_541_0_1, 105, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_RootcLcLTGoodRunsListReader), -1, 0, 1, 1, 1, 0, "g - 'Bool_t' 0 'kFALSE' checkGRLInfo", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("TGoodRunsListReader",1908,G__TGoodRunsListsCint_541_0_2, 105, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_RootcLcLTGoodRunsListReader), -1, 0, 2, 1, 1, 0,
"u 'TString' - 11 - dataCardName g - 'Bool_t' 0 'kFALSE' checkGRLInfo", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("Interpret",957,G__TGoodRunsListsCint_541_0_3, 103, -1, G__defined_typename("Bool_t"), 0, 0, 1, 1, 0, "", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("GetXMLString",1160,G__TGoodRunsListsCint_541_0_4, 117, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_TString), -1, 1, 0, 1, 1, 9, "", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("GetXMLFilename",1330,G__TGoodRunsListsCint_541_0_5, 117, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_TString), -1, 1, 0, 1, 1, 9, "", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("AddXMLFile",890,G__TGoodRunsListsCint_541_0_6, 121, -1, -1, 0, 1, 1, 1, 0, "u 'TString' - 11 - xmlfile", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("AddXMLString",1137,G__TGoodRunsListsCint_541_0_7, 121, -1, -1, 0, 1, 1, 1, 0, "u 'TString' - 11 - xmlstring", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("SetXMLString",1172,G__TGoodRunsListsCint_541_0_8, 121, -1, -1, 0, 1, 1, 1, 0, "u 'TString' - 11 - xmlstring", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("SetXMLFile",925,G__TGoodRunsListsCint_541_0_9, 121, -1, -1, 0, 1, 1, 1, 0, "u 'TString' - 11 - xmlfile", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("SetCheckGRLInfo",1403,G__TGoodRunsListsCint_541_0_10, 121, -1, -1, 0, 1, 1, 1, 0, "g - 'Bool_t' 0 'kTRUE' check", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("GetMergedGoodRunsList",2113,G__TGoodRunsListsCint_541_0_11, 117, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_RootcLcLTGoodRunsList), -1, 0, 1, 1, 1, 9, "i 'Root::BoolOperation' - 11 'OR' operation", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("GetGoodRunsList",1517,G__TGoodRunsListsCint_541_0_12, 117, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_RootcLcLTGoodRunsList), -1, 0, 1, 1, 1, 9, "h - - 0 - idx", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("GetGRLCollection",1553,G__TGoodRunsListsCint_541_0_13, 117, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_RootcLcLTGRLCollection), -1, 0, 0, 1, 1, 9, "", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("GetMergedGRLCollection",2149,G__TGoodRunsListsCint_541_0_14, 117, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_RootcLcLTGRLCollection), -1, 0, 1, 1, 1, 9, "i 'Root::BoolOperation' - 11 'OR' operation", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("Reset",515,G__TGoodRunsListsCint_541_0_15, 121, -1, -1, 0, 0, 1, 1, 0, "", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("ReadNamedLumiRange",1765,(G__InterfaceMethod) NULL, 121, -1, -1, 0, 1, 1, 4, 0, "U 'TXMLNode' - 0 - -", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("ReadLumiBlockCollection",2314,(G__InterfaceMethod) NULL, 121, -1, -1, 0, 1, 1, 4, 0, "U 'TXMLNode' - 0 - -", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("ReadAttribs",1109,(G__InterfaceMethod) NULL, 121, -1, -1, 0, 1, 1, 4, 0, "U 'TXMLNode' - 0 - -", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("GetLumiBlockCollection",2222,(G__InterfaceMethod) NULL, 117, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_RootcLcLTGoodRun), -1, 0, 1, 1, 4, 0, "U 'TXMLNode' - 0 - dataNode", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("Class",502,G__TGoodRunsListsCint_541_0_20, 85, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_TClass), -1, 0, 0, 3, 1, 0, "", (char*)NULL, (void*) G__func2void( (TClass* (*)())(&Root::TGoodRunsListReader::Class) ), 0);
G__memfunc_setup("Class_Name",982,G__TGoodRunsListsCint_541_0_21, 67, -1, -1, 0, 0, 3, 1, 1, "", (char*)NULL, (void*) G__func2void( (const char* (*)())(&Root::TGoodRunsListReader::Class_Name) ), 0);
G__memfunc_setup("Class_Version",1339,G__TGoodRunsListsCint_541_0_22, 115, -1, G__defined_typename("Version_t"), 0, 0, 3, 1, 0, "", (char*)NULL, (void*) G__func2void( (Version_t (*)())(&Root::TGoodRunsListReader::Class_Version) ), 0);
G__memfunc_setup("Dictionary",1046,G__TGoodRunsListsCint_541_0_23, 121, -1, -1, 0, 0, 3, 1, 0, "", (char*)NULL, (void*) G__func2void( (void (*)())(&Root::TGoodRunsListReader::Dictionary) ), 0);
G__memfunc_setup("IsA",253,(G__InterfaceMethod) NULL,85, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_TClass), -1, 0, 0, 1, 1, 8, "", (char*)NULL, (void*) NULL, 1);
G__memfunc_setup("ShowMembers",1132,(G__InterfaceMethod) NULL,121, -1, -1, 0, 1, 1, 1, 0, "u 'TMemberInspector' - 1 - insp", (char*)NULL, (void*) NULL, 1);
G__memfunc_setup("Streamer",835,(G__InterfaceMethod) NULL,121, -1, -1, 0, 1, 1, 1, 0, "u 'TBuffer' - 1 - b", (char*)NULL, (void*) NULL, 1);
G__memfunc_setup("StreamerNVirtual",1656,G__TGoodRunsListsCint_541_0_27, 121, -1, -1, 0, 1, 1, 1, 0, "u 'TBuffer' - 1 - b", (char*)NULL, (void*) NULL, 0);
G__memfunc_setup("DeclFileName",1145,G__TGoodRunsListsCint_541_0_28, 67, -1, -1, 0, 0, 3, 1, 1, "", (char*)NULL, (void*) G__func2void( (const char* (*)())(&Root::TGoodRunsListReader::DeclFileName) ), 0);
G__memfunc_setup("ImplFileLine",1178,G__TGoodRunsListsCint_541_0_29, 105, -1, -1, 0, 0, 3, 1, 0, "", (char*)NULL, (void*) G__func2void( (int (*)())(&Root::TGoodRunsListReader::ImplFileLine) ), 0);
G__memfunc_setup("ImplFileName",1171,G__TGoodRunsListsCint_541_0_30, 67, -1, -1, 0, 0, 3, 1, 1, "", (char*)NULL, (void*) G__func2void( (const char* (*)())(&Root::TGoodRunsListReader::ImplFileName) ), 0);
G__memfunc_setup("DeclFileLine",1152,G__TGoodRunsListsCint_541_0_31, 105, -1, -1, 0, 0, 3, 1, 0, "", (char*)NULL, (void*) G__func2void( (int (*)())(&Root::TGoodRunsListReader::DeclFileLine) ), 0);
// automatic destructor
G__memfunc_setup("~TGoodRunsListReader", 2034, G__TGoodRunsListsCint_541_0_32, (int) ('y'), -1, -1, 0, 0, 1, 1, 0, "", (char*) NULL, (void*) NULL, 1);
G__tag_memfunc_reset();
}
static void G__setup_memfuncDQ(void) {
/* DQ */
G__tag_memfunc_setup(G__get_linked_tagnum(&G__TGoodRunsListsCintLN_DQ));
G__memfunc_setup("SetXMLFile",925,G__TGoodRunsListsCint_542_0_1, 121, -1, -1, 0, 1, 1, 1, 0, "u 'TString' - 11 - filename", (char*)NULL, (void*) G__func2void( (void (*)(const TString&))(&DQ::SetXMLFile) ), 0);
G__memfunc_setup("GetGRL",517,G__TGoodRunsListsCint_542_0_2, 117, G__get_linked_tagnum(&G__TGoodRunsListsCintLN_RootcLcLTGoodRunsList), -1, 1, 0, 1, 1, 0, "", (char*)NULL, (void*) G__func2void( (Root::TGoodRunsList& (*)())(&DQ::GetGRL) ), 0);
G__memfunc_setup("PassRunLB",858,G__TGoodRunsListsCint_542_0_3, 103, -1, -1, 0, 2, 1, 1, 0,
"i - - 0 - runnr i - - 0 - lbnr", (char*)NULL, (void*) G__func2void( (bool (*)(int, int))(&DQ::PassRunLB) ), 0);
G__tag_memfunc_reset();
}
/*********************************************************
* Member function information setup
*********************************************************/
extern "C" void G__cpp_setup_memfuncTGoodRunsListsCint() {
}
/*********************************************************
* Global variable information setup for each class
*********************************************************/
static void G__cpp_setup_global0() {
/* Setting up global variables */
G__resetplocal();
}
static void G__cpp_setup_global1() {
G__resetglobalenv();
}
extern "C" void G__cpp_setup_globalTGoodRunsListsCint() {
G__cpp_setup_global0();
G__cpp_setup_global1();
}
/*********************************************************
* Global function information setup for each class
*********************************************************/
static void G__cpp_setup_func0() {
G__lastifuncposition();
}
static void G__cpp_setup_func1() {
}
static void G__cpp_setup_func2() {
}
static void G__cpp_setup_func3() {
}
static void G__cpp_setup_func4() {
}
static void G__cpp_setup_func5() {
}
static void G__cpp_setup_func6() {
}
static void G__cpp_setup_func7() {
}
static void G__cpp_setup_func8() {
}
static void G__cpp_setup_func9() {
}
static void G__cpp_setup_func10() {
}
static void G__cpp_setup_func11() {
}
static void G__cpp_setup_func12() {
}
static void G__cpp_setup_func13() {
}
static void G__cpp_setup_func14() {
}
static void G__cpp_setup_func15() {
}
static void G__cpp_setup_func16() {
}
static void G__cpp_setup_func17() {
}
static void G__cpp_setup_func18() {
}
static void G__cpp_setup_func19() {
}
static void G__cpp_setup_func20() {
}
static void G__cpp_setup_func21() {
}
static void G__cpp_setup_func22() {
}
static void G__cpp_setup_func23() {
}
static void G__cpp_setup_func24() {
}
static void G__cpp_setup_func25() {
G__resetifuncposition();
}
extern "C" void G__cpp_setup_funcTGoodRunsListsCint() {
G__cpp_setup_func0();
G__cpp_setup_func1();
G__cpp_setup_func2();
G__cpp_setup_func3();
G__cpp_setup_func4();
G__cpp_setup_func5();
G__cpp_setup_func6();
G__cpp_setup_func7();
G__cpp_setup_func8();
G__cpp_setup_func9();
G__cpp_setup_func10();
G__cpp_setup_func11();
G__cpp_setup_func12();
G__cpp_setup_func13();
G__cpp_setup_func14();
G__cpp_setup_func15();
G__cpp_setup_func16();
G__cpp_setup_func17();
G__cpp_setup_func18();
G__cpp_setup_func19();
G__cpp_setup_func20();
G__cpp_setup_func21();
G__cpp_setup_func22();
G__cpp_setup_func23();
G__cpp_setup_func24();
G__cpp_setup_func25();
}
/*********************************************************
* Class,struct,union,enum tag information setup
*********************************************************/
/* Setup class/struct taginfo */
G__linked_taginfo G__TGoodRunsListsCintLN_TClass = { "TClass" , 99 , -1 };
G__linked_taginfo G__TGoodRunsListsCintLN_TBuffer = { "TBuffer" , 99 , -1 };
G__linked_taginfo G__TGoodRunsListsCintLN_TMemberInspector = { "TMemberInspector" , 99 , -1 };
G__linked_taginfo G__TGoodRunsListsCintLN_TObject = { "TObject" , 99 , -1 };
G__linked_taginfo G__TGoodRunsListsCintLN_TNamed = { "TNamed" , 99 , -1 };
G__linked_taginfo G__TGoodRunsListsCintLN_TString = { "TString" , 99 , -1 };
G__linked_taginfo G__TGoodRunsListsCintLN_vectorlEROOTcLcLTSchemaHelpercOallocatorlEROOTcLcLTSchemaHelpergRsPgR = { "vector<ROOT::TSchemaHelper,allocator<ROOT::TSchemaHelper> >" , 99 , -1 };
G__linked_taginfo G__TGoodRunsListsCintLN_reverse_iteratorlEvectorlEROOTcLcLTSchemaHelpercOallocatorlEROOTcLcLTSchemaHelpergRsPgRcLcLiteratorgR = { "reverse_iterator<vector<ROOT::TSchemaHelper,allocator<ROOT::TSchemaHelper> >::iterator>" , 99 , -1 };
G__linked_taginfo G__TGoodRunsListsCintLN_vectorlETVirtualArraymUcOallocatorlETVirtualArraymUgRsPgR = { "vector<TVirtualArray*,allocator<TVirtualArray*> >" , 99 , -1 };
G__linked_taginfo G__TGoodRunsListsCintLN_reverse_iteratorlEvectorlETVirtualArraymUcOallocatorlETVirtualArraymUgRsPgRcLcLiteratorgR = { "reverse_iterator<vector<TVirtualArray*,allocator<TVirtualArray*> >::iterator>" , 99 , -1 };
G__linked_taginfo G__TGoodRunsListsCintLN_Root = { "Root" , 110 , -1 };
G__linked_taginfo G__TGoodRunsListsCintLN_iteratorlEbidirectional_iterator_tagcOTObjectmUcOlongcOconstsPTObjectmUmUcOconstsPTObjectmUaNgR = { "iterator<bidirectional_iterator_tag,TObject*,long,const TObject**,const TObject*&>" , 115 , -1 };
G__linked_taginfo G__TGoodRunsListsCintLN_TFormula = { "TFormula" , 99 , -1 };
G__linked_taginfo G__TGoodRunsListsCintLN_RootcLcLRegularFormula = { "Root::RegularFormula" , 99 , -1 };
G__linked_taginfo G__TGoodRunsListsCintLN_listlETStringcOallocatorlETStringgRsPgR = { "list<TString,allocator<TString> >" , 99 , -1 };
G__linked_taginfo G__TGoodRunsListsCintLN_vectorlEstringcOallocatorlEstringgRsPgR = { "vector<string,allocator<string> >" , 99 , -1 };
G__linked_taginfo G__TGoodRunsListsCintLN_reverse_iteratorlEvectorlEstringcOallocatorlEstringgRsPgRcLcLiteratorgR = { "reverse_iterator<vector<string,allocator<string> >::iterator>" , 99 , -1 };
G__linked_taginfo G__TGoodRunsListsCintLN_lesslEintgR = { "less<int>" , 115 , -1 };
G__linked_taginfo G__TGoodRunsListsCintLN_RootcLcLTMsgLevel = { "Root::TMsgLevel" , 101 , -1 };
G__linked_taginfo G__TGoodRunsListsCintLN_RootcLcLTMsgLogger = { "Root::TMsgLogger" , 99 , -1 };
G__linked_taginfo G__TGoodRunsListsCintLN_maplERootcLcLTMsgLevelcOstringcOlesslERootcLcLTMsgLevelgRcOallocatorlEpairlEconstsPRootcLcLTMsgLevelcOstringgRsPgRsPgR = { "map<Root::TMsgLevel,string,less<Root::TMsgLevel>,allocator<pair<const Root::TMsgLevel,string> > >" , 99 , -1 };
G__linked_taginfo G__TGoodRunsListsCintLN_RootcLcLTLumiBlockRange = { "Root::TLumiBlockRange" , 99 , -1 };
G__linked_taginfo G__TGoodRunsListsCintLN_vectorlERootcLcLTLumiBlockRangecOallocatorlERootcLcLTLumiBlockRangegRsPgR = { "vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >" , 99 , -1 };
G__linked_taginfo G__TGoodRunsListsCintLN_vectorlERootcLcLTLumiBlockRangecOallocatorlERootcLcLTLumiBlockRangegRsPgRcLcLiterator = { "vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >::iterator" , 99 , -1 };
G__linked_taginfo G__TGoodRunsListsCintLN_reverse_iteratorlEvectorlERootcLcLTLumiBlockRangecOallocatorlERootcLcLTLumiBlockRangegRsPgRcLcLiteratorgR = { "reverse_iterator<vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >::iterator>" , 99 , -1 };
G__linked_taginfo G__TGoodRunsListsCintLN_RootcLcLTGoodRun = { "Root::TGoodRun" , 99 , -1 };
G__linked_taginfo G__TGoodRunsListsCintLN_RootcLcLTGoodRunsList = { "Root::TGoodRunsList" , 99 , -1 };
G__linked_taginfo G__TGoodRunsListsCintLN_allocatorlEpairlEconstsPintcORootcLcLTGoodRungRsPgR = { "allocator<pair<const int,Root::TGoodRun> >" , 99 , -1 };
G__linked_taginfo G__TGoodRunsListsCintLN_maplEintcORootcLcLTGoodRuncOlesslEintgRcOallocatorlEpairlEconstsPintcORootcLcLTGoodRungRsPgRsPgR = { "map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > >" , 99 , -1 };
G__linked_taginfo G__TGoodRunsListsCintLN_pairlEintcORootcLcLTGoodRungR = { "pair<int,Root::TGoodRun>" , 115 , -1 };
G__linked_taginfo G__TGoodRunsListsCintLN_maplEintcORootcLcLTGoodRuncOlesslEintgRcOallocatorlEpairlEconstsPintcORootcLcLTGoodRungRsPgRsPgRcLcLiterator = { "map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > >::iterator" , 99 , -1 };
G__linked_taginfo G__TGoodRunsListsCintLN_maplEintcORootcLcLTGoodRuncOlesslEintgRcOallocatorlEpairlEconstsPintcORootcLcLTGoodRungRsPgRsPgRcLcLreverse_iterator = { "map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > >::reverse_iterator" , 99 , -1 };
G__linked_taginfo G__TGoodRunsListsCintLN_pairlEmaplEintcORootcLcLTGoodRuncOlesslEintgRcOallocatorlEpairlEconstsPintcORootcLcLTGoodRungRsPgRsPgRcLcLiteratorcOboolgR = { "pair<map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > >::iterator,bool>" , 115 , -1 };
G__linked_taginfo G__TGoodRunsListsCintLN_lesslETStringgR = { "less<TString>" , 115 , -1 };
G__linked_taginfo G__TGoodRunsListsCintLN_allocatorlEpairlEconstsPTStringcOTStringgRsPgR = { "allocator<pair<const TString,TString> >" , 99 , -1 };
G__linked_taginfo G__TGoodRunsListsCintLN_maplETStringcOTStringcOlesslETStringgRcOallocatorlEpairlEconstsPTStringcOTStringgRsPgRsPgR = { "map<TString,TString,less<TString>,allocator<pair<const TString,TString> > >" , 99 , -1 };
G__linked_taginfo G__TGoodRunsListsCintLN_pairlETStringcOTStringgR = { "pair<TString,TString>" , 115 , -1 };
G__linked_taginfo G__TGoodRunsListsCintLN_maplETStringcOTStringcOlesslETStringgRcOallocatorlEpairlEconstsPTStringcOTStringgRsPgRsPgRcLcLiterator = { "map<TString,TString,less<TString>,allocator<pair<const TString,TString> > >::iterator" , 99 , -1 };
G__linked_taginfo G__TGoodRunsListsCintLN_maplETStringcOTStringcOlesslETStringgRcOallocatorlEpairlEconstsPTStringcOTStringgRsPgRsPgRcLcLreverse_iterator = { "map<TString,TString,less<TString>,allocator<pair<const TString,TString> > >::reverse_iterator" , 99 , -1 };
G__linked_taginfo G__TGoodRunsListsCintLN_pairlEmaplETStringcOTStringcOlesslETStringgRcOallocatorlEpairlEconstsPTStringcOTStringgRsPgRsPgRcLcLiteratorcOboolgR = { "pair<map<TString,TString,less<TString>,allocator<pair<const TString,TString> > >::iterator,bool>" , 115 , -1 };
G__linked_taginfo G__TGoodRunsListsCintLN_vectorlEintcOallocatorlEintgRsPgR = { "vector<int,allocator<int> >" , 99 , -1 };
G__linked_taginfo G__TGoodRunsListsCintLN_reverse_iteratorlEvectorlEintcOallocatorlEintgRsPgRcLcLiteratorgR = { "reverse_iterator<vector<int,allocator<int> >::iterator>" , 99 , -1 };
G__linked_taginfo G__TGoodRunsListsCintLN_vectorlERootcLcLTGoodRuncOallocatorlERootcLcLTGoodRungRsPgR = { "vector<Root::TGoodRun,allocator<Root::TGoodRun> >" , 99 , -1 };
G__linked_taginfo G__TGoodRunsListsCintLN_vectorlERootcLcLTGoodRuncOallocatorlERootcLcLTGoodRungRsPgRcLcLiterator = { "vector<Root::TGoodRun,allocator<Root::TGoodRun> >::iterator" , 99 , -1 };
G__linked_taginfo G__TGoodRunsListsCintLN_reverse_iteratorlEvectorlERootcLcLTGoodRuncOallocatorlERootcLcLTGoodRungRsPgRcLcLiteratorgR = { "reverse_iterator<vector<Root::TGoodRun,allocator<Root::TGoodRun> >::iterator>" , 99 , -1 };
G__linked_taginfo G__TGoodRunsListsCintLN_RootcLcLBoolOperation = { "Root::BoolOperation" , 101 , -1 };
G__linked_taginfo G__TGoodRunsListsCintLN_RootcLcLTGRLCollection = { "Root::TGRLCollection" , 99 , -1 };
G__linked_taginfo G__TGoodRunsListsCintLN_vectorlERootcLcLTGoodRunsListcOallocatorlERootcLcLTGoodRunsListgRsPgR = { "vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >" , 99 , -1 };
G__linked_taginfo G__TGoodRunsListsCintLN_vectorlERootcLcLTGoodRunsListcOallocatorlERootcLcLTGoodRunsListgRsPgRcLcLiterator = { "vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >::iterator" , 99 , -1 };
G__linked_taginfo G__TGoodRunsListsCintLN_reverse_iteratorlEvectorlERootcLcLTGoodRunsListcOallocatorlERootcLcLTGoodRunsListgRsPgRcLcLiteratorgR = { "reverse_iterator<vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >::iterator>" , 99 , -1 };
G__linked_taginfo G__TGoodRunsListsCintLN__xmlTextWriter = { "_xmlTextWriter" , 115 , -1 };
G__linked_taginfo G__TGoodRunsListsCintLN_RootcLcLTGoodRunsListWriter = { "Root::TGoodRunsListWriter" , 99 , -1 };
G__linked_taginfo G__TGoodRunsListsCintLN_vectorlETStringcOallocatorlETStringgRsPgR = { "vector<TString,allocator<TString> >" , 99 , -1 };
G__linked_taginfo G__TGoodRunsListsCintLN_reverse_iteratorlEvectorlETStringcOallocatorlETStringgRsPgRcLcLiteratorgR = { "reverse_iterator<vector<TString,allocator<TString> >::iterator>" , 99 , -1 };
G__linked_taginfo G__TGoodRunsListsCintLN_TXMLNode = { "TXMLNode" , 99 , -1 };
G__linked_taginfo G__TGoodRunsListsCintLN_RootcLcLTGoodRunsListReader = { "Root::TGoodRunsListReader" , 99 , -1 };
G__linked_taginfo G__TGoodRunsListsCintLN_DQ = { "DQ" , 110 , -1 };
/* Reset class/struct taginfo */
extern "C" void G__cpp_reset_tagtableTGoodRunsListsCint() {
G__TGoodRunsListsCintLN_TClass.tagnum = -1 ;
G__TGoodRunsListsCintLN_TBuffer.tagnum = -1 ;
G__TGoodRunsListsCintLN_TMemberInspector.tagnum = -1 ;
G__TGoodRunsListsCintLN_TObject.tagnum = -1 ;
G__TGoodRunsListsCintLN_TNamed.tagnum = -1 ;
G__TGoodRunsListsCintLN_TString.tagnum = -1 ;
G__TGoodRunsListsCintLN_vectorlEROOTcLcLTSchemaHelpercOallocatorlEROOTcLcLTSchemaHelpergRsPgR.tagnum = -1 ;
G__TGoodRunsListsCintLN_reverse_iteratorlEvectorlEROOTcLcLTSchemaHelpercOallocatorlEROOTcLcLTSchemaHelpergRsPgRcLcLiteratorgR.tagnum = -1 ;
G__TGoodRunsListsCintLN_vectorlETVirtualArraymUcOallocatorlETVirtualArraymUgRsPgR.tagnum = -1 ;
G__TGoodRunsListsCintLN_reverse_iteratorlEvectorlETVirtualArraymUcOallocatorlETVirtualArraymUgRsPgRcLcLiteratorgR.tagnum = -1 ;
G__TGoodRunsListsCintLN_Root.tagnum = -1 ;
G__TGoodRunsListsCintLN_iteratorlEbidirectional_iterator_tagcOTObjectmUcOlongcOconstsPTObjectmUmUcOconstsPTObjectmUaNgR.tagnum = -1 ;
G__TGoodRunsListsCintLN_TFormula.tagnum = -1 ;
G__TGoodRunsListsCintLN_RootcLcLRegularFormula.tagnum = -1 ;
G__TGoodRunsListsCintLN_listlETStringcOallocatorlETStringgRsPgR.tagnum = -1 ;
G__TGoodRunsListsCintLN_vectorlEstringcOallocatorlEstringgRsPgR.tagnum = -1 ;
G__TGoodRunsListsCintLN_reverse_iteratorlEvectorlEstringcOallocatorlEstringgRsPgRcLcLiteratorgR.tagnum = -1 ;
G__TGoodRunsListsCintLN_lesslEintgR.tagnum = -1 ;
G__TGoodRunsListsCintLN_RootcLcLTMsgLevel.tagnum = -1 ;
G__TGoodRunsListsCintLN_RootcLcLTMsgLogger.tagnum = -1 ;
G__TGoodRunsListsCintLN_maplERootcLcLTMsgLevelcOstringcOlesslERootcLcLTMsgLevelgRcOallocatorlEpairlEconstsPRootcLcLTMsgLevelcOstringgRsPgRsPgR.tagnum = -1 ;
G__TGoodRunsListsCintLN_RootcLcLTLumiBlockRange.tagnum = -1 ;
G__TGoodRunsListsCintLN_vectorlERootcLcLTLumiBlockRangecOallocatorlERootcLcLTLumiBlockRangegRsPgR.tagnum = -1 ;
G__TGoodRunsListsCintLN_vectorlERootcLcLTLumiBlockRangecOallocatorlERootcLcLTLumiBlockRangegRsPgRcLcLiterator.tagnum = -1 ;
G__TGoodRunsListsCintLN_reverse_iteratorlEvectorlERootcLcLTLumiBlockRangecOallocatorlERootcLcLTLumiBlockRangegRsPgRcLcLiteratorgR.tagnum = -1 ;
G__TGoodRunsListsCintLN_RootcLcLTGoodRun.tagnum = -1 ;
G__TGoodRunsListsCintLN_RootcLcLTGoodRunsList.tagnum = -1 ;
G__TGoodRunsListsCintLN_allocatorlEpairlEconstsPintcORootcLcLTGoodRungRsPgR.tagnum = -1 ;
G__TGoodRunsListsCintLN_maplEintcORootcLcLTGoodRuncOlesslEintgRcOallocatorlEpairlEconstsPintcORootcLcLTGoodRungRsPgRsPgR.tagnum = -1 ;
G__TGoodRunsListsCintLN_pairlEintcORootcLcLTGoodRungR.tagnum = -1 ;
G__TGoodRunsListsCintLN_maplEintcORootcLcLTGoodRuncOlesslEintgRcOallocatorlEpairlEconstsPintcORootcLcLTGoodRungRsPgRsPgRcLcLiterator.tagnum = -1 ;
G__TGoodRunsListsCintLN_maplEintcORootcLcLTGoodRuncOlesslEintgRcOallocatorlEpairlEconstsPintcORootcLcLTGoodRungRsPgRsPgRcLcLreverse_iterator.tagnum = -1 ;
G__TGoodRunsListsCintLN_pairlEmaplEintcORootcLcLTGoodRuncOlesslEintgRcOallocatorlEpairlEconstsPintcORootcLcLTGoodRungRsPgRsPgRcLcLiteratorcOboolgR.tagnum = -1 ;
G__TGoodRunsListsCintLN_lesslETStringgR.tagnum = -1 ;
G__TGoodRunsListsCintLN_allocatorlEpairlEconstsPTStringcOTStringgRsPgR.tagnum = -1 ;
G__TGoodRunsListsCintLN_maplETStringcOTStringcOlesslETStringgRcOallocatorlEpairlEconstsPTStringcOTStringgRsPgRsPgR.tagnum = -1 ;
G__TGoodRunsListsCintLN_pairlETStringcOTStringgR.tagnum = -1 ;
G__TGoodRunsListsCintLN_maplETStringcOTStringcOlesslETStringgRcOallocatorlEpairlEconstsPTStringcOTStringgRsPgRsPgRcLcLiterator.tagnum = -1 ;
G__TGoodRunsListsCintLN_maplETStringcOTStringcOlesslETStringgRcOallocatorlEpairlEconstsPTStringcOTStringgRsPgRsPgRcLcLreverse_iterator.tagnum = -1 ;
G__TGoodRunsListsCintLN_pairlEmaplETStringcOTStringcOlesslETStringgRcOallocatorlEpairlEconstsPTStringcOTStringgRsPgRsPgRcLcLiteratorcOboolgR.tagnum = -1 ;
G__TGoodRunsListsCintLN_vectorlEintcOallocatorlEintgRsPgR.tagnum = -1 ;
G__TGoodRunsListsCintLN_reverse_iteratorlEvectorlEintcOallocatorlEintgRsPgRcLcLiteratorgR.tagnum = -1 ;
G__TGoodRunsListsCintLN_vectorlERootcLcLTGoodRuncOallocatorlERootcLcLTGoodRungRsPgR.tagnum = -1 ;
G__TGoodRunsListsCintLN_vectorlERootcLcLTGoodRuncOallocatorlERootcLcLTGoodRungRsPgRcLcLiterator.tagnum = -1 ;
G__TGoodRunsListsCintLN_reverse_iteratorlEvectorlERootcLcLTGoodRuncOallocatorlERootcLcLTGoodRungRsPgRcLcLiteratorgR.tagnum = -1 ;
G__TGoodRunsListsCintLN_RootcLcLBoolOperation.tagnum = -1 ;
G__TGoodRunsListsCintLN_RootcLcLTGRLCollection.tagnum = -1 ;
G__TGoodRunsListsCintLN_vectorlERootcLcLTGoodRunsListcOallocatorlERootcLcLTGoodRunsListgRsPgR.tagnum = -1 ;
G__TGoodRunsListsCintLN_vectorlERootcLcLTGoodRunsListcOallocatorlERootcLcLTGoodRunsListgRsPgRcLcLiterator.tagnum = -1 ;
G__TGoodRunsListsCintLN_reverse_iteratorlEvectorlERootcLcLTGoodRunsListcOallocatorlERootcLcLTGoodRunsListgRsPgRcLcLiteratorgR.tagnum = -1 ;
G__TGoodRunsListsCintLN__xmlTextWriter.tagnum = -1 ;
G__TGoodRunsListsCintLN_RootcLcLTGoodRunsListWriter.tagnum = -1 ;
G__TGoodRunsListsCintLN_vectorlETStringcOallocatorlETStringgRsPgR.tagnum = -1 ;
G__TGoodRunsListsCintLN_reverse_iteratorlEvectorlETStringcOallocatorlETStringgRsPgRcLcLiteratorgR.tagnum = -1 ;
G__TGoodRunsListsCintLN_TXMLNode.tagnum = -1 ;
G__TGoodRunsListsCintLN_RootcLcLTGoodRunsListReader.tagnum = -1 ;
G__TGoodRunsListsCintLN_DQ.tagnum = -1 ;
}
extern "C" void G__cpp_setup_tagtableTGoodRunsListsCint() {
/* Setting up class,struct,union tag entry */
G__get_linked_tagnum_fwd(&G__TGoodRunsListsCintLN_TClass);
G__get_linked_tagnum_fwd(&G__TGoodRunsListsCintLN_TBuffer);
G__get_linked_tagnum_fwd(&G__TGoodRunsListsCintLN_TMemberInspector);
G__get_linked_tagnum_fwd(&G__TGoodRunsListsCintLN_TObject);
G__get_linked_tagnum_fwd(&G__TGoodRunsListsCintLN_TNamed);
G__get_linked_tagnum_fwd(&G__TGoodRunsListsCintLN_TString);
G__get_linked_tagnum_fwd(&G__TGoodRunsListsCintLN_vectorlEROOTcLcLTSchemaHelpercOallocatorlEROOTcLcLTSchemaHelpergRsPgR);
G__get_linked_tagnum_fwd(&G__TGoodRunsListsCintLN_reverse_iteratorlEvectorlEROOTcLcLTSchemaHelpercOallocatorlEROOTcLcLTSchemaHelpergRsPgRcLcLiteratorgR);
G__get_linked_tagnum_fwd(&G__TGoodRunsListsCintLN_vectorlETVirtualArraymUcOallocatorlETVirtualArraymUgRsPgR);
G__get_linked_tagnum_fwd(&G__TGoodRunsListsCintLN_reverse_iteratorlEvectorlETVirtualArraymUcOallocatorlETVirtualArraymUgRsPgRcLcLiteratorgR);
G__tagtable_setup(G__get_linked_tagnum_fwd(&G__TGoodRunsListsCintLN_Root),0,-1,0,(char*)NULL,G__setup_memvarRoot,G__setup_memfuncRoot);
G__get_linked_tagnum_fwd(&G__TGoodRunsListsCintLN_iteratorlEbidirectional_iterator_tagcOTObjectmUcOlongcOconstsPTObjectmUmUcOconstsPTObjectmUaNgR);
G__get_linked_tagnum_fwd(&G__TGoodRunsListsCintLN_TFormula);
G__tagtable_setup(G__get_linked_tagnum_fwd(&G__TGoodRunsListsCintLN_RootcLcLRegularFormula),sizeof(Root::RegularFormula),-1,327424,(char*)NULL,G__setup_memvarRootcLcLRegularFormula,G__setup_memfuncRootcLcLRegularFormula);
G__get_linked_tagnum_fwd(&G__TGoodRunsListsCintLN_listlETStringcOallocatorlETStringgRsPgR);
G__get_linked_tagnum_fwd(&G__TGoodRunsListsCintLN_vectorlEstringcOallocatorlEstringgRsPgR);
G__get_linked_tagnum_fwd(&G__TGoodRunsListsCintLN_reverse_iteratorlEvectorlEstringcOallocatorlEstringgRsPgRcLcLiteratorgR);
G__get_linked_tagnum_fwd(&G__TGoodRunsListsCintLN_lesslEintgR);
G__get_linked_tagnum_fwd(&G__TGoodRunsListsCintLN_RootcLcLTMsgLevel);
G__get_linked_tagnum_fwd(&G__TGoodRunsListsCintLN_RootcLcLTMsgLogger);
G__get_linked_tagnum_fwd(&G__TGoodRunsListsCintLN_maplERootcLcLTMsgLevelcOstringcOlesslERootcLcLTMsgLevelgRcOallocatorlEpairlEconstsPRootcLcLTMsgLevelcOstringgRsPgRsPgR);
G__tagtable_setup(G__get_linked_tagnum_fwd(&G__TGoodRunsListsCintLN_RootcLcLTLumiBlockRange),sizeof(Root::TLumiBlockRange),-1,327424,(char*)NULL,G__setup_memvarRootcLcLTLumiBlockRange,G__setup_memfuncRootcLcLTLumiBlockRange);
G__tagtable_setup(G__get_linked_tagnum_fwd(&G__TGoodRunsListsCintLN_vectorlERootcLcLTLumiBlockRangecOallocatorlERootcLcLTLumiBlockRangegRsPgR),sizeof(vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >),-1,298752,(char*)NULL,G__setup_memvarvectorlERootcLcLTLumiBlockRangecOallocatorlERootcLcLTLumiBlockRangegRsPgR,G__setup_memfuncvectorlERootcLcLTLumiBlockRangecOallocatorlERootcLcLTLumiBlockRangegRsPgR);
G__tagtable_setup(G__get_linked_tagnum_fwd(&G__TGoodRunsListsCintLN_vectorlERootcLcLTLumiBlockRangecOallocatorlERootcLcLTLumiBlockRangegRsPgRcLcLiterator),sizeof(vector<Root::TLumiBlockRange,allocator<Root::TLumiBlockRange> >::iterator),-1,35072,(char*)NULL,G__setup_memvarvectorlERootcLcLTLumiBlockRangecOallocatorlERootcLcLTLumiBlockRangegRsPgRcLcLiterator,G__setup_memfuncvectorlERootcLcLTLumiBlockRangecOallocatorlERootcLcLTLumiBlockRangegRsPgRcLcLiterator);
G__get_linked_tagnum_fwd(&G__TGoodRunsListsCintLN_reverse_iteratorlEvectorlERootcLcLTLumiBlockRangecOallocatorlERootcLcLTLumiBlockRangegRsPgRcLcLiteratorgR);
G__tagtable_setup(G__get_linked_tagnum_fwd(&G__TGoodRunsListsCintLN_RootcLcLTGoodRun),sizeof(Root::TGoodRun),-1,327424,(char*)NULL,G__setup_memvarRootcLcLTGoodRun,G__setup_memfuncRootcLcLTGoodRun);
G__tagtable_setup(G__get_linked_tagnum_fwd(&G__TGoodRunsListsCintLN_RootcLcLTGoodRunsList),sizeof(Root::TGoodRunsList),-1,327424,(char*)NULL,G__setup_memvarRootcLcLTGoodRunsList,G__setup_memfuncRootcLcLTGoodRunsList);
G__get_linked_tagnum_fwd(&G__TGoodRunsListsCintLN_allocatorlEpairlEconstsPintcORootcLcLTGoodRungRsPgR);
G__tagtable_setup(G__get_linked_tagnum_fwd(&G__TGoodRunsListsCintLN_maplEintcORootcLcLTGoodRuncOlesslEintgRcOallocatorlEpairlEconstsPintcORootcLcLTGoodRungRsPgRsPgR),sizeof(map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > >),-1,298752,(char*)NULL,G__setup_memvarmaplEintcORootcLcLTGoodRuncOlesslEintgRcOallocatorlEpairlEconstsPintcORootcLcLTGoodRungRsPgRsPgR,G__setup_memfuncmaplEintcORootcLcLTGoodRuncOlesslEintgRcOallocatorlEpairlEconstsPintcORootcLcLTGoodRungRsPgRsPgR);
G__tagtable_setup(G__get_linked_tagnum_fwd(&G__TGoodRunsListsCintLN_pairlEintcORootcLcLTGoodRungR),sizeof(pair<int,Root::TGoodRun>),-1,297216,(char*)NULL,G__setup_memvarpairlEintcORootcLcLTGoodRungR,G__setup_memfuncpairlEintcORootcLcLTGoodRungR);
G__tagtable_setup(G__get_linked_tagnum_fwd(&G__TGoodRunsListsCintLN_maplEintcORootcLcLTGoodRuncOlesslEintgRcOallocatorlEpairlEconstsPintcORootcLcLTGoodRungRsPgRsPgRcLcLiterator),sizeof(map<int,Root::TGoodRun,less<int>,allocator<pair<const int,Root::TGoodRun> > >::iterator),-1,2816,(char*)NULL,G__setup_memvarmaplEintcORootcLcLTGoodRuncOlesslEintgRcOallocatorlEpairlEconstsPintcORootcLcLTGoodRungRsPgRsPgRcLcLiterator,G__setup_memfuncmaplEintcORootcLcLTGoodRuncOlesslEintgRcOallocatorlEpairlEconstsPintcORootcLcLTGoodRungRsPgRsPgRcLcLiterator);
G__get_linked_tagnum_fwd(&G__TGoodRunsListsCintLN_maplEintcORootcLcLTGoodRuncOlesslEintgRcOallocatorlEpairlEconstsPintcORootcLcLTGoodRungRsPgRsPgRcLcLreverse_iterator);
G__get_linked_tagnum_fwd(&G__TGoodRunsListsCintLN_pairlEmaplEintcORootcLcLTGoodRuncOlesslEintgRcOallocatorlEpairlEconstsPintcORootcLcLTGoodRungRsPgRsPgRcLcLiteratorcOboolgR);
G__get_linked_tagnum_fwd(&G__TGoodRunsListsCintLN_lesslETStringgR);
G__get_linked_tagnum_fwd(&G__TGoodRunsListsCintLN_allocatorlEpairlEconstsPTStringcOTStringgRsPgR);
G__tagtable_setup(G__get_linked_tagnum_fwd(&G__TGoodRunsListsCintLN_maplETStringcOTStringcOlesslETStringgRcOallocatorlEpairlEconstsPTStringcOTStringgRsPgRsPgR),sizeof(map<TString,TString,less<TString>,allocator<pair<const TString,TString> > >),-1,298752,(char*)NULL,G__setup_memvarmaplETStringcOTStringcOlesslETStringgRcOallocatorlEpairlEconstsPTStringcOTStringgRsPgRsPgR,G__setup_memfuncmaplETStringcOTStringcOlesslETStringgRcOallocatorlEpairlEconstsPTStringcOTStringgRsPgRsPgR);
G__tagtable_setup(G__get_linked_tagnum_fwd(&G__TGoodRunsListsCintLN_pairlETStringcOTStringgR),sizeof(pair<TString,TString>),-1,297216,(char*)NULL,G__setup_memvarpairlETStringcOTStringgR,G__setup_memfuncpairlETStringcOTStringgR);
G__get_linked_tagnum_fwd(&G__TGoodRunsListsCintLN_maplETStringcOTStringcOlesslETStringgRcOallocatorlEpairlEconstsPTStringcOTStringgRsPgRsPgRcLcLiterator);
G__get_linked_tagnum_fwd(&G__TGoodRunsListsCintLN_maplETStringcOTStringcOlesslETStringgRcOallocatorlEpairlEconstsPTStringcOTStringgRsPgRsPgRcLcLreverse_iterator);
G__get_linked_tagnum_fwd(&G__TGoodRunsListsCintLN_pairlEmaplETStringcOTStringcOlesslETStringgRcOallocatorlEpairlEconstsPTStringcOTStringgRsPgRsPgRcLcLiteratorcOboolgR);
G__get_linked_tagnum_fwd(&G__TGoodRunsListsCintLN_vectorlEintcOallocatorlEintgRsPgR);
G__get_linked_tagnum_fwd(&G__TGoodRunsListsCintLN_reverse_iteratorlEvectorlEintcOallocatorlEintgRsPgRcLcLiteratorgR);
G__tagtable_setup(G__get_linked_tagnum_fwd(&G__TGoodRunsListsCintLN_vectorlERootcLcLTGoodRuncOallocatorlERootcLcLTGoodRungRsPgR),sizeof(vector<Root::TGoodRun,allocator<Root::TGoodRun> >),-1,298752,(char*)NULL,G__setup_memvarvectorlERootcLcLTGoodRuncOallocatorlERootcLcLTGoodRungRsPgR,G__setup_memfuncvectorlERootcLcLTGoodRuncOallocatorlERootcLcLTGoodRungRsPgR);
G__tagtable_setup(G__get_linked_tagnum_fwd(&G__TGoodRunsListsCintLN_vectorlERootcLcLTGoodRuncOallocatorlERootcLcLTGoodRungRsPgRcLcLiterator),sizeof(vector<Root::TGoodRun,allocator<Root::TGoodRun> >::iterator),-1,35072,(char*)NULL,G__setup_memvarvectorlERootcLcLTGoodRuncOallocatorlERootcLcLTGoodRungRsPgRcLcLiterator,G__setup_memfuncvectorlERootcLcLTGoodRuncOallocatorlERootcLcLTGoodRungRsPgRcLcLiterator);
G__get_linked_tagnum_fwd(&G__TGoodRunsListsCintLN_reverse_iteratorlEvectorlERootcLcLTGoodRuncOallocatorlERootcLcLTGoodRungRsPgRcLcLiteratorgR);
G__get_linked_tagnum_fwd(&G__TGoodRunsListsCintLN_RootcLcLBoolOperation);
G__tagtable_setup(G__get_linked_tagnum_fwd(&G__TGoodRunsListsCintLN_RootcLcLTGRLCollection),sizeof(Root::TGRLCollection),-1,327424,(char*)NULL,G__setup_memvarRootcLcLTGRLCollection,G__setup_memfuncRootcLcLTGRLCollection);
G__tagtable_setup(G__get_linked_tagnum_fwd(&G__TGoodRunsListsCintLN_vectorlERootcLcLTGoodRunsListcOallocatorlERootcLcLTGoodRunsListgRsPgR),sizeof(vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >),-1,298752,(char*)NULL,G__setup_memvarvectorlERootcLcLTGoodRunsListcOallocatorlERootcLcLTGoodRunsListgRsPgR,G__setup_memfuncvectorlERootcLcLTGoodRunsListcOallocatorlERootcLcLTGoodRunsListgRsPgR);
G__tagtable_setup(G__get_linked_tagnum_fwd(&G__TGoodRunsListsCintLN_vectorlERootcLcLTGoodRunsListcOallocatorlERootcLcLTGoodRunsListgRsPgRcLcLiterator),sizeof(vector<Root::TGoodRunsList,allocator<Root::TGoodRunsList> >::iterator),-1,35072,(char*)NULL,G__setup_memvarvectorlERootcLcLTGoodRunsListcOallocatorlERootcLcLTGoodRunsListgRsPgRcLcLiterator,G__setup_memfuncvectorlERootcLcLTGoodRunsListcOallocatorlERootcLcLTGoodRunsListgRsPgRcLcLiterator);
G__get_linked_tagnum_fwd(&G__TGoodRunsListsCintLN_reverse_iteratorlEvectorlERootcLcLTGoodRunsListcOallocatorlERootcLcLTGoodRunsListgRsPgRcLcLiteratorgR);
G__get_linked_tagnum_fwd(&G__TGoodRunsListsCintLN__xmlTextWriter);
G__tagtable_setup(G__get_linked_tagnum_fwd(&G__TGoodRunsListsCintLN_RootcLcLTGoodRunsListWriter),sizeof(Root::TGoodRunsListWriter),-1,324864,(char*)NULL,G__setup_memvarRootcLcLTGoodRunsListWriter,G__setup_memfuncRootcLcLTGoodRunsListWriter);
G__get_linked_tagnum_fwd(&G__TGoodRunsListsCintLN_vectorlETStringcOallocatorlETStringgRsPgR);
G__get_linked_tagnum_fwd(&G__TGoodRunsListsCintLN_reverse_iteratorlEvectorlETStringcOallocatorlETStringgRsPgRcLcLiteratorgR);
G__get_linked_tagnum_fwd(&G__TGoodRunsListsCintLN_TXMLNode);
G__tagtable_setup(G__get_linked_tagnum_fwd(&G__TGoodRunsListsCintLN_RootcLcLTGoodRunsListReader),sizeof(Root::TGoodRunsListReader),-1,324864,(char*)NULL,G__setup_memvarRootcLcLTGoodRunsListReader,G__setup_memfuncRootcLcLTGoodRunsListReader);
G__tagtable_setup(G__get_linked_tagnum_fwd(&G__TGoodRunsListsCintLN_DQ),0,-1,0,(char*)NULL,G__setup_memvarDQ,G__setup_memfuncDQ);
}
extern "C" void G__cpp_setupTGoodRunsListsCint(void) {
G__check_setup_version(30051515,"G__cpp_setupTGoodRunsListsCint()");
G__set_cpp_environmentTGoodRunsListsCint();
G__cpp_setup_tagtableTGoodRunsListsCint();
G__cpp_setup_inheritanceTGoodRunsListsCint();
G__cpp_setup_typetableTGoodRunsListsCint();
G__cpp_setup_memvarTGoodRunsListsCint();
G__cpp_setup_memfuncTGoodRunsListsCint();
G__cpp_setup_globalTGoodRunsListsCint();
G__cpp_setup_funcTGoodRunsListsCint();
if(0==G__getsizep2memfunc()) G__get_sizep2memfuncTGoodRunsListsCint();
return;
}
class G__cpp_setup_initTGoodRunsListsCint {
public:
G__cpp_setup_initTGoodRunsListsCint() { G__add_setup_func("TGoodRunsListsCint",(G__incsetup)(&G__cpp_setupTGoodRunsListsCint)); G__call_setup_funcs(); }
~G__cpp_setup_initTGoodRunsListsCint() { G__remove_setup_func("TGoodRunsListsCint"); }
};
G__cpp_setup_initTGoodRunsListsCint G__cpp_setup_initializerTGoodRunsListsCint;
| [
"affablelochan@gmail.com"
] | affablelochan@gmail.com |
ec6b9eda92c03ee8ed2850ca12a6aa6d77c9e95c | c057e033602e465adfa3d84d80331a3a21cef609 | /C/testcases/CWE415_Double_Free/s01/CWE415_Double_Free__malloc_free_struct_82_bad.cpp | a2de230a4e7d8382767e20d4a997d18b02a5e48d | [] | no_license | Anzsley/My_Juliet_Test_Suite_v1.3_for_C_Cpp | 12c2796ae7e580d89e4e7b8274dddf920361c41c | f278f1464588ffb763b7d06e2650fda01702148f | refs/heads/main | 2023-04-11T08:29:22.597042 | 2021-04-09T11:53:16 | 2021-04-09T11:53:16 | 356,251,613 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 899 | cpp | /* TEMPLATE GENERATED TESTCASE FILE
Filename: CWE415_Double_Free__malloc_free_struct_82_bad.cpp
Label Definition File: CWE415_Double_Free__malloc_free.label.xml
Template File: sources-sinks-82_bad.tmpl.cpp
*/
/*
* @description
* CWE: 415 Double Free
* BadSource: Allocate data using malloc() and Deallocate data using free()
* GoodSource: Allocate data using malloc()
* Sinks:
* GoodSink: do nothing
* BadSink : Deallocate data using free()
* Flow Variant: 82 Data flow: data passed in a parameter to an virtual method called via a pointer
*
* */
#ifndef OMITBAD
#include "std_testcase.h"
#include "CWE415_Double_Free__malloc_free_struct_82.h"
namespace CWE415_Double_Free__malloc_free_struct_82
{
void CWE415_Double_Free__malloc_free_struct_82_bad::action(twoIntsStruct * data)
{
/* POTENTIAL FLAW: Possibly freeing memory twice */
free(data);
}
}
#endif /* OMITBAD */
| [
"65642214+Anzsley@users.noreply.github.com"
] | 65642214+Anzsley@users.noreply.github.com |
f7946c64d715c5a9c1ed753d8fcf038f08402cf4 | 9b5be5645cf4cc06bf38ec696fefe2370d4faa25 | /6.Dbus/3.DbusMessages/Server/widget.cpp | 9e885c2da857573e0a2fab49e7471664754268ad | [] | no_license | DukeHouse/QConcurrent-IPC | 786dd38e805614654a02a339d22aa273caaabc89 | d23a85c7dad370736799ea9a3592473bcde12042 | refs/heads/master | 2023-01-13T21:23:01.936563 | 2020-11-14T02:58:19 | 2020-11-14T02:58:19 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,338 | cpp | #include "widget.h"
#include "ui_widget.h"
#include "calculatoradaptor.h"
#include <QDebug>
Widget::Widget(QWidget *parent) :
QWidget(parent),
ui(new Ui::Widget)
{
ui->setupUi(this);
//Create actual calculator
slaveCalculator = new SlaveCalculator(this);
//Adaptor is used in the class exposing the service.
//You have to pass the object you want to expose to DBus in the parameter
//because methods will be called on it
new CalculatorInterfaceAdaptor(slaveCalculator);
QDBusConnection connection = QDBusConnection::sessionBus();
//Here you pass in the object that you want expose to Dbus. Take note of this info, it is used in client.
connection.registerObject("/CalcServicePath", slaveCalculator);
//Here you pass in the service name. Take note of this as it is also needed for clients to reach our exposed object.
connection.registerService("com.blikoon.CalculatorService");
QDBusConnection::sessionBus().connect(QString(), QString(),
"com.blikoon.CalculatorInterface",
"message", this, SLOT(messageSlot(QString)));
}
Widget::~Widget()
{
delete ui;
}
void Widget::messageSlot(QString message)
{
qDebug() << "Server got signal from client, parameter : " << message;
}
| [
"yanminwei1993@163.com"
] | yanminwei1993@163.com |
b02850559946d8d185f63d345fdca2a93175f34f | ef9ad5d739b5bfb2a9761065bb08ba8e7dafa657 | /GameEditor/Include/Animation2DBindDlg.h | 8aa3fd29299a103704db5f396ea3f1f67a75bce6 | [] | no_license | kojea0919/MetalSlug_ | ac9877e1f6aeff110b7d38b6f53f0569389640d5 | 65a122c119c2efd50622cde3dc709e140b4b4606 | refs/heads/master | 2023-01-25T02:01:47.591252 | 2020-11-22T11:04:30 | 2020-11-22T11:04:30 | 310,506,598 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,942 | h | #pragma once
// CAnimation2DBindDlg 대화 상자
class CAnimation2DBindDlg : public CDialogEx
{
DECLARE_DYNAMIC(CAnimation2DBindDlg)
public:
CAnimation2DBindDlg(CWnd* pParent = nullptr); // 표준 생성자입니다.
virtual ~CAnimation2DBindDlg();
// 대화 상자 데이터입니다.
#ifdef AFX_DESIGN_TIME
enum { IDD = IDD_DIALOG_ANIMCOMBINEEDIT };
#endif
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 지원입니다.
DECLARE_MESSAGE_MAP()
public:
//Get함수
//----------------------------
RECT GetParentCutInfo(int iIdx) const
{
return m_vecParentCutRect[iIdx];
}
Vector2 GetParentPivotInfo(int iIdx) const
{
return m_vecParentPivot[iIdx];
}
RECT GetChildCutInfo(int iIdx) const
{
return m_vecChildCutRect[iIdx];
}
Vector2 GetChildPivotInfo(int iIdx) const
{
return m_vecChildPivot[iIdx];
}
//----------------------------
private:
void ReadParentAniFile(const char* pFullPath);
void ReadChildAniFile(const char* pFullPath);
private:
void InitParentAniInfoList();
void InitChildAniInfoList();
private:
CImage m_ParentImage;
CImage m_ChildImage;
//Parent Cut좌표
//-----------------------------
vector<RECT> m_vecParentCutRect;
//-----------------------------
//Child Cut좌표
//-----------------------------
vector<RECT> m_vecChildCutRect;
//-----------------------------
//Parent Pivot
//-----------------------------
vector<Vector2> m_vecParentPivot;
//-----------------------------
//Child Pivot
//-----------------------------
vector<Vector2> m_vecChildPivot;
//-----------------------------
//Child Connect Pos
//-----------------------------
vector<Vector2> m_vecConnectPos;
//-----------------------------
//재생 속도, 시간
//-----------------------------
float m_fPlayRate;
float m_fPlayTime;
//-----------------------------
//현재 선택중인 Image index
int m_iCurSelectParentImageIdx;
int m_iCurSelectChildImageIdx;
int m_iCurSelectConnectIdx;
char m_strParentFullPath[MAX_PATH];
//자식 애니메이션 이름
char m_strChildAnimName[MAX_PATH];
public:
//애니메이션 Player View
class CAnimationBinderPlayerView* m_pAnimPlayerView;
virtual BOOL OnInitDialog();
CString m_strParentAniFileName;
CString m_strChildAniFileName;
afx_msg void OnBnClickedButtonParentaniload();
afx_msg void OnBnClickedButtonChildaniload();
CListCtrl m_ParentAniList;
CListCtrl m_ChildAniList;
afx_msg void OnLvnItemchangedListChildani(NMHDR* pNMHDR, LRESULT* pResult);
CString m_strRelativeX;
CString m_strRelativeY;
afx_msg void OnLvnItemchangedListParentani(NMHDR* pNMHDR, LRESULT* pResult);
virtual BOOL PreTranslateMessage(MSG* pMsg);
afx_msg void OnBnClickedButtonZoomin();
afx_msg void OnBnClickedButtonZoomout();
afx_msg void OnBnClickedButtonInsert();
afx_msg void OnClose();
afx_msg void OnBnClickedButtonAllinsert();
afx_msg void OnBnClickedButtonSave();
};
| [
"gottkf0919@naver.com"
] | gottkf0919@naver.com |
a42d2db55a22f33d0d0894b5f87004c9bca79d31 | 4c7f04313e055ff08de887d76007a4aa96377396 | /gazebo7_7.14.0_exercise/gazebo/gui/LogPlayWidget.cc | 1906f66ee1a9d9faf5eff0d84ed5e51b716c8afc | [
"Apache-2.0"
] | permissive | WalteR-MittY-pro/Gazebo-MPI | 8ef51f80b49bcf56510337fdb67f1d2f4b605275 | 6e3f702463e6ac2d59194aac1c8a9a37ef4d0153 | refs/heads/master | 2023-03-31T07:41:44.718326 | 2020-03-02T07:22:13 | 2020-03-02T07:22:13 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 26,660 | cc | /*
* Copyright (C) 2015 Open Source Robotics Foundation
*
* 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 "gazebo/common/Console.hh"
#include "gazebo/common/Time.hh"
#include "gazebo/transport/Node.hh"
#include "gazebo/gui/Actions.hh"
#include "gazebo/gui/LogPlayWidget.hh"
#include "gazebo/gui/LogPlayWidgetPrivate.hh"
using namespace gazebo;
using namespace gui;
/////////////////////////////////////////////////
LogPlayWidget::LogPlayWidget(QWidget *_parent)
: QWidget(_parent), dataPtr(new LogPlayWidgetPrivate)
{
this->setObjectName("logPlayWidget");
this->dataPtr->timePanel = dynamic_cast<TimePanel *>(_parent);
QSize bigSize(70, 70);
QSize bigIconSize(40, 40);
// Empty space on the left
QWidget *leftSpacer = new QWidget();
leftSpacer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
// Play
this->dataPtr->playButton = new QToolButton(this);
this->SetupButton(this->dataPtr->playButton,
":/images/log_play.png", false);
connect(this->dataPtr->playButton, SIGNAL(clicked()), this, SLOT(OnPlay()));
connect(this, SIGNAL(ShowPlay()), this->dataPtr->playButton, SLOT(show()));
connect(this, SIGNAL(HidePlay()), this->dataPtr->playButton, SLOT(hide()));
// Pause
this->dataPtr->pauseButton = new QToolButton(this);
this->SetupButton(this->dataPtr->pauseButton,
":/images/log_pause.png", false);
connect(this->dataPtr->pauseButton, SIGNAL(clicked()), this, SLOT(OnPause()));
connect(this, SIGNAL(ShowPause()), this->dataPtr->pauseButton, SLOT(show()));
connect(this, SIGNAL(HidePause()), this->dataPtr->pauseButton, SLOT(hide()));
// Step forward
this->dataPtr->stepForwardButton = new QToolButton(this);
this->SetupButton(this->dataPtr->stepForwardButton,
":/images/log_step_forward.png", true);
connect(this->dataPtr->stepForwardButton, SIGNAL(clicked()), this,
SLOT(OnStepForward()));
// Step back
this->dataPtr->stepBackButton = new QToolButton(this);
this->SetupButton(this->dataPtr->stepBackButton,
":/images/log_step_back.png", true);
connect(this->dataPtr->stepBackButton, SIGNAL(clicked()), this,
SLOT(OnStepBack()));
// Rewind
this->dataPtr->rewindButton = new QToolButton(this);
this->SetupButton(this->dataPtr->rewindButton,
":/images/log_rewind.png", true);
connect(this->dataPtr->rewindButton, SIGNAL(clicked()), this,
SLOT(OnRewind()));
// Forward
this->dataPtr->forwardButton = new QToolButton(this);
this->SetupButton(this->dataPtr->forwardButton,
":/images/log_forward.png", true);
connect(this->dataPtr->forwardButton, SIGNAL(clicked()), this,
SLOT(OnForward()));
// Step size
QLabel *stepLabel = new QLabel("Step: ");
this->dataPtr->stepSpin = new QSpinBox();
this->dataPtr->stepSpin->setMaximumWidth(30);
this->dataPtr->stepSpin->setValue(1);
this->dataPtr->stepSpin->setRange(1, 10000);
QHBoxLayout *stepLayout = new QHBoxLayout();
stepLayout->addWidget(stepLabel);
stepLayout->addWidget(this->dataPtr->stepSpin);
stepLayout->setAlignment(stepLabel, Qt::AlignRight);
stepLayout->setAlignment(this->dataPtr->stepSpin, Qt::AlignLeft);
// Play layout
QHBoxLayout *playLayout = new QHBoxLayout();
playLayout->addWidget(this->dataPtr->rewindButton);
playLayout->addWidget(this->dataPtr->stepBackButton);
playLayout->addWidget(this->dataPtr->playButton);
playLayout->addWidget(this->dataPtr->pauseButton);
playLayout->addWidget(this->dataPtr->stepForwardButton);
playLayout->addWidget(this->dataPtr->forwardButton);
// Controls layout
QVBoxLayout *controlsLayout = new QVBoxLayout();
controlsLayout->addLayout(playLayout);
controlsLayout->addLayout(stepLayout);
// View
this->dataPtr->view = new LogPlayView(this);
connect(this, SIGNAL(SetCurrentTime(common::Time)), this->dataPtr->view,
SLOT(SetCurrentTime(common::Time)));
connect(this, SIGNAL(SetStartTime(common::Time)), this->dataPtr->view,
SLOT(SetStartTime(common::Time)));
connect(this, SIGNAL(SetEndTime(common::Time)), this->dataPtr->view,
SLOT(SetEndTime(common::Time)));
// Current time fields
// Day edit
this->dataPtr->currentDayEdit = new QLineEdit();
this->dataPtr->currentDayEdit->setAlignment(Qt::AlignRight);
this->dataPtr->currentDayEdit->setValidator(new QIntValidator(0, 99));
this->dataPtr->currentDayEdit->setMaximumWidth(25);
this->dataPtr->currentDayEdit->setText("00");
connect(this->dataPtr->currentDayEdit, SIGNAL(editingFinished()), this,
SLOT(OnCurrentTime()));
connect(this, SIGNAL(SetCurrentDays(const QString &)),
this->dataPtr->currentDayEdit, SLOT(setText(const QString &)));
// Hour edit
this->dataPtr->currentHourEdit = new QLineEdit();
this->dataPtr->currentHourEdit->setAlignment(Qt::AlignRight);
this->dataPtr->currentHourEdit->setValidator(new QIntValidator(0, 23));
this->dataPtr->currentHourEdit->setMaximumWidth(25);
this->dataPtr->currentHourEdit->setText("00");
connect(this->dataPtr->currentHourEdit, SIGNAL(editingFinished()), this,
SLOT(OnCurrentTime()));
connect(this, SIGNAL(SetCurrentHours(const QString &)),
this->dataPtr->currentHourEdit, SLOT(setText(const QString &)));
// Minute edit
this->dataPtr->currentMinuteEdit = new QLineEdit();
this->dataPtr->currentMinuteEdit->setAlignment(Qt::AlignRight);
this->dataPtr->currentMinuteEdit->setValidator(new QIntValidator(0, 59));
this->dataPtr->currentMinuteEdit->setMaximumWidth(25);
this->dataPtr->currentMinuteEdit->setText("00");
connect(this->dataPtr->currentMinuteEdit, SIGNAL(editingFinished()), this,
SLOT(OnCurrentTime()));
connect(this, SIGNAL(SetCurrentMinutes(const QString &)),
this->dataPtr->currentMinuteEdit, SLOT(setText(const QString &)));
// Second edit
this->dataPtr->currentSecondEdit = new QLineEdit();
this->dataPtr->currentSecondEdit->setAlignment(Qt::AlignRight);
this->dataPtr->currentSecondEdit->setValidator(
new QDoubleValidator(0, 59.999, 3));
this->dataPtr->currentSecondEdit->setMaximumWidth(60);
this->dataPtr->currentSecondEdit->setText("00.000");
connect(this->dataPtr->currentSecondEdit, SIGNAL(editingFinished()), this,
SLOT(OnCurrentTime()));
connect(this, SIGNAL(SetCurrentSeconds(const QString &)),
this->dataPtr->currentSecondEdit, SLOT(setText(const QString &)));
// Labels
this->dataPtr->dayLabel = new QLabel("d");
this->dataPtr->hourLabel = new QLabel("h");
this->dataPtr->hourSeparator = new QLabel(":");
std::vector<QLabel *> currentTimeLabels;
currentTimeLabels.push_back(this->dataPtr->dayLabel);
currentTimeLabels.push_back(this->dataPtr->hourLabel);
currentTimeLabels.push_back(new QLabel("min"));
currentTimeLabels.push_back(new QLabel("s"));
// End time
QLabel *endTime = new QLabel();
endTime->setMaximumHeight(10);
connect(this, SIGNAL(SetEndTime(const QString &)), endTime,
SLOT(setText(const QString &)));
auto timeLayout = new QGridLayout();
timeLayout->setContentsMargins(0, 0, 0, 0);
timeLayout->addWidget(this->dataPtr->currentDayEdit, 0, 0);
timeLayout->addWidget(this->dataPtr->currentHourEdit, 0, 1);
timeLayout->addWidget(this->dataPtr->hourSeparator, 0, 2);
timeLayout->addWidget(this->dataPtr->currentMinuteEdit, 0, 3);
timeLayout->addWidget(new QLabel(":"), 0, 4);
timeLayout->addWidget(this->dataPtr->currentSecondEdit, 0, 5);
timeLayout->addWidget(currentTimeLabels[0], 1, 0);
timeLayout->addWidget(currentTimeLabels[1], 1, 1);
timeLayout->addWidget(currentTimeLabels[2], 1, 3);
timeLayout->addWidget(currentTimeLabels[3], 1, 5);
timeLayout->addWidget(endTime, 2, 0, 1, 6);
for (auto label : currentTimeLabels)
{
label->setStyleSheet("QLabel{font-size:11px; color:#444444}");
label->setMaximumHeight(10);
timeLayout->setAlignment(label, Qt::AlignRight);
}
timeLayout->setAlignment(endTime, Qt::AlignRight);
auto timeWidget = new QWidget();
timeWidget->setLayout(timeLayout);
timeWidget->setMaximumHeight(50);
timeWidget->setMaximumWidth(200);
// Empty space on the right
QWidget *rightSpacer = new QWidget();
rightSpacer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
// Main layout
QHBoxLayout *mainLayout = new QHBoxLayout;
mainLayout->addWidget(leftSpacer);
mainLayout->addLayout(controlsLayout);
mainLayout->addWidget(this->dataPtr->view);
mainLayout->addWidget(timeWidget);
mainLayout->addWidget(rightSpacer);
this->setLayout(mainLayout);
mainLayout->setAlignment(controlsLayout, Qt::AlignRight);
mainLayout->setAlignment(timeLayout, Qt::AlignLeft);
this->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
this->layout()->setContentsMargins(0, 0, 0, 0);
// Transport
this->dataPtr->node = transport::NodePtr(new transport::Node());
this->dataPtr->node->TryInit(common::Time::Maximum());
this->dataPtr->logPlaybackControlPub = this->dataPtr->node->
Advertise<msgs::LogPlaybackControl>("~/playback_control");
}
/////////////////////////////////////////////////
LogPlayWidget::~LogPlayWidget()
{
delete this->dataPtr;
this->dataPtr = NULL;
}
/////////////////////////////////////////////////
void LogPlayWidget::SetupButton(QToolButton *_button, QString _icon,
bool _isSmall)
{
QPixmap pixmap(_icon);
QPixmap disabledPixmap(pixmap.size());
disabledPixmap.fill(Qt::transparent);
QPainter p(&disabledPixmap);
p.setOpacity(0.4);
p.drawPixmap(0, 0, pixmap);
QIcon icon(pixmap);
icon.addPixmap(disabledPixmap, QIcon::Disabled);
QSize buttonSize;
QSize iconSize;
if (_isSmall)
{
buttonSize = QSize(50, 50);
iconSize = QSize(30, 30);
}
else
{
buttonSize = QSize(70, 70);
iconSize = QSize(40, 40);
}
_button->setFixedSize(buttonSize);
_button->setCheckable(false);
_button->setEnabled(false);
_button->setIcon(icon);
_button->setIconSize(iconSize);
_button->setStyleSheet(
QString("border-radius: %1px").arg(buttonSize.width()/2-2));
}
/////////////////////////////////////////////////
bool LogPlayWidget::IsPaused() const
{
return this->dataPtr->paused;
}
/////////////////////////////////////////////////
void LogPlayWidget::SetPaused(const bool _paused)
{
this->dataPtr->paused = _paused;
if (_paused)
{
emit ShowPlay();
emit HidePause();
// Check if there are pending steps and publish now that it's paused
if (this->dataPtr->pendingStep != 0)
{
this->PublishMultistep(this->dataPtr->pendingStep);
this->dataPtr->pendingStep = 0;
}
}
else
{
emit HidePlay();
emit ShowPause();
}
}
/////////////////////////////////////////////////
void LogPlayWidget::OnPlay()
{
msgs::LogPlaybackControl msg;
msg.set_pause(false);
this->dataPtr->logPlaybackControlPub->Publish(msg);
}
/////////////////////////////////////////////////
void LogPlayWidget::OnPause()
{
msgs::LogPlaybackControl msg;
msg.set_pause(true);
this->dataPtr->logPlaybackControlPub->Publish(msg);
}
/////////////////////////////////////////////////
void LogPlayWidget::OnStepForward()
{
if (this->dataPtr->paused)
{
this->PublishMultistep(this->dataPtr->stepSpin->value());
}
// Only step after it's paused, to sync with server
else
{
this->OnPause();
this->dataPtr->pendingStep += this->dataPtr->stepSpin->value();
}
}
/////////////////////////////////////////////////
void LogPlayWidget::OnStepBack()
{
if (this->dataPtr->paused)
{
this->PublishMultistep(-this->dataPtr->stepSpin->value());
}
// Only step after it's paused, to sync with server
else
{
this->OnPause();
this->dataPtr->pendingStep += -this->dataPtr->stepSpin->value();
}
}
/////////////////////////////////////////////////
void LogPlayWidget::OnRewind()
{
msgs::LogPlaybackControl msg;
msg.set_rewind(true);
this->dataPtr->logPlaybackControlPub->Publish(msg);
}
/////////////////////////////////////////////////
void LogPlayWidget::OnForward()
{
msgs::LogPlaybackControl msg;
msg.set_forward(true);
this->dataPtr->logPlaybackControlPub->Publish(msg);
}
/////////////////////////////////////////////////
void LogPlayWidget::OnSeek(const common::Time &_time)
{
msgs::LogPlaybackControl msg;
msgs::Set(msg.mutable_seek(), _time);
this->dataPtr->logPlaybackControlPub->Publish(msg);
}
/////////////////////////////////////////////////
void LogPlayWidget::OnCurrentTime()
{
auto day = this->dataPtr->currentDayEdit->text().toInt();
auto hour = this->dataPtr->currentHourEdit->text().toInt();
auto min = this->dataPtr->currentMinuteEdit->text().toInt();
auto sec = this->dataPtr->currentSecondEdit->text().toDouble();
auto time = common::Time(24*60*60*day + 60*60*hour + 60*min + sec);
this->OnSeek(time);
this->dataPtr->currentDayEdit->clearFocus();
this->dataPtr->currentHourEdit->clearFocus();
this->dataPtr->currentMinuteEdit->clearFocus();
this->dataPtr->currentSecondEdit->clearFocus();
}
/////////////////////////////////////////////////
void LogPlayWidget::EmitSetCurrentTime(const common::Time &_time)
{
// Make sure it's within limits
common::Time time = std::max(_time, this->dataPtr->startTime);
if (this->dataPtr->endTime != common::Time::Zero)
time = std::min(time, this->dataPtr->endTime);
this->dataPtr->currentTime = time;
// Enable/disable buttons
this->dataPtr->stepBackButton->setEnabled(time != this->dataPtr->startTime);
this->dataPtr->rewindButton->setEnabled(time != this->dataPtr->startTime);
this->dataPtr->stepForwardButton->setEnabled(time != this->dataPtr->endTime);
this->dataPtr->forwardButton->setEnabled(time != this->dataPtr->endTime);
this->dataPtr->pauseButton->setEnabled(time != this->dataPtr->endTime);
this->dataPtr->playButton->setEnabled(time != this->dataPtr->endTime);
// Update current time line edit if the user is not editing it
if (!(this->dataPtr->currentDayEdit->hasFocus() ||
this->dataPtr->currentHourEdit->hasFocus() ||
this->dataPtr->currentMinuteEdit->hasFocus() ||
this->dataPtr->currentSecondEdit->hasFocus()))
{
// milliseconds
double msec = time.nsec / common::Time::nsInMs;
// seconds
double s = time.sec;
int seconds = msec / 1000;
msec -= seconds * 1000;
s += seconds;
// days
unsigned int day = s / 86400;
s -= day * 86400;
// hours
unsigned int hour = s / 3600;
s -= hour * 3600;
// minutes
unsigned int min = s / 60;
s -= min * 60;
this->SetCurrentDays(QString::number(day));
this->SetCurrentHours(QString::number(hour));
this->SetCurrentMinutes(QString::number(min));
this->SetCurrentSeconds(QString::number(s + msec / 1000.0, 'f', 3));
}
// Update current time item in view
this->SetCurrentTime(time);
}
/////////////////////////////////////////////////
void LogPlayWidget::EmitSetStartTime(const common::Time &_time)
{
if (this->dataPtr->endTime != common::Time::Zero &&
_time >= this->dataPtr->endTime)
{
gzwarn << "Start time [" << _time << "] after end time [" <<
this->dataPtr->endTime << "]. Not updating." << std::endl;
return;
}
this->dataPtr->startTime = _time;
// Update start time in view
this->SetStartTime(this->dataPtr->startTime);
// Keep current time within bounds
if (this->dataPtr->startTime > this->dataPtr->currentTime)
this->EmitSetCurrentTime(this->dataPtr->startTime);
}
/////////////////////////////////////////////////
void LogPlayWidget::EmitSetEndTime(const common::Time &_time)
{
if (_time <= this->dataPtr->startTime)
{
gzwarn << "End time [" << _time << "] before start time [" <<
this->dataPtr->startTime << "]. Not updating." << std::endl;
return;
}
this->dataPtr->endTime = _time;
// Use shorter string if less than 1h
if (_time < common::Time::Hour)
this->dataPtr->lessThan1h = true;
// Update end time label
std::string timeString;
if (this->dataPtr->lessThan1h)
{
timeString = _time.FormattedString(common::Time::FormatOption::MINUTES);
}
else
{
timeString = _time.FormattedString();
}
timeString = "/ " + timeString;
this->SetEndTime(QString::fromStdString(timeString));
// Update end time in view
this->SetEndTime(_time);
// Keep current time within bounds
if (this->dataPtr->endTime < this->dataPtr->currentTime)
this->EmitSetCurrentTime(this->dataPtr->endTime);
// Hide unecessary widgets
this->dataPtr->currentDayEdit->setVisible(!this->dataPtr->lessThan1h);
this->dataPtr->currentHourEdit->setVisible(!this->dataPtr->lessThan1h);
this->dataPtr->dayLabel->setVisible(!this->dataPtr->lessThan1h);
this->dataPtr->hourLabel->setVisible(!this->dataPtr->lessThan1h);
this->dataPtr->hourSeparator->setVisible(!this->dataPtr->lessThan1h);
}
/////////////////////////////////////////////////
void LogPlayWidget::PublishMultistep(const int _step)
{
msgs::LogPlaybackControl msg;
msg.set_multi_step(_step);
this->dataPtr->logPlaybackControlPub->Publish(msg);
}
/////////////////////////////////////////////////
LogPlayView::LogPlayView(LogPlayWidget *_parent)
: QGraphicsView(_parent), dataPtr(new LogPlayViewPrivate)
{
this->setSizePolicy(QSizePolicy::Expanding,
QSizePolicy::Expanding);
this->dataPtr->sceneWidth = 1000;
this->dataPtr->sceneHeight = 120;
this->dataPtr->margin = 50;
QGraphicsScene *graphicsScene = new QGraphicsScene();
graphicsScene->setBackgroundBrush(QColor(128, 128, 128));
this->setScene(graphicsScene);
this->setMinimumWidth(this->dataPtr->sceneHeight);
this->setViewportUpdateMode(QGraphicsView::FullViewportUpdate);
this->setStyleSheet("QGraphicsView{border-style: none;}");
this->setSceneRect(0, 0,
this->dataPtr->sceneWidth, this->dataPtr->sceneHeight);
// Time line
QGraphicsLineItem *line = new QGraphicsLineItem(this->dataPtr->margin,
this->dataPtr->sceneHeight/2,
this->dataPtr->sceneWidth - this->dataPtr->margin,
this->dataPtr->sceneHeight/2);
line->setPen(QPen(QColor(50, 50, 50, 255), 2));
graphicsScene->addItem(line);
// Current time item
this->dataPtr->currentTimeItem = new CurrentTimeItem();
this->dataPtr->currentTimeItem->setPos(this->dataPtr->margin,
this->dataPtr->sceneHeight/2);
graphicsScene->addItem(this->dataPtr->currentTimeItem);
this->dataPtr->startTimeSet = false;
this->dataPtr->endTimeSet = false;
// Send controls to parent
LogPlayWidget *widget = qobject_cast<LogPlayWidget *>(_parent);
if (!widget)
return;
connect(this, SIGNAL(Seek(const common::Time &)), widget,
SLOT(OnSeek(const common::Time &)));
}
/////////////////////////////////////////////////
void LogPlayView::SetCurrentTime(const common::Time &_time)
{
if (this->dataPtr->currentTimeItem->isSelected())
return;
common::Time totalTime = this->dataPtr->endTime - this->dataPtr->startTime;
if (totalTime == common::Time::Zero)
return;
double relPos = ((_time - this->dataPtr->startTime) / totalTime).Double();
this->dataPtr->currentTimeItem->setPos(this->dataPtr->margin +
(this->dataPtr->sceneWidth - 2 * this->dataPtr->margin)*relPos,
this->dataPtr->sceneHeight/2);
}
/////////////////////////////////////////////////
void LogPlayView::SetStartTime(const common::Time &_time)
{
this->dataPtr->startTime = _time;
this->dataPtr->startTimeSet = true;
}
/////////////////////////////////////////////////
void LogPlayView::SetEndTime(const common::Time &_time)
{
this->dataPtr->endTime = _time;
this->dataPtr->endTimeSet = true;
if (this->dataPtr->startTimeSet)
this->DrawTimeline();
}
/////////////////////////////////////////////////
void LogPlayView::DrawTimeline()
{
if (this->dataPtr->timelineDrawn || !this->dataPtr->startTimeSet ||
!this->dataPtr->endTimeSet)
return;
common::Time totalTime = this->dataPtr->endTime - this->dataPtr->startTime;
if (totalTime == common::Time::Zero)
return;
// Aim for this number, but some samples might be added/removed
int intervals = 10;
// All ticks are shifted from a round number of seconds (no msec or nsec)
common::Time roundStartTime = common::Time(this->dataPtr->startTime.sec, 0);
// Time between ticks (round seconds)
common::Time interval = totalTime/intervals;
interval.nsec = 0;
if (interval == common::Time::Zero)
interval = common::Time::Second;
// Time line
int tickHeight = 15;
common::Time tickTime = this->dataPtr->startTime;
int i = 0;
while (tickTime >= this->dataPtr->startTime &&
tickTime < this->dataPtr->endTime)
{
// Intermediate samples have a round number
if (i != 0)
{
tickTime = roundStartTime + interval * i;
}
// If first interval too close, shift by 1s
common::Time endSpace = interval * 0.9;
if (tickTime != this->dataPtr->startTime &&
tickTime < this->dataPtr->startTime + endSpace)
{
roundStartTime += common::Time::Second;
tickTime = roundStartTime + interval * i;
}
// If last interval too close, skip to end
if (tickTime > this->dataPtr->endTime - endSpace)
{
tickTime = this->dataPtr->endTime;
}
++i;
// Relative position
double relPos = ((tickTime - this->dataPtr->startTime) / totalTime)
.Double();
// Tick vertical line
QGraphicsLineItem *tick = new QGraphicsLineItem(0, -tickHeight, 0, 0);
tick->setPos(this->dataPtr->margin +
(this->dataPtr->sceneWidth - 2 * this->dataPtr->margin)*relPos,
this->dataPtr->sceneHeight/2);
tick->setPen(QPen(QColor(50, 50, 50, 255), 2));
this->scene()->addItem(tick);
// Text
std::string timeText;
if (tickTime == this->dataPtr->startTime ||
tickTime == this->dataPtr->endTime)
{
timeText = tickTime.FormattedString(common::Time::FormatOption::MINUTES);
}
else
{
timeText = tickTime.FormattedString(common::Time::FormatOption::MINUTES,
common::Time::FormatOption::SECONDS);
}
QGraphicsSimpleTextItem *tickText = new QGraphicsSimpleTextItem(
QString::fromStdString(timeText));
tickText->setBrush(QBrush(QColor(50, 50, 50, 255)));
tickText->setPos(
this->dataPtr->margin - tickText->boundingRect().width()*0.5 +
(this->dataPtr->sceneWidth - 2 * this->dataPtr->margin)*relPos,
this->dataPtr->sceneHeight/2 - 3 * tickHeight);
this->scene()->addItem(tickText);
}
this->dataPtr->timelineDrawn = true;
}
/////////////////////////////////////////////////
void LogPlayView::mousePressEvent(QMouseEvent *_event)
{
QGraphicsItem *mouseItem =
this->scene()->itemAt(this->mapToScene(_event->pos()));
if (mouseItem == this->dataPtr->currentTimeItem)
{
QApplication::setOverrideCursor(QCursor(Qt::ClosedHandCursor));
mouseItem->setSelected(true);
}
}
/////////////////////////////////////////////////
void LogPlayView::mouseMoveEvent(QMouseEvent *_event)
{
// If nothing is selected
if (this->scene()->selectedItems().isEmpty())
{
QGraphicsItem *mouseItem =
this->scene()->itemAt(this->mapToScene(_event->pos()));
// Change cursor when hovering over current time item
if (mouseItem == this->dataPtr->currentTimeItem)
QApplication::setOverrideCursor(QCursor(Qt::OpenHandCursor));
else
QApplication::setOverrideCursor(QCursor(Qt::ArrowCursor));
}
// If dragging current time item, keep it within bounds
if (this->dataPtr->currentTimeItem->isSelected())
{
QPointF newPos(this->mapToScene(_event->pos()));
if (newPos.x() < this->dataPtr->margin)
newPos.setX(this->dataPtr->margin);
else if (newPos.x() > (this->dataPtr->sceneWidth - this->dataPtr->margin))
newPos.setX(this->dataPtr->sceneWidth - this->dataPtr->margin);
newPos.setY(this->dataPtr->sceneHeight/2);
this->dataPtr->currentTimeItem->setPos(newPos);
}
}
/////////////////////////////////////////////////
void LogPlayView::mouseReleaseEvent(QMouseEvent */*_event*/)
{
// Send time seek if releasing current time item
if (this->dataPtr->currentTimeItem->isSelected())
{
double relPos =
(this->dataPtr->currentTimeItem->pos().x() - this->dataPtr->margin) /
(this->dataPtr->sceneWidth - 2 * this->dataPtr->margin);
common::Time totalTime = this->dataPtr->endTime - this->dataPtr->startTime;
common::Time seekTime = (totalTime * relPos) + this->dataPtr->startTime;
this->Seek(seekTime);
}
this->scene()->clearSelection();
QApplication::setOverrideCursor(QCursor(Qt::ArrowCursor));
}
/////////////////////////////////////////////////
CurrentTimeItem::CurrentTimeItem()
{
this->setEnabled(true);
this->setRect(-8, -25, 16, 50);
this->setZValue(10);
this->setAcceptHoverEvents(true);
this->setAcceptedMouseButtons(Qt::LeftButton);
this->setFlag(QGraphicsItem::ItemIsSelectable);
this->setFlag(QGraphicsItem::ItemIsMovable);
this->setFlag(QGraphicsItem::ItemSendsScenePositionChanges);
this->setCursor(Qt::SizeAllCursor);
}
/////////////////////////////////////////////////
void CurrentTimeItem::paint(QPainter *_painter,
const QStyleOptionGraphicsItem */*_option*/, QWidget */*_widget*/)
{
int lineHeight = 50;
int lineWidth = 3;
// Vertical line
QLineF vLine(-lineWidth/10.0, -lineHeight/2.0,
-lineWidth/10.0, +lineHeight/2.0);
QPen linePen;
linePen.setColor(QColor(50, 50, 50, 255));
linePen.setWidth(lineWidth);
_painter->setPen(linePen);
_painter->drawLine(vLine);
// Triangle
QVector<QPointF> trianglePts;
trianglePts.push_back(QPointF(-8, -lineHeight/2 - 1));
trianglePts.push_back(QPointF(8, -lineHeight/2 - 1));
trianglePts.push_back(QPointF(0, -lineHeight/2 + 10));
QPolygonF triangle(trianglePts);
QPen whitePen(Qt::white, 0);
QPen orangePen(QColor(245, 129, 19, 255), 0);
QBrush whiteBrush(Qt::white);
QBrush orangeBrush(QColor(245, 129, 19, 255));
if (this->isSelected())
{
_painter->setPen(whitePen);
_painter->setBrush(whiteBrush);
}
else
{
_painter->setPen(orangePen);
_painter->setBrush(orangeBrush);
}
_painter->drawPolygon(triangle);
}
| [
"tjpu_zenglei@sina.com"
] | tjpu_zenglei@sina.com |
77a00c64e048b3028b465dc17a44e0f3c691ab22 | e590e09c160f6cfb16522c35189d2660d0b541e1 | /Functions/passByReference.cpp | 7fdc3352e4537037f357418cb9e06ee16ed751a7 | [] | no_license | nniroula/CPP_VSCode | 047dd58a8f98f784abc606df07745b6238d98528 | 0f8847dd0803988a890d25e63aaf8c96e4d145ba | refs/heads/main | 2023-03-23T20:56:17.960384 | 2021-03-19T23:44:13 | 2021-03-19T23:44:13 | 311,813,717 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 571 | cpp | /*
Write a function that has main function, takes user input in one function and another function uses
reference parameter; pass by reference.
*/
#include<iostream>
using namespace std;
int sumAll(int &, int &);
int getUserInput(int &, int &);
int main(){
int x, y; // these are called original arguments.
getUserInput(x, y);
cout<<"The sum is "<< sumAll(x, y)<<endl;
return 0;
}
int sumAll(int &a, int &b){
return a + b;
}
int getUserInput(int &num1, int &num2){
cout<<"Please enter both numbers: ";
cin>>num1>>num2;
return num1, num2;
} | [
"nkbhaie2017@gmail.com"
] | nkbhaie2017@gmail.com |
a82245769529623cf06432d33d822467c6344e45 | 0305b40a7ea1f270a01166e1b644a895e271655a | /17471.cpp | 3b4778e33cd41a2387ba2fbfca7fdf34c8146665 | [] | no_license | chan2ie/BOJ_problem_solving | 84b8d1447a2478e99eafd0da9271d6e33c791d79 | ee08fc2fb9e121f4c949364adb776c888c7ff0d8 | refs/heads/main | 2023-08-17T14:57:12.611744 | 2021-10-04T03:25:13 | 2021-10-04T03:25:13 | 412,163,969 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 471 | cpp | #include <iostream>
#include <vector>
#include <queue>
using namespace::std;
int is_connected(vector<int> nodes) {
}
int main() {
int n, sum = 0;
cin >> n;
vector<int> people(n, 0);
for (int i = 0; i < n; i++) {
cin >> people[i];
sum += people[i];
}
vector<vector<int>> connected(n, vector<int>(n, 0));
int temp;
for (int i = 0; i < n; i++) {
int n2;
cin >> n2;
for (int j = 0; j < n2; j++) {
cin >> temp;
connected[i][temp] = 1;
}
}
} | [
"dlcksgml17@sogang.ac.kr"
] | dlcksgml17@sogang.ac.kr |
e16a65f6bcbaa7e91fb0dc94b2a4522e96ca8eb3 | 733f6955bd8a52ccb13f546fbd453c9f824ee328 | /src/SkyBox.h | 523bf7aa3b6a8ee0cc7827c11ae3b0871551daaa | [] | no_license | liao-mo/CG-Project5 | f4229bf6c15c43e3d13efce8726f2ae66e40c6bb | dc94d694d2b6cd113978fc9515ccf23027f4f459 | refs/heads/main | 2023-02-15T06:52:44.073402 | 2021-01-12T14:42:05 | 2021-01-12T14:42:05 | 323,264,700 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,920 | h | #pragma once
#include<iostream>
#include<vector>
#include "learnopengl/model.h"
#include "learnopengl/filesystem.h"
#include <learnopengl/shader_m.h>
#include <glad/glad.h>
#include <glm/glm.hpp>
#include <glm/gtx/transform.hpp>
#include <GL/glu.h>
#include <GL/glut.h>
using namespace std;
class SkyBox {
public:
SkyBox();
unsigned int loadCubemap(vector<std::string> paths);
void setMVP(glm::mat4 m, glm::mat4 v, glm::mat4 p);
void draw();
//skyBox shader
Shader* skyboxShader = nullptr;
// skyBox VAO
unsigned int skyboxVAO, skyboxVBO;
vector<std::string> faces_paths;
//skyBox texture
unsigned int cubemapTexture;
//model, view and projection matrices
glm::mat4 modelMatrix;
glm::mat4 viewMatrix;
glm::mat4 projectionMatrix;
float skyboxVertices[108] = {
// positions
-1.0f, 1.0f, -1.0f,
-1.0f, -1.0f, -1.0f,
1.0f, -1.0f, -1.0f,
1.0f, -1.0f, -1.0f,
1.0f, 1.0f, -1.0f,
-1.0f, 1.0f, -1.0f,
-1.0f, -1.0f, 1.0f,
-1.0f, -1.0f, -1.0f,
-1.0f, 1.0f, -1.0f,
-1.0f, 1.0f, -1.0f,
-1.0f, 1.0f, 1.0f,
-1.0f, -1.0f, 1.0f,
1.0f, -1.0f, -1.0f,
1.0f, -1.0f, 1.0f,
1.0f, 1.0f, 1.0f,
1.0f, 1.0f, 1.0f,
1.0f, 1.0f, -1.0f,
1.0f, -1.0f, -1.0f,
-1.0f, -1.0f, 1.0f,
-1.0f, 1.0f, 1.0f,
1.0f, 1.0f, 1.0f,
1.0f, 1.0f, 1.0f,
1.0f, -1.0f, 1.0f,
-1.0f, -1.0f, 1.0f,
-1.0f, 1.0f, -1.0f,
1.0f, 1.0f, -1.0f,
1.0f, 1.0f, 1.0f,
1.0f, 1.0f, 1.0f,
-1.0f, 1.0f, 1.0f,
-1.0f, 1.0f, -1.0f,
-1.0f, -1.0f, -1.0f,
-1.0f, -1.0f, 1.0f,
1.0f, -1.0f, -1.0f,
1.0f, -1.0f, -1.0f,
-1.0f, -1.0f, 1.0f,
1.0f, -1.0f, 1.0f
};
}; | [
"b10815026@gapps.ntust.edu.tw"
] | b10815026@gapps.ntust.edu.tw |
46af1d8da0bfbe8d9c192973b47aa6552e8416ef | 9eed36ccf2be5585685f9531e595c1d14fd8ef76 | /extern/3rd/PcapPlusPlus-19.12/Common++/header/LRUList.h | a303dec867b8be8856099f2549d0589ccb7f5225 | [
"Unlicense",
"WTFPL"
] | permissive | Cyweb-unknown/eft-packet-1 | 756ab75b96e658a0b2044e09389b7a06d285c971 | 925da44fc1f49e4fe6b17e79248714ada4ea451d | refs/heads/master | 2022-10-27T11:47:09.454465 | 2020-06-13T14:41:43 | 2020-06-13T14:41:43 | 272,038,457 | 1 | 1 | WTFPL | 2020-06-13T15:46:17 | 2020-06-13T15:46:16 | null | UTF-8 | C++ | false | false | 4,084 | h | #ifndef PCAPPP_LRU_LIST
#define PCAPPP_LRU_LIST
#include <map>
#include <list>
#if __cplusplus > 199711L || _MSC_VER >= 1800
#include <utility>
#endif
/// @file
/**
* \namespace pcpp
* \brief The main namespace for the PcapPlusPlus lib
*/
namespace pcpp
{
/**
* @class LRUList
* A template class that implements a LRU cache with limited size. Each time the user puts an element it goes to head of the
* list as the most recently used element (if the element was already in the list it advances to the head of the list).
* The last element in the list is the one least recently used and will be pulled out of the list if it reaches its max size
* and a new element comes in. All actions on this LRU list are O(1)
*/
template<typename T>
class LRUList
{
public:
typedef typename std::list<T>::iterator ListIterator;
typedef typename std::map<T, ListIterator>::iterator MapIterator;
/**
* A c'tor for this class
* @param[in] maxSize The max size this list can go
*/
LRUList(size_t maxSize)
{
m_MaxSize = maxSize;
}
/**
* Puts an element in the list. This element will be inserted (or advanced if it already exists) to the head of the
* list as the most recently used element. If the list already reached its max size and the element is new this method
* will remove the least recently used element and return a value in deletedValue. Method complexity is O(log(getSize())).
* This is a optimized version of the method T* put(const T&).
* @param[in] element The element to insert or to advance to the head of the list (if already exists)
* @param[out] deletedValue The value of deleted element if a pointer is not NULL. This parameter is optional.
* @return 0 if the list didn't reach its max size, 1 otherwise. In case the list already reached its max size
* and deletedValue is not NULL the value of deleted element is copied into the place the deletedValue points to.
*/
int put(const T& element, T* deletedValue = NULL)
{
m_CacheItemsList.push_front(element);
// Inserting a new element. If an element with an equivalent key already exists the method returns an iterator to the element that prevented the insertion
std::pair<MapIterator, bool> pair = m_CacheItemsMap.insert(std::make_pair(element, m_CacheItemsList.begin()));
if (pair.second == false) // already exists
{
m_CacheItemsList.erase(pair.first->second);
pair.first->second = m_CacheItemsList.begin();
}
if (m_CacheItemsMap.size() > m_MaxSize)
{
ListIterator lruIter = m_CacheItemsList.end();
lruIter--;
if (deletedValue != NULL)
#if __cplusplus > 199711L || _MSC_VER >= 1800
*deletedValue = std::move(*lruIter);
#else
*deletedValue = *lruIter;
#endif
m_CacheItemsMap.erase(*lruIter);
m_CacheItemsList.erase(lruIter);
return 1;
}
return 0;
}
/**
* Get the most recently used element (the one at the beginning of the list)
* @return The most recently used element
*/
const T& getMRUElement() const
{
return m_CacheItemsList.front();
}
/**
* Get the least recently used element (the one at the end of the list)
* @return The least recently used element
*/
const T& getLRUElement() const
{
return m_CacheItemsList.back();
}
/**
* Erase an element from the list. If element isn't found in the list nothing happens
* @param[in] element The element to erase
*/
void eraseElement(const T& element)
{
MapIterator iter = m_CacheItemsMap.find(element);
if (iter == m_CacheItemsMap.end())
return;
m_CacheItemsList.erase(iter->second);
m_CacheItemsMap.erase(element);
}
/**
* @return The max size of this list as determined in the c'tor
*/
size_t getMaxSize() const { return m_MaxSize; }
/**
* @return The number of elements currently in this list
*/
size_t getSize() const { return m_CacheItemsMap.size(); }
private:
std::list<T> m_CacheItemsList;
std::map<T, ListIterator> m_CacheItemsMap;
size_t m_MaxSize;
};
} // namespace pcpp
#endif /* PCAPPP_LRU_LIST */
| [
"koraydemirci86@gmail.com"
] | koraydemirci86@gmail.com |
048591e9d010e57fda29a4d621bff57fbf7a6a52 | b878e36f5d6e36a678f35ed5303e07280bde03c4 | /series/data/nodevaluelists/NodeValueList.h | 077f188bafcf1c26fc97c250794ed9c7b3b5f63b | [] | no_license | OldRiverChen/DNM | 7f76dbe02b0969c091795dbe84590b6dc5bb8c93 | 99d6df1775e4d17671d84714acfeb644aaaa74e7 | refs/heads/master | 2020-12-30T15:29:24.349542 | 2017-05-15T01:34:05 | 2017-05-15T01:34:05 | 91,143,608 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,159 | h | #ifndef _NODEVALUELIST_H_
#define _NODEVALUELIST_H_
#include <string>
#include <iostream>
#include "..\Data.h"
#include "..\..\..\util\Log.h"
#include "..\..\..\io\Writer.h"
using namespace std;
/**
* A NodeValueList is an object containing an array with 1 value for each node.
* The node index is used as the index for the array. If a node is removed from
* the graph, his former value is replaced by a Double.NaN. When inserting new
* nodevalues with out-of-bound indeces, the array is expanded accordingly.
*
*/
class NodeValueList:public Data
{
public:
vector<double>* values;
static double emptyValue;
public:
NodeValueList(string name, int size);
NodeValueList(string name, vector<double>* values);
NodeValueList(string name, vector<long>* values);
public:
vector<double>* getValues();
void setValue(int index,double value);
// IO methods
/**
*
* @param dir
* String which contains the path / directory the NodeValueList
* will be written to.
*
* @param filename
* String representing the desired filename for the
* NodeValueList.
*/
void write(string dir, string filename);
};
#endif | [
"309128717@99.com"
] | 309128717@99.com |
1cd686f37525c6f3ec9e650a6275b5394846fedf | 6596a4ec078c40ef7a70db46b8b2f6268bea7925 | /inicio.cpp | d55c00306e8a6329687ae3a2ef8f330434b72dc8 | [] | no_license | MaldoAlberto/Toto_Game | b1314e7c71698bfce72c5b373c761c7480f9e812 | db96e7804006522817ea9fb4c91c9915241e514a | refs/heads/master | 2020-03-24T09:08:52.629799 | 2018-07-27T20:25:42 | 2018-07-27T20:25:42 | 142,619,907 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 578 | cpp | #include "inicio.h"
Inicio::Inicio(QObject *parent) :
GameElement(parent)
{
this->addFrame(QPixmap(":/image/image/start.png"));
this->addFrame(QPixmap(":/image/image/tuto.png"));
this->init();
}
void Inicio::init()
{
}
void Inicio::logic()
{
if(!this->enabledLogic)
return;
}
void Inicio::draw(QPainter *painter)
{
if(!this->enabledDraw)
return;
painter->drawPixmap(45.0,155.0,197.0,73.0,
this->pixmapList[0]);
painter->drawPixmap(86.5,250.0,115.0,70.0,
this->pixmapList[1]);
}
| [
"amaldonador1300@alumno.ipn.mx"
] | amaldonador1300@alumno.ipn.mx |
4c6deceda8a83b252b2746de5c38e029d3bb9224 | 14248aaedfa5f77c7fc5dd8c3741604fb987de5c | /luogu/P1880.cpp | 4e9f6b9785a087c8ee5c460d92ef00a5a25b73b7 | [] | no_license | atubo/online-judge | fc51012465a1bd07561b921f5c7d064e336a4cd2 | 8774f6c608bb209a1ebbb721d6bbfdb5c1d1ce9b | refs/heads/master | 2021-11-22T19:48:14.279016 | 2021-08-29T23:16:16 | 2021-08-29T23:16:16 | 13,290,232 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,469 | cpp | // https://www.luogu.org/problem/show?pid=1880
// 石子合并
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 210;
int dp[MAXN][MAXN];
int A[MAXN], ps[MAXN];
int N;
int solve1() {
for (int i = 1; i <= N; i++) {
dp[i][i] = 0;
}
for (int len = 2; len <= N/2; len++) {
for (int i = 1; i <= N-len; i++) {
int j = i + len - 1;
dp[i][j] = INT_MAX;
for (int k = i; k < j; k++) {
dp[i][j] = min(dp[i][j], dp[i][k] + dp[k+1][j] + ps[j]-ps[i-1]);
}
}
}
int ans = INT_MAX;
for (int i = 1; i <= N/2; i++) {
ans = min(ans, dp[i][i+N/2-1]);
}
return ans;
}
int solve2() {
for (int i = 1; i <= N; i++) {
dp[i][i] = 0;
}
for (int len = 2; len <= N/2; len++) {
for (int i = 1; i <= N-len; i++) {
int j = i + len - 1;
dp[i][j] = INT_MIN;
for (int k = i; k < j; k++) {
dp[i][j] = max(dp[i][j], dp[i][k] + dp[k+1][j] + ps[j]-ps[i-1]);
}
}
}
int ans = INT_MIN;
for (int i = 1; i <= N/2; i++) {
ans = max(ans, dp[i][i+N/2-1]);
}
return ans;
}
int main() {
scanf("%d", &N);
for (int i = 1; i <= N; i++) {
scanf("%d", &A[i]);
A[i+N] = A[i];
}
N *= 2;
for (int i = 1; i <= N; i++) {
ps[i] = A[i] + ps[i-1];
}
printf("%d\n%d\n", solve1(), solve2());
return 0;
}
| [
"err722@yahoo.com"
] | err722@yahoo.com |
eb878cdfa51db4d92b117368a9152c9819ca594f | f50d212d822c78adb9f037b50fba3c13f031ef52 | /Code/Matrix/Matrix.h | 005cbf6a43d0b9fd304bd4fb5d2c3b9a2cb96ca3 | [] | no_license | drinkingcoder/PictureProcessing | 178aabbcfd2e15bbfcdd3352e722c4a0080dce44 | b03c52c5bf9279e79ae91d4ed261a2ebe63ea703 | refs/heads/master | 2020-12-25T11:15:12.601033 | 2016-06-07T15:04:37 | 2016-06-07T15:04:37 | 60,622,862 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,247 | h | #include <math.h>
#include<stdio.h>
#include<iostream>
#include<string>
#include<stdlib.h>
#include"../Defs.h"
#define PI 3.1415926
#ifndef _MATRIX_H_
#define _MATRIX_H_
using namespace std;
class Matrix
{
public:
float** data;
int Row,Col;
Matrix(int Row,int Col);
Matrix(Matrix const& m);
~Matrix();
float* operator[](int k);
friend Matrix operator+(Matrix& m1,Matrix& m2);
friend Matrix operator-(Matrix& m1,Matrix& m2);
friend Matrix operator*(Matrix& m1,Matrix& m2);
void SwapRow(int i,int j);
void TimesRow(int row,float times);
void PlusRow(int i,float times,int j);
void SwapCol(int i,int j);
Matrix* SolveEquation();
static float GaussianFunction(float sigma,float dis);
static Matrix* UnitMatrix(int Row);
static Matrix* Multiplication(Matrix* m1,Matrix* m2);
static Matrix* Translate(Matrix* m,float x,float y);
static Matrix* MirrorX(Matrix* m,float x);
static Matrix* MirrorY(Matrix* m,float y);
static Matrix* Scale(Matrix* m,float xcoeff,float ycoeff);
static Matrix* Rotate(Matrix* m,float degree);
static Matrix* Shear(Matrix* m,float x,float y);
static Matrix* Laplacian(int Row);
static Matrix* ones(int Row);
static Matrix* GaussianFilter(float sigma);
void printInfo(string s);
};
#endif
| [
"drinkingcoder@gmail.com"
] | drinkingcoder@gmail.com |
c9c56c4183a8f96a0e78bfb44569189fc927b8fe | 3e6048eca0214386d3ad6c2eb393778dd8370c81 | /apptest/src/base/future/impl/core.h | 2f4e8504970737449078311ecc7e7e562a1ac4e3 | [] | no_license | nmraz/winapitest | c7be8f46c9ce63c52e3ae30c4f628a85d46ac336 | 30cd58ead136eedacf368c3b2732fbd92377830f | refs/heads/master | 2022-12-30T05:32:52.802258 | 2019-05-04T20:59:56 | 2019-05-04T20:59:56 | 306,280,501 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,827 | h | #pragma once
#include "base/assert.h"
#include "base/expected.h"
#include "base/function.h"
#include "base/future/exceptions.h"
#include "base/non_copyable.h"
#include <exception>
#include <mutex>
namespace base::impl {
template<typename T>
class future_core : public non_copy_movable {
public:
future_core() = default;
future_core(expected<T>&& val);
~future_core();
template<typename Cont>
void set_cont(Cont&& cont);
void fulfill(expected<T>&& val);
private:
void call_cont(std::unique_lock<std::mutex> hold) noexcept;
expected<T> val_;
function<void(expected<T>&&)> cont_;
std::mutex lock_; // protects val_, cont_
bool cont_set_ = false;
bool fulfilled_ = false;
};
template<typename T>
future_core<T>::future_core(expected<T>&& val)
: val_(std::move(val))
, fulfilled_(true) {
}
template<typename T>
future_core<T>::~future_core() {
if (val_.has_exception()) {
std::terminate();
}
}
template<typename T>
template<typename Cont>
void future_core<T>::set_cont(Cont&& cont) {
std::unique_lock hold(lock_);
ASSERT(!cont_set_) << "Future continuation already set";
cont_ = std::forward<Cont>(cont);
cont_set_ = true;
call_cont(std::move(hold));
}
template<typename T>
void future_core<T>::fulfill(expected<T>&& val) {
std::unique_lock hold(lock_);
ASSERT(!fulfilled_) << "Promise already fulfilled";
val_ = std::move(val);
fulfilled_ = true;
call_cont(std::move(hold));
}
// PRIVATE
template<typename T>
void future_core<T>::call_cont(std::unique_lock<std::mutex> hold) noexcept {
if (cont_set_ && fulfilled_) {
hold.unlock();
// at this point, it is safe to access cont_ and val_ without locking,
// since they are guaranteed not to be mutated elsewhere
cont_(std::move(val_));
val_.reset();
}
}
} // namespace base::impl | [
"noamraz8@gmail.com"
] | noamraz8@gmail.com |
4ed492e3bf818e38ac29fc66934ce070d08354c7 | 221553caa94f29634de701409a35c74d6168404b | /Testes/2018/CI1/Pratica/Bank.cpp | e1e9a6ae0465ff7921383bb40fbb12cd2d5a74e2 | [] | no_license | TitanicThompson1/AEDA | dc42f606674573160df047f6f8bedee14bac7952 | 39c6f4f17d5ef5202fae7c1bb47a3b338be6d051 | refs/heads/master | 2020-08-01T02:27:50.916671 | 2020-06-03T15:07:48 | 2020-06-03T15:07:48 | 210,828,440 | 1 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 1,798 | cpp | /*
* Bank.cpp
*/
#include "Bank.h"
#include <algorithm>
#include <string>
Bank::Bank() {}
void Bank::addAccount(Account *a) {
accounts.push_back(a);
}
void Bank::addBankOfficer(BankOfficer b){
bankOfficers.push_back(b);
}
vector<BankOfficer> Bank::getBankOfficers() const {
return bankOfficers;
}
vector<Account *> Bank::getAccounts() const {
return accounts;
}
// ----------------------------------------------------------------------------------------------
// a alterar
double Bank::getWithdraw(string cod1) const{
double res=0;
for(int i=0;i<accounts.size();i++){
if(accounts.at(i)->getCodH()==cod1)
res+=accounts.at(i)->getWithdraw();
}
return res;
}
// a alterar
vector<Account *> Bank::removeBankOfficer(string name){
vector<Account *> res;
auto it=bankOfficers.begin();
while(it!=bankOfficers.end() && it->getName()!=name )
{
it++;
}
if(it==bankOfficers.end())
return res;
res=it->getAccounts();
bankOfficers.erase(it);
return res;
}
// a alterar
const BankOfficer & Bank::addAccountToBankOfficer(Account *ac, string name) {
BankOfficer *bo= new BankOfficer();
int ind=-1;
for(int i=0;i<bankOfficers.size();i++)
{
if(name==bankOfficers.at(i).getName()){
ind=i;
bo=&bankOfficers.at(i);
break;
}
}
if(ind==-1)
throw NoBankOfficerException(name);
bankOfficers.at(ind).addAccount(ac);
return *bo;
}
bool ordena(Account *a1 , Account *a2 ){
if(a1->getBalance()<a2->getBalance())
return true;
else if(a1->getBalance()==a2->getBalance() && a1->getCodIBAN()<a2->getCodIBAN())
return true;
return false;
}
void Bank::sortAccounts() {
sort(accounts.begin(),accounts.end(),ordena);
}
| [
"45363817+TitanicThompson1@users.noreply.github.com"
] | 45363817+TitanicThompson1@users.noreply.github.com |
55d4880bd5b88d7045389a3ceb87423832fce839 | f5f254032ef9503b6611727bebe5df81721b9f86 | /osources/info.cpp | 1e69e923378cf00100492c23dce83ef5cc4f4545 | [] | no_license | niaho/nihao.github.io | b50d1850f014ef5f981a4906b601d0a96e39b01b | 3d42dc34f009569f56271c7990eab083c73617a6 | refs/heads/master | 2021-04-26T23:57:36.218163 | 2019-08-14T03:34:23 | 2019-08-14T03:34:23 | 123,885,339 | 2 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 27,768 | cpp | /***************************************************************************
* The following ODBC APIs are implemented in this file: *
* *
* SQLGetInfo (ISO 92) *
* SQLGetFunctions (ISO 92) *
* SQLGetTypeInfo (ISO 92) *
* *
****************************************************************************/
#include "odbc.h"
#include "string.h"
#define MYINFO_SET_ULONG(val) \
{ \
*((SQLUINTEGER*)rgbInfoValue) = val; \
*pcbInfoValue = sizeof(SQLUINTEGER); \
}
#define MYINFO_SET_USHORT(val) \
{ \
*((SQLUSMALLINT*)rgbInfoValue) = val; \
*pcbInfoValue = sizeof(SQLUSMALLINT); \
}
#define MYINFO_SET_STR(rgbInfoValue,cbInfoValueMax,pcbInfoValue,val) \
{ \
*pcbInfoValue=(sb2)strlen(val); \
strncpy1((char*)rgbInfoValue,val,cbInfoValueMax); \
if (*pcbInfoValue >= cbInfoValueMax) \
DBUG_RETURN_STATUS(SQL_SUCCESS_WITH_INFO); \
DBUG_RETURN_STATUS(SQL_SUCCESS); \
}
#define MYINFO_SET_STR_L(rgbInfoValue,cbInfoValueMax,pcbInfoValue,val,len) \
{ \
*pcbInfoValue=len; \
strncpy1((char*)rgbInfoValue,val,cbInfoValueMax); \
if (len >= cbInfoValueMax) \
DBUG_RETURN_STATUS(SQL_SUCCESS_WITH_INFO); \
DBUG_RETURN_STATUS(SQL_SUCCESS); \
}
static bool myodbc_ov2_inited= 0;
/*
@type : ODBC 1.0 API
@purpose : returns general information about the driver and data
source associated with a connection
*/
char allowed_chars[]= {
'\307','\374','\351','\342','\344','\340','\345','\347','\352','\353',
'\350','\357','\356','\354','\304','\305','\311','\346','\306','\364',
'\366','\362','\373','\371','\377','\326','\334','\341','\355','\363',
'\372','\361','\321',0};
#define rhsql_keywords "UNIQUE,ZEROFILL,UNSIGNED,BIGINT,BLOB,TINYBLOB,MEDIMUMBLOB,LONGBLOB,"\
"MEDIUMINT,PROCEDURE,SHOW,LIMIT,DEFAULT,TABLES,REGEXP,RLIKE,KEYS,TINYTEXT,MEDIUMTEXT"
SQLRETURN SQL_API SQLGetInfo(SQLHDBC hdbc,
SQLUSMALLINT fInfoType,
SQLPOINTER rgbInfoValue,
SQLSMALLINT cbInfoValueMax,
SQLSMALLINT FAR *pcbInfoValue)
{
SQLDBC FAR *dbc=(SQLDBC FAR*) hdbc;
char dummy2[255];
SQLSMALLINT dummy;
DBUG_ENTER("SQLGetInfo");
DBUG_PRINT("enter",("fInfoType: %d, cbInfoValueMax :%d",
fInfoType, cbInfoValueMax));
if (cbInfoValueMax)
cbInfoValueMax--;
if (!pcbInfoValue)
pcbInfoValue=&dummy;
if (!rgbInfoValue)
{
rgbInfoValue=dummy2;
cbInfoValueMax=sizeof(dummy2)-1;
}
switch (fInfoType)
{
case SQL_ACTIVE_ENVIRONMENTS:
*((SQLUSMALLINT*) rgbInfoValue)=0;
*pcbInfoValue=sizeof(SQLUSMALLINT);
break;
case SQL_AGGREGATE_FUNCTIONS:
*((SQLUINTEGER*) rgbInfoValue)= (SQL_AF_ALL | SQL_AF_AVG | SQL_AF_COUNT |
SQL_AF_DISTINCT | SQL_AF_MAX |
SQL_AF_MIN | SQL_AF_SUM);
*pcbInfoValue=sizeof(SQLUINTEGER);
break;
case SQL_ALTER_DOMAIN:
*((SQLUINTEGER*) rgbInfoValue)=0;
*pcbInfoValue=sizeof(SQLUINTEGER);
break;
case SQL_ALTER_TABLE:
*((SQLUINTEGER*) rgbInfoValue)= SQL_AT_ADD_COLUMN | SQL_AT_DROP_COLUMN;
*pcbInfoValue=sizeof(SQLUINTEGER);
break;
case SQL_ASYNC_MODE:
*((SQLUINTEGER*) rgbInfoValue)= SQL_AM_NONE;
*pcbInfoValue=sizeof(SQLUINTEGER);
break;
case SQL_BATCH_ROW_COUNT:
*((SQLUINTEGER*) rgbInfoValue)= SQL_BRC_EXPLICIT;
*pcbInfoValue=sizeof(SQLUINTEGER);
break;
case SQL_BATCH_SUPPORT:
*((SQLUINTEGER*) rgbInfoValue)= SQL_BS_ROW_COUNT_EXPLICIT;
*pcbInfoValue=sizeof(SQLUINTEGER);
break;
case SQL_BOOKMARK_PERSISTENCE:
*((SQLUINTEGER*) rgbInfoValue)=0L;
*pcbInfoValue=sizeof(SQLUINTEGER);
break;
case SQL_CATALOG_LOCATION:
*((SQLUSMALLINT*) rgbInfoValue)=SQL_CL_START;
*pcbInfoValue=sizeof(SQLUSMALLINT);
break;
case SQL_CATALOG_NAME:
case SQL_ACCESSIBLE_TABLES:
case SQL_COLUMN_ALIAS:
case SQL_EXPRESSIONS_IN_ORDERBY:
case SQL_LIKE_ESCAPE_CLAUSE:
case SQL_MAX_ROW_SIZE_INCLUDES_LONG:
case SQL_MULT_RESULT_SETS:
case SQL_MULTIPLE_ACTIVE_TXN:
case SQL_OUTER_JOINS:
case SQL_ORDER_BY_COLUMNS_IN_SELECT:
MYINFO_SET_STR_L(rgbInfoValue,cbInfoValueMax,pcbInfoValue,"Y",1);
break;
case SQL_CATALOG_NAME_SEPARATOR:
MYINFO_SET_STR_L(rgbInfoValue,cbInfoValueMax,pcbInfoValue,".",1);
break;
case SQL_CATALOG_TERM:
MYINFO_SET_STR_L(rgbInfoValue,cbInfoValueMax,pcbInfoValue,"database",8);
break;
case SQL_CATALOG_USAGE:
*((SQLUINTEGER*) rgbInfoValue)= (SQL_CU_DML_STATEMENTS |
SQL_CU_TABLE_DEFINITION |
SQL_CU_INDEX_DEFINITION |
SQL_CU_PRIVILEGE_DEFINITION);
*pcbInfoValue=sizeof(SQLUINTEGER);
break;
case SQL_COLLATION_SEQ:
/*
We have to change this to return to the active collation sequence
in the server RhSQL server, as soon as it supports different
collation sequences / user.
*/
MYINFO_SET_STR_L(rgbInfoValue,cbInfoValueMax,pcbInfoValue,"",0);
break;
case SQL_CONCAT_NULL_BEHAVIOR:
*((SQLUSMALLINT*) rgbInfoValue)= SQL_CB_NULL;
*pcbInfoValue=sizeof(SQLUSMALLINT);
break;
case SQL_CONVERT_BIGINT:
case SQL_CONVERT_BIT:
case SQL_CONVERT_CHAR:
case SQL_CONVERT_DATE:
case SQL_CONVERT_DECIMAL:
case SQL_CONVERT_DOUBLE:
case SQL_CONVERT_FLOAT:
case SQL_CONVERT_INTEGER:
case SQL_CONVERT_LONGVARCHAR:
case SQL_CONVERT_NUMERIC:
case SQL_CONVERT_REAL:
case SQL_CONVERT_SMALLINT:
case SQL_CONVERT_TIME:
case SQL_CONVERT_TIMESTAMP:
case SQL_CONVERT_TINYINT:
case SQL_CONVERT_VARCHAR:
case SQL_CONVERT_BINARY:
case SQL_CONVERT_VARBINARY:
case SQL_CONVERT_LONGVARBINARY:
*((SQLUINTEGER*) rgbInfoValue)= (SQL_CVT_CHAR | SQL_CVT_NUMERIC |
SQL_CVT_DECIMAL | SQL_CVT_INTEGER |
SQL_CVT_SMALLINT | SQL_CVT_FLOAT |
SQL_CVT_REAL | SQL_CVT_DOUBLE |
SQL_CVT_VARCHAR | SQL_CVT_LONGVARCHAR |
SQL_CVT_BIT | SQL_CVT_TINYINT |
SQL_CVT_BIGINT | SQL_CVT_DATE |
SQL_CVT_TIME | SQL_CVT_TIMESTAMP|
SQL_CVT_BINARY | SQL_CVT_VARBINARY |SQL_CVT_LONGVARBINARY
);
*pcbInfoValue=sizeof(SQLUINTEGER);
break;
// case SQL_CONVERT_BINARY:
// case SQL_CONVERT_VARBINARY:
// case SQL_CONVERT_LONGVARBINARY:
case SQL_CONVERT_INTERVAL_DAY_TIME:
case SQL_CONVERT_INTERVAL_YEAR_MONTH:
*((SQLUINTEGER*) rgbInfoValue)=0L;
*pcbInfoValue=sizeof(SQLUINTEGER);
break;
/* Non supported options..*/
case SQL_CONVERT_FUNCTIONS:
case SQL_CONVERT_WCHAR:
case SQL_CONVERT_WVARCHAR:
case SQL_CONVERT_WLONGVARCHAR:
case SQL_CREATE_ASSERTION:
case SQL_CREATE_CHARACTER_SET:
case SQL_CREATE_COLLATION:
case SQL_CREATE_DOMAIN:
case SQL_CREATE_TRANSLATION:
case SQL_DROP_ASSERTION:
case SQL_DROP_CHARACTER_SET:
case SQL_DROP_COLLATION:
case SQL_DROP_DOMAIN:
case SQL_DROP_TRANSLATION:
case SQL_KEYSET_CURSOR_ATTRIBUTES1:
case SQL_KEYSET_CURSOR_ATTRIBUTES2:
case SQL_INFO_SCHEMA_VIEWS:
case SQL_SCHEMA_USAGE:
case SQL_DROP_SCHEMA:
case SQL_SQL92_FOREIGN_KEY_DELETE_RULE:
case SQL_SQL92_FOREIGN_KEY_UPDATE_RULE:
case SQL_SQL92_NUMERIC_VALUE_FUNCTIONS:
case SQL_SQL92_PREDICATES:
case SQL_SQL92_VALUE_EXPRESSIONS:
case SQL_SUBQUERIES:
case SQL_TIMEDATE_ADD_INTERVALS:
case SQL_TIMEDATE_DIFF_INTERVALS:
case SQL_UNION:
case SQL_LOCK_TYPES:
*((SQLUINTEGER*) rgbInfoValue)=0L;
*pcbInfoValue=sizeof(SQLUINTEGER);
break;
case SQL_CREATE_VIEW:
*((SQLUINTEGER*) rgbInfoValue)=SQL_CV_CREATE_VIEW|
SQL_CV_CHECK_OPTION|SQL_CV_CASCADED|SQL_CV_LOCAL;
*pcbInfoValue=sizeof(SQLUINTEGER);
break;
case SQL_CREATE_SCHEMA:
*((SQLUINTEGER*) rgbInfoValue)=SQL_CS_CREATE_SCHEMA;
*pcbInfoValue=sizeof(SQLUINTEGER);
break;
case SQL_DROP_VIEW:
*((SQLUINTEGER*) rgbInfoValue)=SQL_DV_DROP_VIEW;
*pcbInfoValue=sizeof(SQLUINTEGER);
break;
/* Un limit, set to default..*/
case SQL_MAX_ASYNC_CONCURRENT_STATEMENTS:
case SQL_MAX_BINARY_LITERAL_LEN:
case SQL_MAX_CHAR_LITERAL_LEN:
case SQL_MAX_DRIVER_CONNECTIONS:
case SQL_MAX_ROW_SIZE:
*((SQLUINTEGER*) rgbInfoValue)=0L;
*pcbInfoValue=sizeof(SQLUINTEGER);
break;
case SQL_MAX_COLUMNS_IN_GROUP_BY:
case SQL_MAX_COLUMNS_IN_ORDER_BY:
case SQL_MAX_COLUMNS_IN_SELECT:
case SQL_MAX_COLUMNS_IN_TABLE:
case SQL_MAX_CONCURRENT_ACTIVITIES:
case SQL_MAX_PROCEDURE_NAME_LEN:
case SQL_MAX_SCHEMA_NAME_LEN:
*((SQLUSMALLINT*) rgbInfoValue)=0L;
*pcbInfoValue=sizeof(SQLUSMALLINT);
break;
case SQL_CORRELATION_NAME:
*((SQLSMALLINT*) rgbInfoValue)= SQL_CN_DIFFERENT;
*pcbInfoValue=sizeof(SQLSMALLINT);
break;
case SQL_CREATE_TABLE:
*((SQLUINTEGER*) rgbInfoValue)= (SQL_CT_CREATE_TABLE |
SQL_CT_COMMIT_DELETE |
SQL_CT_LOCAL_TEMPORARY |
SQL_CT_COLUMN_DEFAULT);
*pcbInfoValue=sizeof(SQLUINTEGER);
break;
case SQL_CURSOR_COMMIT_BEHAVIOR:
case SQL_CURSOR_ROLLBACK_BEHAVIOR:
*((SQLUSMALLINT*) rgbInfoValue)= SQL_CB_PRESERVE; //SQL_CB_CLOSE;//
*pcbInfoValue=sizeof(SQLUSMALLINT);
break;
#ifdef SQL_CURSOR_ROLLBACK_SQL_CURSOR_SENSITIVITY
case SQL_CURSOR_ROLLBACK_SQL_CURSOR_SENSITIVITY:
*((SQLUINTEGER*) rgbInfoValue)= SQL_UNSPECIFIED;
*pcbInfoValue=sizeof(SQLUINTEGER);
break;
#endif
#ifdef SQL_CURSOR_SENSITIVITY
case SQL_CURSOR_SENSITIVITY:
*((SQLUINTEGER*) rgbInfoValue)= SQL_UNSPECIFIED;
*pcbInfoValue=sizeof(SQLUINTEGER);
break;
#endif
case SQL_DATA_SOURCE_NAME:
MYINFO_SET_STR(rgbInfoValue,cbInfoValueMax,pcbInfoValue,dbc->dsn);
break;
case SQL_DATA_SOURCE_READ_ONLY:
case SQL_DESCRIBE_PARAMETER:
case SQL_INTEGRITY:
case SQL_NEED_LONG_DATA_LEN:
case SQL_ROW_UPDATES:
MYINFO_SET_STR_L(rgbInfoValue,cbInfoValueMax,pcbInfoValue,"N",1);
break;
case SQL_ACCESSIBLE_PROCEDURES:
case SQL_PROCEDURES:
MYINFO_SET_STR_L(rgbInfoValue,cbInfoValueMax,pcbInfoValue,"Y",1);
break;
case SQL_DATABASE_NAME:
MYINFO_SET_STR(rgbInfoValue,cbInfoValueMax,pcbInfoValue,dbc->db_name);
break;
case SQL_DATETIME_LITERALS:
*((SQLUINTEGER*) rgbInfoValue)= SQL_DL_SQL92_DATE |
SQL_DL_SQL92_TIME |
SQL_DL_SQL92_TIMESTAMP;
*pcbInfoValue=sizeof(SQLUINTEGER);
break;
case SQL_DBMS_NAME:
MYINFO_SET_STR(rgbInfoValue,cbInfoValueMax,pcbInfoValue,"XuguSQL Server");
break;
case SQL_DBMS_VER:
{
if(dbc->server_version)
{
MYINFO_SET_STR(rgbInfoValue,cbInfoValueMax,pcbInfoValue,dbc->server_version);
}
else
{
MYINFO_SET_STR(rgbInfoValue,cbInfoValueMax,pcbInfoValue,"XuguSQL Server 2.0");
}
break;
}
case SQL_DDL_INDEX:
*((SQLUINTEGER*) rgbInfoValue)= SQL_DI_CREATE_INDEX | SQL_DI_DROP_INDEX;
*pcbInfoValue=sizeof(SQLUINTEGER);
break;
case SQL_DEFAULT_TXN_ISOLATION:
*((SQLUINTEGER*) rgbInfoValue)= DEFAULT_TXN_ISOLATION;
*pcbInfoValue=sizeof(SQLUINTEGER);
break;
case SQL_DRIVER_NAME:
MYINFO_SET_STR(rgbInfoValue,cbInfoValueMax,pcbInfoValue,DRIVER_DLL_NAME);
break;
case SQL_DRIVER_ODBC_VER:
MYINFO_SET_STR(rgbInfoValue,cbInfoValueMax,pcbInfoValue,SQL_SPEC_STRING);
break;
case SQL_DRIVER_VER:
MYINFO_SET_STR(rgbInfoValue,cbInfoValueMax,pcbInfoValue,DRIVER_VERSION);
break;
case SQL_DROP_TABLE:
*((SQLUINTEGER*) rgbInfoValue)= (SQL_DT_DROP_TABLE |
SQL_DT_CASCADE |
SQL_DT_RESTRICT);
*pcbInfoValue=sizeof(SQLUINTEGER);
break;
case SQL_STATIC_CURSOR_ATTRIBUTES1:
*((SQLUINTEGER*) rgbInfoValue) = (SQL_CA1_NEXT |
SQL_CA1_ABSOLUTE |
SQL_CA1_RELATIVE |
SQL_CA1_LOCK_NO_CHANGE |
SQL_CA1_POS_POSITION |
SQL_CA1_POS_UPDATE |
SQL_CA1_POS_DELETE |
SQL_CA1_POS_REFRESH |
SQL_CA1_POSITIONED_UPDATE |
SQL_CA1_POSITIONED_DELETE |
SQL_CA1_BULK_ADD);
*pcbInfoValue=sizeof(SQLUINTEGER);
break;
case SQL_STATIC_CURSOR_ATTRIBUTES2:
*((SQLUINTEGER*) rgbInfoValue) = (SQL_CA2_MAX_ROWS_SELECT |
SQL_CA2_MAX_ROWS_INSERT |
SQL_CA2_MAX_ROWS_DELETE |
SQL_CA2_MAX_ROWS_UPDATE |
SQL_CA2_CRC_EXACT);
*pcbInfoValue=sizeof(SQLUINTEGER);
break;
case SQL_FORWARD_ONLY_CURSOR_ATTRIBUTES1:
*((SQLUINTEGER*) rgbInfoValue) = (SQL_CA1_NEXT |
SQL_CA1_ABSOLUTE |
SQL_CA1_RELATIVE |
SQL_CA1_LOCK_NO_CHANGE |
SQL_CA1_POS_POSITION |
SQL_CA1_POS_UPDATE |
SQL_CA1_POS_DELETE |
SQL_CA1_POS_REFRESH |
SQL_CA1_POSITIONED_UPDATE |
SQL_CA1_POSITIONED_DELETE |
SQL_CA1_BULK_ADD);
if (dbc->flag & FLAG_FORWARD_CURSOR)
*((SQLUINTEGER*) rgbInfoValue) = (SQL_CA1_NEXT);
*pcbInfoValue=sizeof(SQLUINTEGER);
break;
case SQL_FORWARD_ONLY_CURSOR_ATTRIBUTES2:
*((SQLUINTEGER*) rgbInfoValue) = (SQL_CA2_MAX_ROWS_SELECT |
SQL_CA2_MAX_ROWS_INSERT |
SQL_CA2_MAX_ROWS_DELETE |
SQL_CA2_MAX_ROWS_UPDATE |
SQL_CA2_CRC_EXACT);
if (dbc->flag & FLAG_FORWARD_CURSOR)
*((SQLUINTEGER*) rgbInfoValue) &= ~(SQL_CA2_CRC_EXACT);
*pcbInfoValue=sizeof(SQLUINTEGER);
break;
case SQL_DYNAMIC_CURSOR_ATTRIBUTES1:
*((SQLUINTEGER*) rgbInfoValue) = (SQL_CA1_NEXT |
SQL_CA1_ABSOLUTE |
SQL_CA1_RELATIVE |
SQL_CA1_LOCK_NO_CHANGE |
SQL_CA1_POS_POSITION |
SQL_CA1_POS_UPDATE |
SQL_CA1_POS_DELETE |
SQL_CA1_POS_REFRESH |
SQL_CA1_POSITIONED_UPDATE |
SQL_CA1_POSITIONED_DELETE |
SQL_CA1_BULK_ADD);
*pcbInfoValue=sizeof(SQLUINTEGER);
break;
case SQL_DYNAMIC_CURSOR_ATTRIBUTES2:
*((SQLUINTEGER*) rgbInfoValue) = (SQL_CA2_SENSITIVITY_ADDITIONS |
SQL_CA2_SENSITIVITY_DELETIONS |
SQL_CA2_SENSITIVITY_UPDATES |
SQL_CA2_MAX_ROWS_SELECT |
SQL_CA2_MAX_ROWS_INSERT |
SQL_CA2_MAX_ROWS_DELETE |
SQL_CA2_MAX_ROWS_UPDATE |
SQL_CA2_CRC_EXACT |
SQL_CA2_SIMULATE_TRY_UNIQUE);
*pcbInfoValue=sizeof(SQLUINTEGER);
break;
case SQL_FILE_USAGE:
*((SQLUSMALLINT*) rgbInfoValue)=SQL_FILE_NOT_SUPPORTED;
*pcbInfoValue=sizeof(SQLUSMALLINT);
break;
case SQL_GETDATA_EXTENSIONS:
*((SQLUINTEGER*) rgbInfoValue)= (SQL_GD_ANY_COLUMN |
SQL_GD_ANY_ORDER |
SQL_GD_BOUND);
*pcbInfoValue=sizeof(SQLUINTEGER);
break;
case SQL_GROUP_BY:
*((SQLUSMALLINT*) rgbInfoValue)=SQL_GB_NO_RELATION;
*pcbInfoValue=sizeof(SQLUSMALLINT);
break;
case SQL_IDENTIFIER_CASE:
*((SQLUSMALLINT*) rgbInfoValue)= SQL_IC_MIXED;
*pcbInfoValue=sizeof(SQLUSMALLINT);
break;
case SQL_IDENTIFIER_QUOTE_CHAR:
MYINFO_SET_STR(rgbInfoValue,cbInfoValueMax,pcbInfoValue, "\"" );
break;
case SQL_INDEX_KEYWORDS:
*((SQLUINTEGER*) rgbInfoValue)= SQL_IK_NONE;
*pcbInfoValue=sizeof(SQLUINTEGER);
break;
case SQL_INSERT_STATEMENT:
*((SQLUINTEGER*) rgbInfoValue)= (SQL_IS_INSERT_LITERALS |
SQL_IS_INSERT_SEARCHED |
SQL_IS_SELECT_INTO);
*pcbInfoValue=sizeof(SQLUINTEGER);
break;
case SQL_KEYWORDS: /* Need to return all keywords..*/
MYINFO_SET_STR(rgbInfoValue,cbInfoValueMax,pcbInfoValue,rhsql_keywords);
break;
case SQL_MAX_CATALOG_NAME_LEN:
case SQL_MAX_COLUMN_NAME_LEN:
case SQL_MAX_IDENTIFIER_LEN:
case SQL_MAX_TABLE_NAME_LEN:
*((SQLUSMALLINT*) rgbInfoValue)= MAX_NAME_LEN;
*pcbInfoValue=sizeof(SQLUSMALLINT);
break;
case SQL_MAX_COLUMNS_IN_INDEX:
*((SQLUSMALLINT*) rgbInfoValue)=MAX_NAME_LEN;
*pcbInfoValue=sizeof(SQLUSMALLINT);
break;
case SQL_MAX_CURSOR_NAME_LEN:
*((SQLUSMALLINT*) rgbInfoValue)=RHSQL_MAX_CURSOR_LEN;
*pcbInfoValue=sizeof(SQLUSMALLINT);
break;
case SQL_MAX_INDEX_SIZE:
*((SQLUINTEGER*) rgbInfoValue)=500;
*pcbInfoValue=sizeof(SQLUINTEGER);
break;
case SQL_MAX_STATEMENT_LEN:
*((SQLUINTEGER*) rgbInfoValue)=NET_BUFF_LEN;
*pcbInfoValue=sizeof(SQLUINTEGER);
break;
case SQL_MAX_TABLES_IN_SELECT:
/* This is 63 on 64 bit machines */
*((SQLUSMALLINT*) rgbInfoValue)=32;
*pcbInfoValue=sizeof(SQLUSMALLINT);
break;
case SQL_MAX_USER_NAME_LEN:
*((SQLUSMALLINT*) rgbInfoValue)=32;
*pcbInfoValue=sizeof(SQLUSMALLINT);
break;
case SQL_NON_NULLABLE_COLUMNS:
*((SQLUSMALLINT*) rgbInfoValue)=SQL_NNC_NON_NULL;
*pcbInfoValue=sizeof(SQLUSMALLINT);
break;
case SQL_NULL_COLLATION:
*((SQLUSMALLINT*) rgbInfoValue)=SQL_NC_START;
*pcbInfoValue=sizeof(SQLUSMALLINT);
break;
case SQL_NUMERIC_FUNCTIONS:
*((SQLUINTEGER*) rgbInfoValue)=
(SQL_FN_NUM_ABS | SQL_FN_NUM_ACOS | SQL_FN_NUM_ASIN | SQL_FN_NUM_ATAN |
SQL_FN_NUM_ATAN2 | SQL_FN_NUM_CEILING | SQL_FN_NUM_COS |
SQL_FN_NUM_COT | SQL_FN_NUM_EXP | SQL_FN_NUM_FLOOR | SQL_FN_NUM_LOG
| SQL_FN_NUM_MOD | SQL_FN_NUM_SIGN | SQL_FN_NUM_SIN | SQL_FN_NUM_SQRT
| SQL_FN_NUM_TAN | SQL_FN_NUM_PI | SQL_FN_NUM_RAND |
SQL_FN_NUM_DEGREES | SQL_FN_NUM_LOG10 | SQL_FN_NUM_POWER |
SQL_FN_NUM_RADIANS | SQL_FN_NUM_ROUND | SQL_FN_NUM_TRUNCATE);
*pcbInfoValue=sizeof(SQLUINTEGER);
break;
case SQL_ODBC_API_CONFORMANCE:
*((SQLSMALLINT*) rgbInfoValue)=SQL_OAC_LEVEL1;
*pcbInfoValue=sizeof(SQLSMALLINT);
break;
case SQL_ODBC_SQL_CONFORMANCE:
*((SQLSMALLINT*) rgbInfoValue)=SQL_OSC_CORE;
*pcbInfoValue=sizeof(SQLSMALLINT);
break;
case SQL_ODBC_INTERFACE_CONFORMANCE:
*((SQLUINTEGER*) rgbInfoValue)= SQL_OIC_LEVEL1;
*pcbInfoValue=sizeof(SQLUINTEGER);
break;
case SQL_OJ_CAPABILITIES:
*((SQLUINTEGER*) rgbInfoValue)= (SQL_OJ_LEFT | SQL_OJ_NESTED |
SQL_OJ_NOT_ORDERED |
SQL_OJ_INNER | SQL_OJ_ALL_COMPARISON_OPS |SQL_OJ_RIGHT );
*pcbInfoValue=sizeof(SQLUINTEGER);
break;
case SQL_PARAM_ARRAY_ROW_COUNTS:
*((SQLUINTEGER*) rgbInfoValue)= SQL_PARC_NO_BATCH;
*pcbInfoValue=sizeof(SQLUINTEGER);
break;
case SQL_PARAM_ARRAY_SELECTS:
*((SQLUINTEGER*) rgbInfoValue)= SQL_PAS_NO_SELECT;
*pcbInfoValue=sizeof(SQLUINTEGER);
break;
case SQL_PROCEDURE_TERM:
MYINFO_SET_STR_L(rgbInfoValue,cbInfoValueMax,pcbInfoValue,"procedure",0);
break;
case SQL_POS_OPERATIONS:
*((int*) rgbInfoValue)= (SQL_POS_POSITION |
SQL_POS_UPDATE |
SQL_POS_DELETE |
SQL_POS_ADD |
SQL_POS_REFRESH);
if (dbc->flag & FLAG_FORWARD_CURSOR)
*((int*) rgbInfoValue)= 0L;
*pcbInfoValue=sizeof(int);
break;
case SQL_POSITIONED_STATEMENTS:
*((int*) rgbInfoValue)= (SQL_PS_POSITIONED_DELETE |
SQL_PS_POSITIONED_UPDATE);
if (dbc->flag & FLAG_FORWARD_CURSOR)
*((int*) rgbInfoValue)= 0L;
*pcbInfoValue=sizeof(int);
break;
case SQL_QUOTED_IDENTIFIER_CASE:
*((SQLUSMALLINT*) rgbInfoValue)=SQL_IC_SENSITIVE;
*pcbInfoValue=sizeof(SQLUSMALLINT);
break;
case SQL_SCHEMA_TERM:
MYINFO_SET_STR_L(rgbInfoValue,cbInfoValueMax,pcbInfoValue,"schema",0);
break;
case SQL_SCROLL_OPTIONS:
*((SQLUINTEGER*) rgbInfoValue)= (SQL_SO_FORWARD_ONLY | SQL_SO_STATIC | SQL_SO_KEYSET_DRIVEN | SQL_SO_DYNAMIC);
if (dbc->flag & FLAG_FORWARD_CURSOR)
*((SQLUINTEGER*) rgbInfoValue) &= ~(SQL_SO_STATIC);
else if (dbc->flag & FLAG_DYNAMIC_CURSOR)
*((SQLUINTEGER*) rgbInfoValue) |= (SQL_SO_DYNAMIC);
*pcbInfoValue=sizeof(SQLUINTEGER);
break;
case SQL_SCROLL_CONCURRENCY:
*((SQLUINTEGER*) rgbInfoValue)= (SQL_SS_ADDITIONS |
SQL_SS_DELETIONS |
SQL_SS_UPDATES);
*pcbInfoValue=sizeof(SQLUINTEGER);
break;
case SQL_SEARCH_PATTERN_ESCAPE:
MYINFO_SET_STR_L(rgbInfoValue,cbInfoValueMax,pcbInfoValue,"\\",1);
break;
case SQL_SERVER_NAME:
MYINFO_SET_STR(rgbInfoValue,cbInfoValueMax,pcbInfoValue,SERVER_NAME);
break;
case SQL_SPECIAL_CHARACTERS:
MYINFO_SET_STR(rgbInfoValue,cbInfoValueMax,pcbInfoValue,(char *)allowed_chars);
break;
case SQL_SQL_CONFORMANCE:
*((SQLUINTEGER*) rgbInfoValue)= SQL_SC_SQL92_INTERMEDIATE;
*pcbInfoValue=sizeof(SQLUINTEGER);
break;
case SQL_STRING_FUNCTIONS:
*((SQLUINTEGER*) rgbInfoValue)=
(SQL_FN_STR_CONCAT | SQL_FN_STR_INSERT |
SQL_FN_STR_LEFT | SQL_FN_STR_LTRIM | SQL_FN_STR_LENGTH |
SQL_FN_STR_LOCATE | SQL_FN_STR_LCASE | SQL_FN_STR_REPEAT |
SQL_FN_STR_REPLACE | SQL_FN_STR_RIGHT | SQL_FN_STR_RTRIM |
SQL_FN_STR_SUBSTRING | SQL_FN_STR_UCASE | SQL_FN_STR_ASCII |
SQL_FN_STR_CHAR | SQL_FN_STR_LOCATE_2 | SQL_FN_STR_SOUNDEX |
SQL_FN_STR_SPACE);
*pcbInfoValue=sizeof(SQLUINTEGER);
break;
case SQL_TIMEDATE_FUNCTIONS:
*((SQLUINTEGER*) rgbInfoValue)=
(SQL_FN_TD_NOW | SQL_FN_TD_CURDATE | SQL_FN_TD_DAYOFMONTH |
SQL_FN_TD_DAYOFWEEK | SQL_FN_TD_DAYOFYEAR | SQL_FN_TD_MONTH |
SQL_FN_TD_QUARTER | SQL_FN_TD_WEEK | SQL_FN_TD_YEAR |
SQL_FN_TD_CURTIME | SQL_FN_TD_HOUR | SQL_FN_TD_MINUTE |
SQL_FN_TD_SECOND | SQL_FN_TD_DAYNAME | SQL_FN_TD_MONTHNAME);
*pcbInfoValue=sizeof(SQLUINTEGER);
break;
case SQL_SQL92_DATETIME_FUNCTIONS:
*((SQLUINTEGER*) rgbInfoValue)= (SQL_SDF_CURRENT_DATE |
SQL_SDF_CURRENT_TIME |
SQL_SDF_CURRENT_TIMESTAMP);
*pcbInfoValue=sizeof(SQLUINTEGER);
break;
case SQL_SQL92_GRANT:
*((SQLUINTEGER*) rgbInfoValue)= (SQL_SG_DELETE_TABLE |
SQL_SG_INSERT_COLUMN |
SQL_SG_INSERT_TABLE |
SQL_SG_REFERENCES_TABLE |
SQL_SG_REFERENCES_COLUMN |
SQL_SG_SELECT_TABLE |
SQL_SG_UPDATE_COLUMN |
SQL_SG_UPDATE_TABLE);
*pcbInfoValue=sizeof(SQLUINTEGER);
break;
case SQL_SQL92_RELATIONAL_JOIN_OPERATORS:
*((SQLUINTEGER*) rgbInfoValue)= (SQL_SRJO_CROSS_JOIN |
SQL_SRJO_INNER_JOIN |
SQL_SRJO_LEFT_OUTER_JOIN |
SQL_SRJO_NATURAL_JOIN |
SQL_SRJO_RIGHT_OUTER_JOIN);
*pcbInfoValue=sizeof(SQLUINTEGER);
break;
case SQL_SQL92_REVOKE:
*((SQLUINTEGER*) rgbInfoValue)= (SQL_SR_DELETE_TABLE |
SQL_SR_INSERT_COLUMN |
SQL_SR_INSERT_TABLE |
SQL_SR_REFERENCES_TABLE |
SQL_SR_REFERENCES_COLUMN |
SQL_SR_SELECT_TABLE |
SQL_SR_UPDATE_COLUMN |
SQL_SR_UPDATE_TABLE);
*pcbInfoValue=sizeof(SQLUINTEGER);
break;
case SQL_SQL92_ROW_VALUE_CONSTRUCTOR:
*((SQLUINTEGER*) rgbInfoValue)= (SQL_SRVC_VALUE_EXPRESSION |
SQL_SRVC_NULL |
SQL_SRVC_DEFAULT);
*pcbInfoValue=sizeof(SQLUINTEGER);
break;
case SQL_SQL92_STRING_FUNCTIONS:
*((SQLUINTEGER*) rgbInfoValue)= (SQL_SSF_CONVERT |
SQL_SSF_LOWER |
SQL_SSF_UPPER |
SQL_SSF_SUBSTRING |
SQL_SSF_TRANSLATE |
SQL_SSF_TRIM_BOTH |
SQL_SSF_TRIM_LEADING |
SQL_SSF_TRIM_TRAILING);
*pcbInfoValue=sizeof(SQLUINTEGER);
break;
case SQL_STANDARD_CLI_CONFORMANCE:
*((SQLUINTEGER*) rgbInfoValue)= SQL_SCC_ISO92_CLI;
*pcbInfoValue=sizeof(SQLUINTEGER);
break;
case SQL_SYSTEM_FUNCTIONS:
*((SQLUINTEGER*) rgbInfoValue)= (SQL_FN_SYS_DBNAME |
SQL_FN_SYS_IFNULL |
SQL_FN_SYS_USERNAME);
*pcbInfoValue=sizeof(SQLUINTEGER);
break;
case SQL_STATIC_SENSITIVITY:
*((int*) rgbInfoValue)= (SQL_SS_ADDITIONS |
SQL_SS_DELETIONS |
SQL_SS_UPDATES);
*pcbInfoValue=sizeof(int);
break;
case SQL_TABLE_TERM:
MYINFO_SET_STR_L(rgbInfoValue,cbInfoValueMax,pcbInfoValue,"table",5);
break;
case SQL_TXN_CAPABLE:
*((SQLUSMALLINT*) rgbInfoValue)=SQL_TC_DDL_COMMIT;
*pcbInfoValue=sizeof(SQLUSMALLINT);
break;
case SQL_TXN_ISOLATION_OPTION:
*((SQLUINTEGER*) rgbInfoValue)= SQL_TXN_READ_COMMITTED |
SQL_TXN_READ_UNCOMMITTED |
SQL_TXN_REPEATABLE_READ |
SQL_TXN_SERIALIZABLE;
*pcbInfoValue=sizeof(SQLUINTEGER);
break;
case SQL_USER_NAME:
MYINFO_SET_STR(rgbInfoValue,cbInfoValueMax,pcbInfoValue,dbc->p_sess->uname);
break;
case SQL_XOPEN_CLI_YEAR:
MYINFO_SET_STR_L(rgbInfoValue,cbInfoValueMax,pcbInfoValue,"1992",4);
break;
case SQL_FETCH_DIRECTION:
*((long*) rgbInfoValue)=
(SQL_FD_FETCH_NEXT | SQL_FD_FETCH_FIRST |
SQL_FD_FETCH_LAST | SQL_FD_FETCH_PRIOR |
SQL_FD_FETCH_ABSOLUTE | SQL_FD_FETCH_RELATIVE);
if (dbc->flag & FLAG_NO_DEFAULT_CURSOR)
*((long*) rgbInfoValue)&= ~ (long) SQL_FD_FETCH_PRIOR;
if (dbc->flag & FLAG_FORWARD_CURSOR)
*((long*) rgbInfoValue)= (long) SQL_FD_FETCH_NEXT;
*pcbInfoValue=sizeof(long);
break;
case SQL_ODBC_SAG_CLI_CONFORMANCE:
*((SQLSMALLINT*) rgbInfoValue)=SQL_OSCC_COMPLIANT;
*pcbInfoValue=sizeof(SQLSMALLINT);
break;
default:
{
char buff[80];
sprintf(buff,"Unsupported option: %d to SQLGetInfo",fInfoType);
DBUG_RETURN(setError(hdbc,RHERR_S1C00,buff,4000));
}
}/* end of switch */
DBUG_RETURN_STATUS(SQL_SUCCESS);
}
/*
@type : myodbc3 internal
@purpose : function initializaions
*/
/*
@type : myodbc3 internal
@purpose : list of supported and unsupported functions in the driver
*/
int myodbc3_functions[] = {
SQL_API_SQLALLOCCONNECT,
SQL_API_SQLALLOCENV,
SQL_API_SQLALLOCHANDLE,
SQL_API_SQLALLOCSTMT,
SQL_API_SQLBINDCOL,
SQL_API_SQLBINDPARAM, //
SQL_API_SQLCANCEL,
SQL_API_SQLCLOSECURSOR,
SQL_API_SQLCOLATTRIBUTE,
SQL_API_SQLCOLUMNS,
SQL_API_SQLCONNECT,
SQL_API_SQLCOPYDESC, //
SQL_API_SQLDATASOURCES,
SQL_API_SQLDESCRIBECOL,
SQL_API_SQLDISCONNECT,
SQL_API_SQLENDTRAN,
SQL_API_SQLERROR,
SQL_API_SQLEXECDIRECT,
SQL_API_SQLEXECUTE,
SQL_API_SQLFETCH,
SQL_API_SQLFETCHSCROLL,
SQL_API_SQLFREECONNECT,
SQL_API_SQLFREEENV,
SQL_API_SQLFREEHANDLE,
SQL_API_SQLFREESTMT,
SQL_API_SQLGETCONNECTATTR,
SQL_API_SQLGETCONNECTOPTION,
SQL_API_SQLGETCURSORNAME,
SQL_API_SQLGETDATA,
SQL_API_SQLGETDESCFIELD, //
SQL_API_SQLGETDESCREC, //
SQL_API_SQLGETDIAGFIELD,
SQL_API_SQLGETDIAGREC,
SQL_API_SQLGETENVATTR,
SQL_API_SQLGETFUNCTIONS,
SQL_API_SQLGETINFO,
SQL_API_SQLGETSTMTATTR,
SQL_API_SQLGETSTMTOPTION,
SQL_API_SQLGETTYPEINFO,
SQL_API_SQLNUMRESULTCOLS,
SQL_API_SQLPARAMDATA,
SQL_API_SQLPREPARE,
SQL_API_SQLPUTDATA,
SQL_API_SQLROWCOUNT,
SQL_API_SQLSETCONNECTATTR,
SQL_API_SQLSETCONNECTOPTION,
SQL_API_SQLSETCURSORNAME,
SQL_API_SQLSETDESCFIELD, //
SQL_API_SQLSETDESCREC, //
SQL_API_SQLSETENVATTR,
SQL_API_SQLSETPARAM, //
SQL_API_SQLSETSTMTATTR,
SQL_API_SQLSETSTMTOPTION,
SQL_API_SQLSPECIALCOLUMNS,
SQL_API_SQLSTATISTICS,
SQL_API_SQLTABLES,
SQL_API_SQLTRANSACT,
/* SQL_API_SQLALLOCHANDLESTD */
SQL_API_SQLBULKOPERATIONS,
SQL_API_SQLBINDPARAMETER,
SQL_API_SQLBROWSECONNECT,
SQL_API_SQLCOLATTRIBUTES,
SQL_API_SQLCOLUMNPRIVILEGES ,
SQL_API_SQLDESCRIBEPARAM,
SQL_API_SQLDRIVERCONNECT,
SQL_API_SQLDRIVERS,
SQL_API_SQLEXTENDEDFETCH,
SQL_API_SQLFOREIGNKEYS,
SQL_API_SQLMORERESULTS,
SQL_API_SQLNATIVESQL,
SQL_API_SQLNUMPARAMS,
SQL_API_SQLPARAMOPTIONS,
SQL_API_SQLPRIMARYKEYS,
SQL_API_SQLPROCEDURECOLUMNS,
SQL_API_SQLPROCEDURES,
SQL_API_SQLSETPOS,
SQL_API_SQLSETSCROLLOPTIONS,
SQL_API_SQLTABLEPRIVILEGES
};
/*
@type : ODBC 1.0 API
@purpose : returns information about whether a driver supports a specific
ODBC function
*/
SQLRETURN SQL_API SQLGetFunctions(SQLHDBC hdbc,SQLUSMALLINT fFunction,
SQLUSMALLINT FAR *pfExists)
{
SQLDBC FAR *dbc=(SQLDBC FAR*) hdbc;
int index;
int myodbc_func_size;
DBUG_ENTER("SQLGetFunctions");
DBUG_PRINT("enter",("fFunction: %d",fFunction));
myodbc_func_size = (sizeof(myodbc3_functions)/
sizeof(myodbc3_functions[0]));
if (fFunction == SQL_API_ODBC3_ALL_FUNCTIONS)
{
for (index = 0; index < myodbc_func_size; index ++)
{
int id = myodbc3_functions[index];
pfExists[id >> 4] |= (1 << ( id & 0x000F));
}
DBUG_RETURN_STATUS(SQL_SUCCESS);
}
if (fFunction == SQL_API_ALL_FUNCTIONS)
{
for (index = 0; index < myodbc_func_size; index ++)
{
if (myodbc3_functions[index] < 100)
pfExists[myodbc3_functions[index]] = SQL_TRUE;
}
DBUG_RETURN_STATUS(SQL_SUCCESS);
}
*pfExists = SQL_FALSE;
for (index = 0; index < myodbc_func_size; index ++)
{
if (myodbc3_functions[index] == fFunction)
{
*pfExists = SQL_TRUE;
break;
}
}
DBUG_RETURN_STATUS(SQL_SUCCESS);
}
| [
"345207370@qq.com"
] | 345207370@qq.com |
c0ca888b0fc62445e9090f8f4ca9f83e569224a3 | bc7200bd7f1f7d74cdecee5c6efd86d609f3ce9c | /DirectX11Tutorial/GraphicsManager.h | af8af8136f101c28501204ae51bf3935de687f22 | [] | no_license | KashyapRajpal/DirectX11Tutorial | bfd5f81eeab6d04bdd00cd22da8a0a3230c3bfa1 | f512d9dcede0ea16d69cdfbd33a01534e774584f | refs/heads/master | 2021-06-11T04:52:53.327832 | 2017-03-26T17:34:48 | 2017-03-26T17:34:48 | 65,440,199 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 649 | h | #pragma once
// Includes
#include "Defines.h"
#include "D3DManager.h"
#include "Model.h"
#include "Camera.h"
#ifdef USE_TEXTURES
#include "TextureShaderClass.h"
#else
#include "ColorShader.h"
#endif
class GraphicsManager
{
public:
GraphicsManager();
~GraphicsManager();
bool Init(int screenWidth, int screenHeight, HWND pWindowHandle);
void Release();
bool ProcessFrame();
private:
// Memeber functions
bool RenderFrame();
// Member Variables
D3DManager* m_pD3DManager;
Camera* m_pCamera;
Model* m_pModel;
#ifdef USE_TEXTURES
TextureShaderClass* m_pTextureShader;
#else
ColorShader* m_pColorShader;
#endif
};
| [
"kashyapdrajpal@gmail.com"
] | kashyapdrajpal@gmail.com |
ee2fccac3f40d69b6d4eddb06a89f40d2afaaa87 | 9e233ebc24141cf71cc0b6a707deb3a40a50111b | /chapter2/chapter2/chapter2.cpp | ee2e80aca123c8521d3459fdad7f21fa3ec95357 | [] | no_license | CartYuyDgs/C-_Demo | 14dcdc4e81e30895c60c47195203ff78bef03b40 | c76c0a84c6c8a3f41932907847976586b98b1897 | refs/heads/main | 2023-04-16T06:49:02.987617 | 2021-04-21T15:43:50 | 2021-04-21T15:43:50 | 358,796,012 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 535 | cpp | #include <graphics.h>
#include <conio.h>
#include <stdio.h>
int main()
{
int y = 100;
//int step = 50;
float vy = 0;
float g = 5;
initgraph(600, 800);
while (1) {
cleardevice();
vy = vy + g;
y = y + vy;
if (y >= 700) {
vy = -vy*0.95;
}
if (y > 700) {
y = 700;
}
fillcircle(300, y, 10);
if (y >=800 ) {
y = 100;
}
Sleep(100);
}
_getch();
closegraph();
return 0;
}
| [
"yy_dgs@126.com"
] | yy_dgs@126.com |
9f8274fea5549750d18d26cf1f78ae5e74d12b42 | c57819bebe1a3e1d305ae0cb869cdcc48c7181d1 | /src/qt/src/3rdparty/webkit/Source/WebCore/platform/network/NetworkingContext.h | 134394e696ba8f36809811c402d1205dbaeb765c | [
"BSD-3-Clause",
"BSD-2-Clause",
"LGPL-2.1-only",
"LGPL-2.0-only",
"Qt-LGPL-exception-1.1",
"LicenseRef-scancode-generic-exception",
"GPL-3.0-only",
"GPL-1.0-or-later",
"GFDL-1.3-only"
] | permissive | blowery/phantomjs | 255829570e90a28d1cd597192e20314578ef0276 | f929d2b04a29ff6c3c5b47cd08a8f741b1335c72 | refs/heads/master | 2023-04-08T01:22:35.426692 | 2012-10-11T17:43:24 | 2012-10-11T17:43:24 | 6,177,895 | 1 | 0 | BSD-3-Clause | 2023-04-03T23:09:40 | 2012-10-11T17:39:25 | C++ | UTF-8 | C++ | false | false | 2,303 | h | /*
Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
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.
*/
#ifndef NetworkingContext_h
#define NetworkingContext_h
#include <wtf/RefCounted.h>
#if PLATFORM(MAC)
#include "SchedulePair.h"
#endif
#if PLATFORM(QT)
QT_BEGIN_NAMESPACE
class QObject;
class QNetworkAccessManager;
QT_END_NAMESPACE
#endif
namespace WebCore {
#if PLATFORM(ANDROID)
class FrameLoaderClient;
class MainResourceLoader;
#endif
class ResourceError;
class ResourceRequest;
class NetworkingContext : public RefCounted<NetworkingContext> {
public:
virtual ~NetworkingContext() { }
virtual bool isValid() const { return true; }
#if PLATFORM(MAC)
virtual bool needsSiteSpecificQuirks() const = 0;
virtual bool localFileContentSniffingEnabled() const = 0;
virtual SchedulePairHashSet* scheduledRunLoopPairs() const = 0;
virtual ResourceError blockedError(const ResourceRequest&) const = 0;
#endif
#if PLATFORM(QT)
virtual QObject* originatingObject() const = 0;
virtual QNetworkAccessManager* networkAccessManager() const = 0;
virtual bool mimeSniffingEnabled() const = 0;
#endif
#if PLATFORM(WIN)
virtual String userAgent() const = 0;
virtual String referrer() const = 0;
virtual ResourceError blockedError(const ResourceRequest&) const = 0;
#endif
#if PLATFORM(ANDROID)
virtual MainResourceLoader* mainResourceLoader() const = 0;
virtual FrameLoaderClient* frameLoaderClient() const = 0;
#endif
protected:
NetworkingContext() { }
};
}
#endif // NetworkingContext_h
| [
"ariya.hidayat@gmail.com"
] | ariya.hidayat@gmail.com |
6be1f9a8709f78cd2e81e1b845c0930c11ce0fe0 | bc99a708da264c9e8786786bf4f4451515978bec | /test/fsm_parts_test.cpp | 90bb2d009096278de6b1d0297a4c5fa0621abf0f | [
"Artistic-2.0"
] | permissive | zmij/afsm | 1c4c1ce6197fc43f83079e66a581b8451d118f47 | 49181bf52fa2ab8bcea6017d11b3cd321b56c13c | refs/heads/develop | 2021-06-30T12:54:16.141283 | 2020-03-22T15:26:40 | 2020-03-22T15:27:35 | 59,731,854 | 168 | 27 | Artistic-2.0 | 2020-03-22T15:15:59 | 2016-05-26T08:05:45 | C++ | UTF-8 | C++ | false | false | 5,924 | cpp | /*
* fsm_parts_test.cpp
*
* Created on: 29 мая 2016 г.
* Author: sergey.fedorov
*/
#include <gtest/gtest.h>
#include <afsm/fsm.hpp>
namespace afsm {
namespace test {
namespace a {
struct event_a {};
struct event_b {};
struct event_c {};
struct dummy_action {
template < typename FSM, typename SourceState, typename TargetState >
void
operator()(event_a&&, FSM&, SourceState& source, TargetState&) const
{
::std::cerr << "Dummy action triggered (a)\n";
source.value = "a";
}
template < typename FSM, typename SourceState, typename TargetState >
void
operator()(event_b&&, FSM&, SourceState& source, TargetState&) const
{
::std::cerr << "Dummy action triggered (b)\n";
source.value = "b";
}
template < typename FSM, typename SourceState, typename TargetState >
void
operator()(event_c&&, FSM&, SourceState& source, TargetState&) const
{
::std::cerr << "Dummy action triggered (c)\n";
source.value = "c";
}
};
struct dummy_action_a {
template < typename FSM, typename SourceState, typename TargetState >
void
operator()(event_a const&, FSM&, SourceState& source, TargetState&) const
{
::std::cerr << "Dummy action 2 triggered (a)\n";
source.value = "dummy";
}
};
struct a_guard {
template <typename FSM, typename State, typename Event>
bool
operator()(FSM const&, State const&, Event const&) const
{ return true; }
};
struct internal_transitions_test : def::state< internal_transitions_test > {
::std::string value = "none";
using internal_transitions = transition_table <
in< event_a, dummy_action, a_guard >,
in< event_a, dummy_action_a, not_< a_guard > >,
in< event_b, dummy_action, none >,
in< event_c, dummy_action, none >,
in< event_c, dummy_action, none >
>;
};
struct test_state : state<internal_transitions_test, none> {
using base_state = state<internal_transitions_test, none>;
using base_state::process_event;
test_state(enclosing_fsm_type& fsm) : base_state{fsm} {}
};
TEST(FSM, InnerStateTransitions)
{
none n;
test_state ts{n};
EXPECT_EQ("none", ts.value);
EXPECT_EQ(actions::event_process_result::process_in_state, ts.process_event(event_a{}));
EXPECT_EQ("a", ts.value);
EXPECT_EQ(actions::event_process_result::process_in_state, ts.process_event(event_b{}));
EXPECT_EQ("b", ts.value);
EXPECT_EQ(actions::event_process_result::process_in_state, ts.process_event(event_c{}));
EXPECT_EQ("c", ts.value);
}
} /* namespace a */
namespace b {
struct event_ab {};
struct event_bca {};
struct inner_event {};
struct is_none {
template < typename FSM, typename State >
bool
operator()(FSM const& fsm, State const&)
{
return fsm.value == "none";
}
};
struct dummy_sm : detail::null_observer {
};
struct inner_dispatch_test : def::state_machine< inner_dispatch_test > {
struct state_a;
struct state_b;
struct state_c;
struct inner_action {
template < typename FSM >
void
operator()(inner_event const&, FSM& fsm, state_a&, state_a&) const
{
::std::cerr << "Dummy action triggered (inner_event - a)\n";
fsm.value = "in_a";
}
template < typename FSM >
void
operator()(inner_event const&, FSM& fsm, state_b&, state_b&) const
{
::std::cerr << "Dummy action triggered (inner_event - b)\n";
fsm.value = "in_b";
}
template < typename FSM >
void
operator()(inner_event const&, FSM& fsm, state_c&, state_c&) const
{
::std::cerr << "Dummy action triggered (inner_event - c)\n";
fsm.value = "in_c";
}
};
struct state_a : state< state_a > {
using internal_transitions = def::transition_table <
in< inner_event, inner_action, none >
>;
};
struct state_b : state< state_b > {
using internal_transitions = def::transition_table <
in< inner_event, inner_action, none >
>;
};
struct state_c : state< state_c > {
using internal_transitions = def::transition_table <
in< inner_event, inner_action, none >
>;
};
using transitions = transition_table <
tr< state_a, event_ab, state_b, none, none >,
tr< state_b, event_bca, state_c, none, is_none >,
tr< state_b, event_bca, state_a, none, not_<is_none> >
>;
using initial_state = state_a;
::std::string value = "none";
};
struct test_sm : inner_state_machine< inner_dispatch_test, dummy_sm > {
using base_state = inner_state_machine<inner_dispatch_test, dummy_sm>;
using base_state::process_event;
test_sm(enclosing_fsm_type& fsm) : base_state{fsm} {}
};
dummy_sm&
root_machine(dummy_sm& sm)
{
return sm;
}
dummy_sm const&
root_machine(dummy_sm const& sm)
{
return sm;
}
TEST(FSM, InnerEventDispatch)
{
dummy_sm n;
test_sm tsm{n};
EXPECT_EQ("none", tsm.value);
EXPECT_EQ(test_sm::initial_state_index, tsm.current_state());
EXPECT_EQ(actions::event_process_result::process_in_state, tsm.process_event(inner_event{}));
EXPECT_EQ("in_a", tsm.value);
EXPECT_EQ(actions::event_process_result::process, tsm.process_event(event_ab{}));
EXPECT_NE(test_sm::initial_state_index, tsm.current_state());
EXPECT_EQ(actions::event_process_result::process_in_state, tsm.process_event(inner_event{}));
EXPECT_EQ("in_b", tsm.value);
EXPECT_EQ(actions::event_process_result::process, tsm.process_event(event_bca{}));
EXPECT_EQ(actions::event_process_result::process_in_state, tsm.process_event(inner_event{}));
}
} /* namespace b */
} /* namespace test */
} /* namespace afsm */
| [
"sergei.a.fedorov@gmail.com"
] | sergei.a.fedorov@gmail.com |
d05a44baa072e9d3e1c25bea726c87f807fade52 | 9e2053838b71de624cbb54506b409c95a4bc1596 | /src/SDKMethodImpl.cxx | 1850d4a9d8e6aaafb439a2df27377472bd16786c | [] | no_license | tsuibin/weibo-sdk | 5abed2b0791574d4ad53fa2b42fb341439f535fe | 1a1b0cef073e9a544ff84c59c4e89d268b368220 | refs/heads/master | 2016-09-05T23:06:46.132474 | 2014-06-14T09:32:16 | 2014-06-14T09:32:16 | 20,710,905 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 4,816 | cxx | #include "config.h"
#include <stdio.h>
//#include <boost/make_shared.hpp>
#include "SDKMethodImpl.hxx"
#include "SDKHelper.hxx"
#include "SDKManager.hxx"
using namespace weibo;
#ifdef LOG_SUPPORT
# define DEFAULT_SUBSYSTEM "WeiboSDKV4"
# include <util/log/Logger.hxx>
#else
# define CerrLog(args_)
# define StackLog(args_)
# define DebugLog(args_)
# define InfoLog(args_)
# define WarningLog(args_)
# define ErrLog(args_)
# define CritLog(args_)
#endif
SDKMethodImpl::SDKMethodImpl(SDKManager *manager)
: mManager(manager)
, mUnfiedFormat(WRF_JSON)
{
}
eWeiboResultCode SDKMethodImpl::oauth2(const char* userName, const char* password, UserTaskInfo* pTask)
{
std::string param;
if (Util::StringUtil::NullOrEmpty(userName))
{
return WRC_USERID_NULL;
}
if (Util::StringUtil::NullOrEmpty(password))
{
return WRC_PASSWORD_NULL;
}
SDKHelper::setParam(param, "&username", userName, PARAM_ENCODE_UTF8);
SDKHelper::setParam(param, "&password", password, PARAM_ENCODE_UTF8);
SDKHelper::setParam(param, "&client_id", mConsumerkey.c_str(), PARAM_ENCODE_UTF8);
SDKHelper::setParam(param, "&client_secret", mConsumersecret.c_str(), PARAM_ENCODE_UTF8);
SDKHelper::setParam(param, "&grant_type", "password", PARAM_ENCODE_UTF8);
WeiboRequestPtr requestPtr;
requestPtr.reset(new WeiboRequest());
if (requestPtr)
{
requestPtr->mHttpMethod = httpengine::HM_POST;
requestPtr->mOptionId = WBOPT_OAUTH2_ACCESS_TOKEN;
requestPtr->mURL = "https://api.weibo.com/oauth2/access_token";
requestPtr->mPostArg = param;
if (pTask)
{
memcpy(&(requestPtr->mTaskInfo), pTask, sizeof(UserTaskInfo));
}
return internalEnqueue(requestPtr);
}
return WRC_INTERNAL_ERROR;
}
weibo::eWeiboResultCode SDKMethodImpl::oauth2Code(const char* code, const char* url, UserTaskInfo* pTask)
{
std::string param;
if (Util::StringUtil::NullOrEmpty(code))
{
return WRC_USERID_NULL;
}
SDKHelper::setParam(param, "&client_id", mConsumerkey.c_str(), PARAM_ENCODE_UTF8);
SDKHelper::setParam(param, "&client_secret", mConsumersecret.c_str(), PARAM_ENCODE_UTF8);
SDKHelper::setParam(param, "&code", code, PARAM_ENCODE_UTF8);
SDKHelper::setParam(param, "&redirect_uri", url, PARAM_ENCODE_UTF8);
SDKHelper::setParam(param, "&grant_type", "authorization_code", PARAM_ENCODE_UTF8);
WeiboRequestPtr requestPtr;
requestPtr.reset(new WeiboRequest());
if (requestPtr)
{
requestPtr->mHttpMethod = httpengine::HM_POST;
requestPtr->mOptionId = WBOPT_OAUTH2_ACCESS_TOKEN;
requestPtr->mURL = "https://api.weibo.com/oauth2/access_token";
requestPtr->mPostArg = param;
if (pTask)
{
memcpy(&(requestPtr->mTaskInfo), pTask, sizeof(UserTaskInfo));
}
return internalEnqueue(requestPtr);
}
return WRC_INTERNAL_ERROR;
}
eWeiboResultCode SDKMethodImpl::endSession()
{
std::string param;
SDKHelper::setParam(param, "&source", mConsumerkey.c_str(), PARAM_ENCODE_UTF8);
WeiboRequestPtr requestPtr;
requestPtr.reset(new WeiboRequest());
if (requestPtr)
{
requestPtr->mHttpMethod = httpengine::HM_POST;
requestPtr->mOptionId = WBOPT_END_SESSION;
requestPtr->mURL = "http://api.weibo.com/account/end_session";
requestPtr->mPostArg = param;
return internalEnqueue(requestPtr);
}
return WRC_INTERNAL_ERROR;
}
WeiboRequestPtr SDKMethodImpl::internalMakeWeiboRequest(unsigned int methodOption, std::string& addtionParam, const eWeiboRequestFormat reqformat,
const httpengine::HttpMethod method, const UserTaskInfo* pTask)
{
return SDKHelper::makeRequest(methodOption, addtionParam, reqformat,
method, mConsumerkey.c_str(), mAccesstoken.c_str(), pTask);
}
eWeiboResultCode SDKMethodImpl::internalEnqueue(WeiboRequestPtr requestPtr)
{
if (mManager && requestPtr)
{
return mManager->enqueueRequest(requestPtr);
}
return WRC_INTERNAL_ERROR;
}
void SDKMethodImpl::setUnifiedFormat(const eWeiboRequestFormat format)
{
mUnfiedFormat = format;
}
eWeiboRequestFormat SDKMethodImpl::getUnifiedFormat() const
{
return mUnfiedFormat;
}
void SDKMethodImpl::setConsumer(std::string &key, std::string& secret)
{
mConsumerkey = key;
mConsumersecret = secret;
}
void SDKMethodImpl::setAccesstoken(std::string &token)
{
mAccesstoken = token;
}
#include "Inline/Statuses.inl"
#include "Inline/Comment.inl"
#include "Inline/DirectMessage.inl"
#include "Inline/FriendShip.inl"
#include "Inline/Users.inl"
#include "Inline/Favorites.inl"
#include "Inline/Trends.inl"
#include "Inline/Tags.inl"
#include "Inline/Suggestions.inl"
#include "Inline/Account.inl"
#include "Inline/Search.inl"
#include "Inline/ShortURL.inl"
#include "Inline/Unread.inl"
#include "Inline/Groups.inl"
| [
"tsuibin@live.com"
] | tsuibin@live.com |
630e9092bdab8cf1563908242fdf846a34882c44 | 294f98193301c562d3343eaad3925b422b2932a8 | /main.cc | 76738178f27ef236f37aa9a126d96c012c8cc151 | [] | no_license | victusfate/openglExamples | 84b90dffa81644e32cf00c3dfc96e655abba827c | a033c8f616250738fa3a812eb0ab798972033830 | refs/heads/master | 2016-09-05T18:32:27.160034 | 2014-03-19T14:28:14 | 2014-03-19T14:28:14 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 8,847 | cc | #include <GL/glew.h>
#include <GLFW/glfw3.h>
#include <stdlib.h>
#include <stdio.h>
#include <iostream>
#include <vector>
#include <Magick++.h>
using namespace std;
#define GLSL330(src) "#version 330 core\n" #src
void gl_GenTexture(GLuint &id, int width, int height,void *ptr = NULL)
{
glGenTextures(1, &id);
glBindTexture(GL_TEXTURE_2D, id);
// GL_UNSIGNED_BYTE specifier is apparently ignored..
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, width, height, 0, GL_BGRA, GL_UNSIGNED_BYTE, ptr);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glBindTexture(GL_TEXTURE_2D, 0);
glFlush();
glFinish();
}
// glfw3: http://www.glfw.org/
// helper to check and display for shader compiler errors
bool check_shader_compile_status(GLuint obj) {
GLint status;
glGetShaderiv(obj, GL_COMPILE_STATUS, &status);
if(status == GL_FALSE) {
GLint length;
glGetShaderiv(obj, GL_INFO_LOG_LENGTH, &length);
vector<char> log(length);
glGetShaderInfoLog(obj, length, &length, &log[0]);
cerr << &log[0];
return false;
}
return true;
}
// helper to check and display for shader linker error
bool check_program_link_status(GLuint obj) {
GLint status;
glGetProgramiv(obj, GL_LINK_STATUS, &status);
if(status == GL_FALSE) {
GLint length;
glGetProgramiv(obj, GL_INFO_LOG_LENGTH, &length);
vector<char> log(length);
glGetProgramInfoLog(obj, length, &length, &log[0]);
cerr << &log[0];
return false;
}
return true;
}
static void error_callback(int error, const char *msg) {
cerr << "GLWT error " << error << ": " << msg << endl;
}
int main(int argc, char *argv[])
{
if (argc != 2) {
cout << "usage: " << argv[0] << " image " << endl;
exit(1);
}
Magick::InitializeMagick(NULL);
Magick::Image image(argv[1]);
int width = image.baseColumns();
int height = image.baseRows();
vector<unsigned char> imageData(width*height*4);
image.write(0,0,width,height,"BGRA",Magick::CharPixel,(void *)&(imageData[0]));
cout << "got here" << endl;
glfwSetErrorCallback(error_callback);
if(glfwInit() == GL_FALSE) {
cerr << "failed to init GLFW" << endl;
return 1;
}
// GLenum err = glewInit();
// if (GLEW_OK != err)
// {
// // Problem: glewInit failed, something is seriously wrong.
// cout << "Error: " << glewGetErrorString(err) << endl;
// return 1;
// }
// select opengl version
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
// create a window
GLFWwindow *window;
if((window = glfwCreateWindow(width, height, "glfw3", NULL, NULL)) == 0) {
cerr << "failed to open window" << endl;
glfwTerminate();
return 1;
}
glfwMakeContextCurrent(window);
// start GLEW extension handler
glewExperimental = GL_TRUE;
glewInit();
// safe to make gl calls
// get version info
cout << "Renderer: " << glGetString(GL_RENDERER) << endl;
cout << "OpenGL version: " << glGetString(GL_VERSION) << endl;
cout << "shader lang: " << glGetString(GL_SHADING_LANGUAGE_VERSION) << endl;
GLuint texID;
gl_GenTexture(texID,width,height,(void *)&(imageData[0]));
// shader source code
string vertex_source = GLSL330(
layout(location = 0) in vec4 vposition;
out vec2 VertTexCoord;
void main() {
VertTexCoord.x = 0.5 * ( vposition.x + 1.0);
VertTexCoord.y = 0.5 * (-vposition.y + 1.0);
gl_Position = vposition;
}
);
string fragment_source = GLSL330(
in vec2 VertTexCoord;
layout(location = 0) out vec4 outColor;
uniform sampler2D Diffuse;
void main() {
outColor = texture(Diffuse, VertTexCoord);
}
);
// program and shader handles
GLuint shader_program, vertex_shader, fragment_shader, UniformDiffuse;
// we need these to properly pass the strings
const char *source;
int length;
// create and compiler vertex shader
vertex_shader = glCreateShader(GL_VERTEX_SHADER);
source = vertex_source.c_str();
length = vertex_source.size();
glShaderSource(vertex_shader, 1, &source, &length);
glCompileShader(vertex_shader);
GLint success = 0;
glGetShaderiv(vertex_shader, GL_COMPILE_STATUS, &success);
if(success == GL_FALSE) {
cout << "vertex shader busted messelaneous" << endl;
glfwDestroyWindow(window);
glfwTerminate();
return 1;
}
// create and compiler fragment shader
fragment_shader = glCreateShader(GL_FRAGMENT_SHADER);
source = fragment_source.c_str();
length = fragment_source.size();
glShaderSource(fragment_shader, 1, &source, &length);
glCompileShader(fragment_shader);
success = 0;
glGetShaderiv(fragment_shader, GL_COMPILE_STATUS, &success);
if(success == GL_FALSE) {
cout << "fragment shader busted messelaneous" << endl;
glfwDestroyWindow(window);
glfwTerminate();
return 1;
}
// create program
shader_program = glCreateProgram();
// attach shaders
glAttachShader(shader_program, vertex_shader);
glAttachShader(shader_program, fragment_shader);
glBindAttribLocation(shader_program, 0, "texCoord");
glBindFragDataLocation(shader_program, 0, "color");
// link the program and check for errors
glLinkProgram(shader_program);
//Note the different functions here: glGetProgram* instead of glGetShader*.
GLint isLinked = 0;
glGetProgramiv(shader_program, GL_LINK_STATUS, (int *)&isLinked);
if(isLinked == GL_FALSE) {
cout << "shader linking into program busted messelaneous" << endl;
return 1;
}
UniformDiffuse = glGetUniformLocation(shader_program, "Diffuse");
// vao and vbo handle
GLuint vao, vbo;
// generate and bind the vao
glGenVertexArrays(1, &vao);
glBindVertexArray(vao);
// generate and bind the buffer object
glGenBuffers(1, &vbo);
glBindBuffer(GL_ARRAY_BUFFER, vbo);
// data for a fullscreen quad
GLfloat vertexData[] = {
// X Y Z
-1.0f,-1.0f, 0.0f,
-1.0f, 1.0f, 0.0f,
1.0f, 1.0f, 0.0f,
1.0f, 1.0f, 0.0f,
1.0f,-1.0f, 0.0f,
-1.0f,-1.0f, 0.0f
}; // 2 triangles to cover a rectangle
// fill with data
glBufferData(GL_ARRAY_BUFFER, sizeof(GLfloat)*6*3, vertexData, GL_STATIC_DRAW);
// set up generic attrib pointers, 2 triangles
glEnableVertexAttribArray(0);
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 3*sizeof(GLfloat), (char*)0 + 0*sizeof(GLfloat));
glEnableVertexAttribArray(1);
glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 3*sizeof(GLfloat), (char*)0 + 3*sizeof(GLfloat));
while(!glfwWindowShouldClose(window)) {
glfwPollEvents();
// clear first
glClear(GL_COLOR_BUFFER_BIT);
// use the shader program
glUseProgram(shader_program);
// bind the input texture
glEnable(GL_TEXTURE_2D); //Enable texture
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, texID);
// set uniform sampler for texture input
glUniform1i(UniformDiffuse, 0);
// bind the vao
glBindVertexArray(vao);
// draw
glDrawArrays(GL_TRIANGLES, 0, 6);
// check for errors
GLenum error = glGetError();
if(error != GL_NO_ERROR) {
static int first = 1;
if (first && error == 1280) {
cout << "GL error!" << error << " string " << gluErrorString(error) << endl;
first = 0;
}
if (error != 1280) {
cout << "GL error!" << error << " string " << gluErrorString(error) << endl;
break; // skip invalid enumerant
}
}
// finally swap buffers
glfwSwapBuffers(window);
}
// delete the created objects
glDeleteVertexArrays(1, &vao);
glDeleteBuffers(1, &vbo);
glDetachShader(shader_program, vertex_shader);
glDetachShader(shader_program, fragment_shader);
glDeleteShader(vertex_shader);
glDeleteShader(fragment_shader);
glDeleteProgram(shader_program);
glfwDestroyWindow(window);
glfwTerminate();
return 0;
}
| [
"messel@gmail.com"
] | messel@gmail.com |
a029af22d1b69133496d924a8ef7908db0e00365 | e3e8138296400d3e4d8f3e221917b5290acbfa5d | /Days/Day9.h | e4a3278b2d3b9470f210631d510d19487e14001b | [] | no_license | Lowlanstre/AoC2020 | b0749452b2bbb7d44b93f44ef05b07bf759394aa | bf88e9f5e5279d2ee7b0fdc3e1735953611a99e0 | refs/heads/master | 2023-02-01T05:34:45.267444 | 2020-12-16T21:57:33 | 2020-12-16T21:57:33 | 319,756,917 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 159 | h | #pragma once
#include <fstream>
#include <iostream>
#include <vector>
#include <algorithm>
#include <deque>
class Day9 {
public:
static void solve();
}; | [
"41010358+Lowlanstre@users.noreply.github.com"
] | 41010358+Lowlanstre@users.noreply.github.com |
826293ec8ef42468d08e5f55eedb2c17b3f54d04 | d447d0b9287caeaf10714bb3c749acf9f8667538 | /cisst/mtsTutorial/cisstLog/main.cpp | 1a7f4e16fc35d2c742980a3380901748a476f190 | [] | no_license | zchen24/tutorial | cbcfc4d461869300ff7fc5c9d66337b7faf336f9 | e323c7b1536915683ef7ad312af99012fec2e66c | refs/heads/master | 2023-08-18T12:14:10.223230 | 2023-08-13T11:55:38 | 2023-08-13T11:55:38 | 122,897,217 | 13 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 562 | cpp | #include <iostream>
int main(int argc, char *argv[])
{
// // log configuration
// cmnLogger::SetMask(CMN_LOG_ALLOW_ALL);
// // get all messages to log file
// cmnLogger::SetMaskDefaultLog(CMN_LOG_ALLOW_ALL);
// cmnLogger::AddChannel(std::cout, CMN_LOG_ALLOW_ERRORS_AND_WARNINGS);
// // specify a higher, more verbose log level for these classes
// cmnLogger::SetMaskClass("sineTask", CMN_LOG_ALLOW_ALL);
// cmnLogger::SetMaskClass("displayTask", CMN_LOG_ALLOW_ALL);
std::cout << "hello cisstLogger" << std::endl;
return 0;
}
| [
"zihan.chen.jhu@gmail.com"
] | zihan.chen.jhu@gmail.com |
5fb4b61e92dc82c3e115efa14067aaeb33b4694c | 9cfb29b7f8022f586f98b8833bd3cb4bfc7d3f84 | /ckrack/xcode/Crack.h | fc67e0116ba8b1191a7519df93ece83aa40c6f88 | [] | no_license | bd/-speriments | a97f2a5e5164884331617d6f28763f13f67a26c1 | 820c20095dd28ab1edc728dd75d3cbff66539f06 | refs/heads/master | 2021-01-01T18:28:25.936061 | 2020-11-28T20:54:54 | 2020-11-28T20:54:54 | 355,564 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 331 | h | #pragma once
#include "cinder/Vector.h"
#include <vector>
class Crack{
public:
Crack();
Crack(ci::Vec2f, ci::Vec2f);
void update();
void draw();
static Crack randomCrack();
static Crack continueCrack(Crack);
static bool out_of_bounds(ci::Vec2f);
ci::Vec2f mStart;
ci::Vec2f mEnd;
}; | [
"bddbbd.b@gmail.com"
] | bddbbd.b@gmail.com |
28d532bde179f1fced3acc70cb99283765f816b0 | 823a71a85999958d32bb15e99f0665544563d7a4 | /27. (J)Mr Lee.cpp | 44de2b90c3d75892242d176f0d0d5e79822b7ca8 | [] | no_license | sahilgoyals1999/Samsung-Coding-Questions | 607b62b18777b51fe6c7e31129819e7f6fdcb610 | 61fd8c66ed4e35127e17fcbd4f9d79a6b287b79f | refs/heads/main | 2023-08-14T01:03:34.109604 | 2021-09-18T07:41:51 | 2021-09-18T07:41:51 | 395,620,151 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,100 | cpp | /*
https://gist.github.com/hunarjain/69dcbda518ee83f772a31a66255e5bed
Mr. Lee has to travel various offices abroad to assist branches of each place.
But he has a problem.
The airfare would be real high as all offices he has to visit are in foreign countries.
He wants to visit every location only one time and return home with the lowest expense.
Help this company-caring man calculate the lowest expense.
Time limit : 1 second (java : 2 seconds)
Input format:
Several test cases can be included in the inputs. T,
the number of cases is given in the first row of the inputs.
After that, the test cases as many as T (T ≤ 30) are given in a row.
N, the number of offices to visit is given on the first row per each test case.
At this moment, No. 1 office is regarded as his company (Departure point).
(1 ≤ N ≤ 12) Airfares are given to move cities in which branches are located from the second row to N number rows.
i.e. jth number of ith row is the airfare to move from ith city to jth city.
If it is impossible to move between two cities, it is given as zero.
Output format:
Output the minimum airfare used to depart from his company,
visit all offices, and then return his company on the first row per each test case.
Input:
2
5
0 14 4 10 20
14 0 7 8 7
4 5 0 7 16
11 7 9 0 2
18 7 17 4 0
5
9 9 2 9 5
6 3 5 1 5
1 8 3 3 3
6 0 9 6 8
6 6 9 4 8
Output:
30
18
*/
#include <iostream>
using namespace std;
int a[111][111], vis[111];
int mincost = 9876;
void solve(int n, int cost, int x) {
int flag = 0;
for (int i = 0; i < n; i++) {
if (vis[i] == 0) {
flag = 1;
break;
}
}
if (!flag) {
mincost = min(mincost, cost + a[x][0]);
return;
}
for (int i = 0; i < n; i++) {
if (vis[i] == 0 && a[x][i] != 0) {
vis[i] = 1;
solve(n, cost + a[x][i], i);
vis[i] = 0;
}
}
}
int main() {
int t;
cin >> t;
while (t--) {
int n;
cin >> n;
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
cin >> a[i][j];
}
}
mincost = 12345;
for (int i = 0; i < n; i++) {
vis[i] = 0;
}
vis[0] = 1;
solve(n, 0, 0);
cout << mincost << endl;
}
} | [
"sahilgoyals1999@users.noreply.github.com"
] | sahilgoyals1999@users.noreply.github.com |
4fd3e19ba8383bf405d502946c4499cc52bf8a17 | 9b4f4ad42b82800c65f12ae507d2eece02935ff6 | /src/Map/TileMapRenderer.cpp | 364d28aaa319814803c0d7c60dc31e892796347a | [] | no_license | github188/SClass | f5ef01247a8bcf98d64c54ee383cad901adf9630 | ca1b7efa6181f78d6f01a6129c81f0a9dd80770b | refs/heads/main | 2023-07-03T01:25:53.067293 | 2021-08-06T18:19:22 | 2021-08-06T18:19:22 | 393,572,232 | 0 | 1 | null | 2021-08-07T03:57:17 | 2021-08-07T03:57:16 | null | UTF-8 | C++ | false | false | 3,187 | cpp | #include "Stdafx.h"
#include "MyMemory.h"
#include "Math/Math.h"
#include "Data/ArrayListInt64.h"
#include "Map/TileMapRenderer.h"
Map::TileMapRenderer::TileMapRenderer(Media::DrawEngine *eng, Map::TileMap *map, Parser::ParserList *parsers)
{
this->eng = eng;
this->map = map;
this->parsers = parsers;
this->lastLevel = -1;
NEW_CLASS(this->lastIds, Data::ArrayListInt64());
NEW_CLASS(this->lastImgs, Data::ArrayList<CachedImage*>());
}
Map::TileMapRenderer::~TileMapRenderer()
{
CachedImage *cimg;
OSInt i = this->lastImgs->GetCount();
while (i-- > 0)
{
cimg = this->lastImgs->GetItem(i);
this->eng->DeleteImage(cimg->img);
MemFree(cimg);
}
DEL_CLASS(this->lastImgs);
DEL_CLASS(this->lastIds);
}
void Map::TileMapRenderer::DrawMap(Media::DrawImage *img, Map::MapView *view)
{
CachedImage *cimg;
Data::ArrayListInt64 *cacheIds;
Data::ArrayList<CachedImage *> *cacheImgs;
Data::ArrayListInt64 *idList;
OSInt i;
OSInt j;
OSInt k;
Media::ImageList *imgList;
NEW_CLASS(idList, Data::ArrayListInt64());
OSInt level = map->GetNearestLevel(view->GetScale());
NEW_CLASS(cacheIds, Data::ArrayListInt64());
NEW_CLASS(cacheImgs, Data::ArrayList<CachedImage*>());
if (this->lastLevel == level)
{
cacheIds->AddRange(this->lastIds);
cacheImgs->AddRange(this->lastImgs);
this->lastIds->Clear();
this->lastImgs->Clear();
}
else
{
j = this->lastImgs->GetCount();
while (j-- > 0)
{
cimg = this->lastImgs->GetItem(j);
this->eng->DeleteImage(cimg->img);
MemFree(cimg);
}
this->lastIds->Clear();
this->lastImgs->Clear();
}
Double bounds[4];
Double lat = view->GetTopLat();
Double lon = view->GetLeftLon();
Double lat2 = view->GetBottomLat();
Double lon2 = view->GetRightLon();
Double scnX;
Double scnY;
map->GetImageIDs(level, lon, lat, lon2, lat2, idList);
i = idList->GetCount();
while (i-- > 0)
{
j = cacheIds->SortedIndexOf(idList->GetItem(i));
if (j >= 0)
{
k = this->lastIds->SortedInsert(cacheIds->RemoveAt(j));
this->lastImgs->Insert(k, cimg = cacheImgs->RemoveAt(j));
view->LatLonToScnXY(cimg->tly, cimg->tlx, &scnX, &scnY);
img->DrawImagePt(cimg->img, Math::Double2Int(scnX), Math::Double2Int(scnY));
}
else
{
imgList = this->map->LoadTileImage(level, idList->GetItem(i), this->parsers, bounds, false);
if (imgList)
{
cimg = MemAlloc(CachedImage, 1);
cimg->tlx = bounds[0];
cimg->tly = bounds[1];
cimg->img = this->eng->ConvImage(imgList->GetImage(0, 0));
view->LatLonToScnXY(cimg->tly, cimg->tlx, &scnX, &scnY);
img->DrawImagePt(cimg->img, Math::Double2Int(scnX), Math::Double2Int(scnY));
DEL_CLASS(imgList);
k = this->lastIds->SortedInsert(idList->GetItem(i));
this->lastImgs->Insert(k, cimg);
}
}
}
DEL_CLASS(idList);
lastLevel = level;
i = cacheImgs->GetCount();
while (i-- > 0)
{
cimg = cacheImgs->GetItem(i);
this->eng->DeleteImage(cimg->img);
MemFree(cimg);
}
DEL_CLASS(cacheIds);
DEL_CLASS(cacheImgs);
}
void Map::TileMapRenderer::SetUpdatedHandler(UpdatedHandler updHdlr, void *userObj)
{
}
| [
"sswroom@yahoo.com"
] | sswroom@yahoo.com |
b68c16e7be2ffd8b781b5ac51645783687685ac7 | 641fa8341d8c436ad24945bcbf8e7d7d1dd7dbb2 | /chrome/browser/ui/signin_view_controller.h | adc7ce5825d65d4b9b83411382ff6e2de40703c2 | [
"BSD-3-Clause"
] | permissive | massnetwork/mass-browser | 7de0dfc541cbac00ffa7308541394bac1e945b76 | 67526da9358734698c067b7775be491423884339 | refs/heads/master | 2022-12-07T09:01:31.027715 | 2017-01-19T14:29:18 | 2017-01-19T14:29:18 | 73,799,690 | 4 | 4 | BSD-3-Clause | 2022-11-26T11:53:23 | 2016-11-15T09:49:29 | null | UTF-8 | C++ | false | false | 1,944 | h | // Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_UI_SIGNIN_VIEW_CONTROLLER_H_
#define CHROME_BROWSER_UI_SIGNIN_VIEW_CONTROLLER_H_
#include "base/macros.h"
#include "chrome/browser/ui/profile_chooser_constants.h"
class Browser;
class SigninViewControllerDelegate;
namespace signin_metrics {
enum class AccessPoint;
}
// Class responsible for showing and hiding the Signin and Sync Confirmation
// tab-modal dialogs.
class SigninViewController {
public:
SigninViewController();
virtual ~SigninViewController();
// Returns true if the signin flow should be shown as tab-modal for |mode|.
static bool ShouldShowModalSigninForMode(profiles::BubbleViewMode mode);
// Shows the signin flow as a tab modal dialog attached to |browser|'s active
// web contents.
// |access_point| indicates the access point used to open the Gaia sign in
// page.
void ShowModalSignin(profiles::BubbleViewMode mode,
Browser* browser,
signin_metrics::AccessPoint access_point);
void ShowModalSyncConfirmationDialog(Browser* browser);
void ShowModalSigninErrorDialog(Browser* browser);
// Closes the tab-modal signin flow previously shown using this
// SigninViewController, if one exists. Does nothing otherwise.
void CloseModalSignin();
// Sets the height of the modal signin dialog.
void SetModalSigninHeight(int height);
// Notifies this object that it's |signin_view_controller_delegate_|
// member has become invalid.
void ResetModalSigninDelegate();
SigninViewControllerDelegate* delegate() {
return signin_view_controller_delegate_;
}
private:
SigninViewControllerDelegate* signin_view_controller_delegate_;
DISALLOW_COPY_AND_ASSIGN(SigninViewController);
};
#endif // CHROME_BROWSER_UI_SIGNIN_VIEW_CONTROLLER_H_
| [
"xElvis89x@gmail.com"
] | xElvis89x@gmail.com |
b30d088d6c727a37aed0de91735997710e1ac397 | 91a882547e393d4c4946a6c2c99186b5f72122dd | /Source/XPSP1/NT/enduser/troubleshoot/msinfo/scopemap.h | 69d536122169f943e4aee5170eafdd52e56783a5 | [] | no_license | IAmAnubhavSaini/cryptoAlgorithm-nt5src | 94f9b46f101b983954ac6e453d0cf8d02aa76fc7 | d9e1cdeec650b9d6d3ce63f9f0abe50dabfaf9e2 | refs/heads/master | 2023-09-02T10:14:14.795579 | 2021-11-20T13:47:06 | 2021-11-20T13:47:06 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 5,170 | h | // ScopeMap.h - Create a map of Scope items.
//
// History: a-jsari 10/7/97 Initial version
//
// Copyright (c) 1998-1999 Microsoft Corporation
#pragma once
#include <afxtempl.h>
#include "DataSrc.h"
#include "ViewObj.h"
#include "Consts.h"
// This hack is required because we may be building in an environment
// which doesn't have a late enough version of rpcndr.h
#if __RPCNDR_H_VERSION__ < 440
#define __RPCNDR_H_VERSION__ 440
#define MIDL_INTERFACE(x) interface
#endif
#ifndef __mmc_h__
#include <mmc.h>
#endif // __mmc_h__
/*
* CScopeItem - an object which can be inserted in a CMapStringToOb which contains
* an HSCOPEITEM
*
* History: a-jsari 12/16/97 Initial version.
*/
class CScopeItem : public CObject {
public:
CScopeItem() {}
CScopeItem(HSCOPEITEM hsiNew) :m_hsiValue(hsiNew) { }
CScopeItem(const CScopeItem &siCopy) :m_hsiValue(siCopy.m_hsiValue) { }
~CScopeItem() {}
const CScopeItem &operator=(const CScopeItem &siCopy)
{
if (&siCopy != this)
SetValue(siCopy.GetValue());
return *this;
}
void SetValue(HSCOPEITEM hsiSet) { m_hsiValue = hsiSet; }
HSCOPEITEM GetValue() const { return m_hsiValue; }
private:
HSCOPEITEM m_hsiValue;
};
/*
* CScopeItemMap - Wrapper function for two cross-mappings of HSCOPEITEM and
* CViewObject pairs.
*
* History: a-jsari 10/7/97 Initial version.
*/
class CScopeItemMap {
public:
CScopeItemMap() :m_mapScopeToView(MapIncrement), m_mapViewToScope(MapIncrement)
{ m_mapScopeToView.InitHashTable(HashSize); m_mapViewToScope.InitHashTable(HashSize); }
~CScopeItemMap() { Clear(); }
CFolder *CategoryFromScope(HSCOPEITEM hsiNode) const;
void InsertRoot(CViewObject *pvoRootData, HSCOPEITEM hsiNode);
void Insert(CViewObject *pvoData, HSCOPEITEM hsiNode);
BOOL ScopeFromView(CViewObject *pvoNode, HSCOPEITEM &hsiNode) const;
BOOL ScopeFromName(const CString &strName, HSCOPEITEM &hsiNode) const;
void Clear();
private:
static const int MapIncrement;
static const int HashSize;
CMap<HSCOPEITEM, HSCOPEITEM &, CViewObject *, CViewObject * &> m_mapScopeToView;
CMap<CViewObject *, CViewObject * &, HSCOPEITEM, HSCOPEITEM &> m_mapViewToScope;
CMapStringToOb m_mapNameToScope;
};
/*
* CategoryFromScope - Return the CDataCategory pointer, given the hsiNode.
* Note: Do not free the resultant pointer.
*
* History: a-jsari 10/7/97
*/
inline CFolder *CScopeItemMap::CategoryFromScope(HSCOPEITEM hsiNode) const
{
CViewObject *pvoData;
if (m_mapScopeToView.Lookup(hsiNode, pvoData) == 0) return NULL;
// Root category.
return pvoData->Category();
}
/*
* Insert - Inserts the pvoData <-> hsiNode pairing into the maps.
*
* History: a-jsari 10/8/97
*/
inline void CScopeItemMap::Insert(CViewObject *pvoData, HSCOPEITEM hsiNode)
{
CString strName;
m_mapScopeToView.SetAt(hsiNode, pvoData);
m_mapViewToScope.SetAt(pvoData, hsiNode);
pvoData->Category()->InternalName(strName);
m_mapNameToScope.SetAt(strName, new CScopeItem(hsiNode));
}
/*
* InsertRoot - Special case insertion for the ROOT node (which always has
* a Cookie of Zero), but which we want to have a legitamate object for
* the Node.
*
* History: a-jsari 10/10/97
*/
inline void CScopeItemMap::InsertRoot(CViewObject *pvoData, HSCOPEITEM hsiNode)
{
CString strValue = cszRootName;
CViewObject *pvoNullCookie = NULL;
m_mapScopeToView.SetAt(hsiNode, pvoData);
// Insert the NULL cookie as the index for the HSCOPEITEM
m_mapViewToScope.SetAt(pvoNullCookie, hsiNode);
m_mapNameToScope.SetAt(strValue, new CScopeItem(hsiNode));
}
/*
* ScopeFromView - Return the HSCOPEITEM pvoNode maps to, in hsiNode.
*
* Return Codes:
* TRUE - Successful completion
* FALSE - pvoNode could not be found in the map.
*
* History: a-jsari 10/8/97
*/
inline BOOL CScopeItemMap::ScopeFromView(CViewObject *pvoNode, HSCOPEITEM &hsiNode) const
{
return m_mapViewToScope.Lookup(pvoNode, hsiNode);
}
/*
* ScopeFromName - Return the scope item
*
* History: a-jsari 12/11/97
*/
inline BOOL CScopeItemMap::ScopeFromName(const CString &strName, HSCOPEITEM &hsiNode) const
{
BOOL fReturn;
CScopeItem *psiNode;
fReturn = m_mapNameToScope.Lookup(strName, (CObject * &)psiNode);
if (fReturn) hsiNode = psiNode->GetValue();
return fReturn;
}
/*
* clear - Remove all map items and free the CViewObject pointers
*
* History: a-jsari 10/7/97
*/
inline void CScopeItemMap::Clear()
{
if (m_mapScopeToView.IsEmpty()) {
ASSERT(m_mapViewToScope.IsEmpty());
return;
}
CViewObject *pvoIterator;
CString strIterator;
CScopeItem *psiIterator;
HSCOPEITEM hsiIterator;
POSITION posCurrent;
posCurrent = m_mapScopeToView.GetStartPosition();
while (posCurrent != NULL) {
m_mapScopeToView.GetNextAssoc(posCurrent, hsiIterator, pvoIterator);
VERIFY(m_mapScopeToView.RemoveKey(hsiIterator));
delete pvoIterator;
}
posCurrent = m_mapNameToScope.GetStartPosition();
while (posCurrent != NULL) {
m_mapNameToScope.GetNextAssoc(posCurrent, strIterator, (CObject * &)psiIterator);
VERIFY(m_mapNameToScope.RemoveKey(strIterator));
delete psiIterator;
}
ASSERT(m_mapScopeToView.IsEmpty());
m_mapViewToScope.RemoveAll();
}
| [
"support@cryptoalgo.cf"
] | support@cryptoalgo.cf |
57f1f9e42a0dc088a00c47f0b743c2ac4e326e94 | 6d6f770686212d6bcbcf873f0395fa5308f20ed8 | /OCEAN_SIMULATOR/OCEAN2020FOMmapper/AISStateRepository.h | 3ad120ebc17bd7f29b70352bbf247b92a526781a | [] | no_license | SavvasR1991/Marine_vessel_sim | f5ac18ebf64f26aae2ac0cb2163010bdf8c5f0d4 | 49843482c48df092e36d8a488837cdb045ec952c | refs/heads/main | 2023-06-18T14:51:37.975824 | 2021-07-16T07:06:50 | 2021-07-16T07:06:50 | 307,322,910 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 5,400 | h | /*+*******************************************************************************
#
# Project : OCEAN 2020 (EDA)
#
# Original : 2019/06/25
#
# Copyright (c) 2019 ANTYCIP SIMULATION
#*******************************************************************************-*/
//! \file AISStateRepository.h
//! \brief Contains the DtOCEAN2020FOMAISStateRepository class declaration.
//! \ingroup OCEAN2020FOM_SISOSTD00112015
#pragma once
//Project include
#include "DataTypes/OCEAN2020FOM_SISOSTD00112015Enums.h"
#include "dllExportOCEAN2020FOM_SISOSTD00112015.h"
//VRLINK include
#include <matrix/vlVector.h>
#include <vl/embeddedSystemRepository.h>
#include <vl/globalObjectDesignator.h>
#include <vl/hlaLogicalTime.h>
#include <vl/hlaLogicalTimeInterval.h>
#include <vlpi/entityType.h>
#include <vlpi/entityIdentifier.h>
#include <vlutil/vlString.h>
#include <vector>
namespace OCEAN2020 {
//! Instances of DtOCEAN2020FOMAISStateRepository are used to store state data for
//! EmbeddedSystem.AIS objects.
//! \ingroup OCEAN2020FOM_SISOSTD00112015
class DT_DLL_OCEAN2020FOM_SISOSTD00112015 DtOCEAN2020FOMAISStateRepository : public DtEmbeddedSystemRepository
{
public:
//! Constructor.
DtOCEAN2020FOMAISStateRepository();
//! Destructor.
virtual ~DtOCEAN2020FOMAISStateRepository();
//! Copy Constructor.
DtOCEAN2020FOMAISStateRepository(const DtOCEAN2020FOMAISStateRepository& orig);
//! Assignment Operator.
DtOCEAN2020FOMAISStateRepository& operator=(const DtOCEAN2020FOMAISStateRepository& orig);
//! Return a copy/empty object of the same type as this.
virtual DtStateRepository* clone(bool copy) const;
//! Create a DtOCEAN2020FOMAISStateRepository.
static DtOCEAN2020FOMAISStateRepository* create();
//! Print data to the DtInfo stream
virtual void printData() const;
//! Print data to the specified stream
virtual void printDataToStream(std::ostream& stream) const;
//! Set the ClassType.
virtual void setClassType(const DtString& val);
//! Get the ClassType."
virtual const DtString& classType() const;
//! Set the COG.
virtual void setCOG(DtFloat32 val);
//! Get the COG."
virtual DtFloat32 COG() const;
//! Set the Destination.
virtual void setDestination(const DtString& val);
//! Get the Destination."
virtual const DtString& destination() const;
//! Set the ETA.
virtual void setETA(const DtString& val);
//! Get the ETA."
virtual const DtString& ETA() const;
//! Set the IMO.
virtual void setIMO(DtU32 val);
//! Get the IMO."
virtual DtU32 IMO() const;
//! Set the Latitude.
virtual void setLatitude(DtFloat64 val);
//! Get the Latitude."
virtual DtFloat64 latitude() const;
//! Set the Longitude.
virtual void setLongitude(DtFloat64 val);
//! Get the Longitude."
virtual DtFloat64 longitude() const;
//! Set the MMSI.
virtual void setMMSI(DtU32 val);
//! Get the MMSI."
virtual DtU32 MMSI() const;
//! Set the Name.
virtual void setName(const DtString& val);
//! Get the Name."
virtual const DtString& name() const;
//! Set the NavigationStatus.
virtual void setNavigationStatus(const DtString& val);
//! Get the NavigationStatus."
virtual const DtString& navigationStatus() const;
//! Set the SOG.
virtual void setSOG(DtFloat32 val);
//! Get the SOG."
virtual DtFloat32 SOG() const;
//! Set the TB.
virtual void setTB(DtFloat32 val);
//! Get the TB."
virtual DtFloat32 TB() const;
//! Set the TH.
virtual void setTH(DtFloat32 val);
//! Get the TH."
virtual DtFloat32 TH() const;
//! Set the TurnRate.
virtual void setTurnRate(DtFloat32 val);
//! Get the TurnRate."
virtual DtFloat32 turnRate() const;
//! Set the UTC_s.
virtual void setUTC_s(const DtString& val);
//! Get the UTC_s."
virtual const DtString& UTC_s() const;
//! Set the UTC_TimeStamp.
virtual void setUTC_TimeStamp(const DtString& val);
//! Get the UTC_TimeStamp."
virtual const DtString& UTC_TimeStamp() const;
//! Set the RCS.
virtual void setRCS(const DtString& val);
//! Get the RCS."
virtual const DtString& RCS() const;
//! Set the VesselLength.
virtual void setVesselLength(DtFloat32 val);
//! Get the VesselLength."
virtual DtFloat32 vesselLength() const;
//! Set the VesselWidth.
virtual void setVesselWidth(DtFloat32 val);
//! Get the VesselWidth."
virtual DtFloat32 vesselWidth() const;
//! Set the VesselType.
virtual void setVesselType(const DtString& val);
//! Get the VesselType."
virtual const DtString& vesselType() const;
protected:
DtString myClassType;
DtFloat32 myCOG;
DtString myDestination;
DtString myETA;
DtU32 myIMO;
DtFloat64 myLatitude;
DtFloat64 myLongitude;
DtU32 myMMSI;
DtString myName;
DtString myNavigationStatus;
DtFloat32 mySOG;
DtFloat32 myTB;
DtFloat32 myTH;
DtFloat32 myTurnRate;
DtString myUTC_s;
DtString myUTC_TimeStamp;
DtString myRCS;
DtFloat32 myVesselLength;
DtFloat32 myVesselWidth;
DtString myVesselType;
};
} //end OCEAN2020
| [
"savvasrostantis@hotmail.com"
] | savvasrostantis@hotmail.com |
2f5f88f2a9b10e947c2e0010e30959a745255d24 | a9e308c81c27a80c53c899ce806d6d7b4a9bbbf3 | /engine/xray/sound/sources/sound_object_commands.h | d3d816a0e73e6590a93674431e6d0d646addf9d1 | [] | no_license | NikitaNikson/xray-2_0 | 00d8e78112d7b3d5ec1cb790c90f614dc732f633 | 82b049d2d177aac15e1317cbe281e8c167b8f8d1 | refs/heads/master | 2023-06-25T16:51:26.243019 | 2020-09-29T15:49:23 | 2020-09-29T15:49:23 | 390,966,305 | 1 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,828 | h | ////////////////////////////////////////////////////////////////////////////
// Created : 27.04.2010
// Author : Andrew Kolomiets
// Copyright (C) GSC Game World - 2010
////////////////////////////////////////////////////////////////////////////
#ifndef SOUND_OBJECT_COMMANDS_H_INCLUDED
#define SOUND_OBJECT_COMMANDS_H_INCLUDED
#include <xray/intrusive_spsc_queue.h>
#include <xray/intrusive_mpsc_queue.h>
namespace xray {
namespace sound {
class sound_world;
class sound_object_impl;
struct sound_command :public boost::noncopyable
{
sound_command ( base_allocator_type* a):m_creator(a) {};
virtual ~sound_command ( ) {};
virtual void execute ( ) {};
sound_command* m_next;
base_allocator_type* m_creator;
}; // struct sound_command
struct sound_command_object :public sound_command
{
private:
typedef sound_command super;
public:
sound_command_object ( base_allocator_type* a, sound_object_impl* o ):super(a),m_owner(o){};
virtual void execute ( ) {};
sound_command* m_next;
sound_object_impl* m_owner;
base_allocator_type* m_creator;
}; // struct sound_command
class playback_command : public sound_command_object
{
private:
typedef sound_command_object super;
public:
enum playback_event{ev_play, ev_stop};
playback_command ( base_allocator_type* a, playback_event const& ev, sound_object_impl* o );
virtual void execute ( );
playback_event m_event;
}; // class playback_command
class sound_position_command : public sound_command_object
{
private:
typedef sound_command_object super;
public:
sound_position_command( base_allocator_type* a, float3 const& position, sound_object_impl* o );
virtual void execute ( );
float3 m_position;
}; // class playback_command
struct callback_command : public sound_command_object
{
private:
typedef sound_command_object super;
public:
enum cb_event{ev_unknown, ev_stream_end, ev_buffer_end, ev_buffer_error};
callback_command ( base_allocator_type* a, cb_event const& ev, sound_object_impl* o, void* context );
void execute ( );
cb_event m_event_type;
void* m_context;
}; // struct callback_command
class listener_properties_command : public sound_command
{
private:
typedef sound_command super;
public:
listener_properties_command ( base_allocator_type* a, sound_world& sound_world, float4x4 const& inv_view_matrix );
virtual void execute ( );
sound_world& m_sound_world;
float4x4 m_inv_view_matrix;
}; // class playback_command
typedef intrusive_spsc_queue<sound_command, sound_command, &sound_command::m_next> sound_commands_spsc_type;
typedef intrusive_mpsc_queue<sound_command, sound_command, &sound_command::m_next> sound_commands_mpsc_type;
} // namespace sound
} // namespace xray
#endif // #ifndef SOUND_OBJECT_COMMANDS_H_INCLUDED | [
"loxotron@bk.ru"
] | loxotron@bk.ru |
cc9368c853dc1fe3798855aebc8f4be6e126ea47 | 08b8cf38e1936e8cec27f84af0d3727321cec9c4 | /data/crawl/git/old_hunk_1453.cpp | 93b128a853a6688f3fdb38768a8bbec01d4263bb | [] | no_license | ccdxc/logSurvey | eaf28e9c2d6307140b17986d5c05106d1fd8e943 | 6b80226e1667c1e0760ab39160893ee19b0e9fb1 | refs/heads/master | 2022-01-07T21:31:55.446839 | 2018-04-21T14:12:43 | 2018-04-21T14:12:43 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 392 | cpp | strbuf_addf(&sb, "%s: %.*s", reflog_msg, linelen(state->msg),
state->msg);
update_ref(sb.buf, "HEAD", commit, ptr, 0, UPDATE_REFS_DIE_ON_ERR);
if (state->rebasing) {
FILE *fp = xfopen(am_path(state, "rewritten"), "a");
assert(!is_null_sha1(state->orig_commit));
fprintf(fp, "%s ", sha1_to_hex(state->orig_commit));
fprintf(fp, "%s\n", sha1_to_hex(commit));
fclose(fp);
}
| [
"993273596@qq.com"
] | 993273596@qq.com |
0fbef779276da3bf00e530f517bd65787482bc47 | b7cca28ad91b46aef4ae5f5e34d4b25957886e94 | /School/Support.cpp | 2e65b0dac14fe51e88e070889d75cb67ea12a365 | [] | no_license | U201714643/School | d3b201877520542c43e9ebb253962d3f03ec8a3a | ce60c1a2911904d01b5f8ec18a7c16765b7d560f | refs/heads/master | 2020-08-08T19:23:45.842964 | 2019-10-29T07:53:50 | 2019-10-29T07:53:50 | 213,899,046 | 0 | 1 | null | null | null | null | GB18030 | C++ | false | false | 2,155 | cpp | #include "stdafx.h"
#include "Support.h"
#include "include\mysql.h"
char * MsToTime(char * ms, char * Src) { //转换毫秒单位的时间为分:秒制
int s = atoi(ms) / 1000; //用秒表示
if (s == 0) { //用时过短,可能是某处出错
sprintf_s(Src, 32, "采样错误");
}
else { //s/60得到分钟数,s%60得到秒数
sprintf_s(Src, 32, "%d:%d", s / 60, s % 60);
}
return Src;
}
int PwdCode(char *s1, char *s2) { //用户名+密码编码
int i, j;
long l;
for (l = 0, j = 0; s1[j] != 0; j++) {
for (i = 0; i < 3; i++)
l = l ^ (l << 5); //尽量填满32位
l = l ^ s1[j];
}
for (j = 0; s2[j] != 0; j++) {
for (i = 0; i < 3; i++)
l = l ^ (l << 5);
l = l ^ s2[j];
}
return l;
}
int ValidIP(char * str) //校验IP地址合法性
{
int a, b, c, d;
int ret = TRUE;
ret = sscanf_s(str, "%d.%d.%d.%d", &a, &b, &c, &d);
if (ret == 4 && (a >= 1 && a <= 255) && (b >= 0 && b <= 255) && (c >= 0 && c <= 255) && (d >= 1 && d <= 254))
return TRUE;
else
return FALSE;
}
char * RealChar(char * str) { //转换*、/为×、÷便于显示
char t[EXPLEN] = { 0 };
char * p = str;
while (*p) { //逐个对比并写入新字符串
if (*p == '*') {
strcat_s(t, "×");
}
else if (*p == '/') {
strcat_s(t, "÷");
}
else {
//非×、÷字符保持原样
int length = strlen(t); //字符串t长度
t[length] = *p; //即在字符串末尾添加
t[length + 1] = 0; //防止字符串尾部的0被破坏
}
p++;
}
strcpy_s(str, EXPLEN, t); //因字符串t为局部变量,在返回后会丢失,故复制到字符串str中
return str; //返回复制后的字符串首地址str
}
int IntFormEidt(CEdit * Edit) { //从文本框中获得数字
char buf[128]; //保存字符串形式的数字
Edit->GetWindowTextA(buf, sizeof(buf)); //获得字符串形式的数字
if (strlen(buf) == 0)
return -1; //我们的程序正常情况下无负数
return atoi(buf);
}
int MyRnd(int min, int max) { //生成位于[min,max]之间的整数
int length = max - min + 1; //注意区间长度需要加1
return rand() % length + min; //区间内取数再加上起点即为范围内随机数
} | [
"hhyu1500@vip.qq.com"
] | hhyu1500@vip.qq.com |
6887802693f9c0f51fe142a445764f5a14531b96 | 836d3d8aaaf4abcc59f6a0be1e9678d10877fe22 | /OSSIA/ossia/network/domain/detail/array_domain.hpp | c5f2aa7fe33dddd7b317c859708fad7358fa8c19 | [] | no_license | avilleret/API | c8a3a7eb132fa0a2e89ece976050d46332cc7acb | e585a160a4b6acab305b614791d75dd2c28f5a12 | refs/heads/master | 2020-06-13T20:03:32.779677 | 2016-12-04T00:15:11 | 2016-12-04T00:15:11 | 75,563,833 | 0 | 0 | null | 2016-12-04T20:53:04 | 2016-12-04T20:53:04 | null | UTF-8 | C++ | false | false | 691 | hpp | #pragma once
#include <ossia/network/domain/domain_base.hpp>
namespace ossia
{
namespace net
{
/**
* Applying a domain value by value to arrays
*/
struct tuple_clamp
{
const net::domain_base<std::vector<ossia::value>>& domain;
ossia::value operator()(bounding_mode b, const std::vector<ossia::value>& val) const;
ossia::value operator()(bounding_mode b, std::vector<ossia::value>&& val) const;
// TODO numeric_tuple_clamp that will be used instead
// of the loops in domain_clamp_visitor
};
template<std::size_t N>
struct vec_clamp
{
const net::domain_base<std::array<float, N>>& domain;
ossia::value operator()(bounding_mode b, std::array<float, N> val) const;
};
}
}
| [
"jeanmichael.celerier@gmail.com"
] | jeanmichael.celerier@gmail.com |
e87541ded95144d7a792a6d619312a265e4ccc52 | 5a7d3db1f4dc544d47430dcecf9de5ae2990fe88 | /.emacs.d/undohist/!home!sirogami!programming!compe!AtCoder!JOI!1!g.cc | 62c047a02cbfec86ac2b8225a9e61a092bfe3030 | [] | no_license | sirogamichandayo/emacs_sirogami | d990da25e5b83b23799070b4d1b5c540b12023b9 | c646cfd1c4a69cef2762432ba4492e32c2c025c8 | refs/heads/master | 2023-01-24T12:38:56.308764 | 2020-12-07T10:42:35 | 2020-12-07T10:42:35 | 245,687,325 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 5,526 | cc |
((digest . "84026a817b898e9732b83f964dbf8a6a") (undo-list nil (" std::cout << t << std::endl;
" . 652) ((marker) . -31) ((marker) . -31) ((marker . 652) . -17) ((marker . 652) . -17) ((marker . 652) . -17) ((marker) . -31) (t 24379 27899 203294 93000) nil (558 . 559) nil ("i" . -558) ((marker . 652) . -1) 559 (t 24379 27409 8945 747000) nil (");
" . 603) (" DEBUG(t" . -603) ((marker . 652) . -9) ((marker . 603) . -9) ((marker . 603) . -9) 612 (t 24379 27339 656892 787000) nil (611 . 612) nil (612 . 613) nil (")" . -611) (611 . 612) (")" . -611) (611 . 612) (610 . 612) nil (605 . 610) nil (602 . 605) (t 24379 27233 68602 998000) nil (667 . 669) nil (679 . 680) nil (675 . 679) nil (673 . 675) nil (669 . 673) nil (667 . 669) nil (666 . 667) nil (664 . 666) nil (659 . 664) nil (652 . 654) (" " . 652) (657 . 658) (652 . 653) (" " . 652) ((marker . 652) . -2) (657 . 658) nil (654 . 657) nil (651 . 654) (t 24379 27168 613341 728000) nil (711 . 712) nil (709 . 711) nil (708 . 709) (t 24379 27157 645467 930000) nil (706 . 707) (706 . 707) (nil syntax-table nil 706 . 707) (nil syntax-table (1) 705 . 706) (705 . 706) ("\"" . -705) (nil syntax-table nil 706 . 707) (nil syntax-table (1) 705 . 706) (704 . 706) (t 24379 27154 609502 875000) nil (716 . 717) nil (713 . 715) nil ("4" . -713) ((marker . 652) . -1) ((marker . 721) . -1) ((marker . 721) . -1) 714 nil (713 . 714) nil ("3" . -713) ((marker . 652) . -1) ("5" . -714) ((marker . 652) . -1) 715 nil (711 . 715) nil ("^" . -711) ((marker . 652) . -1) 712 nil (709 . 712) nil (709 . 710) (705 . 708) (" " . 705) ((marker . 652) . -6) ((marker . 713) . -6) ((marker . 713) . -6) (711 . 712) nil ("t" . -711) ((marker . 652) . -1) ((marker . 713) . -1) ((marker . 713) . -1) 712 nil (711 . 712) nil (704 . 711) (" " . 704) ((marker . 652) . -1) 705 nil (704 . 705) nil (702 . 704) nil (698 . 702) nil (697 . 698) nil ("%" . -697) ((marker . 652) . -1) 698 nil (696 . 698) nil (695 . 696) (")" . -695) (695 . 696) nil (")" . -687) ((marker . 652) . -1) ((marker*) . 1) ((marker) . -1) 688 nil (686 . 688) nil (691 . 694) nil ("5" . -691) ((marker . 652) . -1) 692 nil (688 . 692) nil ("?" . -688) ((marker . 652) . -1) ((marker . 689) . -1) ((marker . 689) . -1) (" " . -689) ((marker . 652) . -1) ((marker . 689) . -1) ((marker . 689) . -1) 690 nil (687 . 690) nil (" " . -687) ((marker . 652) . -1) ("t" . -688) ((marker . 652) . -1) 689 nil (687 . 689) nil (685 . 687) nil (683 . 685) nil (682 . 683) nil (680 . 681) (680 . 681) (nil syntax-table nil 693 . 694) (nil syntax-table (1) 679 . 680) (679 . 680) ("\"" . -679) (nil syntax-table nil 693 . 694) (nil syntax-table (1) 679 . 680) (678 . 680) nil (676 . 678) nil (672 . 676) nil ("5" . -672) ((marker . 652) . -1) 673 nil (670 . 673) nil (669 . 670) nil (668 . 669) nil (667 . 668) nil (679 . 680) nil (675 . 679) nil (673 . 675) nil (669 . 673) nil (667 . 669) nil (666 . 667) nil (664 . 666) nil (659 . 664) nil (652 . 654) (" " . 652) (657 . 658) (652 . 653) (" " . 652) ((marker . 652) . -2) (657 . 658) nil (654 . 657) nil (651 . 654) nil (650 . 651) nil (647 . 648) (642 . 648) nil (640 . 641) nil ("4" . -640) ((marker . 652) . -1) 641 nil (640 . 641) nil ("6" . -640) ((marker . 652) . -1) ((marker . 640) . -1) ((marker . 640) . -1) 641 nil (640 . 641) (638 . 641) nil ("[" . -638) ((marker . 652) . -1) ("]" . 639) nil (638 . 640) nil (637 . 639) nil (632 . 637) nil (629 . 632) nil (628 . 629) nil (626 . 628) nil ("5" . -626) ((marker . 652) . -1) ("0" . -627) ((marker . 652) . -1) 628 nil (625 . 628) nil (624 . 625) nil (623 . 624) nil (" " . -622) ((marker . 652) . -1) 623 nil (622 . 623) nil (620 . 621) (615 . 621) nil (613 . 614) (611 . 614) nil (610 . 612) nil (605 . 610) nil (602 . 605) nil (601 . 602) nil (596 . 601) nil (595 . 596) nil (594 . 595) nil (593 . 594) (")" . -593) (593 . 594) nil (591 . 592) nil ("2" . -591) ((marker . 652) . -1) 592 nil (591 . 592) (589 . 592) nil (")" . -582) ((marker . 652) . -1) ((marker*) . 1) ((marker) . -1) 583 nil (581 . 583) nil (585 . 588) nil (583 . 584) (578 . 584) nil (576 . 578) nil (573 . 576) nil (572 . 573) nil (570 . 571) nil (569 . 571) nil (" " . -569) ((marker . 652) . -1) ((marker . 569) . -1) ((marker . 569) . -1) ("=" . -570) ((marker . 652) . -1) ((marker . 569) . -1) ((marker . 569) . -1) (" " . -571) ((marker . 652) . -1) ((marker . 569) . -1) ((marker . 569) . -1) 572 nil (565 . 572) nil (562 . 565) (" " . 562) ((marker . 652) . -2) 564 nil (561 . 564) nil (560 . 561) nil (558 . 559) (555 . 559) nil (553 . 555) nil (548 . 553) nil (546 . 547) nil ("5" . -546) ((marker . 652) . -1) 547 nil (543 . 544) nil ("i" . -543) ((marker . 652) . -1) 544 nil (545 . 547) nil (544 . 545) nil (543 . 544) nil (")" . -543) (543 . 544) (")" . -543) (543 . 544) (542 . 544) nil (539 . 542) nil (536 . 539) (" " . 536) ((marker . 652) . -1) 537 nil (536 . 537) nil (535 . 536) nil (533 . 534) nil ("5" . -533) ((marker . 652) . -1) 534 nil (533 . 534) nil (532 . 534) nil (531 . 532) nil (530 . 531) nil (529 . 530) nil (527 . 529) nil (526 . 527) nil (520 . 526) nil (517 . 520) nil ("
" . 518) (" ll " . -518) ((marker . 652) . -5) ((marker . 739) . -5) 523 nil ("h" . -523) ((marker . 652) . -1) 524 nil (520 . 524) nil (518 . 520) (517 . 520) nil (515 . 516) (" " . 515) (517 . 519) nil (514 . 517) nil (511 . 513) nil (510 . 511) nil (509 . 510) nil (")" . -509) (509 . 510) (")" . -509) (509 . 510) (508 . 510) nil (505 . 508) nil (504 . 505) nil (505 . 506) (" " . 505) (504 . 505) nil (1 . 519) (t . -1)))
| [
"sirogamiemacs@gmail.com"
] | sirogamiemacs@gmail.com |
3797f348b6030ea2709582cb650e83cbc3707d7b | 3ac202a691e298142905bad7c92ce3d5c7c60a0b | /MFCFrame/UserLogin.cpp | 802eecf8d8146c565d54a182c010dbf417cf78e9 | [] | no_license | UESTC-TongzhiGroup/TongzhiClient | 3af112b2d5b42a2d9cbb7eb9ebb4b5a4dfe4b457 | 1f64e9f6f3bd04117143b758963260bc797afc88 | refs/heads/master | 2021-08-19T01:30:34.930219 | 2017-11-24T10:32:14 | 2017-11-24T10:32:14 | 103,965,641 | 1 | 2 | null | null | null | null | UTF-8 | C++ | false | false | 3,154 | cpp | // UserLogin.cpp : 实现文件
//
#include "stdafx.h"
#include "Frame.h"
#include "UserLogin.h"
#include "Config.h"
#define IDC_LOGIN 10000
#define IDC_USERNAME 10001
#define IDC_PASSWORD 10002
// CUserLogin 对话框
IMPLEMENT_DYNAMIC(CUserLogin, CDialogEx)
CUserLogin::CUserLogin(CWnd* pParent)
: CDialogEx(CUserLogin::IDD, pParent)
{
Config::loadLicense();
registerMode = Config::getLicensesMap().empty();
m_SUserName.m_hWnd = NULL;
m_Spassword.m_hWnd = NULL;
m_login.m_hWnd = NULL;
}
CUserLogin::~CUserLogin()
{
}
void CUserLogin::DoDataExchange(CDataExchange* pDX)
{
CDialogEx::DoDataExchange(pDX);
DDX_Control(pDX, IDC_EDIT1, m_Name);
DDX_Control(pDX, IDC_EDIT2, m_Password);
}
BEGIN_MESSAGE_MAP(CUserLogin, CDialogEx)
ON_WM_PAINT()
ON_WM_CREATE()
ON_BN_CLICKED(IDOK, &CUserLogin::OnBnClickedOk)
END_MESSAGE_MAP()
// CUserLogin 消息处理程序
void CUserLogin::OnPaint()
{
CPaintDC dc(this); // device context for painting
CRect rcClient;
GetClientRect(rcClient);
dc.FillSolidRect(rcClient, RGB(240, 248, 251));
}
int CUserLogin::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CDialogEx::OnCreate(lpCreateStruct) == -1)
return -1;
CRect rcClient;
GetClientRect(&rcClient);
if (m_login.m_hWnd == NULL)
{
m_login.CreateEx(_T("多功能智能监控报警软件"), WS_VISIBLE | WS_CHILD, 0, 0, rcClient.Width(), 36, m_hWnd, (HMENU)IDC_LOGIN);
m_login.SetImageForButton(IDB_SIDEBAR_HEAD);
}
if (m_SUserName.m_hWnd == NULL)
{
m_SUserName.CreateEx(_T("用户名"), WS_VISIBLE | WS_CHILD, rcClient.left+60, rcClient.top+76, 60, 20, m_hWnd, (HMENU)IDC_USERNAME);
m_SUserName.SetImageForButton(IDB_BACK);
}
if (m_Spassword.m_hWnd == NULL)
{
m_Spassword.CreateEx(_T("密码"), WS_VISIBLE | WS_CHILD, rcClient.left + 60, rcClient.top + 118, 60, 20, m_hWnd, (HMENU)IDC_PASSWORD);
m_Spassword.SetImageForButton(IDB_BACK);
}
return 0;
}
using namespace StrUtil;
bool CUserLogin::checkLicense(CString usr, CString passwd) {
auto &lmap = Config::getLicensesMap();
string usr_str = CStr2std(usr), passwd_str = CStr2std(passwd);
if (registerMode) {
lmap.insert({ usr_str,passwd_str });
Config::saveLicense();
return true;
}
auto pair = lmap.find(usr_str);
return pair != lmap.end() && passwd_str == pair->second;
}
void CUserLogin::OnBnClickedOk()
{
CString c, b;
m_Name.GetWindowText(c);
m_Password.GetWindowText(b);
if (c.IsEmpty() || b.IsEmpty())
{
MessageBox(_T("用户名或密码不能为空!"),_T("提示"));
return;
}
//TODO:修改登录逻辑
else if(checkLicense(c,b))
{
//MessageBox(_T("登陆成功!"), _T("登陆"));//这句可有可无
}
else
{
MessageBox(_T("用户名或密码不正确!"), _T("提示"));
return;
}
CDialogEx::OnOK();
}
BOOL CUserLogin::OnInitDialog()
{
CDialogEx::OnInitDialog();
if (registerMode){
GetDlgItem(IDOK)->SetWindowText(_T("注册"));
MessageBox(_T("注册说明注册说明注册说明注册说明注册说明注册说明注册说明"), _T("欢迎首次使用"));
}
return TRUE; // return TRUE unless you set the focus to a control
// 异常: OCX 属性页应返回 FALSE
}
| [
"gakongren@gmail.com"
] | gakongren@gmail.com |
b7f236aced4832b045dcac80cba3486ede18344a | 73e03b3a24f1a241c298451a8fa76058b84ac54e | /DataStruct/line_arr/line_arr/Struct_arr.cpp | 2f4e713fae745f5a765973035d7d9430483aed25 | [] | no_license | wenyu332/DataStruct | 695f5dbafffdfdd732ab15fbbdc4901f0eebfd2f | 0fc2fbb6406533bd2a6ba2dbc3688bdbcc297a35 | refs/heads/master | 2021-01-17T20:43:05.551036 | 2016-08-15T00:22:22 | 2016-08-15T00:22:22 | 65,692,198 | 0 | 0 | null | null | null | null | GB18030 | C++ | false | false | 1,995 | cpp |
#include <stdlib.h>
#include <stdio.h>
#include <iostream>
struct Arr{
int *pBase; //存储的是数组第一个元素的地址
int len; //数组所能容纳的最大元素的个数
int cnt; //当前数组有效元素的个数
};
void init_arr(struct Arr *arr,int length);
bool append_arr(struct Arr *arr,int value);
bool insert_arr(struct Arr *pArr,int position,int value);
bool delete_arr();
int get();
bool is_empty(struct Arr *arr);
bool is_full(struct Arr *arr);
void sort_arr();
void show_arr(struct Arr *arr);
void inversion_arr(); //倒置数组
int main(void )
{
struct Arr arr;
init_arr(&arr,6);
show_arr(&arr); //直接传arr也可以
is_empty(&arr);
append_arr(&arr,1);
append_arr(&arr,15);
append_arr(&arr,231);
show_arr(&arr);
insert_arr(&arr,1,88);
show_arr(&arr);
system("pause");
return 0;
}
void init_arr(struct Arr *pArr,int length)
{
pArr->pBase =(int *)malloc(sizeof(int)*length); //arr指向结构体变量的pBase成员变量
if(NULL==pArr->pBase)
{
printf("动态内存分配失败");
exit(-1);
}
else
{
pArr->len=length;
pArr->cnt=0;
}
return ;
}
bool is_empty(struct Arr *pArr)
{
if(0==pArr->cnt)
return true;
else
return false;
}
bool is_full(struct Arr *pArr)
{
if(pArr->cnt==pArr->len)
return true;
else
return false;
}
void show_arr(struct Arr *pArr)
{
if(is_empty(pArr))
{
printf("数组为空");
}
else
{
for(int i=0;i<pArr->cnt;i++)
{
printf("%d",pArr->pBase[i]);
printf("\n");
std::cout<<*(pArr->pBase+1)<<std::endl;
}
}
printf("\n");
}
bool append_arr(struct Arr* pArr,int value)
{
if(is_full(pArr))
{
printf("数组已满");
return false;
}
else
{
pArr->pBase[pArr->cnt]=value;
pArr->cnt++;
return true;
}
}
bool insert_arr(struct Arr *pArr,int position,int value)
{
if(is_full(pArr))
{
printf("数组已满");
return false;
}
else
{
for(int i=pArr->cnt-1;i>=position;i--)
{
pArr->pBase[i+1]=pArr->pBase[i];
}
pArr->pBase[position]=value;
pArr->cnt++;
return true;
}
} | [
"15664655351@163.com"
] | 15664655351@163.com |
fcf45c995e886dee63f7be3a4d4d752269e0140d | a631190c8994f65f99af5d9f6c84bc1da657bdbb | /28twenty-eight/ComputeMatrix.cpp | 91c5ed5752f4c7b378b1908c89a6b3def86fedc2 | [] | no_license | Viredery/CLRS | a482942ea50cf1c1f571d66453beec0d9c16aad1 | 9b3724f0b0ec32e4eae787fd18e0224cfa757df2 | refs/heads/master | 2021-05-04T10:24:00.457941 | 2017-11-07T16:05:40 | 2017-11-07T16:05:40 | 53,512,452 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 2,744 | cpp | #include<iostream>
using namespace std;
const int N = 4; //Define the size of the Matrix
template< typename T >
void Strassen(int n, T A[][N], T B[][N], T C[][N]);
template< typename T >
void Input(int n, T p[][N]);
template< typename T >
void Output(int n, T C[][N]);
int main()
{
//Define three Matrices
int A[N][N],B[N][N],C[N][N];
//对A和B矩阵赋值
Input(N,A);Input(N,B);
//调用Strassen方法实现C=A*B
Strassen(N, A, B, C);
//输出矩阵C中值
Output(N, C);
}
template< typename T >
void MatrixAdd(int n, T A[][N], T B[][N], T C[][N])
{
for(int i = 0; i != n; i++)
for(int j = 0; j != n; j++)
C[i][j] = A[i][j] + B[i][j];
}
template< typename T>
void MatrixMinus(int n, T A[][N], T B[][N], T C[][N])
{
for(int i = 0; i != n; i++)
for(int j = 0; j != n; j++)
C[i][j] = A[i][j] - B[i][j];
}
template< typename T >
void Strassen(int n, T A[][N], T B[][N], T C[][N])
{
if(n == 1)
{
C[0][0] = A[0][0] * B[0][0];
return;
}
T a[N][N],b[N][N],c[N][N],d[N][N];
T e[N][N],f[N][N],g[N][N],h[N][N];
T r[N][N],s[N][N],t[N][N],u[N][N];
T p1[N][N],p2[N][N],p3[N][N],p4[N][N],p5[N][N],p6[N][N],p7[N][N];
T temp1[N][N],temp2[N][N];
for(int i = 0; i != n/2; i++)
for(int j = 0; j != n/2; j++)
{
a[i][j] = A[i][j];
b[i][j] = A[i][j+n/2];
c[i][j] = A[i+n/2][j];
d[i][j] = A[i+n/2][j+n/2];
e[i][j] = B[i][j];
f[i][j] = B[i][j+n/2];
g[i][j] = B[i+n/2][j];
h[i][j] = B[i+n/2][j+n/2];
}
MatrixMinus(n/2,f,h,temp1);
Strassen(n/2,a,temp1,p1);
MatrixAdd(n/2,a,b,temp1);
Strassen(n/2,temp1,h,p2);
MatrixAdd(n/2,p1,p2,s);
MatrixAdd(n/2,c,d,temp1);
Strassen(n/2,temp1,e,p3);
MatrixMinus(n/2,g,e,temp1);
Strassen(n/2,d,temp1,p4);
MatrixAdd(n/2,p3,p4,t);
MatrixAdd(n/2,a,d,temp1);
MatrixAdd(n/2,e,h,temp2);
Strassen(n/2,temp1,temp2,p5);
MatrixMinus(n/2,b,d,temp1);
MatrixAdd(n/2,g,h,temp2);
Strassen(n/2,temp1,temp2,p6);
MatrixAdd(n/2,p5,p4,temp1);
MatrixMinus(n/2,temp1,p2,temp2);
MatrixAdd(n/2,temp2,p6,r);
MatrixMinus(n/2,a,c,temp1);
MatrixAdd(n/2,e,f,temp2);
Strassen(n/2,temp1,temp2,p7);
MatrixAdd(n/2,p5,p1,temp1);
MatrixMinus(n/2,temp1,p3,temp2);
MatrixMinus(n/2,temp2,p7,u);
for(int i = 0; i != n/2; i++)
for(int j = 0; j != n/2; j++)
{
C[i][j] = r[i][j];
C[i][j+n/2] = s[i][j];
C[i+n/2][j] = t[i][j];
C[i+n/2][j+n/2] = u[i][j];
}
}
template< typename T >
void Input(int n, T p[][N])
{
for(int i = 0; i != n; i++)
{
cout<<"Input "<<n<<" elements in line "<<i+1<<" :"<<endl;
for(int j = 0; j != n ; j++)
cin>>p[i][j];
}
}
template< typename T >
void Output(int n, T C[][N])
{
cout<<"The Output Matrix is :"<<endl;
for(int i = 0; i != n; i++)
{
for(int j = 0; j != n ; j++)
cout<<C[i][j]<<" ";
cout<<endl;
}
}
| [
"dyrviredery@hotmail.com"
] | dyrviredery@hotmail.com |
e665d14c90164287db5d74559cbc102b1f9777a4 | 6f91c0a3a160bb68fc1232572c09a0b2af00caae | /src/windows/dx11/BufferDX11.cpp | eefccb644200b689f15f4333b6ba8d813a707e14 | [] | no_license | mrlonelyjtr/forward | fb59c691ea666ad34c25f8705905a889ac7ac687 | c4b64dfb29cfccac6a437f443ec09628dbe735b8 | refs/heads/master | 2021-01-10T06:11:30.015557 | 2016-01-23T06:13:27 | 2016-01-23T06:13:27 | 47,819,395 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 4,556 | cpp |
//--------------------------------------------------------------------------------
#include "BufferDX11.h"
//--------------------------------------------------------------------------------
using namespace forward;
//--------------------------------------------------------------------------------
BufferDX11::BufferDX11()
{
ZeroMemory( &m_DesiredDesc, sizeof( D3D11_BUFFER_DESC ) );
ZeroMemory( &m_ActualDesc, sizeof( D3D11_BUFFER_DESC ) );
}
//--------------------------------------------------------------------------------
BufferDX11::~BufferDX11()
{
}
//--------------------------------------------------------------------------------
D3D11_BUFFER_DESC BufferDX11::GetActualDescription()
{
ZeroMemory( &m_ActualDesc, sizeof( D3D11_BUFFER_DESC ) );
if ( m_pBuffer )
m_pBuffer->GetDesc( &m_ActualDesc );
return( m_ActualDesc );
}
//--------------------------------------------------------------------------------
D3D11_BUFFER_DESC BufferDX11::GetDesiredDescription()
{
return( m_DesiredDesc );
}
//--------------------------------------------------------------------------------
void BufferDX11::SetDesiredDescription( D3D11_BUFFER_DESC desc )
{
m_DesiredDesc = desc;
}
//--------------------------------------------------------------------------------
u32 BufferDX11::GetByteWidth()
{
D3D11_BUFFER_DESC description = GetActualDescription();
return( description.ByteWidth );
}
//--------------------------------------------------------------------------------
D3D11_USAGE BufferDX11::GetUsage()
{
D3D11_BUFFER_DESC description = GetActualDescription();
return( description.Usage );
}
//--------------------------------------------------------------------------------
u32 BufferDX11::GetBindFlags()
{
D3D11_BUFFER_DESC description = GetActualDescription();
return( description.BindFlags );
}
//--------------------------------------------------------------------------------
u32 BufferDX11::GetCPUAccessFlags()
{
D3D11_BUFFER_DESC description = GetActualDescription();
return( description.CPUAccessFlags );
}
//--------------------------------------------------------------------------------
u32 BufferDX11::GetMiscFlags()
{
D3D11_BUFFER_DESC description = GetActualDescription();
return( description.MiscFlags );
}
//--------------------------------------------------------------------------------
u32 BufferDX11::GetStructureByteStride()
{
D3D11_BUFFER_DESC description = GetActualDescription();
return( description.StructureByteStride );
}
//--------------------------------------------------------------------------------
void BufferDX11::SetByteWidth( u32 width )
{
m_DesiredDesc.ByteWidth = width;
}
//--------------------------------------------------------------------------------
void BufferDX11::SetUsage( D3D11_USAGE usage )
{
m_DesiredDesc.Usage = usage;
}
//--------------------------------------------------------------------------------
void BufferDX11::SetBindFlags( u32 flags )
{
m_DesiredDesc.BindFlags = flags;
}
//--------------------------------------------------------------------------------
void BufferDX11::SetCPUAccessFlags( u32 flags )
{
m_DesiredDesc.CPUAccessFlags = flags;
}
//--------------------------------------------------------------------------------
void BufferDX11::SetMiscFlags( u32 flags )
{
m_DesiredDesc.MiscFlags = flags;
}
//--------------------------------------------------------------------------------
void BufferDX11::SetStructureByteStride( u32 stride )
{
m_DesiredDesc.StructureByteStride = stride;
}
//--------------------------------------------------------------------------------
void* BufferDX11::Map()
{
return( 0 );
}
//--------------------------------------------------------------------------------
void BufferDX11::UnMap()
{
}
//--------------------------------------------------------------------------------
ID3D11Resource* BufferDX11::GetResource()
{
return( m_pBuffer.Get() );
}
//--------------------------------------------------------------------------------
u32 BufferDX11::GetEvictionPriority()
{
u32 priority = 0;
if ( m_pBuffer )
priority = m_pBuffer->GetEvictionPriority();
return( priority );
}
//--------------------------------------------------------------------------------
void BufferDX11::SetEvictionPriority( u32 EvictionPriority )
{
if ( m_pBuffer )
m_pBuffer->SetEvictionPriority( EvictionPriority );
}
//-------------------------------------------------------------------------------- | [
"296793179@qq.com"
] | 296793179@qq.com |
6114c8301ed3aef775a9891e1e479c1594ba7da5 | b90f153ab09eb6b29388409de7893cf110007219 | /common/shader.cpp | 32106ed48ba2cdea7011cd28a4a7aca2f275cc0a | [] | no_license | jwoogerd/magical-particles | e4aaeebddbdc6b0fb3c396a097e9e4fdb4fdd55c | 865d9d09ca083320cdd396cde6be8803b1b25d03 | refs/heads/master | 2020-05-31T07:30:36.090247 | 2014-08-06T23:35:33 | 2014-08-06T23:35:33 | 19,400,875 | 0 | 1 | null | null | null | null | UTF-8 | C++ | false | false | 1,914 | cpp | #include "shader.h"
#include <iostream>
#include <fstream>
#include <vector>
Shader::Shader(void) {}
Shader::~Shader(void) {}
// read a file and return as a string
string Shader::readFile(const char* path) {
string content;
ifstream fileStream(path, ios::in);
if (!fileStream.is_open()) {
cerr << "File could not be opened" << endl;
return "";
}
string line = "";
while (!fileStream.eof()) {
getline(fileStream, line);
content.append(line + "\n");
}
fileStream.close();
return content;
}
GLuint Shader::loadShader(const char* vertPath, const char* fragPath) {
//generate shader names
GLuint vertShader = glCreateShader(GL_VERTEX_SHADER);
GLuint fragShader = glCreateShader(GL_FRAGMENT_SHADER);
//get shader src
string vertShaderStr = readFile(vertPath);
string fragShaderStr = readFile(fragPath);
const char* vertShaderSrc = vertShaderStr.c_str();
const char* fragShaderSrc = fragShaderStr.c_str();
GLint result = GL_FALSE;
//compile vertex shader
glShaderSource(vertShader, 1, &vertShaderSrc, NULL);
glCompileShader(vertShader);
char error[1024];
glGetShaderInfoLog(vertShader, 1024, NULL, error);
cout << "Compiler errors: \n" << error << endl;
//compile fragment shader
glShaderSource(fragShader, 1, &fragShaderSrc, NULL);
glCompileShader(fragShader);
glGetShaderInfoLog(fragShader, 1024, NULL, error);
cout << "Compiler errors: \n" << error << endl;
//link the program
GLuint program = glCreateProgram();
glAttachShader(program, vertShader);
glAttachShader(program, fragShader);
glLinkProgram(program);
glGetProgramiv(program, GL_LINK_STATUS, &result);
glGetProgramInfoLog(program, 1024, NULL, error);
cout << error << endl;
glDeleteShader(vertShader);
glDeleteShader(fragShader);
return program;
} | [
"jayme.woogerd@tufts.edu"
] | jayme.woogerd@tufts.edu |
7f9e7caea0588f5f5c2903c4d2ff3e8d0186a188 | 6d7a3bb26053cb180f35c88daf108f5a773ff293 | /wasm_llvm/tools/clang/lib/CodeGen/CodeGenModule.cpp | 43b79cbffba19d62b4dbe2f4d0fd433e329df9a9 | [
"NCSA",
"MIT"
] | permissive | WaykiChain/wicc-wasm-cdt | e4088f0313fbeb1aae7f4631b2735fbd2fc3c0c6 | fcf9edcc9d8abf689c6a2452399735c887185bfa | refs/heads/master | 2021-07-06T15:20:58.417585 | 2020-10-12T01:25:17 | 2020-10-12T01:25:17 | 237,560,833 | 1 | 2 | MIT | 2020-10-12T01:25:19 | 2020-02-01T04:19:53 | C++ | UTF-8 | C++ | false | false | 196,752 | cpp | //===--- CodeGenModule.cpp - Emit LLVM Code from ASTs for a Module --------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This coordinates the per-module state used while generating code.
//
//===----------------------------------------------------------------------===//
#include "CodeGenModule.h"
#include "CGBlocks.h"
#include "CGCUDARuntime.h"
#include "CGCXXABI.h"
#include "CGCall.h"
#include "CGDebugInfo.h"
#include "CGObjCRuntime.h"
#include "CGOpenCLRuntime.h"
#include "CGOpenMPRuntime.h"
#include "CGOpenMPRuntimeNVPTX.h"
#include "CodeGenFunction.h"
#include "CodeGenPGO.h"
#include "ConstantEmitter.h"
#include "CoverageMappingGen.h"
#include "TargetInfo.h"
#include "clang/AST/ASTContext.h"
#include "clang/AST/CharUnits.h"
#include "clang/AST/DeclCXX.h"
#include "clang/AST/DeclObjC.h"
#include "clang/AST/DeclTemplate.h"
#include "clang/AST/Mangle.h"
#include "clang/AST/RecordLayout.h"
#include "clang/AST/RecursiveASTVisitor.h"
#include "clang/Basic/Builtins.h"
#include "clang/Basic/CharInfo.h"
#include "clang/Basic/Diagnostic.h"
#include "clang/Basic/Module.h"
#include "clang/Basic/SourceManager.h"
#include "clang/Basic/TargetInfo.h"
#include "clang/Basic/Version.h"
#include "clang/CodeGen/ConstantInitBuilder.h"
#include "clang/Frontend/CodeGenOptions.h"
#include "clang/Sema/SemaDiagnostic.h"
#include "llvm/ADT/Triple.h"
#include "llvm/Analysis/TargetLibraryInfo.h"
#include "llvm/IR/CallSite.h"
#include "llvm/IR/CallingConv.h"
#include "llvm/IR/DataLayout.h"
#include "llvm/IR/Intrinsics.h"
#include "llvm/IR/LLVMContext.h"
#include "llvm/IR/Module.h"
#include "llvm/ProfileData/InstrProfReader.h"
#include "llvm/Support/ConvertUTF.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/MD5.h"
using namespace clang;
using namespace CodeGen;
static llvm::cl::opt<bool> LimitedCoverage(
"limited-coverage-experimental", llvm::cl::ZeroOrMore, llvm::cl::Hidden,
llvm::cl::desc("Emit limited coverage mapping information (experimental)"),
llvm::cl::init(false));
static const char AnnotationSection[] = "llvm.metadata";
static CGCXXABI *createCXXABI(CodeGenModule &CGM) {
switch (CGM.getTarget().getCXXABI().getKind()) {
case TargetCXXABI::GenericAArch64:
case TargetCXXABI::GenericARM:
case TargetCXXABI::iOS:
case TargetCXXABI::iOS64:
case TargetCXXABI::WatchOS:
case TargetCXXABI::GenericMIPS:
case TargetCXXABI::GenericItanium:
case TargetCXXABI::WebAssembly:
return CreateItaniumCXXABI(CGM);
case TargetCXXABI::Microsoft:
return CreateMicrosoftCXXABI(CGM);
}
llvm_unreachable("invalid C++ ABI kind");
}
CodeGenModule::CodeGenModule(ASTContext &C, const HeaderSearchOptions &HSO,
const PreprocessorOptions &PPO,
const CodeGenOptions &CGO, llvm::Module &M,
DiagnosticsEngine &diags,
CoverageSourceInfo *CoverageInfo)
: Context(C), LangOpts(C.getLangOpts()), HeaderSearchOpts(HSO),
PreprocessorOpts(PPO), CodeGenOpts(CGO), TheModule(M), Diags(diags),
Target(C.getTargetInfo()), ABI(createCXXABI(*this)),
VMContext(M.getContext()), Types(*this), VTables(*this),
SanitizerMD(new SanitizerMetadata(*this)) {
// Initialize the type cache.
llvm::LLVMContext &LLVMContext = M.getContext();
VoidTy = llvm::Type::getVoidTy(LLVMContext);
Int8Ty = llvm::Type::getInt8Ty(LLVMContext);
Int16Ty = llvm::Type::getInt16Ty(LLVMContext);
Int32Ty = llvm::Type::getInt32Ty(LLVMContext);
Int64Ty = llvm::Type::getInt64Ty(LLVMContext);
HalfTy = llvm::Type::getHalfTy(LLVMContext);
FloatTy = llvm::Type::getFloatTy(LLVMContext);
DoubleTy = llvm::Type::getDoubleTy(LLVMContext);
PointerWidthInBits = C.getTargetInfo().getPointerWidth(0);
PointerAlignInBytes =
C.toCharUnitsFromBits(C.getTargetInfo().getPointerAlign(0)).getQuantity();
SizeSizeInBytes =
C.toCharUnitsFromBits(C.getTargetInfo().getMaxPointerWidth()).getQuantity();
IntAlignInBytes =
C.toCharUnitsFromBits(C.getTargetInfo().getIntAlign()).getQuantity();
IntTy = llvm::IntegerType::get(LLVMContext, C.getTargetInfo().getIntWidth());
IntPtrTy = llvm::IntegerType::get(LLVMContext,
C.getTargetInfo().getMaxPointerWidth());
Int8PtrTy = Int8Ty->getPointerTo(0);
Int8PtrPtrTy = Int8PtrTy->getPointerTo(0);
AllocaInt8PtrTy = Int8Ty->getPointerTo(
M.getDataLayout().getAllocaAddrSpace());
ASTAllocaAddressSpace = getTargetCodeGenInfo().getASTAllocaAddressSpace();
RuntimeCC = getTargetCodeGenInfo().getABIInfo().getRuntimeCC();
if (LangOpts.ObjC1)
createObjCRuntime();
if (LangOpts.OpenCL)
createOpenCLRuntime();
if (LangOpts.OpenMP)
createOpenMPRuntime();
if (LangOpts.CUDA)
createCUDARuntime();
// Enable TBAA unless it's suppressed. ThreadSanitizer needs TBAA even at O0.
if (LangOpts.Sanitize.has(SanitizerKind::Thread) ||
(!CodeGenOpts.RelaxedAliasing && CodeGenOpts.OptimizationLevel > 0))
TBAA.reset(new CodeGenTBAA(Context, TheModule, CodeGenOpts, getLangOpts(),
getCXXABI().getMangleContext()));
// If debug info or coverage generation is enabled, create the CGDebugInfo
// object.
if (CodeGenOpts.getDebugInfo() != codegenoptions::NoDebugInfo ||
CodeGenOpts.EmitGcovArcs || CodeGenOpts.EmitGcovNotes)
DebugInfo.reset(new CGDebugInfo(*this));
Block.GlobalUniqueCount = 0;
if (C.getLangOpts().ObjC1)
ObjCData.reset(new ObjCEntrypoints());
if (CodeGenOpts.hasProfileClangUse()) {
auto ReaderOrErr = llvm::IndexedInstrProfReader::create(
CodeGenOpts.ProfileInstrumentUsePath);
if (auto E = ReaderOrErr.takeError()) {
unsigned DiagID = Diags.getCustomDiagID(DiagnosticsEngine::Error,
"Could not read profile %0: %1");
llvm::handleAllErrors(std::move(E), [&](const llvm::ErrorInfoBase &EI) {
getDiags().Report(DiagID) << CodeGenOpts.ProfileInstrumentUsePath
<< EI.message();
});
} else
PGOReader = std::move(ReaderOrErr.get());
}
// If coverage mapping generation is enabled, create the
// CoverageMappingModuleGen object.
if (CodeGenOpts.CoverageMapping)
CoverageMapping.reset(new CoverageMappingModuleGen(*this, *CoverageInfo));
}
CodeGenModule::~CodeGenModule() {}
void CodeGenModule::createObjCRuntime() {
// This is just isGNUFamily(), but we want to force implementors of
// new ABIs to decide how best to do this.
switch (LangOpts.ObjCRuntime.getKind()) {
case ObjCRuntime::GNUstep:
case ObjCRuntime::GCC:
case ObjCRuntime::ObjFW:
ObjCRuntime.reset(CreateGNUObjCRuntime(*this));
return;
case ObjCRuntime::FragileMacOSX:
case ObjCRuntime::MacOSX:
case ObjCRuntime::iOS:
case ObjCRuntime::WatchOS:
ObjCRuntime.reset(CreateMacObjCRuntime(*this));
return;
}
llvm_unreachable("bad runtime kind");
}
void CodeGenModule::createOpenCLRuntime() {
OpenCLRuntime.reset(new CGOpenCLRuntime(*this));
}
void CodeGenModule::createOpenMPRuntime() {
// Select a specialized code generation class based on the target, if any.
// If it does not exist use the default implementation.
switch (getTriple().getArch()) {
case llvm::Triple::nvptx:
case llvm::Triple::nvptx64:
assert(getLangOpts().OpenMPIsDevice &&
"OpenMP NVPTX is only prepared to deal with device code.");
OpenMPRuntime.reset(new CGOpenMPRuntimeNVPTX(*this));
break;
default:
if (LangOpts.OpenMPSimd)
OpenMPRuntime.reset(new CGOpenMPSIMDRuntime(*this));
else
OpenMPRuntime.reset(new CGOpenMPRuntime(*this));
break;
}
}
void CodeGenModule::createCUDARuntime() {
CUDARuntime.reset(CreateNVCUDARuntime(*this));
}
void CodeGenModule::addReplacement(StringRef Name, llvm::Constant *C) {
Replacements[Name] = C;
}
void CodeGenModule::applyReplacements() {
for (auto &I : Replacements) {
StringRef MangledName = I.first();
llvm::Constant *Replacement = I.second;
llvm::GlobalValue *Entry = GetGlobalValue(MangledName);
if (!Entry)
continue;
auto *OldF = cast<llvm::Function>(Entry);
auto *NewF = dyn_cast<llvm::Function>(Replacement);
if (!NewF) {
if (auto *Alias = dyn_cast<llvm::GlobalAlias>(Replacement)) {
NewF = dyn_cast<llvm::Function>(Alias->getAliasee());
} else {
auto *CE = cast<llvm::ConstantExpr>(Replacement);
assert(CE->getOpcode() == llvm::Instruction::BitCast ||
CE->getOpcode() == llvm::Instruction::GetElementPtr);
NewF = dyn_cast<llvm::Function>(CE->getOperand(0));
}
}
// Replace old with new, but keep the old order.
OldF->replaceAllUsesWith(Replacement);
if (NewF) {
NewF->removeFromParent();
OldF->getParent()->getFunctionList().insertAfter(OldF->getIterator(),
NewF);
}
OldF->eraseFromParent();
}
}
void CodeGenModule::addGlobalValReplacement(llvm::GlobalValue *GV, llvm::Constant *C) {
GlobalValReplacements.push_back(std::make_pair(GV, C));
}
void CodeGenModule::applyGlobalValReplacements() {
for (auto &I : GlobalValReplacements) {
llvm::GlobalValue *GV = I.first;
llvm::Constant *C = I.second;
GV->replaceAllUsesWith(C);
GV->eraseFromParent();
}
}
// This is only used in aliases that we created and we know they have a
// linear structure.
static const llvm::GlobalObject *getAliasedGlobal(
const llvm::GlobalIndirectSymbol &GIS) {
llvm::SmallPtrSet<const llvm::GlobalIndirectSymbol*, 4> Visited;
const llvm::Constant *C = &GIS;
for (;;) {
C = C->stripPointerCasts();
if (auto *GO = dyn_cast<llvm::GlobalObject>(C))
return GO;
// stripPointerCasts will not walk over weak aliases.
auto *GIS2 = dyn_cast<llvm::GlobalIndirectSymbol>(C);
if (!GIS2)
return nullptr;
if (!Visited.insert(GIS2).second)
return nullptr;
C = GIS2->getIndirectSymbol();
}
}
void CodeGenModule::checkAliases() {
// Check if the constructed aliases are well formed. It is really unfortunate
// that we have to do this in CodeGen, but we only construct mangled names
// and aliases during codegen.
bool Error = false;
DiagnosticsEngine &Diags = getDiags();
for (const GlobalDecl &GD : Aliases) {
const auto *D = cast<ValueDecl>(GD.getDecl());
SourceLocation Location;
bool IsIFunc = D->hasAttr<IFuncAttr>();
if (const Attr *A = D->getDefiningAttr())
Location = A->getLocation();
else
llvm_unreachable("Not an alias or ifunc?");
StringRef MangledName = getMangledName(GD);
llvm::GlobalValue *Entry = GetGlobalValue(MangledName);
auto *Alias = cast<llvm::GlobalIndirectSymbol>(Entry);
const llvm::GlobalValue *GV = getAliasedGlobal(*Alias);
if (!GV) {
Error = true;
Diags.Report(Location, diag::err_cyclic_alias) << IsIFunc;
} else if (GV->isDeclaration()) {
Error = true;
Diags.Report(Location, diag::err_alias_to_undefined)
<< IsIFunc << IsIFunc;
} else if (IsIFunc) {
// Check resolver function type.
llvm::FunctionType *FTy = dyn_cast<llvm::FunctionType>(
GV->getType()->getPointerElementType());
assert(FTy);
if (!FTy->getReturnType()->isPointerTy())
Diags.Report(Location, diag::err_ifunc_resolver_return);
if (FTy->getNumParams())
Diags.Report(Location, diag::err_ifunc_resolver_params);
}
llvm::Constant *Aliasee = Alias->getIndirectSymbol();
llvm::GlobalValue *AliaseeGV;
if (auto CE = dyn_cast<llvm::ConstantExpr>(Aliasee))
AliaseeGV = cast<llvm::GlobalValue>(CE->getOperand(0));
else
AliaseeGV = cast<llvm::GlobalValue>(Aliasee);
if (const SectionAttr *SA = D->getAttr<SectionAttr>()) {
StringRef AliasSection = SA->getName();
if (AliasSection != AliaseeGV->getSection())
Diags.Report(SA->getLocation(), diag::warn_alias_with_section)
<< AliasSection << IsIFunc << IsIFunc;
}
// We have to handle alias to weak aliases in here. LLVM itself disallows
// this since the object semantics would not match the IL one. For
// compatibility with gcc we implement it by just pointing the alias
// to its aliasee's aliasee. We also warn, since the user is probably
// expecting the link to be weak.
if (auto GA = dyn_cast<llvm::GlobalIndirectSymbol>(AliaseeGV)) {
if (GA->isInterposable()) {
Diags.Report(Location, diag::warn_alias_to_weak_alias)
<< GV->getName() << GA->getName() << IsIFunc;
Aliasee = llvm::ConstantExpr::getPointerBitCastOrAddrSpaceCast(
GA->getIndirectSymbol(), Alias->getType());
Alias->setIndirectSymbol(Aliasee);
}
}
}
if (!Error)
return;
for (const GlobalDecl &GD : Aliases) {
StringRef MangledName = getMangledName(GD);
llvm::GlobalValue *Entry = GetGlobalValue(MangledName);
auto *Alias = dyn_cast<llvm::GlobalIndirectSymbol>(Entry);
Alias->replaceAllUsesWith(llvm::UndefValue::get(Alias->getType()));
Alias->eraseFromParent();
}
}
void CodeGenModule::clear() {
DeferredDeclsToEmit.clear();
if (OpenMPRuntime)
OpenMPRuntime->clear();
}
void InstrProfStats::reportDiagnostics(DiagnosticsEngine &Diags,
StringRef MainFile) {
if (!hasDiagnostics())
return;
if (VisitedInMainFile > 0 && VisitedInMainFile == MissingInMainFile) {
if (MainFile.empty())
MainFile = "<stdin>";
Diags.Report(diag::warn_profile_data_unprofiled) << MainFile;
} else {
if (Mismatched > 0)
Diags.Report(diag::warn_profile_data_out_of_date) << Visited << Mismatched;
if (Missing > 0)
Diags.Report(diag::warn_profile_data_missing) << Visited << Missing;
}
}
void CodeGenModule::Release() {
EmitDeferred();
EmitVTablesOpportunistically();
applyGlobalValReplacements();
applyReplacements();
checkAliases();
emitMultiVersionFunctions();
EmitCXXGlobalInitFunc();
EmitCXXGlobalDtorFunc();
registerGlobalDtorsWithAtExit();
EmitCXXThreadLocalInitFunc();
if (ObjCRuntime)
if (llvm::Function *ObjCInitFunction = ObjCRuntime->ModuleInitFunction())
AddGlobalCtor(ObjCInitFunction);
if (Context.getLangOpts().CUDA && !Context.getLangOpts().CUDAIsDevice &&
CUDARuntime) {
if (llvm::Function *CudaCtorFunction = CUDARuntime->makeModuleCtorFunction())
AddGlobalCtor(CudaCtorFunction);
if (llvm::Function *CudaDtorFunction = CUDARuntime->makeModuleDtorFunction())
AddGlobalDtor(CudaDtorFunction);
}
if (OpenMPRuntime) {
if (llvm::Function *OpenMPRegistrationFunction =
OpenMPRuntime->emitRegistrationFunction()) {
auto ComdatKey = OpenMPRegistrationFunction->hasComdat() ?
OpenMPRegistrationFunction : nullptr;
AddGlobalCtor(OpenMPRegistrationFunction, 0, ComdatKey);
}
OpenMPRuntime->clear();
}
if (PGOReader) {
getModule().setProfileSummary(PGOReader->getSummary().getMD(VMContext));
if (PGOStats.hasDiagnostics())
PGOStats.reportDiagnostics(getDiags(), getCodeGenOpts().MainFileName);
}
EmitCtorList(GlobalCtors, "llvm.global_ctors");
EmitCtorList(GlobalDtors, "llvm.global_dtors");
EmitGlobalAnnotations();
EmitStaticExternCAliases();
EmitDeferredUnusedCoverageMappings();
if (CoverageMapping)
CoverageMapping->emit();
if (CodeGenOpts.SanitizeCfiCrossDso) {
CodeGenFunction(*this).EmitCfiCheckFail();
CodeGenFunction(*this).EmitCfiCheckStub();
}
emitAtAvailableLinkGuard();
emitLLVMUsed();
if (SanStats)
SanStats->finish();
if (CodeGenOpts.Autolink &&
(Context.getLangOpts().Modules || !LinkerOptionsMetadata.empty())) {
EmitModuleLinkOptions();
}
// Record mregparm value now so it is visible through rest of codegen.
if (Context.getTargetInfo().getTriple().getArch() == llvm::Triple::x86)
getModule().addModuleFlag(llvm::Module::Error, "NumRegisterParameters",
CodeGenOpts.NumRegisterParameters);
if (CodeGenOpts.DwarfVersion) {
// We actually want the latest version when there are conflicts.
// We can change from Warning to Latest if such mode is supported.
getModule().addModuleFlag(llvm::Module::Warning, "Dwarf Version",
CodeGenOpts.DwarfVersion);
}
if (CodeGenOpts.EmitCodeView) {
// Indicate that we want CodeView in the metadata.
getModule().addModuleFlag(llvm::Module::Warning, "CodeView", 1);
}
if (CodeGenOpts.ControlFlowGuard) {
// We want function ID tables for Control Flow Guard.
getModule().addModuleFlag(llvm::Module::Warning, "cfguard", 1);
}
if (CodeGenOpts.OptimizationLevel > 0 && CodeGenOpts.StrictVTablePointers) {
// We don't support LTO with 2 with different StrictVTablePointers
// FIXME: we could support it by stripping all the information introduced
// by StrictVTablePointers.
getModule().addModuleFlag(llvm::Module::Error, "StrictVTablePointers",1);
llvm::Metadata *Ops[2] = {
llvm::MDString::get(VMContext, "StrictVTablePointers"),
llvm::ConstantAsMetadata::get(llvm::ConstantInt::get(
llvm::Type::getInt32Ty(VMContext), 1))};
getModule().addModuleFlag(llvm::Module::Require,
"StrictVTablePointersRequirement",
llvm::MDNode::get(VMContext, Ops));
}
if (DebugInfo)
// We support a single version in the linked module. The LLVM
// parser will drop debug info with a different version number
// (and warn about it, too).
getModule().addModuleFlag(llvm::Module::Warning, "Debug Info Version",
llvm::DEBUG_METADATA_VERSION);
// We need to record the widths of enums and wchar_t, so that we can generate
// the correct build attributes in the ARM backend. wchar_size is also used by
// TargetLibraryInfo.
uint64_t WCharWidth =
Context.getTypeSizeInChars(Context.getWideCharType()).getQuantity();
getModule().addModuleFlag(llvm::Module::Error, "wchar_size", WCharWidth);
llvm::Triple::ArchType Arch = Context.getTargetInfo().getTriple().getArch();
if ( Arch == llvm::Triple::arm
|| Arch == llvm::Triple::armeb
|| Arch == llvm::Triple::thumb
|| Arch == llvm::Triple::thumbeb) {
// The minimum width of an enum in bytes
uint64_t EnumWidth = Context.getLangOpts().ShortEnums ? 1 : 4;
getModule().addModuleFlag(llvm::Module::Error, "min_enum_size", EnumWidth);
}
if (CodeGenOpts.SanitizeCfiCrossDso) {
// Indicate that we want cross-DSO control flow integrity checks.
getModule().addModuleFlag(llvm::Module::Override, "Cross-DSO CFI", 1);
}
if (CodeGenOpts.CFProtectionReturn &&
Target.checkCFProtectionReturnSupported(getDiags())) {
// Indicate that we want to instrument return control flow protection.
getModule().addModuleFlag(llvm::Module::Override, "cf-protection-return",
1);
}
if (CodeGenOpts.CFProtectionBranch &&
Target.checkCFProtectionBranchSupported(getDiags())) {
// Indicate that we want to instrument branch control flow protection.
getModule().addModuleFlag(llvm::Module::Override, "cf-protection-branch",
1);
}
if (LangOpts.CUDAIsDevice && getTriple().isNVPTX()) {
// Indicate whether __nvvm_reflect should be configured to flush denormal
// floating point values to 0. (This corresponds to its "__CUDA_FTZ"
// property.)
getModule().addModuleFlag(llvm::Module::Override, "nvvm-reflect-ftz",
LangOpts.CUDADeviceFlushDenormalsToZero ? 1 : 0);
}
// Emit OpenCL specific module metadata: OpenCL/SPIR version.
if (LangOpts.OpenCL) {
EmitOpenCLMetadata();
// Emit SPIR version.
if (getTriple().getArch() == llvm::Triple::spir ||
getTriple().getArch() == llvm::Triple::spir64) {
// SPIR v2.0 s2.12 - The SPIR version used by the module is stored in the
// opencl.spir.version named metadata.
llvm::Metadata *SPIRVerElts[] = {
llvm::ConstantAsMetadata::get(llvm::ConstantInt::get(
Int32Ty, LangOpts.OpenCLVersion / 100)),
llvm::ConstantAsMetadata::get(llvm::ConstantInt::get(
Int32Ty, (LangOpts.OpenCLVersion / 100 > 1) ? 0 : 2))};
llvm::NamedMDNode *SPIRVerMD =
TheModule.getOrInsertNamedMetadata("opencl.spir.version");
llvm::LLVMContext &Ctx = TheModule.getContext();
SPIRVerMD->addOperand(llvm::MDNode::get(Ctx, SPIRVerElts));
}
}
if (uint32_t PLevel = Context.getLangOpts().PICLevel) {
assert(PLevel < 3 && "Invalid PIC Level");
getModule().setPICLevel(static_cast<llvm::PICLevel::Level>(PLevel));
if (Context.getLangOpts().PIE)
getModule().setPIELevel(static_cast<llvm::PIELevel::Level>(PLevel));
}
if (CodeGenOpts.NoPLT)
getModule().setRtLibUseGOT();
SimplifyPersonality();
if (getCodeGenOpts().EmitDeclMetadata)
EmitDeclMetadata();
if (getCodeGenOpts().EmitGcovArcs || getCodeGenOpts().EmitGcovNotes)
EmitCoverageFile();
if (DebugInfo)
DebugInfo->finalize();
if (getCodeGenOpts().EmitVersionIdentMetadata)
EmitVersionIdentMetadata();
EmitTargetMetadata();
}
void CodeGenModule::EmitOpenCLMetadata() {
// SPIR v2.0 s2.13 - The OpenCL version used by the module is stored in the
// opencl.ocl.version named metadata node.
llvm::Metadata *OCLVerElts[] = {
llvm::ConstantAsMetadata::get(llvm::ConstantInt::get(
Int32Ty, LangOpts.OpenCLVersion / 100)),
llvm::ConstantAsMetadata::get(llvm::ConstantInt::get(
Int32Ty, (LangOpts.OpenCLVersion % 100) / 10))};
llvm::NamedMDNode *OCLVerMD =
TheModule.getOrInsertNamedMetadata("opencl.ocl.version");
llvm::LLVMContext &Ctx = TheModule.getContext();
OCLVerMD->addOperand(llvm::MDNode::get(Ctx, OCLVerElts));
}
void CodeGenModule::UpdateCompletedType(const TagDecl *TD) {
// Make sure that this type is translated.
Types.UpdateCompletedType(TD);
}
void CodeGenModule::RefreshTypeCacheForClass(const CXXRecordDecl *RD) {
// Make sure that this type is translated.
Types.RefreshTypeCacheForClass(RD);
}
llvm::MDNode *CodeGenModule::getTBAATypeInfo(QualType QTy) {
if (!TBAA)
return nullptr;
return TBAA->getTypeInfo(QTy);
}
TBAAAccessInfo CodeGenModule::getTBAAAccessInfo(QualType AccessType) {
if (!TBAA)
return TBAAAccessInfo();
return TBAA->getAccessInfo(AccessType);
}
TBAAAccessInfo
CodeGenModule::getTBAAVTablePtrAccessInfo(llvm::Type *VTablePtrType) {
if (!TBAA)
return TBAAAccessInfo();
return TBAA->getVTablePtrAccessInfo(VTablePtrType);
}
llvm::MDNode *CodeGenModule::getTBAAStructInfo(QualType QTy) {
if (!TBAA)
return nullptr;
return TBAA->getTBAAStructInfo(QTy);
}
llvm::MDNode *CodeGenModule::getTBAABaseTypeInfo(QualType QTy) {
if (!TBAA)
return nullptr;
return TBAA->getBaseTypeInfo(QTy);
}
llvm::MDNode *CodeGenModule::getTBAAAccessTagInfo(TBAAAccessInfo Info) {
if (!TBAA)
return nullptr;
return TBAA->getAccessTagInfo(Info);
}
TBAAAccessInfo CodeGenModule::mergeTBAAInfoForCast(TBAAAccessInfo SourceInfo,
TBAAAccessInfo TargetInfo) {
if (!TBAA)
return TBAAAccessInfo();
return TBAA->mergeTBAAInfoForCast(SourceInfo, TargetInfo);
}
TBAAAccessInfo
CodeGenModule::mergeTBAAInfoForConditionalOperator(TBAAAccessInfo InfoA,
TBAAAccessInfo InfoB) {
if (!TBAA)
return TBAAAccessInfo();
return TBAA->mergeTBAAInfoForConditionalOperator(InfoA, InfoB);
}
TBAAAccessInfo
CodeGenModule::mergeTBAAInfoForMemoryTransfer(TBAAAccessInfo DestInfo,
TBAAAccessInfo SrcInfo) {
if (!TBAA)
return TBAAAccessInfo();
return TBAA->mergeTBAAInfoForConditionalOperator(DestInfo, SrcInfo);
}
void CodeGenModule::DecorateInstructionWithTBAA(llvm::Instruction *Inst,
TBAAAccessInfo TBAAInfo) {
if (llvm::MDNode *Tag = getTBAAAccessTagInfo(TBAAInfo))
Inst->setMetadata(llvm::LLVMContext::MD_tbaa, Tag);
}
void CodeGenModule::DecorateInstructionWithInvariantGroup(
llvm::Instruction *I, const CXXRecordDecl *RD) {
I->setMetadata(llvm::LLVMContext::MD_invariant_group,
llvm::MDNode::get(getLLVMContext(), {}));
}
void CodeGenModule::Error(SourceLocation loc, StringRef message) {
unsigned diagID = getDiags().getCustomDiagID(DiagnosticsEngine::Error, "%0");
getDiags().Report(Context.getFullLoc(loc), diagID) << message;
}
/// ErrorUnsupported - Print out an error that codegen doesn't support the
/// specified stmt yet.
void CodeGenModule::ErrorUnsupported(const Stmt *S, const char *Type) {
unsigned DiagID = getDiags().getCustomDiagID(DiagnosticsEngine::Error,
"cannot compile this %0 yet");
std::string Msg = Type;
getDiags().Report(Context.getFullLoc(S->getLocStart()), DiagID)
<< Msg << S->getSourceRange();
}
/// ErrorUnsupported - Print out an error that codegen doesn't support the
/// specified decl yet.
void CodeGenModule::ErrorUnsupported(const Decl *D, const char *Type) {
unsigned DiagID = getDiags().getCustomDiagID(DiagnosticsEngine::Error,
"cannot compile this %0 yet");
std::string Msg = Type;
getDiags().Report(Context.getFullLoc(D->getLocation()), DiagID) << Msg;
}
llvm::ConstantInt *CodeGenModule::getSize(CharUnits size) {
return llvm::ConstantInt::get(SizeTy, size.getQuantity());
}
void CodeGenModule::setGlobalVisibility(llvm::GlobalValue *GV,
const NamedDecl *D) const {
if (GV->hasDLLImportStorageClass())
return;
// Internal definitions always have default visibility.
if (GV->hasLocalLinkage()) {
GV->setVisibility(llvm::GlobalValue::DefaultVisibility);
return;
}
if (!D)
return;
// Set visibility for definitions.
LinkageInfo LV = D->getLinkageAndVisibility();
if (LV.isVisibilityExplicit() || !GV->isDeclarationForLinker())
GV->setVisibility(GetLLVMVisibility(LV.getVisibility()));
}
static bool shouldAssumeDSOLocal(const CodeGenModule &CGM,
llvm::GlobalValue *GV) {
if (GV->hasLocalLinkage())
return true;
if (!GV->hasDefaultVisibility() && !GV->hasExternalWeakLinkage())
return true;
// DLLImport explicitly marks the GV as external.
if (GV->hasDLLImportStorageClass())
return false;
const llvm::Triple &TT = CGM.getTriple();
// Every other GV is local on COFF.
// Make an exception for windows OS in the triple: Some firmware builds use
// *-win32-macho triples. This (accidentally?) produced windows relocations
// without GOT tables in older clang versions; Keep this behaviour.
// FIXME: even thread local variables?
if (TT.isOSBinFormatCOFF() || (TT.isOSWindows() && TT.isOSBinFormatMachO()))
return true;
// Only handle COFF and ELF for now.
if (!TT.isOSBinFormatELF())
return false;
// If this is not an executable, don't assume anything is local.
const auto &CGOpts = CGM.getCodeGenOpts();
llvm::Reloc::Model RM = CGOpts.RelocationModel;
const auto &LOpts = CGM.getLangOpts();
if (RM != llvm::Reloc::Static && !LOpts.PIE)
return false;
// A definition cannot be preempted from an executable.
if (!GV->isDeclarationForLinker())
return true;
// Most PIC code sequences that assume that a symbol is local cannot produce a
// 0 if it turns out the symbol is undefined. While this is ABI and relocation
// depended, it seems worth it to handle it here.
if (RM == llvm::Reloc::PIC_ && GV->hasExternalWeakLinkage())
return false;
// PPC has no copy relocations and cannot use a plt entry as a symbol address.
llvm::Triple::ArchType Arch = TT.getArch();
if (Arch == llvm::Triple::ppc || Arch == llvm::Triple::ppc64 ||
Arch == llvm::Triple::ppc64le)
return false;
// If we can use copy relocations we can assume it is local.
if (auto *Var = dyn_cast<llvm::GlobalVariable>(GV))
if (!Var->isThreadLocal() &&
(RM == llvm::Reloc::Static || CGOpts.PIECopyRelocations))
return true;
// If we can use a plt entry as the symbol address we can assume it
// is local.
// FIXME: This should work for PIE, but the gold linker doesn't support it.
if (isa<llvm::Function>(GV) && !CGOpts.NoPLT && RM == llvm::Reloc::Static)
return true;
// Otherwise don't assue it is local.
return false;
}
void CodeGenModule::setDSOLocal(llvm::GlobalValue *GV) const {
GV->setDSOLocal(shouldAssumeDSOLocal(*this, GV));
}
void CodeGenModule::setDLLImportDLLExport(llvm::GlobalValue *GV,
GlobalDecl GD) const {
const auto *D = dyn_cast<NamedDecl>(GD.getDecl());
// C++ destructors have a few C++ ABI specific special cases.
if (const auto *Dtor = dyn_cast_or_null<CXXDestructorDecl>(D)) {
getCXXABI().setCXXDestructorDLLStorage(GV, Dtor, GD.getDtorType());
return;
}
setDLLImportDLLExport(GV, D);
}
void CodeGenModule::setDLLImportDLLExport(llvm::GlobalValue *GV,
const NamedDecl *D) const {
if (D && D->isExternallyVisible()) {
if (D->hasAttr<DLLImportAttr>())
GV->setDLLStorageClass(llvm::GlobalVariable::DLLImportStorageClass);
else if (D->hasAttr<DLLExportAttr>() && !GV->isDeclarationForLinker())
GV->setDLLStorageClass(llvm::GlobalVariable::DLLExportStorageClass);
}
}
void CodeGenModule::setGVProperties(llvm::GlobalValue *GV,
GlobalDecl GD) const {
setDLLImportDLLExport(GV, GD);
setGlobalVisibilityAndLocal(GV, dyn_cast<NamedDecl>(GD.getDecl()));
}
void CodeGenModule::setGVProperties(llvm::GlobalValue *GV,
const NamedDecl *D) const {
setDLLImportDLLExport(GV, D);
setGlobalVisibilityAndLocal(GV, D);
}
void CodeGenModule::setGlobalVisibilityAndLocal(llvm::GlobalValue *GV,
const NamedDecl *D) const {
setGlobalVisibility(GV, D);
setDSOLocal(GV);
}
static llvm::GlobalVariable::ThreadLocalMode GetLLVMTLSModel(StringRef S) {
return llvm::StringSwitch<llvm::GlobalVariable::ThreadLocalMode>(S)
.Case("global-dynamic", llvm::GlobalVariable::GeneralDynamicTLSModel)
.Case("local-dynamic", llvm::GlobalVariable::LocalDynamicTLSModel)
.Case("initial-exec", llvm::GlobalVariable::InitialExecTLSModel)
.Case("local-exec", llvm::GlobalVariable::LocalExecTLSModel);
}
static llvm::GlobalVariable::ThreadLocalMode GetLLVMTLSModel(
CodeGenOptions::TLSModel M) {
switch (M) {
case CodeGenOptions::GeneralDynamicTLSModel:
return llvm::GlobalVariable::GeneralDynamicTLSModel;
case CodeGenOptions::LocalDynamicTLSModel:
return llvm::GlobalVariable::LocalDynamicTLSModel;
case CodeGenOptions::InitialExecTLSModel:
return llvm::GlobalVariable::InitialExecTLSModel;
case CodeGenOptions::LocalExecTLSModel:
return llvm::GlobalVariable::LocalExecTLSModel;
}
llvm_unreachable("Invalid TLS model!");
}
void CodeGenModule::setTLSMode(llvm::GlobalValue *GV, const VarDecl &D) const {
assert(D.getTLSKind() && "setting TLS mode on non-TLS var!");
llvm::GlobalValue::ThreadLocalMode TLM;
TLM = GetLLVMTLSModel(CodeGenOpts.getDefaultTLSModel());
// Override the TLS model if it is explicitly specified.
if (const TLSModelAttr *Attr = D.getAttr<TLSModelAttr>()) {
TLM = GetLLVMTLSModel(Attr->getModel());
}
GV->setThreadLocalMode(TLM);
}
static void AppendTargetMangling(const CodeGenModule &CGM,
const TargetAttr *Attr, raw_ostream &Out) {
if (Attr->isDefaultVersion())
return;
Out << '.';
const auto &Target = CGM.getTarget();
TargetAttr::ParsedTargetAttr Info =
Attr->parse([&Target](StringRef LHS, StringRef RHS) {
// Multiversioning doesn't allow "no-${feature}", so we can
// only have "+" prefixes here.
assert(LHS.startswith("+") && RHS.startswith("+") &&
"Features should always have a prefix.");
return Target.multiVersionSortPriority(LHS.substr(1)) >
Target.multiVersionSortPriority(RHS.substr(1));
});
bool IsFirst = true;
if (!Info.Architecture.empty()) {
IsFirst = false;
Out << "arch_" << Info.Architecture;
}
for (StringRef Feat : Info.Features) {
if (!IsFirst)
Out << '_';
IsFirst = false;
Out << Feat.substr(1);
}
}
static std::string getMangledNameImpl(const CodeGenModule &CGM, GlobalDecl GD,
const NamedDecl *ND,
bool OmitTargetMangling = false) {
SmallString<256> Buffer;
llvm::raw_svector_ostream Out(Buffer);
MangleContext &MC = CGM.getCXXABI().getMangleContext();
if (MC.shouldMangleDeclName(ND)) {
llvm::raw_svector_ostream Out(Buffer);
if (const auto *D = dyn_cast<CXXConstructorDecl>(ND))
MC.mangleCXXCtor(D, GD.getCtorType(), Out);
else if (const auto *D = dyn_cast<CXXDestructorDecl>(ND))
MC.mangleCXXDtor(D, GD.getDtorType(), Out);
else
MC.mangleName(ND, Out);
} else {
IdentifierInfo *II = ND->getIdentifier();
assert(II && "Attempt to mangle unnamed decl.");
const auto *FD = dyn_cast<FunctionDecl>(ND);
if (FD &&
FD->getType()->castAs<FunctionType>()->getCallConv() == CC_X86RegCall) {
llvm::raw_svector_ostream Out(Buffer);
Out << "__regcall3__" << II->getName();
} else {
Out << II->getName();
}
}
if (const auto *FD = dyn_cast<FunctionDecl>(ND))
if (FD->isMultiVersion() && !OmitTargetMangling)
AppendTargetMangling(CGM, FD->getAttr<TargetAttr>(), Out);
return Out.str();
}
void CodeGenModule::UpdateMultiVersionNames(GlobalDecl GD,
const FunctionDecl *FD) {
if (!FD->isMultiVersion())
return;
// Get the name of what this would be without the 'target' attribute. This
// allows us to lookup the version that was emitted when this wasn't a
// multiversion function.
std::string NonTargetName =
getMangledNameImpl(*this, GD, FD, /*OmitTargetMangling=*/true);
GlobalDecl OtherGD;
if (lookupRepresentativeDecl(NonTargetName, OtherGD)) {
assert(OtherGD.getCanonicalDecl()
.getDecl()
->getAsFunction()
->isMultiVersion() &&
"Other GD should now be a multiversioned function");
// OtherFD is the version of this function that was mangled BEFORE
// becoming a MultiVersion function. It potentially needs to be updated.
const FunctionDecl *OtherFD =
OtherGD.getCanonicalDecl().getDecl()->getAsFunction();
std::string OtherName = getMangledNameImpl(*this, OtherGD, OtherFD);
// This is so that if the initial version was already the 'default'
// version, we don't try to update it.
if (OtherName != NonTargetName) {
// Remove instead of erase, since others may have stored the StringRef
// to this.
const auto ExistingRecord = Manglings.find(NonTargetName);
if (ExistingRecord != std::end(Manglings))
Manglings.remove(&(*ExistingRecord));
auto Result = Manglings.insert(std::make_pair(OtherName, OtherGD));
MangledDeclNames[OtherGD.getCanonicalDecl()] = Result.first->first();
if (llvm::GlobalValue *Entry = GetGlobalValue(NonTargetName))
Entry->setName(OtherName);
}
}
}
StringRef CodeGenModule::getMangledName(GlobalDecl GD) {
GlobalDecl CanonicalGD = GD.getCanonicalDecl();
// Some ABIs don't have constructor variants. Make sure that base and
// complete constructors get mangled the same.
if (const auto *CD = dyn_cast<CXXConstructorDecl>(CanonicalGD.getDecl())) {
if (!getTarget().getCXXABI().hasConstructorVariants()) {
CXXCtorType OrigCtorType = GD.getCtorType();
assert(OrigCtorType == Ctor_Base || OrigCtorType == Ctor_Complete);
if (OrigCtorType == Ctor_Base)
CanonicalGD = GlobalDecl(CD, Ctor_Complete);
}
}
auto FoundName = MangledDeclNames.find(CanonicalGD);
if (FoundName != MangledDeclNames.end())
return FoundName->second;
// Keep the first result in the case of a mangling collision.
const auto *ND = cast<NamedDecl>(GD.getDecl());
auto Result =
Manglings.insert(std::make_pair(getMangledNameImpl(*this, GD, ND), GD));
return MangledDeclNames[CanonicalGD] = Result.first->first();
}
StringRef CodeGenModule::getBlockMangledName(GlobalDecl GD,
const BlockDecl *BD) {
MangleContext &MangleCtx = getCXXABI().getMangleContext();
const Decl *D = GD.getDecl();
SmallString<256> Buffer;
llvm::raw_svector_ostream Out(Buffer);
if (!D)
MangleCtx.mangleGlobalBlock(BD,
dyn_cast_or_null<VarDecl>(initializedGlobalDecl.getDecl()), Out);
else if (const auto *CD = dyn_cast<CXXConstructorDecl>(D))
MangleCtx.mangleCtorBlock(CD, GD.getCtorType(), BD, Out);
else if (const auto *DD = dyn_cast<CXXDestructorDecl>(D))
MangleCtx.mangleDtorBlock(DD, GD.getDtorType(), BD, Out);
else
MangleCtx.mangleBlock(cast<DeclContext>(D), BD, Out);
auto Result = Manglings.insert(std::make_pair(Out.str(), BD));
return Result.first->first();
}
llvm::GlobalValue *CodeGenModule::GetGlobalValue(StringRef Name) {
return getModule().getNamedValue(Name);
}
/// AddGlobalCtor - Add a function to the list that will be called before
/// main() runs.
void CodeGenModule::AddGlobalCtor(llvm::Function *Ctor, int Priority,
llvm::Constant *AssociatedData) {
// FIXME: Type coercion of void()* types.
GlobalCtors.push_back(Structor(Priority, Ctor, AssociatedData));
}
/// AddGlobalDtor - Add a function to the list that will be called
/// when the module is unloaded.
void CodeGenModule::AddGlobalDtor(llvm::Function *Dtor, int Priority) {
if (CodeGenOpts.RegisterGlobalDtorsWithAtExit) {
DtorsUsingAtExit[Priority].push_back(Dtor);
return;
}
// FIXME: Type coercion of void()* types.
GlobalDtors.push_back(Structor(Priority, Dtor, nullptr));
}
void CodeGenModule::EmitCtorList(CtorList &Fns, const char *GlobalName) {
if (Fns.empty()) return;
// Ctor function type is void()*.
llvm::FunctionType* CtorFTy = llvm::FunctionType::get(VoidTy, false);
llvm::Type *CtorPFTy = llvm::PointerType::getUnqual(CtorFTy);
// Get the type of a ctor entry, { i32, void ()*, i8* }.
llvm::StructType *CtorStructTy = llvm::StructType::get(
Int32Ty, llvm::PointerType::getUnqual(CtorFTy), VoidPtrTy);
// Construct the constructor and destructor arrays.
ConstantInitBuilder builder(*this);
auto ctors = builder.beginArray(CtorStructTy);
for (const auto &I : Fns) {
auto ctor = ctors.beginStruct(CtorStructTy);
ctor.addInt(Int32Ty, I.Priority);
ctor.add(llvm::ConstantExpr::getBitCast(I.Initializer, CtorPFTy));
if (I.AssociatedData)
ctor.add(llvm::ConstantExpr::getBitCast(I.AssociatedData, VoidPtrTy));
else
ctor.addNullPointer(VoidPtrTy);
ctor.finishAndAddTo(ctors);
}
auto list =
ctors.finishAndCreateGlobal(GlobalName, getPointerAlign(),
/*constant*/ false,
llvm::GlobalValue::AppendingLinkage);
// The LTO linker doesn't seem to like it when we set an alignment
// on appending variables. Take it off as a workaround.
list->setAlignment(0);
Fns.clear();
}
llvm::GlobalValue::LinkageTypes
CodeGenModule::getFunctionLinkage(GlobalDecl GD) {
const auto *D = cast<FunctionDecl>(GD.getDecl());
GVALinkage Linkage = getContext().GetGVALinkageForFunction(D);
if (const auto *Dtor = dyn_cast<CXXDestructorDecl>(D))
return getCXXABI().getCXXDestructorLinkage(Linkage, Dtor, GD.getDtorType());
if (isa<CXXConstructorDecl>(D) &&
cast<CXXConstructorDecl>(D)->isInheritingConstructor() &&
Context.getTargetInfo().getCXXABI().isMicrosoft()) {
// Our approach to inheriting constructors is fundamentally different from
// that used by the MS ABI, so keep our inheriting constructor thunks
// internal rather than trying to pick an unambiguous mangling for them.
return llvm::GlobalValue::InternalLinkage;
}
return getLLVMLinkageForDeclarator(D, Linkage, /*isConstantVariable=*/false);
}
llvm::ConstantInt *CodeGenModule::CreateCrossDsoCfiTypeId(llvm::Metadata *MD) {
llvm::MDString *MDS = dyn_cast<llvm::MDString>(MD);
if (!MDS) return nullptr;
return llvm::ConstantInt::get(Int64Ty, llvm::MD5Hash(MDS->getString()));
}
void CodeGenModule::SetLLVMFunctionAttributes(const Decl *D,
const CGFunctionInfo &Info,
llvm::Function *F) {
unsigned CallingConv;
llvm::AttributeList PAL;
ConstructAttributeList(F->getName(), Info, D, PAL, CallingConv, false);
F->setAttributes(PAL);
F->setCallingConv(static_cast<llvm::CallingConv::ID>(CallingConv));
}
/// Determines whether the language options require us to model
/// unwind exceptions. We treat -fexceptions as mandating this
/// except under the fragile ObjC ABI with only ObjC exceptions
/// enabled. This means, for example, that C with -fexceptions
/// enables this.
static bool hasUnwindExceptions(const LangOptions &LangOpts) {
// If exceptions are completely disabled, obviously this is false.
if (!LangOpts.Exceptions) return false;
// If C++ exceptions are enabled, this is true.
if (LangOpts.CXXExceptions) return true;
// If ObjC exceptions are enabled, this depends on the ABI.
if (LangOpts.ObjCExceptions) {
return LangOpts.ObjCRuntime.hasUnwindExceptions();
}
return true;
}
void CodeGenModule::SetLLVMFunctionAttributesForDefinition(const Decl *D,
llvm::Function *F) {
llvm::AttrBuilder B;
if (CodeGenOpts.UnwindTables)
B.addAttribute(llvm::Attribute::UWTable);
if (!hasUnwindExceptions(LangOpts))
B.addAttribute(llvm::Attribute::NoUnwind);
if (!D || !D->hasAttr<NoStackProtectorAttr>()) {
if (LangOpts.getStackProtector() == LangOptions::SSPOn)
B.addAttribute(llvm::Attribute::StackProtect);
else if (LangOpts.getStackProtector() == LangOptions::SSPStrong)
B.addAttribute(llvm::Attribute::StackProtectStrong);
else if (LangOpts.getStackProtector() == LangOptions::SSPReq)
B.addAttribute(llvm::Attribute::StackProtectReq);
}
if (!D) {
// If we don't have a declaration to control inlining, the function isn't
// explicitly marked as alwaysinline for semantic reasons, and inlining is
// disabled, mark the function as noinline.
if (!F->hasFnAttribute(llvm::Attribute::AlwaysInline) &&
CodeGenOpts.getInlining() == CodeGenOptions::OnlyAlwaysInlining)
B.addAttribute(llvm::Attribute::NoInline);
F->addAttributes(llvm::AttributeList::FunctionIndex, B);
return;
}
// Track whether we need to add the optnone LLVM attribute,
// starting with the default for this optimization level.
bool ShouldAddOptNone =
!CodeGenOpts.DisableO0ImplyOptNone && CodeGenOpts.OptimizationLevel == 0;
// We can't add optnone in the following cases, it won't pass the verifier.
ShouldAddOptNone &= !D->hasAttr<MinSizeAttr>();
ShouldAddOptNone &= !F->hasFnAttribute(llvm::Attribute::AlwaysInline);
ShouldAddOptNone &= !D->hasAttr<AlwaysInlineAttr>();
if (ShouldAddOptNone || D->hasAttr<OptimizeNoneAttr>()) {
B.addAttribute(llvm::Attribute::OptimizeNone);
// OptimizeNone implies noinline; we should not be inlining such functions.
B.addAttribute(llvm::Attribute::NoInline);
assert(!F->hasFnAttribute(llvm::Attribute::AlwaysInline) &&
"OptimizeNone and AlwaysInline on same function!");
// We still need to handle naked functions even though optnone subsumes
// much of their semantics.
if (D->hasAttr<NakedAttr>())
B.addAttribute(llvm::Attribute::Naked);
// OptimizeNone wins over OptimizeForSize and MinSize.
F->removeFnAttr(llvm::Attribute::OptimizeForSize);
F->removeFnAttr(llvm::Attribute::MinSize);
} else if (D->hasAttr<NakedAttr>()) {
// Naked implies noinline: we should not be inlining such functions.
B.addAttribute(llvm::Attribute::Naked);
B.addAttribute(llvm::Attribute::NoInline);
} else if (D->hasAttr<NoDuplicateAttr>()) {
B.addAttribute(llvm::Attribute::NoDuplicate);
} else if (D->hasAttr<NoInlineAttr>()) {
B.addAttribute(llvm::Attribute::NoInline);
} else if (D->hasAttr<AlwaysInlineAttr>() &&
!F->hasFnAttribute(llvm::Attribute::NoInline)) {
// (noinline wins over always_inline, and we can't specify both in IR)
B.addAttribute(llvm::Attribute::AlwaysInline);
} else if (CodeGenOpts.getInlining() == CodeGenOptions::OnlyAlwaysInlining) {
// If we're not inlining, then force everything that isn't always_inline to
// carry an explicit noinline attribute.
if (!F->hasFnAttribute(llvm::Attribute::AlwaysInline))
B.addAttribute(llvm::Attribute::NoInline);
} else {
// Otherwise, propagate the inline hint attribute and potentially use its
// absence to mark things as noinline.
if (auto *FD = dyn_cast<FunctionDecl>(D)) {
if (any_of(FD->redecls(), [&](const FunctionDecl *Redecl) {
return Redecl->isInlineSpecified();
})) {
B.addAttribute(llvm::Attribute::InlineHint);
} else if (CodeGenOpts.getInlining() ==
CodeGenOptions::OnlyHintInlining &&
!FD->isInlined() &&
!F->hasFnAttribute(llvm::Attribute::AlwaysInline)) {
B.addAttribute(llvm::Attribute::NoInline);
}
}
}
// Add other optimization related attributes if we are optimizing this
// function.
if (!D->hasAttr<OptimizeNoneAttr>()) {
if (D->hasAttr<ColdAttr>()) {
if (!ShouldAddOptNone)
B.addAttribute(llvm::Attribute::OptimizeForSize);
B.addAttribute(llvm::Attribute::Cold);
}
if (D->hasAttr<MinSizeAttr>())
B.addAttribute(llvm::Attribute::MinSize);
}
F->addAttributes(llvm::AttributeList::FunctionIndex, B);
unsigned alignment = D->getMaxAlignment() / Context.getCharWidth();
if (alignment)
F->setAlignment(alignment);
if (!D->hasAttr<AlignedAttr>())
if (LangOpts.FunctionAlignment)
F->setAlignment(1 << LangOpts.FunctionAlignment);
// Some C++ ABIs require 2-byte alignment for member functions, in order to
// reserve a bit for differentiating between virtual and non-virtual member
// functions. If the current target's C++ ABI requires this and this is a
// member function, set its alignment accordingly.
if (getTarget().getCXXABI().areMemberFunctionsAligned()) {
if (F->getAlignment() < 2 && isa<CXXMethodDecl>(D))
F->setAlignment(2);
}
// In the cross-dso CFI mode, we want !type attributes on definitions only.
if (CodeGenOpts.SanitizeCfiCrossDso)
if (auto *FD = dyn_cast<FunctionDecl>(D))
CreateFunctionTypeMetadata(FD, F);
}
void CodeGenModule::SetCommonAttributes(GlobalDecl GD, llvm::GlobalValue *GV) {
const Decl *D = GD.getDecl();
if (dyn_cast_or_null<NamedDecl>(D))
setGVProperties(GV, GD);
else
GV->setVisibility(llvm::GlobalValue::DefaultVisibility);
if (D && D->hasAttr<UsedAttr>())
addUsedGlobal(GV);
}
bool CodeGenModule::GetCPUAndFeaturesAttributes(const Decl *D,
llvm::AttrBuilder &Attrs) {
// Add target-cpu and target-features attributes to functions. If
// we have a decl for the function and it has a target attribute then
// parse that and add it to the feature set.
StringRef TargetCPU = getTarget().getTargetOpts().CPU;
std::vector<std::string> Features;
const auto *FD = dyn_cast_or_null<FunctionDecl>(D);
FD = FD ? FD->getMostRecentDecl() : FD;
const auto *TD = FD ? FD->getAttr<TargetAttr>() : nullptr;
bool AddedAttr = false;
if (TD) {
llvm::StringMap<bool> FeatureMap;
getFunctionFeatureMap(FeatureMap, FD);
// Produce the canonical string for this set of features.
for (const llvm::StringMap<bool>::value_type &Entry : FeatureMap)
Features.push_back((Entry.getValue() ? "+" : "-") + Entry.getKey().str());
// Now add the target-cpu and target-features to the function.
// While we populated the feature map above, we still need to
// get and parse the target attribute so we can get the cpu for
// the function.
TargetAttr::ParsedTargetAttr ParsedAttr = TD->parse();
if (ParsedAttr.Architecture != "" &&
getTarget().isValidCPUName(ParsedAttr.Architecture))
TargetCPU = ParsedAttr.Architecture;
} else {
// Otherwise just add the existing target cpu and target features to the
// function.
Features = getTarget().getTargetOpts().Features;
}
if (TargetCPU != "") {
Attrs.addAttribute("target-cpu", TargetCPU);
AddedAttr = true;
}
if (!Features.empty()) {
llvm::sort(Features.begin(), Features.end());
Attrs.addAttribute("target-features", llvm::join(Features, ","));
AddedAttr = true;
}
return AddedAttr;
}
void CodeGenModule::setNonAliasAttributes(GlobalDecl GD,
llvm::GlobalObject *GO) {
const Decl *D = GD.getDecl();
SetCommonAttributes(GD, GO);
if (D) {
if (auto *GV = dyn_cast<llvm::GlobalVariable>(GO)) {
if (auto *SA = D->getAttr<PragmaClangBSSSectionAttr>())
GV->addAttribute("bss-section", SA->getName());
if (auto *SA = D->getAttr<PragmaClangDataSectionAttr>())
GV->addAttribute("data-section", SA->getName());
if (auto *SA = D->getAttr<PragmaClangRodataSectionAttr>())
GV->addAttribute("rodata-section", SA->getName());
}
if (auto *F = dyn_cast<llvm::Function>(GO)) {
if (auto *SA = D->getAttr<PragmaClangTextSectionAttr>())
if (!D->getAttr<SectionAttr>())
F->addFnAttr("implicit-section-name", SA->getName());
llvm::AttrBuilder Attrs;
if (GetCPUAndFeaturesAttributes(D, Attrs)) {
// We know that GetCPUAndFeaturesAttributes will always have the
// newest set, since it has the newest possible FunctionDecl, so the
// new ones should replace the old.
F->removeFnAttr("target-cpu");
F->removeFnAttr("target-features");
F->addAttributes(llvm::AttributeList::FunctionIndex, Attrs);
}
}
if (const SectionAttr *SA = D->getAttr<SectionAttr>())
GO->setSection(SA->getName());
}
getTargetCodeGenInfo().setTargetAttributes(D, GO, *this);
}
void CodeGenModule::SetInternalFunctionAttributes(GlobalDecl GD,
llvm::Function *F,
const CGFunctionInfo &FI) {
const Decl *D = GD.getDecl();
SetLLVMFunctionAttributes(D, FI, F);
SetLLVMFunctionAttributesForDefinition(D, F);
F->setLinkage(llvm::Function::InternalLinkage);
setNonAliasAttributes(GD, F);
}
static void setLinkageForGV(llvm::GlobalValue *GV, const NamedDecl *ND) {
// Set linkage and visibility in case we never see a definition.
LinkageInfo LV = ND->getLinkageAndVisibility();
// Don't set internal linkage on declarations.
// "extern_weak" is overloaded in LLVM; we probably should have
// separate linkage types for this.
if (isExternallyVisible(LV.getLinkage()) &&
(ND->hasAttr<WeakAttr>() || ND->isWeakImported()))
GV->setLinkage(llvm::GlobalValue::ExternalWeakLinkage);
}
void CodeGenModule::CreateFunctionTypeMetadata(const FunctionDecl *FD,
llvm::Function *F) {
// Only if we are checking indirect calls.
if (!LangOpts.Sanitize.has(SanitizerKind::CFIICall))
return;
// Non-static class methods are handled via vtable pointer checks elsewhere.
if (isa<CXXMethodDecl>(FD) && !cast<CXXMethodDecl>(FD)->isStatic())
return;
// Additionally, if building with cross-DSO support...
if (CodeGenOpts.SanitizeCfiCrossDso) {
// Skip available_externally functions. They won't be codegen'ed in the
// current module anyway.
if (getContext().GetGVALinkageForFunction(FD) == GVA_AvailableExternally)
return;
}
llvm::Metadata *MD = CreateMetadataIdentifierForType(FD->getType());
F->addTypeMetadata(0, MD);
F->addTypeMetadata(0, CreateMetadataIdentifierGeneralized(FD->getType()));
// Emit a hash-based bit set entry for cross-DSO calls.
if (CodeGenOpts.SanitizeCfiCrossDso)
if (auto CrossDsoTypeId = CreateCrossDsoCfiTypeId(MD))
F->addTypeMetadata(0, llvm::ConstantAsMetadata::get(CrossDsoTypeId));
}
void CodeGenModule::SetFunctionAttributes(GlobalDecl GD, llvm::Function *F,
bool IsIncompleteFunction,
bool IsThunk) {
if (llvm::Intrinsic::ID IID = F->getIntrinsicID()) {
// If this is an intrinsic function, set the function's attributes
// to the intrinsic's attributes.
F->setAttributes(llvm::Intrinsic::getAttributes(getLLVMContext(), IID));
return;
}
const auto *FD = cast<FunctionDecl>(GD.getDecl());
if (!IsIncompleteFunction) {
SetLLVMFunctionAttributes(FD, getTypes().arrangeGlobalDeclaration(GD), F);
// Setup target-specific attributes.
if (F->isDeclaration())
getTargetCodeGenInfo().setTargetAttributes(FD, F, *this);
}
// Add the Returned attribute for "this", except for iOS 5 and earlier
// where substantial code, including the libstdc++ dylib, was compiled with
// GCC and does not actually return "this".
if (!IsThunk && getCXXABI().HasThisReturn(GD) &&
!(getTriple().isiOS() && getTriple().isOSVersionLT(6))) {
assert(!F->arg_empty() &&
F->arg_begin()->getType()
->canLosslesslyBitCastTo(F->getReturnType()) &&
"unexpected this return");
F->addAttribute(1, llvm::Attribute::Returned);
}
// Only a few attributes are set on declarations; these may later be
// overridden by a definition.
setLinkageForGV(F, FD);
setGVProperties(F, FD);
if (FD->getAttr<PragmaClangTextSectionAttr>()) {
F->addFnAttr("implicit-section-name");
}
if (const SectionAttr *SA = FD->getAttr<SectionAttr>())
F->setSection(SA->getName());
if (FD->isReplaceableGlobalAllocationFunction()) {
// A replaceable global allocation function does not act like a builtin by
// default, only if it is invoked by a new-expression or delete-expression.
F->addAttribute(llvm::AttributeList::FunctionIndex,
llvm::Attribute::NoBuiltin);
// A sane operator new returns a non-aliasing pointer.
// FIXME: Also add NonNull attribute to the return value
// for the non-nothrow forms?
auto Kind = FD->getDeclName().getCXXOverloadedOperator();
if (getCodeGenOpts().AssumeSaneOperatorNew &&
(Kind == OO_New || Kind == OO_Array_New))
F->addAttribute(llvm::AttributeList::ReturnIndex,
llvm::Attribute::NoAlias);
}
if (isa<CXXConstructorDecl>(FD) || isa<CXXDestructorDecl>(FD))
F->setUnnamedAddr(llvm::GlobalValue::UnnamedAddr::Global);
else if (const auto *MD = dyn_cast<CXXMethodDecl>(FD))
if (MD->isVirtual())
F->setUnnamedAddr(llvm::GlobalValue::UnnamedAddr::Global);
// Don't emit entries for function declarations in the cross-DSO mode. This
// is handled with better precision by the receiving DSO.
if (!CodeGenOpts.SanitizeCfiCrossDso)
CreateFunctionTypeMetadata(FD, F);
if (getLangOpts().OpenMP && FD->hasAttr<OMPDeclareSimdDeclAttr>())
getOpenMPRuntime().emitDeclareSimdFunction(FD, F);
}
void CodeGenModule::addUsedGlobal(llvm::GlobalValue *GV) {
assert(!GV->isDeclaration() &&
"Only globals with definition can force usage.");
LLVMUsed.emplace_back(GV);
}
void CodeGenModule::addCompilerUsedGlobal(llvm::GlobalValue *GV) {
assert(!GV->isDeclaration() &&
"Only globals with definition can force usage.");
LLVMCompilerUsed.emplace_back(GV);
}
static void emitUsed(CodeGenModule &CGM, StringRef Name,
std::vector<llvm::WeakTrackingVH> &List) {
// Don't create llvm.used if there is no need.
if (List.empty())
return;
// Convert List to what ConstantArray needs.
SmallVector<llvm::Constant*, 8> UsedArray;
UsedArray.resize(List.size());
for (unsigned i = 0, e = List.size(); i != e; ++i) {
UsedArray[i] =
llvm::ConstantExpr::getPointerBitCastOrAddrSpaceCast(
cast<llvm::Constant>(&*List[i]), CGM.Int8PtrTy);
}
if (UsedArray.empty())
return;
llvm::ArrayType *ATy = llvm::ArrayType::get(CGM.Int8PtrTy, UsedArray.size());
auto *GV = new llvm::GlobalVariable(
CGM.getModule(), ATy, false, llvm::GlobalValue::AppendingLinkage,
llvm::ConstantArray::get(ATy, UsedArray), Name);
GV->setSection("llvm.metadata");
}
void CodeGenModule::emitLLVMUsed() {
emitUsed(*this, "llvm.used", LLVMUsed);
emitUsed(*this, "llvm.compiler.used", LLVMCompilerUsed);
}
void CodeGenModule::AppendLinkerOptions(StringRef Opts) {
auto *MDOpts = llvm::MDString::get(getLLVMContext(), Opts);
LinkerOptionsMetadata.push_back(llvm::MDNode::get(getLLVMContext(), MDOpts));
}
void CodeGenModule::AddDetectMismatch(StringRef Name, StringRef Value) {
llvm::SmallString<32> Opt;
getTargetCodeGenInfo().getDetectMismatchOption(Name, Value, Opt);
auto *MDOpts = llvm::MDString::get(getLLVMContext(), Opt);
LinkerOptionsMetadata.push_back(llvm::MDNode::get(getLLVMContext(), MDOpts));
}
void CodeGenModule::AddELFLibDirective(StringRef Lib) {
auto &C = getLLVMContext();
LinkerOptionsMetadata.push_back(llvm::MDNode::get(
C, {llvm::MDString::get(C, "lib"), llvm::MDString::get(C, Lib)}));
}
void CodeGenModule::AddDependentLib(StringRef Lib) {
llvm::SmallString<24> Opt;
getTargetCodeGenInfo().getDependentLibraryOption(Lib, Opt);
auto *MDOpts = llvm::MDString::get(getLLVMContext(), Opt);
LinkerOptionsMetadata.push_back(llvm::MDNode::get(getLLVMContext(), MDOpts));
}
/// Add link options implied by the given module, including modules
/// it depends on, using a postorder walk.
static void addLinkOptionsPostorder(CodeGenModule &CGM, Module *Mod,
SmallVectorImpl<llvm::MDNode *> &Metadata,
llvm::SmallPtrSet<Module *, 16> &Visited) {
// Import this module's parent.
if (Mod->Parent && Visited.insert(Mod->Parent).second) {
addLinkOptionsPostorder(CGM, Mod->Parent, Metadata, Visited);
}
// Import this module's dependencies.
for (unsigned I = Mod->Imports.size(); I > 0; --I) {
if (Visited.insert(Mod->Imports[I - 1]).second)
addLinkOptionsPostorder(CGM, Mod->Imports[I-1], Metadata, Visited);
}
// Add linker options to link against the libraries/frameworks
// described by this module.
llvm::LLVMContext &Context = CGM.getLLVMContext();
// For modules that use export_as for linking, use that module
// name instead.
if (Mod->UseExportAsModuleLinkName)
return;
for (unsigned I = Mod->LinkLibraries.size(); I > 0; --I) {
// Link against a framework. Frameworks are currently Darwin only, so we
// don't to ask TargetCodeGenInfo for the spelling of the linker option.
if (Mod->LinkLibraries[I-1].IsFramework) {
llvm::Metadata *Args[2] = {
llvm::MDString::get(Context, "-framework"),
llvm::MDString::get(Context, Mod->LinkLibraries[I - 1].Library)};
Metadata.push_back(llvm::MDNode::get(Context, Args));
continue;
}
// Link against a library.
llvm::SmallString<24> Opt;
CGM.getTargetCodeGenInfo().getDependentLibraryOption(
Mod->LinkLibraries[I-1].Library, Opt);
auto *OptString = llvm::MDString::get(Context, Opt);
Metadata.push_back(llvm::MDNode::get(Context, OptString));
}
}
void CodeGenModule::EmitModuleLinkOptions() {
// Collect the set of all of the modules we want to visit to emit link
// options, which is essentially the imported modules and all of their
// non-explicit child modules.
llvm::SetVector<clang::Module *> LinkModules;
llvm::SmallPtrSet<clang::Module *, 16> Visited;
SmallVector<clang::Module *, 16> Stack;
// Seed the stack with imported modules.
for (Module *M : ImportedModules) {
// Do not add any link flags when an implementation TU of a module imports
// a header of that same module.
if (M->getTopLevelModuleName() == getLangOpts().CurrentModule &&
!getLangOpts().isCompilingModule())
continue;
if (Visited.insert(M).second)
Stack.push_back(M);
}
// Find all of the modules to import, making a little effort to prune
// non-leaf modules.
while (!Stack.empty()) {
clang::Module *Mod = Stack.pop_back_val();
bool AnyChildren = false;
// Visit the submodules of this module.
for (clang::Module::submodule_iterator Sub = Mod->submodule_begin(),
SubEnd = Mod->submodule_end();
Sub != SubEnd; ++Sub) {
// Skip explicit children; they need to be explicitly imported to be
// linked against.
if ((*Sub)->IsExplicit)
continue;
if (Visited.insert(*Sub).second) {
Stack.push_back(*Sub);
AnyChildren = true;
}
}
// We didn't find any children, so add this module to the list of
// modules to link against.
if (!AnyChildren) {
LinkModules.insert(Mod);
}
}
// Add link options for all of the imported modules in reverse topological
// order. We don't do anything to try to order import link flags with respect
// to linker options inserted by things like #pragma comment().
SmallVector<llvm::MDNode *, 16> MetadataArgs;
Visited.clear();
for (Module *M : LinkModules)
if (Visited.insert(M).second)
addLinkOptionsPostorder(*this, M, MetadataArgs, Visited);
std::reverse(MetadataArgs.begin(), MetadataArgs.end());
LinkerOptionsMetadata.append(MetadataArgs.begin(), MetadataArgs.end());
// Add the linker options metadata flag.
auto *NMD = getModule().getOrInsertNamedMetadata("llvm.linker.options");
for (auto *MD : LinkerOptionsMetadata)
NMD->addOperand(MD);
}
void CodeGenModule::EmitDeferred() {
// Emit code for any potentially referenced deferred decls. Since a
// previously unused static decl may become used during the generation of code
// for a static function, iterate until no changes are made.
if (!DeferredVTables.empty()) {
EmitDeferredVTables();
// Emitting a vtable doesn't directly cause more vtables to
// become deferred, although it can cause functions to be
// emitted that then need those vtables.
assert(DeferredVTables.empty());
}
// Stop if we're out of both deferred vtables and deferred declarations.
if (DeferredDeclsToEmit.empty())
return;
// Grab the list of decls to emit. If EmitGlobalDefinition schedules more
// work, it will not interfere with this.
std::vector<GlobalDecl> CurDeclsToEmit;
CurDeclsToEmit.swap(DeferredDeclsToEmit);
for (GlobalDecl &D : CurDeclsToEmit) {
// We should call GetAddrOfGlobal with IsForDefinition set to true in order
// to get GlobalValue with exactly the type we need, not something that
// might had been created for another decl with the same mangled name but
// different type.
llvm::GlobalValue *GV = dyn_cast<llvm::GlobalValue>(
GetAddrOfGlobal(D, ForDefinition));
// In case of different address spaces, we may still get a cast, even with
// IsForDefinition equal to true. Query mangled names table to get
// GlobalValue.
if (!GV)
GV = GetGlobalValue(getMangledName(D));
// Make sure GetGlobalValue returned non-null.
assert(GV);
// Check to see if we've already emitted this. This is necessary
// for a couple of reasons: first, decls can end up in the
// deferred-decls queue multiple times, and second, decls can end
// up with definitions in unusual ways (e.g. by an extern inline
// function acquiring a strong function redefinition). Just
// ignore these cases.
if (!GV->isDeclaration())
continue;
// Otherwise, emit the definition and move on to the next one.
EmitGlobalDefinition(D, GV);
// If we found out that we need to emit more decls, do that recursively.
// This has the advantage that the decls are emitted in a DFS and related
// ones are close together, which is convenient for testing.
if (!DeferredVTables.empty() || !DeferredDeclsToEmit.empty()) {
EmitDeferred();
assert(DeferredVTables.empty() && DeferredDeclsToEmit.empty());
}
}
}
void CodeGenModule::EmitVTablesOpportunistically() {
// Try to emit external vtables as available_externally if they have emitted
// all inlined virtual functions. It runs after EmitDeferred() and therefore
// is not allowed to create new references to things that need to be emitted
// lazily. Note that it also uses fact that we eagerly emitting RTTI.
assert((OpportunisticVTables.empty() || shouldOpportunisticallyEmitVTables())
&& "Only emit opportunistic vtables with optimizations");
for (const CXXRecordDecl *RD : OpportunisticVTables) {
assert(getVTables().isVTableExternal(RD) &&
"This queue should only contain external vtables");
if (getCXXABI().canSpeculativelyEmitVTable(RD))
VTables.GenerateClassData(RD);
}
OpportunisticVTables.clear();
}
void CodeGenModule::EmitGlobalAnnotations() {
if (Annotations.empty())
return;
// Create a new global variable for the ConstantStruct in the Module.
llvm::Constant *Array = llvm::ConstantArray::get(llvm::ArrayType::get(
Annotations[0]->getType(), Annotations.size()), Annotations);
auto *gv = new llvm::GlobalVariable(getModule(), Array->getType(), false,
llvm::GlobalValue::AppendingLinkage,
Array, "llvm.global.annotations");
gv->setSection(AnnotationSection);
}
llvm::Constant *CodeGenModule::EmitAnnotationString(StringRef Str) {
llvm::Constant *&AStr = AnnotationStrings[Str];
if (AStr)
return AStr;
// Not found yet, create a new global.
llvm::Constant *s = llvm::ConstantDataArray::getString(getLLVMContext(), Str);
auto *gv =
new llvm::GlobalVariable(getModule(), s->getType(), true,
llvm::GlobalValue::PrivateLinkage, s, ".str");
gv->setSection(AnnotationSection);
gv->setUnnamedAddr(llvm::GlobalValue::UnnamedAddr::Global);
AStr = gv;
return gv;
}
llvm::Constant *CodeGenModule::EmitAnnotationUnit(SourceLocation Loc) {
SourceManager &SM = getContext().getSourceManager();
PresumedLoc PLoc = SM.getPresumedLoc(Loc);
if (PLoc.isValid())
return EmitAnnotationString(PLoc.getFilename());
return EmitAnnotationString(SM.getBufferName(Loc));
}
llvm::Constant *CodeGenModule::EmitAnnotationLineNo(SourceLocation L) {
SourceManager &SM = getContext().getSourceManager();
PresumedLoc PLoc = SM.getPresumedLoc(L);
unsigned LineNo = PLoc.isValid() ? PLoc.getLine() :
SM.getExpansionLineNumber(L);
return llvm::ConstantInt::get(Int32Ty, LineNo);
}
llvm::Constant *CodeGenModule::EmitAnnotateAttr(llvm::GlobalValue *GV,
const AnnotateAttr *AA,
SourceLocation L) {
// Get the globals for file name, annotation, and the line number.
llvm::Constant *AnnoGV = EmitAnnotationString(AA->getAnnotation()),
*UnitGV = EmitAnnotationUnit(L),
*LineNoCst = EmitAnnotationLineNo(L);
// Create the ConstantStruct for the global annotation.
llvm::Constant *Fields[4] = {
llvm::ConstantExpr::getBitCast(GV, Int8PtrTy),
llvm::ConstantExpr::getBitCast(AnnoGV, Int8PtrTy),
llvm::ConstantExpr::getBitCast(UnitGV, Int8PtrTy),
LineNoCst
};
return llvm::ConstantStruct::getAnon(Fields);
}
void CodeGenModule::AddGlobalAnnotations(const ValueDecl *D,
llvm::GlobalValue *GV) {
assert(D->hasAttr<AnnotateAttr>() && "no annotate attribute");
// Get the struct elements for these annotations.
for (const auto *I : D->specific_attrs<AnnotateAttr>())
Annotations.push_back(EmitAnnotateAttr(GV, I, D->getLocation()));
}
bool CodeGenModule::isInSanitizerBlacklist(SanitizerMask Kind,
llvm::Function *Fn,
SourceLocation Loc) const {
const auto &SanitizerBL = getContext().getSanitizerBlacklist();
// Blacklist by function name.
if (SanitizerBL.isBlacklistedFunction(Kind, Fn->getName()))
return true;
// Blacklist by location.
if (Loc.isValid())
return SanitizerBL.isBlacklistedLocation(Kind, Loc);
// If location is unknown, this may be a compiler-generated function. Assume
// it's located in the main file.
auto &SM = Context.getSourceManager();
if (const auto *MainFile = SM.getFileEntryForID(SM.getMainFileID())) {
return SanitizerBL.isBlacklistedFile(Kind, MainFile->getName());
}
return false;
}
bool CodeGenModule::isInSanitizerBlacklist(llvm::GlobalVariable *GV,
SourceLocation Loc, QualType Ty,
StringRef Category) const {
// For now globals can be blacklisted only in ASan and KASan.
const SanitizerMask EnabledAsanMask = LangOpts.Sanitize.Mask &
(SanitizerKind::Address | SanitizerKind::KernelAddress |
SanitizerKind::HWAddress | SanitizerKind::KernelHWAddress);
if (!EnabledAsanMask)
return false;
const auto &SanitizerBL = getContext().getSanitizerBlacklist();
if (SanitizerBL.isBlacklistedGlobal(EnabledAsanMask, GV->getName(), Category))
return true;
if (SanitizerBL.isBlacklistedLocation(EnabledAsanMask, Loc, Category))
return true;
// Check global type.
if (!Ty.isNull()) {
// Drill down the array types: if global variable of a fixed type is
// blacklisted, we also don't instrument arrays of them.
while (auto AT = dyn_cast<ArrayType>(Ty.getTypePtr()))
Ty = AT->getElementType();
Ty = Ty.getCanonicalType().getUnqualifiedType();
// We allow to blacklist only record types (classes, structs etc.)
if (Ty->isRecordType()) {
std::string TypeStr = Ty.getAsString(getContext().getPrintingPolicy());
if (SanitizerBL.isBlacklistedType(EnabledAsanMask, TypeStr, Category))
return true;
}
}
return false;
}
bool CodeGenModule::imbueXRayAttrs(llvm::Function *Fn, SourceLocation Loc,
StringRef Category) const {
if (!LangOpts.XRayInstrument)
return false;
const auto &XRayFilter = getContext().getXRayFilter();
using ImbueAttr = XRayFunctionFilter::ImbueAttribute;
auto Attr = ImbueAttr::NONE;
if (Loc.isValid())
Attr = XRayFilter.shouldImbueLocation(Loc, Category);
if (Attr == ImbueAttr::NONE)
Attr = XRayFilter.shouldImbueFunction(Fn->getName());
switch (Attr) {
case ImbueAttr::NONE:
return false;
case ImbueAttr::ALWAYS:
Fn->addFnAttr("function-instrument", "xray-always");
break;
case ImbueAttr::ALWAYS_ARG1:
Fn->addFnAttr("function-instrument", "xray-always");
Fn->addFnAttr("xray-log-args", "1");
break;
case ImbueAttr::NEVER:
Fn->addFnAttr("function-instrument", "xray-never");
break;
}
return true;
}
bool CodeGenModule::MustBeEmitted(const ValueDecl *Global) {
// Never defer when EmitAllDecls is specified.
if (LangOpts.EmitAllDecls)
return true;
return getContext().DeclMustBeEmitted(Global);
}
bool CodeGenModule::MayBeEmittedEagerly(const ValueDecl *Global) {
if (const auto *FD = dyn_cast<FunctionDecl>(Global))
if (FD->getTemplateSpecializationKind() == TSK_ImplicitInstantiation)
// Implicit template instantiations may change linkage if they are later
// explicitly instantiated, so they should not be emitted eagerly.
return false;
if (const auto *VD = dyn_cast<VarDecl>(Global))
if (Context.getInlineVariableDefinitionKind(VD) ==
ASTContext::InlineVariableDefinitionKind::WeakUnknown)
// A definition of an inline constexpr static data member may change
// linkage later if it's redeclared outside the class.
return false;
// If OpenMP is enabled and threadprivates must be generated like TLS, delay
// codegen for global variables, because they may be marked as threadprivate.
if (LangOpts.OpenMP && LangOpts.OpenMPUseTLS &&
getContext().getTargetInfo().isTLSSupported() && isa<VarDecl>(Global))
return false;
return true;
}
ConstantAddress CodeGenModule::GetAddrOfUuidDescriptor(
const CXXUuidofExpr* E) {
// Sema has verified that IIDSource has a __declspec(uuid()), and that its
// well-formed.
StringRef Uuid = E->getUuidStr();
std::string Name = "_GUID_" + Uuid.lower();
std::replace(Name.begin(), Name.end(), '-', '_');
// The UUID descriptor should be pointer aligned.
CharUnits Alignment = CharUnits::fromQuantity(PointerAlignInBytes);
// Look for an existing global.
if (llvm::GlobalVariable *GV = getModule().getNamedGlobal(Name))
return ConstantAddress(GV, Alignment);
llvm::Constant *Init = EmitUuidofInitializer(Uuid);
assert(Init && "failed to initialize as constant");
auto *GV = new llvm::GlobalVariable(
getModule(), Init->getType(),
/*isConstant=*/true, llvm::GlobalValue::LinkOnceODRLinkage, Init, Name);
if (supportsCOMDAT())
GV->setComdat(TheModule.getOrInsertComdat(GV->getName()));
setDSOLocal(GV);
return ConstantAddress(GV, Alignment);
}
ConstantAddress CodeGenModule::GetWeakRefReference(const ValueDecl *VD) {
const AliasAttr *AA = VD->getAttr<AliasAttr>();
assert(AA && "No alias?");
CharUnits Alignment = getContext().getDeclAlign(VD);
llvm::Type *DeclTy = getTypes().ConvertTypeForMem(VD->getType());
// See if there is already something with the target's name in the module.
llvm::GlobalValue *Entry = GetGlobalValue(AA->getAliasee());
if (Entry) {
unsigned AS = getContext().getTargetAddressSpace(VD->getType());
auto Ptr = llvm::ConstantExpr::getBitCast(Entry, DeclTy->getPointerTo(AS));
return ConstantAddress(Ptr, Alignment);
}
llvm::Constant *Aliasee;
if (isa<llvm::FunctionType>(DeclTy))
Aliasee = GetOrCreateLLVMFunction(AA->getAliasee(), DeclTy,
GlobalDecl(cast<FunctionDecl>(VD)),
/*ForVTable=*/false);
else
Aliasee = GetOrCreateLLVMGlobal(AA->getAliasee(),
llvm::PointerType::getUnqual(DeclTy),
nullptr);
auto *F = cast<llvm::GlobalValue>(Aliasee);
F->setLinkage(llvm::Function::ExternalWeakLinkage);
WeakRefReferences.insert(F);
return ConstantAddress(Aliasee, Alignment);
}
void CodeGenModule::EmitGlobal(GlobalDecl GD) {
const auto *Global = cast<ValueDecl>(GD.getDecl());
// Weak references don't produce any output by themselves.
if (Global->hasAttr<WeakRefAttr>())
return;
// If this is an alias definition (which otherwise looks like a declaration)
// emit it now.
if (Global->hasAttr<AliasAttr>())
return EmitAliasDefinition(GD);
// IFunc like an alias whose value is resolved at runtime by calling resolver.
if (Global->hasAttr<IFuncAttr>())
return emitIFuncDefinition(GD);
// If this is CUDA, be selective about which declarations we emit.
if (LangOpts.CUDA) {
if (LangOpts.CUDAIsDevice) {
if (!Global->hasAttr<CUDADeviceAttr>() &&
!Global->hasAttr<CUDAGlobalAttr>() &&
!Global->hasAttr<CUDAConstantAttr>() &&
!Global->hasAttr<CUDASharedAttr>())
return;
} else {
// We need to emit host-side 'shadows' for all global
// device-side variables because the CUDA runtime needs their
// size and host-side address in order to provide access to
// their device-side incarnations.
// So device-only functions are the only things we skip.
if (isa<FunctionDecl>(Global) && !Global->hasAttr<CUDAHostAttr>() &&
Global->hasAttr<CUDADeviceAttr>())
return;
assert((isa<FunctionDecl>(Global) || isa<VarDecl>(Global)) &&
"Expected Variable or Function");
}
}
if (LangOpts.OpenMP) {
// If this is OpenMP device, check if it is legal to emit this global
// normally.
if (OpenMPRuntime && OpenMPRuntime->emitTargetGlobal(GD))
return;
if (auto *DRD = dyn_cast<OMPDeclareReductionDecl>(Global)) {
if (MustBeEmitted(Global))
EmitOMPDeclareReduction(DRD);
return;
}
}
// Ignore declarations, they will be emitted on their first use.
if (const auto *FD = dyn_cast<FunctionDecl>(Global)) {
// Forward declarations are emitted lazily on first use.
if (!FD->doesThisDeclarationHaveABody()) {
if (!FD->doesDeclarationForceExternallyVisibleDefinition())
return;
StringRef MangledName = getMangledName(GD);
// Compute the function info and LLVM type.
const CGFunctionInfo &FI = getTypes().arrangeGlobalDeclaration(GD);
llvm::Type *Ty = getTypes().GetFunctionType(FI);
GetOrCreateLLVMFunction(MangledName, Ty, GD, /*ForVTable=*/false,
/*DontDefer=*/false);
return;
}
} else {
const auto *VD = cast<VarDecl>(Global);
assert(VD->isFileVarDecl() && "Cannot emit local var decl as global.");
// We need to emit device-side global CUDA variables even if a
// variable does not have a definition -- we still need to define
// host-side shadow for it.
bool MustEmitForCuda = LangOpts.CUDA && !LangOpts.CUDAIsDevice &&
!VD->hasDefinition() &&
(VD->hasAttr<CUDAConstantAttr>() ||
VD->hasAttr<CUDADeviceAttr>());
if (!MustEmitForCuda &&
VD->isThisDeclarationADefinition() != VarDecl::Definition &&
!Context.isMSStaticDataMemberInlineDefinition(VD)) {
// If this declaration may have caused an inline variable definition to
// change linkage, make sure that it's emitted.
if (Context.getInlineVariableDefinitionKind(VD) ==
ASTContext::InlineVariableDefinitionKind::Strong)
GetAddrOfGlobalVar(VD);
return;
}
}
// Defer code generation to first use when possible, e.g. if this is an inline
// function. If the global must always be emitted, do it eagerly if possible
// to benefit from cache locality.
if (MustBeEmitted(Global) && MayBeEmittedEagerly(Global)) {
// Emit the definition if it can't be deferred.
EmitGlobalDefinition(GD);
return;
}
// If we're deferring emission of a C++ variable with an
// initializer, remember the order in which it appeared in the file.
if (getLangOpts().CPlusPlus && isa<VarDecl>(Global) &&
cast<VarDecl>(Global)->hasInit()) {
DelayedCXXInitPosition[Global] = CXXGlobalInits.size();
CXXGlobalInits.push_back(nullptr);
}
StringRef MangledName = getMangledName(GD);
if (GetGlobalValue(MangledName) != nullptr) {
// The value has already been used and should therefore be emitted.
addDeferredDeclToEmit(GD);
} else if (MustBeEmitted(Global)) {
// The value must be emitted, but cannot be emitted eagerly.
assert(!MayBeEmittedEagerly(Global));
addDeferredDeclToEmit(GD);
} else {
// Otherwise, remember that we saw a deferred decl with this name. The
// first use of the mangled name will cause it to move into
// DeferredDeclsToEmit.
DeferredDecls[MangledName] = GD;
}
}
// Check if T is a class type with a destructor that's not dllimport.
static bool HasNonDllImportDtor(QualType T) {
if (const auto *RT = T->getBaseElementTypeUnsafe()->getAs<RecordType>())
if (CXXRecordDecl *RD = dyn_cast<CXXRecordDecl>(RT->getDecl()))
if (RD->getDestructor() && !RD->getDestructor()->hasAttr<DLLImportAttr>())
return true;
return false;
}
namespace {
struct FunctionIsDirectlyRecursive :
public RecursiveASTVisitor<FunctionIsDirectlyRecursive> {
const StringRef Name;
const Builtin::Context &BI;
bool Result;
FunctionIsDirectlyRecursive(StringRef N, const Builtin::Context &C) :
Name(N), BI(C), Result(false) {
}
typedef RecursiveASTVisitor<FunctionIsDirectlyRecursive> Base;
bool TraverseCallExpr(CallExpr *E) {
const FunctionDecl *FD = E->getDirectCallee();
if (!FD)
return true;
AsmLabelAttr *Attr = FD->getAttr<AsmLabelAttr>();
if (Attr && Name == Attr->getLabel()) {
Result = true;
return false;
}
unsigned BuiltinID = FD->getBuiltinID();
if (!BuiltinID || !BI.isLibFunction(BuiltinID))
return true;
StringRef BuiltinName = BI.getName(BuiltinID);
if (BuiltinName.startswith("__builtin_") &&
Name == BuiltinName.slice(strlen("__builtin_"), StringRef::npos)) {
Result = true;
return false;
}
return true;
}
};
// Make sure we're not referencing non-imported vars or functions.
struct DLLImportFunctionVisitor
: public RecursiveASTVisitor<DLLImportFunctionVisitor> {
bool SafeToInline = true;
bool shouldVisitImplicitCode() const { return true; }
bool VisitVarDecl(VarDecl *VD) {
if (VD->getTLSKind()) {
// A thread-local variable cannot be imported.
SafeToInline = false;
return SafeToInline;
}
// A variable definition might imply a destructor call.
if (VD->isThisDeclarationADefinition())
SafeToInline = !HasNonDllImportDtor(VD->getType());
return SafeToInline;
}
bool VisitCXXBindTemporaryExpr(CXXBindTemporaryExpr *E) {
if (const auto *D = E->getTemporary()->getDestructor())
SafeToInline = D->hasAttr<DLLImportAttr>();
return SafeToInline;
}
bool VisitDeclRefExpr(DeclRefExpr *E) {
ValueDecl *VD = E->getDecl();
if (isa<FunctionDecl>(VD))
SafeToInline = VD->hasAttr<DLLImportAttr>();
else if (VarDecl *V = dyn_cast<VarDecl>(VD))
SafeToInline = !V->hasGlobalStorage() || V->hasAttr<DLLImportAttr>();
return SafeToInline;
}
bool VisitCXXConstructExpr(CXXConstructExpr *E) {
SafeToInline = E->getConstructor()->hasAttr<DLLImportAttr>();
return SafeToInline;
}
bool VisitCXXMemberCallExpr(CXXMemberCallExpr *E) {
CXXMethodDecl *M = E->getMethodDecl();
if (!M) {
// Call through a pointer to member function. This is safe to inline.
SafeToInline = true;
} else {
SafeToInline = M->hasAttr<DLLImportAttr>();
}
return SafeToInline;
}
bool VisitCXXDeleteExpr(CXXDeleteExpr *E) {
SafeToInline = E->getOperatorDelete()->hasAttr<DLLImportAttr>();
return SafeToInline;
}
bool VisitCXXNewExpr(CXXNewExpr *E) {
SafeToInline = E->getOperatorNew()->hasAttr<DLLImportAttr>();
return SafeToInline;
}
};
}
// isTriviallyRecursive - Check if this function calls another
// decl that, because of the asm attribute or the other decl being a builtin,
// ends up pointing to itself.
bool
CodeGenModule::isTriviallyRecursive(const FunctionDecl *FD) {
StringRef Name;
if (getCXXABI().getMangleContext().shouldMangleDeclName(FD)) {
// asm labels are a special kind of mangling we have to support.
AsmLabelAttr *Attr = FD->getAttr<AsmLabelAttr>();
if (!Attr)
return false;
Name = Attr->getLabel();
} else {
Name = FD->getName();
}
FunctionIsDirectlyRecursive Walker(Name, Context.BuiltinInfo);
Walker.TraverseFunctionDecl(const_cast<FunctionDecl*>(FD));
return Walker.Result;
}
bool CodeGenModule::shouldEmitFunction(GlobalDecl GD) {
if (getFunctionLinkage(GD) != llvm::Function::AvailableExternallyLinkage)
return true;
const auto *F = cast<FunctionDecl>(GD.getDecl());
if (CodeGenOpts.OptimizationLevel == 0 && !F->hasAttr<AlwaysInlineAttr>())
return false;
if (F->hasAttr<DLLImportAttr>()) {
// Check whether it would be safe to inline this dllimport function.
DLLImportFunctionVisitor Visitor;
Visitor.TraverseFunctionDecl(const_cast<FunctionDecl*>(F));
if (!Visitor.SafeToInline)
return false;
if (const CXXDestructorDecl *Dtor = dyn_cast<CXXDestructorDecl>(F)) {
// Implicit destructor invocations aren't captured in the AST, so the
// check above can't see them. Check for them manually here.
for (const Decl *Member : Dtor->getParent()->decls())
if (isa<FieldDecl>(Member))
if (HasNonDllImportDtor(cast<FieldDecl>(Member)->getType()))
return false;
for (const CXXBaseSpecifier &B : Dtor->getParent()->bases())
if (HasNonDllImportDtor(B.getType()))
return false;
}
}
// PR9614. Avoid cases where the source code is lying to us. An available
// externally function should have an equivalent function somewhere else,
// but a function that calls itself is clearly not equivalent to the real
// implementation.
// This happens in glibc's btowc and in some configure checks.
return !isTriviallyRecursive(F);
}
bool CodeGenModule::shouldOpportunisticallyEmitVTables() {
return CodeGenOpts.OptimizationLevel > 0;
}
void CodeGenModule::EmitGlobalDefinition(GlobalDecl GD, llvm::GlobalValue *GV) {
const auto *D = cast<ValueDecl>(GD.getDecl());
PrettyStackTraceDecl CrashInfo(const_cast<ValueDecl *>(D), D->getLocation(),
Context.getSourceManager(),
"Generating code for declaration");
if (isa<FunctionDecl>(D)) {
// At -O0, don't generate IR for functions with available_externally
// linkage.
if (!shouldEmitFunction(GD))
return;
if (const auto *Method = dyn_cast<CXXMethodDecl>(D)) {
// Make sure to emit the definition(s) before we emit the thunks.
// This is necessary for the generation of certain thunks.
if (const auto *CD = dyn_cast<CXXConstructorDecl>(Method))
ABI->emitCXXStructor(CD, getFromCtorType(GD.getCtorType()));
else if (const auto *DD = dyn_cast<CXXDestructorDecl>(Method))
ABI->emitCXXStructor(DD, getFromDtorType(GD.getDtorType()));
else
EmitGlobalFunctionDefinition(GD, GV);
if (Method->isVirtual())
getVTables().EmitThunks(GD);
return;
}
return EmitGlobalFunctionDefinition(GD, GV);
}
if (const auto *VD = dyn_cast<VarDecl>(D))
return EmitGlobalVarDefinition(VD, !VD->hasDefinition());
llvm_unreachable("Invalid argument to EmitGlobalDefinition()");
}
static void ReplaceUsesOfNonProtoTypeWithRealFunction(llvm::GlobalValue *Old,
llvm::Function *NewFn);
void CodeGenModule::emitMultiVersionFunctions() {
for (GlobalDecl GD : MultiVersionFuncs) {
SmallVector<CodeGenFunction::MultiVersionResolverOption, 10> Options;
const FunctionDecl *FD = cast<FunctionDecl>(GD.getDecl());
getContext().forEachMultiversionedFunctionVersion(
FD, [this, &GD, &Options](const FunctionDecl *CurFD) {
GlobalDecl CurGD{
(CurFD->isDefined() ? CurFD->getDefinition() : CurFD)};
StringRef MangledName = getMangledName(CurGD);
llvm::Constant *Func = GetGlobalValue(MangledName);
if (!Func) {
if (CurFD->isDefined()) {
EmitGlobalFunctionDefinition(CurGD, nullptr);
Func = GetGlobalValue(MangledName);
} else {
const CGFunctionInfo &FI =
getTypes().arrangeGlobalDeclaration(GD);
llvm::FunctionType *Ty = getTypes().GetFunctionType(FI);
Func = GetAddrOfFunction(CurGD, Ty, /*ForVTable=*/false,
/*DontDefer=*/false, ForDefinition);
}
assert(Func && "This should have just been created");
}
Options.emplace_back(getTarget(), cast<llvm::Function>(Func),
CurFD->getAttr<TargetAttr>()->parse());
});
llvm::Function *ResolverFunc = cast<llvm::Function>(
GetGlobalValue((getMangledName(GD) + ".resolver").str()));
if (supportsCOMDAT())
ResolverFunc->setComdat(
getModule().getOrInsertComdat(ResolverFunc->getName()));
std::stable_sort(
Options.begin(), Options.end(),
std::greater<CodeGenFunction::MultiVersionResolverOption>());
CodeGenFunction CGF(*this);
CGF.EmitMultiVersionResolver(ResolverFunc, Options);
}
}
/// If an ifunc for the specified mangled name is not in the module, create and
/// return an llvm IFunc Function with the specified type.
llvm::Constant *
CodeGenModule::GetOrCreateMultiVersionIFunc(GlobalDecl GD, llvm::Type *DeclTy,
StringRef MangledName,
const FunctionDecl *FD) {
std::string IFuncName = (MangledName + ".ifunc").str();
if (llvm::GlobalValue *IFuncGV = GetGlobalValue(IFuncName))
return IFuncGV;
// Since this is the first time we've created this IFunc, make sure
// that we put this multiversioned function into the list to be
// replaced later.
MultiVersionFuncs.push_back(GD);
std::string ResolverName = (MangledName + ".resolver").str();
llvm::Type *ResolverType = llvm::FunctionType::get(
llvm::PointerType::get(DeclTy,
Context.getTargetAddressSpace(FD->getType())),
false);
llvm::Constant *Resolver =
GetOrCreateLLVMFunction(ResolverName, ResolverType, GlobalDecl{},
/*ForVTable=*/false);
llvm::GlobalIFunc *GIF = llvm::GlobalIFunc::create(
DeclTy, 0, llvm::Function::ExternalLinkage, "", Resolver, &getModule());
GIF->setName(IFuncName);
SetCommonAttributes(FD, GIF);
return GIF;
}
/// GetOrCreateLLVMFunction - If the specified mangled name is not in the
/// module, create and return an llvm Function with the specified type. If there
/// is something in the module with the specified name, return it potentially
/// bitcasted to the right type.
///
/// If D is non-null, it specifies a decl that correspond to this. This is used
/// to set the attributes on the function when it is first created.
llvm::Constant *CodeGenModule::GetOrCreateLLVMFunction(
StringRef MangledName, llvm::Type *Ty, GlobalDecl GD, bool ForVTable,
bool DontDefer, bool IsThunk, llvm::AttributeList ExtraAttrs,
ForDefinition_t IsForDefinition) {
const Decl *D = GD.getDecl();
bool isWasmImport = false;
bool isWasmEntry = false;
bool isWasmABI = false;
bool isWasmAction = false;
bool isWasmNotify = false;
// Any attempts to use a MultiVersion function should result in retrieving
// the iFunc instead. Name Mangling will handle the rest of the changes.
if (const FunctionDecl *FD = cast_or_null<FunctionDecl>(D)) {
// if (FD->hasAttr<EosioWasmImportAttr>())
// isWasmImport = true;
// if (FD->hasAttr<EosioWasmEntryAttr>())
// isWasmEntry = true;
// if (FD->hasAttr<EosioWasmABIAttr>())
// isWasmABI = true;
// if (FD->hasAttr<EosioWasmActionAttr>())
// isWasmAction = true;
// if (FD->hasAttr<EosioWasmNotifyAttr>())
// isWasmNotify = true;
if (FD->hasAttr<WasmWasmImportAttr>())
isWasmImport = true;
if (FD->hasAttr<WasmWasmEntryAttr>())
isWasmEntry = true;
if (FD->hasAttr<WasmWasmABIAttr>())
isWasmABI = true;
if (FD->hasAttr<WasmWasmActionAttr>())
isWasmAction = true;
if (FD->hasAttr<WasmWasmNotifyAttr>())
isWasmNotify = true;
// For the device mark the function as one that should be emitted.
if (getLangOpts().OpenMPIsDevice && OpenMPRuntime &&
!OpenMPRuntime->markAsGlobalTarget(GD) && FD->isDefined() &&
!DontDefer && !IsForDefinition) {
const FunctionDecl *FDDef = FD->getDefinition();
GlobalDecl GDDef;
if (const auto *CD = dyn_cast<CXXConstructorDecl>(FDDef))
GDDef = GlobalDecl(CD, GD.getCtorType());
else if (const auto *DD = dyn_cast<CXXDestructorDecl>(FDDef))
GDDef = GlobalDecl(DD, GD.getDtorType());
else
GDDef = GlobalDecl(FDDef);
addDeferredDeclToEmit(GDDef);
}
if (FD->isMultiVersion() && FD->getAttr<TargetAttr>()->isDefaultVersion()) {
UpdateMultiVersionNames(GD, FD);
if (!IsForDefinition)
return GetOrCreateMultiVersionIFunc(GD, Ty, MangledName, FD);
}
}
// Lookup the entry, lazily creating it if necessary.
llvm::GlobalValue *Entry = GetGlobalValue(MangledName);
if (Entry) {
if (WeakRefReferences.erase(Entry)) {
const FunctionDecl *FD = cast_or_null<FunctionDecl>(D);
if (FD && !FD->hasAttr<WeakAttr>())
Entry->setLinkage(llvm::Function::ExternalLinkage);
}
// Handle dropped DLL attributes.
if (D && !D->hasAttr<DLLImportAttr>() && !D->hasAttr<DLLExportAttr>()) {
Entry->setDLLStorageClass(llvm::GlobalValue::DefaultStorageClass);
setDSOLocal(Entry);
}
// If there are two attempts to define the same mangled name, issue an
// error.
if (IsForDefinition && !Entry->isDeclaration()) {
GlobalDecl OtherGD;
// Check that GD is not yet in DiagnosedConflictingDefinitions is required
// to make sure that we issue an error only once.
if (lookupRepresentativeDecl(MangledName, OtherGD) &&
(GD.getCanonicalDecl().getDecl() !=
OtherGD.getCanonicalDecl().getDecl()) &&
DiagnosedConflictingDefinitions.insert(GD).second) {
getDiags().Report(D->getLocation(), diag::err_duplicate_mangled_name)
<< MangledName;
getDiags().Report(OtherGD.getDecl()->getLocation(),
diag::note_previous_definition);
}
}
if ((isa<llvm::Function>(Entry) || isa<llvm::GlobalAlias>(Entry)) &&
(Entry->getType()->getElementType() == Ty)) {
return Entry;
}
// Make sure the result is of the correct type.
// (If function is requested for a definition, we always need to create a new
// function, not just return a bitcast.)
if (!IsForDefinition)
return llvm::ConstantExpr::getBitCast(Entry, Ty->getPointerTo());
}
// This function doesn't have a complete type (for example, the return
// type is an incomplete struct). Use a fake type instead, and make
// sure not to try to set attributes.
bool IsIncompleteFunction = false;
llvm::FunctionType *FTy;
if (isa<llvm::FunctionType>(Ty)) {
FTy = cast<llvm::FunctionType>(Ty);
} else {
FTy = llvm::FunctionType::get(VoidTy, false);
IsIncompleteFunction = true;
}
llvm::Function *F =
llvm::Function::Create(FTy, llvm::Function::ExternalLinkage,
Entry ? StringRef() : MangledName, &getModule());
// If we already created a function with the same mangled name (but different
// type) before, take its name and add it to the list of functions to be
// replaced with F at the end of CodeGen.
//
// This happens if there is a prototype for a function (e.g. "int f()") and
// then a definition of a different type (e.g. "int f(int x)").
if (Entry) {
F->takeName(Entry);
// This might be an implementation of a function without a prototype, in
// which case, try to do special replacement of calls which match the new
// prototype. The really key thing here is that we also potentially drop
// arguments from the call site so as to make a direct call, which makes the
// inliner happier and suppresses a number of optimizer warnings (!) about
// dropping arguments.
if (!Entry->use_empty()) {
ReplaceUsesOfNonProtoTypeWithRealFunction(Entry, F);
Entry->removeDeadConstantUsers();
}
llvm::Constant *BC = llvm::ConstantExpr::getBitCast(
F, Entry->getType()->getElementType()->getPointerTo());
addGlobalValReplacement(Entry, BC);
}
assert(F->getName() == MangledName && "name was uniqued!");
if (D)
SetFunctionAttributes(GD, F, IsIncompleteFunction, IsThunk);
if (ExtraAttrs.hasAttributes(llvm::AttributeList::FunctionIndex)) {
llvm::AttrBuilder B(ExtraAttrs, llvm::AttributeList::FunctionIndex);
F->addAttributes(llvm::AttributeList::FunctionIndex, B);
}
//xiaoyu
if (isWasmImport)
F->addFnAttr("wasm_wasm_import", "true");
if (isWasmEntry)
F->addFnAttr("wasm_wasm_entry", "true");
if (isWasmABI)
if (const FunctionDecl *FD = cast_or_null<FunctionDecl>(D)) {
F->addFnAttr("wasm_wasm_abi", FD->getWasmWasmABI().c_str());
}
if (isWasmAction)
if (const FunctionDecl *FD = cast_or_null<FunctionDecl>(D)) {
F->addFnAttr("wasm_wasm_action", FD->getWasmWasmAction().c_str());
}
if (isWasmNotify)
if (const FunctionDecl *FD = cast_or_null<FunctionDecl>(D)) {
F->addFnAttr("wasm_wasm_notify", FD->getWasmWasmNotify().c_str());
}
if (!DontDefer) {
// All MSVC dtors other than the base dtor are linkonce_odr and delegate to
// each other bottoming out with the base dtor. Therefore we emit non-base
// dtors on usage, even if there is no dtor definition in the TU.
if (D && isa<CXXDestructorDecl>(D) &&
getCXXABI().useThunkForDtorVariant(cast<CXXDestructorDecl>(D),
GD.getDtorType()))
addDeferredDeclToEmit(GD);
// This is the first use or definition of a mangled name. If there is a
// deferred decl with this name, remember that we need to emit it at the end
// of the file.
auto DDI = DeferredDecls.find(MangledName);
if (DDI != DeferredDecls.end()) {
// Move the potentially referenced deferred decl to the
// DeferredDeclsToEmit list, and remove it from DeferredDecls (since we
// don't need it anymore).
addDeferredDeclToEmit(DDI->second);
DeferredDecls.erase(DDI);
// Otherwise, there are cases we have to worry about where we're
// using a declaration for which we must emit a definition but where
// we might not find a top-level definition:
// - member functions defined inline in their classes
// - friend functions defined inline in some class
// - special member functions with implicit definitions
// If we ever change our AST traversal to walk into class methods,
// this will be unnecessary.
//
// We also don't emit a definition for a function if it's going to be an
// entry in a vtable, unless it's already marked as used.
} else if (getLangOpts().CPlusPlus && D) {
// Look for a declaration that's lexically in a record.
for (const auto *FD = cast<FunctionDecl>(D)->getMostRecentDecl(); FD;
FD = FD->getPreviousDecl()) {
if (isa<CXXRecordDecl>(FD->getLexicalDeclContext())) {
if (FD->doesThisDeclarationHaveABody()) {
addDeferredDeclToEmit(GD.getWithDecl(FD));
break;
}
}
}
}
}
// Make sure the result is of the requested type.
if (!IsIncompleteFunction) {
assert(F->getType()->getElementType() == Ty);
return F;
}
llvm::Type *PTy = llvm::PointerType::getUnqual(Ty);
return llvm::ConstantExpr::getBitCast(F, PTy);
}
/// GetAddrOfFunction - Return the address of the given function. If Ty is
/// non-null, then this function will use the specified type if it has to
/// create it (this occurs when we see a definition of the function).
llvm::Constant *CodeGenModule::GetAddrOfFunction(GlobalDecl GD,
llvm::Type *Ty,
bool ForVTable,
bool DontDefer,
ForDefinition_t IsForDefinition) {
// If there was no specific requested type, just convert it now.
if (!Ty) {
const auto *FD = cast<FunctionDecl>(GD.getDecl());
auto CanonTy = Context.getCanonicalType(FD->getType());
Ty = getTypes().ConvertFunctionType(CanonTy, FD);
}
// Devirtualized destructor calls may come through here instead of via
// getAddrOfCXXStructor. Make sure we use the MS ABI base destructor instead
// of the complete destructor when necessary.
if (const auto *DD = dyn_cast<CXXDestructorDecl>(GD.getDecl())) {
if (getTarget().getCXXABI().isMicrosoft() &&
GD.getDtorType() == Dtor_Complete &&
DD->getParent()->getNumVBases() == 0)
GD = GlobalDecl(DD, Dtor_Base);
}
StringRef MangledName = getMangledName(GD);
return GetOrCreateLLVMFunction(MangledName, Ty, GD, ForVTable, DontDefer,
/*IsThunk=*/false, llvm::AttributeList(),
IsForDefinition);
}
static const FunctionDecl *
GetRuntimeFunctionDecl(ASTContext &C, StringRef Name) {
TranslationUnitDecl *TUDecl = C.getTranslationUnitDecl();
DeclContext *DC = TranslationUnitDecl::castToDeclContext(TUDecl);
IdentifierInfo &CII = C.Idents.get(Name);
for (const auto &Result : DC->lookup(&CII))
if (const auto FD = dyn_cast<FunctionDecl>(Result))
return FD;
if (!C.getLangOpts().CPlusPlus)
return nullptr;
// Demangle the premangled name from getTerminateFn()
IdentifierInfo &CXXII =
(Name == "_ZSt9terminatev" || Name == "?terminate@@YAXXZ")
? C.Idents.get("terminate")
: C.Idents.get(Name);
for (const auto &N : {"__cxxabiv1", "std"}) {
IdentifierInfo &NS = C.Idents.get(N);
for (const auto &Result : DC->lookup(&NS)) {
NamespaceDecl *ND = dyn_cast<NamespaceDecl>(Result);
if (auto LSD = dyn_cast<LinkageSpecDecl>(Result))
for (const auto &Result : LSD->lookup(&NS))
if ((ND = dyn_cast<NamespaceDecl>(Result)))
break;
if (ND)
for (const auto &Result : ND->lookup(&CXXII))
if (const auto *FD = dyn_cast<FunctionDecl>(Result))
return FD;
}
}
return nullptr;
}
/// CreateRuntimeFunction - Create a new runtime function with the specified
/// type and name.
llvm::Constant *
CodeGenModule::CreateRuntimeFunction(llvm::FunctionType *FTy, StringRef Name,
llvm::AttributeList ExtraAttrs,
bool Local) {
llvm::Constant *C =
GetOrCreateLLVMFunction(Name, FTy, GlobalDecl(), /*ForVTable=*/false,
/*DontDefer=*/false, /*IsThunk=*/false,
ExtraAttrs);
if (auto *F = dyn_cast<llvm::Function>(C)) {
if (F->empty()) {
F->setCallingConv(getRuntimeCC());
if (!Local && getTriple().isOSBinFormatCOFF() &&
!getCodeGenOpts().LTOVisibilityPublicStd &&
!getTriple().isWindowsGNUEnvironment()) {
const FunctionDecl *FD = GetRuntimeFunctionDecl(Context, Name);
if (!FD || FD->hasAttr<DLLImportAttr>()) {
F->setDLLStorageClass(llvm::GlobalValue::DLLImportStorageClass);
F->setLinkage(llvm::GlobalValue::ExternalLinkage);
}
}
setDSOLocal(F);
}
}
return C;
}
/// CreateBuiltinFunction - Create a new builtin function with the specified
/// type and name.
llvm::Constant *
CodeGenModule::CreateBuiltinFunction(llvm::FunctionType *FTy, StringRef Name,
llvm::AttributeList ExtraAttrs) {
return CreateRuntimeFunction(FTy, Name, ExtraAttrs, true);
}
/// isTypeConstant - Determine whether an object of this type can be emitted
/// as a constant.
///
/// If ExcludeCtor is true, the duration when the object's constructor runs
/// will not be considered. The caller will need to verify that the object is
/// not written to during its construction.
bool CodeGenModule::isTypeConstant(QualType Ty, bool ExcludeCtor) {
if (!Ty.isConstant(Context) && !Ty->isReferenceType())
return false;
if (Context.getLangOpts().CPlusPlus) {
if (const CXXRecordDecl *Record
= Context.getBaseElementType(Ty)->getAsCXXRecordDecl())
return ExcludeCtor && !Record->hasMutableFields() &&
Record->hasTrivialDestructor();
}
return true;
}
/// GetOrCreateLLVMGlobal - If the specified mangled name is not in the module,
/// create and return an llvm GlobalVariable with the specified type. If there
/// is something in the module with the specified name, return it potentially
/// bitcasted to the right type.
///
/// If D is non-null, it specifies a decl that correspond to this. This is used
/// to set the attributes on the global when it is first created.
///
/// If IsForDefinition is true, it is guaranteed that an actual global with
/// type Ty will be returned, not conversion of a variable with the same
/// mangled name but some other type.
llvm::Constant *
CodeGenModule::GetOrCreateLLVMGlobal(StringRef MangledName,
llvm::PointerType *Ty,
const VarDecl *D,
ForDefinition_t IsForDefinition) {
// Lookup the entry, lazily creating it if necessary.
llvm::GlobalValue *Entry = GetGlobalValue(MangledName);
if (Entry) {
if (WeakRefReferences.erase(Entry)) {
if (D && !D->hasAttr<WeakAttr>())
Entry->setLinkage(llvm::Function::ExternalLinkage);
}
// Handle dropped DLL attributes.
if (D && !D->hasAttr<DLLImportAttr>() && !D->hasAttr<DLLExportAttr>())
Entry->setDLLStorageClass(llvm::GlobalValue::DefaultStorageClass);
if (LangOpts.OpenMP && !LangOpts.OpenMPSimd && D)
getOpenMPRuntime().registerTargetGlobalVariable(D, Entry);
if (Entry->getType() == Ty)
return Entry;
// If there are two attempts to define the same mangled name, issue an
// error.
if (IsForDefinition && !Entry->isDeclaration()) {
GlobalDecl OtherGD;
const VarDecl *OtherD;
// Check that D is not yet in DiagnosedConflictingDefinitions is required
// to make sure that we issue an error only once.
if (D && lookupRepresentativeDecl(MangledName, OtherGD) &&
(D->getCanonicalDecl() != OtherGD.getCanonicalDecl().getDecl()) &&
(OtherD = dyn_cast<VarDecl>(OtherGD.getDecl())) &&
OtherD->hasInit() &&
DiagnosedConflictingDefinitions.insert(D).second) {
getDiags().Report(D->getLocation(), diag::err_duplicate_mangled_name)
<< MangledName;
getDiags().Report(OtherGD.getDecl()->getLocation(),
diag::note_previous_definition);
}
}
// Make sure the result is of the correct type.
if (Entry->getType()->getAddressSpace() != Ty->getAddressSpace())
return llvm::ConstantExpr::getAddrSpaceCast(Entry, Ty);
// (If global is requested for a definition, we always need to create a new
// global, not just return a bitcast.)
if (!IsForDefinition)
return llvm::ConstantExpr::getBitCast(Entry, Ty);
}
auto AddrSpace = GetGlobalVarAddressSpace(D);
auto TargetAddrSpace = getContext().getTargetAddressSpace(AddrSpace);
auto *GV = new llvm::GlobalVariable(
getModule(), Ty->getElementType(), false,
llvm::GlobalValue::ExternalLinkage, nullptr, MangledName, nullptr,
llvm::GlobalVariable::NotThreadLocal, TargetAddrSpace);
// If we already created a global with the same mangled name (but different
// type) before, take its name and remove it from its parent.
if (Entry) {
GV->takeName(Entry);
if (!Entry->use_empty()) {
llvm::Constant *NewPtrForOldDecl =
llvm::ConstantExpr::getBitCast(GV, Entry->getType());
Entry->replaceAllUsesWith(NewPtrForOldDecl);
}
Entry->eraseFromParent();
}
// This is the first use or definition of a mangled name. If there is a
// deferred decl with this name, remember that we need to emit it at the end
// of the file.
auto DDI = DeferredDecls.find(MangledName);
if (DDI != DeferredDecls.end()) {
// Move the potentially referenced deferred decl to the DeferredDeclsToEmit
// list, and remove it from DeferredDecls (since we don't need it anymore).
addDeferredDeclToEmit(DDI->second);
DeferredDecls.erase(DDI);
}
// Handle things which are present even on external declarations.
if (D) {
if (LangOpts.OpenMP && !LangOpts.OpenMPSimd)
getOpenMPRuntime().registerTargetGlobalVariable(D, GV);
// FIXME: This code is overly simple and should be merged with other global
// handling.
GV->setConstant(isTypeConstant(D->getType(), false));
GV->setAlignment(getContext().getDeclAlign(D).getQuantity());
setLinkageForGV(GV, D);
if (D->getTLSKind()) {
if (D->getTLSKind() == VarDecl::TLS_Dynamic)
CXXThreadLocals.push_back(D);
setTLSMode(GV, *D);
}
setGVProperties(GV, D);
// If required by the ABI, treat declarations of static data members with
// inline initializers as definitions.
if (getContext().isMSStaticDataMemberInlineDefinition(D)) {
EmitGlobalVarDefinition(D);
}
// Emit section information for extern variables.
if (D->hasExternalStorage()) {
if (const SectionAttr *SA = D->getAttr<SectionAttr>())
GV->setSection(SA->getName());
}
// Handle XCore specific ABI requirements.
if (getTriple().getArch() == llvm::Triple::xcore &&
D->getLanguageLinkage() == CLanguageLinkage &&
D->getType().isConstant(Context) &&
isExternallyVisible(D->getLinkageAndVisibility().getLinkage()))
GV->setSection(".cp.rodata");
// Check if we a have a const declaration with an initializer, we may be
// able to emit it as available_externally to expose it's value to the
// optimizer.
if (Context.getLangOpts().CPlusPlus && GV->hasExternalLinkage() &&
D->getType().isConstQualified() && !GV->hasInitializer() &&
!D->hasDefinition() && D->hasInit() && !D->hasAttr<DLLImportAttr>()) {
const auto *Record =
Context.getBaseElementType(D->getType())->getAsCXXRecordDecl();
bool HasMutableFields = Record && Record->hasMutableFields();
if (!HasMutableFields) {
const VarDecl *InitDecl;
const Expr *InitExpr = D->getAnyInitializer(InitDecl);
if (InitExpr) {
ConstantEmitter emitter(*this);
llvm::Constant *Init = emitter.tryEmitForInitializer(*InitDecl);
if (Init) {
auto *InitType = Init->getType();
if (GV->getType()->getElementType() != InitType) {
// The type of the initializer does not match the definition.
// This happens when an initializer has a different type from
// the type of the global (because of padding at the end of a
// structure for instance).
GV->setName(StringRef());
// Make a new global with the correct type, this is now guaranteed
// to work.
auto *NewGV = cast<llvm::GlobalVariable>(
GetAddrOfGlobalVar(D, InitType, IsForDefinition));
// Erase the old global, since it is no longer used.
GV->eraseFromParent();
GV = NewGV;
} else {
GV->setInitializer(Init);
GV->setConstant(true);
GV->setLinkage(llvm::GlobalValue::AvailableExternallyLinkage);
}
emitter.finalize(GV);
}
}
}
}
}
LangAS ExpectedAS =
D ? D->getType().getAddressSpace()
: (LangOpts.OpenCL ? LangAS::opencl_global : LangAS::Default);
assert(getContext().getTargetAddressSpace(ExpectedAS) ==
Ty->getPointerAddressSpace());
if (AddrSpace != ExpectedAS)
return getTargetCodeGenInfo().performAddrSpaceCast(*this, GV, AddrSpace,
ExpectedAS, Ty);
return GV;
}
llvm::Constant *
CodeGenModule::GetAddrOfGlobal(GlobalDecl GD,
ForDefinition_t IsForDefinition) {
const Decl *D = GD.getDecl();
if (isa<CXXConstructorDecl>(D))
return getAddrOfCXXStructor(cast<CXXConstructorDecl>(D),
getFromCtorType(GD.getCtorType()),
/*FnInfo=*/nullptr, /*FnType=*/nullptr,
/*DontDefer=*/false, IsForDefinition);
else if (isa<CXXDestructorDecl>(D))
return getAddrOfCXXStructor(cast<CXXDestructorDecl>(D),
getFromDtorType(GD.getDtorType()),
/*FnInfo=*/nullptr, /*FnType=*/nullptr,
/*DontDefer=*/false, IsForDefinition);
else if (isa<CXXMethodDecl>(D)) {
auto FInfo = &getTypes().arrangeCXXMethodDeclaration(
cast<CXXMethodDecl>(D));
auto Ty = getTypes().GetFunctionType(*FInfo);
return GetAddrOfFunction(GD, Ty, /*ForVTable=*/false, /*DontDefer=*/false,
IsForDefinition);
} else if (isa<FunctionDecl>(D)) {
const CGFunctionInfo &FI = getTypes().arrangeGlobalDeclaration(GD);
llvm::FunctionType *Ty = getTypes().GetFunctionType(FI);
return GetAddrOfFunction(GD, Ty, /*ForVTable=*/false, /*DontDefer=*/false,
IsForDefinition);
} else
return GetAddrOfGlobalVar(cast<VarDecl>(D), /*Ty=*/nullptr,
IsForDefinition);
}
llvm::GlobalVariable *
CodeGenModule::CreateOrReplaceCXXRuntimeVariable(StringRef Name,
llvm::Type *Ty,
llvm::GlobalValue::LinkageTypes Linkage) {
llvm::GlobalVariable *GV = getModule().getNamedGlobal(Name);
llvm::GlobalVariable *OldGV = nullptr;
if (GV) {
// Check if the variable has the right type.
if (GV->getType()->getElementType() == Ty)
return GV;
// Because C++ name mangling, the only way we can end up with an already
// existing global with the same name is if it has been declared extern "C".
assert(GV->isDeclaration() && "Declaration has wrong type!");
OldGV = GV;
}
// Create a new variable.
GV = new llvm::GlobalVariable(getModule(), Ty, /*isConstant=*/true,
Linkage, nullptr, Name);
if (OldGV) {
// Replace occurrences of the old variable if needed.
GV->takeName(OldGV);
if (!OldGV->use_empty()) {
llvm::Constant *NewPtrForOldDecl =
llvm::ConstantExpr::getBitCast(GV, OldGV->getType());
OldGV->replaceAllUsesWith(NewPtrForOldDecl);
}
OldGV->eraseFromParent();
}
if (supportsCOMDAT() && GV->isWeakForLinker() &&
!GV->hasAvailableExternallyLinkage())
GV->setComdat(TheModule.getOrInsertComdat(GV->getName()));
return GV;
}
/// GetAddrOfGlobalVar - Return the llvm::Constant for the address of the
/// given global variable. If Ty is non-null and if the global doesn't exist,
/// then it will be created with the specified type instead of whatever the
/// normal requested type would be. If IsForDefinition is true, it is guaranteed
/// that an actual global with type Ty will be returned, not conversion of a
/// variable with the same mangled name but some other type.
llvm::Constant *CodeGenModule::GetAddrOfGlobalVar(const VarDecl *D,
llvm::Type *Ty,
ForDefinition_t IsForDefinition) {
assert(D->hasGlobalStorage() && "Not a global variable");
QualType ASTTy = D->getType();
if (!Ty)
Ty = getTypes().ConvertTypeForMem(ASTTy);
llvm::PointerType *PTy =
llvm::PointerType::get(Ty, getContext().getTargetAddressSpace(ASTTy));
StringRef MangledName = getMangledName(D);
return GetOrCreateLLVMGlobal(MangledName, PTy, D, IsForDefinition);
}
/// CreateRuntimeVariable - Create a new runtime global variable with the
/// specified type and name.
llvm::Constant *
CodeGenModule::CreateRuntimeVariable(llvm::Type *Ty,
StringRef Name) {
auto *Ret =
GetOrCreateLLVMGlobal(Name, llvm::PointerType::getUnqual(Ty), nullptr);
setDSOLocal(cast<llvm::GlobalValue>(Ret->stripPointerCasts()));
return Ret;
}
void CodeGenModule::EmitTentativeDefinition(const VarDecl *D) {
assert(!D->getInit() && "Cannot emit definite definitions here!");
StringRef MangledName = getMangledName(D);
llvm::GlobalValue *GV = GetGlobalValue(MangledName);
// We already have a definition, not declaration, with the same mangled name.
// Emitting of declaration is not required (and actually overwrites emitted
// definition).
if (GV && !GV->isDeclaration())
return;
// If we have not seen a reference to this variable yet, place it into the
// deferred declarations table to be emitted if needed later.
if (!MustBeEmitted(D) && !GV) {
DeferredDecls[MangledName] = D;
return;
}
// The tentative definition is the only definition.
EmitGlobalVarDefinition(D);
}
CharUnits CodeGenModule::GetTargetTypeStoreSize(llvm::Type *Ty) const {
return Context.toCharUnitsFromBits(
getDataLayout().getTypeStoreSizeInBits(Ty));
}
LangAS CodeGenModule::GetGlobalVarAddressSpace(const VarDecl *D) {
LangAS AddrSpace = LangAS::Default;
if (LangOpts.OpenCL) {
AddrSpace = D ? D->getType().getAddressSpace() : LangAS::opencl_global;
assert(AddrSpace == LangAS::opencl_global ||
AddrSpace == LangAS::opencl_constant ||
AddrSpace == LangAS::opencl_local ||
AddrSpace >= LangAS::FirstTargetAddressSpace);
return AddrSpace;
}
if (LangOpts.CUDA && LangOpts.CUDAIsDevice) {
if (D && D->hasAttr<CUDAConstantAttr>())
return LangAS::cuda_constant;
else if (D && D->hasAttr<CUDASharedAttr>())
return LangAS::cuda_shared;
else
return LangAS::cuda_device;
}
return getTargetCodeGenInfo().getGlobalVarAddressSpace(*this, D);
}
LangAS CodeGenModule::getStringLiteralAddressSpace() const {
// OpenCL v1.2 s6.5.3: a string literal is in the constant address space.
if (LangOpts.OpenCL)
return LangAS::opencl_constant;
if (auto AS = getTarget().getConstantAddressSpace())
return AS.getValue();
return LangAS::Default;
}
// In address space agnostic languages, string literals are in default address
// space in AST. However, certain targets (e.g. amdgcn) request them to be
// emitted in constant address space in LLVM IR. To be consistent with other
// parts of AST, string literal global variables in constant address space
// need to be casted to default address space before being put into address
// map and referenced by other part of CodeGen.
// In OpenCL, string literals are in constant address space in AST, therefore
// they should not be casted to default address space.
static llvm::Constant *
castStringLiteralToDefaultAddressSpace(CodeGenModule &CGM,
llvm::GlobalVariable *GV) {
llvm::Constant *Cast = GV;
if (!CGM.getLangOpts().OpenCL) {
if (auto AS = CGM.getTarget().getConstantAddressSpace()) {
if (AS != LangAS::Default)
Cast = CGM.getTargetCodeGenInfo().performAddrSpaceCast(
CGM, GV, AS.getValue(), LangAS::Default,
GV->getValueType()->getPointerTo(
CGM.getContext().getTargetAddressSpace(LangAS::Default)));
}
}
return Cast;
}
template<typename SomeDecl>
void CodeGenModule::MaybeHandleStaticInExternC(const SomeDecl *D,
llvm::GlobalValue *GV) {
if (!getLangOpts().CPlusPlus)
return;
// Must have 'used' attribute, or else inline assembly can't rely on
// the name existing.
if (!D->template hasAttr<UsedAttr>())
return;
// Must have internal linkage and an ordinary name.
if (!D->getIdentifier() || D->getFormalLinkage() != InternalLinkage)
return;
// Must be in an extern "C" context. Entities declared directly within
// a record are not extern "C" even if the record is in such a context.
const SomeDecl *First = D->getFirstDecl();
if (First->getDeclContext()->isRecord() || !First->isInExternCContext())
return;
// OK, this is an internal linkage entity inside an extern "C" linkage
// specification. Make a note of that so we can give it the "expected"
// mangled name if nothing else is using that name.
std::pair<StaticExternCMap::iterator, bool> R =
StaticExternCValues.insert(std::make_pair(D->getIdentifier(), GV));
// If we have multiple internal linkage entities with the same name
// in extern "C" regions, none of them gets that name.
if (!R.second)
R.first->second = nullptr;
}
static bool shouldBeInCOMDAT(CodeGenModule &CGM, const Decl &D) {
if (!CGM.supportsCOMDAT())
return false;
if (D.hasAttr<SelectAnyAttr>())
return true;
GVALinkage Linkage;
if (auto *VD = dyn_cast<VarDecl>(&D))
Linkage = CGM.getContext().GetGVALinkageForVariable(VD);
else
Linkage = CGM.getContext().GetGVALinkageForFunction(cast<FunctionDecl>(&D));
switch (Linkage) {
case GVA_Internal:
case GVA_AvailableExternally:
case GVA_StrongExternal:
return false;
case GVA_DiscardableODR:
case GVA_StrongODR:
return true;
}
llvm_unreachable("No such linkage");
}
void CodeGenModule::maybeSetTrivialComdat(const Decl &D,
llvm::GlobalObject &GO) {
if (!shouldBeInCOMDAT(*this, D))
return;
GO.setComdat(TheModule.getOrInsertComdat(GO.getName()));
}
/// Pass IsTentative as true if you want to create a tentative definition.
void CodeGenModule::EmitGlobalVarDefinition(const VarDecl *D,
bool IsTentative) {
// OpenCL global variables of sampler type are translated to function calls,
// therefore no need to be translated.
QualType ASTTy = D->getType();
if (getLangOpts().OpenCL && ASTTy->isSamplerT())
return;
// If this is OpenMP device, check if it is legal to emit this global
// normally.
if (LangOpts.OpenMPIsDevice && OpenMPRuntime &&
OpenMPRuntime->emitTargetGlobalVariable(D))
return;
llvm::Constant *Init = nullptr;
CXXRecordDecl *RD = ASTTy->getBaseElementTypeUnsafe()->getAsCXXRecordDecl();
bool NeedsGlobalCtor = false;
bool NeedsGlobalDtor = RD && !RD->hasTrivialDestructor();
const VarDecl *InitDecl;
const Expr *InitExpr = D->getAnyInitializer(InitDecl);
Optional<ConstantEmitter> emitter;
// CUDA E.2.4.1 "__shared__ variables cannot have an initialization
// as part of their declaration." Sema has already checked for
// error cases, so we just need to set Init to UndefValue.
if (getLangOpts().CUDA && getLangOpts().CUDAIsDevice &&
D->hasAttr<CUDASharedAttr>())
Init = llvm::UndefValue::get(getTypes().ConvertType(ASTTy));
else if (!InitExpr) {
// This is a tentative definition; tentative definitions are
// implicitly initialized with { 0 }.
//
// Note that tentative definitions are only emitted at the end of
// a translation unit, so they should never have incomplete
// type. In addition, EmitTentativeDefinition makes sure that we
// never attempt to emit a tentative definition if a real one
// exists. A use may still exists, however, so we still may need
// to do a RAUW.
assert(!ASTTy->isIncompleteType() && "Unexpected incomplete type");
Init = EmitNullConstant(D->getType());
} else {
initializedGlobalDecl = GlobalDecl(D);
emitter.emplace(*this);
Init = emitter->tryEmitForInitializer(*InitDecl);
if (!Init) {
QualType T = InitExpr->getType();
if (D->getType()->isReferenceType())
T = D->getType();
if (getLangOpts().CPlusPlus) {
Init = EmitNullConstant(T);
NeedsGlobalCtor = true;
} else {
ErrorUnsupported(D, "static initializer");
Init = llvm::UndefValue::get(getTypes().ConvertType(T));
}
} else {
// We don't need an initializer, so remove the entry for the delayed
// initializer position (just in case this entry was delayed) if we
// also don't need to register a destructor.
if (getLangOpts().CPlusPlus && !NeedsGlobalDtor)
DelayedCXXInitPosition.erase(D);
}
}
llvm::Type* InitType = Init->getType();
llvm::Constant *Entry =
GetAddrOfGlobalVar(D, InitType, ForDefinition_t(!IsTentative));
// Strip off a bitcast if we got one back.
if (auto *CE = dyn_cast<llvm::ConstantExpr>(Entry)) {
assert(CE->getOpcode() == llvm::Instruction::BitCast ||
CE->getOpcode() == llvm::Instruction::AddrSpaceCast ||
// All zero index gep.
CE->getOpcode() == llvm::Instruction::GetElementPtr);
Entry = CE->getOperand(0);
}
// Entry is now either a Function or GlobalVariable.
auto *GV = dyn_cast<llvm::GlobalVariable>(Entry);
// We have a definition after a declaration with the wrong type.
// We must make a new GlobalVariable* and update everything that used OldGV
// (a declaration or tentative definition) with the new GlobalVariable*
// (which will be a definition).
//
// This happens if there is a prototype for a global (e.g.
// "extern int x[];") and then a definition of a different type (e.g.
// "int x[10];"). This also happens when an initializer has a different type
// from the type of the global (this happens with unions).
if (!GV || GV->getType()->getElementType() != InitType ||
GV->getType()->getAddressSpace() !=
getContext().getTargetAddressSpace(GetGlobalVarAddressSpace(D))) {
// Move the old entry aside so that we'll create a new one.
Entry->setName(StringRef());
// Make a new global with the correct type, this is now guaranteed to work.
GV = cast<llvm::GlobalVariable>(
GetAddrOfGlobalVar(D, InitType, ForDefinition_t(!IsTentative)));
// Replace all uses of the old global with the new global
llvm::Constant *NewPtrForOldDecl =
llvm::ConstantExpr::getBitCast(GV, Entry->getType());
Entry->replaceAllUsesWith(NewPtrForOldDecl);
// Erase the old global, since it is no longer used.
cast<llvm::GlobalValue>(Entry)->eraseFromParent();
}
MaybeHandleStaticInExternC(D, GV);
if (D->hasAttr<AnnotateAttr>())
AddGlobalAnnotations(D, GV);
// Set the llvm linkage type as appropriate.
llvm::GlobalValue::LinkageTypes Linkage =
getLLVMLinkageVarDefinition(D, GV->isConstant());
// CUDA B.2.1 "The __device__ qualifier declares a variable that resides on
// the device. [...]"
// CUDA B.2.2 "The __constant__ qualifier, optionally used together with
// __device__, declares a variable that: [...]
// Is accessible from all the threads within the grid and from the host
// through the runtime library (cudaGetSymbolAddress() / cudaGetSymbolSize()
// / cudaMemcpyToSymbol() / cudaMemcpyFromSymbol())."
if (GV && LangOpts.CUDA) {
if (LangOpts.CUDAIsDevice) {
if (D->hasAttr<CUDADeviceAttr>() || D->hasAttr<CUDAConstantAttr>())
GV->setExternallyInitialized(true);
} else {
// Host-side shadows of external declarations of device-side
// global variables become internal definitions. These have to
// be internal in order to prevent name conflicts with global
// host variables with the same name in a different TUs.
if (D->hasAttr<CUDADeviceAttr>() || D->hasAttr<CUDAConstantAttr>()) {
Linkage = llvm::GlobalValue::InternalLinkage;
// Shadow variables and their properties must be registered
// with CUDA runtime.
unsigned Flags = 0;
if (!D->hasDefinition())
Flags |= CGCUDARuntime::ExternDeviceVar;
if (D->hasAttr<CUDAConstantAttr>())
Flags |= CGCUDARuntime::ConstantDeviceVar;
getCUDARuntime().registerDeviceVar(*GV, Flags);
} else if (D->hasAttr<CUDASharedAttr>())
// __shared__ variables are odd. Shadows do get created, but
// they are not registered with the CUDA runtime, so they
// can't really be used to access their device-side
// counterparts. It's not clear yet whether it's nvcc's bug or
// a feature, but we've got to do the same for compatibility.
Linkage = llvm::GlobalValue::InternalLinkage;
}
}
GV->setInitializer(Init);
if (emitter) emitter->finalize(GV);
// If it is safe to mark the global 'constant', do so now.
GV->setConstant(!NeedsGlobalCtor && !NeedsGlobalDtor &&
isTypeConstant(D->getType(), true));
// If it is in a read-only section, mark it 'constant'.
if (const SectionAttr *SA = D->getAttr<SectionAttr>()) {
const ASTContext::SectionInfo &SI = Context.SectionInfos[SA->getName()];
if ((SI.SectionFlags & ASTContext::PSF_Write) == 0)
GV->setConstant(true);
}
GV->setAlignment(getContext().getDeclAlign(D).getQuantity());
// On Darwin, if the normal linkage of a C++ thread_local variable is
// LinkOnce or Weak, we keep the normal linkage to prevent multiple
// copies within a linkage unit; otherwise, the backing variable has
// internal linkage and all accesses should just be calls to the
// Itanium-specified entry point, which has the normal linkage of the
// variable. This is to preserve the ability to change the implementation
// behind the scenes.
if (!D->isStaticLocal() && D->getTLSKind() == VarDecl::TLS_Dynamic &&
Context.getTargetInfo().getTriple().isOSDarwin() &&
!llvm::GlobalVariable::isLinkOnceLinkage(Linkage) &&
!llvm::GlobalVariable::isWeakLinkage(Linkage))
Linkage = llvm::GlobalValue::InternalLinkage;
GV->setLinkage(Linkage);
if (D->hasAttr<DLLImportAttr>())
GV->setDLLStorageClass(llvm::GlobalVariable::DLLImportStorageClass);
else if (D->hasAttr<DLLExportAttr>())
GV->setDLLStorageClass(llvm::GlobalVariable::DLLExportStorageClass);
else
GV->setDLLStorageClass(llvm::GlobalVariable::DefaultStorageClass);
if (Linkage == llvm::GlobalVariable::CommonLinkage) {
// common vars aren't constant even if declared const.
GV->setConstant(false);
// Tentative definition of global variables may be initialized with
// non-zero null pointers. In this case they should have weak linkage
// since common linkage must have zero initializer and must not have
// explicit section therefore cannot have non-zero initial value.
if (!GV->getInitializer()->isNullValue())
GV->setLinkage(llvm::GlobalVariable::WeakAnyLinkage);
}
setNonAliasAttributes(D, GV);
if (D->getTLSKind() && !GV->isThreadLocal()) {
if (D->getTLSKind() == VarDecl::TLS_Dynamic)
CXXThreadLocals.push_back(D);
setTLSMode(GV, *D);
}
maybeSetTrivialComdat(*D, *GV);
// Emit the initializer function if necessary.
if (NeedsGlobalCtor || NeedsGlobalDtor)
EmitCXXGlobalVarDeclInitFunc(D, GV, NeedsGlobalCtor);
SanitizerMD->reportGlobalToASan(GV, *D, NeedsGlobalCtor);
// Emit global variable debug information.
if (CGDebugInfo *DI = getModuleDebugInfo())
if (getCodeGenOpts().getDebugInfo() >= codegenoptions::LimitedDebugInfo)
DI->EmitGlobalVariable(GV, D);
}
static bool isVarDeclStrongDefinition(const ASTContext &Context,
CodeGenModule &CGM, const VarDecl *D,
bool NoCommon) {
// Don't give variables common linkage if -fno-common was specified unless it
// was overridden by a NoCommon attribute.
if ((NoCommon || D->hasAttr<NoCommonAttr>()) && !D->hasAttr<CommonAttr>())
return true;
// C11 6.9.2/2:
// A declaration of an identifier for an object that has file scope without
// an initializer, and without a storage-class specifier or with the
// storage-class specifier static, constitutes a tentative definition.
if (D->getInit() || D->hasExternalStorage())
return true;
// A variable cannot be both common and exist in a section.
if (D->hasAttr<SectionAttr>())
return true;
// A variable cannot be both common and exist in a section.
// We don't try to determine which is the right section in the front-end.
// If no specialized section name is applicable, it will resort to default.
if (D->hasAttr<PragmaClangBSSSectionAttr>() ||
D->hasAttr<PragmaClangDataSectionAttr>() ||
D->hasAttr<PragmaClangRodataSectionAttr>())
return true;
// Thread local vars aren't considered common linkage.
if (D->getTLSKind())
return true;
// Tentative definitions marked with WeakImportAttr are true definitions.
if (D->hasAttr<WeakImportAttr>())
return true;
// A variable cannot be both common and exist in a comdat.
if (shouldBeInCOMDAT(CGM, *D))
return true;
// Declarations with a required alignment do not have common linkage in MSVC
// mode.
if (Context.getTargetInfo().getCXXABI().isMicrosoft()) {
if (D->hasAttr<AlignedAttr>())
return true;
QualType VarType = D->getType();
if (Context.isAlignmentRequired(VarType))
return true;
if (const auto *RT = VarType->getAs<RecordType>()) {
const RecordDecl *RD = RT->getDecl();
for (const FieldDecl *FD : RD->fields()) {
if (FD->isBitField())
continue;
if (FD->hasAttr<AlignedAttr>())
return true;
if (Context.isAlignmentRequired(FD->getType()))
return true;
}
}
}
return false;
}
llvm::GlobalValue::LinkageTypes CodeGenModule::getLLVMLinkageForDeclarator(
const DeclaratorDecl *D, GVALinkage Linkage, bool IsConstantVariable) {
if (Linkage == GVA_Internal)
return llvm::Function::InternalLinkage;
if (D->hasAttr<WeakAttr>()) {
if (IsConstantVariable)
return llvm::GlobalVariable::WeakODRLinkage;
else
return llvm::GlobalVariable::WeakAnyLinkage;
}
// We are guaranteed to have a strong definition somewhere else,
// so we can use available_externally linkage.
if (Linkage == GVA_AvailableExternally)
return llvm::GlobalValue::AvailableExternallyLinkage;
// Note that Apple's kernel linker doesn't support symbol
// coalescing, so we need to avoid linkonce and weak linkages there.
// Normally, this means we just map to internal, but for explicit
// instantiations we'll map to external.
// In C++, the compiler has to emit a definition in every translation unit
// that references the function. We should use linkonce_odr because
// a) if all references in this translation unit are optimized away, we
// don't need to codegen it. b) if the function persists, it needs to be
// merged with other definitions. c) C++ has the ODR, so we know the
// definition is dependable.
if (Linkage == GVA_DiscardableODR)
return !Context.getLangOpts().AppleKext ? llvm::Function::LinkOnceODRLinkage
: llvm::Function::InternalLinkage;
// An explicit instantiation of a template has weak linkage, since
// explicit instantiations can occur in multiple translation units
// and must all be equivalent. However, we are not allowed to
// throw away these explicit instantiations.
//
// We don't currently support CUDA device code spread out across multiple TUs,
// so say that CUDA templates are either external (for kernels) or internal.
// This lets llvm perform aggressive inter-procedural optimizations.
if (Linkage == GVA_StrongODR) {
if (Context.getLangOpts().AppleKext)
return llvm::Function::ExternalLinkage;
if (Context.getLangOpts().CUDA && Context.getLangOpts().CUDAIsDevice)
return D->hasAttr<CUDAGlobalAttr>() ? llvm::Function::ExternalLinkage
: llvm::Function::InternalLinkage;
return llvm::Function::WeakODRLinkage;
}
// C++ doesn't have tentative definitions and thus cannot have common
// linkage.
if (!getLangOpts().CPlusPlus && isa<VarDecl>(D) &&
!isVarDeclStrongDefinition(Context, *this, cast<VarDecl>(D),
CodeGenOpts.NoCommon))
return llvm::GlobalVariable::CommonLinkage;
// selectany symbols are externally visible, so use weak instead of
// linkonce. MSVC optimizes away references to const selectany globals, so
// all definitions should be the same and ODR linkage should be used.
// http://msdn.microsoft.com/en-us/library/5tkz6s71.aspx
if (D->hasAttr<SelectAnyAttr>())
return llvm::GlobalVariable::WeakODRLinkage;
// Otherwise, we have strong external linkage.
assert(Linkage == GVA_StrongExternal);
return llvm::GlobalVariable::ExternalLinkage;
}
llvm::GlobalValue::LinkageTypes CodeGenModule::getLLVMLinkageVarDefinition(
const VarDecl *VD, bool IsConstant) {
GVALinkage Linkage = getContext().GetGVALinkageForVariable(VD);
return getLLVMLinkageForDeclarator(VD, Linkage, IsConstant);
}
/// Replace the uses of a function that was declared with a non-proto type.
/// We want to silently drop extra arguments from call sites
static void replaceUsesOfNonProtoConstant(llvm::Constant *old,
llvm::Function *newFn) {
// Fast path.
if (old->use_empty()) return;
llvm::Type *newRetTy = newFn->getReturnType();
SmallVector<llvm::Value*, 4> newArgs;
SmallVector<llvm::OperandBundleDef, 1> newBundles;
for (llvm::Value::use_iterator ui = old->use_begin(), ue = old->use_end();
ui != ue; ) {
llvm::Value::use_iterator use = ui++; // Increment before the use is erased.
llvm::User *user = use->getUser();
// Recognize and replace uses of bitcasts. Most calls to
// unprototyped functions will use bitcasts.
if (auto *bitcast = dyn_cast<llvm::ConstantExpr>(user)) {
if (bitcast->getOpcode() == llvm::Instruction::BitCast)
replaceUsesOfNonProtoConstant(bitcast, newFn);
continue;
}
// Recognize calls to the function.
llvm::CallSite callSite(user);
if (!callSite) continue;
if (!callSite.isCallee(&*use)) continue;
// If the return types don't match exactly, then we can't
// transform this call unless it's dead.
if (callSite->getType() != newRetTy && !callSite->use_empty())
continue;
// Get the call site's attribute list.
SmallVector<llvm::AttributeSet, 8> newArgAttrs;
llvm::AttributeList oldAttrs = callSite.getAttributes();
// If the function was passed too few arguments, don't transform.
unsigned newNumArgs = newFn->arg_size();
if (callSite.arg_size() < newNumArgs) continue;
// If extra arguments were passed, we silently drop them.
// If any of the types mismatch, we don't transform.
unsigned argNo = 0;
bool dontTransform = false;
for (llvm::Argument &A : newFn->args()) {
if (callSite.getArgument(argNo)->getType() != A.getType()) {
dontTransform = true;
break;
}
// Add any parameter attributes.
newArgAttrs.push_back(oldAttrs.getParamAttributes(argNo));
argNo++;
}
if (dontTransform)
continue;
// Okay, we can transform this. Create the new call instruction and copy
// over the required information.
newArgs.append(callSite.arg_begin(), callSite.arg_begin() + argNo);
// Copy over any operand bundles.
callSite.getOperandBundlesAsDefs(newBundles);
llvm::CallSite newCall;
if (callSite.isCall()) {
newCall = llvm::CallInst::Create(newFn, newArgs, newBundles, "",
callSite.getInstruction());
} else {
auto *oldInvoke = cast<llvm::InvokeInst>(callSite.getInstruction());
newCall = llvm::InvokeInst::Create(newFn,
oldInvoke->getNormalDest(),
oldInvoke->getUnwindDest(),
newArgs, newBundles, "",
callSite.getInstruction());
}
newArgs.clear(); // for the next iteration
if (!newCall->getType()->isVoidTy())
newCall->takeName(callSite.getInstruction());
newCall.setAttributes(llvm::AttributeList::get(
newFn->getContext(), oldAttrs.getFnAttributes(),
oldAttrs.getRetAttributes(), newArgAttrs));
newCall.setCallingConv(callSite.getCallingConv());
// Finally, remove the old call, replacing any uses with the new one.
if (!callSite->use_empty())
callSite->replaceAllUsesWith(newCall.getInstruction());
// Copy debug location attached to CI.
if (callSite->getDebugLoc())
newCall->setDebugLoc(callSite->getDebugLoc());
callSite->eraseFromParent();
}
}
/// ReplaceUsesOfNonProtoTypeWithRealFunction - This function is called when we
/// implement a function with no prototype, e.g. "int foo() {}". If there are
/// existing call uses of the old function in the module, this adjusts them to
/// call the new function directly.
///
/// This is not just a cleanup: the always_inline pass requires direct calls to
/// functions to be able to inline them. If there is a bitcast in the way, it
/// won't inline them. Instcombine normally deletes these calls, but it isn't
/// run at -O0.
static void ReplaceUsesOfNonProtoTypeWithRealFunction(llvm::GlobalValue *Old,
llvm::Function *NewFn) {
// If we're redefining a global as a function, don't transform it.
if (!isa<llvm::Function>(Old)) return;
replaceUsesOfNonProtoConstant(Old, NewFn);
}
void CodeGenModule::HandleCXXStaticMemberVarInstantiation(VarDecl *VD) {
auto DK = VD->isThisDeclarationADefinition();
if (DK == VarDecl::Definition && VD->hasAttr<DLLImportAttr>())
return;
TemplateSpecializationKind TSK = VD->getTemplateSpecializationKind();
// If we have a definition, this might be a deferred decl. If the
// instantiation is explicit, make sure we emit it at the end.
if (VD->getDefinition() && TSK == TSK_ExplicitInstantiationDefinition)
GetAddrOfGlobalVar(VD);
EmitTopLevelDecl(VD);
}
void CodeGenModule::EmitGlobalFunctionDefinition(GlobalDecl GD,
llvm::GlobalValue *GV) {
const auto *D = cast<FunctionDecl>(GD.getDecl());
// Compute the function info and LLVM type.
const CGFunctionInfo &FI = getTypes().arrangeGlobalDeclaration(GD);
llvm::FunctionType *Ty = getTypes().GetFunctionType(FI);
// Get or create the prototype for the function.
if (!GV || (GV->getType()->getElementType() != Ty))
GV = cast<llvm::GlobalValue>(GetAddrOfFunction(GD, Ty, /*ForVTable=*/false,
/*DontDefer=*/true,
ForDefinition));
// Already emitted.
if (!GV->isDeclaration())
return;
// We need to set linkage and visibility on the function before
// generating code for it because various parts of IR generation
// want to propagate this information down (e.g. to local static
// declarations).
auto *Fn = cast<llvm::Function>(GV);
setFunctionLinkage(GD, Fn);
// FIXME: this is redundant with part of setFunctionDefinitionAttributes
setGVProperties(Fn, GD);
MaybeHandleStaticInExternC(D, Fn);
maybeSetTrivialComdat(*D, *Fn);
CodeGenFunction(*this).GenerateCode(D, Fn, FI);
setNonAliasAttributes(GD, Fn);
SetLLVMFunctionAttributesForDefinition(D, Fn);
if (const ConstructorAttr *CA = D->getAttr<ConstructorAttr>())
AddGlobalCtor(Fn, CA->getPriority());
if (const DestructorAttr *DA = D->getAttr<DestructorAttr>())
AddGlobalDtor(Fn, DA->getPriority());
if (D->hasAttr<AnnotateAttr>())
AddGlobalAnnotations(D, Fn);
}
void CodeGenModule::EmitAliasDefinition(GlobalDecl GD) {
const auto *D = cast<ValueDecl>(GD.getDecl());
const AliasAttr *AA = D->getAttr<AliasAttr>();
assert(AA && "Not an alias?");
StringRef MangledName = getMangledName(GD);
if (AA->getAliasee() == MangledName) {
Diags.Report(AA->getLocation(), diag::err_cyclic_alias) << 0;
return;
}
// If there is a definition in the module, then it wins over the alias.
// This is dubious, but allow it to be safe. Just ignore the alias.
llvm::GlobalValue *Entry = GetGlobalValue(MangledName);
if (Entry && !Entry->isDeclaration())
return;
Aliases.push_back(GD);
llvm::Type *DeclTy = getTypes().ConvertTypeForMem(D->getType());
// Create a reference to the named value. This ensures that it is emitted
// if a deferred decl.
llvm::Constant *Aliasee;
if (isa<llvm::FunctionType>(DeclTy))
Aliasee = GetOrCreateLLVMFunction(AA->getAliasee(), DeclTy, GD,
/*ForVTable=*/false);
else
Aliasee = GetOrCreateLLVMGlobal(AA->getAliasee(),
llvm::PointerType::getUnqual(DeclTy),
/*D=*/nullptr);
// Create the new alias itself, but don't set a name yet.
auto *GA = llvm::GlobalAlias::create(
DeclTy, 0, llvm::Function::ExternalLinkage, "", Aliasee, &getModule());
if (Entry) {
if (GA->getAliasee() == Entry) {
Diags.Report(AA->getLocation(), diag::err_cyclic_alias) << 0;
return;
}
assert(Entry->isDeclaration());
// If there is a declaration in the module, then we had an extern followed
// by the alias, as in:
// extern int test6();
// ...
// int test6() __attribute__((alias("test7")));
//
// Remove it and replace uses of it with the alias.
GA->takeName(Entry);
Entry->replaceAllUsesWith(llvm::ConstantExpr::getBitCast(GA,
Entry->getType()));
Entry->eraseFromParent();
} else {
GA->setName(MangledName);
}
// Set attributes which are particular to an alias; this is a
// specialization of the attributes which may be set on a global
// variable/function.
if (D->hasAttr<WeakAttr>() || D->hasAttr<WeakRefAttr>() ||
D->isWeakImported()) {
GA->setLinkage(llvm::Function::WeakAnyLinkage);
}
if (const auto *VD = dyn_cast<VarDecl>(D))
if (VD->getTLSKind())
setTLSMode(GA, *VD);
SetCommonAttributes(GD, GA);
}
void CodeGenModule::emitIFuncDefinition(GlobalDecl GD) {
const auto *D = cast<ValueDecl>(GD.getDecl());
const IFuncAttr *IFA = D->getAttr<IFuncAttr>();
assert(IFA && "Not an ifunc?");
StringRef MangledName = getMangledName(GD);
if (IFA->getResolver() == MangledName) {
Diags.Report(IFA->getLocation(), diag::err_cyclic_alias) << 1;
return;
}
// Report an error if some definition overrides ifunc.
llvm::GlobalValue *Entry = GetGlobalValue(MangledName);
if (Entry && !Entry->isDeclaration()) {
GlobalDecl OtherGD;
if (lookupRepresentativeDecl(MangledName, OtherGD) &&
DiagnosedConflictingDefinitions.insert(GD).second) {
Diags.Report(D->getLocation(), diag::err_duplicate_mangled_name)
<< MangledName;
Diags.Report(OtherGD.getDecl()->getLocation(),
diag::note_previous_definition);
}
return;
}
Aliases.push_back(GD);
llvm::Type *DeclTy = getTypes().ConvertTypeForMem(D->getType());
llvm::Constant *Resolver =
GetOrCreateLLVMFunction(IFA->getResolver(), DeclTy, GD,
/*ForVTable=*/false);
llvm::GlobalIFunc *GIF =
llvm::GlobalIFunc::create(DeclTy, 0, llvm::Function::ExternalLinkage,
"", Resolver, &getModule());
if (Entry) {
if (GIF->getResolver() == Entry) {
Diags.Report(IFA->getLocation(), diag::err_cyclic_alias) << 1;
return;
}
assert(Entry->isDeclaration());
// If there is a declaration in the module, then we had an extern followed
// by the ifunc, as in:
// extern int test();
// ...
// int test() __attribute__((ifunc("resolver")));
//
// Remove it and replace uses of it with the ifunc.
GIF->takeName(Entry);
Entry->replaceAllUsesWith(llvm::ConstantExpr::getBitCast(GIF,
Entry->getType()));
Entry->eraseFromParent();
} else
GIF->setName(MangledName);
SetCommonAttributes(GD, GIF);
}
llvm::Function *CodeGenModule::getIntrinsic(unsigned IID,
ArrayRef<llvm::Type*> Tys) {
return llvm::Intrinsic::getDeclaration(&getModule(), (llvm::Intrinsic::ID)IID,
Tys);
}
static llvm::StringMapEntry<llvm::GlobalVariable *> &
GetConstantCFStringEntry(llvm::StringMap<llvm::GlobalVariable *> &Map,
const StringLiteral *Literal, bool TargetIsLSB,
bool &IsUTF16, unsigned &StringLength) {
StringRef String = Literal->getString();
unsigned NumBytes = String.size();
// Check for simple case.
if (!Literal->containsNonAsciiOrNull()) {
StringLength = NumBytes;
return *Map.insert(std::make_pair(String, nullptr)).first;
}
// Otherwise, convert the UTF8 literals into a string of shorts.
IsUTF16 = true;
SmallVector<llvm::UTF16, 128> ToBuf(NumBytes + 1); // +1 for ending nulls.
const llvm::UTF8 *FromPtr = (const llvm::UTF8 *)String.data();
llvm::UTF16 *ToPtr = &ToBuf[0];
(void)llvm::ConvertUTF8toUTF16(&FromPtr, FromPtr + NumBytes, &ToPtr,
ToPtr + NumBytes, llvm::strictConversion);
// ConvertUTF8toUTF16 returns the length in ToPtr.
StringLength = ToPtr - &ToBuf[0];
// Add an explicit null.
*ToPtr = 0;
return *Map.insert(std::make_pair(
StringRef(reinterpret_cast<const char *>(ToBuf.data()),
(StringLength + 1) * 2),
nullptr)).first;
}
ConstantAddress
CodeGenModule::GetAddrOfConstantCFString(const StringLiteral *Literal) {
unsigned StringLength = 0;
bool isUTF16 = false;
llvm::StringMapEntry<llvm::GlobalVariable *> &Entry =
GetConstantCFStringEntry(CFConstantStringMap, Literal,
getDataLayout().isLittleEndian(), isUTF16,
StringLength);
if (auto *C = Entry.second)
return ConstantAddress(C, CharUnits::fromQuantity(C->getAlignment()));
llvm::Constant *Zero = llvm::Constant::getNullValue(Int32Ty);
llvm::Constant *Zeros[] = { Zero, Zero };
// If we don't already have it, get __CFConstantStringClassReference.
if (!CFConstantStringClassRef) {
llvm::Type *Ty = getTypes().ConvertType(getContext().IntTy);
Ty = llvm::ArrayType::get(Ty, 0);
llvm::GlobalValue *GV = cast<llvm::GlobalValue>(
CreateRuntimeVariable(Ty, "__CFConstantStringClassReference"));
if (getTriple().isOSBinFormatCOFF()) {
IdentifierInfo &II = getContext().Idents.get(GV->getName());
TranslationUnitDecl *TUDecl = getContext().getTranslationUnitDecl();
DeclContext *DC = TranslationUnitDecl::castToDeclContext(TUDecl);
const VarDecl *VD = nullptr;
for (const auto &Result : DC->lookup(&II))
if ((VD = dyn_cast<VarDecl>(Result)))
break;
if (!VD || !VD->hasAttr<DLLExportAttr>()) {
GV->setDLLStorageClass(llvm::GlobalValue::DLLImportStorageClass);
GV->setLinkage(llvm::GlobalValue::ExternalLinkage);
} else {
GV->setDLLStorageClass(llvm::GlobalValue::DLLExportStorageClass);
GV->setLinkage(llvm::GlobalValue::ExternalLinkage);
}
}
setDSOLocal(GV);
// Decay array -> ptr
CFConstantStringClassRef =
llvm::ConstantExpr::getGetElementPtr(Ty, GV, Zeros);
}
QualType CFTy = getContext().getCFConstantStringType();
auto *STy = cast<llvm::StructType>(getTypes().ConvertType(CFTy));
ConstantInitBuilder Builder(*this);
auto Fields = Builder.beginStruct(STy);
// Class pointer.
Fields.add(cast<llvm::ConstantExpr>(CFConstantStringClassRef));
// Flags.
Fields.addInt(IntTy, isUTF16 ? 0x07d0 : 0x07C8);
// String pointer.
llvm::Constant *C = nullptr;
if (isUTF16) {
auto Arr = llvm::makeArrayRef(
reinterpret_cast<uint16_t *>(const_cast<char *>(Entry.first().data())),
Entry.first().size() / 2);
C = llvm::ConstantDataArray::get(VMContext, Arr);
} else {
C = llvm::ConstantDataArray::getString(VMContext, Entry.first());
}
// Note: -fwritable-strings doesn't make the backing store strings of
// CFStrings writable. (See <rdar://problem/10657500>)
auto *GV =
new llvm::GlobalVariable(getModule(), C->getType(), /*isConstant=*/true,
llvm::GlobalValue::PrivateLinkage, C, ".str");
GV->setUnnamedAddr(llvm::GlobalValue::UnnamedAddr::Global);
// Don't enforce the target's minimum global alignment, since the only use
// of the string is via this class initializer.
CharUnits Align = isUTF16
? getContext().getTypeAlignInChars(getContext().ShortTy)
: getContext().getTypeAlignInChars(getContext().CharTy);
GV->setAlignment(Align.getQuantity());
// FIXME: We set the section explicitly to avoid a bug in ld64 224.1.
// Without it LLVM can merge the string with a non unnamed_addr one during
// LTO. Doing that changes the section it ends in, which surprises ld64.
if (getTriple().isOSBinFormatMachO())
GV->setSection(isUTF16 ? "__TEXT,__ustring"
: "__TEXT,__cstring,cstring_literals");
// String.
llvm::Constant *Str =
llvm::ConstantExpr::getGetElementPtr(GV->getValueType(), GV, Zeros);
if (isUTF16)
// Cast the UTF16 string to the correct type.
Str = llvm::ConstantExpr::getBitCast(Str, Int8PtrTy);
Fields.add(Str);
// String length.
auto Ty = getTypes().ConvertType(getContext().LongTy);
Fields.addInt(cast<llvm::IntegerType>(Ty), StringLength);
CharUnits Alignment = getPointerAlign();
// The struct.
GV = Fields.finishAndCreateGlobal("_unnamed_cfstring_", Alignment,
/*isConstant=*/false,
llvm::GlobalVariable::PrivateLinkage);
switch (getTriple().getObjectFormat()) {
case llvm::Triple::UnknownObjectFormat:
llvm_unreachable("unknown file format");
case llvm::Triple::COFF:
case llvm::Triple::ELF:
case llvm::Triple::Wasm:
GV->setSection("cfstring");
break;
case llvm::Triple::MachO:
GV->setSection("__DATA,__cfstring");
break;
}
Entry.second = GV;
return ConstantAddress(GV, Alignment);
}
bool CodeGenModule::getExpressionLocationsEnabled() const {
return !CodeGenOpts.EmitCodeView || CodeGenOpts.DebugColumnInfo;
}
QualType CodeGenModule::getObjCFastEnumerationStateType() {
if (ObjCFastEnumerationStateType.isNull()) {
RecordDecl *D = Context.buildImplicitRecord("__objcFastEnumerationState");
D->startDefinition();
QualType FieldTypes[] = {
Context.UnsignedLongTy,
Context.getPointerType(Context.getObjCIdType()),
Context.getPointerType(Context.UnsignedLongTy),
Context.getConstantArrayType(Context.UnsignedLongTy,
llvm::APInt(32, 5), ArrayType::Normal, 0)
};
for (size_t i = 0; i < 4; ++i) {
FieldDecl *Field = FieldDecl::Create(Context,
D,
SourceLocation(),
SourceLocation(), nullptr,
FieldTypes[i], /*TInfo=*/nullptr,
/*BitWidth=*/nullptr,
/*Mutable=*/false,
ICIS_NoInit);
Field->setAccess(AS_public);
D->addDecl(Field);
}
D->completeDefinition();
ObjCFastEnumerationStateType = Context.getTagDeclType(D);
}
return ObjCFastEnumerationStateType;
}
llvm::Constant *
CodeGenModule::GetConstantArrayFromStringLiteral(const StringLiteral *E) {
assert(!E->getType()->isPointerType() && "Strings are always arrays");
// Don't emit it as the address of the string, emit the string data itself
// as an inline array.
if (E->getCharByteWidth() == 1) {
SmallString<64> Str(E->getString());
// Resize the string to the right size, which is indicated by its type.
const ConstantArrayType *CAT = Context.getAsConstantArrayType(E->getType());
Str.resize(CAT->getSize().getZExtValue());
return llvm::ConstantDataArray::getString(VMContext, Str, false);
}
auto *AType = cast<llvm::ArrayType>(getTypes().ConvertType(E->getType()));
llvm::Type *ElemTy = AType->getElementType();
unsigned NumElements = AType->getNumElements();
// Wide strings have either 2-byte or 4-byte elements.
if (ElemTy->getPrimitiveSizeInBits() == 16) {
SmallVector<uint16_t, 32> Elements;
Elements.reserve(NumElements);
for(unsigned i = 0, e = E->getLength(); i != e; ++i)
Elements.push_back(E->getCodeUnit(i));
Elements.resize(NumElements);
return llvm::ConstantDataArray::get(VMContext, Elements);
}
assert(ElemTy->getPrimitiveSizeInBits() == 32);
SmallVector<uint32_t, 32> Elements;
Elements.reserve(NumElements);
for(unsigned i = 0, e = E->getLength(); i != e; ++i)
Elements.push_back(E->getCodeUnit(i));
Elements.resize(NumElements);
return llvm::ConstantDataArray::get(VMContext, Elements);
}
static llvm::GlobalVariable *
GenerateStringLiteral(llvm::Constant *C, llvm::GlobalValue::LinkageTypes LT,
CodeGenModule &CGM, StringRef GlobalName,
CharUnits Alignment) {
unsigned AddrSpace = CGM.getContext().getTargetAddressSpace(
CGM.getStringLiteralAddressSpace());
llvm::Module &M = CGM.getModule();
// Create a global variable for this string
auto *GV = new llvm::GlobalVariable(
M, C->getType(), !CGM.getLangOpts().WritableStrings, LT, C, GlobalName,
nullptr, llvm::GlobalVariable::NotThreadLocal, AddrSpace);
GV->setAlignment(Alignment.getQuantity());
GV->setUnnamedAddr(llvm::GlobalValue::UnnamedAddr::Global);
if (GV->isWeakForLinker()) {
assert(CGM.supportsCOMDAT() && "Only COFF uses weak string literals");
GV->setComdat(M.getOrInsertComdat(GV->getName()));
}
CGM.setDSOLocal(GV);
return GV;
}
/// GetAddrOfConstantStringFromLiteral - Return a pointer to a
/// constant array for the given string literal.
ConstantAddress
CodeGenModule::GetAddrOfConstantStringFromLiteral(const StringLiteral *S,
StringRef Name) {
CharUnits Alignment = getContext().getAlignOfGlobalVarInChars(S->getType());
llvm::Constant *C = GetConstantArrayFromStringLiteral(S);
llvm::GlobalVariable **Entry = nullptr;
if (!LangOpts.WritableStrings) {
Entry = &ConstantStringMap[C];
if (auto GV = *Entry) {
if (Alignment.getQuantity() > GV->getAlignment())
GV->setAlignment(Alignment.getQuantity());
return ConstantAddress(GV, Alignment);
}
}
SmallString<256> MangledNameBuffer;
StringRef GlobalVariableName;
llvm::GlobalValue::LinkageTypes LT;
// Mangle the string literal if that's how the ABI merges duplicate strings.
// Don't do it if they are writable, since we don't want writes in one TU to
// affect strings in another.
if (getCXXABI().getMangleContext().shouldMangleStringLiteral(S) &&
!LangOpts.WritableStrings) {
llvm::raw_svector_ostream Out(MangledNameBuffer);
getCXXABI().getMangleContext().mangleStringLiteral(S, Out);
LT = llvm::GlobalValue::LinkOnceODRLinkage;
GlobalVariableName = MangledNameBuffer;
} else {
LT = llvm::GlobalValue::PrivateLinkage;
GlobalVariableName = Name;
}
auto GV = GenerateStringLiteral(C, LT, *this, GlobalVariableName, Alignment);
if (Entry)
*Entry = GV;
SanitizerMD->reportGlobalToASan(GV, S->getStrTokenLoc(0), "<string literal>",
QualType());
return ConstantAddress(castStringLiteralToDefaultAddressSpace(*this, GV),
Alignment);
}
/// GetAddrOfConstantStringFromObjCEncode - Return a pointer to a constant
/// array for the given ObjCEncodeExpr node.
ConstantAddress
CodeGenModule::GetAddrOfConstantStringFromObjCEncode(const ObjCEncodeExpr *E) {
std::string Str;
getContext().getObjCEncodingForType(E->getEncodedType(), Str);
return GetAddrOfConstantCString(Str);
}
/// GetAddrOfConstantCString - Returns a pointer to a character array containing
/// the literal and a terminating '\0' character.
/// The result has pointer to array type.
ConstantAddress CodeGenModule::GetAddrOfConstantCString(
const std::string &Str, const char *GlobalName) {
StringRef StrWithNull(Str.c_str(), Str.size() + 1);
CharUnits Alignment =
getContext().getAlignOfGlobalVarInChars(getContext().CharTy);
llvm::Constant *C =
llvm::ConstantDataArray::getString(getLLVMContext(), StrWithNull, false);
// Don't share any string literals if strings aren't constant.
llvm::GlobalVariable **Entry = nullptr;
if (!LangOpts.WritableStrings) {
Entry = &ConstantStringMap[C];
if (auto GV = *Entry) {
if (Alignment.getQuantity() > GV->getAlignment())
GV->setAlignment(Alignment.getQuantity());
return ConstantAddress(GV, Alignment);
}
}
// Get the default prefix if a name wasn't specified.
if (!GlobalName)
GlobalName = ".str";
// Create a global variable for this.
auto GV = GenerateStringLiteral(C, llvm::GlobalValue::PrivateLinkage, *this,
GlobalName, Alignment);
if (Entry)
*Entry = GV;
return ConstantAddress(castStringLiteralToDefaultAddressSpace(*this, GV),
Alignment);
}
ConstantAddress CodeGenModule::GetAddrOfGlobalTemporary(
const MaterializeTemporaryExpr *E, const Expr *Init) {
assert((E->getStorageDuration() == SD_Static ||
E->getStorageDuration() == SD_Thread) && "not a global temporary");
const auto *VD = cast<VarDecl>(E->getExtendingDecl());
// If we're not materializing a subobject of the temporary, keep the
// cv-qualifiers from the type of the MaterializeTemporaryExpr.
QualType MaterializedType = Init->getType();
if (Init == E->GetTemporaryExpr())
MaterializedType = E->getType();
CharUnits Align = getContext().getTypeAlignInChars(MaterializedType);
if (llvm::Constant *Slot = MaterializedGlobalTemporaryMap[E])
return ConstantAddress(Slot, Align);
// FIXME: If an externally-visible declaration extends multiple temporaries,
// we need to give each temporary the same name in every translation unit (and
// we also need to make the temporaries externally-visible).
SmallString<256> Name;
llvm::raw_svector_ostream Out(Name);
getCXXABI().getMangleContext().mangleReferenceTemporary(
VD, E->getManglingNumber(), Out);
APValue *Value = nullptr;
if (E->getStorageDuration() == SD_Static) {
// We might have a cached constant initializer for this temporary. Note
// that this might have a different value from the value computed by
// evaluating the initializer if the surrounding constant expression
// modifies the temporary.
Value = getContext().getMaterializedTemporaryValue(E, false);
if (Value && Value->isUninit())
Value = nullptr;
}
// Try evaluating it now, it might have a constant initializer.
Expr::EvalResult EvalResult;
if (!Value && Init->EvaluateAsRValue(EvalResult, getContext()) &&
!EvalResult.hasSideEffects())
Value = &EvalResult.Val;
LangAS AddrSpace =
VD ? GetGlobalVarAddressSpace(VD) : MaterializedType.getAddressSpace();
Optional<ConstantEmitter> emitter;
llvm::Constant *InitialValue = nullptr;
bool Constant = false;
llvm::Type *Type;
if (Value) {
// The temporary has a constant initializer, use it.
emitter.emplace(*this);
InitialValue = emitter->emitForInitializer(*Value, AddrSpace,
MaterializedType);
Constant = isTypeConstant(MaterializedType, /*ExcludeCtor*/Value);
Type = InitialValue->getType();
} else {
// No initializer, the initialization will be provided when we
// initialize the declaration which performed lifetime extension.
Type = getTypes().ConvertTypeForMem(MaterializedType);
}
// Create a global variable for this lifetime-extended temporary.
llvm::GlobalValue::LinkageTypes Linkage =
getLLVMLinkageVarDefinition(VD, Constant);
if (Linkage == llvm::GlobalVariable::ExternalLinkage) {
const VarDecl *InitVD;
if (VD->isStaticDataMember() && VD->getAnyInitializer(InitVD) &&
isa<CXXRecordDecl>(InitVD->getLexicalDeclContext())) {
// Temporaries defined inside a class get linkonce_odr linkage because the
// class can be defined in multiple translation units.
Linkage = llvm::GlobalVariable::LinkOnceODRLinkage;
} else {
// There is no need for this temporary to have external linkage if the
// VarDecl has external linkage.
Linkage = llvm::GlobalVariable::InternalLinkage;
}
}
auto TargetAS = getContext().getTargetAddressSpace(AddrSpace);
auto *GV = new llvm::GlobalVariable(
getModule(), Type, Constant, Linkage, InitialValue, Name.c_str(),
/*InsertBefore=*/nullptr, llvm::GlobalVariable::NotThreadLocal, TargetAS);
if (emitter) emitter->finalize(GV);
setGVProperties(GV, VD);
GV->setAlignment(Align.getQuantity());
if (supportsCOMDAT() && GV->isWeakForLinker())
GV->setComdat(TheModule.getOrInsertComdat(GV->getName()));
if (VD->getTLSKind())
setTLSMode(GV, *VD);
llvm::Constant *CV = GV;
if (AddrSpace != LangAS::Default)
CV = getTargetCodeGenInfo().performAddrSpaceCast(
*this, GV, AddrSpace, LangAS::Default,
Type->getPointerTo(
getContext().getTargetAddressSpace(LangAS::Default)));
MaterializedGlobalTemporaryMap[E] = CV;
return ConstantAddress(CV, Align);
}
/// EmitObjCPropertyImplementations - Emit information for synthesized
/// properties for an implementation.
void CodeGenModule::EmitObjCPropertyImplementations(const
ObjCImplementationDecl *D) {
for (const auto *PID : D->property_impls()) {
// Dynamic is just for type-checking.
if (PID->getPropertyImplementation() == ObjCPropertyImplDecl::Synthesize) {
ObjCPropertyDecl *PD = PID->getPropertyDecl();
// Determine which methods need to be implemented, some may have
// been overridden. Note that ::isPropertyAccessor is not the method
// we want, that just indicates if the decl came from a
// property. What we want to know is if the method is defined in
// this implementation.
if (!D->getInstanceMethod(PD->getGetterName()))
CodeGenFunction(*this).GenerateObjCGetter(
const_cast<ObjCImplementationDecl *>(D), PID);
if (!PD->isReadOnly() &&
!D->getInstanceMethod(PD->getSetterName()))
CodeGenFunction(*this).GenerateObjCSetter(
const_cast<ObjCImplementationDecl *>(D), PID);
}
}
}
static bool needsDestructMethod(ObjCImplementationDecl *impl) {
const ObjCInterfaceDecl *iface = impl->getClassInterface();
for (const ObjCIvarDecl *ivar = iface->all_declared_ivar_begin();
ivar; ivar = ivar->getNextIvar())
if (ivar->getType().isDestructedType())
return true;
return false;
}
static bool AllTrivialInitializers(CodeGenModule &CGM,
ObjCImplementationDecl *D) {
CodeGenFunction CGF(CGM);
for (ObjCImplementationDecl::init_iterator B = D->init_begin(),
E = D->init_end(); B != E; ++B) {
CXXCtorInitializer *CtorInitExp = *B;
Expr *Init = CtorInitExp->getInit();
if (!CGF.isTrivialInitializer(Init))
return false;
}
return true;
}
/// EmitObjCIvarInitializations - Emit information for ivar initialization
/// for an implementation.
void CodeGenModule::EmitObjCIvarInitializations(ObjCImplementationDecl *D) {
// We might need a .cxx_destruct even if we don't have any ivar initializers.
if (needsDestructMethod(D)) {
IdentifierInfo *II = &getContext().Idents.get(".cxx_destruct");
Selector cxxSelector = getContext().Selectors.getSelector(0, &II);
ObjCMethodDecl *DTORMethod =
ObjCMethodDecl::Create(getContext(), D->getLocation(), D->getLocation(),
cxxSelector, getContext().VoidTy, nullptr, D,
/*isInstance=*/true, /*isVariadic=*/false,
/*isPropertyAccessor=*/true, /*isImplicitlyDeclared=*/true,
/*isDefined=*/false, ObjCMethodDecl::Required);
D->addInstanceMethod(DTORMethod);
CodeGenFunction(*this).GenerateObjCCtorDtorMethod(D, DTORMethod, false);
D->setHasDestructors(true);
}
// If the implementation doesn't have any ivar initializers, we don't need
// a .cxx_construct.
if (D->getNumIvarInitializers() == 0 ||
AllTrivialInitializers(*this, D))
return;
IdentifierInfo *II = &getContext().Idents.get(".cxx_construct");
Selector cxxSelector = getContext().Selectors.getSelector(0, &II);
// The constructor returns 'self'.
ObjCMethodDecl *CTORMethod = ObjCMethodDecl::Create(getContext(),
D->getLocation(),
D->getLocation(),
cxxSelector,
getContext().getObjCIdType(),
nullptr, D, /*isInstance=*/true,
/*isVariadic=*/false,
/*isPropertyAccessor=*/true,
/*isImplicitlyDeclared=*/true,
/*isDefined=*/false,
ObjCMethodDecl::Required);
D->addInstanceMethod(CTORMethod);
CodeGenFunction(*this).GenerateObjCCtorDtorMethod(D, CTORMethod, true);
D->setHasNonZeroConstructors(true);
}
// EmitLinkageSpec - Emit all declarations in a linkage spec.
void CodeGenModule::EmitLinkageSpec(const LinkageSpecDecl *LSD) {
if (LSD->getLanguage() != LinkageSpecDecl::lang_c &&
LSD->getLanguage() != LinkageSpecDecl::lang_cxx) {
ErrorUnsupported(LSD, "linkage spec");
return;
}
EmitDeclContext(LSD);
}
void CodeGenModule::EmitDeclContext(const DeclContext *DC) {
for (auto *I : DC->decls()) {
// Unlike other DeclContexts, the contents of an ObjCImplDecl at TU scope
// are themselves considered "top-level", so EmitTopLevelDecl on an
// ObjCImplDecl does not recursively visit them. We need to do that in
// case they're nested inside another construct (LinkageSpecDecl /
// ExportDecl) that does stop them from being considered "top-level".
if (auto *OID = dyn_cast<ObjCImplDecl>(I)) {
for (auto *M : OID->methods())
EmitTopLevelDecl(M);
}
EmitTopLevelDecl(I);
}
}
/// EmitTopLevelDecl - Emit code for a single top level declaration.
void CodeGenModule::EmitTopLevelDecl(Decl *D) {
// Ignore dependent declarations.
if (D->isTemplated())
return;
switch (D->getKind()) {
case Decl::CXXConversion:
case Decl::CXXMethod:
case Decl::Function:
EmitGlobal(cast<FunctionDecl>(D));
// Always provide some coverage mapping
// even for the functions that aren't emitted.
AddDeferredUnusedCoverageMapping(D);
break;
case Decl::CXXDeductionGuide:
// Function-like, but does not result in code emission.
break;
case Decl::Var:
case Decl::Decomposition:
case Decl::VarTemplateSpecialization:
EmitGlobal(cast<VarDecl>(D));
if (auto *DD = dyn_cast<DecompositionDecl>(D))
for (auto *B : DD->bindings())
if (auto *HD = B->getHoldingVar())
EmitGlobal(HD);
break;
// Indirect fields from global anonymous structs and unions can be
// ignored; only the actual variable requires IR gen support.
case Decl::IndirectField:
break;
// C++ Decls
case Decl::Namespace:
EmitDeclContext(cast<NamespaceDecl>(D));
break;
case Decl::ClassTemplateSpecialization: {
const auto *Spec = cast<ClassTemplateSpecializationDecl>(D);
if (DebugInfo &&
Spec->getSpecializationKind() == TSK_ExplicitInstantiationDefinition &&
Spec->hasDefinition())
DebugInfo->completeTemplateDefinition(*Spec);
} LLVM_FALLTHROUGH;
case Decl::CXXRecord:
if (DebugInfo) {
if (auto *ES = D->getASTContext().getExternalSource())
if (ES->hasExternalDefinitions(D) == ExternalASTSource::EK_Never)
DebugInfo->completeUnusedClass(cast<CXXRecordDecl>(*D));
}
// Emit any static data members, they may be definitions.
for (auto *I : cast<CXXRecordDecl>(D)->decls())
if (isa<VarDecl>(I) || isa<CXXRecordDecl>(I))
EmitTopLevelDecl(I);
break;
// No code generation needed.
case Decl::UsingShadow:
case Decl::ClassTemplate:
case Decl::VarTemplate:
case Decl::VarTemplatePartialSpecialization:
case Decl::FunctionTemplate:
case Decl::TypeAliasTemplate:
case Decl::Block:
case Decl::Empty:
break;
case Decl::Using: // using X; [C++]
if (CGDebugInfo *DI = getModuleDebugInfo())
DI->EmitUsingDecl(cast<UsingDecl>(*D));
return;
case Decl::NamespaceAlias:
if (CGDebugInfo *DI = getModuleDebugInfo())
DI->EmitNamespaceAlias(cast<NamespaceAliasDecl>(*D));
return;
case Decl::UsingDirective: // using namespace X; [C++]
if (CGDebugInfo *DI = getModuleDebugInfo())
DI->EmitUsingDirective(cast<UsingDirectiveDecl>(*D));
return;
case Decl::CXXConstructor:
getCXXABI().EmitCXXConstructors(cast<CXXConstructorDecl>(D));
break;
case Decl::CXXDestructor:
getCXXABI().EmitCXXDestructors(cast<CXXDestructorDecl>(D));
break;
case Decl::StaticAssert:
// Nothing to do.
break;
// Objective-C Decls
// Forward declarations, no (immediate) code generation.
case Decl::ObjCInterface:
case Decl::ObjCCategory:
break;
case Decl::ObjCProtocol: {
auto *Proto = cast<ObjCProtocolDecl>(D);
if (Proto->isThisDeclarationADefinition())
ObjCRuntime->GenerateProtocol(Proto);
break;
}
case Decl::ObjCCategoryImpl:
// Categories have properties but don't support synthesize so we
// can ignore them here.
ObjCRuntime->GenerateCategory(cast<ObjCCategoryImplDecl>(D));
break;
case Decl::ObjCImplementation: {
auto *OMD = cast<ObjCImplementationDecl>(D);
EmitObjCPropertyImplementations(OMD);
EmitObjCIvarInitializations(OMD);
ObjCRuntime->GenerateClass(OMD);
// Emit global variable debug information.
if (CGDebugInfo *DI = getModuleDebugInfo())
if (getCodeGenOpts().getDebugInfo() >= codegenoptions::LimitedDebugInfo)
DI->getOrCreateInterfaceType(getContext().getObjCInterfaceType(
OMD->getClassInterface()), OMD->getLocation());
break;
}
case Decl::ObjCMethod: {
auto *OMD = cast<ObjCMethodDecl>(D);
// If this is not a prototype, emit the body.
if (OMD->getBody())
CodeGenFunction(*this).GenerateObjCMethod(OMD);
break;
}
case Decl::ObjCCompatibleAlias:
ObjCRuntime->RegisterAlias(cast<ObjCCompatibleAliasDecl>(D));
break;
case Decl::PragmaComment: {
const auto *PCD = cast<PragmaCommentDecl>(D);
switch (PCD->getCommentKind()) {
case PCK_Unknown:
llvm_unreachable("unexpected pragma comment kind");
case PCK_Linker:
AppendLinkerOptions(PCD->getArg());
break;
case PCK_Lib:
if (getTarget().getTriple().isOSBinFormatELF() &&
!getTarget().getTriple().isPS4())
AddELFLibDirective(PCD->getArg());
else
AddDependentLib(PCD->getArg());
break;
case PCK_Compiler:
case PCK_ExeStr:
case PCK_User:
break; // We ignore all of these.
}
break;
}
case Decl::PragmaDetectMismatch: {
const auto *PDMD = cast<PragmaDetectMismatchDecl>(D);
AddDetectMismatch(PDMD->getName(), PDMD->getValue());
break;
}
case Decl::LinkageSpec:
EmitLinkageSpec(cast<LinkageSpecDecl>(D));
break;
case Decl::FileScopeAsm: {
// File-scope asm is ignored during device-side CUDA compilation.
if (LangOpts.CUDA && LangOpts.CUDAIsDevice)
break;
// File-scope asm is ignored during device-side OpenMP compilation.
if (LangOpts.OpenMPIsDevice)
break;
auto *AD = cast<FileScopeAsmDecl>(D);
getModule().appendModuleInlineAsm(AD->getAsmString()->getString());
break;
}
case Decl::Import: {
auto *Import = cast<ImportDecl>(D);
// If we've already imported this module, we're done.
if (!ImportedModules.insert(Import->getImportedModule()))
break;
// Emit debug information for direct imports.
if (!Import->getImportedOwningModule()) {
if (CGDebugInfo *DI = getModuleDebugInfo())
DI->EmitImportDecl(*Import);
}
// Find all of the submodules and emit the module initializers.
llvm::SmallPtrSet<clang::Module *, 16> Visited;
SmallVector<clang::Module *, 16> Stack;
Visited.insert(Import->getImportedModule());
Stack.push_back(Import->getImportedModule());
while (!Stack.empty()) {
clang::Module *Mod = Stack.pop_back_val();
if (!EmittedModuleInitializers.insert(Mod).second)
continue;
for (auto *D : Context.getModuleInitializers(Mod))
EmitTopLevelDecl(D);
// Visit the submodules of this module.
for (clang::Module::submodule_iterator Sub = Mod->submodule_begin(),
SubEnd = Mod->submodule_end();
Sub != SubEnd; ++Sub) {
// Skip explicit children; they need to be explicitly imported to emit
// the initializers.
if ((*Sub)->IsExplicit)
continue;
if (Visited.insert(*Sub).second)
Stack.push_back(*Sub);
}
}
break;
}
case Decl::Export:
EmitDeclContext(cast<ExportDecl>(D));
break;
case Decl::OMPThreadPrivate:
EmitOMPThreadPrivateDecl(cast<OMPThreadPrivateDecl>(D));
break;
case Decl::OMPDeclareReduction:
EmitOMPDeclareReduction(cast<OMPDeclareReductionDecl>(D));
break;
default:
// Make sure we handled everything we should, every other kind is a
// non-top-level decl. FIXME: Would be nice to have an isTopLevelDeclKind
// function. Need to recode Decl::Kind to do that easily.
assert(isa<TypeDecl>(D) && "Unsupported decl kind");
break;
}
}
void CodeGenModule::AddDeferredUnusedCoverageMapping(Decl *D) {
// Do we need to generate coverage mapping?
if (!CodeGenOpts.CoverageMapping)
return;
switch (D->getKind()) {
case Decl::CXXConversion:
case Decl::CXXMethod:
case Decl::Function:
case Decl::ObjCMethod:
case Decl::CXXConstructor:
case Decl::CXXDestructor: {
if (!cast<FunctionDecl>(D)->doesThisDeclarationHaveABody())
return;
SourceManager &SM = getContext().getSourceManager();
if (LimitedCoverage && SM.getMainFileID() != SM.getFileID(D->getLocStart()))
return;
auto I = DeferredEmptyCoverageMappingDecls.find(D);
if (I == DeferredEmptyCoverageMappingDecls.end())
DeferredEmptyCoverageMappingDecls[D] = true;
break;
}
default:
break;
};
}
void CodeGenModule::ClearUnusedCoverageMapping(const Decl *D) {
// Do we need to generate coverage mapping?
if (!CodeGenOpts.CoverageMapping)
return;
if (const auto *Fn = dyn_cast<FunctionDecl>(D)) {
if (Fn->isTemplateInstantiation())
ClearUnusedCoverageMapping(Fn->getTemplateInstantiationPattern());
}
auto I = DeferredEmptyCoverageMappingDecls.find(D);
if (I == DeferredEmptyCoverageMappingDecls.end())
DeferredEmptyCoverageMappingDecls[D] = false;
else
I->second = false;
}
void CodeGenModule::EmitDeferredUnusedCoverageMappings() {
// We call takeVector() here to avoid use-after-free.
// FIXME: DeferredEmptyCoverageMappingDecls is getting mutated because
// we deserialize function bodies to emit coverage info for them, and that
// deserializes more declarations. How should we handle that case?
for (const auto &Entry : DeferredEmptyCoverageMappingDecls.takeVector()) {
if (!Entry.second)
continue;
const Decl *D = Entry.first;
switch (D->getKind()) {
case Decl::CXXConversion:
case Decl::CXXMethod:
case Decl::Function:
case Decl::ObjCMethod: {
CodeGenPGO PGO(*this);
GlobalDecl GD(cast<FunctionDecl>(D));
PGO.emitEmptyCounterMapping(D, getMangledName(GD),
getFunctionLinkage(GD));
break;
}
case Decl::CXXConstructor: {
CodeGenPGO PGO(*this);
GlobalDecl GD(cast<CXXConstructorDecl>(D), Ctor_Base);
PGO.emitEmptyCounterMapping(D, getMangledName(GD),
getFunctionLinkage(GD));
break;
}
case Decl::CXXDestructor: {
CodeGenPGO PGO(*this);
GlobalDecl GD(cast<CXXDestructorDecl>(D), Dtor_Base);
PGO.emitEmptyCounterMapping(D, getMangledName(GD),
getFunctionLinkage(GD));
break;
}
default:
break;
};
}
}
/// Turns the given pointer into a constant.
static llvm::Constant *GetPointerConstant(llvm::LLVMContext &Context,
const void *Ptr) {
uintptr_t PtrInt = reinterpret_cast<uintptr_t>(Ptr);
llvm::Type *i64 = llvm::Type::getInt64Ty(Context);
return llvm::ConstantInt::get(i64, PtrInt);
}
static void EmitGlobalDeclMetadata(CodeGenModule &CGM,
llvm::NamedMDNode *&GlobalMetadata,
GlobalDecl D,
llvm::GlobalValue *Addr) {
if (!GlobalMetadata)
GlobalMetadata =
CGM.getModule().getOrInsertNamedMetadata("clang.global.decl.ptrs");
// TODO: should we report variant information for ctors/dtors?
llvm::Metadata *Ops[] = {llvm::ConstantAsMetadata::get(Addr),
llvm::ConstantAsMetadata::get(GetPointerConstant(
CGM.getLLVMContext(), D.getDecl()))};
GlobalMetadata->addOperand(llvm::MDNode::get(CGM.getLLVMContext(), Ops));
}
/// For each function which is declared within an extern "C" region and marked
/// as 'used', but has internal linkage, create an alias from the unmangled
/// name to the mangled name if possible. People expect to be able to refer
/// to such functions with an unmangled name from inline assembly within the
/// same translation unit.
void CodeGenModule::EmitStaticExternCAliases() {
if (!getTargetCodeGenInfo().shouldEmitStaticExternCAliases())
return;
for (auto &I : StaticExternCValues) {
IdentifierInfo *Name = I.first;
llvm::GlobalValue *Val = I.second;
if (Val && !getModule().getNamedValue(Name->getName()))
addUsedGlobal(llvm::GlobalAlias::create(Name->getName(), Val));
}
}
bool CodeGenModule::lookupRepresentativeDecl(StringRef MangledName,
GlobalDecl &Result) const {
auto Res = Manglings.find(MangledName);
if (Res == Manglings.end())
return false;
Result = Res->getValue();
return true;
}
/// Emits metadata nodes associating all the global values in the
/// current module with the Decls they came from. This is useful for
/// projects using IR gen as a subroutine.
///
/// Since there's currently no way to associate an MDNode directly
/// with an llvm::GlobalValue, we create a global named metadata
/// with the name 'clang.global.decl.ptrs'.
void CodeGenModule::EmitDeclMetadata() {
llvm::NamedMDNode *GlobalMetadata = nullptr;
for (auto &I : MangledDeclNames) {
llvm::GlobalValue *Addr = getModule().getNamedValue(I.second);
// Some mangled names don't necessarily have an associated GlobalValue
// in this module, e.g. if we mangled it for DebugInfo.
if (Addr)
EmitGlobalDeclMetadata(*this, GlobalMetadata, I.first, Addr);
}
}
/// Emits metadata nodes for all the local variables in the current
/// function.
void CodeGenFunction::EmitDeclMetadata() {
if (LocalDeclMap.empty()) return;
llvm::LLVMContext &Context = getLLVMContext();
// Find the unique metadata ID for this name.
unsigned DeclPtrKind = Context.getMDKindID("clang.decl.ptr");
llvm::NamedMDNode *GlobalMetadata = nullptr;
for (auto &I : LocalDeclMap) {
const Decl *D = I.first;
llvm::Value *Addr = I.second.getPointer();
if (auto *Alloca = dyn_cast<llvm::AllocaInst>(Addr)) {
llvm::Value *DAddr = GetPointerConstant(getLLVMContext(), D);
Alloca->setMetadata(
DeclPtrKind, llvm::MDNode::get(
Context, llvm::ValueAsMetadata::getConstant(DAddr)));
} else if (auto *GV = dyn_cast<llvm::GlobalValue>(Addr)) {
GlobalDecl GD = GlobalDecl(cast<VarDecl>(D));
EmitGlobalDeclMetadata(CGM, GlobalMetadata, GD, GV);
}
}
}
void CodeGenModule::EmitVersionIdentMetadata() {
llvm::NamedMDNode *IdentMetadata =
TheModule.getOrInsertNamedMetadata("llvm.ident");
std::string Version = getClangFullVersion();
llvm::LLVMContext &Ctx = TheModule.getContext();
llvm::Metadata *IdentNode[] = {llvm::MDString::get(Ctx, Version)};
IdentMetadata->addOperand(llvm::MDNode::get(Ctx, IdentNode));
}
void CodeGenModule::EmitTargetMetadata() {
// Warning, new MangledDeclNames may be appended within this loop.
// We rely on MapVector insertions adding new elements to the end
// of the container.
// FIXME: Move this loop into the one target that needs it, and only
// loop over those declarations for which we couldn't emit the target
// metadata when we emitted the declaration.
for (unsigned I = 0; I != MangledDeclNames.size(); ++I) {
auto Val = *(MangledDeclNames.begin() + I);
const Decl *D = Val.first.getDecl()->getMostRecentDecl();
llvm::GlobalValue *GV = GetGlobalValue(Val.second);
getTargetCodeGenInfo().emitTargetMD(D, GV, *this);
}
}
void CodeGenModule::EmitCoverageFile() {
if (getCodeGenOpts().CoverageDataFile.empty() &&
getCodeGenOpts().CoverageNotesFile.empty())
return;
llvm::NamedMDNode *CUNode = TheModule.getNamedMetadata("llvm.dbg.cu");
if (!CUNode)
return;
llvm::NamedMDNode *GCov = TheModule.getOrInsertNamedMetadata("llvm.gcov");
llvm::LLVMContext &Ctx = TheModule.getContext();
auto *CoverageDataFile =
llvm::MDString::get(Ctx, getCodeGenOpts().CoverageDataFile);
auto *CoverageNotesFile =
llvm::MDString::get(Ctx, getCodeGenOpts().CoverageNotesFile);
for (int i = 0, e = CUNode->getNumOperands(); i != e; ++i) {
llvm::MDNode *CU = CUNode->getOperand(i);
llvm::Metadata *Elts[] = {CoverageNotesFile, CoverageDataFile, CU};
GCov->addOperand(llvm::MDNode::get(Ctx, Elts));
}
}
llvm::Constant *CodeGenModule::EmitUuidofInitializer(StringRef Uuid) {
// Sema has checked that all uuid strings are of the form
// "12345678-1234-1234-1234-1234567890ab".
assert(Uuid.size() == 36);
for (unsigned i = 0; i < 36; ++i) {
if (i == 8 || i == 13 || i == 18 || i == 23) assert(Uuid[i] == '-');
else assert(isHexDigit(Uuid[i]));
}
// The starts of all bytes of Field3 in Uuid. Field 3 is "1234-1234567890ab".
const unsigned Field3ValueOffsets[8] = { 19, 21, 24, 26, 28, 30, 32, 34 };
llvm::Constant *Field3[8];
for (unsigned Idx = 0; Idx < 8; ++Idx)
Field3[Idx] = llvm::ConstantInt::get(
Int8Ty, Uuid.substr(Field3ValueOffsets[Idx], 2), 16);
llvm::Constant *Fields[4] = {
llvm::ConstantInt::get(Int32Ty, Uuid.substr(0, 8), 16),
llvm::ConstantInt::get(Int16Ty, Uuid.substr(9, 4), 16),
llvm::ConstantInt::get(Int16Ty, Uuid.substr(14, 4), 16),
llvm::ConstantArray::get(llvm::ArrayType::get(Int8Ty, 8), Field3)
};
return llvm::ConstantStruct::getAnon(Fields);
}
llvm::Constant *CodeGenModule::GetAddrOfRTTIDescriptor(QualType Ty,
bool ForEH) {
// Return a bogus pointer if RTTI is disabled, unless it's for EH.
// FIXME: should we even be calling this method if RTTI is disabled
// and it's not for EH?
if ((!ForEH && !getLangOpts().RTTI) || getLangOpts().CUDAIsDevice)
return llvm::Constant::getNullValue(Int8PtrTy);
if (ForEH && Ty->isObjCObjectPointerType() &&
LangOpts.ObjCRuntime.isGNUFamily())
return ObjCRuntime->GetEHType(Ty);
return getCXXABI().getAddrOfRTTIDescriptor(Ty);
}
void CodeGenModule::EmitOMPThreadPrivateDecl(const OMPThreadPrivateDecl *D) {
// Do not emit threadprivates in simd-only mode.
if (LangOpts.OpenMP && LangOpts.OpenMPSimd)
return;
for (auto RefExpr : D->varlists()) {
auto *VD = cast<VarDecl>(cast<DeclRefExpr>(RefExpr)->getDecl());
bool PerformInit =
VD->getAnyInitializer() &&
!VD->getAnyInitializer()->isConstantInitializer(getContext(),
/*ForRef=*/false);
Address Addr(GetAddrOfGlobalVar(VD), getContext().getDeclAlign(VD));
if (auto InitFunction = getOpenMPRuntime().emitThreadPrivateVarDefinition(
VD, Addr, RefExpr->getLocStart(), PerformInit))
CXXGlobalInits.push_back(InitFunction);
}
}
llvm::Metadata *CodeGenModule::CreateMetadataIdentifierForType(QualType T) {
llvm::Metadata *&InternalId = MetadataIdMap[T.getCanonicalType()];
if (InternalId)
return InternalId;
if (isExternallyVisible(T->getLinkage())) {
std::string OutName;
llvm::raw_string_ostream Out(OutName);
getCXXABI().getMangleContext().mangleTypeName(T, Out);
InternalId = llvm::MDString::get(getLLVMContext(), Out.str());
} else {
InternalId = llvm::MDNode::getDistinct(getLLVMContext(),
llvm::ArrayRef<llvm::Metadata *>());
}
return InternalId;
}
// Generalize pointer types to a void pointer with the qualifiers of the
// originally pointed-to type, e.g. 'const char *' and 'char * const *'
// generalize to 'const void *' while 'char *' and 'const char **' generalize to
// 'void *'.
static QualType GeneralizeType(ASTContext &Ctx, QualType Ty) {
if (!Ty->isPointerType())
return Ty;
return Ctx.getPointerType(
QualType(Ctx.VoidTy).withCVRQualifiers(
Ty->getPointeeType().getCVRQualifiers()));
}
// Apply type generalization to a FunctionType's return and argument types
static QualType GeneralizeFunctionType(ASTContext &Ctx, QualType Ty) {
if (auto *FnType = Ty->getAs<FunctionProtoType>()) {
SmallVector<QualType, 8> GeneralizedParams;
for (auto &Param : FnType->param_types())
GeneralizedParams.push_back(GeneralizeType(Ctx, Param));
return Ctx.getFunctionType(
GeneralizeType(Ctx, FnType->getReturnType()),
GeneralizedParams, FnType->getExtProtoInfo());
}
if (auto *FnType = Ty->getAs<FunctionNoProtoType>())
return Ctx.getFunctionNoProtoType(
GeneralizeType(Ctx, FnType->getReturnType()));
llvm_unreachable("Encountered unknown FunctionType");
}
llvm::Metadata *CodeGenModule::CreateMetadataIdentifierGeneralized(QualType T) {
T = GeneralizeFunctionType(getContext(), T);
llvm::Metadata *&InternalId = GeneralizedMetadataIdMap[T.getCanonicalType()];
if (InternalId)
return InternalId;
if (isExternallyVisible(T->getLinkage())) {
std::string OutName;
llvm::raw_string_ostream Out(OutName);
getCXXABI().getMangleContext().mangleTypeName(T, Out);
Out << ".generalized";
InternalId = llvm::MDString::get(getLLVMContext(), Out.str());
} else {
InternalId = llvm::MDNode::getDistinct(getLLVMContext(),
llvm::ArrayRef<llvm::Metadata *>());
}
return InternalId;
}
/// Returns whether this module needs the "all-vtables" type identifier.
bool CodeGenModule::NeedAllVtablesTypeId() const {
// Returns true if at least one of vtable-based CFI checkers is enabled and
// is not in the trapping mode.
return ((LangOpts.Sanitize.has(SanitizerKind::CFIVCall) &&
!CodeGenOpts.SanitizeTrap.has(SanitizerKind::CFIVCall)) ||
(LangOpts.Sanitize.has(SanitizerKind::CFINVCall) &&
!CodeGenOpts.SanitizeTrap.has(SanitizerKind::CFINVCall)) ||
(LangOpts.Sanitize.has(SanitizerKind::CFIDerivedCast) &&
!CodeGenOpts.SanitizeTrap.has(SanitizerKind::CFIDerivedCast)) ||
(LangOpts.Sanitize.has(SanitizerKind::CFIUnrelatedCast) &&
!CodeGenOpts.SanitizeTrap.has(SanitizerKind::CFIUnrelatedCast)));
}
void CodeGenModule::AddVTableTypeMetadata(llvm::GlobalVariable *VTable,
CharUnits Offset,
const CXXRecordDecl *RD) {
llvm::Metadata *MD =
CreateMetadataIdentifierForType(QualType(RD->getTypeForDecl(), 0));
VTable->addTypeMetadata(Offset.getQuantity(), MD);
if (CodeGenOpts.SanitizeCfiCrossDso)
if (auto CrossDsoTypeId = CreateCrossDsoCfiTypeId(MD))
VTable->addTypeMetadata(Offset.getQuantity(),
llvm::ConstantAsMetadata::get(CrossDsoTypeId));
if (NeedAllVtablesTypeId()) {
llvm::Metadata *MD = llvm::MDString::get(getLLVMContext(), "all-vtables");
VTable->addTypeMetadata(Offset.getQuantity(), MD);
}
}
TargetAttr::ParsedTargetAttr CodeGenModule::filterFunctionTargetAttrs(const TargetAttr *TD) {
assert(TD != nullptr);
TargetAttr::ParsedTargetAttr ParsedAttr = TD->parse();
ParsedAttr.Features.erase(
llvm::remove_if(ParsedAttr.Features,
[&](const std::string &Feat) {
return !Target.isValidFeatureName(
StringRef{Feat}.substr(1));
}),
ParsedAttr.Features.end());
return ParsedAttr;
}
// Fills in the supplied string map with the set of target features for the
// passed in function.
void CodeGenModule::getFunctionFeatureMap(llvm::StringMap<bool> &FeatureMap,
const FunctionDecl *FD) {
StringRef TargetCPU = Target.getTargetOpts().CPU;
if (const auto *TD = FD->getAttr<TargetAttr>()) {
TargetAttr::ParsedTargetAttr ParsedAttr = filterFunctionTargetAttrs(TD);
// Make a copy of the features as passed on the command line into the
// beginning of the additional features from the function to override.
ParsedAttr.Features.insert(ParsedAttr.Features.begin(),
Target.getTargetOpts().FeaturesAsWritten.begin(),
Target.getTargetOpts().FeaturesAsWritten.end());
if (ParsedAttr.Architecture != "" &&
Target.isValidCPUName(ParsedAttr.Architecture))
TargetCPU = ParsedAttr.Architecture;
// Now populate the feature map, first with the TargetCPU which is either
// the default or a new one from the target attribute string. Then we'll use
// the passed in features (FeaturesAsWritten) along with the new ones from
// the attribute.
Target.initFeatureMap(FeatureMap, getDiags(), TargetCPU,
ParsedAttr.Features);
} else {
Target.initFeatureMap(FeatureMap, getDiags(), TargetCPU,
Target.getTargetOpts().Features);
}
}
llvm::SanitizerStatReport &CodeGenModule::getSanStats() {
if (!SanStats)
SanStats = llvm::make_unique<llvm::SanitizerStatReport>(&getModule());
return *SanStats;
}
llvm::Value *
CodeGenModule::createOpenCLIntToSamplerConversion(const Expr *E,
CodeGenFunction &CGF) {
llvm::Constant *C = ConstantEmitter(CGF).emitAbstract(E, E->getType());
auto SamplerT = getOpenCLRuntime().getSamplerType(E->getType().getTypePtr());
auto FTy = llvm::FunctionType::get(SamplerT, {C->getType()}, false);
return CGF.Builder.CreateCall(CreateRuntimeFunction(FTy,
"__translate_sampler_initializer"),
{C});
}
| [
"1634054493@qq.com"
] | 1634054493@qq.com |
87c5ff622e086e6fec034d0de46ce9ddf9350eb1 | 1a5a3b9f8675000cf94b1a6797a909e1a0fcc40e | /src/client/src/Util/CRandom.h | 5eacfea5522927ef249058cadb0c2498ea5e6d6e | [] | no_license | Davidixx/client | f57e0d82b4aeec75394b453aa4300e3dd022d5d7 | 4c0c1c0106c081ba9e0306c14607765372d6779c | refs/heads/main | 2023-07-29T19:10:20.011837 | 2021-08-11T20:40:39 | 2021-08-11T20:40:39 | 403,916,993 | 0 | 0 | null | 2021-09-07T09:21:40 | 2021-09-07T09:21:39 | null | UTF-8 | C++ | false | false | 840 | h | #ifndef __CRANDOM_H
#define __CRANDOM_H
#include "LIB_Util.h"
//-------------------------------------------------------------------------------------------------
#define MAX_RANDOM_FUNC 4
#define CRandom CR001
#define AcRANDOM R_AC
#define BcRANDOM R_BC
#define VcRANDOM R_VC
#define MyRANDOM R_MY
class CR001 {
private:
DWORD m_dwVcCallCnt;
DWORD m_dwBcCallCnt;
DWORD m_dwAcCallCnt;
DWORD m_dwMyCallCnt;
BYTE m_btType;
int m_iVcSeed;
int m_iBcSeed;
int m_iAcSeed;
int m_iMySeed;
// DECLARE_INSTANCE( CR001 )
public :
void Init(DWORD dwSeed);
void SetType(BYTE btRandTYPE);
int Get();
int R_AC();
int R_BC();
int R_VC();
int R_MY();
};
//-------------------------------------------------------------------------------------------------
#endif
| [
"ralphminderhoud@gmail.com"
] | ralphminderhoud@gmail.com |
3ded8ff09b3759baa49bf473fd4b7e29a90d34fa | 6b342e06bf8ec9bf89af44eb96bb716240947981 | /380.cpp | c53144a44ce74d887c6113a731d8ee40b6192c3e | [] | no_license | githubcai/leetcode | d822198f07db33ffbb1bc98813e5cd332be56562 | 4b63186b522cb80a0bc4939a89f5b6294c1b11ca | refs/heads/master | 2021-01-13T03:32:38.704206 | 2017-03-14T02:06:35 | 2017-03-14T02:06:35 | 77,529,061 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 1,174 | cpp | class RandomizedSet {
unordered_map<int, int> ref;
vector<int> nums;
public:
/** Initialize your data structure here. */
RandomizedSet() {
}
/** Inserts a value to the set. Returns true if the set did not already contain the specified element. */
bool insert(int val) {
if(ref.find(val) != ref.end()) return false;
ref[val] = nums.size();
nums.push_back(val);
return true;
}
/** Removes a value from the set. Returns true if the set contained the specified element. */
bool remove(int val) {
auto iter = ref.find(val);
if(iter == ref.end()) return false;
nums[iter->second] = nums.back();
ref[nums.back()] = iter->second;
nums.pop_back();
ref.erase(iter);
return true;
}
/** Get a random element from the set. */
int getRandom() {
return nums[rand() % nums.size()];
}
};
/**
* Your RandomizedSet object will be instantiated and called as such:
* RandomizedSet obj = new RandomizedSet();
* bool param_1 = obj.insert(val);
* bool param_2 = obj.remove(val);
* int param_3 = obj.getRandom();
*/
| [
"2468085704@qq.com"
] | 2468085704@qq.com |
b48866513c4f541a250b2a2a844d90722c0274ba | a787a0b9859be15e838e29215cb77543b995c826 | /C++ projects/Maze Solver/kruskalishmaze.cpp | 7b41f774787379e765dcf95e3c87c977e038775f | [] | no_license | AdamMoffitt/portfolio | 675e46f0b308ad06a095a4b0cdb28d4694fe7782 | 198d88c13eff4f7579863cc5a0e2d02f756f2647 | refs/heads/master | 2023-01-13T12:09:01.052253 | 2020-04-29T15:31:44 | 2020-04-29T15:31:44 | 56,955,304 | 2 | 1 | null | 2023-01-09T12:17:06 | 2016-04-24T05:13:08 | HTML | UTF-8 | C++ | false | false | 2,850 | cpp | #include "kruskalishmaze.h"
#include "ufds.h"
#include <cstdlib>
#include <time.h>
KruskalishMaze::KruskalishMaze(int numRows, int numCols, int startX, int startY, int goalX, int goalY, bool simple)
: Maze(numRows, numCols, startX, startY, goalX, goalY), _maze(numRows)
{
for (int i=0; i < numRows; i++)
{
_maze[i].resize( numCols );
}
createMaze(simple);
}
bool KruskalishMaze::canTravel(Direction d, int row, int col) const
{
return ! _maze[row][col].walls[d];
}
void KruskalishMaze::destroyWall(Direction d, int row, int col)
{
_maze[row][col].walls[d] = false;
}
Direction randdir()
{
switch( rand() % 4 )
{
case 0: return UP;
case 1: return DOWN;
case 2: return LEFT;
default: return RIGHT;
}
}
/*
* Creates a Maze where any two squares have a unique path between them
in a Kruskalish fashion.
*/
void KruskalishMaze::createMaze(bool simpleMaze)
{
long seed = time(NULL);
srand(seed);
int rows = numRows();
int cols = numCols();
UnionFind uf(rows * cols);
int numComponents = rows * cols;
int row, col, otherrow, othercol, component1, component2;
Direction dir, otherdir;
while( numComponents > 1 )
{
row = otherrow = rand() % numRows();
col = othercol = rand() % numCols();
dir = randdir();
switch(dir)
{
case UP: otherrow--; otherdir = DOWN; break;
case DOWN: otherrow++; otherdir = UP; break;
case LEFT: othercol--; otherdir = RIGHT; break;
case RIGHT: othercol++; otherdir = LEFT; break;
}
component1 = row * numRows() + col;
component2 = otherrow * numRows() + othercol;
if( otherrow >= 0 && otherrow < numRows()
&& othercol >= 0 && othercol < numCols()
&& ! uf.same(component1, component2) )
{
destroyWall(dir, row, col);
destroyWall(otherdir, otherrow, othercol);
uf.merge(component1, component2);
numComponents--;
}
}
// The maze now has a unique solution. That's a simple maze.
// If we don't want a simple maze, let's destroy some interior walls.
if( ! simpleMaze )
{
const int WALLS_TO_DESTROY = numRows() * numCols() / 10;
for( int i=0; i < WALLS_TO_DESTROY; i++)
{
row = otherrow = rand() % numRows();
col = othercol = rand() % numCols();
dir = randdir();
switch(dir)
{
case UP: otherrow--; otherdir = DOWN; break;
case DOWN: otherrow++; otherdir = UP; break;
case LEFT: othercol--; otherdir = RIGHT; break;
case RIGHT: othercol++; otherdir = LEFT; break;
}
if( otherrow >= 0 && otherrow < numRows()
&& othercol >= 0 && othercol < numCols() )
{
destroyWall(dir, row, col);
destroyWall(otherdir, otherrow, othercol);
}
else
i--;
}
}
}
| [
"admoffit@"
] | admoffit@ |
07881a6c9a1914d68076e2853bc42a08c92df7bf | 77013b8303a10d0c937c9ca2bbba20dd35d53bbf | /Math/gcd.cpp | 56e1d89b6c46383172e3b118572e2c5eee4ba683 | [
"MIT"
] | permissive | aneesh001/InterviewBit | 9d10febfcace743b2335acdfcca0f2265c647d8d | fcbac096fd8e9554a52db10dc9e5a88cb8a83ef3 | refs/heads/master | 2020-03-18T06:05:36.438449 | 2018-07-01T06:02:57 | 2018-07-01T06:02:57 | 134,376,158 | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 143 | cpp | #include <bits/stdc++.h>
using namespace std;
int gcd(int A, int B) {
if(B == 0) return A;
else return gcd(B, A % B);
}
int main(void) {
} | [
"aneeshd00812@gmail.com"
] | aneeshd00812@gmail.com |
00d87c6cab7668c9d806b1f018d6f8d5336cb806 | 68cf8767e067611fed434e176ac932bcdbf8ecb4 | /1685.cpp | 4b2dc6291f67814fe5e9e4c7e84f5470541e6b79 | [] | no_license | zhsenl/online-judge | b72d45aa894a566b6377cb16fe83ed61c6475a9a | e560eec265aa894b0b4ffe6310e312450f656625 | refs/heads/master | 2020-05-18T16:29:34.043515 | 2014-03-13T06:59:51 | 2014-03-13T06:59:51 | null | 0 | 0 | null | null | null | null | UTF-8 | C++ | false | false | 508 | cpp | //#include <iostream>
//using namespace std;
//
//const int N = 1005;
//int n, arr[N];
//
//int main(){
// while(cin >> n && n){
// for(int i = 0; i < n; i++) cin >> arr[i];
// int ans = 1;
// for(int i = 1; i < n; i++){
// if(ans % 2 == 1 && arr[i] < arr[i - 1]) ans ++;
// if(ans % 2 == 0 && arr[i] > arr[i - 1]) ans ++;
// }
// cout << ans << endl;
// }
//
//}
/*
f[i] = f[i - 1] + 1 when (f[i - 1] % 2 == 0 and a[i] > a[i - 1]) or (f[i - 1] % 2 == 1 and a[i] < a[i - 1])
+ 0 otherwise
*/ | [
"zhsenl@qq.com"
] | zhsenl@qq.com |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.