File indexing completed on 2024-04-28 16:13:25

0001 /*
0002     SPDX-FileCopyrightText: 2018 Ralf Habacker ralf.habacker @freenet.de
0003 
0004     This file is part of libalkimia.
0005 
0006     SPDX-License-Identifier: LGPL-2.1-or-later
0007 */
0008 
0009 #ifndef ALKONLINEQUOTESOURCE_H
0010 #define ALKONLINEQUOTESOURCE_H
0011 
0012 #include <alkimia/alkonlinequotesprofile.h>
0013 
0014 #include <QString>
0015 
0016 class AlkOnlineQuotesProfile;
0017 
0018 /**
0019   * @author Thomas Baumgart & Ace Jones
0020   *
0021   * This is a helper class to store information about an online source
0022   * for stock prices or currency exchange rates.
0023   */
0024 class ALK_EXPORT AlkOnlineQuoteSource
0025 {
0026 public:
0027 
0028     AlkOnlineQuoteSource();
0029     explicit AlkOnlineQuoteSource(const QString &name, AlkOnlineQuotesProfile *profile);
0030     explicit AlkOnlineQuoteSource(const QString &name, const QString &url, const QString &sym,
0031                          const QString &price, const QString &date, const QString &dateformat,
0032                          bool skipStripping = false);
0033     ~AlkOnlineQuoteSource();
0034 
0035     AlkOnlineQuoteSource(const AlkOnlineQuoteSource &other);
0036     AlkOnlineQuoteSource &operator=(AlkOnlineQuoteSource other);
0037 
0038     friend void swap(AlkOnlineQuoteSource& first, AlkOnlineQuoteSource& second);
0039 
0040     bool isEmpty();
0041     bool isValid();
0042 
0043     bool read();
0044     bool write();
0045     void rename(const QString &name);
0046     void remove();
0047 
0048     QString name() const;
0049     QString url() const;
0050     QString sym() const;
0051     QString price() const;
0052     QString date() const;
0053     QString dateformat() const;
0054     QString financeQuoteName() const;
0055 
0056     bool skipStripping() const;
0057     bool isGHNS();
0058     bool isReadOnly();
0059     bool isFinanceQuote() const;
0060     static bool isFinanceQuote(const QString &name);
0061 
0062     void setName(const QString &name);
0063     void setUrl(const QString &url);
0064     void setSym(const QString &symbol);
0065     void setPrice(const QString &price);
0066     void setDate(const QString &date);
0067     void setDateformat(const QString &dateformat);
0068     void setSkipStripping(bool state);
0069     void setGHNS(bool state);
0070 
0071     QString ghnsWriteFileName();
0072     void setProfile(AlkOnlineQuotesProfile *profile);
0073     AlkOnlineQuotesProfile *profile();
0074 
0075 protected:
0076     class Private;
0077     Private *d;
0078 };
0079 
0080 inline void swap(AlkOnlineQuoteSource& first, AlkOnlineQuoteSource& second) // krazy:exclude=inline
0081 {
0082   using std::swap;
0083   swap(first.d, second.d);
0084 }
0085 
0086 #endif // ALKONLINEQUOTESOURCE_H