Compare commits
17 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
25dc415094 | ||
|
|
0b37b6a980 | ||
|
|
42493dbdee | ||
|
|
a8fa293695 | ||
|
|
e7341a19cf | ||
|
|
2ecf500322 | ||
|
|
494ed3b964 | ||
|
|
53747cc984 | ||
|
|
b63cf606f0 | ||
|
|
3dd45611ff | ||
|
|
e32d0562a2 | ||
|
|
a991cbf242 | ||
|
|
2e047367b0 | ||
|
|
f9ed90bee0 | ||
|
|
62e6b31a17 | ||
|
|
ce52f88f4b | ||
|
|
6d5de69f90 |
14
.gitignore
vendored
Normal file
14
.gitignore
vendored
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
Makefile.in
|
||||||
|
aclocal.m4
|
||||||
|
autom4te.cache
|
||||||
|
conf.defs
|
||||||
|
auto.h*
|
||||||
|
config.h.in
|
||||||
|
config.status
|
||||||
|
src/.deps
|
||||||
|
src/Makefile
|
||||||
|
src/task
|
||||||
|
stamp-h1
|
||||||
|
Makefile
|
||||||
|
configure
|
||||||
|
config.log
|
||||||
121
ChangeLog
121
ChangeLog
@@ -1,16 +1,125 @@
|
|||||||
|
|
||||||
|
1.0.0 - First official release ()
|
||||||
|
- Bug: assertion fails for task info n, where n is out of range
|
||||||
|
- Bug: assertion fails on mobile for t v
|
||||||
|
|
||||||
|
0.10.0 - Productization ()
|
||||||
|
~ Documentation complete
|
||||||
|
~ Test suite
|
||||||
|
~ All known bugs fixed
|
||||||
|
|
||||||
|
------ reality -----------------------------------
|
||||||
|
|
||||||
|
0.9.7
|
||||||
|
5/17/2008
|
||||||
|
+ Task offers to create a sample ~/.taskrc file if one is not found.
|
||||||
|
+ Task offers to create a ~/.task directory if one is not found.
|
||||||
|
|
||||||
|
0.9.6
|
||||||
|
5/13/208
|
||||||
|
+ Replaced color management code.
|
||||||
|
+ Improved color rules code.
|
||||||
|
|
||||||
|
0.9.5
|
||||||
|
5/12/2008
|
||||||
|
+ Replaced Table storage with Grid.
|
||||||
|
5/10/2008
|
||||||
|
+ Added Grid.cpp to configure.ac
|
||||||
|
+ Added Makefile to src/.gitignore
|
||||||
|
+ Makefile should not be part of the repository.
|
||||||
|
+ Added Grid.cpp
|
||||||
|
+ Added Grid::Cell::operator==
|
||||||
|
4/27/2008
|
||||||
|
+ ChangeLog file begun.
|
||||||
|
+ Bumped version to 0.9.5 for next release.
|
||||||
|
|
||||||
|
0.9.4
|
||||||
|
4/26/2008
|
||||||
|
+ Integrated new Grid object into build - not yet integrated into Table.
|
||||||
|
4/19/2008
|
||||||
|
+ More .gitignore tweaks.
|
||||||
|
+ Added .gitignore
|
||||||
|
+ Added more missing files.
|
||||||
|
+ Added all source code.
|
||||||
|
+ Generic OSS files added.
|
||||||
|
+ Initial commit.
|
||||||
|
|
||||||
|
0.9.3
|
||||||
|
4/6/2008
|
||||||
|
|
||||||
0.9.2
|
0.9.2
|
||||||
4/3/2008
|
4/3/2008
|
||||||
- Configure now detects ncurses, flock.
|
|
||||||
|
|
||||||
|
|
||||||
0.9.1
|
0.9.1
|
||||||
4/1/2008
|
4/1/2008
|
||||||
- First autoconf version released.
|
|
||||||
- Bug: due dates not checked for correctness
|
|
||||||
- Bug: attributes without values stored instead of removed
|
|
||||||
|
|
||||||
|
|
||||||
0.9.0
|
0.9.0
|
||||||
|
3/23/2008
|
||||||
|
+ flat source directory
|
||||||
|
+ autoconf complete
|
||||||
|
+ "task next"
|
||||||
|
+ "task stats"
|
||||||
|
+ "task export"
|
||||||
|
+ Rule₋based colorization
|
||||||
|
|
||||||
|
0.8.16
|
||||||
|
3/13/208
|
||||||
|
|
||||||
|
0.8.14
|
||||||
|
2/20/2008
|
||||||
|
|
||||||
|
0.8.13
|
||||||
|
2/2/2008
|
||||||
|
|
||||||
|
0.8.1
|
||||||
|
1/28/2008
|
||||||
|
|
||||||
|
0.8.0 - Polish (1/25/2008)
|
||||||
|
+ Code cleanup, reorganization
|
||||||
|
+ "task overdue"
|
||||||
|
+ Add "age" column to list and long
|
||||||
|
+ Use 'conf' for build, version tracking
|
||||||
|
+ Add "/from/to/" description editing
|
||||||
|
|
||||||
|
0.7.0 - Multi-user, File handling, atomicity (1/8/2008)
|
||||||
|
+ Clean, publishable API reimplementation
|
||||||
|
+ File locking
|
||||||
|
+ retain deleted tasks
|
||||||
|
+ "task info ID" report showing all metadata
|
||||||
|
|
||||||
|
0.6.0 - Reports (12/27/2006)
|
||||||
|
+ "task history"
|
||||||
|
+ "task summary"
|
||||||
|
+ "task calendar"
|
||||||
|
+ due: support
|
||||||
|
+ Table sorting
|
||||||
|
|
||||||
|
0.5.0 - Multi-user support (12/10/2006)
|
||||||
|
+ Command logging
|
||||||
|
+ "task usage" report
|
||||||
|
|
||||||
|
0.4.0 - Destructive / modification commands (12/3/2006)
|
||||||
|
+ "task delete" complete
|
||||||
|
+ "task id ..." complete
|
||||||
|
+ "task list ..." synonym for "task find ..."
|
||||||
|
|
||||||
|
0.3.0 - Work in progress support (12/3/2006)
|
||||||
|
+ "task start" complete
|
||||||
|
+ "task done" complete
|
||||||
|
+ completed.data support
|
||||||
|
|
||||||
|
0.2.0 - Neutral commands (12/2/2006)
|
||||||
|
+ "task find" complete
|
||||||
|
+ "task projects" complete
|
||||||
|
+ "task tags" complete
|
||||||
|
|
||||||
|
0.1.0 - Constructive commands (12/1/2006)
|
||||||
|
+ "task add" complete
|
||||||
|
+ completed.data support
|
||||||
|
+ ~/.taskrc support
|
||||||
|
|
||||||
|
0.0.1 - Basic infrastructure (11/29/2006)
|
||||||
|
+ Command line parsing
|
||||||
|
+ API layer
|
||||||
|
+ Usage
|
||||||
|
|
||||||
|
|||||||
40
README
40
README
@@ -5,3 +5,43 @@ Based on ideas in todo.sh
|
|||||||
Movie at www.b.n/task.mov
|
Movie at www.b.n/task.mov
|
||||||
Feedback, suggestions to task@beckingham.net
|
Feedback, suggestions to task@beckingham.net
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Task - a GTD utility featuring:
|
||||||
|
|
||||||
|
- Robust C++ implementation
|
||||||
|
- Tags
|
||||||
|
- Colorful, tabular output
|
||||||
|
- Reports
|
||||||
|
- Low-level API
|
||||||
|
- Auto-completion on all commands, options
|
||||||
|
- Multi-user file locking
|
||||||
|
- Clean architecture allowing quick addition of new features
|
||||||
|
- UUID for all tasks
|
||||||
|
|
||||||
|
Task is an implementation of GTD ideas, similar to todo.sh, but without many of
|
||||||
|
the limitations in todo.sh, namely:
|
||||||
|
|
||||||
|
- Bugs are not being fixed
|
||||||
|
- No response or web update from ________ on code submission
|
||||||
|
- todo.py is the todo.sh replacement, but requires a python installation - a
|
||||||
|
significant barrier to many users, and is currently merely a
|
||||||
|
reimplementation of todo.sh
|
||||||
|
- project.sh is the natural progression for todo.sh, but is intended to be a
|
||||||
|
project management solution, but is so far todo.sh with a "done" and
|
||||||
|
"overview" command
|
||||||
|
- There is no output formatting
|
||||||
|
- There is no way to enumerate projects, categories
|
||||||
|
- There is no file locking for multi-user access
|
||||||
|
- With no API, a graphical front end must reimplement the primitives
|
||||||
|
|
||||||
|
With a robust infrastructure in place for parsing commands, file I/O and
|
||||||
|
structured output, the development threshold for adding new features is kept
|
||||||
|
low.
|
||||||
|
|
||||||
|
It is intended that features, mainly in the form of reports will be added
|
||||||
|
frequently, with best practices and useful reports evolving.
|
||||||
|
|
||||||
|
Task is scope-limited to GTD functionality only.
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
# Process this file with autoconf to produce a configure script.
|
# Process this file with autoconf to produce a configure script.
|
||||||
|
|
||||||
AC_PREREQ(2.61)
|
AC_PREREQ(2.61)
|
||||||
AC_INIT(task, 0.9.4, bugs@beckingham.net)
|
AC_INIT(task, 0.9.7, bugs@beckingham.net)
|
||||||
AM_INIT_AUTOMAKE
|
AM_INIT_AUTOMAKE
|
||||||
AC_CONFIG_SRCDIR([src/task.cpp])
|
AC_CONFIG_SRCDIR([src/task.cpp])
|
||||||
AC_CONFIG_HEADER([auto.h])
|
AC_CONFIG_HEADER([auto.h])
|
||||||
@@ -19,7 +19,7 @@ AC_CHECK_LIB(ncurses,initscr)
|
|||||||
|
|
||||||
# Checks for header files.
|
# Checks for header files.
|
||||||
AC_HEADER_STDC
|
AC_HEADER_STDC
|
||||||
AC_CHECK_HEADERS([stdlib.h sys/file.h sys/time.h unistd.h])
|
AC_CHECK_HEADERS([stdlib.h sys/file.h sys/stat.h sys/time.h unistd.h])
|
||||||
AC_CHECK_HEADERS([string vector map])
|
AC_CHECK_HEADERS([string vector map])
|
||||||
|
|
||||||
# Checks for typedefs, structures, and compiler characteristics.
|
# Checks for typedefs, structures, and compiler characteristics.
|
||||||
@@ -37,5 +37,5 @@ AC_CHECK_FUNCS([select])
|
|||||||
AC_CHECK_FUNC(flock, [AC_DEFINE([HAVE_FLOCK], [1], [Found flock])])
|
AC_CHECK_FUNC(flock, [AC_DEFINE([HAVE_FLOCK], [1], [Found flock])])
|
||||||
AC_CHECK_FUNC(uuid_unparse_lower, [AC_DEFINE([HAVE_UUID], [1], [Found uuid_unparse_lower])])
|
AC_CHECK_FUNC(uuid_unparse_lower, [AC_DEFINE([HAVE_UUID], [1], [Found uuid_unparse_lower])])
|
||||||
|
|
||||||
AC_CONFIG_FILES([Makefile])
|
AC_CONFIG_FILES([Makefile src/Makefile])
|
||||||
AC_OUTPUT
|
AC_OUTPUT
|
||||||
|
|||||||
@@ -91,14 +91,14 @@ Config.o Config.o: Config.cpp /usr/include/c++/4.0.0/iostream \
|
|||||||
/usr/include/c++/4.0.0/bits/istream.tcc /usr/include/c++/4.0.0/fstream \
|
/usr/include/c++/4.0.0/bits/istream.tcc /usr/include/c++/4.0.0/fstream \
|
||||||
/usr/include/c++/4.0.0/i686-apple-darwin9/bits/basic_file.h \
|
/usr/include/c++/4.0.0/i686-apple-darwin9/bits/basic_file.h \
|
||||||
/usr/include/c++/4.0.0/bits/fstream.tcc /usr/include/c++/4.0.0/sstream \
|
/usr/include/c++/4.0.0/bits/fstream.tcc /usr/include/c++/4.0.0/sstream \
|
||||||
/usr/include/c++/4.0.0/bits/sstream.tcc task.h \
|
/usr/include/c++/4.0.0/bits/sstream.tcc /usr/include/sys/stat.h task.h \
|
||||||
/usr/include/c++/4.0.0/vector /usr/include/c++/4.0.0/bits/stl_vector.h \
|
/usr/include/c++/4.0.0/vector /usr/include/c++/4.0.0/bits/stl_vector.h \
|
||||||
/usr/include/c++/4.0.0/bits/stl_bvector.h \
|
/usr/include/c++/4.0.0/bits/stl_bvector.h \
|
||||||
/usr/include/c++/4.0.0/bits/vector.tcc /usr/include/c++/4.0.0/map \
|
/usr/include/c++/4.0.0/bits/vector.tcc /usr/include/c++/4.0.0/map \
|
||||||
/usr/include/c++/4.0.0/bits/stl_tree.h \
|
/usr/include/c++/4.0.0/bits/stl_tree.h \
|
||||||
/usr/include/c++/4.0.0/bits/stl_map.h \
|
/usr/include/c++/4.0.0/bits/stl_map.h \
|
||||||
/usr/include/c++/4.0.0/bits/stl_multimap.h /usr/include/sys/types.h \
|
/usr/include/c++/4.0.0/bits/stl_multimap.h /usr/include/sys/types.h \
|
||||||
Config.h Table.h color.h TDB.h T.h stlmacros.h ../auto.h
|
Config.h Table.h color.h Grid.h color.h TDB.h T.h stlmacros.h ../auto.h
|
||||||
|
|
||||||
/usr/include/c++/4.0.0/iostream:
|
/usr/include/c++/4.0.0/iostream:
|
||||||
|
|
||||||
@@ -366,6 +366,8 @@ Config.o Config.o: Config.cpp /usr/include/c++/4.0.0/iostream \
|
|||||||
|
|
||||||
/usr/include/c++/4.0.0/bits/sstream.tcc:
|
/usr/include/c++/4.0.0/bits/sstream.tcc:
|
||||||
|
|
||||||
|
/usr/include/sys/stat.h:
|
||||||
|
|
||||||
task.h:
|
task.h:
|
||||||
|
|
||||||
/usr/include/c++/4.0.0/vector:
|
/usr/include/c++/4.0.0/vector:
|
||||||
@@ -392,6 +394,10 @@ Table.h:
|
|||||||
|
|
||||||
color.h:
|
color.h:
|
||||||
|
|
||||||
|
Grid.h:
|
||||||
|
|
||||||
|
color.h:
|
||||||
|
|
||||||
TDB.h:
|
TDB.h:
|
||||||
|
|
||||||
T.h:
|
T.h:
|
||||||
|
|||||||
@@ -95,7 +95,8 @@ Date.o Date.o: Date.cpp /usr/include/c++/4.0.0/iostream \
|
|||||||
/usr/include/c++/4.0.0/bits/stl_tree.h \
|
/usr/include/c++/4.0.0/bits/stl_tree.h \
|
||||||
/usr/include/c++/4.0.0/bits/stl_map.h \
|
/usr/include/c++/4.0.0/bits/stl_map.h \
|
||||||
/usr/include/c++/4.0.0/bits/stl_multimap.h /usr/include/sys/types.h \
|
/usr/include/c++/4.0.0/bits/stl_multimap.h /usr/include/sys/types.h \
|
||||||
Config.h Table.h color.h TDB.h T.h stlmacros.h ../auto.h Date.h
|
Config.h Table.h color.h Grid.h color.h TDB.h T.h stlmacros.h ../auto.h \
|
||||||
|
Date.h
|
||||||
|
|
||||||
/usr/include/c++/4.0.0/iostream:
|
/usr/include/c++/4.0.0/iostream:
|
||||||
|
|
||||||
@@ -379,6 +380,10 @@ Table.h:
|
|||||||
|
|
||||||
color.h:
|
color.h:
|
||||||
|
|
||||||
|
Grid.h:
|
||||||
|
|
||||||
|
color.h:
|
||||||
|
|
||||||
TDB.h:
|
TDB.h:
|
||||||
|
|
||||||
T.h:
|
T.h:
|
||||||
|
|||||||
@@ -95,7 +95,7 @@ T.o T.o: T.cpp /usr/include/c++/4.0.0/iostream \
|
|||||||
/usr/include/c++/4.0.0/bits/stl_tree.h \
|
/usr/include/c++/4.0.0/bits/stl_tree.h \
|
||||||
/usr/include/c++/4.0.0/bits/stl_map.h \
|
/usr/include/c++/4.0.0/bits/stl_map.h \
|
||||||
/usr/include/c++/4.0.0/bits/stl_multimap.h /usr/include/sys/types.h \
|
/usr/include/c++/4.0.0/bits/stl_multimap.h /usr/include/sys/types.h \
|
||||||
Config.h Table.h color.h TDB.h T.h stlmacros.h ../auto.h
|
Config.h Table.h color.h Grid.h color.h TDB.h T.h stlmacros.h ../auto.h
|
||||||
|
|
||||||
/usr/include/c++/4.0.0/iostream:
|
/usr/include/c++/4.0.0/iostream:
|
||||||
|
|
||||||
@@ -379,6 +379,10 @@ Table.h:
|
|||||||
|
|
||||||
color.h:
|
color.h:
|
||||||
|
|
||||||
|
Grid.h:
|
||||||
|
|
||||||
|
color.h:
|
||||||
|
|
||||||
TDB.h:
|
TDB.h:
|
||||||
|
|
||||||
T.h:
|
T.h:
|
||||||
|
|||||||
@@ -99,7 +99,7 @@ TDB.o TDB.o: TDB.cpp /usr/include/c++/4.0.0/iostream \
|
|||||||
/usr/include/c++/4.0.0/bits/stl_tree.h \
|
/usr/include/c++/4.0.0/bits/stl_tree.h \
|
||||||
/usr/include/c++/4.0.0/bits/stl_map.h \
|
/usr/include/c++/4.0.0/bits/stl_map.h \
|
||||||
/usr/include/c++/4.0.0/bits/stl_multimap.h Config.h Table.h color.h \
|
/usr/include/c++/4.0.0/bits/stl_multimap.h Config.h Table.h color.h \
|
||||||
TDB.h T.h stlmacros.h ../auto.h
|
Grid.h color.h TDB.h T.h stlmacros.h ../auto.h
|
||||||
|
|
||||||
/usr/include/c++/4.0.0/iostream:
|
/usr/include/c++/4.0.0/iostream:
|
||||||
|
|
||||||
@@ -395,6 +395,10 @@ Table.h:
|
|||||||
|
|
||||||
color.h:
|
color.h:
|
||||||
|
|
||||||
|
Grid.h:
|
||||||
|
|
||||||
|
color.h:
|
||||||
|
|
||||||
TDB.h:
|
TDB.h:
|
||||||
|
|
||||||
T.h:
|
T.h:
|
||||||
|
|||||||
@@ -94,8 +94,9 @@ Table.o Table.o: Table.cpp /usr/include/c++/4.0.0/iostream \
|
|||||||
/usr/include/c++/4.0.0/bits/stl_multimap.h \
|
/usr/include/c++/4.0.0/bits/stl_multimap.h \
|
||||||
/usr/include/c++/4.0.0/vector /usr/include/c++/4.0.0/bits/stl_vector.h \
|
/usr/include/c++/4.0.0/vector /usr/include/c++/4.0.0/bits/stl_vector.h \
|
||||||
/usr/include/c++/4.0.0/bits/stl_bvector.h \
|
/usr/include/c++/4.0.0/bits/stl_bvector.h \
|
||||||
/usr/include/c++/4.0.0/bits/vector.tcc color.h Date.h stlmacros.h \
|
/usr/include/c++/4.0.0/bits/vector.tcc color.h Grid.h Date.h task.h \
|
||||||
task.h /usr/include/sys/types.h Config.h TDB.h T.h ../auto.h
|
/usr/include/sys/types.h Config.h Table.h color.h TDB.h T.h T.h \
|
||||||
|
stlmacros.h ../auto.h
|
||||||
|
|
||||||
/usr/include/c++/4.0.0/iostream:
|
/usr/include/c++/4.0.0/iostream:
|
||||||
|
|
||||||
@@ -373,9 +374,9 @@ Table.h:
|
|||||||
|
|
||||||
color.h:
|
color.h:
|
||||||
|
|
||||||
Date.h:
|
Grid.h:
|
||||||
|
|
||||||
stlmacros.h:
|
Date.h:
|
||||||
|
|
||||||
task.h:
|
task.h:
|
||||||
|
|
||||||
@@ -383,8 +384,16 @@ task.h:
|
|||||||
|
|
||||||
Config.h:
|
Config.h:
|
||||||
|
|
||||||
|
Table.h:
|
||||||
|
|
||||||
|
color.h:
|
||||||
|
|
||||||
TDB.h:
|
TDB.h:
|
||||||
|
|
||||||
T.h:
|
T.h:
|
||||||
|
|
||||||
|
T.h:
|
||||||
|
|
||||||
|
stlmacros.h:
|
||||||
|
|
||||||
../auto.h:
|
../auto.h:
|
||||||
|
|||||||
@@ -95,8 +95,8 @@ parse.o parse.o: parse.cpp /usr/include/c++/4.0.0/iostream \
|
|||||||
/usr/include/c++/4.0.0/bits/stl_tree.h \
|
/usr/include/c++/4.0.0/bits/stl_tree.h \
|
||||||
/usr/include/c++/4.0.0/bits/stl_map.h \
|
/usr/include/c++/4.0.0/bits/stl_map.h \
|
||||||
/usr/include/c++/4.0.0/bits/stl_multimap.h Date.h task.h \
|
/usr/include/c++/4.0.0/bits/stl_multimap.h Date.h task.h \
|
||||||
/usr/include/sys/types.h Config.h Table.h color.h TDB.h T.h stlmacros.h \
|
/usr/include/sys/types.h Config.h Table.h color.h Grid.h color.h TDB.h \
|
||||||
../auto.h
|
T.h stlmacros.h ../auto.h
|
||||||
|
|
||||||
/usr/include/c++/4.0.0/iostream:
|
/usr/include/c++/4.0.0/iostream:
|
||||||
|
|
||||||
@@ -382,6 +382,10 @@ Table.h:
|
|||||||
|
|
||||||
color.h:
|
color.h:
|
||||||
|
|
||||||
|
Grid.h:
|
||||||
|
|
||||||
|
color.h:
|
||||||
|
|
||||||
TDB.h:
|
TDB.h:
|
||||||
|
|
||||||
T.h:
|
T.h:
|
||||||
|
|||||||
@@ -94,8 +94,8 @@ rules.o rules.o: rules.cpp /usr/include/c++/4.0.0/iostream \
|
|||||||
/usr/include/c++/4.0.0/bits/stl_multimap.h \
|
/usr/include/c++/4.0.0/bits/stl_multimap.h \
|
||||||
/usr/include/c++/4.0.0/vector /usr/include/c++/4.0.0/bits/stl_vector.h \
|
/usr/include/c++/4.0.0/vector /usr/include/c++/4.0.0/bits/stl_vector.h \
|
||||||
/usr/include/c++/4.0.0/bits/stl_bvector.h \
|
/usr/include/c++/4.0.0/bits/stl_bvector.h \
|
||||||
/usr/include/c++/4.0.0/bits/vector.tcc Table.h color.h Date.h T.h \
|
/usr/include/c++/4.0.0/bits/vector.tcc Table.h color.h Grid.h Date.h \
|
||||||
task.h /usr/include/sys/types.h TDB.h stlmacros.h ../auto.h
|
T.h task.h /usr/include/sys/types.h color.h TDB.h stlmacros.h ../auto.h
|
||||||
|
|
||||||
/usr/include/c++/4.0.0/iostream:
|
/usr/include/c++/4.0.0/iostream:
|
||||||
|
|
||||||
@@ -375,6 +375,8 @@ Table.h:
|
|||||||
|
|
||||||
color.h:
|
color.h:
|
||||||
|
|
||||||
|
Grid.h:
|
||||||
|
|
||||||
Date.h:
|
Date.h:
|
||||||
|
|
||||||
T.h:
|
T.h:
|
||||||
@@ -383,6 +385,8 @@ task.h:
|
|||||||
|
|
||||||
/usr/include/sys/types.h:
|
/usr/include/sys/types.h:
|
||||||
|
|
||||||
|
color.h:
|
||||||
|
|
||||||
TDB.h:
|
TDB.h:
|
||||||
|
|
||||||
stlmacros.h:
|
stlmacros.h:
|
||||||
|
|||||||
@@ -98,8 +98,8 @@ task.o task.o: task.cpp /usr/include/c++/4.0.0/iostream \
|
|||||||
/usr/include/c++/4.0.0/bits/stl_multimap.h \
|
/usr/include/c++/4.0.0/bits/stl_multimap.h \
|
||||||
/usr/include/c++/4.0.0/vector /usr/include/c++/4.0.0/bits/stl_vector.h \
|
/usr/include/c++/4.0.0/vector /usr/include/c++/4.0.0/bits/stl_vector.h \
|
||||||
/usr/include/c++/4.0.0/bits/stl_bvector.h \
|
/usr/include/c++/4.0.0/bits/stl_bvector.h \
|
||||||
/usr/include/c++/4.0.0/bits/vector.tcc Date.h Table.h color.h \
|
/usr/include/c++/4.0.0/bits/vector.tcc Date.h Table.h color.h Grid.h \
|
||||||
stlmacros.h TDB.h T.h task.h ../auto.h /usr/include/ncurses.h \
|
stlmacros.h TDB.h T.h task.h color.h ../auto.h /usr/include/ncurses.h \
|
||||||
/usr/include/ncurses_dll.h /usr/include/unctrl.h /usr/include/curses.h
|
/usr/include/ncurses_dll.h /usr/include/unctrl.h /usr/include/curses.h
|
||||||
|
|
||||||
/usr/include/c++/4.0.0/iostream:
|
/usr/include/c++/4.0.0/iostream:
|
||||||
@@ -396,6 +396,8 @@ Table.h:
|
|||||||
|
|
||||||
color.h:
|
color.h:
|
||||||
|
|
||||||
|
Grid.h:
|
||||||
|
|
||||||
stlmacros.h:
|
stlmacros.h:
|
||||||
|
|
||||||
TDB.h:
|
TDB.h:
|
||||||
@@ -404,6 +406,8 @@ T.h:
|
|||||||
|
|
||||||
task.h:
|
task.h:
|
||||||
|
|
||||||
|
color.h:
|
||||||
|
|
||||||
../auto.h:
|
../auto.h:
|
||||||
|
|
||||||
/usr/include/ncurses.h:
|
/usr/include/ncurses.h:
|
||||||
|
|||||||
@@ -95,7 +95,7 @@ text.o text.o: text.cpp /usr/include/c++/4.0.0/iostream \
|
|||||||
/usr/include/c++/4.0.0/map /usr/include/c++/4.0.0/bits/stl_tree.h \
|
/usr/include/c++/4.0.0/map /usr/include/c++/4.0.0/bits/stl_tree.h \
|
||||||
/usr/include/c++/4.0.0/bits/stl_map.h \
|
/usr/include/c++/4.0.0/bits/stl_map.h \
|
||||||
/usr/include/c++/4.0.0/bits/stl_multimap.h /usr/include/sys/types.h \
|
/usr/include/c++/4.0.0/bits/stl_multimap.h /usr/include/sys/types.h \
|
||||||
Config.h Table.h color.h TDB.h T.h stlmacros.h ../auto.h
|
Config.h Table.h color.h Grid.h color.h TDB.h T.h stlmacros.h ../auto.h
|
||||||
|
|
||||||
/usr/include/c++/4.0.0/iostream:
|
/usr/include/c++/4.0.0/iostream:
|
||||||
|
|
||||||
@@ -379,6 +379,10 @@ Table.h:
|
|||||||
|
|
||||||
color.h:
|
color.h:
|
||||||
|
|
||||||
|
Grid.h:
|
||||||
|
|
||||||
|
color.h:
|
||||||
|
|
||||||
TDB.h:
|
TDB.h:
|
||||||
|
|
||||||
T.h:
|
T.h:
|
||||||
|
|||||||
@@ -95,8 +95,9 @@ util.o util.o: util.cpp /usr/include/c++/4.0.0/iostream \
|
|||||||
/usr/include/sys/time.h Table.h /usr/include/c++/4.0.0/map \
|
/usr/include/sys/time.h Table.h /usr/include/c++/4.0.0/map \
|
||||||
/usr/include/c++/4.0.0/bits/stl_tree.h \
|
/usr/include/c++/4.0.0/bits/stl_tree.h \
|
||||||
/usr/include/c++/4.0.0/bits/stl_map.h \
|
/usr/include/c++/4.0.0/bits/stl_map.h \
|
||||||
/usr/include/c++/4.0.0/bits/stl_multimap.h color.h task.h Config.h \
|
/usr/include/c++/4.0.0/bits/stl_multimap.h color.h Grid.h task.h \
|
||||||
TDB.h T.h stlmacros.h ../auto.h /usr/include/uuid/uuid.h
|
Config.h color.h TDB.h T.h stlmacros.h ../auto.h \
|
||||||
|
/usr/include/uuid/uuid.h
|
||||||
|
|
||||||
/usr/include/c++/4.0.0/iostream:
|
/usr/include/c++/4.0.0/iostream:
|
||||||
|
|
||||||
@@ -378,10 +379,14 @@ Table.h:
|
|||||||
|
|
||||||
color.h:
|
color.h:
|
||||||
|
|
||||||
|
Grid.h:
|
||||||
|
|
||||||
task.h:
|
task.h:
|
||||||
|
|
||||||
Config.h:
|
Config.h:
|
||||||
|
|
||||||
|
color.h:
|
||||||
|
|
||||||
TDB.h:
|
TDB.h:
|
||||||
|
|
||||||
T.h:
|
T.h:
|
||||||
|
|||||||
2
src/.gitignore
vendored
Normal file
2
src/.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
Makefile
|
||||||
|
*.o
|
||||||
@@ -6,6 +6,7 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
#include <sys/stat.h>
|
||||||
#include "task.h"
|
#include "task.h"
|
||||||
#include "Config.h"
|
#include "Config.h"
|
||||||
|
|
||||||
@@ -60,6 +61,67 @@ bool Config::load (const std::string& file)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
void Config::createDefault (const std::string& file)
|
||||||
|
{
|
||||||
|
if (confirm (
|
||||||
|
"A configuration file could not be found in "
|
||||||
|
+ file
|
||||||
|
+ "\n\n"
|
||||||
|
+ "Would you like a sample .taskrc created, so task can proceed?"))
|
||||||
|
{
|
||||||
|
// Determine a path to the task directory.
|
||||||
|
std::string taskDir = "";
|
||||||
|
for (int i = file.length () - 1; i >= 0; --i)
|
||||||
|
{
|
||||||
|
if (file[i] == '/')
|
||||||
|
{
|
||||||
|
taskDir = file.substr (0, i) + "/.task";
|
||||||
|
if (-1 == access (taskDir.c_str (), F_OK))
|
||||||
|
mkdir (taskDir.c_str (), S_IRWXU);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (taskDir != "")
|
||||||
|
{
|
||||||
|
FILE* out;
|
||||||
|
if (out = fopen (file.c_str (), "w"))
|
||||||
|
{
|
||||||
|
fprintf (out, "data.location=%s\n", taskDir.c_str ());
|
||||||
|
fprintf (out, "command.logging=off\n");
|
||||||
|
fprintf (out, "confirmation=yes\n");
|
||||||
|
fprintf (out, "#nag=Note: try to stick to high priority tasks. See \"task next\".\n");
|
||||||
|
fprintf (out, "next=2\n");
|
||||||
|
fprintf (out, "curses=on\n");
|
||||||
|
fprintf (out, "color=on\n");
|
||||||
|
|
||||||
|
fprintf (out, "color.overdue=red\n");
|
||||||
|
fprintf (out, "#color.due=on yellow\n");
|
||||||
|
fprintf (out, "#color.pri.H=on_red\n");
|
||||||
|
fprintf (out, "#color.pri.M=on_yellow\n");
|
||||||
|
fprintf (out, "#color.pri.L=on_green\n");
|
||||||
|
fprintf (out, "color.active=cyan\n");
|
||||||
|
fprintf (out, "color.tagged=yellow\n");
|
||||||
|
|
||||||
|
fclose (out);
|
||||||
|
|
||||||
|
set ("data.location", taskDir);
|
||||||
|
set ("command.logging", "off");
|
||||||
|
set ("confirmation", "yes");
|
||||||
|
set ("next", 2);
|
||||||
|
set ("curses", "on");
|
||||||
|
set ("color", "on");
|
||||||
|
set ("color.overdue", "red");
|
||||||
|
set ("color.active", "cyan");
|
||||||
|
set ("color.tagged", "yellow");
|
||||||
|
|
||||||
|
std::cout << "Done." << std::endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// Return the configuration value given the specified key.
|
// Return the configuration value given the specified key.
|
||||||
const std::string& Config::get (const char* key)
|
const std::string& Config::get (const char* key)
|
||||||
|
|||||||
@@ -17,6 +17,8 @@ public:
|
|||||||
Config (const std::string&);
|
Config (const std::string&);
|
||||||
|
|
||||||
bool load (const std::string&);
|
bool load (const std::string&);
|
||||||
|
void createDefault (const std::string&);
|
||||||
|
|
||||||
const std::string& get (const char*);
|
const std::string& get (const char*);
|
||||||
const std::string& get (const char*, const char*);
|
const std::string& get (const char*, const char*);
|
||||||
const std::string& get (const std::string&);
|
const std::string& get (const std::string&);
|
||||||
|
|||||||
425
src/Grid.cpp
Normal file
425
src/Grid.cpp
Normal file
@@ -0,0 +1,425 @@
|
|||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Copyright 2007 - 2008, Paul Beckingham. All rights reserved.
|
||||||
|
//
|
||||||
|
// Grid implements a sparse 2D array of Cell objects. Grid makes every effort
|
||||||
|
// to perform well on cell insertion and retrieval. A Cell is a variant type,
|
||||||
|
// capable of storing char, bool, int, float, double and std::string types.
|
||||||
|
//
|
||||||
|
// Every cell is accessible from both mColumns and mRows. This allows the
|
||||||
|
// client code to specify which method is used, because there will be a
|
||||||
|
// performance penalty with one of the methods, depending on the layout of
|
||||||
|
// cells within the grid.
|
||||||
|
//
|
||||||
|
// mColumns, like mRows, is a vector of a vector of Cell*.
|
||||||
|
//
|
||||||
|
// mColumns
|
||||||
|
// [0..n]
|
||||||
|
// +---+---+-----------+---+
|
||||||
|
// | 0 | 1 | | n |
|
||||||
|
// +---+---+-----------+---+
|
||||||
|
// | |
|
||||||
|
// v |
|
||||||
|
// +---+ . +---+ . | .
|
||||||
|
// mRows | 0 | -------> | x | v
|
||||||
|
// [0..1] +---+ . +---+ +---+
|
||||||
|
// | 1 | -------> | y | --------> | z |
|
||||||
|
// +---+ . +---+ +---+
|
||||||
|
// | |
|
||||||
|
// | |
|
||||||
|
// | |
|
||||||
|
// +---+ . . . . .
|
||||||
|
// | n |
|
||||||
|
// +---+ . . . . .
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
#include <Grid.h>
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
Grid::Grid ()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// The cells are deleted via their mRows reference, not by their mColumns
|
||||||
|
// reference. This is because the cells are doubly-linked, and so the
|
||||||
|
// convention is that rows own cells, columns merely own pointers.
|
||||||
|
Grid::~Grid ()
|
||||||
|
{
|
||||||
|
std::vector < std::vector <Cell*>* >::iterator row;
|
||||||
|
std::vector <Cell*>::iterator col;
|
||||||
|
for (row = mRows.begin (); row != mRows.end (); ++row)
|
||||||
|
if (*row)
|
||||||
|
for (col = (*row)->begin (); col != (*row)->end (); ++col)
|
||||||
|
if (*col)
|
||||||
|
delete *col;
|
||||||
|
|
||||||
|
std::vector < std::vector <Cell*>* >::iterator it;
|
||||||
|
for (it = mRows.begin (); it != mRows.end (); ++it)
|
||||||
|
if (*it)
|
||||||
|
delete *it;
|
||||||
|
|
||||||
|
for (it = mColumns.begin (); it != mColumns.end (); ++it)
|
||||||
|
if (*it)
|
||||||
|
delete *it;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
void Grid::add (
|
||||||
|
const unsigned int row,
|
||||||
|
const unsigned int col,
|
||||||
|
const bool value)
|
||||||
|
{
|
||||||
|
expandGrid (row, col);
|
||||||
|
insertCell (row, col, new Cell (value));
|
||||||
|
}
|
||||||
|
|
||||||
|
void Grid::add (
|
||||||
|
const unsigned int row,
|
||||||
|
const unsigned int col,
|
||||||
|
const char value)
|
||||||
|
{
|
||||||
|
expandGrid (row, col);
|
||||||
|
insertCell (row, col, new Cell (value));
|
||||||
|
}
|
||||||
|
|
||||||
|
void Grid::add (
|
||||||
|
const unsigned int row,
|
||||||
|
const unsigned int col,
|
||||||
|
const int value)
|
||||||
|
{
|
||||||
|
expandGrid (row, col);
|
||||||
|
insertCell (row, col, new Cell (value));
|
||||||
|
}
|
||||||
|
|
||||||
|
void Grid::add (
|
||||||
|
const unsigned int row,
|
||||||
|
const unsigned int col,
|
||||||
|
const float value)
|
||||||
|
{
|
||||||
|
expandGrid (row, col);
|
||||||
|
insertCell (row, col, new Cell (value));
|
||||||
|
}
|
||||||
|
|
||||||
|
void Grid::add (
|
||||||
|
const unsigned int row,
|
||||||
|
const unsigned int col,
|
||||||
|
const double value)
|
||||||
|
{
|
||||||
|
expandGrid (row, col);
|
||||||
|
insertCell (row, col, new Cell (value));
|
||||||
|
}
|
||||||
|
|
||||||
|
void Grid::add (
|
||||||
|
const unsigned int row,
|
||||||
|
const unsigned int col,
|
||||||
|
const char* value)
|
||||||
|
{
|
||||||
|
expandGrid (row, col);
|
||||||
|
insertCell (row, col, new Cell (std::string (value)));
|
||||||
|
}
|
||||||
|
|
||||||
|
void Grid::add (
|
||||||
|
const unsigned int row,
|
||||||
|
const unsigned int col,
|
||||||
|
const std::string& value)
|
||||||
|
{
|
||||||
|
expandGrid (row, col);
|
||||||
|
insertCell (row, col, new Cell (value));
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
unsigned int Grid::width () const
|
||||||
|
{
|
||||||
|
return mColumns.size ();
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned int Grid::height () const
|
||||||
|
{
|
||||||
|
return mRows.size ();
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
Grid::Cell* Grid::byRow (const unsigned int row, const unsigned int col) const
|
||||||
|
{
|
||||||
|
if (row <= mRows.size () &&
|
||||||
|
mRows[row] != NULL &&
|
||||||
|
col <= mRows[row]->size ())
|
||||||
|
return (*mRows[row])[col];
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
Grid::Cell* Grid::byColumn (const unsigned int row, const unsigned int col) const
|
||||||
|
{
|
||||||
|
if (col <= mColumns.size () &&
|
||||||
|
mColumns[col] != NULL &&
|
||||||
|
row <= mColumns[col]->size ())
|
||||||
|
return (*mColumns[col])[row];
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
void Grid::expandGrid (const unsigned int row, const unsigned int col)
|
||||||
|
{
|
||||||
|
// If the new row is outside the bounds of the current grid, add blank rows to
|
||||||
|
// pad, then a new row vector.
|
||||||
|
if (row >= mRows.size ())
|
||||||
|
{
|
||||||
|
for (unsigned int r = mRows.size (); r <= row; ++r)
|
||||||
|
if (r < row)
|
||||||
|
// {
|
||||||
|
// std::cout << "additional mRows[" << r << "] = NULL" << std::endl;
|
||||||
|
mRows.push_back (NULL);
|
||||||
|
// }
|
||||||
|
else
|
||||||
|
// {
|
||||||
|
// std::cout << "additional mRows[" << r << "] = new std::vector <Cell*>" << std::endl;
|
||||||
|
mRows.push_back (new std::vector <Cell*>);
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
// If the new row is within the bounds of the current grid, ensure that the
|
||||||
|
// row points to a vector of cells.
|
||||||
|
else if (mRows[row] == NULL)
|
||||||
|
// {
|
||||||
|
// std::cout << "existing mRows[" << row << "] = new std::vector <Cell*>" << std::endl;
|
||||||
|
mRows[row] = new std::vector <Cell*>;
|
||||||
|
// }
|
||||||
|
|
||||||
|
if (col >= mRows[row]->size ())
|
||||||
|
for (unsigned int c = mRows[row]->size (); c <= col; ++c)
|
||||||
|
// {
|
||||||
|
// std::cout << "additional mRows[" << row << "][" << c << "] = NULL" << std::endl;
|
||||||
|
mRows[row]->push_back (NULL);
|
||||||
|
// }
|
||||||
|
|
||||||
|
// If the new col is outside the bounds of the current grid, add blank cols to
|
||||||
|
// pad, then a new col vector.
|
||||||
|
if (col >= mColumns.size ())
|
||||||
|
{
|
||||||
|
for (unsigned int c = mColumns.size (); c <= col; ++c)
|
||||||
|
if (c < col)
|
||||||
|
// {
|
||||||
|
// std::cout << "additional mColumns[" << c << "] = NULL" << std::endl;
|
||||||
|
mColumns.push_back (NULL);
|
||||||
|
// }
|
||||||
|
else
|
||||||
|
// {
|
||||||
|
// std::cout << "additional mColumns[" << c << "] = new std::vector <Cell*>" << std::endl;
|
||||||
|
mColumns.push_back (new std::vector <Cell*>);
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
// If the new col is within the bounds of the current grid, ensure that the
|
||||||
|
// col points to a vector of cells.
|
||||||
|
else if (mColumns[col] == NULL)
|
||||||
|
// {
|
||||||
|
// std::cout << "existing mColumns[" << col << "] = new std::vector <Cell*>" << std::endl;
|
||||||
|
mColumns[col] = new std::vector <Cell*>;
|
||||||
|
// }
|
||||||
|
|
||||||
|
if (row >= mColumns[col]->size ())
|
||||||
|
for (unsigned int r = mColumns[col]->size (); r <= row; ++r)
|
||||||
|
// {
|
||||||
|
// std::cout << "additional mColumns[" << col << "][" << r << "] = NULL" << std::endl;
|
||||||
|
mColumns[col]->push_back (NULL);
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
void Grid::insertCell (
|
||||||
|
const unsigned int row,
|
||||||
|
const unsigned int col,
|
||||||
|
Cell* cell)
|
||||||
|
{
|
||||||
|
// Delete any existing cell, because cells are owned by rows, not columns.
|
||||||
|
if ((*mRows[row])[col] != NULL)
|
||||||
|
// {
|
||||||
|
// std::cout << "deleted old cell mRows[" << row << "][" << col << "]" << std::endl;
|
||||||
|
delete (*mRows[row])[col];
|
||||||
|
// }
|
||||||
|
|
||||||
|
(*mRows[row])[col] = cell;
|
||||||
|
(*mColumns[col])[row] = cell;
|
||||||
|
// std::cout << "assigned new cell mRows[" << row << "][" << col << "]" << std::endl;
|
||||||
|
// std::cout << "assigned new cell mColumns[" << col << "][" << row << "]" << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
Grid::Cell::Cell (const bool value)
|
||||||
|
: mType (CELL_BOOL)
|
||||||
|
, mBool (value)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
Grid::Cell::Cell (const char value)
|
||||||
|
: mType (CELL_CHAR)
|
||||||
|
, mChar (value)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
Grid::Cell::Cell (const int value)
|
||||||
|
: mType (CELL_INT)
|
||||||
|
, mInt (value)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
Grid::Cell::Cell (const float value)
|
||||||
|
: mType (CELL_FLOAT)
|
||||||
|
, mFloat (value)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
Grid::Cell::Cell (const double value)
|
||||||
|
: mType (CELL_DOUBLE)
|
||||||
|
, mDouble (value)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
Grid::Cell::Cell (const std::string& value)
|
||||||
|
: mType (CELL_STRING)
|
||||||
|
, mString (value)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// These cast operators make a best approximation to an appropriate rendering,
|
||||||
|
// given the format change.
|
||||||
|
Grid::Cell::operator bool () const
|
||||||
|
{
|
||||||
|
switch (mType)
|
||||||
|
{
|
||||||
|
case CELL_BOOL: return mBool;
|
||||||
|
case CELL_CHAR: return mChar != '\0' &&
|
||||||
|
mChar != ' ' &&
|
||||||
|
mChar != '0';
|
||||||
|
case CELL_INT: return mInt != 0;
|
||||||
|
case CELL_FLOAT: return mFloat != 0.0;
|
||||||
|
case CELL_DOUBLE: return mDouble != 0.0;
|
||||||
|
case CELL_STRING: return mString.length () > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
Grid::Cell::operator char () const
|
||||||
|
{
|
||||||
|
switch (mType)
|
||||||
|
{
|
||||||
|
case CELL_BOOL: return mBool ? 'Y' : 'N';
|
||||||
|
case CELL_CHAR: return mChar;
|
||||||
|
case CELL_INT: return (char) mInt;
|
||||||
|
case CELL_FLOAT: return (char) (int) mFloat;
|
||||||
|
case CELL_DOUBLE: return (char) (int) mDouble;
|
||||||
|
case CELL_STRING: return mString[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
return '\0';
|
||||||
|
}
|
||||||
|
|
||||||
|
Grid::Cell::operator int () const
|
||||||
|
{
|
||||||
|
switch (mType)
|
||||||
|
{
|
||||||
|
case CELL_BOOL: return mBool ? 1 : 0;
|
||||||
|
case CELL_CHAR: return (int) mChar;
|
||||||
|
case CELL_INT: return mInt;
|
||||||
|
case CELL_FLOAT: return (int) mFloat;
|
||||||
|
case CELL_DOUBLE: return (int) mDouble;
|
||||||
|
case CELL_STRING: return mString.length ();
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
Grid::Cell::operator float () const
|
||||||
|
{
|
||||||
|
switch (mType)
|
||||||
|
{
|
||||||
|
case CELL_BOOL: return mBool ? 1.0 : 0.0;
|
||||||
|
case CELL_CHAR: return (float) (int) mChar;
|
||||||
|
case CELL_INT: return (float) mInt;
|
||||||
|
case CELL_FLOAT: return mFloat;
|
||||||
|
case CELL_DOUBLE: return (float) mDouble;
|
||||||
|
case CELL_STRING: return (float) mString.length ();
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
Grid::Cell::operator double () const
|
||||||
|
{
|
||||||
|
switch (mType)
|
||||||
|
{
|
||||||
|
case CELL_BOOL: return mBool ? 1.0 : 0.0;
|
||||||
|
case CELL_CHAR: return (double) (int) mChar;
|
||||||
|
case CELL_INT: return (double) mInt;
|
||||||
|
case CELL_FLOAT: return (double) mFloat;
|
||||||
|
case CELL_DOUBLE: return mDouble;
|
||||||
|
case CELL_STRING: return (double) mString.length ();
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
Grid::Cell::operator std::string () const
|
||||||
|
{
|
||||||
|
char s[64] = {0};
|
||||||
|
|
||||||
|
switch (mType)
|
||||||
|
{
|
||||||
|
case CELL_BOOL: return mBool ? "true" : "false";
|
||||||
|
case CELL_CHAR: sprintf (s, "%c", mChar);
|
||||||
|
return std::string (s);
|
||||||
|
case CELL_INT: sprintf (s, "%d", mInt);
|
||||||
|
return std::string (s);
|
||||||
|
case CELL_FLOAT: sprintf (s, "%f", mFloat);
|
||||||
|
return std::string (s);
|
||||||
|
case CELL_DOUBLE: sprintf (s, "%f", mDouble);
|
||||||
|
return std::string (s);
|
||||||
|
case CELL_STRING: return mString;
|
||||||
|
}
|
||||||
|
|
||||||
|
return std::string ("");
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
bool Grid::Cell::operator== (const Grid::Cell& rhs) const
|
||||||
|
{
|
||||||
|
switch (mType)
|
||||||
|
{
|
||||||
|
case CELL_BOOL: return mBool == rhs.mBool ? true : false;
|
||||||
|
case CELL_CHAR: return mChar == rhs.mChar ? true : false;
|
||||||
|
case CELL_INT: return mInt == rhs.mInt ? true : false;
|
||||||
|
case CELL_FLOAT: return mFloat == rhs.mFloat ? true : false;
|
||||||
|
case CELL_DOUBLE: return mDouble == rhs.mDouble ? true : false;
|
||||||
|
case CELL_STRING: return mString == rhs.mString ? true : false;
|
||||||
|
default: break; // To prevent warnings.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
bool Grid::Cell::operator!= (const Grid::Cell& rhs) const
|
||||||
|
{
|
||||||
|
switch (mType)
|
||||||
|
{
|
||||||
|
case CELL_BOOL: return mBool != rhs.mBool ? true : false;
|
||||||
|
case CELL_CHAR: return mChar != rhs.mChar ? true : false;
|
||||||
|
case CELL_INT: return mInt != rhs.mInt ? true : false;
|
||||||
|
case CELL_FLOAT: return mFloat != rhs.mFloat ? true : false;
|
||||||
|
case CELL_DOUBLE: return mDouble != rhs.mDouble ? true : false;
|
||||||
|
case CELL_STRING: return mString != rhs.mString ? true : false;
|
||||||
|
default: break; // To prevent warnings.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
Grid::Cell::cellType Grid::Cell::type () const
|
||||||
|
{
|
||||||
|
return mType;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
78
src/Grid.h
Normal file
78
src/Grid.h
Normal file
@@ -0,0 +1,78 @@
|
|||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Copyright 2007 - 2008, Paul Beckingham. All rights reserved.
|
||||||
|
//
|
||||||
|
//
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
#ifndef INCLUDED_GRID
|
||||||
|
#define INCLUDED_GRID
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
class Grid
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
class Cell
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Cell (const bool);
|
||||||
|
Cell (const char);
|
||||||
|
Cell (const int);
|
||||||
|
Cell (const float);
|
||||||
|
Cell (const double);
|
||||||
|
Cell (const std::string&);
|
||||||
|
|
||||||
|
operator bool () const;
|
||||||
|
operator char () const;
|
||||||
|
operator int () const;
|
||||||
|
operator float () const;
|
||||||
|
operator double () const;
|
||||||
|
operator std::string () const;
|
||||||
|
bool operator== (const Cell&) const;
|
||||||
|
bool operator!= (const Cell&) const;
|
||||||
|
|
||||||
|
enum cellType {CELL_BOOL, CELL_CHAR, CELL_INT, CELL_FLOAT, CELL_DOUBLE, CELL_STRING};
|
||||||
|
|
||||||
|
cellType type () const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
cellType mType;
|
||||||
|
bool mBool;
|
||||||
|
char mChar;
|
||||||
|
int mInt;
|
||||||
|
float mFloat;
|
||||||
|
double mDouble;
|
||||||
|
std::string mString;
|
||||||
|
};
|
||||||
|
|
||||||
|
public:
|
||||||
|
Grid ();
|
||||||
|
~Grid ();
|
||||||
|
|
||||||
|
void add (const unsigned int, const unsigned int, const bool);
|
||||||
|
void add (const unsigned int, const unsigned int, const char);
|
||||||
|
void add (const unsigned int, const unsigned int, const int);
|
||||||
|
void add (const unsigned int, const unsigned int, const float);
|
||||||
|
void add (const unsigned int, const unsigned int, const double);
|
||||||
|
void add (const unsigned int, const unsigned int, const char*);
|
||||||
|
void add (const unsigned int, const unsigned int, const std::string&);
|
||||||
|
|
||||||
|
unsigned int width () const;
|
||||||
|
unsigned int height () const;
|
||||||
|
|
||||||
|
Cell* byRow (const unsigned int, const unsigned int) const;
|
||||||
|
Cell* byColumn (const unsigned int, const unsigned int) const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
void expandGrid (const unsigned int, const unsigned int);
|
||||||
|
void insertCell (const unsigned int, const unsigned int, Cell*);
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::vector < std::vector <Cell*>* > mRows;
|
||||||
|
std::vector < std::vector <Cell*>* > mColumns;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
429
src/Makefile
429
src/Makefile
@@ -1,429 +0,0 @@
|
|||||||
# Makefile.in generated by automake 1.10 from Makefile.am.
|
|
||||||
# src/Makefile. Generated from Makefile.in by configure.
|
|
||||||
|
|
||||||
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
|
|
||||||
# 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
|
|
||||||
# This Makefile.in is free software; the Free Software Foundation
|
|
||||||
# gives unlimited permission to copy and/or distribute it,
|
|
||||||
# with or without modifications, as long as this notice is preserved.
|
|
||||||
|
|
||||||
# This program is distributed in the hope that it will be useful,
|
|
||||||
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
|
|
||||||
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
|
||||||
# PARTICULAR PURPOSE.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
pkgdatadir = $(datadir)/task
|
|
||||||
pkglibdir = $(libdir)/task
|
|
||||||
pkgincludedir = $(includedir)/task
|
|
||||||
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
|
|
||||||
install_sh_DATA = $(install_sh) -c -m 644
|
|
||||||
install_sh_PROGRAM = $(install_sh) -c
|
|
||||||
install_sh_SCRIPT = $(install_sh) -c
|
|
||||||
INSTALL_HEADER = $(INSTALL_DATA)
|
|
||||||
transform = $(program_transform_name)
|
|
||||||
NORMAL_INSTALL = :
|
|
||||||
PRE_INSTALL = :
|
|
||||||
POST_INSTALL = :
|
|
||||||
NORMAL_UNINSTALL = :
|
|
||||||
PRE_UNINSTALL = :
|
|
||||||
POST_UNINSTALL = :
|
|
||||||
bin_PROGRAMS = task$(EXEEXT)
|
|
||||||
subdir = src
|
|
||||||
DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
|
|
||||||
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
|
|
||||||
am__aclocal_m4_deps = $(top_srcdir)/configure.ac
|
|
||||||
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
|
|
||||||
$(ACLOCAL_M4)
|
|
||||||
mkinstalldirs = $(install_sh) -d
|
|
||||||
CONFIG_HEADER = $(top_builddir)/auto.h
|
|
||||||
CONFIG_CLEAN_FILES =
|
|
||||||
am__installdirs = "$(DESTDIR)$(bindir)"
|
|
||||||
binPROGRAMS_INSTALL = $(INSTALL_PROGRAM)
|
|
||||||
PROGRAMS = $(bin_PROGRAMS)
|
|
||||||
am_task_OBJECTS = Config.$(OBJEXT) Date.$(OBJEXT) T.$(OBJEXT) \
|
|
||||||
TDB.$(OBJEXT) Table.$(OBJEXT) color.$(OBJEXT) parse.$(OBJEXT) \
|
|
||||||
task.$(OBJEXT) util.$(OBJEXT) text.$(OBJEXT) rules.$(OBJEXT)
|
|
||||||
task_OBJECTS = $(am_task_OBJECTS)
|
|
||||||
task_LDADD = $(LDADD)
|
|
||||||
DEFAULT_INCLUDES = -I. -I$(top_builddir)
|
|
||||||
depcomp = $(SHELL) $(top_srcdir)/depcomp
|
|
||||||
am__depfiles_maybe = depfiles
|
|
||||||
CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
|
|
||||||
$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
|
|
||||||
CXXLD = $(CXX)
|
|
||||||
CXXLINK = $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) \
|
|
||||||
-o $@
|
|
||||||
COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
|
|
||||||
$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
|
|
||||||
CCLD = $(CC)
|
|
||||||
LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
|
|
||||||
SOURCES = $(task_SOURCES)
|
|
||||||
DIST_SOURCES = $(task_SOURCES)
|
|
||||||
ETAGS = etags
|
|
||||||
CTAGS = ctags
|
|
||||||
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
|
|
||||||
ACLOCAL = ${SHELL} /Users/paul/work/task_rel/missing --run aclocal-1.10
|
|
||||||
AMTAR = ${SHELL} /Users/paul/work/task_rel/missing --run tar
|
|
||||||
AUTOCONF = ${SHELL} /Users/paul/work/task_rel/missing --run autoconf
|
|
||||||
AUTOHEADER = ${SHELL} /Users/paul/work/task_rel/missing --run autoheader
|
|
||||||
AUTOMAKE = ${SHELL} /Users/paul/work/task_rel/missing --run automake-1.10
|
|
||||||
AWK = awk
|
|
||||||
CC = gcc
|
|
||||||
CCDEPMODE = depmode=gcc3
|
|
||||||
CFLAGS = -g -O2
|
|
||||||
CPPFLAGS =
|
|
||||||
CXX = g++
|
|
||||||
CXXCPP = g++ -E
|
|
||||||
CXXDEPMODE = depmode=gcc3
|
|
||||||
CXXFLAGS = -g -O2
|
|
||||||
CYGPATH_W = echo
|
|
||||||
DEFS = -DHAVE_CONFIG_H
|
|
||||||
DEPDIR = .deps
|
|
||||||
ECHO_C = \c
|
|
||||||
ECHO_N =
|
|
||||||
ECHO_T =
|
|
||||||
EGREP = /usr/bin/grep -E
|
|
||||||
EXEEXT =
|
|
||||||
GREP = /usr/bin/grep
|
|
||||||
INSTALL = /usr/bin/install -c
|
|
||||||
INSTALL_DATA = ${INSTALL} -m 644
|
|
||||||
INSTALL_PROGRAM = ${INSTALL}
|
|
||||||
INSTALL_SCRIPT = ${INSTALL}
|
|
||||||
INSTALL_STRIP_PROGRAM = $(install_sh) -c -s
|
|
||||||
LDFLAGS =
|
|
||||||
LIBOBJS = ${LIBOBJDIR}mktime$U.o
|
|
||||||
LIBS = -lncurses
|
|
||||||
LTLIBOBJS = ${LIBOBJDIR}mktime$U.lo
|
|
||||||
MAKEINFO = ${SHELL} /Users/paul/work/task_rel/missing --run makeinfo
|
|
||||||
MKDIR_P = .././install-sh -c -d
|
|
||||||
OBJEXT = o
|
|
||||||
PACKAGE = task
|
|
||||||
PACKAGE_BUGREPORT = bugs@beckingham.net
|
|
||||||
PACKAGE_NAME = task
|
|
||||||
PACKAGE_STRING = task 0.9.0
|
|
||||||
PACKAGE_TARNAME = task
|
|
||||||
PACKAGE_VERSION = 0.9.0
|
|
||||||
PATH_SEPARATOR = :
|
|
||||||
SET_MAKE =
|
|
||||||
SHELL = /bin/sh
|
|
||||||
STRIP =
|
|
||||||
VERSION = 0.9.0
|
|
||||||
abs_builddir = /Users/paul/work/task_rel/src
|
|
||||||
abs_srcdir = /Users/paul/work/task_rel/src
|
|
||||||
abs_top_builddir = /Users/paul/work/task_rel
|
|
||||||
abs_top_srcdir = /Users/paul/work/task_rel
|
|
||||||
ac_ct_CC = gcc
|
|
||||||
ac_ct_CXX = g++
|
|
||||||
am__include = include
|
|
||||||
am__leading_dot = .
|
|
||||||
am__quote =
|
|
||||||
am__tar = ${AMTAR} chof - "$$tardir"
|
|
||||||
am__untar = ${AMTAR} xf -
|
|
||||||
bindir = ${exec_prefix}/bin
|
|
||||||
build_alias =
|
|
||||||
builddir = .
|
|
||||||
datadir = ${datarootdir}
|
|
||||||
datarootdir = ${prefix}/share
|
|
||||||
docdir = ${datarootdir}/doc/${PACKAGE_TARNAME}
|
|
||||||
dvidir = ${docdir}
|
|
||||||
exec_prefix = ${prefix}
|
|
||||||
host_alias =
|
|
||||||
htmldir = ${docdir}
|
|
||||||
includedir = ${prefix}/include
|
|
||||||
infodir = ${datarootdir}/info
|
|
||||||
install_sh = $(SHELL) /Users/paul/work/task_rel/install-sh
|
|
||||||
libdir = ${exec_prefix}/lib
|
|
||||||
libexecdir = ${exec_prefix}/libexec
|
|
||||||
localedir = ${datarootdir}/locale
|
|
||||||
localstatedir = ${prefix}/var
|
|
||||||
mandir = ${datarootdir}/man
|
|
||||||
mkdir_p = $(top_builddir)/./install-sh -c -d
|
|
||||||
oldincludedir = /usr/include
|
|
||||||
pdfdir = ${docdir}
|
|
||||||
prefix = /usr/local
|
|
||||||
program_transform_name = s,x,x,
|
|
||||||
psdir = ${docdir}
|
|
||||||
sbindir = ${exec_prefix}/sbin
|
|
||||||
sharedstatedir = ${prefix}/com
|
|
||||||
srcdir = .
|
|
||||||
subdirs = src
|
|
||||||
sysconfdir = ${prefix}/etc
|
|
||||||
target_alias =
|
|
||||||
top_builddir = ..
|
|
||||||
top_srcdir = ..
|
|
||||||
task_SOURCES = Config.cpp Date.cpp T.cpp TDB.cpp Table.cpp color.cpp parse.cpp task.cpp util.cpp text.cpp rules.cpp Config.h Date.h T.h TDB.h Table.h color.h stlmacros.h task.h
|
|
||||||
all: all-am
|
|
||||||
|
|
||||||
.SUFFIXES:
|
|
||||||
.SUFFIXES: .cpp .o .obj
|
|
||||||
$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
|
|
||||||
@for dep in $?; do \
|
|
||||||
case '$(am__configure_deps)' in \
|
|
||||||
*$$dep*) \
|
|
||||||
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
|
|
||||||
&& exit 0; \
|
|
||||||
exit 1;; \
|
|
||||||
esac; \
|
|
||||||
done; \
|
|
||||||
echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/Makefile'; \
|
|
||||||
cd $(top_srcdir) && \
|
|
||||||
$(AUTOMAKE) --gnu src/Makefile
|
|
||||||
.PRECIOUS: Makefile
|
|
||||||
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
|
|
||||||
@case '$?' in \
|
|
||||||
*config.status*) \
|
|
||||||
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
|
|
||||||
*) \
|
|
||||||
echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
|
|
||||||
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
|
|
||||||
esac;
|
|
||||||
|
|
||||||
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
|
|
||||||
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
|
|
||||||
|
|
||||||
$(top_srcdir)/configure: $(am__configure_deps)
|
|
||||||
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
|
|
||||||
$(ACLOCAL_M4): $(am__aclocal_m4_deps)
|
|
||||||
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
|
|
||||||
install-binPROGRAMS: $(bin_PROGRAMS)
|
|
||||||
@$(NORMAL_INSTALL)
|
|
||||||
test -z "$(bindir)" || $(MKDIR_P) "$(DESTDIR)$(bindir)"
|
|
||||||
@list='$(bin_PROGRAMS)'; for p in $$list; do \
|
|
||||||
p1=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
|
|
||||||
if test -f $$p \
|
|
||||||
; then \
|
|
||||||
f=`echo "$$p1" | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \
|
|
||||||
echo " $(INSTALL_PROGRAM_ENV) $(binPROGRAMS_INSTALL) '$$p' '$(DESTDIR)$(bindir)/$$f'"; \
|
|
||||||
$(INSTALL_PROGRAM_ENV) $(binPROGRAMS_INSTALL) "$$p" "$(DESTDIR)$(bindir)/$$f" || exit 1; \
|
|
||||||
else :; fi; \
|
|
||||||
done
|
|
||||||
|
|
||||||
uninstall-binPROGRAMS:
|
|
||||||
@$(NORMAL_UNINSTALL)
|
|
||||||
@list='$(bin_PROGRAMS)'; for p in $$list; do \
|
|
||||||
f=`echo "$$p" | sed 's,^.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/'`; \
|
|
||||||
echo " rm -f '$(DESTDIR)$(bindir)/$$f'"; \
|
|
||||||
rm -f "$(DESTDIR)$(bindir)/$$f"; \
|
|
||||||
done
|
|
||||||
|
|
||||||
clean-binPROGRAMS:
|
|
||||||
-test -z "$(bin_PROGRAMS)" || rm -f $(bin_PROGRAMS)
|
|
||||||
task$(EXEEXT): $(task_OBJECTS) $(task_DEPENDENCIES)
|
|
||||||
@rm -f task$(EXEEXT)
|
|
||||||
$(CXXLINK) $(task_OBJECTS) $(task_LDADD) $(LIBS)
|
|
||||||
|
|
||||||
mostlyclean-compile:
|
|
||||||
-rm -f *.$(OBJEXT)
|
|
||||||
|
|
||||||
distclean-compile:
|
|
||||||
-rm -f *.tab.c
|
|
||||||
|
|
||||||
include ./$(DEPDIR)/Config.Po
|
|
||||||
include ./$(DEPDIR)/Date.Po
|
|
||||||
include ./$(DEPDIR)/T.Po
|
|
||||||
include ./$(DEPDIR)/TDB.Po
|
|
||||||
include ./$(DEPDIR)/Table.Po
|
|
||||||
include ./$(DEPDIR)/color.Po
|
|
||||||
include ./$(DEPDIR)/parse.Po
|
|
||||||
include ./$(DEPDIR)/rules.Po
|
|
||||||
include ./$(DEPDIR)/task.Po
|
|
||||||
include ./$(DEPDIR)/text.Po
|
|
||||||
include ./$(DEPDIR)/util.Po
|
|
||||||
|
|
||||||
.cpp.o:
|
|
||||||
$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
|
|
||||||
mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
|
|
||||||
# source='$<' object='$@' libtool=no \
|
|
||||||
# DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) \
|
|
||||||
# $(CXXCOMPILE) -c -o $@ $<
|
|
||||||
|
|
||||||
.cpp.obj:
|
|
||||||
$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
|
|
||||||
mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
|
|
||||||
# source='$<' object='$@' libtool=no \
|
|
||||||
# DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) \
|
|
||||||
# $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
|
|
||||||
|
|
||||||
ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
|
|
||||||
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
|
|
||||||
unique=`for i in $$list; do \
|
|
||||||
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
|
|
||||||
done | \
|
|
||||||
$(AWK) ' { files[$$0] = 1; } \
|
|
||||||
END { for (i in files) print i; }'`; \
|
|
||||||
mkid -fID $$unique
|
|
||||||
tags: TAGS
|
|
||||||
|
|
||||||
TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
|
|
||||||
$(TAGS_FILES) $(LISP)
|
|
||||||
tags=; \
|
|
||||||
here=`pwd`; \
|
|
||||||
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
|
|
||||||
unique=`for i in $$list; do \
|
|
||||||
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
|
|
||||||
done | \
|
|
||||||
$(AWK) ' { files[$$0] = 1; } \
|
|
||||||
END { for (i in files) print i; }'`; \
|
|
||||||
if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
|
|
||||||
test -n "$$unique" || unique=$$empty_fix; \
|
|
||||||
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
|
|
||||||
$$tags $$unique; \
|
|
||||||
fi
|
|
||||||
ctags: CTAGS
|
|
||||||
CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
|
|
||||||
$(TAGS_FILES) $(LISP)
|
|
||||||
tags=; \
|
|
||||||
here=`pwd`; \
|
|
||||||
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
|
|
||||||
unique=`for i in $$list; do \
|
|
||||||
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
|
|
||||||
done | \
|
|
||||||
$(AWK) ' { files[$$0] = 1; } \
|
|
||||||
END { for (i in files) print i; }'`; \
|
|
||||||
test -z "$(CTAGS_ARGS)$$tags$$unique" \
|
|
||||||
|| $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
|
|
||||||
$$tags $$unique
|
|
||||||
|
|
||||||
GTAGS:
|
|
||||||
here=`$(am__cd) $(top_builddir) && pwd` \
|
|
||||||
&& cd $(top_srcdir) \
|
|
||||||
&& gtags -i $(GTAGS_ARGS) $$here
|
|
||||||
|
|
||||||
distclean-tags:
|
|
||||||
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
|
|
||||||
|
|
||||||
distdir: $(DISTFILES)
|
|
||||||
@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
|
|
||||||
topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
|
|
||||||
list='$(DISTFILES)'; \
|
|
||||||
dist_files=`for file in $$list; do echo $$file; done | \
|
|
||||||
sed -e "s|^$$srcdirstrip/||;t" \
|
|
||||||
-e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
|
|
||||||
case $$dist_files in \
|
|
||||||
*/*) $(MKDIR_P) `echo "$$dist_files" | \
|
|
||||||
sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
|
|
||||||
sort -u` ;; \
|
|
||||||
esac; \
|
|
||||||
for file in $$dist_files; do \
|
|
||||||
if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
|
|
||||||
if test -d $$d/$$file; then \
|
|
||||||
dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
|
|
||||||
if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
|
|
||||||
cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
|
|
||||||
fi; \
|
|
||||||
cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
|
|
||||||
else \
|
|
||||||
test -f $(distdir)/$$file \
|
|
||||||
|| cp -p $$d/$$file $(distdir)/$$file \
|
|
||||||
|| exit 1; \
|
|
||||||
fi; \
|
|
||||||
done
|
|
||||||
check-am: all-am
|
|
||||||
check: check-am
|
|
||||||
all-am: Makefile $(PROGRAMS)
|
|
||||||
installdirs:
|
|
||||||
for dir in "$(DESTDIR)$(bindir)"; do \
|
|
||||||
test -z "$$dir" || $(MKDIR_P) "$$dir"; \
|
|
||||||
done
|
|
||||||
install: install-am
|
|
||||||
install-exec: install-exec-am
|
|
||||||
install-data: install-data-am
|
|
||||||
uninstall: uninstall-am
|
|
||||||
|
|
||||||
install-am: all-am
|
|
||||||
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
|
|
||||||
|
|
||||||
installcheck: installcheck-am
|
|
||||||
install-strip:
|
|
||||||
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
|
|
||||||
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
|
|
||||||
`test -z '$(STRIP)' || \
|
|
||||||
echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
|
|
||||||
mostlyclean-generic:
|
|
||||||
|
|
||||||
clean-generic:
|
|
||||||
|
|
||||||
distclean-generic:
|
|
||||||
-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
|
|
||||||
|
|
||||||
maintainer-clean-generic:
|
|
||||||
@echo "This command is intended for maintainers to use"
|
|
||||||
@echo "it deletes files that may require special tools to rebuild."
|
|
||||||
clean: clean-am
|
|
||||||
|
|
||||||
clean-am: clean-binPROGRAMS clean-generic mostlyclean-am
|
|
||||||
|
|
||||||
distclean: distclean-am
|
|
||||||
-rm -rf ./$(DEPDIR)
|
|
||||||
-rm -f Makefile
|
|
||||||
distclean-am: clean-am distclean-compile distclean-generic \
|
|
||||||
distclean-tags
|
|
||||||
|
|
||||||
dvi: dvi-am
|
|
||||||
|
|
||||||
dvi-am:
|
|
||||||
|
|
||||||
html: html-am
|
|
||||||
|
|
||||||
info: info-am
|
|
||||||
|
|
||||||
info-am:
|
|
||||||
|
|
||||||
install-data-am:
|
|
||||||
|
|
||||||
install-dvi: install-dvi-am
|
|
||||||
|
|
||||||
install-exec-am: install-binPROGRAMS
|
|
||||||
|
|
||||||
install-html: install-html-am
|
|
||||||
|
|
||||||
install-info: install-info-am
|
|
||||||
|
|
||||||
install-man:
|
|
||||||
|
|
||||||
install-pdf: install-pdf-am
|
|
||||||
|
|
||||||
install-ps: install-ps-am
|
|
||||||
|
|
||||||
installcheck-am:
|
|
||||||
|
|
||||||
maintainer-clean: maintainer-clean-am
|
|
||||||
-rm -rf ./$(DEPDIR)
|
|
||||||
-rm -f Makefile
|
|
||||||
maintainer-clean-am: distclean-am maintainer-clean-generic
|
|
||||||
|
|
||||||
mostlyclean: mostlyclean-am
|
|
||||||
|
|
||||||
mostlyclean-am: mostlyclean-compile mostlyclean-generic
|
|
||||||
|
|
||||||
pdf: pdf-am
|
|
||||||
|
|
||||||
pdf-am:
|
|
||||||
|
|
||||||
ps: ps-am
|
|
||||||
|
|
||||||
ps-am:
|
|
||||||
|
|
||||||
uninstall-am: uninstall-binPROGRAMS
|
|
||||||
|
|
||||||
.MAKE: install-am install-strip
|
|
||||||
|
|
||||||
.PHONY: CTAGS GTAGS all all-am check check-am clean clean-binPROGRAMS \
|
|
||||||
clean-generic ctags distclean distclean-compile \
|
|
||||||
distclean-generic distclean-tags distdir dvi dvi-am html \
|
|
||||||
html-am info info-am install install-am install-binPROGRAMS \
|
|
||||||
install-data install-data-am install-dvi install-dvi-am \
|
|
||||||
install-exec install-exec-am install-html install-html-am \
|
|
||||||
install-info install-info-am install-man install-pdf \
|
|
||||||
install-pdf-am install-ps install-ps-am install-strip \
|
|
||||||
installcheck installcheck-am installdirs maintainer-clean \
|
|
||||||
maintainer-clean-generic mostlyclean mostlyclean-compile \
|
|
||||||
mostlyclean-generic pdf pdf-am ps ps-am tags uninstall \
|
|
||||||
uninstall-am uninstall-binPROGRAMS
|
|
||||||
|
|
||||||
# Tell versions [3.59,3.63) of GNU make to not export all variables.
|
|
||||||
# Otherwise a system limit (for SysV at least) may be exceeded.
|
|
||||||
.NOEXPORT:
|
|
||||||
@@ -1,2 +1,2 @@
|
|||||||
bin_PROGRAMS = task
|
bin_PROGRAMS = task
|
||||||
task_SOURCES = Config.cpp Date.cpp T.cpp TDB.cpp Table.cpp color.cpp parse.cpp task.cpp util.cpp text.cpp rules.cpp Config.h Date.h T.h TDB.h Table.h color.h stlmacros.h task.h
|
task_SOURCES = Config.cpp Date.cpp T.cpp TDB.cpp Table.cpp Grid.cpp color.cpp parse.cpp task.cpp util.cpp text.cpp rules.cpp Config.h Date.h T.h TDB.h Table.h Grid.h color.h stlmacros.h task.h
|
||||||
|
|||||||
@@ -44,8 +44,9 @@ am__installdirs = "$(DESTDIR)$(bindir)"
|
|||||||
binPROGRAMS_INSTALL = $(INSTALL_PROGRAM)
|
binPROGRAMS_INSTALL = $(INSTALL_PROGRAM)
|
||||||
PROGRAMS = $(bin_PROGRAMS)
|
PROGRAMS = $(bin_PROGRAMS)
|
||||||
am_task_OBJECTS = Config.$(OBJEXT) Date.$(OBJEXT) T.$(OBJEXT) \
|
am_task_OBJECTS = Config.$(OBJEXT) Date.$(OBJEXT) T.$(OBJEXT) \
|
||||||
TDB.$(OBJEXT) Table.$(OBJEXT) color.$(OBJEXT) parse.$(OBJEXT) \
|
TDB.$(OBJEXT) Table.$(OBJEXT) Grid.$(OBJEXT) color.$(OBJEXT) \
|
||||||
task.$(OBJEXT) util.$(OBJEXT) text.$(OBJEXT) rules.$(OBJEXT)
|
parse.$(OBJEXT) task.$(OBJEXT) util.$(OBJEXT) text.$(OBJEXT) \
|
||||||
|
rules.$(OBJEXT)
|
||||||
task_OBJECTS = $(am_task_OBJECTS)
|
task_OBJECTS = $(am_task_OBJECTS)
|
||||||
task_LDADD = $(LDADD)
|
task_LDADD = $(LDADD)
|
||||||
DEFAULT_INCLUDES = -I. -I$(top_builddir)@am__isrc@
|
DEFAULT_INCLUDES = -I. -I$(top_builddir)@am__isrc@
|
||||||
@@ -149,12 +150,11 @@ psdir = @psdir@
|
|||||||
sbindir = @sbindir@
|
sbindir = @sbindir@
|
||||||
sharedstatedir = @sharedstatedir@
|
sharedstatedir = @sharedstatedir@
|
||||||
srcdir = @srcdir@
|
srcdir = @srcdir@
|
||||||
subdirs = @subdirs@
|
|
||||||
sysconfdir = @sysconfdir@
|
sysconfdir = @sysconfdir@
|
||||||
target_alias = @target_alias@
|
target_alias = @target_alias@
|
||||||
top_builddir = @top_builddir@
|
top_builddir = @top_builddir@
|
||||||
top_srcdir = @top_srcdir@
|
top_srcdir = @top_srcdir@
|
||||||
task_SOURCES = Config.cpp Date.cpp T.cpp TDB.cpp Table.cpp color.cpp parse.cpp task.cpp util.cpp text.cpp rules.cpp Config.h Date.h T.h TDB.h Table.h color.h stlmacros.h task.h
|
task_SOURCES = Config.cpp Date.cpp T.cpp TDB.cpp Table.cpp Grid.cpp color.cpp parse.cpp task.cpp util.cpp text.cpp rules.cpp Config.h Date.h T.h TDB.h Table.h Grid.h color.h stlmacros.h task.h
|
||||||
all: all-am
|
all: all-am
|
||||||
|
|
||||||
.SUFFIXES:
|
.SUFFIXES:
|
||||||
@@ -223,6 +223,7 @@ distclean-compile:
|
|||||||
|
|
||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Config.Po@am__quote@
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Config.Po@am__quote@
|
||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Date.Po@am__quote@
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Date.Po@am__quote@
|
||||||
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Grid.Po@am__quote@
|
||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/T.Po@am__quote@
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/T.Po@am__quote@
|
||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/TDB.Po@am__quote@
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/TDB.Po@am__quote@
|
||||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Table.Po@am__quote@
|
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Table.Po@am__quote@
|
||||||
|
|||||||
@@ -500,7 +500,7 @@ int T::determineVersion (const std::string& line)
|
|||||||
// a UUID followed by a status, then there is still a way to differentiate
|
// a UUID followed by a status, then there is still a way to differentiate
|
||||||
// between 2 and 3.
|
// between 2 and 3.
|
||||||
//
|
//
|
||||||
// The danger is that a version 2 binary reads and misinterprets a version 2
|
// The danger is that a version 2 binary reads and misinterprets a version 3
|
||||||
// file. This is why it is a good idea to rely on an explicit version
|
// file. This is why it is a good idea to rely on an explicit version
|
||||||
// declaration rather than chance positioning.
|
// declaration rather than chance positioning.
|
||||||
|
|
||||||
@@ -508,3 +508,4 @@ int T::determineVersion (const std::string& line)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|||||||
345
src/Table.cpp
345
src/Table.cpp
@@ -22,10 +22,10 @@
|
|||||||
//
|
//
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include "Table.h"
|
#include <Table.h>
|
||||||
#include "Date.h"
|
#include <Date.h>
|
||||||
#include "stlmacros.h"
|
#include <task.h>
|
||||||
#include "task.h"
|
#include <stlmacros.h>
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
Table::Table ()
|
Table::Table ()
|
||||||
@@ -45,20 +45,20 @@ Table::~Table ()
|
|||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
void Table::setTableColor (Text::color fg, Text::color bg)
|
void Table::setTableColor (Text::color fg, Text::color bg)
|
||||||
{
|
{
|
||||||
mFg["table"] = fg;
|
mFg["table"] = Text::colorName (fg);
|
||||||
mBg["table"] = bg;
|
mBg["table"] = Text::colorName (bg);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
void Table::setTableFg (Text::color c)
|
void Table::setTableFg (Text::color c)
|
||||||
{
|
{
|
||||||
mFg["table"] = c;
|
mFg["table"] = Text::colorName (c);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
void Table::setTableBg (Text::color c)
|
void Table::setTableBg (Text::color c)
|
||||||
{
|
{
|
||||||
mBg["table"] = c;
|
mBg["table"] = Text::colorName (c);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
@@ -97,8 +97,8 @@ void Table::setColumnColor (int column, Text::color fg, Text::color bg)
|
|||||||
{
|
{
|
||||||
char id[12];
|
char id[12];
|
||||||
sprintf (id, "col:%d", column);
|
sprintf (id, "col:%d", column);
|
||||||
mFg[id] = fg;
|
mFg[id] = Text::colorName (fg);
|
||||||
mBg[id] = bg;
|
mBg[id] = Text::colorName (bg);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
@@ -106,7 +106,7 @@ void Table::setColumnFg (int column, Text::color c)
|
|||||||
{
|
{
|
||||||
char id[12];
|
char id[12];
|
||||||
sprintf (id, "col:%d", column);
|
sprintf (id, "col:%d", column);
|
||||||
mFg[id] = c;
|
mFg[id] = Text::colorName (c);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
@@ -114,7 +114,7 @@ void Table::setColumnBg (int column, Text::color c)
|
|||||||
{
|
{
|
||||||
char id[12];
|
char id[12];
|
||||||
sprintf (id, "col:%d", column);
|
sprintf (id, "col:%d", column);
|
||||||
mBg[id] = c;
|
mBg[id] = Text::colorName (c);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
@@ -153,9 +153,7 @@ void Table::setColumnCommify (int column)
|
|||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
void Table::setColumnJustification (int column, just j)
|
void Table::setColumnJustification (int column, just j)
|
||||||
{
|
{
|
||||||
char id[12];
|
mJustification[column] = j;
|
||||||
sprintf (id, "col:%d", column);
|
|
||||||
mJustification[id] = j;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
@@ -172,36 +170,33 @@ int Table::addRow ()
|
|||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
void Table::setRowColor (int row, Text::color fg, Text::color bg)
|
void Table::setRowColor (const int row, const Text::color fg, const Text::color bg)
|
||||||
{
|
{
|
||||||
char id[12];
|
char id[12];
|
||||||
sprintf (id, "row:%d", row);
|
sprintf (id, "row:%d", row);
|
||||||
mFg[id] = fg;
|
mFg[id] = Text::colorName (fg);
|
||||||
mBg[id] = bg;
|
mBg[id] = Text::colorName (bg);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
void Table::setRowFg (int row, Text::color c)
|
void Table::setRowFg (const int row, const Text::color c)
|
||||||
{
|
{
|
||||||
char id[12];
|
char id[12];
|
||||||
sprintf (id, "row:%d", row);
|
sprintf (id, "row:%d", row);
|
||||||
mFg[id] = c;
|
mFg[id] = Text::colorName (c);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
void Table::setRowBg (int row, Text::color c)
|
void Table::setRowBg (const int row, const Text::color c)
|
||||||
{
|
{
|
||||||
char id[12];
|
char id[12];
|
||||||
sprintf (id, "row:%d", row);
|
sprintf (id, "row:%d", row);
|
||||||
mBg[id] = c;
|
mBg[id] = Text::colorName (c);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
void Table::addCell (int row, int col, const std::string& data)
|
void Table::addCell (const int row, const int col, const std::string& data)
|
||||||
{
|
{
|
||||||
char id[24];
|
|
||||||
sprintf (id, "cell:%d,%d", row, col);
|
|
||||||
|
|
||||||
int length = 0;
|
int length = 0;
|
||||||
|
|
||||||
if (mSuppressWS)
|
if (mSuppressWS)
|
||||||
@@ -214,14 +209,14 @@ void Table::addCell (int row, int col, const std::string& data)
|
|||||||
|
|
||||||
clean (data2);
|
clean (data2);
|
||||||
length = data2.length ();
|
length = data2.length ();
|
||||||
mData[id] = data2;
|
mData.add (row, col, data2);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (mCommify.find (col) != mCommify.end ())
|
if (mCommify.find (col) != mCommify.end ())
|
||||||
mData[id] = commify (data);
|
mData.add (row, col, commify (data));
|
||||||
else
|
else
|
||||||
mData[id] = data;
|
mData.add (row, col, data);
|
||||||
|
|
||||||
length = data.length ();
|
length = data.length ();
|
||||||
}
|
}
|
||||||
@@ -231,127 +226,114 @@ void Table::addCell (int row, int col, const std::string& data)
|
|||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
void Table::addCell (int row, int col, char data)
|
void Table::addCell (const int row, const int col, const char data)
|
||||||
{
|
{
|
||||||
char id[24];
|
mData.add (row, col, data);
|
||||||
sprintf (id, "cell:%d,%d", row, col);
|
|
||||||
|
|
||||||
char value[2];
|
|
||||||
sprintf (value, "%c", data);
|
|
||||||
|
|
||||||
mData[id] = value;
|
|
||||||
|
|
||||||
// Automatically maintain max width.
|
// Automatically maintain max width.
|
||||||
mMaxDataWidth[col] = max (mMaxDataWidth[col], (signed) ::strlen (value));
|
mMaxDataWidth[col] = max (mMaxDataWidth[col], 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
void Table::addCell (int row, int col, int data)
|
void Table::addCell (const int row, const int col, const int data)
|
||||||
{
|
{
|
||||||
char id[24];
|
|
||||||
sprintf (id, "cell:%d,%d", row, col);
|
|
||||||
|
|
||||||
char value[12];
|
char value[12];
|
||||||
sprintf (value, "%d", data);
|
sprintf (value, "%d", data);
|
||||||
|
|
||||||
if (mCommify.find (col) != mCommify.end ())
|
if (mCommify.find (col) != mCommify.end ())
|
||||||
mData[id] = commify (value);
|
mData.add (row, col, commify (value));
|
||||||
else
|
else
|
||||||
mData[id] = value;
|
mData.add (row, col, value);
|
||||||
|
|
||||||
// Automatically maintain max width.
|
// Automatically maintain max width.
|
||||||
mMaxDataWidth[col] = max (mMaxDataWidth[col], (signed) ::strlen (value));
|
mMaxDataWidth[col] = max (mMaxDataWidth[col], (signed) ::strlen (value));
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
void Table::addCell (int row, int col, float data)
|
void Table::addCell (const int row, const int col, const float data)
|
||||||
{
|
{
|
||||||
char id[24];
|
|
||||||
sprintf (id, "cell:%d,%d", row, col);
|
|
||||||
|
|
||||||
char value[24];
|
char value[24];
|
||||||
sprintf (value, "%.2f", data);
|
sprintf (value, "%.2f", data);
|
||||||
|
|
||||||
if (mCommify.find (col) != mCommify.end ())
|
if (mCommify.find (col) != mCommify.end ())
|
||||||
mData[id] = commify (value);
|
mData.add (row, col, commify (value));
|
||||||
else
|
else
|
||||||
mData[id] = value;
|
mData.add (row, col, value);
|
||||||
|
|
||||||
// Automatically maintain max width.
|
// Automatically maintain max width.
|
||||||
mMaxDataWidth[col] = max (mMaxDataWidth[col], (signed) ::strlen (value));
|
mMaxDataWidth[col] = max (mMaxDataWidth[col], (signed) ::strlen (value));
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
void Table::addCell (int row, int col, double data)
|
void Table::addCell (const int row, const int col, const double data)
|
||||||
{
|
{
|
||||||
char id[24];
|
|
||||||
sprintf (id, "cell:%d,%d", row, col);
|
|
||||||
|
|
||||||
char value[24];
|
char value[24];
|
||||||
sprintf (value, "%.6f", data);
|
sprintf (value, "%.6f", data);
|
||||||
|
|
||||||
if (mCommify.find (col) != mCommify.end ())
|
if (mCommify.find (col) != mCommify.end ())
|
||||||
mData[id] = commify (value);
|
mData.add (row, col, commify (value));
|
||||||
else
|
else
|
||||||
mData[id] = value;
|
mData.add (row, col, value);
|
||||||
|
|
||||||
// Automatically maintain max width.
|
// Automatically maintain max width.
|
||||||
mMaxDataWidth[col] = max (mMaxDataWidth[col], (signed) ::strlen (value));
|
mMaxDataWidth[col] = max (mMaxDataWidth[col], (signed) ::strlen (value));
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
void Table::setCellColor (int row, int col, Text::color fg, Text::color bg)
|
void Table::setCellColor (const int row, const int col, const Text::color fg, const Text::color bg)
|
||||||
{
|
{
|
||||||
char id[24];
|
char id[24];
|
||||||
sprintf (id, "cell:%d,%d", row, col);
|
sprintf (id, "cell:%d,%d", row, col);
|
||||||
mFg[id] = fg;
|
mFg[id] = Text::colorName (fg);
|
||||||
mBg[id] = bg;
|
mBg[id] = Text::colorName (bg);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
void Table::setCellFg (int row, int col, Text::color c)
|
void Table::setCellFg (const int row, const int col, const Text::color c)
|
||||||
{
|
{
|
||||||
char id[24];
|
char id[24];
|
||||||
sprintf (id, "cell:%d,%d", row, col);
|
sprintf (id, "cell:%d,%d", row, col);
|
||||||
mFg[id] = c;
|
mFg[id] = Text::colorName (c);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
void Table::setCellBg (int row, int col, Text::color c)
|
void Table::setCellBg (const int row, const int col, const Text::color c)
|
||||||
{
|
{
|
||||||
char id[24];
|
char id[24];
|
||||||
sprintf (id, "cell:%d,%d", row, col);
|
sprintf (id, "cell:%d,%d", row, col);
|
||||||
mBg[id] = c;
|
mBg[id] = Text::colorName (c);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
std::string Table::getCell (int row, int col)
|
std::string Table::getCell (const int row, const int col)
|
||||||
{
|
{
|
||||||
char id[24];
|
Grid::Cell* c = mData.byRow (row, col);
|
||||||
sprintf (id, "cell:%d,%d", row, col);
|
if (c)
|
||||||
return mData[id];
|
return (std::string) *c;
|
||||||
|
|
||||||
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
Text::color Table::getFg (int row, int col)
|
Text::color Table::getFg (const int row, const int col)
|
||||||
{
|
{
|
||||||
char idCell[24];
|
char idCell[24];
|
||||||
sprintf (idCell, "cell:%d,%d", row, col);
|
sprintf (idCell, "cell:%d,%d", row, col);
|
||||||
if (mFg.find (idCell) != mFg.end ())
|
if (mFg.find (idCell) != mFg.end ())
|
||||||
return mFg[idCell];
|
return Text::colorCode (mFg[idCell]);
|
||||||
|
|
||||||
char idRow[12];
|
char idRow[12];
|
||||||
sprintf (idRow, "row:%d", row);
|
sprintf (idRow, "row:%d", row);
|
||||||
if (mFg.find (idRow) != mFg.end ())
|
if (mFg.find (idRow) != mFg.end ())
|
||||||
return mFg[idRow];
|
return Text::colorCode (mFg[idRow]);
|
||||||
|
|
||||||
char idCol[12];
|
char idCol[12];
|
||||||
sprintf (idCol, "col:%d", col);
|
sprintf (idCol, "col:%d", col);
|
||||||
if (mFg.find (idCol) != mFg.end ())
|
if (mFg.find (idCol) != mFg.end ())
|
||||||
return mFg[idCol];
|
return Text::colorCode (mFg[idCol]);
|
||||||
|
|
||||||
if (mFg.find ("table") != mFg.end ())
|
if (mFg.find ("table") != mFg.end ())
|
||||||
return mFg["table"];
|
return Text::colorCode (mFg["table"]);
|
||||||
|
|
||||||
return Text::nocolor;
|
return Text::nocolor;
|
||||||
}
|
}
|
||||||
@@ -362,31 +344,31 @@ Text::color Table::getHeaderFg (int col)
|
|||||||
char idCol[12];
|
char idCol[12];
|
||||||
sprintf (idCol, "col:%d", col);
|
sprintf (idCol, "col:%d", col);
|
||||||
|
|
||||||
return mFg.find (idCol) != mFg.end () ? mFg[idCol]
|
return mFg.find (idCol) != mFg.end () ? Text::colorCode (mFg[idCol])
|
||||||
: mFg.find ("table") != mFg.end () ? mFg["table"]
|
: mFg.find ("table") != mFg.end () ? Text::colorCode (mFg["table"])
|
||||||
: Text::nocolor;
|
: Text::nocolor;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
Text::color Table::getBg (int row, int col)
|
Text::color Table::getBg (const int row, const int col)
|
||||||
{
|
{
|
||||||
char idCell[24];
|
char idCell[24];
|
||||||
sprintf (idCell, "cell:%d,%d", row, col);
|
sprintf (idCell, "cell:%d,%d", row, col);
|
||||||
if (mBg.find (idCell) != mBg.end ())
|
if (mBg.find (idCell) != mBg.end ())
|
||||||
return mBg[idCell];
|
return Text::colorCode (mBg[idCell]);
|
||||||
|
|
||||||
char idRow[12];
|
char idRow[12];
|
||||||
sprintf (idRow, "row:%d", row);
|
sprintf (idRow, "row:%d", row);
|
||||||
if (mBg.find (idRow) != mBg.end ())
|
if (mBg.find (idRow) != mBg.end ())
|
||||||
return mBg[idRow];
|
return Text::colorCode (mBg[idRow]);
|
||||||
|
|
||||||
char idCol[12];
|
char idCol[12];
|
||||||
sprintf (idCol, "col:%d", col);
|
sprintf (idCol, "col:%d", col);
|
||||||
if (mBg.find (idCol) != mBg.end ())
|
if (mBg.find (idCol) != mBg.end ())
|
||||||
return mBg[idCol];
|
return Text::colorCode (mBg[idCol]);
|
||||||
|
|
||||||
if (mBg.find ("table") != mBg.end ())
|
if (mBg.find ("table") != mBg.end ())
|
||||||
return mBg["table"];
|
return Text::colorCode (mBg["table"]);
|
||||||
|
|
||||||
return Text::nocolor;
|
return Text::nocolor;
|
||||||
}
|
}
|
||||||
@@ -397,19 +379,19 @@ Text::color Table::getHeaderBg (int col)
|
|||||||
char idCol[12];
|
char idCol[12];
|
||||||
sprintf (idCol, "col:%d", col);
|
sprintf (idCol, "col:%d", col);
|
||||||
|
|
||||||
return mBg.find (idCol) != mBg.end () ? mBg[idCol]
|
return mBg.find (idCol) != mBg.end () ? Text::colorCode (mBg[idCol])
|
||||||
: mBg.find ("table") != mBg.end () ? mBg["table"]
|
: mBg.find ("table") != mBg.end () ? Text::colorCode (mBg["table"])
|
||||||
: Text::nocolor;
|
: Text::nocolor;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
Text::attr Table::getHeaderUnderline (int col)
|
Text::color Table::getHeaderUnderline (int col)
|
||||||
{
|
{
|
||||||
char idCol[12];
|
char idCol[12];
|
||||||
sprintf (idCol, "col:%d", col);
|
sprintf (idCol, "col:%d", col);
|
||||||
|
|
||||||
return mUnderline.find (idCol) != mUnderline.end () ? Text::underline
|
return mUnderline.find (idCol) != mUnderline.end () ? Text::underline
|
||||||
: Text::normal;
|
: Text::nocolor;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
@@ -503,22 +485,10 @@ void Table::calculateColumnWidths ()
|
|||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
Table::just Table::getJustification (int row, int col)
|
Table::just Table::getJustification (const int row, const int col)
|
||||||
{
|
{
|
||||||
char idCell[24];
|
if (mJustification.find (col) != mJustification.end ())
|
||||||
sprintf (idCell, "cell:%d,%d", row, col);
|
return mJustification[col];
|
||||||
if (mJustification.find (idCell) != mJustification.end ())
|
|
||||||
return mJustification[idCell];
|
|
||||||
|
|
||||||
char idRow[12];
|
|
||||||
sprintf (idRow, "row:%d", row);
|
|
||||||
if (mJustification.find (idRow) != mJustification.end ())
|
|
||||||
return mJustification[idRow];
|
|
||||||
|
|
||||||
char idCol[12];
|
|
||||||
sprintf (idCol, "col:%d", col);
|
|
||||||
if (mJustification.find (idCol) != mJustification.end ())
|
|
||||||
return mJustification[idCol];
|
|
||||||
|
|
||||||
return left;
|
return left;
|
||||||
}
|
}
|
||||||
@@ -526,11 +496,7 @@ Table::just Table::getJustification (int row, int col)
|
|||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
Table::just Table::getHeaderJustification (int col)
|
Table::just Table::getHeaderJustification (int col)
|
||||||
{
|
{
|
||||||
char idCol[12];
|
return mJustification.find (col) != mJustification.end () ? mJustification[col]
|
||||||
sprintf (idCol, "col:%d", col);
|
|
||||||
|
|
||||||
return mJustification.find (idCol) != mJustification.end () ? mJustification[idCol]
|
|
||||||
: mJustification.find ("table") != mJustification.end () ? mJustification["table"]
|
|
||||||
: left;
|
: left;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -556,42 +522,17 @@ const std::string Table::formatHeader (
|
|||||||
{
|
{
|
||||||
assert (width > 0);
|
assert (width > 0);
|
||||||
|
|
||||||
Text::color fg = getHeaderFg (col);
|
Text::color fg = getHeaderFg (col);
|
||||||
Text::color bg = getHeaderBg (col);
|
Text::color bg = getHeaderBg (col);
|
||||||
std::string data = mColumns[col];
|
std::string data = mColumns[col];
|
||||||
Text::attr decoration = getHeaderUnderline (col);
|
Text::color decoration = getHeaderUnderline (col);
|
||||||
|
|
||||||
std::string colorOn = "";
|
|
||||||
std::string pad = "";
|
std::string pad = "";
|
||||||
std::string intraPad = "";
|
std::string intraPad = "";
|
||||||
std::string preJust = "";
|
std::string preJust = "";
|
||||||
std::string attrOn = "";
|
std::string attrOn = "";
|
||||||
std::string attrOff = "";
|
std::string attrOff = "";
|
||||||
std::string postJust = "";
|
std::string postJust = "";
|
||||||
std::string colorOff = "";
|
|
||||||
|
|
||||||
if (fg != Text::nocolor)
|
|
||||||
{
|
|
||||||
char c[12];
|
|
||||||
sprintf (c, "\033[%dm", fg + 29);
|
|
||||||
colorOn += c;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (bg != Text::nocolor)
|
|
||||||
{
|
|
||||||
char c[12];
|
|
||||||
sprintf (c, "\033[%dm", bg + 39);
|
|
||||||
colorOn += c;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (colorOn != "")
|
|
||||||
colorOff += "\033[0m";
|
|
||||||
|
|
||||||
if (decoration == Text::underline)
|
|
||||||
{
|
|
||||||
attrOn = "\033[4m";
|
|
||||||
attrOff = "\033[0m";
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int i = 0; i < padding; ++i)
|
for (int i = 0; i < padding; ++i)
|
||||||
pad += " ";
|
pad += " ";
|
||||||
@@ -606,24 +547,19 @@ const std::string Table::formatHeader (
|
|||||||
for (int i = 0; i < getIntraPadding (); ++i)
|
for (int i = 0; i < getIntraPadding (); ++i)
|
||||||
intraPad += " ";
|
intraPad += " ";
|
||||||
|
|
||||||
return colorOn +
|
return Text::colorize (
|
||||||
attrOn +
|
fg, bg,
|
||||||
pad +
|
Text::colorize (
|
||||||
preJust +
|
decoration, Text::nocolor,
|
||||||
data +
|
pad + preJust+ data + postJust + pad) + intraPad);
|
||||||
postJust +
|
|
||||||
pad +
|
|
||||||
attrOff +
|
|
||||||
intraPad +
|
|
||||||
colorOff;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
void Table::formatCell (
|
void Table::formatCell (
|
||||||
int row,
|
const int row,
|
||||||
int col,
|
const int col,
|
||||||
int width,
|
const int width,
|
||||||
int padding,
|
const int padding,
|
||||||
std::vector <std::string>& lines,
|
std::vector <std::string>& lines,
|
||||||
std::string& blank)
|
std::string& blank)
|
||||||
{
|
{
|
||||||
@@ -634,27 +570,8 @@ void Table::formatCell (
|
|||||||
just justification = getJustification (row, col);
|
just justification = getJustification (row, col);
|
||||||
std::string data = getCell (row, col);
|
std::string data = getCell (row, col);
|
||||||
|
|
||||||
std::string colorOn = "";
|
|
||||||
std::string pad = "";
|
std::string pad = "";
|
||||||
std::string intraPad = "";
|
std::string intraPad = "";
|
||||||
std::string colorOff = "";
|
|
||||||
|
|
||||||
if (fg != Text::nocolor)
|
|
||||||
{
|
|
||||||
char c[12];
|
|
||||||
sprintf (c, "\033[%dm", fg + 29);
|
|
||||||
colorOn += c;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (bg != Text::nocolor)
|
|
||||||
{
|
|
||||||
char c[12];
|
|
||||||
sprintf (c, "\033[%dm", bg + 39);
|
|
||||||
colorOn += c;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (fg != Text::nocolor || bg != Text::nocolor)
|
|
||||||
colorOff += "\033[0m";
|
|
||||||
|
|
||||||
for (int i = 0; i < padding; ++i)
|
for (int i = 0; i < padding; ++i)
|
||||||
pad += " ";
|
pad += " ";
|
||||||
@@ -694,14 +611,7 @@ void Table::formatCell (
|
|||||||
}
|
}
|
||||||
|
|
||||||
lines.push_back (
|
lines.push_back (
|
||||||
colorOn +
|
Text::colorize (fg, bg, pad + preJust + chunks[chunk] + postJust + pad + intraPad));
|
||||||
pad +
|
|
||||||
preJust +
|
|
||||||
chunks[chunk] +
|
|
||||||
postJust +
|
|
||||||
pad +
|
|
||||||
intraPad +
|
|
||||||
colorOff);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// The blank is used to vertically pad cells that have blank lines.
|
// The blank is used to vertically pad cells that have blank lines.
|
||||||
@@ -709,19 +619,15 @@ void Table::formatCell (
|
|||||||
for (int i = 0; i < width; ++i)
|
for (int i = 0; i < width; ++i)
|
||||||
pad += " ";
|
pad += " ";
|
||||||
|
|
||||||
blank =
|
blank = Text::colorize (fg, bg, pad + intraPad);
|
||||||
colorOn +
|
|
||||||
pad +
|
|
||||||
intraPad +
|
|
||||||
colorOff;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
const std::string Table::formatCell (
|
const std::string Table::formatCell (
|
||||||
int row,
|
const int row,
|
||||||
int col,
|
const int col,
|
||||||
int width,
|
const int width,
|
||||||
int padding)
|
const int padding)
|
||||||
{
|
{
|
||||||
assert (width > 0);
|
assert (width > 0);
|
||||||
|
|
||||||
@@ -730,29 +636,10 @@ const std::string Table::formatCell (
|
|||||||
just justification = getJustification (row, col);
|
just justification = getJustification (row, col);
|
||||||
std::string data = getCell (row, col);
|
std::string data = getCell (row, col);
|
||||||
|
|
||||||
std::string colorOn = "";
|
|
||||||
std::string pad = "";
|
std::string pad = "";
|
||||||
std::string intraPad = "";
|
std::string intraPad = "";
|
||||||
std::string preJust = "";
|
std::string preJust = "";
|
||||||
std::string postJust = "";
|
std::string postJust = "";
|
||||||
std::string colorOff = "";
|
|
||||||
|
|
||||||
if (fg != Text::nocolor)
|
|
||||||
{
|
|
||||||
char c[12];
|
|
||||||
sprintf (c, "\033[%dm", fg + 29);
|
|
||||||
colorOn += c;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (bg != Text::nocolor)
|
|
||||||
{
|
|
||||||
char c[12];
|
|
||||||
sprintf (c, "\033[%dm", bg + 39);
|
|
||||||
colorOn += c;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (fg != Text::nocolor || bg != Text::nocolor)
|
|
||||||
colorOff += "\033[0m";
|
|
||||||
|
|
||||||
for (int i = 0; i < padding; ++i)
|
for (int i = 0; i < padding; ++i)
|
||||||
pad += " ";
|
pad += " ";
|
||||||
@@ -783,14 +670,7 @@ const std::string Table::formatCell (
|
|||||||
for (int i = 0; i < getIntraPadding (); ++i)
|
for (int i = 0; i < getIntraPadding (); ++i)
|
||||||
intraPad += " ";
|
intraPad += " ";
|
||||||
|
|
||||||
return colorOn +
|
return Text::colorize (fg, bg, pad + preJust + data + postJust + pad + intraPad);
|
||||||
pad +
|
|
||||||
preJust +
|
|
||||||
data +
|
|
||||||
postJust +
|
|
||||||
pad +
|
|
||||||
intraPad +
|
|
||||||
colorOff;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
@@ -873,48 +753,47 @@ void Table::sort (std::vector <int>& order)
|
|||||||
{
|
{
|
||||||
keepScanning = false;
|
keepScanning = false;
|
||||||
|
|
||||||
char left[16];
|
Grid::Cell* left = mData.byRow (order[r], mSortColumns[c]);
|
||||||
sprintf (left, "cell:%d,%d", order[r], mSortColumns[c]);
|
Grid::Cell* right = mData.byRow (order[r + gap], mSortColumns[c]);
|
||||||
|
if (left == NULL && right != NULL)
|
||||||
|
SWAP
|
||||||
|
|
||||||
char right[16];
|
if (left && right && *left != *right)
|
||||||
sprintf (right, "cell:%d,%d", order[r + gap], mSortColumns[c]);
|
|
||||||
|
|
||||||
if (mData[left] != mData[right])
|
|
||||||
{
|
{
|
||||||
switch (mSortOrder[mSortColumns[c]])
|
switch (mSortOrder[mSortColumns[c]])
|
||||||
{
|
{
|
||||||
case ascendingNumeric:
|
case ascendingNumeric:
|
||||||
if (::atoi (mData[left].c_str ()) > ::atoi (mData[right].c_str ()))
|
if ((float)*left > (float)*right)
|
||||||
SWAP
|
SWAP
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case descendingNumeric:
|
case descendingNumeric:
|
||||||
if (::atoi (mData[left].c_str ()) < ::atoi (mData[right].c_str ()))
|
if ((float)*left < (float)*right)
|
||||||
SWAP
|
SWAP
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ascendingCharacter:
|
case ascendingCharacter:
|
||||||
if (mData[left] > mData[right])
|
if ((char)*left > (char)*right)
|
||||||
SWAP
|
SWAP
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case descendingCharacter:
|
case descendingCharacter:
|
||||||
if (mData[left] < mData[right])
|
if ((char)*left < (char)*right)
|
||||||
SWAP
|
SWAP
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ascendingDate:
|
case ascendingDate:
|
||||||
{
|
{
|
||||||
if (mData[left] != "" && mData[right] == "")
|
if ((std::string)*left != "" && (std::string)*right == "")
|
||||||
break;
|
break;
|
||||||
|
|
||||||
else if (mData[left] == "" && mData[right] != "")
|
else if ((std::string)*left == "" && (std::string)*right != "")
|
||||||
SWAP
|
SWAP
|
||||||
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Date dl (mData[left]);
|
Date dl ((std::string)*left);
|
||||||
Date dr (mData[right]);
|
Date dr ((std::string)*right);
|
||||||
if (dl > dr)
|
if (dl > dr)
|
||||||
SWAP
|
SWAP
|
||||||
}
|
}
|
||||||
@@ -923,16 +802,16 @@ void Table::sort (std::vector <int>& order)
|
|||||||
|
|
||||||
case descendingDate:
|
case descendingDate:
|
||||||
{
|
{
|
||||||
if (mData[left] != "" && mData[right] == "")
|
if ((std::string)*left != "" && (std::string)*right == "")
|
||||||
break;
|
break;
|
||||||
|
|
||||||
else if (mData[left] == "" && mData[right] != "")
|
else if ((std::string)*left == "" && (std::string)*right != "")
|
||||||
SWAP
|
SWAP
|
||||||
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Date dl (mData[left]);
|
Date dl ((std::string)*left);
|
||||||
Date dr (mData[right]);
|
Date dr ((std::string)*right);
|
||||||
if (dl < dr)
|
if (dl < dr)
|
||||||
SWAP
|
SWAP
|
||||||
}
|
}
|
||||||
@@ -940,16 +819,16 @@ void Table::sort (std::vector <int>& order)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case ascendingPriority:
|
case ascendingPriority:
|
||||||
if ((mData[left] == "" && mData[right] != "") ||
|
if (((std::string)*left == "" && (std::string)*right != "") ||
|
||||||
(mData[left] == "M" && mData[right] == "L") ||
|
((std::string)*left == "M" && (std::string)*right == "L") ||
|
||||||
(mData[left] == "H" && (mData[right] == "L" || mData[right] == "M")))
|
((std::string)*left == "H" && ((std::string)*right == "L" || (std::string)*right == "M")))
|
||||||
SWAP
|
SWAP
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case descendingPriority:
|
case descendingPriority:
|
||||||
if ((mData[left] == "" && mData[right] != "") ||
|
if (((std::string)*left == "" && (std::string)*right != "") ||
|
||||||
(mData[left] == "L" && (mData[right] == "M" || mData[right] == "H")) ||
|
((std::string)*left == "L" && ((std::string)*right == "M" || (std::string)*right == "H")) ||
|
||||||
(mData[left] == "M" && mData[right] == "H"))
|
((std::string)*left == "M" && (std::string)*right == "H"))
|
||||||
SWAP
|
SWAP
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
37
src/Table.h
37
src/Table.h
@@ -10,7 +10,8 @@
|
|||||||
#include <map>
|
#include <map>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include "color.h"
|
#include <color.h>
|
||||||
|
#include <Grid.h>
|
||||||
|
|
||||||
class Table
|
class Table
|
||||||
{
|
{
|
||||||
@@ -64,20 +65,20 @@ public:
|
|||||||
const std::string render ();
|
const std::string render ();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::string getCell (int, int);
|
std::string getCell (const int, const int);
|
||||||
Text::color getFg (int, int);
|
Text::color getFg (const int, const int);
|
||||||
Text::color getHeaderFg (int);
|
Text::color getHeaderFg (const int);
|
||||||
Text::color getBg (int, int);
|
Text::color getBg (const int, const int);
|
||||||
Text::color getHeaderBg (int);
|
Text::color getHeaderBg (const int);
|
||||||
Text::attr getHeaderUnderline (int);
|
Text::color getHeaderUnderline (const int);
|
||||||
int getPadding (int);
|
int getPadding (const int);
|
||||||
int getIntraPadding ();
|
int getIntraPadding ();
|
||||||
void calculateColumnWidths ();
|
void calculateColumnWidths ();
|
||||||
just getJustification (int, int);
|
just getJustification (const int, const int);
|
||||||
just getHeaderJustification (int);
|
just getHeaderJustification (const int);
|
||||||
const std::string formatHeader (int, int, int);
|
const std::string formatHeader (const int, const int, const int);
|
||||||
const std::string formatCell (int, int, int, int);
|
const std::string formatCell (const int, const int, const int, const int);
|
||||||
void formatCell (int, int, int, int, std::vector <std::string>&, std::string&);
|
void formatCell (const int, const int, const int, const int, std::vector <std::string>&, std::string&);
|
||||||
void optimize (std::string&);
|
void optimize (std::string&);
|
||||||
void sort (std::vector <int>&);
|
void sort (std::vector <int>&);
|
||||||
void clean (std::string&);
|
void clean (std::string&);
|
||||||
@@ -86,9 +87,9 @@ private:
|
|||||||
std::vector <std::string> mColumns;
|
std::vector <std::string> mColumns;
|
||||||
int mRows;
|
int mRows;
|
||||||
int mIntraPadding;
|
int mIntraPadding;
|
||||||
std::map <std::string, Text::color> mFg;
|
std::map <std::string, std::string> mFg;
|
||||||
std::map <std::string, Text::color> mBg;
|
std::map <std::string, std::string> mBg;
|
||||||
std::map <std::string, Text::attr> mUnderline;
|
std::map <std::string, std::string> mUnderline;
|
||||||
|
|
||||||
// Padding...
|
// Padding...
|
||||||
int mTablePadding;
|
int mTablePadding;
|
||||||
@@ -100,9 +101,9 @@ private:
|
|||||||
std::vector <int> mMaxDataWidth;
|
std::vector <int> mMaxDataWidth;
|
||||||
std::vector <int> mCalculatedWidth;
|
std::vector <int> mCalculatedWidth;
|
||||||
|
|
||||||
std::map <std::string, just> mJustification;
|
std::map <int, just> mJustification;
|
||||||
std::map <int, bool> mCommify;
|
std::map <int, bool> mCommify;
|
||||||
std::map <std::string, std::string> mData;
|
Grid mData;
|
||||||
std::vector <int> mSortColumns;
|
std::vector <int> mSortColumns;
|
||||||
std::map <int, order> mSortOrder;
|
std::map <int, order> mSortOrder;
|
||||||
|
|
||||||
|
|||||||
230
src/color.cpp
230
src/color.cpp
@@ -7,58 +7,234 @@
|
|||||||
#include "color.h"
|
#include "color.h"
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
std::string Text::colorName (Text::color c)
|
namespace Text
|
||||||
|
{
|
||||||
|
|
||||||
|
std::string colorName (color c)
|
||||||
{
|
{
|
||||||
switch (c)
|
switch (c)
|
||||||
{
|
{
|
||||||
case black: return "black";
|
case nocolor: return "";
|
||||||
case red: return "red";
|
case off: return "off";
|
||||||
case green: return "green";
|
|
||||||
case yellow: return "yellow";
|
case bold: return "bold";
|
||||||
case blue: return "blue";
|
case underline: return "underline";
|
||||||
case magenta: return "magenta";
|
case bold_underline: return "bold_underline";
|
||||||
case cyan: return "cyan";
|
|
||||||
case white: return "white";
|
case black: return "black";
|
||||||
case nocolor: return "";
|
case red: return "red";
|
||||||
|
case green: return "green";
|
||||||
|
case yellow: return "yellow";
|
||||||
|
case blue: return "blue";
|
||||||
|
case magenta: return "magenta";
|
||||||
|
case cyan: return "cyan";
|
||||||
|
case white: return "white";
|
||||||
|
|
||||||
|
case bold_black: return "bold_black";
|
||||||
|
case bold_red: return "bold_red";
|
||||||
|
case bold_green: return "bold_green";
|
||||||
|
case bold_yellow: return "bold_yellow";
|
||||||
|
case bold_blue: return "bold_blue";
|
||||||
|
case bold_magenta: return "bold_magenta";
|
||||||
|
case bold_cyan: return "bold_cyan";
|
||||||
|
case bold_white: return "bold_white";
|
||||||
|
|
||||||
|
case underline_black: return "underline_black";
|
||||||
|
case underline_red: return "underline_red";
|
||||||
|
case underline_green: return "underline_green";
|
||||||
|
case underline_yellow: return "underline_yellow";
|
||||||
|
case underline_blue: return "underline_blue";
|
||||||
|
case underline_magenta: return "underline_magenta";
|
||||||
|
case underline_cyan: return "underline_cyan";
|
||||||
|
case underline_white: return "underline_white";
|
||||||
|
|
||||||
|
case bold_underline_black: return "bold_underline_black";
|
||||||
|
case bold_underline_red: return "bold_underline_red";
|
||||||
|
case bold_underline_green: return "bold_underline_green";
|
||||||
|
case bold_underline_yellow: return "bold_underline_yellow";
|
||||||
|
case bold_underline_blue: return "bold_underline_blue";
|
||||||
|
case bold_underline_magenta: return "bold_underline_magenta";
|
||||||
|
case bold_underline_cyan: return "bold_underline_cyan";
|
||||||
|
case bold_underline_white: return "bold_underline_white";
|
||||||
|
|
||||||
|
case on_black: return "on_black";
|
||||||
|
case on_red: return "on_red";
|
||||||
|
case on_green: return "on_green";
|
||||||
|
case on_yellow: return "on_yellow";
|
||||||
|
case on_blue: return "on_blue";
|
||||||
|
case on_magenta: return "on_magenta";
|
||||||
|
case on_cyan: return "on_cyan";
|
||||||
|
case on_white: return "on_white";
|
||||||
|
|
||||||
|
case on_bright_black: return "on_bright_black";
|
||||||
|
case on_bright_red: return "on_bright_red";
|
||||||
|
case on_bright_green: return "on_bright_green";
|
||||||
|
case on_bright_yellow: return "on_bright_yellow";
|
||||||
|
case on_bright_blue: return "on_bright_blue";
|
||||||
|
case on_bright_magenta: return "on_bright_magenta";
|
||||||
|
case on_bright_cyan: return "on_bright_cyan";
|
||||||
|
case on_bright_white: return "on_bright_white";
|
||||||
|
|
||||||
|
default: throw "Unknown Text::color value";
|
||||||
}
|
}
|
||||||
|
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
Text::color Text::colorCode (const std::string& c)
|
color colorCode (const std::string& c)
|
||||||
{
|
{
|
||||||
if (c == "black") return black;
|
if (c == "off") return off;
|
||||||
if (c == "red") return red;
|
else if (c == "bold") return bold;
|
||||||
if (c == "green") return green;
|
else if (c == "underline") return underline;
|
||||||
if (c == "yellow") return yellow;
|
else if (c == "bold_underline") return bold_underline;
|
||||||
if (c == "blue") return blue;
|
|
||||||
if (c == "magenta") return magenta;
|
else if (c == "black") return black;
|
||||||
if (c == "cyan") return cyan;
|
else if (c == "red") return red;
|
||||||
if (c == "white") return white;
|
else if (c == "green") return green;
|
||||||
|
else if (c == "yellow") return yellow;
|
||||||
|
else if (c == "blue") return blue;
|
||||||
|
else if (c == "magenta") return magenta;
|
||||||
|
else if (c == "cyan") return cyan;
|
||||||
|
else if (c == "white") return white;
|
||||||
|
|
||||||
|
else if (c == "bold_black") return bold_black;
|
||||||
|
else if (c == "bold_red") return bold_red;
|
||||||
|
else if (c == "bold_green") return bold_green;
|
||||||
|
else if (c == "bold_yellow") return bold_yellow;
|
||||||
|
else if (c == "bold_blue") return bold_blue;
|
||||||
|
else if (c == "bold_magenta") return bold_magenta;
|
||||||
|
else if (c == "bold_cyan") return bold_cyan;
|
||||||
|
else if (c == "bold_white") return bold_white;
|
||||||
|
|
||||||
|
else if (c == "underline_black") return underline_black;
|
||||||
|
else if (c == "underline_red") return underline_red;
|
||||||
|
else if (c == "underline_green") return underline_green;
|
||||||
|
else if (c == "underline_yellow") return underline_yellow;
|
||||||
|
else if (c == "underline_blue") return underline_blue;
|
||||||
|
else if (c == "underline_magenta") return underline_magenta;
|
||||||
|
else if (c == "underline_cyan") return underline_cyan;
|
||||||
|
else if (c == "underline_white") return underline_white;
|
||||||
|
|
||||||
|
else if (c == "bold_underline_black") return bold_underline_black;
|
||||||
|
else if (c == "bold_underline_red") return bold_underline_red;
|
||||||
|
else if (c == "bold_underline_green") return bold_underline_green;
|
||||||
|
else if (c == "bold_underline_yellow") return bold_underline_yellow;
|
||||||
|
else if (c == "bold_underline_blue") return bold_underline_blue;
|
||||||
|
else if (c == "bold_underline_magenta") return bold_underline_magenta;
|
||||||
|
else if (c == "bold_underline_cyan") return bold_underline_cyan;
|
||||||
|
else if (c == "bold_underline_white") return bold_underline_white;
|
||||||
|
|
||||||
|
else if (c == "on_black") return on_black;
|
||||||
|
else if (c == "on_red") return on_red;
|
||||||
|
else if (c == "on_green") return on_green;
|
||||||
|
else if (c == "on_yellow") return on_yellow;
|
||||||
|
else if (c == "on_blue") return on_blue;
|
||||||
|
else if (c == "on_magenta") return on_magenta;
|
||||||
|
else if (c == "on_cyan") return on_cyan;
|
||||||
|
else if (c == "on_white") return on_white;
|
||||||
|
|
||||||
|
else if (c == "on_bright_black") return on_bright_black;
|
||||||
|
else if (c == "on_bright_red") return on_bright_red;
|
||||||
|
else if (c == "on_bright_green") return on_bright_green;
|
||||||
|
else if (c == "on_bright_yellow") return on_bright_yellow;
|
||||||
|
else if (c == "on_bright_blue") return on_bright_blue;
|
||||||
|
else if (c == "on_bright_magenta") return on_bright_magenta;
|
||||||
|
else if (c == "on_bright_cyan") return on_bright_cyan;
|
||||||
|
else if (c == "on_bright_white") return on_bright_white;
|
||||||
|
|
||||||
return nocolor;
|
return nocolor;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
std::string Text::attrName (Text::attr a)
|
std::string decode (color c)
|
||||||
{
|
{
|
||||||
switch (a)
|
switch (c)
|
||||||
{
|
{
|
||||||
case underline: return "underline";
|
case nocolor: return "";
|
||||||
case normal: return "";
|
case off: return "\033[0m";
|
||||||
|
|
||||||
|
case bold: return "\033[1m";
|
||||||
|
case underline: return "\033[4m";
|
||||||
|
case bold_underline: return "\033[1;4m";
|
||||||
|
|
||||||
|
case black: return "\033[30m";
|
||||||
|
case red: return "\033[31m";
|
||||||
|
case green: return "\033[32m";
|
||||||
|
case yellow: return "\033[33m";
|
||||||
|
case blue: return "\033[34m";
|
||||||
|
case magenta: return "\033[35m";
|
||||||
|
case cyan: return "\033[36m";
|
||||||
|
case white: return "\033[37m";
|
||||||
|
|
||||||
|
case bold_black: return "\033[90m";
|
||||||
|
case bold_red: return "\033[91m";
|
||||||
|
case bold_green: return "\033[92m";
|
||||||
|
case bold_yellow: return "\033[93m";
|
||||||
|
case bold_blue: return "\033[94m";
|
||||||
|
case bold_magenta: return "\033[95m";
|
||||||
|
case bold_cyan: return "\033[96m";
|
||||||
|
case bold_white: return "\033[97m";
|
||||||
|
|
||||||
|
case underline_black: return "\033[4;30m";
|
||||||
|
case underline_red: return "\033[4;31m";
|
||||||
|
case underline_green: return "\033[4;32m";
|
||||||
|
case underline_yellow: return "\033[4;33m";
|
||||||
|
case underline_blue: return "\033[4;34m";
|
||||||
|
case underline_magenta: return "\033[4;35m";
|
||||||
|
case underline_cyan: return "\033[4;36m";
|
||||||
|
case underline_white: return "\033[4;37m";
|
||||||
|
|
||||||
|
case bold_underline_black: return "\033[1;4;30m";
|
||||||
|
case bold_underline_red: return "\033[1;4;31m";
|
||||||
|
case bold_underline_green: return "\033[1;4;32m";
|
||||||
|
case bold_underline_yellow: return "\033[1;4;33m";
|
||||||
|
case bold_underline_blue: return "\033[1;4;34m";
|
||||||
|
case bold_underline_magenta: return "\033[1;4;35m";
|
||||||
|
case bold_underline_cyan: return "\033[1;4;36m";
|
||||||
|
case bold_underline_white: return "\033[1;4;37m";
|
||||||
|
|
||||||
|
case on_black: return "\033[40m";
|
||||||
|
case on_red: return "\033[41m";
|
||||||
|
case on_green: return "\033[42m";
|
||||||
|
case on_yellow: return "\033[43m";
|
||||||
|
case on_blue: return "\033[44m";
|
||||||
|
case on_magenta: return "\033[45m";
|
||||||
|
case on_cyan: return "\033[46m";
|
||||||
|
case on_white: return "\033[47m";
|
||||||
|
|
||||||
|
case on_bright_black: return "\033[100m";
|
||||||
|
case on_bright_red: return "\033[101m";
|
||||||
|
case on_bright_green: return "\033[102m";
|
||||||
|
case on_bright_yellow: return "\033[103m";
|
||||||
|
case on_bright_blue: return "\033[104m";
|
||||||
|
case on_bright_magenta: return "\033[105m";
|
||||||
|
case on_bright_cyan: return "\033[106m";
|
||||||
|
case on_bright_white: return "\033[107m";
|
||||||
|
|
||||||
|
default: throw "Unknown Text::color value";
|
||||||
}
|
}
|
||||||
|
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
Text::attr Text::attrCode (const std::string& a)
|
std::string colorize (color fg, color bg, const std::string& input)
|
||||||
{
|
{
|
||||||
if (a == "underline") return underline;
|
return decode (fg) + decode (bg) + input + decode (off);
|
||||||
|
|
||||||
return normal;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
std::string colorize (color fg, color bg)
|
||||||
|
{
|
||||||
|
return decode (fg) + decode (bg);
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
std::string colorize ()
|
||||||
|
{
|
||||||
|
return decode (off);
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
}
|
||||||
|
|||||||
25
src/color.h
25
src/color.h
@@ -8,14 +8,27 @@
|
|||||||
|
|
||||||
namespace Text
|
namespace Text
|
||||||
{
|
{
|
||||||
enum color {nocolor = 0, black, red, green, yellow, blue, magenta, cyan, white};
|
enum color
|
||||||
enum attr {normal = 0, underline};
|
{
|
||||||
|
nocolor = 0,
|
||||||
|
off,
|
||||||
|
bold, underline, bold_underline,
|
||||||
|
black, bold_black, underline_black, bold_underline_black, on_black, on_bright_black,
|
||||||
|
red, bold_red, underline_red, bold_underline_red, on_red, on_bright_red,
|
||||||
|
green, bold_green, underline_green, bold_underline_green, on_green, on_bright_green,
|
||||||
|
yellow, bold_yellow, underline_yellow, bold_underline_yellow, on_yellow, on_bright_yellow,
|
||||||
|
blue, bold_blue, underline_blue, bold_underline_blue, on_blue, on_bright_blue,
|
||||||
|
magenta, bold_magenta, underline_magenta, bold_underline_magenta, on_magenta, on_bright_magenta,
|
||||||
|
cyan, bold_cyan, underline_cyan, bold_underline_cyan, on_cyan, on_bright_cyan,
|
||||||
|
white, bold_white, underline_white, bold_underline_white, on_white, on_bright_white
|
||||||
|
};
|
||||||
|
|
||||||
std::string colorName (Text::color);
|
std::string colorName (color);
|
||||||
Text::color colorCode (const std::string&);
|
color colorCode (const std::string&);
|
||||||
|
|
||||||
std::string attrName (Text::attr);
|
std::string colorize (color, color, const std::string& string);
|
||||||
Text::attr attrCode (const std::string&);
|
std::string colorize (color, color);
|
||||||
|
std::string colorize ();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -15,14 +15,63 @@
|
|||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
static char* colors[] =
|
static char* colors[] =
|
||||||
{
|
{
|
||||||
|
"bold",
|
||||||
|
"underline",
|
||||||
|
"bold_underline",
|
||||||
|
|
||||||
"black",
|
"black",
|
||||||
"blue",
|
|
||||||
"red",
|
"red",
|
||||||
"green",
|
"green",
|
||||||
|
"yellow",
|
||||||
|
"blue",
|
||||||
"magenta",
|
"magenta",
|
||||||
"cyan",
|
"cyan",
|
||||||
"yellow",
|
|
||||||
"white",
|
"white",
|
||||||
|
|
||||||
|
"bold_black",
|
||||||
|
"bold_red",
|
||||||
|
"bold_green",
|
||||||
|
"bold_yellow",
|
||||||
|
"bold_blue",
|
||||||
|
"bold_magenta",
|
||||||
|
"bold_cyan",
|
||||||
|
"bold_white",
|
||||||
|
|
||||||
|
"underline_black",
|
||||||
|
"underline_red",
|
||||||
|
"underline_green",
|
||||||
|
"underline_yellow",
|
||||||
|
"underline_blue",
|
||||||
|
"underline_magenta",
|
||||||
|
"underline_cyan",
|
||||||
|
"underline_white",
|
||||||
|
|
||||||
|
"bold_underline_black",
|
||||||
|
"bold_underline_red",
|
||||||
|
"bold_underline_green",
|
||||||
|
"bold_underline_yellow",
|
||||||
|
"bold_underline_blue",
|
||||||
|
"bold_underline_magenta",
|
||||||
|
"bold_underline_cyan",
|
||||||
|
"bold_underline_white",
|
||||||
|
|
||||||
|
"on_black",
|
||||||
|
"on_red",
|
||||||
|
"on_green",
|
||||||
|
"on_yellow",
|
||||||
|
"on_blue",
|
||||||
|
"on_magenta",
|
||||||
|
"on_cyan",
|
||||||
|
"on_white",
|
||||||
|
|
||||||
|
"on_bright_black",
|
||||||
|
"on_bright_red",
|
||||||
|
"on_bright_green",
|
||||||
|
"on_bright_yellow",
|
||||||
|
"on_bright_blue",
|
||||||
|
"on_bright_magenta",
|
||||||
|
"on_bright_cyan",
|
||||||
|
"on_bright_white",
|
||||||
"",
|
"",
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -16,8 +16,8 @@ static std::map <std::string, Text::color> gsBg;
|
|||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// There are three supported variants:
|
// There are three supported variants:
|
||||||
// 1) "fg"
|
// 1) "fg"
|
||||||
// 2) "on bg"
|
// 2) "bg"
|
||||||
// 3) "fg on bg"
|
// 3) "fg bg"
|
||||||
static void parseColorRule (
|
static void parseColorRule (
|
||||||
const std::string& rule,
|
const std::string& rule,
|
||||||
Text::color& fg,
|
Text::color& fg,
|
||||||
@@ -25,41 +25,18 @@ static void parseColorRule (
|
|||||||
{
|
{
|
||||||
fg = Text::nocolor;
|
fg = Text::nocolor;
|
||||||
bg = Text::nocolor;
|
bg = Text::nocolor;
|
||||||
bool error = false;
|
|
||||||
|
|
||||||
std::vector <std::string> words;
|
std::vector <std::string> words;
|
||||||
split (words, rule, ' ');
|
split (words, rule, ' ');
|
||||||
switch (words.size ())
|
|
||||||
|
std::vector <std::string>::iterator it;
|
||||||
|
for (it = words.begin (); it != words.end (); ++it)
|
||||||
{
|
{
|
||||||
case 1: // "fg" - no spaces.
|
if (it->substr (0, 3) == "on_")
|
||||||
fg = Text::colorCode (words[0]);
|
bg = Text::colorCode (*it);
|
||||||
break;
|
|
||||||
|
|
||||||
case 2: // "on bg" - one space, "on" before.
|
|
||||||
if (words[0] == "on")
|
|
||||||
bg = Text::colorCode (words[1]);
|
|
||||||
else
|
else
|
||||||
error = true;
|
fg = Text::colorCode (*it);
|
||||||
break;
|
|
||||||
|
|
||||||
case 3: // "fg on bg" - two spaces, "on" between them.
|
|
||||||
if (words[1] == "on")
|
|
||||||
{
|
|
||||||
fg = Text::colorCode (words[0]);
|
|
||||||
bg = Text::colorCode (words[2]);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
error = true;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 0:
|
|
||||||
default:
|
|
||||||
error = true;
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (error)
|
|
||||||
std::cout << "Malformed color rule '" << rule << "'" << std::endl;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|||||||
25
src/task.cpp
25
src/task.cpp
@@ -1,5 +1,5 @@
|
|||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// Copyright 2006 - 2008 Paul Beckingham.
|
// Copyright 2006 - 2008, Paul Beckingham.
|
||||||
// All rights reserved.
|
// All rights reserved.
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
@@ -38,9 +38,9 @@ void usage (Config& conf)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
table.addColumn ("");
|
table.addColumn (" ");
|
||||||
table.addColumn ("");
|
table.addColumn (" ");
|
||||||
table.addColumn ("");
|
table.addColumn (" ");
|
||||||
|
|
||||||
table.setColumnJustification (0, Table::left);
|
table.setColumnJustification (0, Table::left);
|
||||||
table.setColumnJustification (1, Table::left);
|
table.setColumnJustification (1, Table::left);
|
||||||
@@ -180,11 +180,13 @@ void usage (Config& conf)
|
|||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
int main (int argc, char** argv)
|
int main (int argc, char** argv)
|
||||||
{
|
{
|
||||||
|
// TODO Find out what this is, and either promote it to live code, or remove it.
|
||||||
// std::set_terminate (__gnu_cxx::__verbose_terminate_handler);
|
// std::set_terminate (__gnu_cxx::__verbose_terminate_handler);
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// Load the config file from the home directory.
|
// Load the config file from the home directory. If the file cannot be
|
||||||
|
// found, offer to create a sample one.
|
||||||
Config conf;
|
Config conf;
|
||||||
struct passwd* pw = getpwuid (getuid ());
|
struct passwd* pw = getpwuid (getuid ());
|
||||||
if (!pw)
|
if (!pw)
|
||||||
@@ -192,7 +194,8 @@ int main (int argc, char** argv)
|
|||||||
|
|
||||||
std::string home = pw->pw_dir;
|
std::string home = pw->pw_dir;
|
||||||
home += "/.taskrc";
|
home += "/.taskrc";
|
||||||
conf.load (home);
|
if (!conf.load (home))
|
||||||
|
conf.createDefault (home);
|
||||||
|
|
||||||
TDB tdb;
|
TDB tdb;
|
||||||
tdb.dataDirectory (conf.get ("data.location"));
|
tdb.dataDirectory (conf.get ("data.location"));
|
||||||
@@ -492,7 +495,7 @@ void handleList (const TDB& tdb, T& task, Config& conf)
|
|||||||
|
|
||||||
// All criteria match, so add refTask to the output table.
|
// All criteria match, so add refTask to the output table.
|
||||||
int row = table.addRow ();
|
int row = table.addRow ();
|
||||||
table.addCell (row, 0, (int) i + 1);
|
table.addCell (row, 0, refTask.getId ());
|
||||||
table.addCell (row, 1, refTask.getAttribute ("project"));
|
table.addCell (row, 1, refTask.getAttribute ("project"));
|
||||||
table.addCell (row, 2, refTask.getAttribute ("priority"));
|
table.addCell (row, 2, refTask.getAttribute ("priority"));
|
||||||
table.addCell (row, 3, due);
|
table.addCell (row, 3, due);
|
||||||
@@ -665,7 +668,7 @@ void handleSmallList (const TDB& tdb, T& task, Config& conf)
|
|||||||
|
|
||||||
// All criteria match, so add refTask to the output table.
|
// All criteria match, so add refTask to the output table.
|
||||||
int row = table.addRow ();
|
int row = table.addRow ();
|
||||||
table.addCell (row, 0, (int) i + 1);
|
table.addCell (row, 0, refTask.getId ());
|
||||||
table.addCell (row, 1, refTask.getAttribute ("project"));
|
table.addCell (row, 1, refTask.getAttribute ("project"));
|
||||||
table.addCell (row, 2, refTask.getAttribute ("priority"));
|
table.addCell (row, 2, refTask.getAttribute ("priority"));
|
||||||
table.addCell (row, 3, refTask.getDescription ());
|
table.addCell (row, 3, refTask.getDescription ());
|
||||||
@@ -1159,7 +1162,7 @@ void handleLongList (const TDB& tdb, T& task, Config& conf)
|
|||||||
|
|
||||||
// All criteria match, so add refTask to the output table.
|
// All criteria match, so add refTask to the output table.
|
||||||
int row = table.addRow ();
|
int row = table.addRow ();
|
||||||
table.addCell (row, 0, (int) i + 1);
|
table.addCell (row, 0, refTask.getId ());
|
||||||
table.addCell (row, 1, refTask.getAttribute ("project"));
|
table.addCell (row, 1, refTask.getAttribute ("project"));
|
||||||
table.addCell (row, 2, refTask.getAttribute ("priority"));
|
table.addCell (row, 2, refTask.getAttribute ("priority"));
|
||||||
table.addCell (row, 3, entered);
|
table.addCell (row, 3, entered);
|
||||||
@@ -1980,7 +1983,7 @@ void handleReportActive (const TDB& tdb, T& task, Config& conf)
|
|||||||
|
|
||||||
// All criteria match, so add refTask to the output table.
|
// All criteria match, so add refTask to the output table.
|
||||||
int row = table.addRow ();
|
int row = table.addRow ();
|
||||||
table.addCell (row, 0, (int) i + 1);
|
table.addCell (row, 0, refTask.getId ());
|
||||||
table.addCell (row, 1, refTask.getAttribute ("project"));
|
table.addCell (row, 1, refTask.getAttribute ("project"));
|
||||||
table.addCell (row, 2, refTask.getAttribute ("priority"));
|
table.addCell (row, 2, refTask.getAttribute ("priority"));
|
||||||
table.addCell (row, 3, due);
|
table.addCell (row, 3, due);
|
||||||
@@ -2099,7 +2102,7 @@ void handleReportOverdue (const TDB& tdb, T& task, Config& conf)
|
|||||||
{
|
{
|
||||||
// All criteria match, so add refTask to the output table.
|
// All criteria match, so add refTask to the output table.
|
||||||
int row = table.addRow ();
|
int row = table.addRow ();
|
||||||
table.addCell (row, 0, (int) i + 1);
|
table.addCell (row, 0, refTask.getId ());
|
||||||
table.addCell (row, 1, refTask.getAttribute ("project"));
|
table.addCell (row, 1, refTask.getAttribute ("project"));
|
||||||
table.addCell (row, 2, refTask.getAttribute ("priority"));
|
table.addCell (row, 2, refTask.getAttribute ("priority"));
|
||||||
table.addCell (row, 3, due);
|
table.addCell (row, 3, due);
|
||||||
|
|||||||
@@ -1,24 +0,0 @@
|
|||||||
PROJECT = t.t tdb.t
|
|
||||||
CFLAGS = -I.. -I../../../library/include -Wall -pedantic -ggdb3 -fno-rtti
|
|
||||||
LFLAGS = -L/usr/local/lib -L../../../library/lib -lcompany -lpcre -lncurses -lcurl
|
|
||||||
|
|
||||||
all: $(PROJECT)
|
|
||||||
|
|
||||||
install: $(PROJECT)
|
|
||||||
@echo unimplemented
|
|
||||||
|
|
||||||
test: $(PROJECT)
|
|
||||||
@echo unimplemented
|
|
||||||
|
|
||||||
clean:
|
|
||||||
-rm *.o $(PROJECT)
|
|
||||||
|
|
||||||
.cpp.o:
|
|
||||||
g++ -c $(CFLAGS) $<
|
|
||||||
|
|
||||||
t.t: t.t.o ../T.o ../parse.o ../../../library/lib/libcompany.a
|
|
||||||
g++ t.t.o ../T.o ../parse.o $(LFLAGS) -o t.t
|
|
||||||
|
|
||||||
tdb.t: tdb.t.o ../TDB.o ../T.o ../parse.o ../../../library/lib/libcompany.a
|
|
||||||
g++ tdb.t.o ../TDB.o ../T.o ../parse.o $(LFLAGS) -o tdb.t
|
|
||||||
|
|
||||||
@@ -1,8 +1,9 @@
|
|||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
#include <T.h>
|
#include "../T.h"
|
||||||
#include <library.h>
|
#include "../task.h"
|
||||||
|
#include "test.h"
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
int main (int argc, char** argv)
|
int main (int argc, char** argv)
|
||||||
|
|||||||
@@ -4,8 +4,9 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#include <TDB.h>
|
#include "../TDB.h"
|
||||||
#include <library.h>
|
#include "../task.h"
|
||||||
|
#include "test.h"
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
int main (int argc, char** argv)
|
int main (int argc, char** argv)
|
||||||
@@ -116,10 +117,10 @@ int main (int argc, char** argv)
|
|||||||
return -2;
|
return -2;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
unlink ("./pending.data");
|
unlink ("./pending.data");
|
||||||
unlink ("./completed.data");
|
unlink ("./completed.data");
|
||||||
*/
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
254
src/tests/test.cpp
Normal file
254
src/tests/test.cpp
Normal file
@@ -0,0 +1,254 @@
|
|||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Copyright 2007, 2008, Paul Beckingham. All rights reserved.
|
||||||
|
//
|
||||||
|
//
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
#include <iostream>
|
||||||
|
#include <string>
|
||||||
|
#include <library.h>
|
||||||
|
|
||||||
|
static int total = 0;
|
||||||
|
static int counter = 0;
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
static void check (void)
|
||||||
|
{
|
||||||
|
if (counter > total)
|
||||||
|
std::cout << "# Warning: There are more tests than planned."
|
||||||
|
<< std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
void plan (int quantity)
|
||||||
|
{
|
||||||
|
total = quantity;
|
||||||
|
std::cout << "1.." << quantity << std::endl;
|
||||||
|
check ();
|
||||||
|
}
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
void ok (bool expression, const std::string& name)
|
||||||
|
{
|
||||||
|
++counter;
|
||||||
|
|
||||||
|
if (expression)
|
||||||
|
std::cout << "ok "
|
||||||
|
<< counter
|
||||||
|
<< " - "
|
||||||
|
<< name
|
||||||
|
<< std::endl;
|
||||||
|
else
|
||||||
|
std::cout << "not ok "
|
||||||
|
<< counter
|
||||||
|
<< " - "
|
||||||
|
<< name
|
||||||
|
<< std::endl;
|
||||||
|
check ();
|
||||||
|
}
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
void notok (bool expression, const std::string& name)
|
||||||
|
{
|
||||||
|
++counter;
|
||||||
|
|
||||||
|
if (!expression)
|
||||||
|
std::cout << "ok "
|
||||||
|
<< counter
|
||||||
|
<< " - "
|
||||||
|
<< name
|
||||||
|
<< std::endl;
|
||||||
|
else
|
||||||
|
std::cout << "not ok "
|
||||||
|
<< counter
|
||||||
|
<< " - "
|
||||||
|
<< name
|
||||||
|
<< std::endl;
|
||||||
|
check ();
|
||||||
|
}
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
void is (bool actual, bool expected, const std::string& name)
|
||||||
|
{
|
||||||
|
++counter;
|
||||||
|
if (actual == expected)
|
||||||
|
std::cout << "ok "
|
||||||
|
<< counter
|
||||||
|
<< " - "
|
||||||
|
<< name
|
||||||
|
<< std::endl;
|
||||||
|
else
|
||||||
|
std::cout << "not ok "
|
||||||
|
<< counter
|
||||||
|
<< " - "
|
||||||
|
<< name
|
||||||
|
<< std::endl
|
||||||
|
<< "# expected: "
|
||||||
|
<< expected
|
||||||
|
<< std::endl
|
||||||
|
<< "# got: "
|
||||||
|
<< actual
|
||||||
|
<< std::endl;
|
||||||
|
check ();
|
||||||
|
}
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
void is (size_t actual, size_t expected, const std::string& name)
|
||||||
|
{
|
||||||
|
++counter;
|
||||||
|
if (actual == expected)
|
||||||
|
std::cout << "ok "
|
||||||
|
<< counter
|
||||||
|
<< " - "
|
||||||
|
<< name
|
||||||
|
<< std::endl;
|
||||||
|
else
|
||||||
|
std::cout << "not ok "
|
||||||
|
<< counter
|
||||||
|
<< " - "
|
||||||
|
<< name
|
||||||
|
<< std::endl
|
||||||
|
<< "# expected: "
|
||||||
|
<< expected
|
||||||
|
<< std::endl
|
||||||
|
<< "# got: "
|
||||||
|
<< actual
|
||||||
|
<< std::endl;
|
||||||
|
check ();
|
||||||
|
}
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
void is (int actual, int expected, const std::string& name)
|
||||||
|
{
|
||||||
|
++counter;
|
||||||
|
if (actual == expected)
|
||||||
|
std::cout << "ok "
|
||||||
|
<< counter
|
||||||
|
<< " - "
|
||||||
|
<< name
|
||||||
|
<< std::endl;
|
||||||
|
else
|
||||||
|
std::cout << "not ok "
|
||||||
|
<< counter
|
||||||
|
<< " - "
|
||||||
|
<< name
|
||||||
|
<< std::endl
|
||||||
|
<< "# expected: "
|
||||||
|
<< expected
|
||||||
|
<< std::endl
|
||||||
|
<< "# got: "
|
||||||
|
<< actual
|
||||||
|
<< std::endl;
|
||||||
|
check ();
|
||||||
|
}
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
void is (double actual, double expected, const std::string& name)
|
||||||
|
{
|
||||||
|
++counter;
|
||||||
|
if (actual == expected)
|
||||||
|
std::cout << "ok "
|
||||||
|
<< counter
|
||||||
|
<< " - "
|
||||||
|
<< name
|
||||||
|
<< std::endl;
|
||||||
|
else
|
||||||
|
std::cout << "not ok "
|
||||||
|
<< counter
|
||||||
|
<< " - "
|
||||||
|
<< name
|
||||||
|
<< std::endl
|
||||||
|
<< "# expected: "
|
||||||
|
<< expected
|
||||||
|
<< std::endl
|
||||||
|
<< "# got: "
|
||||||
|
<< actual
|
||||||
|
<< std::endl;
|
||||||
|
check ();
|
||||||
|
}
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
void is (char actual, char expected, const std::string& name)
|
||||||
|
{
|
||||||
|
++counter;
|
||||||
|
if (actual == expected)
|
||||||
|
std::cout << "ok "
|
||||||
|
<< counter
|
||||||
|
<< " - "
|
||||||
|
<< name
|
||||||
|
<< std::endl;
|
||||||
|
else
|
||||||
|
std::cout << "not ok "
|
||||||
|
<< counter
|
||||||
|
<< " - "
|
||||||
|
<< name
|
||||||
|
<< std::endl
|
||||||
|
<< "# expected: "
|
||||||
|
<< expected
|
||||||
|
<< std::endl
|
||||||
|
<< "# got: "
|
||||||
|
<< actual
|
||||||
|
<< std::endl;
|
||||||
|
check ();
|
||||||
|
}
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
void is (
|
||||||
|
const std::string& actual,
|
||||||
|
const std::string& expected,
|
||||||
|
const std::string& name)
|
||||||
|
{
|
||||||
|
++counter;
|
||||||
|
if (actual == expected)
|
||||||
|
std::cout << "ok "
|
||||||
|
<< counter
|
||||||
|
<< " - "
|
||||||
|
<< name
|
||||||
|
<< std::endl;
|
||||||
|
else
|
||||||
|
std::cout << "not ok "
|
||||||
|
<< counter
|
||||||
|
<< " - "
|
||||||
|
<< name
|
||||||
|
<< std::endl
|
||||||
|
<< "# expected: '"
|
||||||
|
<< expected
|
||||||
|
<< "'"
|
||||||
|
<< std::endl
|
||||||
|
<< "# got: '"
|
||||||
|
<< actual
|
||||||
|
<< "'"
|
||||||
|
<< std::endl;
|
||||||
|
check ();
|
||||||
|
}
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
void diag (const std::string& text)
|
||||||
|
{
|
||||||
|
std::string trimmed = trim (text, " \t\n\r\f");
|
||||||
|
|
||||||
|
std::cout << "# " << trimmed << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
void pass (const std::string& text)
|
||||||
|
{
|
||||||
|
++counter;
|
||||||
|
std::cout << "ok "
|
||||||
|
<< counter
|
||||||
|
<< " "
|
||||||
|
<< text
|
||||||
|
<< std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
void fail (const std::string& text)
|
||||||
|
{
|
||||||
|
++counter;
|
||||||
|
std::cout << "not ok "
|
||||||
|
<< counter
|
||||||
|
<< " "
|
||||||
|
<< text
|
||||||
|
<< std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
24
src/tests/test.h
Normal file
24
src/tests/test.h
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Copyright 2007, 2008, Paul Beckingham. All rights reserved.
|
||||||
|
//
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
#ifndef INCLUDED_TEST
|
||||||
|
#define INCLUDED_TEST
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
void plan (int);
|
||||||
|
void ok (bool, const std::string&);
|
||||||
|
void notok (bool, const std::string&);
|
||||||
|
void is (bool, bool, const std::string&);
|
||||||
|
void is (int, int, const std::string&);
|
||||||
|
void is (size_t, size_t, const std::string&);
|
||||||
|
void is (double, double, const std::string&);
|
||||||
|
void is (char, char, const std::string&);
|
||||||
|
void is (const std::string&, const std::string&, const std::string&);
|
||||||
|
void diag (const std::string&);
|
||||||
|
void fail (const std::string&);
|
||||||
|
void pass (const std::string&);
|
||||||
|
|
||||||
|
#endif
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
Reference in New Issue
Block a user