#pragma once

#include "ServerAddressProvider.hpp"
#include <vector>
#include <string>

namespace tw::app {

/**
 * Shared behaviour of address lists backed by a file.
 *
 * One "ip:port" per line. Resolves file path to
 * $XDG_CONFIG_HOME/towards/<file_name>, falling back to
 * $HOME/.config/towards/<file_name>.
 * add() stays pure virtual: subclasses define their own order.
 */
class FileAddressList : public ServerAddressProvider {
protected:
    std::vector<std::string> m_entries;
    std::string              m_path;
    bool                     m_can_save = false;

    explicit FileAddressList(const std::string& file_name);

public:
    void load() override;
    void save() const override;
    void remove(const std::string& entry) override;
    const std::vector<std::string>& entries() const override;
};

} // namespace tw::app
