Write a C++ program called opts.cc
that behaves as mf.cc
from
HW2, except that it accepts a properties file and command-line
options. These options determine which properties to emit. Unlike
HW2, the property counts are labeled with the two-letter
abbreviation for the property (e.g., Lu
) and not the words (e.g.,
Letter, uppercase
). This means that you have to pay attention to
both characters of the property.
                
The properties file is no longer necessarily
~cs253/pub/ASCII-properties
.
The name of a similar file is a new, required, first (after options)
argument. It may have fewer lines than ASCII-properties
did.
It may not describe all possible characters, and may not be in order.
                
For example, here is a properties file that only describes hexadecimal
chars (0–9, A–F) space, and newline. Its property names are different
than those in ASCII-properties
. It is available in
~cs253/pub/hex-props
.
                
41 Le 42 Le 43 Le 44 Le 45 Le 46 Le 30 Di 31 Di 32 Di 33 Di 34 Di 35 Di 36 Di 37 Di 38 Di 39 Di 20 Sp 0A Nl
Note the completely different properties in that file:
The options are the properties from the second field in the properties
file. For example, if Cc
, Lu
, and Nd
are all properties,
then -Cc
, -Lu
, and -Nd
are valid options. The actual list
of valid properties must be read from the properties file at runtime.
                
There is one special option: -all
. It indicates that all property
counts from the properties file should be displayed.
                
Here are several sample runs. “%” is my prompt:                 
% g++ -Wall opts.cc % cat a This is "test data" for HW2. Don't <ignore> it! % cat b Wed Jan 4 14:53:50 MST 2017 % cat h A1B2C3 % ./a.out -Lu ~cs253/pub/ASCII-properties a b Lu: 9 % ./a.out -Sm -Ll ~cs253/pub/ASCII-properties a b Ll: 31 Sm: 2 % ./a.out -Zs -Lu -Sk ~cs253/pub/ASCII-properties b Lu: 5 Sk: 0 Zs: 6 % ./a.out -all ~cs253/pub/hex-props h Di: 3 Le: 3 Nl: 1 Sp: 0 % ./a.out -all ~cs253/pub/ASCII-properties a b Cc: 3 Ll: 31 Lu: 9 Nd: 12 Pc: 0 Pd: 0 Pe: 0 Po: 7 Ps: 0 Sc: 0 Sk: 0 Sm: 2 Zs: 13 % ./a.out -all ~cs253/pub/ASCII-properties ~cs253/pub/hamlet.txt Cc: 10412 Ll: 119683 Lu: 16350 Nd: 0 Pc: 0 Pd: 422 Pe: 261 Po: 7418 Ps: 261 Sc: 0 Sk: 0 Sm: 48 Zs: 27713 % ./a.out ~cs253/pub/ASCII-properties b -Zs ./a.out: can’t read -Zs
The requirements are the same as those for HW2, plus:                 
./a.out propfile b -Zs
should result in treating -Zs
as a
filename, which should generate an error message complaining
that it doesn’t exist (most likely).
-all
or one of the
properties from the property file), emit an error message, including
the offending argument.
A–Z
and then a–z
-Sm
and
-Ll
are specified, the Sm
count could be the first line, or
the second. We will sort the output of your program before
examining it.
If you have any questions about the requirements, ask. In the real world, your programming tasks will almost always be vague and incompletely specified. Same here.                 
Use web checkin, or Linux checkin:                 
~cs253/bin/checkin HW3 opts.cc
Turn in someone else’s work.                 
Modified: 2017-02-13T21:47                  User: Guest                  Check: HTML CSSEdit History Source |
Apply to CSU |
Contact CSU |
Disclaimer |
Equal Opportunity Colorado State University, Fort Collins, CO 80523 USA © 2015 Colorado State University |