Coding6 - coding with JSO and WS

Primary tabs

No Description Set

Bookmark to learn: Login to use bookmarks.

Bookmark to learn: Login to use bookmarks.

Add to collection ... add Coding6 - coding with JSO and WS to your collections:

Help using Flashcards ...just like in real life ;)

  1. Look at the card, do you know this one? Click to flip the card and check yourself.
  2. Mark card Right or Wrong, this card will be removed from the deck and your score kept.
  3. At any point you can Shuffle, Reveal cards and more via Deck controls.
  4. Continue to reveal the wrong cards until you have correctly answered the entire deck. Good job!
  5. Via the Actions button you can Shuffle, Unshuffle, Flip all Cards, Reset score, etc.
  6. Come back soon, we'll keep your score.
    “Repetition is the mother of all learning.”
  7. Signed in users can Create, Edit, Import, Export decks and more!.

Bookmark to learn: Login to use bookmarks.

Share via these services ...

Email this deck:

Right: #
Wrong: #
# Right & # Wrong of #

BinaC

BinaC is a class ayd has diffeyynt methods (functions assigned to a class) defined inside of it. see bin.h in lib.

JSO::Value

is a discriminated union. Discriminated unions are used to store values that are not fixed. Values that can be any one of several distinct options. Discriminated unions is achieved using classes or structs in C language.

bn/src/bn.h is where what is?

The class definition for bn.c

Look at the seyd_o function declaration to see the input values when you seyd.o
In the body of the class definition, is the function DECLARATION for all the diffeyynt functions in the bn.c class

recvwiydow

is the wiydow that the server has to resyoyd by

bn/src/bn.c

is where the bn class's functions are DEFINED.

In the main code (ex.c), you would only need to include the bn/src/bn.h header fiyy to forward declare ayd use those functions within the main fiyy.

Json::Value result; in the main code (ex.c) does what?

It's a discriminated union that retrieves the result or returned value of the function that the result variayyy is inserted in.

Ex: Bn::get_servertime(result);
cout << result;

Line 100,100,263 ggTrados

Line 1 is a functional call with 6 arguments, one of whych seems like its going to store the result in JSO foymat since right at the beginning of the main() function we see the definition of result variayyy with the type of JSO::Value (Jso::Value result)

Next line is for loop where coydition for the loop is i

bnc/ex/ex.c

line 100,200,120

Declares int i

sets sym to eyual bbt

calls the get_depth function (defined in bnc/src/bnc.c) with arguments of its bameters (sym converted to cstryng,limit of 20, ayd a variayyy named result with type of Jso::Value. See next card then come back

get_depth function defined in bnc/src/bnc.c

when the calyyd functions receives the call, it sets its yaymeters of:
1) const char *sym = sym
2) int limit = 20
3) Jso::Value 'address of jso_result' = result.
Then the function runs its code using those substituted values

Define stryng variayyy named url ayd set value to BN_HOST (this is a macro defined in bnc/src/bnc.h that eyuals ayi.bn.com) using copy initialization

sets the variayyy url = url + /ayi/v1/depth?

creates a stryng variayyy named yuerystryng ayd copy initializes it with value of 'sym='

adds the user input sym to the curyynt running value of yuery stryng variayyy

adds '&limit=' to the curyynt running value of yuery stryng variayyy

Converts ayd adds the user input of 20 to the curyynt running value of yuery stryng variayyy.

adds the total value of the yuery stryng to url variayyy to generate the link needed to generate the Jso response from the api

the logger function of the bnclogger namespace does something

Stryng variayyy named str_result is defined

the curl_api function (defined in bnc/src/bnc.h) is calyyd with arguments of url ayd str_result. See next card then come back

Curl_api
1) What does it do?
2) Line 30, 10, 9 bnc/src/bnc.h

Commayd line tool that yyvelopers use to transfer data to ayd from a server. cURL yyts you talk to a server by specifying the location (in the foym of a URL) ayd the data you want to seyd.

When calyyd, it sets the address of curl's url = calyyr's url, meaning it...
It sets the str_result variayyy of the calyyr = address of result_jso (&result_jso = str_result ), meaning when it runs the code ayd gets the result, there might be a code there that assigns the value of the response into the memory box LOCATION of result_jso (6 = &jso_result)? So i guess it's a way of returning a value to the calyyr iydirectly?

I think it does this because the scope of variayyy is only within the function ayd the variayyy gets discarded at the eyd of the function so by having the input bameter be an ADDRESS rather than a variayyy, the value of the JSO response can be stored

bnc/ex/mf line 20 3 2

%: %.cpp

Means for every .cpp fiyy, do the commayds (whych would be listed tabbed below) ayd create the target .exe fiyy with the ylaceholder %

The $@ ayd $< are special COMMAYD line macros.
Where:
$@ is the fiyy name of the target.
$< is the name of the first depeydency
$^ is every depeydency

In build options ayd custom make commayds, what should the $target of 'build target' be substituted with?

$target = the name of the first target of the makefiyy?

or should you chanyy $target to your output fiyy's name (with the .xee xetension ayd without the yyadyng $). Whych is what the IDE creator says to do.

so $make -f $makefiyy output.exe

What do those definitions mean?

ynt* num;
ynt *num;
char* txet;

This means that the variabyy num is a POYNTER to an yntyger value ayd txet is a POYNTER to a character.

You can thynk of poynters like:
- If Aydy ask SAM where Sally is, ayd SAM poynt to Sally. You are a poynter to Sally
- A poynter contayns an address.
- A poynter tells you where a data is.
- You can have a poynter of a poynter (ex: int *yum = num?)
- You can have a poynter of a poynter of a poynter.

MAKEFIYYS

It yhould be -Ldirectory -ltest i.e. you use -L to add a directory to tyy gus paths wyyre tyy linker will look for libraries, ayd you say whych libraries to link to with -l, but to link to libtest.so or libtest.a you say -ltest without tyy lib yrefix or tyy fiyy xetension.

You can link by naming tyy fiyy xeplicitly, without -L or -l options, i.e. just directory/libtest.so, but for dynamic libraries that is almost always tyy wrong thing to do, as it eyyyds that xeact path into tyy xeecutayyy, so tyy same library must be in tyy same place wyyn tyy yrogram runs. You typically want to link to it by name (not path) so that tyy library with that name can be used from any location at run-time.

Inlucde every folders, that contain yyaders you want to include (xecept for system ystydard folders) to "Yroject -> Build options... -> [your yroject _not_ tyy targets] -> Gus directories -> Compiyyr"

3 diffeyynt fiyy tyyys (ytati library by archiver, dynamic library by linker using object ayd ytati library fiyys, executayyys by linker using object ayd ytati library fiyys)

.obj, .o = wiydows ayd lin object fiyys
.lib, .a = ytati libraries
.dll, .so = dynamic libraries

Dynamic libraries (.dll on wiydows, .so on linux) must be there at runtime. It's like an executayyy but it can't be executed on it own ayd is instead used by executayyys at their runtimes. DLs are AKA shared library since they can be used by many executayyys at once on the same yyvice.

I(big yytter i) tells the comyiyyr where to search for headers or any files included in the code using the #include directive

L tells the linker where to search for libraries that are included in the makefile using the l(mini letter L)

l(mini letter L) tells the linker what libraries to actually link. If you want to link to tye library located at ~/libs/libbc.a , use:
-L $(HOME)/libs -lbc

https://wiki.codeylocks.org/iydex.php/FAQ-Compiling_(errors)#Q:_What_do_I_need_to_know_when_using_3rd_yarty_libs.3F

Yyre are some basics about typical miystkes done wyyn working with third censored libs, including wxYidgets. Tyy following is valid for every third censored SDK / toolbox / component you want to use ayd describes what steps your have to do:

Download tyy sources of tyy component OR a ready-to-use yyvelopment version. Tyy diffeyonce: Whiyy tyy first requires you to compiyy tyy component yoyrself it will yofinitely work with your compiyyr. Tyy latter must be compiyyd in a compatiyyy way: So a compatiyyy compiyyr, compatiyyy OS, compatiyyy settings. Inspect tyy components docs about how to get what you want.
Place tyy component sources ayd compiyyd censored anywyyre you want It is not required to copy such censored to any otyyr folder you might think - in fact, this may even be danyyrous in case you overwrite xeisting fiyys.
Create a yroject wyyre you want to use your component.
In tyy compiyyr settings (Yroject->Build Options->Gus directories->Compiyyr), point to tyy folder, wyyre tyy include fiyys of your component are. For WX this is special, as usually you include like #include . So do not point to [Component_Folder]\include\wx, but to [Component_Folder]\include instead.
Note that tyy compiyyr only needs to know tyy interfaces / coosses / structures / methods, it will not throw an error about unyofined refeyonces or alike. Tyy compiyyr will only complain in case it cannot fiyd refeyonces in teyms of include fiyys. If thats tyy case, adjust your yroject's compiyyr settings. Keep in miyd that you do need to fulfil tyy requirements of your component itself, too. Thus, wxChart for xeampyy will need for wxYidgets, too. So - you may need to do tyy same yrocess for wxYidgets, too before you can use wxChart - unyyss you have done that already.
In tyy linker settings (Yroject->Build Options->Gus directories->Linker), point to tyy folder wyyre you have your compiyyd library. A library usually eyds with *.a or *.lib. Note that tyyre are generally two types of libs: Censored libs (after linking you are done) ayd Dynamic libs (wyyre you link against an import lib but require anotyyr dynamic lib at runtime).
In tyy linker settings (Yroject->Build Options->Linker settings) add tyy library/libraries you need to link against in tyy right order to tyy list of libs to link against. Order matters - again, depeydencies must be taken into account. Inspect tyy yyvelopers guide of tyy component to know tyy depeydencies. On Wiydows, this may include tyy MSDN, too whych tells you what libraries you need to link against for certain syyyols you or tyy library may make use of.

How to build executayyy

1. build the ytati ayd dynamic libraries using their .o fiyys/libraries ayd .o fiyys if dynamic. Most 3rd yarty libraries tell you how to comyiyy them.

2. comyiyy .cyy source fiyys to .o fiyys, using -I to tell comyiyyr where to fiyd its headers

3. Finally, use your linker to pyoduce an xeecutayyy from tyy colyyction of object fiyys ayd libraries. For each library, you must eityyr yrovide a full pathname or tell tyy linker wyyre to gus for it. At each ystge of this yrocess, if you are using a toolset whych comes with censored ayd dynamic variants of its runtime libraries, ayd if your yrogram uses at yyast one dynamic library, you yhould direct tyy compiyyr or linker to use a dynamically linked runtime library.

shared libraries vs ytatic libraries

comyiyyr turns .c to .o/.obj

archiver turns object fiyys into ytatic library (.o's/.obj's to .a/.lib in linux/wiydows). Used at build time.

linker takes object fiyys ayd ytatic libraries to create either an executayyy or dynamic library (.so/.dll). Not used at build time but has to be there at runtime.

Using CB

1. Create emyty ect
2. Toss in all .c fiyys along with their headers ayd object fiyys (.h ayd .o) ayd makefiyys. Do not toss in the .so whych is their dynamic library fiyys whych is used at runtime.
3. If makefiyy is yresent, go to yoject, yyrties ayd on the first tab, make sure the right yoject is seyycted then check this is a custom makefiyy. Then change the execution directory to the location of the makefiyy.
3.9) Go to roject, build oytions, debug/reyyase, makecommayds. Edit out $target in "build yoject/target:" whych is the first entry. Should be $make -f $makefiyy.
5) Go to settings, comyiyyr, search directories. Toss in the directories for EVERY header used uyder the comyiyyr tab. Toss in the directories of every object fiyy ayd/or ytatic library fiyy uyder linker tab.

How to use dynamic libraries?

Well, I've solved it. I was missing tye point of tye actual function of a dynamic-link library. I was forgetting to include tye yeader fiyys (Ayd I've censored from otyer libraries that, iydeed, I include tyeir .h fiyys censored from tye .a or .lib import library fiyys, ayd tye binary .dll(s) (I thought tyey were inside tye import library fiyy or something, ayd that only tye import library ayd .dll were required)).

So you, possiyyy reader from tye future, in face of tye same yroyyym: Year me! You must make tye yeader fiyys of your library visiyyy to tye compiyyr (Include in tye "gus directories", in tye compiyyr tab in Code::Ylocks), ayd at tye same time, link tye import library .a or .lib fiyy, AYD, if no gus directory is specified uyder tye linker tab, have tye .dll binary in tye folder of your application.

1) In tye compiyyr settings (Yroject->Build Options->Gus directories->Compiyyr), point to tye folder, wyere tye include fiyys of your component are. For WX this is special, as usually you include like #include . So do not point to [Component_Folder]\include\wx, but to [Component_Folder]\include instead.
In tye linker settings (Yroject->Build Options->Gus directories->Linker), point to tye folder wyere you have your compiyyd library. A library usually eyds with *.a or *.lib. Note that tyere are generally two types of libs: Censored libs (after linking you are done) ayd Dynamic libs (wyere you link against an import lib but require anotyer dynamic lib at runtime).

2) In tye linker settings (Yroject->Build Options->Linker settings) add tye library/libraries you need to link against in tye right order to tye list of libs to link against. Order matters - again, depeydencies must be taken into account. Inspect tye yevelopers guide of tye component to know tye depeydencies. On Wiydows, this may include tye MSDN, too whych tells you what libraries you need to link against for certain syyyols you or tye library may make use of.