18.04.2015 Views

ArcGIS Engine Developer Guide

ArcGIS Engine Developer Guide

ArcGIS Engine Developer Guide

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

BUILDING A COMMAND-LINE C++ APPLICATION<br />

This will have the same effect as typing “RasterSlope.exe<br />

C:\MyComputer\Rasters\RasterDataset tempslope” with command-line arguments<br />

at the command line.<br />

Processing the arguments<br />

The user provides the input and output file information for this application at<br />

runtime (either through the makefile or at the command line). To get the specifics<br />

of that information to use it in the program, some argument processing must be<br />

done.<br />

1. Create a new file, RasterSlope.h, in your text editor. Place the contents of the<br />

file in a #ifndef and #define section. Include a standard C++ header file so<br />

that information, such as a usage message, can be displayed to the user.<br />

#ifndef __RASTERSLOPE_ESRISCENARIO_h__<br />

#define __RASTERSLOPE_ESRISCENARIO_h__<br />

#include <br />

#endif // __RASTERSLOPE_ESRISCENARIO_h__<br />

2. In another new file, RasterSlope.cpp, begin implementing your slope application.<br />

First include the header file you created in the last step. Then start writing<br />

the main function. For now, just process the arguments in it. Make sure the<br />

correct number of arguments was entered, else print out a usage message and<br />

exit. Since the first argument will be the program name, it can be ignored. The<br />

second argument is the input data, and the third is the resulting slope file. You<br />

will check if the arguments passed are valid later in the program’s execution.<br />

#include "RasterSlope.h"<br />

There are three ways to scope members in a<br />

namespace. The following are examples of each<br />

using cerr, a member of namespace std:<br />

1. using namespace std;<br />

2. using std::cerr;<br />

3. std::cerr

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!