Sponsored Content
Top Forums Programming C++ Returning enumerated type Post 302734329 by kristinu on Thursday 22nd of November 2012 01:14:00 AM
Old 11-22-2012
C++ Returning enumerated type

I am trying to create a function to return me the verbosity level, so I can call it
as follows

Code:
String  s = "normal";
Verbosity  log_level;
log_level = get_log_level(s);

I started a version in the last function but I am having trouble getting it to work.

Code:
#ifndef __VERBOSE_HH__
#define __VERBOSE_HH__

#include "string.hh"
#include "common.hh"

///////////////////////////////////////////////////////////////////////////////

/// \brief
/// sets the verbosity level.
/// \enum Verbose List of valid verbosity levels.

enum  Verbosity {
    none   = 0,
    low    = 1,
    normal = 2,
    medium = 3,
    high   = 4,
    full   = 5,
    diag   = 6
};

///////////////////////////////////////////////////////////////////////////////

/// \brief Sets the verbosity level defined by the user.
/// \param s String specifying the verbosity level.
/// \param vbLevel
/// \return bool Returns true if verbosity level is valid.

bool  get_log_level(
  String&  s,
  Verbosity&  log_level
) {

  if (s == String("none")) {
    log_level = none;
    return (true);

  } else if (s == String("low")) {
    log_level = low;
    return (true);

  } else if (s == String("medium")) {
    log_level = medium;
    return (true);

  } else if (s == String("high")) {
    log_level = high;
    return (true);

  } else if (s == String("full")) {
    log_level = full;
    return (true);

  } else if (s == String("diag")) {
    log_level = diag;
    return (true);

  } else {
    return (false);

  }

}

///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////

Verbosity&  get_log_level(
  String&  s
) {

  if (s == String("none")) {
//    log_level = none;
    return (none);

  } else if (s == String("low")) {
//    log_level = low;
    return (low);

  } else if (s == String("medium")) {
//    log_level = medium;
    return (medium);

  } else if (s == String("high")) {
//    log_level = high;
    return (high);

  } else if (s == String("full")) {
//    log_level = full;
    return (full);

  } else if (s == String("diag")) {
//    log_level = diag;
    return (diag);

  } else {
    return (normal);

  }

}

#endif

 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

String type to date type

Can one string type variable changed into the date type variable. (1 Reply)
Discussion started by: rinku
1 Replies

2. Programming

array type has incomplete element type

Dear colleagues, One of my friend have a problem with c code. While compiling a c program it displays a message like "array type has incomplete element type". Any body can provide a solution for it. Jaganadh.G (1 Reply)
Discussion started by: jaganadh
1 Replies

3. UNIX for Dummies Questions & Answers

FTP not returning CR

Hi all, I have a mainframe file which i am ftping to unix box. even though i have three records in my mainframe file the file on unix is coming as a single record. Can you help me out. Thanks, Hari (3 Replies)
Discussion started by: harikiranr
3 Replies

4. Shell Programming and Scripting

Returning the name of function used

Hi All In my script, I can call on several functions. I have a logging function that is called by any of these functions. What I would like is some way of identifying which function I am using and pass this to the log function as some parameter. Is there some built in command or way of... (3 Replies)
Discussion started by: kingpin2502
3 Replies

5. UNIX for Advanced & Expert Users

find -type d returning files as well as directories

Can anyone see why the following command returns all files and not just the directories as specified? find . -type d -exec ls -F {} \; Also tried find . -type d -name "*" -exec ls -F {} \; find . -type d -name "*" -exec ls -F '{}' \; -print Always returns all files :-\ OS is... (2 Replies)
Discussion started by: tuns99
2 Replies

6. Shell Programming and Scripting

Bash enumerated types

I have a variable, vbLevel and want to assign it to one of several values which are "none", "low", "medium", "high". Then I want to do something like if ; then ... fi (9 Replies)
Discussion started by: kristinu
9 Replies

7. Shell Programming and Scripting

Returning -ve value in a pattern

Dear Friends, I need your help once more. I want to write a simple select as follows select amount from books where sr=1234 However, if value of "Amount" is negative then it should print it as follows. "3000-" and not as "-3000" Can you help me in this? Waiting for reply Anu. (2 Replies)
Discussion started by: anushree.a
2 Replies

8. Shell Programming and Scripting

Script returning 0

hello i write a script which calculate free space but he always is 0 thats wrong with my script? getFileSystemPerformanceData() { if ; then if grep -q "Ubuntu" /etc/issue ; then CMD="df -lP | grep -v "\/home" | grep -v "\/dev/mapper/VolGroup-lv_root"" elif grep... (5 Replies)
Discussion started by: donatas1234
5 Replies

9. What is on Your Mind?

Returning to the forum

hey guys, Im back! I hadnt thought about yall in a long time. I was googling away this morning and found a solution I needed from unix.com. good to see yall are still here and going strong! Im working as a Bladelogic Automation Engineer and have been doing HP and BMC server automation... (0 Replies)
Discussion started by: Kelam_Magnus
0 Replies
ppmtosixel(1)						      General Commands Manual						     ppmtosixel(1)

NAME
ppmtosixel - convert a portable pixmap into DEC sixel format SYNOPSIS
ppmtosixel [-raw] [-margin] [ppmfile] DESCRIPTION
Reads a portable pixmap as input. Produces sixel commands (SIX) as output. The output is formatted for color printing, e.g. for a DEC LJ250 color inkjet printer. If RGB values from the PPM file do not have maxval=100, the RGB values are rescaled. A printer control header and a color assignment table begin the SIX file. Image data is written in a compressed format by default. A printer control footer ends the image file. OPTIONS
-raw If specified, each pixel will be explicitly described in the image file. If -raw is not specified, output will default to com- pressed format in which identical adjacent pixels are replaced by "repeat pixel" commands. A raw file is often an order of magni- tude larger than a compressed file and prints much slower. -margin If -margin is not specified, the image will be start at the left margin (of the window, paper, or whatever). If -margin is speci- fied, a 1.5 inch left margin will offset the image. PRINTING
Generally, sixel files must reach the printer unfiltered. Use the lpr -x option or cat filename > /dev/tty0?. BUGS
Upon rescaling, truncation of the least significant bits of RGB values may result in poor color conversion. If the original PPM maxval was greater than 100, rescaling also reduces the image depth. While the actual RGB values from the ppm file are more or less retained, the color palette of the LJ250 may not match the colors on your screen. This seems to be a printer limitation. SEE ALSO
ppm(5) AUTHOR
Copyright (C) 1991 by Rick Vinci. 26 April 1991 ppmtosixel(1)
All times are GMT -4. The time now is 01:11 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy