Changeset 512 for cpp/frams


Ignore:
Timestamp:
05/23/16 13:50:18 (8 years ago)
Author:
Maciej Komosinski
Message:

No trailing space in full name when last name is empty

Location:
cpp/frams
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • cpp/frams/model/autoname.cpp

    r348 r512  
    1111        SString t;
    1212        t = firstName(model);
    13         t += ' ';
    14         t += lastName(model);
     13        SString last=lastName(model);
     14        if (last.len()>0)
     15                {
     16                t += ' ';
     17                t += last;
     18                }
    1519        return t;
    1620}
     
    3337}
    3438
    35 SString AutoName::firstName(Model& model)
     39SString AutoName::firstName(const SString& g)
    3640{
    3741        char buf[8];
    3842        unsigned int s1 = 0, s2 = 0, s3 = 0;
    39         SString g = model.getGeno().getGene();
    4043        const char *x = g.c_str();
     44        if (*x==0) return SString();
    4145        for (; *x; x++) { s1 += *x; s2 = s2**x + *x; s3 = (s3^*x) + *x; }
    4246        char* t = buf;
     
    4650        buf[0] = (char)toupper(buf[0]);
    4751        return SString(buf);
     52}
     53
     54SString AutoName::firstName(Model& model)
     55{
     56        return firstName(model.getGeno().getGene());
    4857}
    4958
  • cpp/frams/model/autoname.h

    r343 r512  
    1111class AutoName
    1212{
     13public:
     14        static SString makeName(Model&);
     15        static SString firstName(const SString& g);
    1316        static SString firstName(Model&);
    1417        static SString lastName(Model&);
    15 public:
    16         static SString makeName(Model&);
    1718};
    1819
  • cpp/frams/util/sstringutils.cpp

    r382 r512  
    259259}
    260260
    261 SString trim(SString& s)
     261SString trim(const SString& s)
    262262{
    263263        const unsigned char*b = (const unsigned char*)s.c_str();
  • cpp/frams/util/sstringutils.h

    r382 r512  
    2626void strSetField(SString& txt, const SString& name, const SString& value);
    2727
    28 SString trim(SString& s); ///< remove leading/trailing whitespace
     28SString trim(const SString& s); ///< remove leading/trailing whitespace
    2929bool removeCR(SString& s); ///< remove '\r' return true if changed
    3030bool matchWildcard(const SString& word, const SString& pattern);///< '*' in pattern matches any substring
  • cpp/frams/util/validitychecks.cpp

    r375 r512  
    2121}
    2222
    23 SString stringCheck(SString& in,const char* msgobj,const char* msgfun,const char* msg,SString (*checker)(SString& in))
     23SString stringCheck(SString& in,const char* msgobj,const char* msgfun,const char* msg,SString (*checker)(const SString& in))
    2424{
    2525if (!checker)
  • cpp/frams/util/validitychecks.h

    r375 r512  
    1010
    1111bool listIndexCheck(SList* list,int index,const char* msgobj,const char* msgfun);
    12 SString stringCheck(SString& in,const char* msgobj,const char* msgfun,const char* msg,SString (*checker)(SString& in)=NULL);
     12SString stringCheck(SString& in,const char* msgobj,const char* msgfun,const char* msg,SString (*checker)(const SString& in)=NULL);
    1313
    1414#endif
Note: See TracChangeset for help on using the changeset viewer.