version 1.7, 2003/09/04 20:49:52
|
version 1.15, 2005/05/30 13:43:49
|
|
|
//%///////////////////////////////////////////////////////////////////////////// |
//%2005//////////////////////////////////////////////////////////////////////// |
// | // |
// Copyright (c) 2000, 2001, 2002 BMC Software, Hewlett-Packard Company, IBM, |
// Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development |
// The Open Group, Tivoli Systems |
// Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems. |
|
// Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L.P.; |
|
// IBM Corp.; EMC Corporation, The Open Group. |
|
// Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.; |
|
// IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group. |
|
// Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.; |
|
// EMC Corporation; VERITAS Software Corporation; The Open Group. |
// | // |
// Permission is hereby granted, free of charge, to any person obtaining a copy | // Permission is hereby granted, free of charge, to any person obtaining a copy |
// of this software and associated documentation files (the "Software"), to | // of this software and associated documentation files (the "Software"), to |
|
|
// | // |
// Author: Humberto Rivero (hurivero@us.ibm.com) | // Author: Humberto Rivero (hurivero@us.ibm.com) |
// | // |
// Modified By: |
// Modified By: Aruran, IBM (ashanmug@in.ibm.com) for Bug# 3697, 3698, 3699, 3700 |
// | // |
//%///////////////////////////////////////////////////////////////////////////// | //%///////////////////////////////////////////////////////////////////////////// |
| |
|
|
| |
const LanguageParser LanguageParser::EMPTY = LanguageParser(); | const LanguageParser LanguageParser::EMPTY = LanguageParser(); |
| |
void LanguageParser::parseHdr(Array<String> &values, String & hdr){ |
void LanguageParser::parseHdr(Array<String> &values, String hdr){ |
// look for ',' which designates distict (Accept/Content)-Language fields | // look for ',' which designates distict (Accept/Content)-Language fields |
// the form: [languagetag, languagetag, languagetag] so whitespace removal | // the form: [languagetag, languagetag, languagetag] so whitespace removal |
// may be necessary. | // may be necessary. |
|
|
PEG_METHOD_EXIT(); | PEG_METHOD_EXIT(); |
} | } |
| |
Real32 LanguageParser::parseAcceptLanguageValue(String &language_tag, String & hdr){ |
Real32 LanguageParser::parseAcceptLanguageValue(String &language_tag, String hdr){ |
// look for ';' in hdr, that means we have a quality value to capture | // look for ';' in hdr, that means we have a quality value to capture |
// if not, we only have a language | // if not, we only have a language |
| |
|
|
return quality; | return quality; |
} | } |
| |
String LanguageParser::parseContentLanguageValue(String & hdr){ |
String LanguageParser::parseContentLanguageValue(const String& hdr){ |
// we are looking for the language part of the hdr only, | // we are looking for the language part of the hdr only, |
// according to the RFC, there may be parenthesized strings | // according to the RFC, there may be parenthesized strings |
// that describe the purpose of the language, we need to ignore those | // that describe the purpose of the language, we need to ignore those |
|
|
return value; | return value; |
} | } |
| |
String LanguageParser::getLanguage(String & language_tag){ |
String LanguageParser::getLanguage(const String & language_tag){ |
// given a language_tag: en-US-mn we want to return "en" | // given a language_tag: en-US-mn we want to return "en" |
Uint32 i; | Uint32 i; |
if((i = language_tag.find(findSeparator(language_tag.getCString()))) != PEG_NOT_FOUND) | if((i = language_tag.find(findSeparator(language_tag.getCString()))) != PEG_NOT_FOUND) |
|
|
return String(language_tag); | return String(language_tag); |
} | } |
| |
String LanguageParser::getCountry(String & language_tag){ |
String LanguageParser::getCountry(const String & language_tag){ |
// given a language_tag: en-US-mn we want to return "US" | // given a language_tag: en-US-mn we want to return "US" |
Uint32 i,j; | Uint32 i,j; |
if( (i = language_tag.find(findSeparator(language_tag.getCString()))) != PEG_NOT_FOUND ) | if( (i = language_tag.find(findSeparator(language_tag.getCString()))) != PEG_NOT_FOUND ) |
|
|
return String::EMPTY; | return String::EMPTY; |
} | } |
| |
String LanguageParser::getVariant(String & language_tag){ |
String LanguageParser::getVariant(const String & language_tag){ |
// given a language_tag: en-US-mn we want to return "mn" | // given a language_tag: en-US-mn we want to return "mn" |
Uint32 i; | Uint32 i; |
if( (i = language_tag.find(findSeparator(language_tag.getCString()))) != PEG_NOT_FOUND ) | if( (i = language_tag.find(findSeparator(language_tag.getCString()))) != PEG_NOT_FOUND ) |