<commit_before>/* 
 * File:   BuiltInClasses.h
 * Author: tjoppen
 *
 * Created on February 14, 2010, 6:48 PM
 */

#ifndef _BUILTINCLASSES_H
#define	_BUILTINCLASSES_H

#include "Class.h"

class BuiltInClass : public Class {
public:
    BuiltInClass(std::string name);
    virtual ~BuiltInClass();

    bool isBuiltIn() const;

    std::string generateAppender() const;
    virtual std::string generateNodeSetter(std::string memberName, std::string nodeName) const;
    std::string generateParser() const;
    std::string generateMemberSetter(std::string memberName, std::string nodeName) const;
};

#define GENERATE_BUILTIN(name, xslName, classname, defaultValue)\
class name : public BuiltInClass {\
public:\
    name() : BuiltInClass(xslName) {}\
    name(std::string xslOverride) : BuiltInClass(xslOverride) {}\
    std::string getClassname() const {return classname;}\
    std::string getDefaultValue() const {return defaultValue;}

#define GENERATE_BUILTIN_ALIAS(name, base, override)\
class name : public base {\
public:\
    name() : base(override) {}

GENERATE_BUILTIN(IntClass, "int", "int", "0")};
GENERATE_BUILTIN(LongClass, "long", "long", "0")};
GENERATE_BUILTIN(StringClass, "string", "std::string", "std::string()")
    std::string generateNodeSetter(std::string memberName, std::string nodeName) const {
        return nodeName + "->setTextContent(XercesString(" + memberName + "));";
    }

    std::string getTester(std::string name) const {
        return name + ".length() > 0";
    }
};

//aliases
GENERATE_BUILTIN_ALIAS(IntegerClass, IntClass, "integer")};
GENERATE_BUILTIN_ALIAS(AnyURIClass, StringClass, "anyURI")};

#endif	/* _BUILTINCLASSES_H */
<commit_msg>Made string member setter better (not needlessly using stringstream).<commit_after>/* 
 * File:   BuiltInClasses.h
 * Author: tjoppen
 *
 * Created on February 14, 2010, 6:48 PM
 */

#ifndef _BUILTINCLASSES_H
#define	_BUILTINCLASSES_H

#include "Class.h"

class BuiltInClass : public Class {
public:
    BuiltInClass(std::string name);
    virtual ~BuiltInClass();

    bool isBuiltIn() const;

    std::string generateAppender() const;
    virtual std::string generateNodeSetter(std::string memberName, std::string nodeName) const;
    std::string generateParser() const;
    std::string generateMemberSetter(std::string memberName, std::string nodeName) const;
};

#define GENERATE_BUILTIN(name, xslName, classname, defaultValue)\
class name : public BuiltInClass {\
public:\
    name() : BuiltInClass(xslName) {}\
    name(std::string xslOverride) : BuiltInClass(xslOverride) {}\
    std::string getClassname() const {return classname;}\
    std::string getDefaultValue() const {return defaultValue;}

#define GENERATE_BUILTIN_ALIAS(name, base, override)\
class name : public base {\
public:\
    name() : base(override) {}

GENERATE_BUILTIN(IntClass, "int", "int", "0")};
GENERATE_BUILTIN(LongClass, "long", "long", "0")};
GENERATE_BUILTIN(StringClass, "string", "std::string", "std::string()")
    std::string generateNodeSetter(std::string memberName, std::string nodeName) const {
        return nodeName + "->setTextContent(XercesString(" + memberName + "));";
    }

    std::string generateMemberSetter(std::string memberName, std::string nodeName) const {
        return memberName + " = XercesString(" + nodeName + "->getTextContent());";
    }

    std::string getTester(std::string name) const {
        return name + ".length() > 0";
    }
};

//aliases
GENERATE_BUILTIN_ALIAS(IntegerClass, IntClass, "integer")};
GENERATE_BUILTIN_ALIAS(AnyURIClass, StringClass, "anyURI")};

#endif	/* _BUILTINCLASSES_H */

{'fraction_non_alphanumeric': 0.14309484193011648, 'fraction_numerical': 0.0066555740432612314, 'mean_word_length': 5.092905405405405, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '756545', 'n_tokens_mistral': 1230, 'n_tokens_neox': 1174, 'n_words': 267}