Changeset 297

Show
Ignore:
Timestamp:
02/06/05 18:42:04 (4 years ago)
Author:
athomas
Message:

Refactored Property Map/Scope? so it is cleaner.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • todo2/trunk/configure.in

    r295 r297  
    3232 
    3333AC_LANG([C++]) 
    34 AC_PROG_CXX 
    3534AC_PROG_INSTALL 
    3635AC_PROG_LN_S 
     
    10099 
    101100AC_CONFIG_HEADERS([src/config.h]) 
    102 AC_OUTPUT([Makefile doc/Makefile src/Makefile src/filter/Makefile \ 
     101AC_CONFIG_FILES([Makefile doc/Makefile src/Makefile src/filter/Makefile \ 
    103102        src/backend/Makefile src/frontend/Makefile src/contactmethod/Makefile]) 
     103AC_OUTPUT 
  • todo2/trunk/doc

    • Property svn:ignore set to
      Makefile.in
  • todo2/trunk/src

    • Property svn:ignore set to
      Makefile.in
  • todo2/trunk/src/backend

    • Property svn:ignore set to
      Makefile.in
  • todo2/trunk/src/config.h.in

    r295 r297  
    2525#undef HAVE_BCOPY 
    2626 
     27/* Define to 1 if you have the `closedir' function. */ 
     28#undef HAVE_CLOSEDIR 
     29 
    2730/* Define to 1 if you have the <ctype.h> header file. */ 
    2831#undef HAVE_CTYPE_H 
     
    4750#undef HAVE_DL_H 
    4851 
     52/* Define if you have the _dyld_func_lookup function. */ 
     53#undef HAVE_DYLD 
     54 
    4955/* Define to 1 if you have the <errno.h> header file. */ 
    5056#undef HAVE_ERRNO_H 
     
    6167/* Define if you have the libdl library or equivalent. */ 
    6268#undef HAVE_LIBDL 
     69 
     70/* Define to 1 if you have the <mach-o/dyld.h> header file. */ 
     71#undef HAVE_MACH_O_DYLD_H 
    6372 
    6473/* Define to 1 if you have the <malloc.h> header file. */ 
     
    7786#undef HAVE_NDIR_H 
    7887 
     88/* Define to 1 if you have the `opendir' function. */ 
     89#undef HAVE_OPENDIR 
     90 
    7991/* Define if libtool can extract symbol lists from object files. */ 
    8092#undef HAVE_PRELOADED_SYMBOLS 
     93 
     94/* Define to 1 if you have the `readdir' function. */ 
     95#undef HAVE_READDIR 
    8196 
    8297/* Define to 1 if you have the `rindex' function. */ 
     
    177192#undef const 
    178193 
    179 /* Define to a type to use for \`error_t' if it is not otherwise available. */ 
     194/* Define to a type to use for `error_t' if it is not otherwise available. */ 
    180195#undef error_t 
  • todo2/trunk/src/contactmethod

    • Property svn:ignore set to
      Makefile.in
  • todo2/trunk/src/filter

    • Property svn:ignore set to
      Makefile.in
  • todo2/trunk/src/filter/Expression.cc

    r295 r297  
    11#include <crash/Regex.h> 
    22#include <crash/StringManip.h> 
     3#include <crash/Crash.h> 
    34#include "Manager.h" 
    45#include "Expression.h" 
     
    9899"  true      boolean true\n" 
    99100"  false     boolean false\n" 
     101"  active    is item active\n" 
     102"  created   item creation time\n" 
     103"  modified  item modification time\n" 
     104"  owner     item owner\n" 
     105"  type      item type\n" 
     106"  now       current time\n" 
     107"  lifetime  item lifetime\n" 
     108"  username  current system username\n" 
     109"  hostname  system hostname\n" 
    100110"\n" 
    101111"If a key is not present in the current node, it will be searched for under\n" 
     
    254264                        if (ev == "owner") return item->owner()->id(); 
    255265                        if (ev == "type") return (double)item->type(); 
    256                         if (ev == "now") return (double)time(0); 
     266                        if (ev == "now") return crash::time(); 
    257267                        if (ev == "lifetime") return (double)item->lifetime(); 
     268                        if (ev == "username") return crash::username(); 
     269                        if (ev == "hostname") return crash::hostname(); 
    258270 
    259271                        if (manager.havePriority(ev)) return (double)manager.priority(ev); 
  • todo2/trunk/src/frontend

    • Property svn:ignore set to
      Makefile.in
  • todo2/trunk/src/main.cc

    r295 r297  
    9191                        } 
    9292 
     93                /* Load configuration files */ 
    9394                manager.load(SYSCONFDIR "/todo2rc"); 
    9495                if (getenv("HOME")) 
     
    99100                for (Args::iterator i = args.begin(argc, argv); i != args.end(); ++i) 
    100101                        switch (i.option()) { 
    101                                 // Debug is done twice, in case todo.debug is overridden in a 
    102                                 // configuration file. 
     102                                /*     Debug is done twice, in case todo.debug is overridden in a 
     103                                       configuration file. */ 
    103104                                case 'D' : 
    104105                                        try { 
  • todo2/trunk/src/main.h

    r295 r297  
    44#include <string> 
    55#include <cstdlib> 
    6 #include "gettext.h" 
    76#include "config.h" 
    87 
  • todo2/trunk/src/Makefile.am

    r295 r297  
    77bin_PROGRAMS=todo2 
    88todo2_SOURCES=\ 
    9         Scope.cc Scope.h \ 
    109        Manager.cc Manager.h \ 
    1110        BackEnd.cc BackEnd.h \ 
     
    2120        User.cc User.h \ 
    2221        main.cc main.h \ 
    23         gettext.h \ 
    2422        config.h 
    2523 
  • todo2/trunk/src/Manager.cc

    r295 r297  
    6161        set("frontends", "console"); 
    6262 
    63         set("expression.filter", "!done"); 
     63        set("expression.filter", "!completed"); 
    6464        set("priority.-2", "verylow"); 
    6565        set("priority.-1", "low"); 
  • todo2/trunk/src/PropertyMap.cc

    r295 r297  
    3434} 
    3535 
    36 PropertyMap PropertyMap::prefixToPropertyMap(std::string prefix) const
    37 PropertyMap props
     36PropertyMap PropertyMap::prefixToPropertyMap(std::string prefix)
     37PropertyMap props(this)
    3838 
    3939        for (KeyValues::const_iterator i = mkv.begin(); i != mkv.end(); ++i) 
     
    4545void PropertyMap::load(std::string file) { 
    4646ifstream in(file.c_str()); 
    47 string line
     47string line, section
    4848 
    4949        while (getline(in, line)) { 
     
    5151                        line = line.substr(0, line.find('#')); 
    5252 
     53                if (line[0] == '[' && line.find(']')) { 
     54                        section = line.substr(1, line.find(']') - 1) + "."; 
     55                        while (section.find(":") != string::npos) section[section.find(":")] = '.'; 
     56                        continue; 
     57                } 
     58 
    5359                if (line.find('=') != string::npos) { 
    54                 const string key = trim(line.substr(0, line.find('='))); 
     60                const string key = section + trim(line.substr(0, line.find('='))); 
    5561 
    5662                        set(key, ltrim(line.substr(line.find('=') + 1))); 
  • todo2/trunk/src/PropertyMap.h

    r295 r297  
    3333                }; 
    3434                 
     35                typedef std::map<std::string, Value> KeyValues; 
     36                typedef KeyValues::const_iterator const_iterator; 
     37                typedef KeyValues::iterator iterator; 
     38 
    3539                typedef std::vector<std::string> Keys; 
    3640 
    37                 explicit PropertyMap(PropertyMap *parent = 0) : mparent(parent) {} 
     41                explicit PropertyMap(PropertyMap *parent = 0) : mparentpm(parent) {} 
    3842 
    39                 PropertyMap *parent() { return mparent; } 
    40                 const PropertyMap *parent() const { return mparent; } 
     43                PropertyMap *parent() { return mparentpm; } 
     44                const PropertyMap *parent() const { return mparentpm; } 
     45                PropertyMap *parent(PropertyMap *parent) { mparentpm = parent; return parent; } 
    4146 
    4247                Keys keys() const; 
     
    146151                                contact = mail:alec@swapoff.org 
    147152                */ 
    148                 PropertyMap prefixToPropertyMap(std::string prefix) const
     153                PropertyMap prefixToPropertyMap(std::string prefix)
    149154 
    150155                ///     Load a property map from a configuration file 
     
    161166 
    162167        protected : 
    163                 typedef std::map<std::string, Value> KeyValues; 
    164168 
    165                 PropertyMap *mparent
     169                PropertyMap *mparentpm
    166170                KeyValues mkv; 
    167171}; 
  • todo2/trunk/src/User.cc

    r295 r297  
    77using namespace crash; 
    88 
    9 User::User(const Scope::Map &prop) { 
    10 Scope::Map::const_iterator id = prop.find("id"), name = prop.find("name"), 
    11         contact = prop.find("contact"); 
    12  
    13         mid = id->second; 
     9User::User(const PropertyMap &prop) { 
     10        mid = prop.get("id"); 
    1411        mname = prop.get("name", mid); 
    1512        mcontact = prop.get("contact", "mail:" + mid); 
  • todo2/trunk/src/User.h

    r295 r297  
    55#include <string> 
    66#include <crash/Exception.h> 
    7 #include "Scope.h" 
     7#include "PropertyMap.h" 
    88 
    99/** 
     
    1818 
    1919                User() {} 
    20                 User(const Scope::Map &prop); 
     20                User(const PropertyMap &prop); 
    2121 
    2222                std::string id() const { return mid; } 
  • todo2/trunk/.todo

    r295 r297  
    1 <!-- Automagically generated by the ToDo program on 21/06/04, 22:20 --> 
     1<!-- Automagically generated by the ToDo program on 15/11/04, 16:51 --> 
    22<todo version="0.1.18"> 
    33    <title> 
     
    135135            The Console frontend should have the ability to launch an external editor. 
    136136        </note> 
     137        <note priority="low" time="1100497915"> 
     138            GANTT support. 
     139        </note> 
    137140    </note> 
    138141</todo> 
  • todo2/trunk/.todo2

    r295 r297  
    55                <id>kballico</id> 
    66                <name>Kristy Ballico</name> 
    7                 <contact>mailkballico@failover.org</contact> 
     7                <contact>mail:kballico@failover.org</contact> 
    88        </user> 
    99 
     
    2424                <start time="123123123"/> 
    2525                <end time="123123123"/> 
    26                 <owner id="athomas"/> 
     26                <owner id="kballico"/> 
    2727                <title>This is the title</title> 
    2828                <body>This is some cool text</body>