Logo Search packages:      
Sourcecode: fbpager version File versions  Download package

Resources.hh

#ifndef RESOURCES_HH
#define RESOURCES_HH

#include "FbPager.hh"

#include "FbTk/Resource.hh"
#include <string>
#include <cstdio>
#include <cstring>

template<>
void FbTk::Resource<bool>::
00013 setFromString(char const *strval) {
    if (strcasecmp(strval, "true") == 0 ||
        strcasecmp(strval, "yes") == 0)
        *this = true;
    else
        *this = false;
}

template<>
std::string FbTk::Resource<bool>::
00023 getString() {                       
    return std::string(**this == true ? "true" : "false");
}

template <>
00028 void FbTk::Resource<std::string>::setFromString(const char *str) {
    *(*this) = (str ?  str : "");
}

template <>
00033 std::string FbTk::Resource<std::string>::getString() {
    return *(*this);
}

template <>
00038 void FbTk::Resource<int>::setFromString(const char *str) {
    if (str == 0)
        return;
    sscanf(str, "%d", &(*(*this)));
}

template <>
00045 std::string FbTk::Resource<int>::getString() {
    char buff[16];
    sprintf(buff, "%d", (*(*this)));
    return std::string(buff);
}

namespace FbPager {
template <>
00053 void FbTk::Resource<FbPager::Alignment>::setFromString(const char *str) {
    if (strcmp("TopToBottom", str) == 0)
        *(*this) = FbPager::FbPager::TOP_TO_BOTTOM;
    else
        *(*this) = FbPager::FbPager::LEFT_TO_RIGHT;
}

template <>
00061 std::string FbTk::Resource<FbPager::Alignment>::getString() {
    switch (*(*this)) {
    case FbPager::FbPager::LEFT_TO_RIGHT:
        return "LeftToRight";
    case FbPager::FbPager::TOP_TO_BOTTOM:
        return "TopToBottom";
    }
}

} // end namespace FbPager

#endif // RESOURCES

Generated by  Doxygen 1.6.0   Back to index