helper-fns.h revision ef4a6bf28f7697d57173160803211fef5679309e
#ifndef SEEN_HELPER_FNS_H
#define SEEN_HELPER_FNS_H
/** \file
*
* Some helper functions
*
* Authors:
* Felipe CorrĂȘa da Silva Sanches <juca@members.fsf.org>
*
*
* Copyright (C) 2006 Hugo Rodrigues
*
* Released under GNU GPL, read the file 'COPYING' for more information
*/
#include <string.h>
#include <vector>
#include <sstream>
// calling helperfns_read_number(string, false), it's not obvious, what
// that false stands for. helperfns_read_number(string, HELPERFNS_NO_WARNING)
// can be more clear.
#define HELPERFNS_NO_WARNING false
/* convert ascii representation to double
* the function can only be used to convert numbers as given by gui elements that use localized representation
* @param value ascii representation of the number
* @return the converted number
*
* Setting warning to false disables conversion error warnings from
* this function. This can be useful in places, where the input type
* is not known beforehand. For example, see sp_feColorMatrix_set in
* sp-fecolormatrix.cpp */
if (!value) {
g_warning("Called helperfns_read_number with value==null_ptr, this can lead to unexpected behaviour.");
return 0;
}
char *end;
if (*end) {
if (warning) {
}
// We could leave this out, too. If strtod can't convert
// anything, it will return zero.
ret = 0;
}
return ret;
}
if (!value) return default_value;
switch(value[0]){
case 't':
break;
case 'f':
break;
}
return default_value;
}
/* convert ascii representation to double
* the function can only be used to convert numbers as given by gui elements that use localized representation
* numbers are delimeted by space
* @param value ascii representation of the number
* @param size number of elements in string
* @return the vector of the converted numbers
*/
for(int i = 0; i < size; i++){
char *end;
if (*end) {
// We could leave this out, too. If strtod can't convert
// anything, it will return zero.
ret = 0;
}
v[i] = ret;
};
return v;
}
/* convert ascii representation to double
* the function can only be used to convert numbers as given by gui elements that use localized representation
* numbers are delimeted by space
* @param value ascii representation of the number
* @return the vector of the converted numbers
*/
while(*beg)
{
char *end;
// We could leave this out, too. If strtod can't convert
// anything, it will return zero.
ret = 0;
}
}
return v;
}
#endif /* !SEEN_HELPER_FNS_H */
/*
Local Variables:
mode:c++
c-file-style:"stroustrup"
c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
indent-tabs-mode:nil
fill-column:99
End:
*/
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :