Makefile.in
aclocal.m4
+autom4te.cache
configure
missing
ylwrap
m4
+.*.swp
Things to do:
=============
-- String: test cases for numerical conversion
- String: Implement String != regex operator
- String: index and rindex methods with String argument
- String: format operator % like in python
- String: split and join
- String: assign fstream objects to read and write a file
+- String: convert to and from std::sstream and std::string
- regex: throw an exception when contructing a regex returns an error
- date: test parser for invalid dates and syntax errors
- UTC: Convert to and from time_t, struct tm
-- Add classes: xml, configuration, amount
+- xml: Add access to attributes
-libacl (0.3-1) UNRELEASED; urgency=low
+libacl (0.3-1) testing; urgency=low
- * Initial release. (Closes: #XXXXXX)
+ * Initial release.
-- Arjen Baart <arjen@syros.andromeda.nl> Wed, 13 May 2020 08:14:10 +0200
--- /dev/null
+Files: *
+Copyright: 2002-2020 Arjen Baart <arjen@andromeda.nl>
+License: GPL-2+
+
+ This package is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+ .
+ This package is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+ .
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <https://www.gnu.org/licenses/>
+ .
+ On Debian systems, the complete text of the GNU General
+ Public License version 2 can be found in "/usr/share/common-licenses/GPL-2".
--- /dev/null
+diff-ignore = ".*"
html-local: manual.html
-#ps-local: manual.ps
+ps-local: manual.ps
-#txt: manual.txt
+txt: manual.txt
-#all: html txt ps
-all: html
+all: html txt ps
manual.html : $(XMLS) $(IMAGES)
- /usr/local/bin/xml2html manual.xml > manual.html
+ xml2html manual.xml > manual.html
-#manual.ps : $(XMLS) $(PICTURES)
-# xml2latex manual.xml > manual.tex
-# latex manual.tex
-# dvips -o manual.ps manual.dvi
+manual.ps : $(XMLS) $(PICTURES)
+ xml2latex manual.xml > manual.tex
+ latex manual.tex
+ dvips -o manual.ps manual.dvi
-#manual.pdf : $(XMLS) $(PICTURES)
-# xml2latex manual.xml > manual.tex
-# pdflatex manual.tex
+manual.pdf : $(XMLS) $(PICTURES)
+ xml2latex manual.xml > manual.tex
+ pdflatex manual.tex
-#manual.txt : $(XMLS)
-# xml2text manual.xml > manual.txt
+manual.txt : $(XMLS)
+ xml2text manual.xml > manual.txt
check:
# xmllint --noout --xinclude --loaddtd --noent --schema /usr/local/xslt/doc.xsd manual.xml
/* Numerical conversion */
+ String(int); // String x(12); x = "12"
String(long); // String x(12); x = "12"
String(unsigned long); // String x(12); x = "12"
- String(int); // String x(12); x = "12"
+
+ operator int()
+ {
+ return strtol(p->s, 0, 0);
+ }
+
operator long()
{
return strtol(p->s, 0, 0);
return strtod(p->s, 0);
}
- /* */
char& operator[](size_t i); // Individual character access
AM_CPPFLAGS = -I../src
LDADD = ../src/.libs/libACL.la
-check_PROGRAMS = string_assign string_basics string_compare string_cat string_modify string_shift string_substring string_regex \
+check_PROGRAMS = string_assign string_basics string_compare string_cat string_convert string_modify \
+ string_shift string_substring string_regex \
date_assign date_parse date_compare date_arithmetic date_attributes date_check_today \
hour_assign hour_parse hour_compare hour_arithmetic hour_check_now \
utc_assign utc_parse utc_compare utc_arithmetic utc_convert \
string_basics_SOURCES = string_basics.cpp
string_compare_SOURCES = string_compare.cpp
string_cat_SOURCES = string_cat.cpp
+string_convert_SOURCES = string_convert.cpp
string_modify_SOURCES = string_modify.cpp
string_shift_SOURCES = string_shift.cpp
string_substring_SOURCES = string_substring.cpp
configuration_read_SOURCES = configuration_read.cpp
configuration_find_SOURCES = configuration_find.cpp
+
+clean-local:
+ rm -f xml_test01.out.xml
--- /dev/null
+/*******************************************************
+ * Unit test for the String class
+ *
+ * test conversion operations
+ ******************************************************
+ *
+ */
+
+#include "String.h"
+#include <assert.h>
+
+int main()
+{
+
+ // Construct a string from a number
+
+ String s1(12);
+
+ std::cout << s1 << " is contructed from the number 12\n";
+ assert(s1 == "12");
+
+ String s2(2.32);
+
+ std::cout << s2 << " is contructed from the number 2.32\n";
+ assert(s2 == "2.320");
+
+ int n;
+ double f;
+
+ String s3("42");
+ n = int(s3);
+ std::cout << "String " << s3 << " converts into number " << n << "\n";
+ assert(n == 42);
+
+ String s4("3.1415");
+ f = double(s4);
+ std::cout << "String " << s4 << " converts into number " << f << "\n";
+ assert(f == 3.1415);
+
+ int k;
+ double x;
+
+ String s5("not a number");
+ k = int(s5);
+ std::cout << "String " << s5 << " converts into number " << k << "\n";
+ assert(k == 0);
+
+ x = double(s5);
+ std::cout << "String " << s5 << " converts into number " << x << "\n";
+ assert(x == 0.0);
+
+ return 0;
+}
+
--- /dev/null
+12 is contructed from the number 12
+2.320 is contructed from the number 2.32
+String 42 converts into number 42
+String 3.1415 converts into number 3.1415
+String not a number converts into number 0
+String not a number converts into number 0
+PASS string_convert (exit status: 0)
String s1 = "abcdefghij";
- String s2 = s1 << 3;
+ String s2 = s1 << 0;
+ std::cout << s1 << " << 0 = " << s2 << "\n";
+ assert(s2 == "abcdefghij");
+
+ s2 = s1 << 3;
std::cout << s1 << " << 3 = " << s2 << "\n";
assert(s2 == "defghij");
- String s3 = s1 >> 3;
+ String s3 = s1 >> 0;
+ std::cout << s1 << " >> 0 = " << s3 << "\n";
+ assert(s3 == "abcdefghij");
+
+ s3 = s1 >> 3;
std::cout << s1 << " >> 3 = " << s3 << "\n";
assert(s3 == "abcdefg");
std::cout << s5 << "\n";
assert(s5 == "abcde");
+ // Shift an empty string
+
+ String s6, s7;
+ s7 = s6 << 4;
+ std::cout << "Shift left an empty string: \"" << s7 << "\"\n";
+ assert(s7 == "");
+
+ String s8, s9;
+ s9 = s8 >> 4;
+ std::cout << "Shift right an empty string: \"" << s9 << "\"\n";
+ assert(s9 == "");
+
+ // Shift more then the string length
+
+ String s10 = "abcdefghji";
+ String s11, s12;
+
+ s11 = s10 << 42;
+ std::cout << s10 << " << 42 = \"" << s11 << "\"\n";
+ assert(s11 == "");
+
+ s12 = s10 >> 42;
+ std::cout << s10 << " >> 42 = \"" << s12 << "\"\n";
+ assert(s12 == "");
+
return 0;
}
+abcdefghij << 0 = abcdefghij
abcdefghij << 3 = defghij
+abcdefghij >> 0 = abcdefghij
abcdefghij >> 3 = abcdefg
abcdefghij <<= 5 : fghij
abcdefghij >>= 5 : abcde
+Shift left an empty string: ""
+Shift right an empty string: ""
+abcdefghji << 42 = ""
+abcdefghji >> 42 = ""
PASS string_shift (exit status: 0)