[OPUS]

Rootname - A field object that stores the root name portion of a full file specification.


Availability:

This class is available for the OPUS Blackboard API. The initial OPUS 2.0 release is described here

Constructors:
Rootname( )
~Rootname( )

Methods:
operator%( ) override base class-- allow prepend/append support FILE_ACTION's
assign( ) override base class-- validate arg
clone( ) create copy of object
name( ) get field name

Description

The Rootname object stores the root portion of the full file specification for File_entry objects on the files blackboard. Only those characters allowed in a file rootname can be assigned to this object.

Derived from

Field

Example

  
    #include <iostream>
    #include "file_entry.h"
    #include "directory.h"
    #include "rootname.h"
    #include "extension.h"
    #include "dangle.h"
  
    using namespace std;
  
    // The following example demonstrates parsing of a full file
    // specification using a File_entry object and its Field's.
    int main(int argc, char* argv[])
    {
                                             // assign file spec.
       File_entry* fe = new File_entry("/home/opus/data_file.dat_done");
       cout << "File specification: " << fe->str() << endl;
  
       Field* f = new Directory;
       fe->get_field(f);                     // get path
       cout << "Directory is: " << f->ustr() << endl;
       delete f;
  
       f = new Rootname;
       fe->get_field(f);                     // get path
       cout << "Rootname is: " << f->ustr() << endl;
       delete f;
  
       f = new Extension;
       fe->get_field(f);                     // get path
       cout << "Extension is: " << f->ustr() << endl;
       delete f;
  
       f = new Dangle;
       fe->get_field(f);                     // get path
       cout << "Dangle is: " << f->ustr() << endl;
       delete f;
       delete fe;
  
       return 0;
    }
  

See Also:


Rootname::Rootname - The Rootname constructor.

Synopsis


Rootname::Rootname(
                   const string& s) // I - root name string

Rootname::Rootname(
                   const Rootname& abt) // I - initializer

Description

The constructo assigns the argument to the object after validating its format. Arguments must not contain characters that are not allowed in file names by the operating system.

Exceptions Thrown

Bad_val<string> - if the string contains invalid characters; Bad_val.arg contains the calling argument


Rootname::~Rootname - The Rootname destructor.

Synopsis


Rootname::~Rootname()

Description

This method destroys the object.

Exceptions Thrown

none


Rootname::operator% - Apply modifier to the object.

Synopsis


void Rootname::operator%(
                         Field* d) // I - modifier

Description

operator% does a character by character comparison between the string representation of this object and that of the argument. Any character that differs between the two is replaced in this object with the character in the argument. Padding is not considered significant unless the special Field::FORCEPAD character is used in the argument to force the replacement of the character at that position with the pad character. If the wildcard character, File_entry::DIFF_WILDCARD, is present as the first or last character in the argument's string value, it expands to the entire unpadded contents of this object's string representation at that position, and this object is assigned the resulting concatenation. If the argument string contains an Opus_env::FILE_ACTION_INDICATOR character, a File_action exception is thrown so that the desired task can be performed.

Returns

    A pointer to this object.

Exceptions Thrown

Type<Field*> - if the types don't match; Type.arg contains the calling argument
Bad_val<Field*> - if the wildcard is in the wrong place; Bad_val.arg contains the calling argument
File_action<string> - if a file action command should be executed; File_action.arg contains the FILE_ACTION command label

Example

  
    Rootname* mod = new Rootname("*_me");
    Rootname* rnm = new Rootname("read");
  
    // apply differences
    *rnm % mod; // rnm now contains "read_me"
  


Rootname::assign - Assign a string to the object.

Synopsis


void Rootname::assign(
                      const string& s) // I - string to assign from

Description

This methd overrides the base class implementation in order to check the rootname syntax. The string must not contain any characters in Os_specific::NON_DIR_BAD_CHARS.

Exceptions Thrown

Bad_val<string> - if the string contains invalid characters; Bad_val.arg contains the calling argument


Rootname::clone - Create a copy of the object.

Synopsis


Field* Rootname::clone() const

Description

This method creates a new Rootname object, initialized by this object, off the heap and returns a pointer to the new object. The client should delete the returned object when it is no longer needed.

Returns

    A pointer to the new Rootname object initialized by this object.

Exceptions Thrown

none


Rootname::name - Get the field name

Synopsis


string Rootname::name() const 

Description

This method returns the name of the field, "ROOTNAME".

Returns

    string field name

Exceptions Thrown

none


OPUS API index · STScI Home Page · Search · Topics · Index

Copyright © 1997-2000 The Association of Universities for Research in Astronomy, Inc. All Rights Reserved.


For more information, contact opushelp@stsci.edu

Last modified: 25 April 2000