Skip to content
This repository has been archived by the owner on Oct 10, 2019. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
merge C++11 support.
  • Loading branch information
akrennmair committed Feb 17, 2015
1 parent 2b1a445 commit a3106ff
Show file tree
Hide file tree
Showing 76 changed files with 1,011 additions and 1,248 deletions.
6 changes: 4 additions & 2 deletions .travis.yml
@@ -1,7 +1,9 @@
before_install:
- sudo apt-add-repository -y ppa:llxdev/pandora
- sudo apt-add-repository -y ppa:ondrej/php5-experimental
- sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
- sudo apt-get update
- sudo apt-get install -qq libsqlite3-dev libcurl4-openssl-dev libxml2-dev libstfl-dev libjson-c-dev libncursesw5-dev bc
- sudo apt-get install -qq libsqlite3-dev libcurl4-openssl-dev libxml2-dev libstfl-dev libjson-c-dev libncursesw5-dev bc gcc-4.8
- sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.8 50
language: cpp
compiler:
- gcc
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Expand Up @@ -11,7 +11,7 @@ CXX?=c++
# compiler and linker flags
DEFINES=-DLOCALEDIR=\"$(localedir)\"
WARNFLAGS=-Wall -Wextra -Wunreachable-code
CXXFLAGS+=-ggdb -Iinclude -Istfl -Ifilter -I. -Irss $(WARNFLAGS) $(DEFINES)
CXXFLAGS+=-std=c++11 -ggdb -Iinclude -Istfl -Ifilter -I. -Irss $(WARNFLAGS) $(DEFINES)
LDFLAGS+=-L.

PACKAGE=newsbeuter
Expand Down
20 changes: 10 additions & 10 deletions include/cache.h
Expand Up @@ -4,7 +4,7 @@
#include <sqlite3.h>
#include <rss.h>
#include <configcontainer.h>
#include <mutex.h>
#include <mutex>

namespace newsbeuter {

Expand All @@ -15,15 +15,15 @@ class cache {
public:
cache(const std::string& cachefile, configcontainer * c);
~cache();
void externalize_rssfeed(std::tr1::shared_ptr<rss_feed> feed, bool reset_unread);
std::tr1::shared_ptr<rss_feed> internalize_rssfeed(std::string rssurl, rss_ignores * ign);
void update_rssitem_unread_and_enqueued(std::tr1::shared_ptr<rss_item> item, const std::string& feedurl);
void externalize_rssfeed(std::shared_ptr<rss_feed> feed, bool reset_unread);
std::shared_ptr<rss_feed> internalize_rssfeed(std::string rssurl, rss_ignores * ign);
void update_rssitem_unread_and_enqueued(std::shared_ptr<rss_item> item, const std::string& feedurl);
void update_rssitem_unread_and_enqueued(rss_item* item, const std::string& feedurl);
void cleanup_cache(std::vector<std::tr1::shared_ptr<rss_feed> >& feeds);
void cleanup_cache(std::vector<std::shared_ptr<rss_feed>>& feeds);
void do_vacuum();
std::vector<std::tr1::shared_ptr<rss_item> > search_for_items(const std::string& querystr, const std::string& feedurl);
std::vector<std::shared_ptr<rss_item>> search_for_items(const std::string& querystr, const std::string& feedurl);
void catchup_all(const std::string& feedurl = "");
void catchup_all(std::tr1::shared_ptr<rss_feed> feed);
void catchup_all(std::shared_ptr<rss_feed> feed);
void update_rssitem_flags(rss_item* item);
std::vector<std::string> get_feed_urls();
void fetch_lastmodified(const std::string& uri, time_t& t, std::string& etag);
Expand All @@ -40,15 +40,15 @@ class cache {
private:
void populate_tables();
void set_pragmas();
void delete_item(const std::tr1::shared_ptr<rss_item> item);
void delete_item(const std::shared_ptr<rss_item> item);
void clean_old_articles();
void update_rssitem_unlocked(std::tr1::shared_ptr<rss_item> item, const std::string& feedurl, bool reset_unread);
void update_rssitem_unlocked(std::shared_ptr<rss_item> item, const std::string& feedurl, bool reset_unread);

std::string prepare_query(const char * format, ...);

sqlite3 * db;
configcontainer * cfg;
mutex mtx;
std::mutex mtx;
};

}
Expand Down
4 changes: 2 additions & 2 deletions include/colormanager.h
Expand Up @@ -26,13 +26,13 @@ class colormanager : public config_action_handler {
void set_pb_colors(podbeuter::pb_view * v);
inline std::map<std::string,std::string>& get_fgcolors() { return fg_colors; }
inline std::map<std::string,std::string>& get_bgcolors() { return bg_colors; }
inline std::map<std::string,std::vector<std::string> >& get_attributes() { return attributes; }
inline std::map<std::string,std::vector<std::string>>& get_attributes() { return attributes; }
private:

bool colors_loaded_;
std::map<std::string,std::string> fg_colors;
std::map<std::string,std::string> bg_colors;
std::map<std::string,std::vector<std::string> > attributes;
std::map<std::string,std::vector<std::string>> attributes;
};

}
Expand Down
4 changes: 2 additions & 2 deletions include/configcontainer.h
Expand Up @@ -10,8 +10,8 @@ namespace newsbeuter
struct configdata
{
enum configdata_type { INVALID, BOOL, INT, STR, PATH, ALIAS, ENUM };
configdata(const std::string& v = "", configdata_type t = INVALID, bool m = false) : value(v), default_value(v), type(t), multi_option(m) { }
configdata(const std::string& v, ...);
configdata(std::string v = "", configdata_type t = INVALID, bool m = false) : value(v), default_value(v), type(t), multi_option(m) { }
configdata(std::string v, ...);
std::string value;
std::string default_value;
configdata_type type;
Expand Down
2 changes: 1 addition & 1 deletion include/configparser.h
Expand Up @@ -30,7 +30,7 @@ namespace newsbeuter {
private:
void evaluate_backticks(std::vector<std::string>& tokens);
static std::string evaluate_cmd(const std::string& cmd);
std::vector<std::vector<std::string> > parsed_content;
std::vector<std::vector<std::string>> parsed_content;
std::map<std::string,config_action_handler *> action_handlers;
std::set<std::string> included_files;
};
Expand Down
33 changes: 17 additions & 16 deletions include/controller.h
Expand Up @@ -35,9 +35,9 @@ namespace newsbeuter {
void reload_range(unsigned int start, unsigned int end, unsigned int size, bool unattended = false);
void start_reload_all_thread(std::vector<int> * indexes = 0);

std::tr1::shared_ptr<rss_feed> get_feed(unsigned int pos);
std::tr1::shared_ptr<rss_feed> get_feed_by_url(const std::string& feedurl);
std::vector<std::tr1::shared_ptr<rss_item> > search_for_items(const std::string& query, const std::string& feedurl);
std::shared_ptr<rss_feed> get_feed(unsigned int pos);
std::shared_ptr<rss_feed> get_feed_by_url(const std::string& feedurl);
std::vector<std::shared_ptr<rss_item>> search_for_items(const std::string& query, const std::string& feedurl);
inline unsigned int get_feedcount() { return feeds.size(); }

inline void unlock_reload_mutex() { reload_mutex.unlock(); }
Expand All @@ -49,18 +49,18 @@ namespace newsbeuter {
void mark_article_read(const std::string& guid, bool read);
void record_google_replay(const std::string& guid, bool read);
void catchup_all();
inline void catchup_all(std::tr1::shared_ptr<rss_feed> feed) { rsscache->catchup_all(feed); }
inline void catchup_all(std::shared_ptr<rss_feed> feed) { rsscache->catchup_all(feed); }
inline bool get_refresh_on_start() const { return refresh_on_start; }
bool is_valid_podcast_type(const std::string& mimetype);
void enqueue_url(const std::string& url, std::tr1::shared_ptr<rss_feed> feed);
void enqueue_url(const std::string& url, std::shared_ptr<rss_feed> feed);
void notify(const std::string& msg);
unsigned int get_pos_of_next_unread(unsigned int pos);

void reload_urls_file();
void edit_urls_file();

std::vector<std::tr1::shared_ptr<rss_feed> > get_all_feeds();
std::vector<std::tr1::shared_ptr<rss_feed> > get_all_feeds_unlocked();
std::vector<std::shared_ptr<rss_feed>> get_all_feeds();
std::vector<std::shared_ptr<rss_feed>> get_all_feeds_unlocked();

inline filtercontainer& get_filters() { return filters; }

Expand All @@ -70,9 +70,9 @@ namespace newsbeuter {

inline configcontainer * get_cfg() { return &cfg; }

void write_item(std::tr1::shared_ptr<rss_item> item, const std::string& filename);
void write_item(std::tr1::shared_ptr<rss_item> item, std::ostream& ostr);
std::string write_temporary_item(std::tr1::shared_ptr<rss_item> item);
void write_item(std::shared_ptr<rss_item> item, const std::string& filename);
void write_item(std::shared_ptr<rss_item> item, std::ostream& ostr);
std::string write_temporary_item(std::shared_ptr<rss_item> item);

void mark_deleted(const std::string& guid, bool b);

Expand All @@ -84,7 +84,7 @@ namespace newsbeuter {

void sort_feeds();

void update_flags(std::tr1::shared_ptr<rss_item> item);
void update_flags(std::shared_ptr<rss_item> item);

unsigned int get_feed_count_per_tag(const std::string& tag);
private:
Expand All @@ -99,9 +99,10 @@ namespace newsbeuter {
void execute_commands(char ** argv, unsigned int i);

std::string prepare_message(unsigned int pos, unsigned int max);
void enqueue_items(std::tr1::shared_ptr<rss_feed> feed);
void save_feed(std::shared_ptr<rss_feed> feed, unsigned int pos);
void enqueue_items(std::shared_ptr<rss_feed> feed);

std::string generate_enqueue_filename(const std::string& url, std::tr1::shared_ptr<rss_feed> feed);
std::string generate_enqueue_filename(const std::string& url, std::shared_ptr<rss_feed> feed);
std::string get_hostname_from_url(const std::string& url);

void import_read_information(const std::string& readinfofile);
Expand All @@ -110,7 +111,7 @@ namespace newsbeuter {
view * v;
urlreader * urlcfg;
cache * rsscache;
std::vector<std::tr1::shared_ptr<rss_feed> > feeds;
std::vector<std::shared_ptr<rss_feed>> feeds;
std::string config_dir;
std::string url_file;
std::string cache_file;
Expand All @@ -123,12 +124,12 @@ namespace newsbeuter {
rss_ignores ign;
filtercontainer filters;

mutex reload_mutex;
std::mutex reload_mutex;
configparser cfgparser;
colormanager colorman;
regexmanager rxman;
remote_api * api;
mutex feeds_mutex;
std::mutex feeds_mutex;
bool offline_mode;
};

Expand Down
12 changes: 5 additions & 7 deletions include/downloadthread.h
@@ -1,32 +1,30 @@
#ifndef DOWNLOADTHREAD_H_
#define DOWNLOADTHREAD_H_

#include <thread.h>
#include <thread>
#include <controller.h>

namespace newsbeuter
{

class controller;

class downloadthread : public thread
class downloadthread
{
public:
downloadthread(controller * c, std::vector<int> * idxs = 0);
virtual ~downloadthread();
protected:
virtual void run();
void operator()();
private:
controller * ctrl;
std::vector<int> indexes;
};

class reloadrangethread : public thread
class reloadrangethread
{
public:
reloadrangethread(controller * c, unsigned int start, unsigned int end, unsigned int size, bool unattended);
protected:
virtual void run();
void operator()();
private:
controller * ctrl;
unsigned int s, e, ss;
Expand Down
14 changes: 7 additions & 7 deletions include/feedlist_formaction.h
Expand Up @@ -9,19 +9,19 @@

namespace newsbeuter {

typedef std::pair<std::tr1::shared_ptr<rss_feed>, unsigned int> feedptr_pos_pair;
typedef std::pair<std::shared_ptr<rss_feed>, unsigned int> feedptr_pos_pair;

class feedlist_formaction : public formaction {
public:
feedlist_formaction(view *, std::string formstr);
virtual ~feedlist_formaction();
virtual void prepare();
virtual void init();
void set_feedlist(std::vector<std::tr1::shared_ptr<rss_feed> >& feeds);
void update_visible_feeds(std::vector<std::tr1::shared_ptr<rss_feed> >& feeds);
void set_feedlist(std::vector<std::shared_ptr<rss_feed>>& feeds);
void update_visible_feeds(std::vector<std::shared_ptr<rss_feed>>& feeds);
void set_tags(const std::vector<std::string>& t);
virtual keymap_hint_entry * get_keymap_hint();
std::tr1::shared_ptr<rss_feed> get_feed();
std::shared_ptr<rss_feed> get_feed();

virtual void set_redraw(bool b) {
formaction::set_redraw(b);
Expand Down Expand Up @@ -61,9 +61,9 @@ class feedlist_formaction : public formaction {

void set_pos();

std::string get_title(std::tr1::shared_ptr<rss_feed> feed);
std::string get_title(std::shared_ptr<rss_feed> feed);

std::string format_line(const std::string& feedlist_format, std::tr1::shared_ptr<rss_feed> feed, unsigned int pos, unsigned int width);
std::string format_line(const std::string& feedlist_format, std::shared_ptr<rss_feed> feed, unsigned int pos, unsigned int width);

bool zero_feedpos;
unsigned int feeds_shown;
Expand All @@ -77,7 +77,7 @@ class feedlist_formaction : public formaction {

history filterhistory;

std::tr1::shared_ptr<rss_feed> search_dummy_feed;
std::shared_ptr<rss_feed> search_dummy_feed;

unsigned int filterpos;
bool set_filterpos;
Expand Down
10 changes: 5 additions & 5 deletions include/formaction.h
Expand Up @@ -26,7 +26,7 @@ class formaction {
virtual ~formaction();
virtual void prepare() = 0;
virtual void init() = 0;
std::tr1::shared_ptr<stfl::form> get_form();
std::shared_ptr<stfl::form> get_form();
virtual void set_redraw(bool b) { do_redraw = b; }

virtual keymap_hint_entry * get_keymap_hint() = 0;
Expand All @@ -48,8 +48,8 @@ class formaction {
inline std::string get_qna_response(unsigned int i) { return (qna_responses.size() >= (i + 1)) ? qna_responses[i] : ""; }
void start_qna(const std::vector<qna_pair>& prompts, operation finish_op, history * h = NULL);

inline void set_parent_formaction(std::tr1::shared_ptr<formaction> fa) { parent_formaction = fa; }
inline std::tr1::shared_ptr<formaction> get_parent_formaction() const { return parent_formaction; }
inline void set_parent_formaction(std::shared_ptr<formaction> fa) { parent_formaction = fa; }
inline std::shared_ptr<formaction> get_parent_formaction() const { return parent_formaction; }

virtual std::string title() = 0;

Expand All @@ -66,7 +66,7 @@ class formaction {
void start_bookmark_qna(const std::string& default_title, const std::string& default_url, const std::string& default_desc);

view * v;
std::tr1::shared_ptr<stfl::form> f;
std::shared_ptr<stfl::form> f;
bool do_redraw;

std::vector<std::string> qna_responses;
Expand All @@ -84,7 +84,7 @@ class formaction {
std::vector<qna_pair> qna_prompts;
operation finish_operation;
history * qna_history;
std::tr1::shared_ptr<formaction> parent_formaction;
std::shared_ptr<formaction> parent_formaction;
};


Expand Down
17 changes: 8 additions & 9 deletions include/itemlist_formaction.h
Expand Up @@ -3,13 +3,12 @@

#include <formaction.h>
#include <history.h>
#include <mutex.h>
#include <regexmanager.h>
#include <view.h>

namespace newsbeuter {

typedef std::pair<std::tr1::shared_ptr<rss_item>, unsigned int> itemptr_pos_pair;
typedef std::pair<std::shared_ptr<rss_item>, unsigned int> itemptr_pos_pair;

class itemlist_formaction : public formaction {
public:
Expand All @@ -24,12 +23,12 @@ class itemlist_formaction : public formaction {
update_visible_items = true;
}

void set_feed(std::tr1::shared_ptr<rss_feed> fd);
void set_feed(std::shared_ptr<rss_feed> fd);

virtual std::string id() const { return "articlelist"; }
virtual std::string title();

inline std::tr1::shared_ptr<rss_feed> get_feed() { return feed; }
inline std::shared_ptr<rss_feed> get_feed() { return feed; }
inline void set_pos(unsigned int p) { pos = p; }
std::string get_guid();
virtual keymap_hint_entry * get_keymap_hint();
Expand Down Expand Up @@ -60,7 +59,7 @@ class itemlist_formaction : public formaction {
void set_head(const std::string& s, unsigned int unread, unsigned int total, const std::string &url);
int get_pos(unsigned int idx);

void save_article(const std::string& filename, std::tr1::shared_ptr<rss_item> item);
void save_article(const std::string& filename, std::shared_ptr<rss_item> item);

void save_filterpos();

Expand All @@ -70,13 +69,13 @@ class itemlist_formaction : public formaction {

void handle_cmdline_num(unsigned int idx);

std::string gen_flags(std::tr1::shared_ptr<rss_item> item);
std::string gen_flags(std::shared_ptr<rss_item> item);
std::string gen_datestr(time_t t, const char * datetimeformat);

void prepare_set_filterpos();

unsigned int pos;
std::tr1::shared_ptr<rss_feed> feed;
std::shared_ptr<rss_feed> feed;
bool apply_filter;
matcher m;
std::vector<itemptr_pos_pair> visible_items;
Expand All @@ -86,9 +85,9 @@ class itemlist_formaction : public formaction {

history filterhistory;

std::tr1::shared_ptr<rss_feed> search_dummy_feed;
std::shared_ptr<rss_feed> search_dummy_feed;

mutex redraw_mtx;
std::mutex redraw_mtx;

bool set_filterpos;
unsigned int filterpos;
Expand Down

0 comments on commit a3106ff

Please sign in to comment.