Subversion Repositories heating

Rev

Rev 5 | Blame | Compare with Previous | Last modification | View Log | RSS feed

/*
 * Copyright (C) 2015 by Andreas Theofilu. All rights reserved!
 *
 * All rights reserved. No warranty, explicit or implicit, provided.
 *
 * NOTICE:  All information contained herein is, and remains
 * the property of Andreas Theofilu and his suppliers, if any.
 * The intellectual and technical concepts contained
 * herein are proprietary to Andreas Theofilu and its suppliers and
 * may be covered by European 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 Andreas Theofilu.
 * 
 * Author: Andreas Theofilu <andreas@theosys.at>
 */
#ifndef __HELPER_H__
#define __HELPER_H__

#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <vector>

class helper
{
        public:
                helper();
                
                char *readLine(int fd, char *buf, int bufLen);
                char *trim(char *str);
                std::string trim(std::string str);
                int compare(char *str1, char *str2);
                int compcase(const char *str1, const char *str2);
                int compcase(std::string str1, std::string str2);
                char *findc(char *str, int len, char c);
                int findc(std::string str, char c);
                std::vector<std::string> split(std::string str, char delimiter);
                void setPName(char *name);
                std::string itostring(int i);
                char *assign(std::string str);
                void enableDebug(bool what) { dbg = what; };
                void debug(std::string msg);
                bool ToBool(char *str);
                bool ToBool(std::string s);
                bool ToBool(int i);
                bool isArm();

                template <typename T>
                inline std::string ToString(T value)
                {
                        std::stringstream stream;
                        stream << value;
                        return stream.str();
                }

                inline std::string doubleToString(double d, int prec)
                {
                        std::stringstream stream;
                        stream << std::fixed << std::setprecision(prec) << d;
                        return stream.str();
                }

        private:
                char pname[48];
                bool dbg;
};

#endif