source: projects/punch-card/punch-card-editor/src/qpunchcard/codec.cc @ 44

Last change on this file since 44 was 44, checked in by sven, 14 years ago

Import of the Punch Card Editor Project.
This is a C++/Qt project (using qmake) that I've started this weekend.
Of course it's supposed to be released as open source.

I've tried to start with a clean (but now still empty, of course)
directory structure. There will come the sourcecode for a complete
AVR ATmega microcontroller punch card device controller, soon.
I'm planing to finish this editing program and to implement the
communication protocol (over TTY, using some platform indepentent library).
Unfortunately that will take some time (and I don't have much time
any more...)

-- Sven @ workstation

File size: 921 bytes
Line 
1#include "codec.h"
2
3#include "cardcodes.h"
4
5using namespace QPunchCard;
6
7Codec::Codec(const CodeTable* table, char illegal_character) : table(table), illegal_character(illegal_character) {
8        create_inverse();
9}
10
11void Codec::create_inverse() {
12        // Inverse Tabelle (ASCII -> Column-Tabelle) erstellen
13        int i;
14
15        if(!table) {
16                // uhh... miserable failure. Sehr schlecht.
17                // notbehelf:
18//              this->table = o29_code;
19        }
20
21        for(i = 0; i < 4096; i++) {
22                // Illegal characters setzen
23                inverse_table[i] = illegal_character;
24        }
25
26        for(i = ' '; i < '`'; i++) {
27                inverse_table[ table[i] ] = i;
28        }
29}
30
31Codec::Codec(const char* name, char illegal_character) : illegal_character(illegal_character) {
32        if(strcmp(name, "o29_code"))
33                table = o29_code;
34        else if(strcmp(name, "o26_ftn_code"))
35                table = o26_ftn_code;
36        else if(strcmp(name, "o26_comm_code"))
37                table = o26_comm_code;
38        // else => Exception schmeissen :-)
39
40        create_inverse();
41}
Note: See TracBrowser for help on using the repository browser.
© 2008 - 2013 technikum29 • Sven Köppel • Some rights reserved
Powered by Trac
Expect where otherwise noted, content on this site is licensed under a Creative Commons 3.0 License