A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://www.ncbi.nlm.nih.gov/IEB/ToolBox/CPP_DOC/doxyhtml/netcache__client__sample_8cpp_source.html below:

NCBI C++ ToolKit: src/sample/app/netcache/netcache_client_sample.cpp Source File

43  virtual void Init

(

void

);

44  virtual int Run

(

void

);

62

arg_desc->SetUsageContext(

64  "NetCacheAPI Sample"

);

66

arg_desc->AddOptionalKey(

69  "Load-balanced service name"

,

72

arg_desc->AddDefaultKey(

75  "The stream API to use"

,

78

arg_desc->SetConstraint(

111

cout <<

"\nPutData()/ReadData() example:"

<< endl;

121  string

message(

"The quick brown fox jumps over a lazy dog."

);

122  key

= nc_api.

PutData

(message.c_str(), message.size());

127  string

message(

"second message"

);

134  string

message(

"yet another message"

);

135

nc_api.

PutData

(

key

, message.c_str(), message.size());

136

cout <<

"Wrote: '"

<< message <<

"' to blob: "

<<

key

<< endl;

141  while

(

result

.ReadLine(blob_info)) {

143

cout << blob_info << endl;

153

cout <<

"Read: '"

<< message <<

"'"

<< endl;

165

cout <<

"\nPartRead() example:"

<< endl;

175  string

message(

"Just pretend this is a really huge blob, ok?"

);

176  key

= nc_api.

PutData

(message.c_str(), message.size());

177

cout <<

"Wrote: '"

<< message <<

"' to blob: "

<<

key

<< endl;

188  for

(

size_t offset

= 0; remaining > 0; ) {

191  static const size_t

kMaxReadSize = 10;

192  size_t

part_size =

min

(remaining, kMaxReadSize);

197

cout <<

"Read: '"

<< part <<

"'"

<< endl;

201

remaining -= part_size;

215

cout <<

"\nCreateOStream()/GetIStream() example:"

<< endl;

217

unique_ptr<CNetCacheAPI> nc_api_p;

220  if

(

GetArgs

()[

"service"

]) {

222  GetArgs

()[

"service"

].AsString(),

"ncapi_sample"

));

235

unique_ptr<CNcbiOstream> os(nc_api_p->CreateOStream(

key

,

237

*os <<

"line one\n"

;

238

*os <<

"line two\n"

;

239

*os <<

"line three"

<< endl;

240

cout <<

"Wrote three lines to blob: "

<<

key

<< endl;

251

unique_ptr<CNcbiIstream> is(nc_api_p->GetIStream(

key

));

255

cout <<

"Read word: '"

<< message <<

"'"

<< endl;

264

unique_ptr<CNcbiIstream> is(nc_api_p->GetIStream(

key

));

265

cout <<

"Read buffer: '"

<< is->rdbuf() <<

"'"

<< endl;

277

cout <<

"\nCompression example:"

<< endl;

287  string

message(

"The quick brown fox jumps over a lazy dog."

);

292

cout <<

"Wrote: '"

<< message <<

"' to blob: "

<<

key

<< endl;

302

getline(is_zip, message);

303

cout <<

"Read: '"

<< message <<

"'"

<< endl;

316

cout <<

"\nIWriter()/IReader() example:"

<< endl;

335  string

text1(

"just chars."

), text2(

"with a newline"

);

338

cout <<

"Wrote '"

<< text1

339

<<

"' and '"

<< text2 <<

"' to blob: "

<<

key

<< endl;

343  char data

[] =

"abcdefghij1234567890!@#"

;

344

writer->Write(

data

, strlen(

data

));

345

cout <<

"Wrote: '"

<<

data 346

<<

"' to blob: "

<<

key

<< endl;

359

unique_ptr<IReader> reader(nc_api.

GetReader

(

key

, &blob_size));

370

is >> text1 >> text2;

371

cout <<

"Read '"

<< text1

372

<<

"' and '"

<< text2 <<

"' from blob:"

<<

key

<< endl;

378  static const Uint8

kMyBufSize = 10;

379  char

my_buf[kMyBufSize + 1];

389

my_buf[bytes_read] =

'\0'

;

392

cout <<

"Read: '"

<< my_buf <<

"'"

<< endl;

Client API for NetCache server.

Note about the "buf_size" parameter for streams in this API.

virtual int Run(void)

Run the application.

void DemoIWriterIReader(void)

virtual void Init(void)

Initialize the application.

void DemoCompression(void)

void DemoPartialRead(void)

Writer-based output stream.

CZipStreamCompressor – zlib based compression stream processor.

CZipStreamDecompressor – zlib based decompression stream processor.

const CNcbiRegistry & GetConfig(void) const

Get the application's cached configuration parameters (read-only).

virtual const CArgs & GetArgs(void) const

Get parsed command line arguments.

int AppMain(int argc, const char *const *argv, const char *const *envp=0, EAppDiagStream diag=eDS_Default, const char *conf=NcbiEmptyCStr, const string &name=NcbiEmptyString)

Main function (entry point) for the NCBI application.

virtual void SetupArgDescriptions(CArgDescriptions *arg_desc)

Setup the command line argument descriptions.

const CNcbiArguments & GetArguments(void) const

Get the application's cached unprocessed command-line arguments.

@ eString

An arbitrary string.

@ eConstraint

Constraint is not inverted (taken as is)

@ fOwnReader

Delete the reader.

@ fOwnWriter

Delete the writer.

#define NCBI_USER_THROW(message)

Throw a quick-and-dirty runtime exception of type 'CException' with the given error message and error...

#define nc_blob_ttl

Blob life span in seconds.

CNcbiOstream * CreateOStream(string &key, const CNamedParameterList *optional=NULL)

Create a stream object for sending data to a blob.

size_t GetBlobSize(const string &blob_id, const CNamedParameterList *optional=NULL)

Returns the size of the BLOB identified by the "key" parameter.

void ReadPart(const string &key, size_t offset, size_t part_size, string &buffer, const CNamedParameterList *optional=NULL)

Read a part of the blob pointed to by "key" and store its contents in "buffer".

CNetServerMultilineCmdOutput GetBlobInfo(const string &blob_id, const CNamedParameterList *optional=NULL)

Return a CNetServerMultilineCmdOutput object for reading meta information about the specified blob.

string PutData(const void *buf, size_t size, const CNamedParameterList *optional=NULL)

Put BLOB to server.

CNcbiIstream * GetIStream(const string &key, size_t *blob_size=NULL, const CNamedParameterList *optional=NULL)

Create an istream object for reading blob data.

IReader * GetReader(const string &key, size_t *blob_size=NULL, const CNamedParameterList *optional=NULL)

Get a pointer to the IReader interface to read blob contents.

void ReadData(const string &key, string &buffer, const CNamedParameterList *optional=NULL)

Read the blob pointed to by "key" and store its contents in "buffer".

uint64_t Uint8

8-byte (64-bit) unsigned integer

ERW_Result

Result codes for I/O operations.

@ eRW_Success

Everything is okay, I/O completed.

static bool EqualNocase(const CTempString s1, SIZE_TYPE pos, SIZE_TYPE n, const char *s2)

Case-insensitive equality of a substring with another string.

const struct ncbi::grid::netcache::search::fields::KEY key

Defines the CNcbiApplication and CAppException classes for creating NCBI applications.

int NcbiSys_main(int argc, ncbi::TXChar *argv[])

static size_t read_size(CNcbiIstream &stream, const char *name)

Reader-writer based streams.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4