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
XtErrorMsg(3)						    XT COMPATIBILITY FUNCTIONS						     XtErrorMsg(3)

NAME
XtErrorMsg, XtSetErrorMsgHandler, XtWarningMsg, XtSetWarningMsgHandler - high-level error handlers SYNTAX
void XtErrorMsg(String name, String type, String class, String default, String *params, Cardinal *num_params); void XtSetErrorMsgHandler(XtErrorMsgHandler msg_handler); void XtSetWarningMsgHandler(XtErrorMsgHandler msg_handler); void XtWarningMsg(String name, String type, String class, String default, String *params, Cardinal *num_params); ARGUMENTS
class Specifies the resource class. default Specifies the default message to use. name Specifies the general kind of error. type Specifies the detailed name of the error. msg_handler Specifies the new fatal error procedure, which should not return or the nonfatal error procedure, which usually returns. num_params Specifies the number of values in the parameter list. params Specifies a pointer to a list of values to be stored in the message. DESCRIPTION
The XtErrorMsg function has been superceded by XtAppErrorMsg. The XtSetErrorMsgHandler function has been superceded by XtAppSetErrorMsgHandler. The XtSetWarningMsgHandler function has been superceded by XtAppSetWarningMsgHandler. The XtWarningMsg function has been superceded by XtAppWarningMsg SEE ALSO
XtAppErrorMsg(3Xt) X Toolkit Intrinsics - C Language Interface Xlib - C Language X Interface X Version 11 libXt 1.0.5 XtErrorMsg(3)
All times are GMT -4. The time now is 09:03 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy