code
stringlengths
1
2.06M
language
stringclasses
1 value
#include <iostream> #include <vector> using std::cin; using std::cout; using std::vector; using std::swap; using std::distance; void Input(vector <int> *list) { int count; cin >> count; list->reserve(count); int element; for (int i(0); i < count; ++i) { cin >> element; ...
C++
#include <iostream> #include <vector> using std::cin; using std::cout; using std::vector; using std::swap; using std::distance; void Input(vector <int> *list) { int count; cin >> count; list->reserve(count); int element; for (int i(0); i < count; ++i) { cin >> element; ...
C++
#include <iostream> #include <vector> using std::cin; using std::cout; using std::vector; using std::swap; void Input(vector <int> *list) { int count; cin >> count; list->reserve(count); int element; for (int i(0); i < count; ++i) { cin >> element; list->push_back(elem...
C++
#include <iostream> #include <algorithm> #include <vector> #include <ctime> using std::cin; using std::cout; using std::vector; using std::swap; using std::distance; using std::pair; using std::make_pair; void Input(vector <int> *list) { int count; cin >> count; list->reserve(count); in...
C++
#include <iostream> #include <string> #include <algorithm> #include <vector> #include <ctime> using std::string; using std::vector; using std::min; using std::cin; using std::cout; using std::endl; class BullsAndCows { struct Value { vector <int> count_of_number; vector <int> number;...
C++
#include <iostream> #include <vector> #include <set> #include <algorithm> using std::vector; using std::cin; using std::cout; using std::set; using std::pair; using std::make_pair; using std::min; class Graph { struct Vertex { double x, y; int number; vector <Vertex*> edges; Vertex...
C++
#include <iostream> #include <vector> #include <set> #include <algorithm> using std::vector; using std::cin; using std::cout; using std::set; using std::pair; using std::make_pair; using std::min; class Graph { struct Vertex { int interval_number; bool type; // 0 - begin, 1 - end vector <V...
C++
#include <iostream> #include <vector> #include <set> #include <algorithm> using std::abs; using std::vector; using std::cin; using std::cout; using std::set; using std::pair; using std::make_pair; using std::min; const int INF = 1000000001; class Field { struct Point { int x, y, weight;...
C++
#include <iostream> #include <vector>` #include <set> #include <algorithm> using std::vector; using std::cin; using std::cout; using std::set; using std::pair; using std::make_pair; using std::min; class Field { struct Point { int x, y, weight; Point(): x(0), y(0), weight(0){} Point(int new_x,...
C++
#include <iostream> #include <vector>` #include <set> #include <algorithm> using std::vector; using std::cin; using std::cout; using std::set; using std::pair; using std::make_pair; using std::min; class Field { struct Point { int x, y, weight; Point(): x(0), y(0), weight(0){} Point(int new_x,...
C++
#include <algorithm> #include <cstdio> #include <iostream> #include <vector> using std::cin; using std::cout; using std::vector; template <typename InputIterator> void iteration(InputIterator first, InputIterator last) { if (first == last) { return; } auto max_iterator = first, last_elem_iterator ...
C++
#include <algorithm> #include <cstdio> #include <iostream> #include <vector> using std::cin; using std::cout; using std::vector; template <typename InputIterator, typename TKey> InputIterator my_partition(InputIterator begin, InputIterator end, TKey key) { auto iter = begin; while (begin != end) { if ...
C++
#include <algorithm> #include <cstdio> #include <iostream> #include <vector> using std::cin; using std::copy; using std::cout; using std::vector; template <typename InputIterator, typename OutputIterator> void my_merge(InputIterator first_begin, InputIterator first_end, InputIterator second_begin, Input...
C++
#include <algorithm> #include <cstdio> #include <iostream> #include <vector> using std::cin; using std::cout; using std::vector; template <typename InputIterator, typename OutputIterator> void my_merge(InputIterator first_begin, InputIterator first_end, InputIterator second_begin, InputIterator second_e...
C++
#include <algorithm> #include <cstdio> #include <iostream> #include <vector> using std::cin; using std::cout; using std::vector; template <typename InputIterator> void iteration(InputIterator first, InputIterator last) { if (first == last) { return; } auto max_iterator = first, last_elem_iterator ...
C++
#include <iostream> #include <cstdio> #include <vector> using std::vector; using std::cin; using std::cout; using std::min; void input(vector <vector <int> > &cost, vector <vector <int> > &dp) { int n, m; cin >> n >> m; cost.resize(n); dp.resize(n); for (int i = 0; i < n; i++) { dp[i].resi...
C++
#include <iostream> #include <cstdio> #include <vector> #include <deque> #include <algorithm> using std::vector; using std::cin; using std::cout; using std::min; using std::pair; using std::reverse; void input(vector < vector <int> > &lst) { int n, a, b; cin >> n; lst.resize(2 * n); for (int i = 0; i ...
C++
#include <iostream> #include <cstdio> #include <vector> #include <deque> using std::vector; using std::cin; using std::cout; using std::min; using std::pair; using std::deque; using std::make_pair; int dx[] = {0, 0, -1, 1}; int dy[] = {1, -1, 0, 0}; void input(vector < vector <int> > &matrix, pair <int, int> &s, pai...
C++
#include <iostream> #include <cstdio> #include <vector> using std::vector; using std::cin; using std::cout; using std::min; struct Point { int x, y; Point(int x = 0, int y = 0) : x(x), y(y) {} int dist(const Point &other) const { return (x - other.x) * (x - other.x) + (y - other.y) * (y - other.y)...
C++
#include <iostream> #include <cstdio> #include <vector> using std::vector; using std::cin; using std::cout; using std::min; const int MOD = 268435459; void input(vector <vector <int> > &open, vector <vector <int> > &dp) { int n, m; cin >> n >> m; open.resize(n); dp.resize(n); for (int i = 0; i < ...
C++
#include <algorithm> #include <cstdio> #include <iostream> #include <vector> using std::cin; using std::cout; using std::vector; using std::pair; template <typename InputIterator, typename TKey> pair <InputIterator, InputIterator> my_partition(InputIterator begin, InputIterator end, ...
C++
#include <iostream> #include "Matrix.h" using namespace std; int main() { cout<<"Main"<<endl; return 0; }
C++
class Matrix { int **matrix; int size; public: Matrix(); Matrix(int); void initialize(int[3][3]); void set(int,int,int); int get(int,int); Matrix* operator + (Matrix&); Matrix* operator - (Matrix&); Matrix* operator * (Matrix&); ~Matrix(); };
C++
#include <limits.h> #include "Matrix.h" #include "gtest/gtest.h" TEST(Test1, Add_two_matrices) { Matrix A(3), B(3), *C; int input1[3][3] = {{1,3,2},{2,5,4},{6,7,1}}; int input2[3][3] = {{1,7,5},{3,5,5},{-1,4,-2}}; int output[3][3] = {{2,10,7},{5,10,9},{5,11,-1}}; A.initialize(input1); B.initialize(input2); C =...
C++
#include <iostream> #include "Matrix.h" using namespace std; Matrix::Matrix() { } Matrix::Matrix(int n) { size = n; matrix = new int*[size]; for(int i=0; i<size; i++) matrix[i] = new int[size]; } void Matrix::initialize(int values[3][3]) { for(int i=0; i<size; i++) for(int j=0; j<size; j...
C++
/* * Copyright (C) 2007 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by appli...
C++
#include "LutController.h" #include "MainWindow.h" #include <QtDebug> LutController *LutController::instance = 0; LutController::LutController() { users = new UserList(this); window = new MainWindow(); } LutController* LutController::getInstance() { if(!instance) instance = new LutController(); ; return instan...
C++
#ifndef MAINWINDOW_H #define MAINWINDOW_H #include <QMainWindow> #include <QtNetwork> #include <QSystemTrayIcon> #include <QSettings> #include <QListWidgetItem> #include "LutController.h" #include "User.h" class DiscussPane; namespace Ui { class MainWindow; } class MainWindow : public QMainWindow { Q_OBJECT p...
C++
#ifndef USERLIST_H #define USERLIST_H #include <QAbstractListModel> #include "User.h" class UserList : public QAbstractListModel { Q_OBJECT public: explicit UserList(QObject *parent = 0); QVariant data(const QModelIndex &index, int role) const; int rowCount(const QModelIndex &parent) const; Qt::ItemFlags...
C++
#include "User.h" User::User(int id, QString name) : id(id), name(name) { } User::User(QString data) { QStringList infos = data.split(" "); id = infos.at(0).toInt(); name = infos.at(1); } int User::getId() { return id; } QString User::getName() { return name; } void User::setId(int val) { id = val; } vo...
C++
#include <QtGui/QApplication> #include "LutController.h" int main(int argc, char *argv[]) { QApplication *a = new QApplication(argc, argv); a->setQuitOnLastWindowClosed(false); LutController *ctrl = LutController::getInstance(); QApplication::connect(ctrl, SIGNAL(quitMe()), a, SLOT(quit())); ctrl->startApp();...
C++
#include "UserList.h" #include "LutController.h" UserList::UserList(QObject *parent) : QAbstractListModel(parent) { users = new QList<User*>(); } QVariant UserList::data(const QModelIndex &index, int role) const { if (!index.isValid()) return QVariant(); if (index.row() >= users->size()) return QVariant();...
C++
#include "DiscussPane.h" #include "ui_DiscussPane.h" #include "LutController.h" DiscussPane::DiscussPane(int gid, QWidget *parent) : QWidget(parent), ui(new Ui::DiscussPane), guyId(gid) { ui->setupUi(this); ui->textBrowser->setOpenExternalLinks(true); connect(ui->lineEdit, SIGNAL(returnPressed()), ui->pushBu...
C++
#ifndef USER_H #define USER_H #include <QString> #include <QStringList> class User // : public QListWidgetItem { public: User(int id, QString name); User(QString data); int getId(); QString getName(); void setId(int val); void setName(QString n); private: int id; QString name; }; #endif // USER_H
C++
#include "MainWindow.h" #include "ui_MainWindow.h" #include <QInputDialog> #include <QStringList> #include <QUrl> #include "DiscussPane.h" MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow), nickname("Anonymous"), settings("01Lut", "01Lut") { setAttribute(Qt::WA_DeleteOnClo...
C++
#ifndef LUTCONTROLLER_H #define LUTCONTROLLER_H #include <QObject> #include "UserList.h" class MainWindow; class LutController : public QObject { Q_OBJECT public: static LutController* getInstance(); int myId(); QString getNameFromId(int id); void sendMsg(QString str); void sendPrivateMsg(int to, QString ...
C++
#ifndef PRIVATEPANE_H #define PRIVATEPANE_H #include <QWidget> #include "User.h" #include "MainWindow.h" namespace Ui { class DiscussPane; } class DiscussPane : public QWidget { Q_OBJECT signals: void toRead(DiscussPane*); public: explicit DiscussPane(int gid = -1, QWidget *parent = 0); ~DiscussPane(); ...
C++
#include "log.hpp" Log::Log(FString path) { if((file = open(path.data(), O_WRONLY|O_APPEND|O_CREAT, S_IRUSR|S_IWUSR))<0) { cout << "Cannot open log file" << endl; } } Log::~Log() { close(file); } void Log::logger(FString data) { FString str = dateLog(); str.erase(str.size()-1, 1); str += "\t"; str += dat...
C++
#include <iostream> #include <arpa/inet.h> #include <netdb.h> #include <netinet/in.h> #include <unistd.h> #include <sys/select.h> #include <sys/types.h> #include <time.h> #include "prompt.hpp" #include "log.hpp" #include "fstring.hpp" #include "user.hpp" #define BUFFSIZE 100000 #define CMAX 990 using namespace std...
C++
#include "user.hpp" User::User(int sock) { this->sock = sock; name = "Anonymous"; registered = false; } User::~User() { } int User::getSock() { return sock; } FString User::getName() { return this->name; } void User::setName(FString str) { this->name = str; } void User::registerMe() { registered = true; }...
C++
#include "prompt.hpp" /** Constructeur de Prompt */ Prompt::Prompt() : welcome(true) { } /** Destructeur de l'objet */ Prompt::~Prompt() { } /** Les méthodes qui suivent doivent être redéfinies dans les classes dérivées. Ici est simplement définit un comportement par défaut pour chacune d'entre elles, comport...
C++
#ifndef USER_H #define USER_H #include "fstring.hpp" class User { public: User(int sock); ~User(); FString getName(); int getSock(); void setName(FString str); bool isRegistered(); void registerMe(); private: FString name; int sock; bool registered; }; #endif
C++
#include "person.hpp" Person::Person(int _sock) { sock = _sock; name = "Sans nom"; } Person::~Person() { } Person::setName(FString n) { name = n; }
C++
#ifndef FRONTEND_H #define FRONTEND_H /* Cette classe fournit une interface à un backend client (voire serveur) */ #include "fstring.hpp" class Frontend { public: Frontend(){}; virtual void updateBids() = 0; virtual void serverReady() = 0; }; #endif
C++
#include "fstring.hpp" // TEST class Person { public: Person(int _sock); ~Person(); void setName(FString n); private: FString name; int sock; }
C++
#include "server.hpp" #include "fstring.hpp" #include <unistd.h> #include <stdio.h> int main(int argc, char** argv) { int port = 1888; FString logDir = "/var/log/"; char c; FString str; while( (c = getopt(argc, argv, "p:d:")) != EOF ) { switch(c) { case 'p': str = optarg; port = str.toInt(); ...
C++
#ifndef LOG_H #define LOG_H #include <iostream> #include "fstring.hpp" #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> using namespace std; class Log { public: Log(FString path); ~Log(); void logger(FString data); private: int file; FString dateLog(); }...
C++
#include "fstring.hpp" #include <sstream> /** Constructeur de la classe Permet de créer un objet de type FString */ FString::FString() : std::string() { } /** Constructeur de la classe Permet de créer un objet de type FString à partir d'une chaine de caractere */ FString::FString(const char *s) : std::string...
C++
#ifndef FSTRING_HPP #define FSTRING_HPP /** 01/12/2009 -- Cette classe représente une std::string sur laquelle une méthode split() peut être appelée -> Créée pour simplifier l'interprétations des requêtes Ne pas hésiter à rajouter des méthodes qui simplifient l'usage des chaînes de caractères */ #include...
C++
#include <iostream> #include <netdb.h> #include <netinet/in.h> #include <unistd.h> #include "log.hpp" #include "fstring.hpp" #include "prompt.hpp" #define BUFFSIZE 512 using namespace std; /* * Cette classe représente un client * * Elle aussi hérite de prompt :) :) */ class Client : public Prompt { public: Cl...
C++
#include "client.hpp" /** Permet de lancer un client en mode Shell **/ int main(int argc, char **argv) { FString adresse = ""; if(argc > 1) adresse += argv[1]; if(adresse.compare("") == 0) { adresse = "127.0.0.1"; } Client c(adresse.data()); c.start(); return 0; }
C++
#include <cstdio> #include "server.hpp" /** Constructeur d'un objet Serveur */ Server::Server(int port, FString logDir) { nbClients = 0; lport = port; activate = false; for(int i=0; i<CMAX; i++) clients[i] = 0; // set the address structure serverAddress.sin_family = AF_INET; serverAddress.sin_addr.s_addr = h...
C++
#ifndef PROMPT_H #define PROMPT_H /** Freddy Teuma - 28/11/2009 -- Cette classe permet de faire l'interface entre une commande et une action. Dériver cette classe et implémenter les méthodes abstraites. */ #include <iostream> #include <string.h> #include "fstring.hpp" using namespace std; class Prompt { pub...
C++
#include "client.hpp" #include <sstream> /** Constructeur de la classe */ Client::Client(const char* adresse) { dport = 1888; activate = false; connected = false; hostInfo = gethostbyname(adresse); addressServer = (char*)adresse; if(hostInfo != NULL) { serverAddress.sin_family = hostInfo->h_addrtype; mem...
C++
#include "log.hpp" Log::Log(FString path) { if((file = open(path.data(), O_WRONLY|O_APPEND|O_CREAT, S_IRUSR|S_IWUSR))<0) { cout << "Cannot open log file" << endl; } } Log::~Log() { close(file); } void Log::logger(FString data) { FString str = dateLog(); str.erase(str.size()-1, 1); str += "\t"; str += dat...
C++
#include <iostream> #include <arpa/inet.h> #include <netdb.h> #include <netinet/in.h> #include <unistd.h> #include <sys/select.h> #include <sys/types.h> #include <time.h> #include "prompt.hpp" #include "log.hpp" #include "fstring.hpp" #include "user.hpp" #define BUFFSIZE 100000 #define CMAX 990 using namespace std...
C++
#include "user.hpp" User::User(int sock) { this->sock = sock; name = "Anonymous"; registered = false; } User::~User() { } int User::getSock() { return sock; } FString User::getName() { return this->name; } void User::setName(FString str) { this->name = str; } void User::registerMe() { registered = true; }...
C++
#include "prompt.hpp" /** Constructeur de Prompt */ Prompt::Prompt() : welcome(true) { } /** Destructeur de l'objet */ Prompt::~Prompt() { } /** Les méthodes qui suivent doivent être redéfinies dans les classes dérivées. Ici est simplement définit un comportement par défaut pour chacune d'entre elles, comport...
C++
#ifndef USER_H #define USER_H #include "fstring.hpp" class User { public: User(int sock); ~User(); FString getName(); int getSock(); void setName(FString str); bool isRegistered(); void registerMe(); private: FString name; int sock; bool registered; }; #endif
C++
#include "person.hpp" Person::Person(int _sock) { sock = _sock; name = "Sans nom"; } Person::~Person() { } Person::setName(FString n) { name = n; }
C++
#ifndef FRONTEND_H #define FRONTEND_H /* Cette classe fournit une interface à un backend client (voire serveur) */ #include "fstring.hpp" class Frontend { public: Frontend(){}; virtual void updateBids() = 0; virtual void serverReady() = 0; }; #endif
C++
#include "fstring.hpp" // TEST class Person { public: Person(int _sock); ~Person(); void setName(FString n); private: FString name; int sock; }
C++
#include "server.hpp" #include "fstring.hpp" #include <unistd.h> #include <stdio.h> int main(int argc, char** argv) { int port = 1888; FString logDir = "/var/log/"; char c; FString str; while( (c = getopt(argc, argv, "p:d:")) != EOF ) { switch(c) { case 'p': str = optarg; port = str.toInt(); ...
C++
#ifndef LOG_H #define LOG_H #include <iostream> #include "fstring.hpp" #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> using namespace std; class Log { public: Log(FString path); ~Log(); void logger(FString data); private: int file; FString dateLog(); }...
C++
#include "fstring.hpp" #include <sstream> /** Constructeur de la classe Permet de créer un objet de type FString */ FString::FString() : std::string() { } /** Constructeur de la classe Permet de créer un objet de type FString à partir d'une chaine de caractere */ FString::FString(const char *s) : std::string...
C++
#ifndef FSTRING_HPP #define FSTRING_HPP /** 01/12/2009 -- Cette classe représente une std::string sur laquelle une méthode split() peut être appelée -> Créée pour simplifier l'interprétations des requêtes Ne pas hésiter à rajouter des méthodes qui simplifient l'usage des chaînes de caractères */ #include...
C++
#include <iostream> #include <netdb.h> #include <netinet/in.h> #include <unistd.h> #include "log.hpp" #include "fstring.hpp" #include "prompt.hpp" #define BUFFSIZE 512 using namespace std; class Client : public Prompt { public: Client(const char* adresse); ~Client(); void start(); void stop(); void upd...
C++
#include "client.hpp" /** Permet de lancer un client en mode Shell **/ int main(int argc, char **argv) { FString adresse = ""; if(argc > 1) adresse += argv[1]; if(adresse.compare("") == 0) { adresse = "127.0.0.1"; } Client c(adresse.data()); c.start(); return 0; }
C++
#include <cstdio> #include "server.hpp" /** Constructeur d'un objet Serveur */ Server::Server(int port, FString logDir) { nbClients = 0; lport = port; activate = false; for(int i=0; i<CMAX; i++) clients[i] = 0; // set the address structure serverAddress.sin_family = AF_INET; serverAddress.sin_addr.s_addr = h...
C++
#ifndef PROMPT_H #define PROMPT_H /** Freddy Teuma - 28/11/2009 -- Cette classe permet de faire l'interface entre une commande et une action. Dériver cette classe et implémenter les méthodes abstraites. */ #include <iostream> #include <string.h> #include "fstring.hpp" using namespace std; class Prompt { pub...
C++
#include "client.hpp" #include <sstream> /** Constructeur de la classe */ Client::Client(const char* adresse) { dport = 1888; activate = false; connected = false; hostInfo = gethostbyname(adresse); addressServer = (char*)adresse; if(hostInfo != NULL) { serverAddress.sin_family = hostInfo->h_addrtype; mem...
C++
#include "LutController.h" #include "MainWindow.h" #include <QtDebug> LutController *LutController::instance = 0; LutController::LutController() { users = new UserList(this); window = new MainWindow(); } LutController* LutController::getInstance() { if(!instance) instance = new LutController(); ; return instan...
C++
#ifndef MAINWINDOW_H #define MAINWINDOW_H #include <QMainWindow> #include <QtNetwork> #include <QSystemTrayIcon> #include <QSettings> #include <QListWidgetItem> #include "LutController.h" #include "User.h" class DiscussPane; namespace Ui { class MainWindow; } class MainWindow : public QMainWindow { Q_OBJECT p...
C++
#ifndef USERLIST_H #define USERLIST_H #include <QAbstractListModel> #include "User.h" class UserList : public QAbstractListModel { Q_OBJECT public: explicit UserList(QObject *parent = 0); QVariant data(const QModelIndex &index, int role) const; int rowCount(const QModelIndex &parent) const; Qt::ItemFlags...
C++
#include "User.h" User::User(int id, QString name) : id(id), name(name) { } User::User(QString data) { QStringList infos = data.split(" "); id = infos.at(0).toInt(); name = infos.at(1); } int User::getId() { return id; } QString User::getName() { return name; } void User::setId(int val) { id = val; } vo...
C++
#include <QtGui/QApplication> #include "LutController.h" int main(int argc, char *argv[]) { QApplication *a = new QApplication(argc, argv); a->setQuitOnLastWindowClosed(false); LutController *ctrl = LutController::getInstance(); QApplication::connect(ctrl, SIGNAL(quitMe()), a, SLOT(quit())); ctrl->startApp();...
C++
#include "UserList.h" #include "LutController.h" UserList::UserList(QObject *parent) : QAbstractListModel(parent) { users = new QList<User*>(); } QVariant UserList::data(const QModelIndex &index, int role) const { if (!index.isValid()) return QVariant(); if (index.row() >= users->size()) return QVariant();...
C++
#include "DiscussPane.h" #include "ui_DiscussPane.h" #include "LutController.h" DiscussPane::DiscussPane(int gid, QWidget *parent) : QWidget(parent), ui(new Ui::DiscussPane), guyId(gid) { ui->setupUi(this); ui->textBrowser->setOpenExternalLinks(true); connect(ui->lineEdit, SIGNAL(returnPressed()), ui->pushBu...
C++
#ifndef USER_H #define USER_H #include <QString> #include <QStringList> class User // : public QListWidgetItem { public: User(int id, QString name); User(QString data); int getId(); QString getName(); void setId(int val); void setName(QString n); private: int id; QString name; }; #endif // USER_H
C++
#include "MainWindow.h" #include "ui_MainWindow.h" #include <QInputDialog> #include <QStringList> #include <QUrl> #include "DiscussPane.h" MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow), nickname("Anonymous"), settings("01Lut", "01Lut") { setAttribute(Qt::WA_DeleteOnClo...
C++
#ifndef LUTCONTROLLER_H #define LUTCONTROLLER_H #include <QObject> #include "UserList.h" class MainWindow; class LutController : public QObject { Q_OBJECT public: static LutController* getInstance(); int myId(); QString getNameFromId(int id); void sendMsg(QString str); void sendPrivateMsg(int to, QString ...
C++
#ifndef PRIVATEPANE_H #define PRIVATEPANE_H #include <QWidget> #include "User.h" #include "MainWindow.h" namespace Ui { class DiscussPane; } class DiscussPane : public QWidget { Q_OBJECT signals: void toRead(DiscussPane*); public: explicit DiscussPane(int gid = -1, QWidget *parent = 0); ~DiscussPane(); ...
C++
#include "qextserialenumerator.h" #include <QDebug> #include <QMetaType> #include <QStringList> #include <QDir> QextSerialEnumerator::QextSerialEnumerator( ) { if( !QMetaType::isRegistered( QMetaType::type("QextPortInfo") ) ) qRegisterMetaType<QextPortInfo>("QextPortInfo"); } QextSerialEnumerator::~Qex...
C++
#ifndef _QEXTSERIALPORT_H_ #define _QEXTSERIALPORT_H_ #include "qextserialport_global.h" /*if all warning messages are turned off, flag portability warnings to be turned off as well*/ #ifdef _TTY_NOWARN_ #define _TTY_NOWARN_PORT_ #endif /*macros for warning and debug messages*/ #ifdef _TTY_NOWARN_PORT_ #define TTY_...
C++
#include <stdio.h> #include "qextserialport.h" /*! Default constructor. Note that the name of the device used by a QextSerialPort constructed with this constructor will be determined by #defined constants, or lack thereof - the default behavior is the same as _TTY_LINUX_. Possible naming conventions and their asso...
C++
#include <QMutexLocker> #include <QDebug> #include <QRegExp> #include "qextserialport.h" void QextSerialPort::platformSpecificInit() { Win_Handle=INVALID_HANDLE_VALUE; ZeroMemory(&overlap, sizeof(OVERLAPPED)); overlap.hEvent = CreateEvent(NULL, true, false, NULL); winEventNotifier = 0; bytesToWri...
C++
/*! * \file qextserialenumerator.h * \author Michal Policht * \see QextSerialEnumerator */ #ifndef _QEXTSERIALENUMERATOR_H_ #define _QEXTSERIALENUMERATOR_H_ #include <QString> #include <QList> #include <QObject> #include "qextserialport_global.h" #ifdef Q_OS_WIN #include <windows.h> #include <setupapi.h...
C++
#include "qextserialenumerator.h" #include <QDebug> #include <QMetaType> #include <IOKit/serial/IOSerialKeys.h> #include <CoreFoundation/CFNumber.h> #include <sys/param.h> QextSerialEnumerator::QextSerialEnumerator( ) { if( !QMetaType::isRegistered( QMetaType::type("QextPortInfo") ) ) qRegisterMetaType...
C++
#include "qextserialenumerator.h" #include <QDebug> #include <QMetaType> #include <objbase.h> #include <initguid.h> #include "qextserialport.h" #include <QRegExp> QextSerialEnumerator::QextSerialEnumerator( ) { if( !QMetaType::isRegistered( QMetaType::type("QextPortInfo") ) ) qRegisterMetaType<QextPort...
C++
#include <fcntl.h> #include <stdio.h> #include "qextserialport.h" #include <QMutexLocker> #include <QDebug> void QextSerialPort::platformSpecificInit() { fd = 0; readNotifier = 0; } /*! Standard destructor. */ void QextSerialPort::platformSpecificDestruct() {} /*! Sets the baud rate of the serial port. No...
C++
/* qesptest.h **************************************/ #ifndef _QESPTEST_H_ #define _QESPTEST_H_ #include <QWidget> class QLineEdit; class QTextEdit; class QextSerialPort; class QSpinBox; class QespTest : public QWidget { Q_OBJECT public: QespTest(QWidget *parent=0); virtual ~QespTest(); private: QLineEdit...
C++
/* QespTest.cpp **************************************/ #include "QespTest.h" #include <qextserialport.h> #include <QLayout> #include <QLineEdit> #include <QTextEdit> #include <QPushButton> #include <QSpinBox> QespTest::QespTest(QWidget* parent) : QWidget(parent) { //modify the port settings on your own #ifdef _...
C++
#ifndef PORTLISTENER_H_ #define PORTLISTENER_H_ #include <QObject> #include "qextserialport.h" class PortListener : public QObject { Q_OBJECT public: PortListener(const QString & portName); private: QextSerialPort *port; private slots: void onReadyRead(); void onDsrChanged(bool status); }; #en...
C++
#include "PortListener.h" #include <QtDebug> PortListener::PortListener(const QString & portName) { qDebug() << "hi there"; this->port = new QextSerialPort(portName, QextSerialPort::EventDriven); port->setBaudRate(BAUD56000); port->setFlowControl(FLOW_OFF); port->setParity(PAR_NONE); port->set...
C++
/** * @file main.cpp * @brief Main file. * @author Michal Policht */ #include <QCoreApplication> #include "PortListener.h" int main(int argc, char *argv[]) { QCoreApplication app(argc, argv); QString portName = "COM1"; // update this to use your port of choice PortListener *listener = ne...
C++
/** * @file main.cpp * @brief Main file. * @author Michał Policht */ #include <qextserialenumerator.h> #include <QList> #include <QtDebug> int main(int argc, char *argv[]) { (void)argc; (void)argv; QList<QextPortInfo> ports = QextSerialEnumerator::getPorts(); qDebug() << "List of ports:"; for ...
C++
/* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * * The contents of this file are subject to the Mozilla Public License Version * 1.1 (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.mozilla.org/MP...
C++
// stdafx.cpp : source file that includes just the standard includes // ffactivex.pch will be the pre-compiled header // stdafx.obj will contain the pre-compiled type information #include "stdafx.h" // TODO: reference any additional headers you need in STDAFX.H // and not in this file
C++
/* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * * The contents of this file are subject to the Mozilla Public License Version * 1.1 (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.mozilla.org/MP...
C++
/* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * * The contents of this file are subject to the Mozilla Public License Version * 1.1 (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.mozilla.org/MP...
C++