Sie sind auf Seite 1von 5

OhjyA C++ A Quick Guide

(Version 1 beta 5)

Ghasan Sabri Ahmed Al-Sakkaf


(I’ll learn from Al-Melh bazaar and exceed you!)
OhjyA Object Declaration

OhjyA object declaration is as follows:

OhjyA newOhjyA(Text To Encrypt or Decrypt, Password, Encrypt?,


Incomplete?, First Position, Second Position, First Value, Second
Value);

1. OhjyA is to call OhjyA object constructor.


2. newOhjyA (You can choose another name): is the name of the new OhjyA object.
Text To Encrypt or Decrypt (string format): No need to explain!
3. Password (string format): Shouldn’t contain non-numeric chars, e.g. “26271g”.
4. Encrypt? (bool format): ture to encrypt or false to decrypt.
5. Incomplete? (bool format): ture to delete elements if encryption / input
elements if decryption from / to Text, or false to escape deleting / inputting
elements.
6. First Position (int format, applicable just if Incomplete?=true): is the first
position you want to delete / input. Its range is from 1 to Text length multiplied by
two. If Text = “Hello”, then range is 1 to 10. First Position is preferred to be
from 1 to 5.
7. Second Position (int format, applicable just if Incomplete?=true): is the
second position you want to delete / input.
8. First Value (int format, applicable just if Incomplete?=true and
Encrypt?=false): the value of First Position to be inputted in the Text before
decrypting.
9. Second Value (int format, applicable just if Incomplete?=true and
Encrypt?=false): the value of Second Position to be inputted in the Text
before decrypting.

If error occurred, OhjyA (Using Command-Line Interface) will output it. So, you don’t
need to worry about crashes.
Accessing OhjyA Data

OhjyA defines a public OhjyAmember OhjyA::_getmember(string what_member)


member function to be used to get information about specific data. For instance, you’ve
already encrypted successfully, but where to get the encrypted data? (The same goes with
decryption)

Don’t you notice OhjyAmember? What the hell is this?!


Well, it’s a structure to hold data about specific member of OhjyA object. Let’s see its
definition and comments as in ‘OhjyAClass.h’:

struct OhjyAmember {

void *ptr;
// void because OhjyA members are with different types

short int looptime;


// Used if member is a numeric array telling you how many
elements inside it

string type;
// Stores member type in string format

};

So, _getmember() will return an OhjyAmember of what you asked for containing its
pointer in void *ptr type, you should then typecast it properly as you will see form the
next table. looptime will contain an integer indicating how many elements are in the
asked array (Applicable just for integer arrays). The type of member will be stored in
string type.
._getmember() returns table

Query (Not case sensitive) .ptr .looptime .type Notes

stringlength &stringLength 0 int

passwordlength &passwordLength 0 int

stringnumericarray stringNumericArray stringLength int

nextstringnumericarray nextStringNumericArray If encryption: int


2*stringLength,
or:
stringLength/2

passwordarray passwordArray passwordLength int

anotherstringnumericarray anotherStringNumericArray stringLength-2 int Applicable


just in
decryption

firstvalue &firstValue 0 int

secondValue &secondValue 0 int

realstring &realString 0 string

encryptedstring &encryptedString 0 string

string &_string 0 string

encryption / encrypt &encryption 0 bool

isincomplete &is_incomplete 0 bool

noerroe &no_error 0 bool

Note:
• Use “noerror” to check whether OhjyA encountered a problem or not.
• Most of these queries are set primarily for bug detecting in OhjyA 1 development,
so you may not need to use some of them.
A simple OhjyA C++ program

#include <iostream>
#include <string>

// Includes OhjyAC++. You should have both:


// 'OhjyAClass.h' and 'OhjyAClass.cpp' within
// your current project.
#include "OhjyAClass.h"
using namespace std;

string texttoencrypt;
string password;

int main() {

cout<<"Enter text: ";


getline(cin, texttoencrypt);

cout<<"Enter password: ";


getline(cin, password);

// Declaring OhjyA object with 'sample' name


OhjyA sample(texttoencrypt, password, true, false);

// New identifier of OhjyAmember


OhjyAmember encryptedstring;

// Stores data in 'encryptedstring'


encryptedstring = sample._getmember("encryptedstring");

// Declaring a new string pointer


string *strptr;

// Typecasting 'encryptedstring.ptr' into string pointer and store


it in 'strptr'
strptr = (string*)encryptedstring.ptr;

// Getting encrypted string from 'strptr' by dereferencing it;


'*strptr', and then
// output it to Command-Line Interface
cout<<"\nEncrypted string: "<<*strptr<<"\n";

cin.get();
return 0;
}

Das könnte Ihnen auch gefallen